Skip to main content

Module window

Module window 

Source
Expand description

Shared helpers for showing the long-lived main window (the Preferences UI), with a Linux/Wayland-specific workaround for #139.

The main window is created visible: false (tauri.conf.json) and shown on demand from the tray. On GNOME/Wayland a window shown after being created hidden never receives an initial configure event from the compositor until the user manually resizes it, so its client-side decoration input region stays stale and the close/minimise controls swallow clicks until the first double-click-to-maximise toggle (upstream tauri-apps/tauri#13440, still open).

The 0.0.6 fix nudged the size +1px and back synchronously after show(). That never cleared it on Steffi’s Ubuntu 24.04 / GNOME / Wayland setup: Wayland batches surface state until commit, so two set_size calls in the same event-loop turn coalesce to the final (unchanged) size and no configure is emitted — the synchronous nudge was a no-op there. Given a hidden window shown later needs a committed state change, the strategies here defer their second half onto a later event-loop tick, and maximize is the default because Steffi confirmed it clears the controls on her hardware (it mirrors the manual double-click-titlebar that she found worked).

ENTRACTE_WL_FIX selects the strategy so a different compositor can be handled empirically without a rebuild:

  • maximize (default): maximize() then unmaximize() on a later tick — the confirmed fix.
  • nudge: resize +1px, restore on a later tick (the 0.0.6 idea, fixed to actually commit). Kept as an alternative for compositors maximize perturbs.
  • off: do nothing (baseline / opt-out).

Applied only on a real Wayland session: X11 gives a proper configure on show() and must not get a spurious maximise flash.

Enums§

WaylandFix
Which #139 Wayland workaround to apply when showing the main window.

Constants§

DEFER_MS 🔒
Delay before the deferred half of a nudge/maximize round-trip, long enough for the compositor to process and commit the intermediate surface state before we restore it.
WL_FIX_ENV 🔒
Env var selecting the Wayland configure workaround strategy. Honoured only on a Linux Wayland session; ignored elsewhere.

Functions§

apply_wayland_fix 🔒
Apply the selected #139 workaround to a freshly-shown main window. Reached only on a Linux Wayland session (see show_main_window); the nudge/maximize strategies defer their second half onto a later event-loop tick because Wayland coalesces state set within a single turn — the flaw that made the 0.0.6 synchronous nudge a no-op.
close_pause_window
Close the “Pause until…” picker. Invoked by the picker itself after it pauses or the user cancels. A backend command (rather than the JS window API) keeps @tauri-apps/api/window out of the renderer bundle.
is_wayland_session 🔒
Whether this is a Wayland session, from the process environment.
nudged_dimension 🔒
The one transient intermediate size the nudge strategy resizes to before restoring the real size, to provoke a fresh compositor configure event. Grow by 1px so the size genuinely changes (a no-op resize is coalesced away); if the window is already at the u32 ceiling, shrink instead so the value still differs.
show_main_window
Show and focus the main window, applying the Wayland configure workaround on a Linux Wayland session. Single entry point so every “open Preferences” call site (tray menu, CLI re-invocation) gets identical behaviour.
show_pause_window
Show the small “Pause until…” picker, creating it on first use. Launched from the tray; mirrors the overlay’s on-demand window creation. The renderer closes the window after pausing or cancelling, so the next launch builds a fresh one.
wayland_fix_strategy
Resolve the active strategy from the process environment.
wayland_session_from_env 🔒
Pure Wayland-session test over the two relevant env signals, split out so the decision is unit-testable without mutating process env. Mirrors the probes in scheduler::overlay and video; kept local so the window path stays self-contained.