fix(wayland): remove unwraps
This commit is contained in:
@@ -216,7 +216,9 @@ fn main() {
|
|||||||
);
|
);
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(feature = "wayland")]
|
||||||
{
|
{
|
||||||
startup_command.env("WAYLAND_DISPLAY", &wayland.socket_name);
|
if let Some(wayland_socket) = wayland.socket_name.as_ref() {
|
||||||
|
startup_command.env("WAYLAND_DISPLAY", &wayland_socket);
|
||||||
|
}
|
||||||
#[cfg(feature = "xwayland")]
|
#[cfg(feature = "xwayland")]
|
||||||
startup_command.env("DISPLAY", format!(":{}", wayland.xwayland_state.display));
|
startup_command.env("DISPLAY", format!(":{}", wayland.xwayland_state.display));
|
||||||
startup_command.env("GDK_BACKEND", "wayland");
|
startup_command.env("GDK_BACKEND", "wayland");
|
||||||
|
|||||||
@@ -25,11 +25,9 @@ impl CompositorHandler for WaylandState {
|
|||||||
.data_map
|
.data_map
|
||||||
.insert_if_missing_threadsafe(|| AtomicU32::new(0));
|
.insert_if_missing_threadsafe(|| AtomicU32::new(0));
|
||||||
if !count_new {
|
if !count_new {
|
||||||
count = data
|
if let Some(stored_count) = data.data_map.get::<AtomicU32>() {
|
||||||
.data_map
|
count = stored_count.fetch_add(1, Ordering::Relaxed);
|
||||||
.get::<AtomicU32>()
|
}
|
||||||
.unwrap()
|
|
||||||
.fetch_add(1, Ordering::Relaxed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data.data_map.get::<Arc<CoreSurface>>().cloned()
|
data.data_map.get::<Arc<CoreSurface>>().cloned()
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ impl KdeDecorationHandler for WaylandState {
|
|||||||
decoration: &OrgKdeKwinServerDecoration,
|
decoration: &OrgKdeKwinServerDecoration,
|
||||||
mode: WEnum<KdeMode>,
|
mode: WEnum<KdeMode>,
|
||||||
) {
|
) {
|
||||||
decoration.mode(mode.into_result().unwrap());
|
let Ok(mode) = mode.into_result() else {return};
|
||||||
|
decoration.mode(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delegate_kde_decoration!(WaylandState);
|
delegate_kde_decoration!(WaylandState);
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ use smithay::backend::renderer::gles::GlesRenderer;
|
|||||||
use smithay::backend::renderer::ImportDma;
|
use smithay::backend::renderer::ImportDma;
|
||||||
use smithay::reexports::wayland_server::backend::ClientId;
|
use smithay::reexports::wayland_server::backend::ClientId;
|
||||||
use smithay::reexports::wayland_server::DisplayHandle;
|
use smithay::reexports::wayland_server::DisplayHandle;
|
||||||
use smithay::reexports::wayland_server::{backend::GlobalId, Display, ListeningSocket};
|
use smithay::reexports::wayland_server::{Display, ListeningSocket};
|
||||||
|
use std::ffi::OsStr;
|
||||||
use std::os::fd::OwnedFd;
|
use std::os::fd::OwnedFd;
|
||||||
use std::os::unix::prelude::AsRawFd;
|
use std::os::unix::prelude::AsRawFd;
|
||||||
use std::{
|
use std::{
|
||||||
@@ -36,7 +37,7 @@ use tokio::sync::mpsc::UnboundedReceiver;
|
|||||||
use tokio::{
|
use tokio::{
|
||||||
io::unix::AsyncFd, net::UnixListener as AsyncUnixListener, sync::mpsc, task::JoinHandle,
|
io::unix::AsyncFd, net::UnixListener as AsyncUnixListener, sync::mpsc, task::JoinHandle,
|
||||||
};
|
};
|
||||||
use tracing::{debug, debug_span, info, instrument};
|
use tracing::{debug_span, info, instrument};
|
||||||
|
|
||||||
pub static WAYLAND_DISPLAY: OnceCell<String> = OnceCell::new();
|
pub static WAYLAND_DISPLAY: OnceCell<String> = OnceCell::new();
|
||||||
pub static SERIAL_COUNTER: CounterU32 = CounterU32::new(0);
|
pub static SERIAL_COUNTER: CounterU32 = CounterU32::new(0);
|
||||||
@@ -62,8 +63,6 @@ fn get_sk_egl() -> Result<EGLRawHandles> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLOBAL_DESTROY_QUEUE: OnceCell<mpsc::Sender<GlobalId>> = OnceCell::new();
|
|
||||||
|
|
||||||
pub struct DisplayWrapper(Mutex<Display<WaylandState>>, DisplayHandle);
|
pub struct DisplayWrapper(Mutex<Display<WaylandState>>, DisplayHandle);
|
||||||
impl DisplayWrapper {
|
impl DisplayWrapper {
|
||||||
pub fn handle(&self) -> DisplayHandle {
|
pub fn handle(&self) -> DisplayHandle {
|
||||||
@@ -84,7 +83,7 @@ impl DisplayWrapper {
|
|||||||
|
|
||||||
pub struct Wayland {
|
pub struct Wayland {
|
||||||
display: Arc<DisplayWrapper>,
|
display: Arc<DisplayWrapper>,
|
||||||
pub socket_name: String,
|
pub socket_name: Option<String>,
|
||||||
join_handle: JoinHandle<Result<()>>,
|
join_handle: JoinHandle<Result<()>>,
|
||||||
renderer: GlesRenderer,
|
renderer: GlesRenderer,
|
||||||
dmabuf_rx: UnboundedReceiver<Dmabuf>,
|
dmabuf_rx: UnboundedReceiver<Dmabuf>,
|
||||||
@@ -112,22 +111,17 @@ impl Wayland {
|
|||||||
let xwayland_state = xwayland::XWaylandState::create(&display_handle)?;
|
let xwayland_state = xwayland::XWaylandState::create(&display_handle)?;
|
||||||
let wayland_state = WaylandState::new(display_handle, &renderer, dmabuf_tx);
|
let wayland_state = WaylandState::new(display_handle, &renderer, dmabuf_tx);
|
||||||
|
|
||||||
let (global_destroy_queue_in, global_destroy_queue) = mpsc::channel(8);
|
|
||||||
GLOBAL_DESTROY_QUEUE.set(global_destroy_queue_in).unwrap();
|
|
||||||
|
|
||||||
let socket = ListeningSocket::bind_auto("wayland", 0..33)?;
|
let socket = ListeningSocket::bind_auto("wayland", 0..33)?;
|
||||||
let socket_name = socket.socket_name().unwrap().to_str().unwrap().to_string();
|
let socket_name = socket
|
||||||
WAYLAND_DISPLAY
|
.socket_name()
|
||||||
.set(socket_name.clone())
|
.and_then(OsStr::to_str)
|
||||||
.expect("seriously message nova this time they screwed up big time");
|
.map(ToString::to_string);
|
||||||
|
if let Some(socket_name) = &socket_name {
|
||||||
|
let _ = WAYLAND_DISPLAY.set(socket_name.clone());
|
||||||
|
}
|
||||||
info!(socket_name, "Wayland active");
|
info!(socket_name, "Wayland active");
|
||||||
|
|
||||||
let join_handle = Wayland::start_loop(
|
let join_handle = Wayland::start_loop(display.clone(), socket, wayland_state.clone())?;
|
||||||
display.clone(),
|
|
||||||
socket,
|
|
||||||
wayland_state.clone(),
|
|
||||||
global_destroy_queue,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(Wayland {
|
Ok(Wayland {
|
||||||
display,
|
display,
|
||||||
@@ -145,7 +139,6 @@ impl Wayland {
|
|||||||
display: Arc<DisplayWrapper>,
|
display: Arc<DisplayWrapper>,
|
||||||
socket: ListeningSocket,
|
socket: ListeningSocket,
|
||||||
state: Arc<Mutex<WaylandState>>,
|
state: Arc<Mutex<WaylandState>>,
|
||||||
mut global_destroy_queue: mpsc::Receiver<GlobalId>,
|
|
||||||
) -> Result<JoinHandle<Result<()>>> {
|
) -> Result<JoinHandle<Result<()>>> {
|
||||||
let listen_async =
|
let listen_async =
|
||||||
AsyncUnixListener::from_std(unsafe { UnixListener::from_raw_fd(socket.as_raw_fd()) })?;
|
AsyncUnixListener::from_std(unsafe { UnixListener::from_raw_fd(socket.as_raw_fd()) })?;
|
||||||
@@ -160,10 +153,6 @@ impl Wayland {
|
|||||||
let _socket = socket; // Keep the socket alive
|
let _socket = socket; // Keep the socket alive
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
e = global_destroy_queue.recv() => { // New global to destroy
|
|
||||||
debug!(?e, "destroy global");
|
|
||||||
dh1.remove_global::<WaylandState>(e.unwrap());
|
|
||||||
}
|
|
||||||
acc = listen_async.accept() => { // New client connected
|
acc = listen_async.accept() => { // New client connected
|
||||||
let (stream, _) = acc?;
|
let (stream, _) = acc?;
|
||||||
let client_state = Arc::new(ClientState {
|
let client_state = Arc::new(ClientState {
|
||||||
@@ -173,7 +162,7 @@ impl Wayland {
|
|||||||
seat: SeatData::new(&dh1)
|
seat: SeatData::new(&dh1)
|
||||||
});
|
});
|
||||||
let client = dh2.insert_client(stream.into_std()?, client_state.clone())?;
|
let client = dh2.insert_client(stream.into_std()?, client_state.clone())?;
|
||||||
client_state.seat.client.set(client.id()).unwrap();
|
let _ = client_state.seat.client.set(client.id());
|
||||||
}
|
}
|
||||||
e = dispatch_poll_listener.readable() => { // Dispatch
|
e = dispatch_poll_listener.readable() => { // Dispatch
|
||||||
let mut guard = e?;
|
let mut guard = e?;
|
||||||
@@ -211,7 +200,7 @@ impl Wayland {
|
|||||||
|
|
||||||
pub fn make_context_current(&self) {
|
pub fn make_context_current(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.renderer.egl_context().make_current().unwrap();
|
let _ = self.renderer.egl_context().make_current();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use super::{
|
use super::{
|
||||||
state::{ClientState, WaylandState},
|
state::{ClientState, WaylandState},
|
||||||
surface::CoreSurface,
|
surface::CoreSurface,
|
||||||
GLOBAL_DESTROY_QUEUE, SERIAL_COUNTER,
|
SERIAL_COUNTER,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
core::task,
|
core::task,
|
||||||
@@ -290,10 +290,9 @@ impl SeatData {
|
|||||||
touch: OnceCell::new(),
|
touch: OnceCell::new(),
|
||||||
});
|
});
|
||||||
|
|
||||||
seat_data
|
let _ = seat_data
|
||||||
.global_id
|
.global_id
|
||||||
.set(dh.create_global::<WaylandState, _, _>(7, seat_data.clone()))
|
.set(dh.create_global::<WaylandState, _, _>(7, seat_data.clone()));
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
seat_data
|
seat_data
|
||||||
}
|
}
|
||||||
@@ -420,14 +419,6 @@ impl SeatData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Drop for SeatData {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
let id = self.global_id.take().unwrap();
|
|
||||||
let _ = task::new(|| "global destroy queue garbage collection", async move {
|
|
||||||
GLOBAL_DESTROY_QUEUE.get().unwrap().send(id).await
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct CursorInfo {
|
pub struct CursorInfo {
|
||||||
pub surface: WlWeak<WlSurface>,
|
pub surface: WlWeak<WlSurface>,
|
||||||
|
|||||||
@@ -95,13 +95,9 @@ impl WaylandState {
|
|||||||
.cloned()
|
.cloned()
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let dmabuf_default_feedback = match render_node {
|
let dmabuf_default_feedback = match render_node {
|
||||||
Ok(Some(node)) => {
|
Ok(Some(node)) => DmabufFeedbackBuilder::new(node.dev_id(), dmabuf_formats.clone())
|
||||||
let dmabuf_default_feedback =
|
.build()
|
||||||
DmabufFeedbackBuilder::new(node.dev_id(), dmabuf_formats.clone())
|
.ok(),
|
||||||
.build()
|
|
||||||
.unwrap();
|
|
||||||
Some(dmabuf_default_feedback)
|
|
||||||
}
|
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
warn!("failed to query render node, dmabuf will use v3");
|
warn!("failed to query render node, dmabuf will use v3");
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ use smithay::{
|
|||||||
reexports::wayland_server::{self, protocol::wl_surface::WlSurface, DisplayHandle, Resource},
|
reexports::wayland_server::{self, protocol::wl_surface::WlSurface, DisplayHandle, Resource},
|
||||||
wayland::compositor::{self, SurfaceData},
|
wayland::compositor::{self, SurfaceData},
|
||||||
};
|
};
|
||||||
use std::{ffi::c_void, sync::Arc, time::Duration};
|
use std::{cell::RefCell, ffi::c_void, sync::Arc, time::Duration};
|
||||||
use stereokit::{
|
use stereokit::{
|
||||||
Material, StereoKitDraw, Tex, TextureAddress, TextureFormat, TextureSample, TextureType,
|
Material, Shader, StereoKitDraw, Tex, TextureAddress, TextureFormat, TextureSample,
|
||||||
Transparency,
|
TextureType, Transparency,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub static CORE_SURFACES: Registry<CoreSurface> = Registry::new();
|
pub static CORE_SURFACES: Registry<CoreSurface> = Registry::new();
|
||||||
@@ -89,12 +89,12 @@ impl CoreSurface {
|
|||||||
.sk_tex
|
.sk_tex
|
||||||
.get_or_init(|| sk.tex_create(TextureType::IMAGE_NO_MIPS, TextureFormat::RGBA32));
|
.get_or_init(|| sk.tex_create(TextureType::IMAGE_NO_MIPS, TextureFormat::RGBA32));
|
||||||
self.sk_mat.get_or_init(|| {
|
self.sk_mat.get_or_init(|| {
|
||||||
let shader = sk.shader_create_mem(&PANEL_SHADER_BYTES).unwrap();
|
let shader = sk.shader_create_mem(&PANEL_SHADER_BYTES);
|
||||||
// let _ = renderer.with_context(|c| unsafe {
|
// let _ = renderer.with_context(|c| unsafe {
|
||||||
// shader_inject(c, &mut shader, SIMULA_VERT_STR, SIMULA_FRAG_STR)
|
// shader_inject(c, &mut shader, SIMULA_VERT_STR, SIMULA_FRAG_STR)
|
||||||
// });
|
// });
|
||||||
|
|
||||||
let mat = sk.material_create(&shader);
|
let mat = sk.material_create(shader.as_ref().unwrap_or(Shader::UI.as_ref()));
|
||||||
sk.material_set_texture(&mat, "diffuse", sk_tex.as_ref());
|
sk.material_set_texture(&mat, "diffuse", sk_tex.as_ref());
|
||||||
sk.material_set_transparency(&mat, Transparency::Blend);
|
sk.material_set_transparency(&mat, Transparency::Blend);
|
||||||
Arc::new(mat)
|
Arc::new(mat)
|
||||||
@@ -121,18 +121,16 @@ impl CoreSurface {
|
|||||||
let mut mapped_data = self.mapped_data.lock();
|
let mut mapped_data = self.mapped_data.lock();
|
||||||
let just_mapped = mapped_data.is_none();
|
let just_mapped = mapped_data.is_none();
|
||||||
self.with_states(|data| {
|
self.with_states(|data| {
|
||||||
let renderer_surface_state = data
|
let Some(renderer_surface_state) = data
|
||||||
.data_map
|
.data_map
|
||||||
.get::<RendererSurfaceStateUserData>()
|
.get::<RendererSurfaceStateUserData>()
|
||||||
.unwrap()
|
.map(RefCell::borrow) else {return};
|
||||||
.borrow();
|
let Some(smithay_tex) = renderer_surface_state
|
||||||
let smithay_tex = renderer_surface_state
|
|
||||||
.texture::<GlesRenderer>(renderer.id())
|
.texture::<GlesRenderer>(renderer.id())
|
||||||
.unwrap()
|
.cloned() else {return};
|
||||||
.clone();
|
|
||||||
|
|
||||||
let sk_tex = self.sk_tex.get().unwrap();
|
let Some(sk_tex) = self.sk_tex.get() else {return};
|
||||||
let sk_mat = self.sk_mat.get().unwrap();
|
let Some(sk_mat) = self.sk_mat.get() else {return};
|
||||||
unsafe {
|
unsafe {
|
||||||
sk.tex_set_surface(
|
sk.tex_set_surface(
|
||||||
sk_tex.as_ref(),
|
sk_tex.as_ref(),
|
||||||
@@ -151,7 +149,7 @@ impl CoreSurface {
|
|||||||
sk.material_set_queue_offset(sk_mat.as_ref().as_ref(), *material_offset as i32);
|
sk.material_set_queue_offset(sk_mat.as_ref().as_ref(), *material_offset as i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
let surface_size = renderer_surface_state.surface_size().unwrap();
|
let Some(surface_size) = renderer_surface_state.surface_size() else {return};
|
||||||
let new_mapped_data = CoreSurfaceData {
|
let new_mapped_data = CoreSurfaceData {
|
||||||
size: Vector2::from([surface_size.w as u32, surface_size.h as u32]),
|
size: Vector2::from([surface_size.w as u32, surface_size.h as u32]),
|
||||||
wl_tex: Some(SendWrapper::new(smithay_tex)),
|
wl_tex: Some(SendWrapper::new(smithay_tex)),
|
||||||
@@ -186,10 +184,12 @@ impl CoreSurface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn apply_surface_materials(&self) {
|
fn apply_surface_materials(&self) {
|
||||||
for model_node in self.pending_material_applications.get_valid_contents() {
|
if let Some(sk_mat) = self.sk_mat.get() {
|
||||||
model_node.replace_material(self.sk_mat.clone().get().unwrap().clone());
|
for model_node in self.pending_material_applications.get_valid_contents() {
|
||||||
|
model_node.replace_material(sk_mat.clone());
|
||||||
|
}
|
||||||
|
self.pending_material_applications.clear();
|
||||||
}
|
}
|
||||||
self.pending_material_applications.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wl_surface(&self) -> Option<WlSurface> {
|
pub fn wl_surface(&self) -> Option<WlSurface> {
|
||||||
|
|||||||
@@ -267,8 +267,8 @@ impl Dispatch<XdgPositioner, Mutex<PositionerData>, WaylandState> for WaylandSta
|
|||||||
?positioner,
|
?positioner,
|
||||||
constraint_adjustment, "Set positioner constraint adjustment"
|
constraint_adjustment, "Set positioner constraint adjustment"
|
||||||
);
|
);
|
||||||
data.lock().constraint_adjustment =
|
let Some(constraint_adjustment) = ConstraintAdjustment::from_bits(constraint_adjustment) else {return};
|
||||||
ConstraintAdjustment::from_bits(constraint_adjustment).unwrap();
|
data.lock().constraint_adjustment = constraint_adjustment;
|
||||||
}
|
}
|
||||||
xdg_positioner::Request::SetOffset { x, y } => {
|
xdg_positioner::Request::SetOffset { x, y } => {
|
||||||
debug!(?positioner, x, y, "Set positioner offset");
|
debug!(?positioner, x, y, "Set positioner offset");
|
||||||
@@ -372,7 +372,7 @@ impl Dispatch<XdgSurface, Mutex<XdgSurfaceData>, WaylandState> for WaylandState
|
|||||||
{
|
{
|
||||||
let toplevel = toplevel.downgrade();
|
let toplevel = toplevel.downgrade();
|
||||||
move || {
|
move || {
|
||||||
let toplevel = toplevel.upgrade().unwrap();
|
let Ok(toplevel) = toplevel.upgrade() else {return};
|
||||||
let toplevel_data = ToplevelData::get(&toplevel);
|
let toplevel_data = ToplevelData::get(&toplevel);
|
||||||
let Some(xdg_surface) = toplevel_data.lock().xdg_surface() else {return};
|
let Some(xdg_surface) = toplevel_data.lock().xdg_surface() else {return};
|
||||||
let Some(xdg_surface_data) = XdgSurfaceData::get(&xdg_surface) else {return};
|
let Some(xdg_surface_data) = XdgSurfaceData::get(&xdg_surface) else {return};
|
||||||
@@ -394,7 +394,7 @@ impl Dispatch<XdgSurface, Mutex<XdgSurfaceData>, WaylandState> for WaylandState
|
|||||||
{
|
{
|
||||||
let toplevel = toplevel.downgrade();
|
let toplevel = toplevel.downgrade();
|
||||||
move |_| {
|
move |_| {
|
||||||
let toplevel = toplevel.upgrade().unwrap();
|
let Ok(toplevel) = toplevel.upgrade() else {return};
|
||||||
let toplevel_data = ToplevelData::get(&toplevel);
|
let toplevel_data = ToplevelData::get(&toplevel);
|
||||||
let Some(panel_item) = toplevel_data.lock().panel_item() else {
|
let Some(panel_item) = toplevel_data.lock().panel_item() else {
|
||||||
let Some(xdg_surface) = toplevel_data.lock().xdg_surface() else {return};
|
let Some(xdg_surface) = toplevel_data.lock().xdg_surface() else {return};
|
||||||
@@ -426,20 +426,10 @@ impl Dispatch<XdgSurface, Mutex<XdgSurfaceData>, WaylandState> for WaylandState
|
|||||||
parent,
|
parent,
|
||||||
positioner,
|
positioner,
|
||||||
} => {
|
} => {
|
||||||
let parent_clone = parent.clone().unwrap();
|
let Some(parent) = parent else {return};
|
||||||
let parent_data = parent_clone.data::<Mutex<XdgSurfaceData>>().unwrap().lock();
|
let Some(parent_data) = parent.data::<Mutex<XdgSurfaceData>>() else {return};
|
||||||
// let positioner_data = positioner
|
let parent_data = parent_data.lock();
|
||||||
// .data::<Mutex<PositionerData>>()
|
|
||||||
// .unwrap()
|
|
||||||
// .lock()
|
|
||||||
// .clone();
|
|
||||||
// let parent = match &*parent_data {
|
|
||||||
// XdgSurfaceType::Toplevel(_) => SurfaceID::Toplevel,
|
|
||||||
// XdgSurfaceType::Popup(p) => {
|
|
||||||
// SurfaceID::Popup(p.upgrade().unwrap().uid.clone())
|
|
||||||
// }
|
|
||||||
// XdgSurfaceType::Unknown => return,
|
|
||||||
// };
|
|
||||||
let uid = nanoid!();
|
let uid = nanoid!();
|
||||||
let popup_data = Mutex::new(PopupData::new(
|
let popup_data = Mutex::new(PopupData::new(
|
||||||
uid.clone(),
|
uid.clone(),
|
||||||
@@ -447,13 +437,11 @@ impl Dispatch<XdgSurface, Mutex<XdgSurfaceData>, WaylandState> for WaylandState
|
|||||||
parent_data.surface_id.clone(),
|
parent_data.surface_id.clone(),
|
||||||
positioner,
|
positioner,
|
||||||
));
|
));
|
||||||
let panel_item = parent_data.panel_item().unwrap();
|
let Some(panel_item) = parent_data.panel_item() else {return};
|
||||||
|
let Some(popup_wl_surface) = popup_data.lock().wl_surface() else {return};
|
||||||
handle_cursor(
|
handle_cursor(
|
||||||
&panel_item,
|
&panel_item,
|
||||||
panel_item
|
panel_item.backend.seat.new_surface(&popup_wl_surface),
|
||||||
.backend
|
|
||||||
.seat
|
|
||||||
.new_surface(&popup_data.lock().wl_surface().unwrap()),
|
|
||||||
);
|
);
|
||||||
let xdg_popup = data_init.init(id, popup_data);
|
let xdg_popup = data_init.init(id, popup_data);
|
||||||
xdg_surface_data.lock().surface_id = SurfaceID::Child(uid);
|
xdg_surface_data.lock().surface_id = SurfaceID::Child(uid);
|
||||||
@@ -462,12 +450,13 @@ impl Dispatch<XdgSurface, Mutex<XdgSurfaceData>, WaylandState> for WaylandState
|
|||||||
debug!(?xdg_popup, ?xdg_surface, "Create XDG popup");
|
debug!(?xdg_popup, ?xdg_surface, "Create XDG popup");
|
||||||
|
|
||||||
let xdg_surface = xdg_surface.downgrade();
|
let xdg_surface = xdg_surface.downgrade();
|
||||||
let xdg_popup = xdg_popup.downgrade();
|
let xdg_popup: WlWeak<XdgPopup> = xdg_popup.downgrade();
|
||||||
|
let Ok(wl_surface) = xdg_surface_data.lock().wl_surface.upgrade() else {return};
|
||||||
CoreSurface::add_to(
|
CoreSurface::add_to(
|
||||||
state.display_handle.clone(),
|
state.display_handle.clone(),
|
||||||
&xdg_surface_data.lock().wl_surface.upgrade().unwrap(),
|
&wl_surface,
|
||||||
move || {
|
move || {
|
||||||
let xdg_popup = xdg_popup.upgrade().unwrap();
|
let Ok(xdg_popup) = xdg_popup.upgrade() else {return};
|
||||||
let Some(popup_data) = PopupData::get(&xdg_popup) else {return};
|
let Some(popup_data) = PopupData::get(&xdg_popup) else {return};
|
||||||
let popup_data = popup_data.lock();
|
let popup_data = popup_data.lock();
|
||||||
panel_item
|
panel_item
|
||||||
@@ -476,10 +465,9 @@ impl Dispatch<XdgSurface, Mutex<XdgSurfaceData>, WaylandState> for WaylandState
|
|||||||
},
|
},
|
||||||
move |commit_count| {
|
move |commit_count| {
|
||||||
if commit_count == 0 {
|
if commit_count == 0 {
|
||||||
xdg_surface
|
if let Ok(xdg_surface) = xdg_surface.upgrade() {
|
||||||
.upgrade()
|
xdg_surface.configure(SERIAL_COUNTER.inc())
|
||||||
.unwrap()
|
}
|
||||||
.configure(SERIAL_COUNTER.inc())
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -566,11 +554,9 @@ impl Dispatch<XdgToplevel, Mutex<ToplevelData>, WaylandState> for WaylandState {
|
|||||||
debug!(?xdg_toplevel, ?parent, "Set XDG Toplevel parent");
|
debug!(?xdg_toplevel, ?parent, "Set XDG Toplevel parent");
|
||||||
data.lock().parent = parent.clone().map(|toplevel| toplevel.downgrade());
|
data.lock().parent = parent.clone().map(|toplevel| toplevel.downgrade());
|
||||||
let Some(panel_item) = data.lock().panel_item() else {return};
|
let Some(panel_item) = data.lock().panel_item() else {return};
|
||||||
if let Some(parent) = parent {
|
let Some(parent) = parent else {return};
|
||||||
panel_item.toplevel_parent_changed(
|
let Some(parent_panel_item) = ToplevelData::get(&parent).lock().panel_item() else {return};
|
||||||
&ToplevelData::get(&parent).lock().panel_item().unwrap().uid,
|
panel_item.toplevel_parent_changed(&parent_panel_item.uid);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
xdg_toplevel::Request::SetTitle { title } => {
|
xdg_toplevel::Request::SetTitle { title } => {
|
||||||
debug!(?xdg_toplevel, ?title, "Set XDG Toplevel title");
|
debug!(?xdg_toplevel, ?title, "Set XDG Toplevel title");
|
||||||
@@ -943,11 +929,11 @@ impl Backend for XDGBackend {
|
|||||||
size,
|
size,
|
||||||
min_size: toplevel_data.min_size.clone(),
|
min_size: toplevel_data.min_size.clone(),
|
||||||
max_size: toplevel_data.max_size.clone(),
|
max_size: toplevel_data.max_size.clone(),
|
||||||
logical_rectangle: XdgSurfaceData::get(&self.toplevel_xdg_surface().unwrap())
|
logical_rectangle: self
|
||||||
.unwrap()
|
.toplevel_xdg_surface()
|
||||||
.lock()
|
.as_ref()
|
||||||
.geometry
|
.and_then(XdgSurfaceData::get)
|
||||||
.clone()
|
.and_then(|d| d.lock().geometry.clone())
|
||||||
.unwrap_or_else(|| Geometry {
|
.unwrap_or_else(|| Geometry {
|
||||||
origin: [0, 0].into(),
|
origin: [0, 0].into(),
|
||||||
size,
|
size,
|
||||||
|
|||||||
Reference in New Issue
Block a user