detached 186f990

fix(window): add GTK close-request handler for graceful shutdown

Cmd+Q and window close button now properly trigger graceful shutdown
instead of immediately killing the browser process. The close-request
signal handler calls QuitMainLoop() which allows the deferred cleanup()
function to run, properly closing database connections and cleaning up
resources.
commit
186f9905fa5c832667a3af7c68138c24b6bd1cc3
author
bnema · · 2025-10-17 04:29 UTC
parent
1fa2de8
signature
GPG Unverified2B82207D370127A0 The key is unknown
2 files · +14 -0
M CHANGELOG.md +1 -0
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
66
77 ### Fixed
88 - Dark mode flash on startup: Set GTK dark theme preference and WebView background color before window/content creation
9+- Cmd+Q and window close button now trigger graceful shutdown instead of killing the browser process
910
1011 ## [0.12.0] - 2025-10-16
1112
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
6 6
7 ### Fixed7 ### Fixed
8 - Dark mode flash on startup: Set GTK dark theme preference and WebView background color before window/content creation8 - Dark mode flash on startup: Set GTK dark theme preference and WebView background color before window/content creation
9+- Cmd+Q and window close button now trigger graceful shutdown instead of killing the browser process
9 10
10 ## [0.12.0] - 2025-10-1611 ## [0.12.0] - 2025-10-16
11 12
M pkg/webkit/window.go +13 -0
@@ -1,6 +1,8 @@
11 package webkit
22
33 import (
4+ "log"
5+
46 "github.com/diamondburned/gotk4/pkg/gtk/v4"
57 )
68
@@ -21,6 +23,17 @@ func NewWindow(title string) (*Window, error) {
2123 win.SetTitle(title)
2224 win.SetDefaultSize(1024, 768)
2325
26+ // Connect close-request signal to handle Cmd+Q and window close button
27+ // Returning true prevents the default close behavior and allows graceful shutdown
28+ win.ConnectCloseRequest(func() bool {
29+ log.Printf("[window] Close request received (Cmd+Q or close button) - initiating graceful shutdown")
30+ // Quit the main loop gracefully, which will trigger cleanup
31+ QuitMainLoop()
32+ // Return true to prevent GTK from destroying the window immediately
33+ // The cleanup process will handle window destruction
34+ return true
35+ })
36+
2437 return &Window{win: win}, nil
2538 }
2639
@@ -1,6 +1,8 @@
1 package webkit1 package webkit
2 2
3 import (3 import (
4+ "log"
5+
4 "github.com/diamondburned/gotk4/pkg/gtk/v4"6 "github.com/diamondburned/gotk4/pkg/gtk/v4"
5 )7 )
6 8
@@ -21,6 +23,17 @@ func NewWindow(title string) (*Window, error) {
21 win.SetTitle(title)23 win.SetTitle(title)
22 win.SetDefaultSize(1024, 768)24 win.SetDefaultSize(1024, 768)
23 25
26+ // Connect close-request signal to handle Cmd+Q and window close button
27+ // Returning true prevents the default close behavior and allows graceful shutdown
28+ win.ConnectCloseRequest(func() bool {
29+ log.Printf("[window] Close request received (Cmd+Q or close button) - initiating graceful shutdown")
30+ // Quit the main loop gracefully, which will trigger cleanup
31+ QuitMainLoop()
32+ // Return true to prevent GTK from destroying the window immediately
33+ // The cleanup process will handle window destruction
34+ return true
35+ })
36+
24 return &Window{win: win}, nil37 return &Window{win: win}, nil
25 }38 }
26 39

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close