Skip to content

fix(window): add in-page close button on Hyprland - #7

Open
Youpen-y wants to merge 1 commit into
earendil-works:mainfrom
Youpen-y:fix/wlroots-close-button
Open

fix(window): add in-page close button on Hyprland#7
Youpen-y wants to merge 1 commit into
earendil-works:mainfrom
Youpen-y:fix/wlroots-close-button

Conversation

@Youpen-y

@Youpen-y Youpen-y commented Jul 29, 2026

Copy link
Copy Markdown

Fixes #6

Summary

On wlroots Wayland compositors the review window is a layer-shell Overlay with no title bar, so it has no way to be closed. Detect Hyprland in the bridge (tested) and reveal an in-page × button that calls glimpse's existing close API.

Problem

On wlroots-based Wayland compositors (tested on Hyprland; Sway/River theoretically affected) the review window cannot be closed by the user:

  • No title-bar × button — the window has no decorations
  • super+Q / Alt+F4 / Esc don't work — it isn't a regular toplevel, so compositor window actions (killactive, closewindow) don't apply
  • The escape is killing the glimpse process or reloading the extension or ending the pi session

Root cause

glimpse's native Linux backend renders the window as a layer-shell Overlay surface via gtk4-layer-shell:

// glimpseui src/linux/src/main.rs:115-117
window.init_layer_shell();
window.set_layer(Layer::Overlay);
window.set_exclusive_zone(-1);

layer-shell surfaces carry no window decorations (no title bar, no ×) and aren't managed as regular toplevels by the compositor. and glimpse does expose a close API (window.glimpse.close()__glimpse_closeapp.quit() at main.rs:218), but review-loop never calls it: there's no close button in the UI and no keyboard binding.

This only affects wlroots compositors. On macOS / Windows / X11 / GNOME-Wayland, gtk4-layer-shell falls back to a normal decorated toplevel (those compositors don't implement wlr-layer-shell), so the system × button is present.

Solution

Detect Hyprland in the bridge (Node side, where process.env is directly readable via HYPRLAND_INSTANCE_SIGNATURE) and inject a flag into the page HTML. The web app renders an in-page × button only when the flag is set, and wires it to glimpse's existing window.glimpse.close().

Solution

Detect Hyprland in the bridge (Node side, where process.env is directly readable via HYPRLAND_INSTANCE_SIGNATURE) and inject a flag into the page HTML. The web app renders an in-page × button only when the flag is set, and wires it to glimpse's existing window.glimpse.close().

image

Limitations / future work

  • Detection currently covers only Hyprland (tested). Other wlroots
    compositors (Sway → SWAYSOCK, River, …) are theoretically affected (layer-shell has no decorations) but unverified, add their env vars once confirmed.

On wlroots compositors the glimpse native window is a layer-shell Overlay
with no title bar, so the review window could not be closed (no x button,
killactive/Alt+F4/Esc ineffective). Detect Hyprland in the bridge via
process.env (HYPRLAND_INSTANCE_SIGNATURE), inject a flag into the page HTML,
and reveal an in-page x button wired to glimpse's existing
window.glimpse.close() API. On macOS/Windows/X11/GNOME the system x is used
and the in-page button stays hidden. Other wlroots compositors (Sway, River,
...) are theoretically affected but not yet verified.

No changes to glimpse required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot close review window on Hyprland (wlroots)

1 participant