GTK 3 windows get Chandra's frame: org_kde_kwin_server_decoration
CI / test (push) Successful in 12m52s
CI / test (push) Successful in 12m52s
GTK 3 has no xdg-decoration support, so every GTK 3 window without its own header bar (Webby, Nemo-style apps) drew GTK's fallback title bar: a centered title, only a close button, and a dark border inside Chandra's CSD box. GTK 3 asks for server-side decoration through KWin's org_kde_kwin_server_decoration instead. Chandra now advertises it with default mode Server; request_mode(Client) (GTK 3 apps with a header bar) keeps their own frame. The Settings portal also answers org.gnome.desktop.wm.preferences button-layout "appmenu:minimize,maximize,close", so apps that still draw their own title bar show the same three buttons as Chandra's frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hghaEWWsCBgEq6iZHj
This commit is contained in:
4 files changed
+117
-4
No files matched your search
@@ -217,3 +217,43 @@ test "Chrome asking to draw its own frame gets it, instead of a second one aroun
|
|||||||
ignore(gtk_frame(comp, c, shm, surf, xdg, tl))
|
ignore(gtk_frame(comp, c, shm, surf, xdg, tl))
|
||||||
assert_false(comp.windows.get(1UL).unwrap().csd)
|
assert_false(comp.windows.get(1UL).unwrap().csd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///|
|
||||||
|
test "a GTK 3 window asking through org_kde_kwin_server_decoration gets Chandra's frame" {
|
||||||
|
// GTK 3 has no xdg-decoration support: without this protocol every GTK 3 window (Webby) drew
|
||||||
|
// its own fallback title bar, with only a close button, inside a black border.
|
||||||
|
let socket_path = "/tmp/wayland-moon-csd-kde-" + @sys.getpid().to_string() + ".sock"
|
||||||
|
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||||
|
comp.set_layout_mode(@wm.LayoutMode::Floating)
|
||||||
|
let (c, shm, surf, xdg, tl, _) = open_and_configure_client(
|
||||||
|
comp,
|
||||||
|
socket_path,
|
||||||
|
"Webby",
|
||||||
|
"webby",
|
||||||
|
server_deco=false,
|
||||||
|
)
|
||||||
|
assert_true(c.globals.contains("org_kde_kwin_server_decoration_manager"))
|
||||||
|
let mgr = bind_global(c, 2U, "org_kde_kwin_server_decoration_manager", 1U)
|
||||||
|
// create(id, surface), then request_mode(Server) as gdk_wayland_window_announce_ssd does.
|
||||||
|
let deco = c.alloc_id()
|
||||||
|
let cr = @wayland.WireWriter::new()
|
||||||
|
cr.u32(deco)
|
||||||
|
cr.u32(surf)
|
||||||
|
c.send(cr.finish_msg(mgr, 0U))
|
||||||
|
let rm = @wayland.WireWriter::new()
|
||||||
|
rm.u32(2U)
|
||||||
|
c.send(rm.finish_msg(deco, 1U))
|
||||||
|
let size_for = fn(w, h, _max) { (w, h) }
|
||||||
|
ignore(answer_configures(comp, c, shm, surf, xdg, tl, size_for))
|
||||||
|
let win = comp.windows.get(1UL).unwrap()
|
||||||
|
assert_false(win.csd)
|
||||||
|
let r = win.client_rect()
|
||||||
|
assert_eq((r.x, r.y, r.w, r.h), (win.geometry.x, win.geometry.y, win.geometry.w, win.geometry.h))
|
||||||
|
|
||||||
|
// request_mode(Client): a GTK 3 app with its own header bar keeps drawing its frame.
|
||||||
|
let rc = @wayland.WireWriter::new()
|
||||||
|
rc.u32(1U)
|
||||||
|
c.send(rc.finish_msg(deco, 1U))
|
||||||
|
ignore(gtk_frame(comp, c, shm, surf, xdg, tl))
|
||||||
|
assert_true(comp.windows.get(1UL).unwrap().csd)
|
||||||
|
}
|
||||||
@@ -71,9 +71,20 @@ pub fn namespace_matches(patterns : Array[String], ns : String) -> Bool {
|
|||||||
|
|
||||||
///| The settings we know, as (namespace, key, value).
|
///| The settings we know, as (namespace, key, value).
|
||||||
fn SettingsPortal::settings(self : SettingsPortal) -> Array[(String, String, @network.DValue)] {
|
fn SettingsPortal::settings(self : SettingsPortal) -> Array[(String, String, @network.DValue)] {
|
||||||
[(appearance, "color-scheme", U32(color_scheme(self.dark)))]
|
[
|
||||||
|
(appearance, "color-scheme", U32(color_scheme(self.dark))),
|
||||||
|
// Title bar buttons of apps that draw their own (GTK header bars, GTK 3's fallback title
|
||||||
|
// bar): the same three as Chandra's frame. GNOME's default is "appmenu:close".
|
||||||
|
(wm_preferences, "button-layout", Str(button_layout)),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///|
|
||||||
|
pub let wm_preferences : String = "org.gnome.desktop.wm.preferences"
|
||||||
|
|
||||||
|
///|
|
||||||
|
pub let button_layout : String = "appmenu:minimize,maximize,close"
|
||||||
|
|
||||||
///|
|
///|
|
||||||
let introspection : String =
|
let introspection : String =
|
||||||
#|<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
#|<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
||||||
|
|||||||
@@ -49,10 +49,19 @@ test "ReadAll filters namespaces, with globs" {
|
|||||||
call(@portal.settings_iface, "ReadAll", [Arr("s", pats.map(s => @network.DValue::Str(s)))]),
|
call(@portal.settings_iface, "ReadAll", [Arr("s", pats.map(s => @network.DValue::Str(s)))]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
assert_eq(all([]), Ok(want))
|
let wm : @network.DValue = Entry(
|
||||||
|
Str("org.gnome.desktop.wm.preferences"),
|
||||||
|
@network.dict("v", [("button-layout", Variant(Str("appmenu:minimize,maximize,close")))]),
|
||||||
|
)
|
||||||
|
let both = match want[0] {
|
||||||
|
Arr(t, es) => [@network.DValue::Arr(t, [..es, wm])]
|
||||||
|
_ => []
|
||||||
|
}
|
||||||
|
assert_eq(all([]), Ok(both))
|
||||||
assert_eq(all(["org.freedesktop.*"]), Ok(want))
|
assert_eq(all(["org.freedesktop.*"]), Ok(want))
|
||||||
assert_eq(all(["org.freedesktop.appearance"]), Ok(want))
|
assert_eq(all(["org.freedesktop.appearance"]), Ok(want))
|
||||||
assert_eq(all(["org.gnome.*"]), Ok([Arr("{sa{sv}}", [])]))
|
assert_eq(all(["org.gnome.*"]), Ok([Arr("{sa{sv}}", [wm])]))
|
||||||
|
assert_eq(all(["org.kde.*"]), Ok([Arr("{sa{sv}}", [])]))
|
||||||
}
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ enum ObjKind {
|
|||||||
ObjXdgPopup(UInt64)
|
ObjXdgPopup(UInt64)
|
||||||
ObjDecoManager
|
ObjDecoManager
|
||||||
ObjToplevelDeco(UInt64)
|
ObjToplevelDeco(UInt64)
|
||||||
|
/// org_kde_kwin_server_decoration_manager: GTK 3's way of asking for server-side decoration
|
||||||
|
/// (it has no xdg-decoration support).
|
||||||
|
ObjKdeDecoManager
|
||||||
|
/// org_kde_kwin_server_decoration for the wl_surface with this id.
|
||||||
|
ObjKdeDeco(UInt)
|
||||||
ObjSeat
|
ObjSeat
|
||||||
ObjPointer
|
ObjPointer
|
||||||
ObjKeyboard
|
ObjKeyboard
|
||||||
@@ -99,6 +104,9 @@ struct SurfaceState {
|
|||||||
mut window_id : UInt64?
|
mut window_id : UInt64?
|
||||||
/// wl_surface.set_buffer_scale: the buffer is this many times the window's size.
|
/// wl_surface.set_buffer_scale: the buffer is this many times the window's size.
|
||||||
mut buffer_scale : Int
|
mut buffer_scale : Int
|
||||||
|
/// org_kde_kwin_server_decoration mode Server: Chandra draws this window's frame (GTK 3 apps
|
||||||
|
/// without their own header bar, like Webby).
|
||||||
|
mut kde_ssd : Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
@@ -361,6 +369,7 @@ fn emit_registry_globals(c : ClientConn, reg_id : UInt) -> Unit {
|
|||||||
(7U, "wl_subcompositor", 1U),
|
(7U, "wl_subcompositor", 1U),
|
||||||
(8U, "wl_data_device_manager", 3U),
|
(8U, "wl_data_device_manager", 3U),
|
||||||
(9U, "wp_cursor_shape_manager_v1", 1U),
|
(9U, "wp_cursor_shape_manager_v1", 1U),
|
||||||
|
(10U, "org_kde_kwin_server_decoration_manager", 1U),
|
||||||
]
|
]
|
||||||
for g in globals {
|
for g in globals {
|
||||||
let w = WireWriter::new()
|
let w = WireWriter::new()
|
||||||
@@ -565,6 +574,11 @@ fn WaylandServer::dispatch_msg(
|
|||||||
c.objects.set(new_id, ObjXdgWmBase)
|
c.objects.set(new_id, ObjXdgWmBase)
|
||||||
} else if iface == "zxdg_decoration_manager_v1" {
|
} else if iface == "zxdg_decoration_manager_v1" {
|
||||||
c.objects.set(new_id, ObjDecoManager)
|
c.objects.set(new_id, ObjDecoManager)
|
||||||
|
} else if iface == "org_kde_kwin_server_decoration_manager" {
|
||||||
|
c.objects.set(new_id, ObjKdeDecoManager)
|
||||||
|
// default_mode(Server): GTK 3 then leaves out its own title bar and shadow on every
|
||||||
|
// window that has no custom header bar, and asks for Chandra's frame.
|
||||||
|
send_decoration_mode(c, new_id, 2U)
|
||||||
} else if iface == "wl_seat" {
|
} else if iface == "wl_seat" {
|
||||||
c.objects.set(new_id, ObjSeat)
|
c.objects.set(new_id, ObjSeat)
|
||||||
c.seat_ver = ver
|
c.seat_ver = ver
|
||||||
@@ -591,6 +605,7 @@ fn WaylandServer::dispatch_msg(
|
|||||||
xdg_surface_id: None,
|
xdg_surface_id: None,
|
||||||
window_id: None,
|
window_id: None,
|
||||||
buffer_scale: 1,
|
buffer_scale: 1,
|
||||||
|
kde_ssd: false,
|
||||||
})
|
})
|
||||||
} else if opcode == 1U {
|
} else if opcode == 1U {
|
||||||
let rid = reader.u32()
|
let rid = reader.u32()
|
||||||
@@ -658,7 +673,13 @@ fn WaylandServer::dispatch_msg(
|
|||||||
Some(xs) => (xs.geo_x, xs.geo_y)
|
Some(xs) => (xs.geo_x, xs.geo_y)
|
||||||
None => (0, 0)
|
None => (0, 0)
|
||||||
}
|
}
|
||||||
let frame = (tl.deco_obj_id is None || tl.wants_csd, gx, gy)
|
let kde_ssd = match c.surfaces.get(tl.wl_surface_id) {
|
||||||
|
Some(s) => s.kde_ssd
|
||||||
|
None => false
|
||||||
|
}
|
||||||
|
let client_side = tl.wants_csd ||
|
||||||
|
(tl.deco_obj_id is None && !kde_ssd)
|
||||||
|
let frame = (client_side, gx, gy)
|
||||||
if tl.frame_sent != Some(frame) {
|
if tl.frame_sent != Some(frame) {
|
||||||
tl.frame_sent = Some(frame)
|
tl.frame_sent = Some(frame)
|
||||||
events.push(ToplevelFrame(wid, frame.0, gx, gy))
|
events.push(ToplevelFrame(wid, frame.0, gx, gy))
|
||||||
@@ -1206,6 +1227,38 @@ fn WaylandServer::dispatch_msg(
|
|||||||
// Negotiate Server-Side Decoration (2)
|
// Negotiate Server-Side Decoration (2)
|
||||||
send_decoration_mode(c, deco_id, 2U)
|
send_decoration_mode(c, deco_id, 2U)
|
||||||
}
|
}
|
||||||
|
ObjKdeDecoManager =>
|
||||||
|
if opcode == 0U {
|
||||||
|
// create(id, surface): KWin's protocol starts every decoration in the default mode.
|
||||||
|
let deco_id = reader.u32()
|
||||||
|
let sid = reader.u32()
|
||||||
|
c.objects.set(deco_id, ObjKdeDeco(sid))
|
||||||
|
match c.surfaces.get(sid) {
|
||||||
|
Some(s) => s.kde_ssd = true
|
||||||
|
None => ()
|
||||||
|
}
|
||||||
|
send_decoration_mode(c, deco_id, 2U)
|
||||||
|
}
|
||||||
|
ObjKdeDeco(sid) =>
|
||||||
|
if opcode == 0U {
|
||||||
|
// release: the client draws its own frame again.
|
||||||
|
match c.surfaces.get(sid) {
|
||||||
|
Some(s) => s.kde_ssd = false
|
||||||
|
None => ()
|
||||||
|
}
|
||||||
|
c.objects.remove(obj_id)
|
||||||
|
send_delete_id(c, obj_id)
|
||||||
|
} else if opcode == 1U {
|
||||||
|
// request_mode(mode): 2 Server gets Chandra's frame; 1 Client (a GTK 3 app with its own
|
||||||
|
// header bar) and 0 None draw their own.
|
||||||
|
let mode = reader.u32()
|
||||||
|
let ssd = mode == 2U
|
||||||
|
match c.surfaces.get(sid) {
|
||||||
|
Some(s) => s.kde_ssd = ssd
|
||||||
|
None => ()
|
||||||
|
}
|
||||||
|
send_decoration_mode(c, obj_id, mode)
|
||||||
|
}
|
||||||
ObjToplevelDeco(wid) =>
|
ObjToplevelDeco(wid) =>
|
||||||
if opcode == 0U {
|
if opcode == 0U {
|
||||||
// Without its decoration object the client goes back to drawing its own frame.
|
// Without its decoration object the client goes back to drawing its own frame.
|
||||||
|
|||||||
Reference in new issue
Block a user