Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

fix(linux): give windows a title bar again on Wayland compositors that draw none

Tw93e2488e330dfa
diff --git a/src-tauri/src/app/header_bar.rs b/src-tauri/src/app/header_bar.rs
new file mode 100644
index 00000000..8090c1d7
--- /dev/null
+++ b/src-tauri/src/app/header_bar.rs
@@ -0,0 +1,61 @@
+// The title bar of a Pake window on Wayland.
+//
+// tao 0.34 gave every Wayland window a GTK header bar of its own; 0.37 dropped
+// it and leaves the title bar to GTK, which asks the compositor for one when
+// the compositor supports server-side decorations. Hyprland (Omarchy) and
+// other tiling compositors draw none, so after the Tauri 2.12 upgrade a Pake
+// window there had no title, no buttons and nothing to drag (2026-11-19, on
+// Omarchy). A header bar set before the window first shows makes GTK draw the
+// title bar itself again, as it did before.
+
+use gtk::prelude::*;
+use gtk::HeaderBar;
+use tauri::WebviewWindow;
+
+fn layout(resizable: bool) -> &'static str {
+ if resizable {
+ "menu:minimize,maximize,close"
+ } else {
+ "menu:minimize,close"
+ }
+}
+
+/// Gives a decorated Wayland window GTK's own title bar, with the window's
+/// title and its minimize, maximize and close buttons. Call it before the
+/// window is first shown; a window that already has a title bar keeps it.
+pub fn install(window: &WebviewWindow) {
+ let gtk_window = match window.gtk_window() {
+ Ok(gtk_window) => gtk_window,
+ Err(error) => {
+ eprintln!("[Pake] No GTK window for the title bar: {error}");
+ return;
+ }
+ };
+ if !gtk_window.display().backend().is_wayland()
+ || !gtk_window.is_decorated()
+ || gtk_window.titlebar().is_some()
+ {
+ return;
+ }
+
+ let header = HeaderBar::builder()
+ .show_close_button(true)
+ .decoration_layout(layout(gtk_window.is_resizable()))
+ .build();
+ header.set_title(gtk_window.title().as_deref());
+ header.show();
+ gtk_window.set_titlebar(Some(&header));
+
+ let title_header = header.downgrade();
+ gtk_window.connect_title_notify(move |window| {
+ if let Some(header) = title_header.upgrade() {
+ header.set_title(window.title().as_deref());
+ }
+ });
+ let layout_header = header.downgrade();
+ gtk_window.connect_resizable_notify(move |window| {
+ if let Some(header) = layout_header.upgrade() {
+ header.set_decoration_layout(Some(layout(window.is_resizable())));
+ }
+ });
+}
diff --git a/src-tauri/src/app/mod.rs b/src-tauri/src/app/mod.rs
index 2e343efa..3daedbc9 100644
--- a/src-tauri/src/app/mod.rs
+++ b/src-tauri/src/app/mod.rs
@@ -10,6 +10,8 @@ pub mod content_blocking;
pub mod download;
#[cfg(any(target_os = "macos", target_os = "windows"))]
pub mod extensions;
+#[cfg(target_os = "linux")]
+pub mod header_bar;
pub mod invoke;
#[cfg(target_os = "linux")]
pub mod media_permission;
diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rs
index ac86c861..89ccbeae 100644
--- a/src-tauri/src/app/window.rs
+++ b/src-tauri/src/app/window.rs
@@ -824,7 +824,8 @@ fn build_window(
let mut window_builder = WebviewWindowBuilder::new(app, label, url)
.title(effective_title)
- .visible(visible)
+ // Linux builds every window hidden and shows it once its title bar is in.
+ .visible(visible && !cfg!(target_os = "linux"))
.user_agent(user_agent)
.resizable(window_config.resizable)
.maximized(window_config.maximize);
@@ -1237,6 +1238,16 @@ fn build_window(
let window = window_builder.build()?;
+ #[cfg(target_os = "linux")]
+ {
+ if !window_config.hide_window_decorations {
+ crate::app::header_bar::install(&window);
+ }
+ if visible {
+ window.show()?;
+ }
+ }
+
// A popup is built visible, so it can enter full screen now; a hidden window
// enters when it is first shown.
#[cfg(target_os = "macos")]