From 142096827e4c6c2109689c0bc60de9355b99b4c5 Mon Sep 17 00:00:00 2001 From: "Pedro M. de Echanove Pasquin" Date: Fri, 24 Jul 2026 23:20:16 +0200 Subject: [PATCH] =?UTF-8?q?event=5Floop:=20drop=20the=20built-in=20titleba?= =?UTF-8?q?r=20when=20the=20compositor=20decorates=20ltk=20already=20asked?= =?UTF-8?q?=20for=20server-side=20decorations=20through=20SCTK=20(WindowDe?= =?UTF-8?q?corations::RequestServer=20on=20window=20creation)=20but=20pain?= =?UTF-8?q?ted=20its=2036=20px=20titlebar=20unconditionally,=20so=20under?= =?UTF-8?q?=20forge=20an=20xdg=20window=20carried=20two=20stacked=20bars:?= =?UTF-8?q?=20forge's=20SSD=20on=20top=20of=20ltk's=20own.=20The=20WindowH?= =?UTF-8?q?andler=20configure=20now=20honours=20the=20negotiated=20decorat?= =?UTF-8?q?ion=5Fmode:=20Server=20zeroes=20titlebar=5Fheight,=20Client=20?= =?UTF-8?q?=E2=80=94=20which=20is=20also=20what=20SCTK=20reports=20when=20?= =?UTF-8?q?the=20compositor=20lacks=20xdg-decoration,=20e.g.=20GNOME=20?= =?UTF-8?q?=E2=80=94=20restores=20it=20from=20the=20new=20titlebar=5Fbase?= =?UTF-8?q?=20field.=20Every=20titlebar=20consumer=20(draw,=20close-button?= =?UTF-8?q?=20hit=20test,=20drag-move)=20already=20guards=20on=20the=20hei?= =?UTF-8?q?ght=20being=20positive,=20so=20the=20suppressed=20bar=20costs?= =?UTF-8?q?=20nothing=20and=20the=20fallback=20path=20is=20unchanged.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/event_loop/handlers.rs | 10 +++++++++- src/event_loop/surface.rs | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/event_loop/handlers.rs b/src/event_loop/handlers.rs index 3dca314..a3e5e84 100644 --- a/src/event_loop/handlers.rs +++ b/src/event_loop/handlers.rs @@ -19,7 +19,7 @@ use smithay_client_toolkit:: wlr_layer::{ LayerShellHandler, LayerSurface, LayerSurfaceConfigure }, xdg::XdgSurface, xdg::popup::{ Popup, PopupConfigure, PopupHandler }, - xdg::window::{ Window, WindowConfigure, WindowHandler }, + xdg::window::{ DecorationMode, Window, WindowConfigure, WindowHandler }, }, shm::{ Shm, ShmHandler }, session_lock::{ SessionLock, SessionLockHandler, SessionLockSurface, SessionLockSurfaceConfigure }, @@ -222,6 +222,14 @@ impl WindowHandler for AppData window.set_max_size( None ); self.pending_size_hint_unpin = false; } + let tb = if configure.decoration_mode == DecorationMode::Server { 0.0 } + else { self.main.titlebar_base }; + if self.main.titlebar_height != tb + { + self.main.titlebar_height = tb; + self.main.content_dirty = true; + self.view_dirty = true; + } let ( hint_w, hint_h ) = self.app.window_size_hint().unwrap_or( ( 800, 600 ) ); let w = configure.new_size.0.map( |v| v.get() ).unwrap_or( hint_w ); let h = configure.new_size.1.map( |v| v.get() ).unwrap_or( hint_h ); diff --git a/src/event_loop/surface.rs b/src/event_loop/surface.rs index 1e05c3b..0b41dbe 100644 --- a/src/event_loop/surface.rs +++ b/src/event_loop/surface.rs @@ -260,6 +260,9 @@ pub( crate ) struct SurfaceState pub touch_slots: HashMap, /// Height of the client-side title bar (0 for layer-shell surfaces). pub titlebar_height: f32, + /// Title bar height before decoration negotiation; restored when the + /// compositor hands decorations back to the client. + pub titlebar_base: f32, /// Title text shown in the client-side title bar. pub titlebar_title: String, /// Rect of the close button in the title bar (for hit testing). @@ -313,6 +316,7 @@ impl SurfaceState context_menu: None, gesture: GestureState::new(), titlebar_height, + titlebar_base: titlebar_height, titlebar_title, titlebar_close_rect: Rect::default(), scale_factor: 1,