Skip to content

Commit 4902c26

Browse files
remove top level decorator and other wlrootisms.
1 parent cb3da65 commit 4902c26

File tree

4 files changed

+34
-51
lines changed

4 files changed

+34
-51
lines changed

druid-shell/src/backend/wayland/application.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use wayland_client::{
4444
},
4545
};
4646
use wayland_cursor::CursorTheme;
47-
use wayland_protocols::unstable::xdg_decoration::v1::client::zxdg_decoration_manager_v1::ZxdgDecorationManagerV1;
4847
use wayland_protocols::wlr::unstable::layer_shell::v1::client::zwlr_layer_shell_v1::ZwlrLayerShellV1;
4948
use wayland_protocols::xdg_shell::client::xdg_positioner::XdgPositioner;
5049
use wayland_protocols::xdg_shell::client::xdg_surface;
@@ -93,8 +92,7 @@ pub struct Application {
9392
#[allow(dead_code)]
9493
pub(crate) struct Data {
9594
pub(super) wayland: std::rc::Rc<display::Environment>,
96-
pub(super) zxdg_decoration_manager_v1: wl::Main<ZxdgDecorationManagerV1>,
97-
pub(super) zwlr_layershell_v1: wl::Main<ZwlrLayerShellV1>,
95+
pub(super) zwlr_layershell_v1: Option<wl::Main<ZwlrLayerShellV1>>,
9896
pub(super) wl_compositor: wl::Main<WlCompositor>,
9997
pub(super) wl_shm: wl::Main<WlShm>,
10098
/// A map of wayland object IDs to outputs.
@@ -201,14 +199,17 @@ impl Application {
201199
let env = display::new(dispatcher)?;
202200
display::print(&env.registry);
203201

204-
let zxdg_decoration_manager_v1 = env
205-
.registry
206-
.instantiate_exact::<ZxdgDecorationManagerV1>(1)
207-
.map_err(|e| Error::global("zxdg_decoration_manager_v1", 1, e))?;
208202
let zwlr_layershell_v1 = env
209203
.registry
210204
.instantiate_exact::<ZwlrLayerShellV1>(1)
211-
.map_err(|e| Error::global("zwlr_layershell_v1", 1, e))?;
205+
.map_or_else(
206+
|e| {
207+
tracing::info!("unable to instantiate layershell {:?}", e);
208+
None
209+
},
210+
|x| Some(x),
211+
);
212+
212213
let wl_compositor = env
213214
.registry
214215
.instantiate_exact::<WlCompositor>(4)
@@ -230,7 +231,6 @@ impl Application {
230231

231232
// We need to have keyboard events set up for our seats before the next roundtrip.
232233
let appdata = std::sync::Arc::new(Data {
233-
zxdg_decoration_manager_v1,
234234
zwlr_layershell_v1,
235235
wl_compositor,
236236
wl_shm: wl_shm.clone(),
@@ -334,6 +334,7 @@ impl Application {
334334
calloop::channel::Event::Closed => {}
335335
calloop::channel::Event::Msg(output) => match output {
336336
outputs::Event::Located(output) => {
337+
tracing::debug!("output added {:?} {:?}", output.gid, output.id());
337338
appdata
338339
.outputs
339340
.borrow_mut()
@@ -343,6 +344,7 @@ impl Application {
343344
}
344345
}
345346
outputs::Event::Removed(output) => {
347+
tracing::debug!("output removed {:?} {:?}", output.gid, output.id());
346348
appdata.outputs.borrow_mut().remove(&output.id());
347349
for (_, win) in appdata.handles_iter() {
348350
surfaces::Outputs::removed(&win, &output);
@@ -419,11 +421,7 @@ impl surfaces::Compositor for Data {
419421
self.wayland.xdg_base.get_xdg_surface(s)
420422
}
421423

422-
fn zxdg_decoration_manager_v1(&self) -> wl::Main<ZxdgDecorationManagerV1> {
423-
self.zxdg_decoration_manager_v1.clone()
424-
}
425-
426-
fn zwlr_layershell_v1(&self) -> wl::Main<ZwlrLayerShellV1> {
424+
fn zwlr_layershell_v1(&self) -> Option<wl::Main<ZwlrLayerShellV1>> {
427425
self.zwlr_layershell_v1.clone()
428426
}
429427
}

druid-shell/src/backend/wayland/surfaces/layershell.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl Surface {
194194
) -> Self {
195195
let compositor = CompositorHandle::new(c);
196196
let wl_surface = surface::Surface::new(compositor.clone(), handler, kurbo::Size::ZERO);
197-
let ls_surface = compositor.zwlr_layershell_v1().get_layer_surface(
197+
let ls_surface = compositor.zwlr_layershell_v1().unwrap().get_layer_surface(
198198
&wl_surface.inner.wl_surface.borrow(),
199199
None,
200200
config.layer,
@@ -273,7 +273,12 @@ impl Surface {
273273
.borrow_mut()
274274
.preferred
275275
.get_or_insert(o.name.clone());
276-
handle.inner.output.borrow_mut().current.get_or_insert(o);
276+
handle
277+
.inner
278+
.output
279+
.borrow_mut()
280+
.current
281+
.get_or_insert(o.clone());
277282
}
278283
handle.inner.ls_surface.borrow().destroy();
279284
handle.inner.available.replace(false);
@@ -320,15 +325,18 @@ impl Outputs for Surface {
320325
.wl_surface
321326
.replace(surface::Surface::replace(&sdata));
322327
let sdata = self.inner.wl_surface.borrow().inner.clone();
323-
let replacedlayershell =
324-
self.inner
325-
.ls_surface
326-
.replace(sdata.compositor.zwlr_layershell_v1().get_layer_surface(
328+
let replacedlayershell = self.inner.ls_surface.replace(
329+
sdata
330+
.compositor
331+
.zwlr_layershell_v1()
332+
.unwrap()
333+
.get_layer_surface(
327334
&self.inner.wl_surface.borrow().inner.wl_surface.borrow(),
328335
None,
329336
self.inner.config.layer,
330337
self.inner.config.namespace.to_string(),
331-
));
338+
),
339+
);
332340

333341
Surface::initialize(self);
334342
replacedlayershell.destroy();

druid-shell/src/backend/wayland/surfaces/mod.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use wayland_client::protocol::wl_shm::WlShm;
22
use wayland_client::{self as wlc, protocol::wl_surface::WlSurface};
3-
use wayland_protocols::unstable::xdg_decoration::v1::client::zxdg_decoration_manager_v1::ZxdgDecorationManagerV1;
43
use wayland_protocols::wlr::unstable::layer_shell::v1::client::zwlr_layer_shell_v1::ZwlrLayerShellV1;
54
use wayland_protocols::xdg_shell::client::xdg_popup;
65
use wayland_protocols::xdg_shell::client::xdg_positioner;
@@ -29,8 +28,7 @@ pub trait Compositor {
2928
fn get_xdg_surface(&self, surface: &wlc::Main<WlSurface>)
3029
-> wlc::Main<xdg_surface::XdgSurface>;
3130
fn get_xdg_positioner(&self) -> wlc::Main<xdg_positioner::XdgPositioner>;
32-
fn zxdg_decoration_manager_v1(&self) -> wlc::Main<ZxdgDecorationManagerV1>;
33-
fn zwlr_layershell_v1(&self) -> wlc::Main<ZwlrLayerShellV1>;
31+
fn zwlr_layershell_v1(&self) -> Option<wlc::Main<ZwlrLayerShellV1>>;
3432
}
3533

3634
pub trait Decor {
@@ -157,19 +155,13 @@ impl Compositor for CompositorHandle {
157155
}
158156
}
159157

160-
fn zxdg_decoration_manager_v1(&self) -> wlc::Main<ZxdgDecorationManagerV1> {
158+
fn zwlr_layershell_v1(&self) -> Option<wlc::Main<ZwlrLayerShellV1>> {
161159
match self.inner.upgrade() {
162160
None => {
163-
panic!("unable to acquire underyling compositor to acquire the decoration manager")
164-
}
165-
Some(c) => c.zxdg_decoration_manager_v1(),
166-
}
167-
}
168-
169-
fn zwlr_layershell_v1(&self) -> wlc::Main<ZwlrLayerShellV1> {
170-
match self.inner.upgrade() {
171-
None => {
172-
panic!("unable to acquire underyling compositor to acquire the layershell manager")
161+
tracing::warn!(
162+
"unable to acquire underyling compositor to acquire the layershell manager"
163+
);
164+
None
173165
}
174166
Some(c) => c.zwlr_layershell_v1(),
175167
}

druid-shell/src/backend/wayland/surfaces/toplevel.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use wayland_client as wlc;
2-
use wayland_protocols::unstable::xdg_decoration::v1::client::zxdg_toplevel_decoration_v1 as toplevel_decorations;
32
use wayland_protocols::xdg_shell::client::xdg_surface;
43
use wayland_protocols::xdg_shell::client::xdg_toplevel;
54

@@ -17,12 +16,8 @@ use super::Popup;
1716

1817
struct Inner {
1918
wl_surface: surface::Surface,
20-
#[allow(unused)]
2119
pub(super) xdg_surface: wlc::Main<xdg_surface::XdgSurface>,
2220
pub(super) xdg_toplevel: wlc::Main<xdg_toplevel::XdgToplevel>,
23-
#[allow(unused)]
24-
pub(super) zxdg_toplevel_decoration_v1:
25-
wlc::Main<toplevel_decorations::ZxdgToplevelDecorationV1>,
2621
}
2722

2823
impl From<Inner> for std::sync::Arc<surface::Data> {
@@ -47,9 +42,6 @@ impl Surface {
4742
let wl_surface = surface::Surface::new(compositor.clone(), handler, kurbo::Size::ZERO);
4843
let xdg_surface = compositor.get_xdg_surface(&wl_surface.inner.wl_surface.borrow());
4944
let xdg_toplevel = xdg_surface.get_toplevel();
50-
let zxdg_toplevel_decoration_v1 = compositor
51-
.zxdg_decoration_manager_v1()
52-
.get_toplevel_decoration(&xdg_toplevel);
5345

5446
// register to receive xdg_surface events.
5547
xdg_surface.quick_assign({
@@ -66,6 +58,7 @@ impl Surface {
6658
}
6759
}
6860
});
61+
6962
xdg_toplevel.quick_assign({
7063
let wl_surface = wl_surface.clone();
7164
let mut dim = initial_size;
@@ -97,20 +90,12 @@ impl Surface {
9790
}
9891
});
9992

100-
zxdg_toplevel_decoration_v1.quick_assign(move |_zxdg_toplevel_decoration_v1, event, _| {
101-
tracing::info!("toplevel decoration unimplemented {:?}", event);
102-
});
103-
10493
let inner = Inner {
10594
wl_surface,
10695
xdg_toplevel,
10796
xdg_surface,
108-
zxdg_toplevel_decoration_v1,
10997
};
11098

111-
inner
112-
.zxdg_toplevel_decoration_v1
113-
.set_mode(toplevel_decorations::Mode::ServerSide);
11499
if let Some(size) = min_size {
115100
inner
116101
.xdg_toplevel

0 commit comments

Comments
 (0)