gui: on Linux the window has no system title bar over its own header — GNOME drew one (the name and a ×) stacked on the tabs; the window now keeps GNOME's shadow and resize edges but shows no bar, and the page's header is the title bar: the icon and name, dragged to move, double-clicked to maximise, and a round × that hides the window to the tray. Reproduced and checked on Fedora 44 GNOME 50 (Wayland)
This commit is contained in:
+4
-1
@@ -288,7 +288,10 @@ func Run(version string, showMain bool, link string) error {
|
||||
if runtime.GOOS == "windows" {
|
||||
h.main.OnWindowEvent(events.Windows.WebViewNavigationCompleted, func(*application.WindowEvent) { markReady() })
|
||||
} else {
|
||||
h.app.Event.OnApplicationEvent(events.Common.ApplicationStarted, func(*application.ApplicationEvent) { markReady() })
|
||||
h.app.Event.OnApplicationEvent(events.Common.ApplicationStarted, func(*application.ApplicationEvent) {
|
||||
plainTitlebar(h.main) // Linux: the page's header is the title bar
|
||||
markReady()
|
||||
})
|
||||
}
|
||||
if showMain {
|
||||
h.whenReady(func() { h.ShowMain("") })
|
||||
|
||||
@@ -137,7 +137,11 @@ code { font: 11.5px var(--code); }
|
||||
body.window.mac .top { padding-left: 96px; height: 50px; padding-top: 2px; } /* the traffic lights centre 25.75pt from the top, not 25 */
|
||||
body.window.mac .seg { top: calc(50% + 1px); } /* 50% centres in the padding box; the 2px top padding puts the flex row a pixel lower */
|
||||
.brand { display: flex; align-items: center; gap: 6px; font-weight: 600; letter-spacing: .01em; }
|
||||
body.window:not(.mac) .brand { display: none; } /* the title bar above already shows the icon and the name */
|
||||
body.window:not(.mac):not(.linux) .brand { display: none; } /* Windows' title bar above already shows the icon and the name */
|
||||
/* Linux: the header is the title bar, so it closes the window too — round,
|
||||
as GNOME draws its close button, and set a little apart from the icons */
|
||||
.icon.winclose { align-self: center; width: 22px; height: 22px; margin-left: 8px; border-radius: 50%; background: var(--pill); color: var(--fg-2); }
|
||||
.icon.winclose:hover { background: color-mix(in srgb, var(--fg) 12%, transparent); }
|
||||
/* the magpie flaps, flicks its tail and bobs when the window opens and on
|
||||
hover. It moves in pieces cut from the logo, and is drawn whole at rest, so
|
||||
the cuts never show. */
|
||||
|
||||
@@ -4,12 +4,15 @@ const $$ = (s) => document.querySelectorAll(s);
|
||||
const params = new URLSearchParams(location.search);
|
||||
const mode = params.get("mode") || "window";
|
||||
document.body.classList.add(mode);
|
||||
// Only the Mac window draws its title bar inside the page (the traffic lights).
|
||||
// The Mac window draws its title bar inside the page (the traffic lights);
|
||||
// on Linux the page's header is the whole title bar (plainTitlebar), so it
|
||||
// has the name, the close button and a double-click to maximise.
|
||||
if (/^Mac/.test(navigator.platform)) document.body.classList.add("mac");
|
||||
if (/^Linux/.test(navigator.platform)) document.body.classList.add("linux");
|
||||
// The window is dragged by its header, and only where the header says so
|
||||
// (--wails-draggable), so the tabs and buttons in it stay plain clicks.
|
||||
// Outside the app — a browser on the gateway's page — there is no runtime.
|
||||
if (mode === "window") import("/wails/runtime.js").catch(() => {});
|
||||
const winRuntime = mode === "window" ? import("/wails/runtime.js").catch(() => null) : Promise.resolve(null);
|
||||
if (params.get("theme")) document.documentElement.dataset.theme = params.get("theme");
|
||||
// the saved language and theme from boot.js, so the first paint is in them
|
||||
if (window.bootPrefs) {
|
||||
@@ -4114,8 +4117,13 @@ $("#sync").onclick = async () => {
|
||||
$("#open").onclick = () => api("window/main", {});
|
||||
$("#openMain").onclick = () => api("window/main", {});
|
||||
$("#quit").onclick = () => api("window/quit", {});
|
||||
$("#winclose").onclick = () => winRuntime.then((w) => w?.Window.Close()); // hides it: the tray stays
|
||||
$(".top").addEventListener("dblclick", (e) => {
|
||||
if (document.body.classList.contains("linux") && !e.target.closest("button, nav")) winRuntime.then((w) => w?.Window.ToggleMaximise());
|
||||
});
|
||||
if (mode === "window") { $("#open").remove(); $("#openMain").remove(); $("#quit").remove(); }
|
||||
else { $("#nav").remove(); }
|
||||
if (mode !== "window" || !document.body.classList.contains("linux")) $("#winclose").remove();
|
||||
|
||||
// Config files may change underneath us (another magpie, an editor); reload when
|
||||
// the panel comes back into view.
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
<button class="icon" id="prefs" title="Settings" data-tt>
|
||||
<svg viewBox="0 0 24 24" width="14" height="14"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></g></svg>
|
||||
</button>
|
||||
<button class="icon winclose" id="winclose" title="Close" data-tt>
|
||||
<svg viewBox="0 0 16 16" width="10" height="10"><path d="M4 4l8 8M12 4l-8 8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//go:build linux && cgo && gtk3
|
||||
|
||||
package gui
|
||||
|
||||
/*
|
||||
#cgo pkg-config: gtk+-3.0
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void plain_titlebar(void *w) {
|
||||
GtkWidget *bar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_no_show_all(bar, TRUE); // kept hidden when the window shows all it holds
|
||||
gtk_window_set_titlebar(GTK_WINDOW(w), bar);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import "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)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
//go:build linux && cgo && !gtk3
|
||||
|
||||
package gui
|
||||
|
||||
/*
|
||||
#cgo pkg-config: gtk4
|
||||
#include <gtk/gtk.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);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import "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)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//go:build !linux || !cgo
|
||||
|
||||
package gui
|
||||
|
||||
import "github.com/wailsapp/wails/v3/pkg/application"
|
||||
|
||||
// plainTitlebar: macOS insets the traffic lights into the page's header
|
||||
// (MacTitleBarHiddenInset) and Windows keeps its own title bar.
|
||||
func plainTitlebar(*application.WebviewWindow) {}
|
||||
Reference in New Issue
Block a user