Files
magpie/internal/gui/titlebar_gtk4.go
T
yetone d226f87e4c gui: on KDE Plasma's Wayland session the quick panel has no KWin title bar or frame, as the main window has none (#1283)
GTK 3, which the Linux builds link, announces server-side decorations
over org_kde_kwin_server_decoration for every window that isn't
client-decorated, an undecorated (frameless) one too (gtkwindow.c
realize: announce_ssd), and KWin then draws its title bar on it. The main
window escapes it through plainTitlebar's hidden titlebar widget. The
panel now announces client-side decorations after each realize
(ownFrame: gdk_wayland_window_announce_csd), at start and when
lightweight mode makes it again. GTK 4 already asks for none, X11 and
compositors without the protocol never see it.

Run: on real KWin 6.3.6 Wayland (kwin_wayland --virtual with Breeze,
Debian trixie arm64 container, -tags gtk3 test binary): WAYLAND_DEBUG
shows request_mode(1) and KWin answers mode(1); a KWin script reads the
panel's frame 440x520 = its client 440x520. With ownFrame skipped:
request_mode(2), frame 442x557 over client 440x520 (KWin's title bar
and borders, the reporter's picture). go vet -tags gtk3 ./internal/gui
ok there; macOS go vet/go build ok; GOOS=linux/windows go vet -tags nogui
./internal/gui ok. Not tried: the reporter's Manjaro Plasma session, a
GTK 4 build, GNOME/Hyprland (no KDE protocol there, so unchanged).
2026-10-08 18:16:03 +08:00

57 lines
1.6 KiB
Go

//go:build linux && cgo && !gtk3 && !nogui
package gui
/*
#cgo pkg-config: gtk4
#include <gtk/gtk.h>
#include <stdlib.h>
static void plain_titlebar(void *w) {
GtkWidget *bar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_visible(bar, FALSE);
gtk_window_set_titlebar(GTK_WINDOW(w), bar);
}
static void name_window(void *w, char *title) {
gtk_window_set_title(GTK_WINDOW(w), title);
}
*/
import "C"
import (
"unsafe"
"github.com/wailsapp/wails/v3/pkg/application"
)
// plainTitlebar takes the system's title bar off a window whose page has a
// header of its own. GNOME draws one over it, the name and a close button
// stacked on the tabs; frameless, the window would lose its shadow, rounded
// corners and the edges it is resized by. A hidden widget as its titlebar
// keeps all those and shows no bar: the page's header drags it, and has the
// close button.
func plainTitlebar(w *application.WebviewWindow) {
application.InvokeSync(func() {
if p := w.NativeWindow(); p != nil {
C.plain_titlebar(p)
}
})
}
// nameWindow gives a frameless window a title, which Wails leaves unset on
// one; Hyprland tells the panel from the main window by it.
func nameWindow(w *application.WebviewWindow, title string) {
application.InvokeSync(func() {
if p := w.NativeWindow(); p != nil {
t := C.CString(title)
C.name_window(p, t)
C.free(unsafe.Pointer(t))
}
})
}
// ownFrame: GTK 4 asks the compositor for no frame on an undecorated window
// itself (gdk_toplevel_set_decorated), so KWin draws none (#1283).
func ownFrame(*application.WebviewWindow) {}