-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add webkitgtk6 option #4570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add webkitgtk6 option #4570
Conversation
`webkit_web_view_new_with_user_content_manager` has been removed in webkit-6 so this now has to be done manually.
Gtk4 removed several menu widgets and reworked menu and accelerator interactions.
This just removes some already disabled code and clarifies some comments.
This doesn't fully implement functionality and may fail. See: https://discourse.gnome.org/t/file-drag-and-drop-in-gtkmm4/10548/5
Gtk4 requires an app id. The existing 'ProgramName' app option seems like a good fit for this.
The 'on demand' policy was removed but 'never' should still map to case 2.
WalkthroughThis PR splits Linux frontend code into GTK3/WebKit2 and GTK4/WebKit6 paths: legacy files are gated with Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor WebView as C/WebKit
participant CGO as cgo bridge
participant Frontend as Go:frontend_webkit6
participant Dispatcher as frontend.Dispatcher
participant Window as Go/C Window
WebView->>CGO: processMessage / processBindingMessage(C string)
CGO->>Frontend: exported function call
Frontend->>Frontend: validate origin / unmarshal
Frontend->>Dispatcher: dispatch binding or event
Dispatcher->>Window: perform action (show/size/exec)
Window->>CGO: ExecuteOnMainThread / C helpers for UI ops
note right of Frontend `#DDEBF7`: async goroutine dispatch for callbacks and menu clicks
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
COD3HUNT3R
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need changes for doctor command
https://github.com/Sammy-T/wails/tree/feature/webkitgtk6/v2/internal/system/packagemanager
|
@COD3HUNT3R this is intended to work similarly to when using |
Yes, you are right but this would be helpful to find required packages for gtk4, webkit2-6.0 |
|
Had to revert updating from master (ca1eed6) because it broke local development on linux for me. |
|
Running this on X11 Linux Mint, this appears to be working nicely. I still don't know how/if I can get the todos (window positioning, etc.) working with webkit-6 though. @leaanthony Are you able to test this and see how it runs for you? And do you know how to address the commented todos? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
v2/internal/frontend/desktop/linux/menu_webkit6.go(1 hunks)v2/internal/frontend/desktop/linux/window_webkit6.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
v2/internal/frontend/desktop/linux/menu_webkit6.go (3)
v2/pkg/runtime/menu.go (2)
MenuSetApplicationMenu(9-12)MenuUpdateApplicationMenu(14-17)v2/internal/frontend/desktop/linux/window_webkit6.go (1)
Window(38-51)v2/pkg/menu/menuitem.go (1)
SubMenu(319-329)
v2/internal/frontend/desktop/linux/window_webkit6.go (2)
v2/internal/frontend/desktop/linux/window.go (2)
NewWindow(62-149)Window(40-53)v2/internal/frontend/desktop/linux/window_webkit6.c (35)
SetupInvokeSignal(125-128)SetupWebview(590-641)ConnectButtons(359-369)DevtoolsEnabled(643-653)InstallF12Hotkey(951-961)DisableContextMenu(308-312)SetBackgroundColour(165-212)SetTitle(224-230)SetWindowIcon(131-147)SetWindowTransparency(149-161)GTKWIDGET(30-33)GTKWINDOW(35-38)GTKBOX(40-43)Fullscreen(457-473)ExecuteOnMainThread(25-28)UnFullscreen(475-480)Center(391-413)SetMinMaxSize(260-299)Show(415-420)Hide(422-427)Maximise(429-434)UnMaximise(436-441)Minimise(443-448)UnMinimise(450-455)IsFullscreen(371-375)IsMaximised(377-381)IsMinimised(383-387)LoadIndex(655-658)ExecuteJS(714-720)StartDrag(679-685)StartResize(705-712)AllocFileFilterArray(792-795)Opendialog(845-932)MessageDialog(740-788)ShowInspector(941-944)
| func (w *Window) SetApplicationMenu(inmenu *menu.Menu) { | ||
| if inmenu == nil { | ||
| return | ||
| } | ||
|
|
||
| // Clean up previous menu | ||
| for _, gmenu := range gtkMenuCache { | ||
| if gmenu != nil { | ||
| C.g_object_unref(C.gpointer(gmenu)) | ||
| } | ||
| } | ||
|
|
||
| if w.menubar != nil { | ||
| C.gtk_widget_unparent(w.menubar) | ||
| w.menubar = nil | ||
| } | ||
|
|
||
| menuItemToId = make(map[*menu.MenuItem]int) | ||
| menuIdToItem = make(map[int]*menu.MenuItem) | ||
| gtkMenuCache = make(map[*menu.MenuItem]*C.GMenu) | ||
|
|
||
| processMenu(w, inmenu) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Persist the application menu before rebuilding
Line 87 returns immediately when inmenu is nil, and nowhere else do we assign to w.applicationMenu. As a result, MenuUpdateApplicationMenu() always sees a nil menu and becomes a no-op after the first call. Please store the menu pointer up front so refreshes keep working.
func (w *Window) SetApplicationMenu(inmenu *menu.Menu) {
+ w.applicationMenu = inmenu
+
if inmenu == nil {
return
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func (w *Window) SetApplicationMenu(inmenu *menu.Menu) { | |
| if inmenu == nil { | |
| return | |
| } | |
| // Clean up previous menu | |
| for _, gmenu := range gtkMenuCache { | |
| if gmenu != nil { | |
| C.g_object_unref(C.gpointer(gmenu)) | |
| } | |
| } | |
| if w.menubar != nil { | |
| C.gtk_widget_unparent(w.menubar) | |
| w.menubar = nil | |
| } | |
| menuItemToId = make(map[*menu.MenuItem]int) | |
| menuIdToItem = make(map[int]*menu.MenuItem) | |
| gtkMenuCache = make(map[*menu.MenuItem]*C.GMenu) | |
| processMenu(w, inmenu) | |
| } | |
| func (w *Window) SetApplicationMenu(inmenu *menu.Menu) { | |
| // Persist for future updates | |
| w.applicationMenu = inmenu | |
| if inmenu == nil { | |
| return | |
| } | |
| // Clean up previous menu | |
| for _, gmenu := range gtkMenuCache { | |
| if gmenu != nil { | |
| C.g_object_unref(C.gpointer(gmenu)) | |
| } | |
| } | |
| if w.menubar != nil { | |
| C.gtk_widget_unparent(w.menubar) | |
| w.menubar = nil | |
| } | |
| menuItemToId = make(map[*menu.MenuItem]int) | |
| menuIdToItem = make(map[int]*menu.MenuItem) | |
| gtkMenuCache = make(map[*menu.MenuItem]*C.GMenu) | |
| processMenu(w, inmenu) | |
| } |
🤖 Prompt for AI Agents
v2/internal/frontend/desktop/linux/menu_webkit6.go around lines 87-109: the
function currently returns immediately when inmenu is nil and never assigns
w.applicationMenu, so future refreshes see nil; fix by persisting the incoming
menu pointer at the top (set w.applicationMenu = inmenu), and if inmenu is nil
clear any existing native menu state/caches and return; otherwise continue with
the existing cleanup and rebuild logic so MenuUpdateApplicationMenu() can find
the stored menu on subsequent calls.
|
@Sammy-T - Thanks for your continued effort on this 🙏 Is it still a WIP? Wondering if we should convert this to draft? |
|
@leaanthony Thanks. It's been a lot of work and I wasn't sure I'd even get this far. Sorry if I've been spamming you. I wasn't expecting to get hit with all those suggestions. Some of them were relevant. I can switch it back to draft. Currently, this PR is working with the exception of missing some of the window control that was removed in gtk4 (I've marked them in the code as todo comments). I was hoping you could test it out and also take a look at the todos to see if you know of any workarounds/updates? |
This sets the transparency for the entire widget including the menu and the webview's contents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
♻️ Duplicate comments (5)
v2/internal/frontend/desktop/linux/window_webkit6.c (2)
387-411: Center/SetPosition/SetMinMaxSize are no-ops; document or feature-flag.Calls from Go currently give the impression features exist.
- Add explicit comments in Go calling sites noting these are no-ops on GTK4, or guard with build-tagged capabilities.
Also applies to: 235-249, 251-291
636-641: Incorrect argument type for gdk_toplevel_begin_move/resize.Pass a
GdkToplevel*from the window’s surface, notGtkWindow*.- gdk_toplevel_begin_move(options->mainwindow, NULL, mouseButton, xroot, yroot, dragTime); + GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(options->mainwindow)); + gdk_toplevel_begin_move(GDK_TOPLEVEL(surface), NULL, mouseButton, xroot, yroot, dragTime); @@ - gdk_toplevel_begin_resize(options->mainwindow, options->edge, NULL, mouseButton, xroot, yroot, dragTime); + GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(options->mainwindow)); + gdk_toplevel_begin_resize(GDK_TOPLEVEL(surface), options->edge, NULL, mouseButton, xroot, yroot, dragTime);Also applies to: 663-667
v2/internal/frontend/desktop/linux/window_webkit6.go (3)
334-360: Wrap Run() GTK mutations on main thread and drop no-op Center().GTK widget mutations must run on GTK thread. Also Center() is a no-op in GTK4 path.
- if w.menubar != nil { - C.gtk_box_prepend(C.GTKBOX(unsafe.Pointer(w.vbox)), w.menubar) - } - - C.gtk_box_prepend(C.GTKBOX(unsafe.Pointer(w.webviewBox)), C.GTKWIDGET(w.webview)) - C.gtk_box_append(C.GTKBOX(unsafe.Pointer(w.vbox)), w.webviewBox) - - _url := C.CString(url) - defer C.free(unsafe.Pointer(_url)) - C.LoadIndex(w.webview, _url) + _url := C.CString(url) + defer C.free(unsafe.Pointer(_url)) + invokeOnMainThread(func() { + if w.menubar != nil { + C.gtk_box_prepend(C.GTKBOX(unsafe.Pointer(w.vbox)), w.menubar) + } + C.gtk_box_prepend(C.GTKBOX(unsafe.Pointer(w.webviewBox)), C.GTKWIDGET(w.webview)) + C.gtk_box_append(C.GTKBOX(unsafe.Pointer(w.vbox)), w.webviewBox) + C.LoadIndex(w.webview, _url) + C.gtk_window_present(w.asGTKWindow()) + }) if w.appoptions.StartHidden { w.Hide() } - C.gtk_window_present(w.asGTKWindow()) - - w.Center() switch w.appoptions.WindowStartState {
501-511: GTK dialog called from goroutine; dispatch to main thread.This is unsafe for GTK. Use
invokeOnMainThread.- go func() { - data := C.MessageDialogOptions{ - title: C.CString(title), - message: C.CString(message), - messageType: C.int(1), - } - - C.MessageDialog(unsafe.Pointer(&data)) - }() + go func() { + data := C.MessageDialogOptions{ + title: C.CString(title), + message: C.CString(message), + messageType: C.int(1), + } + invokeOnMainThread(func() { C.MessageDialog(unsafe.Pointer(&data)) }) + }()
182-184: Incorrect cast: asGTKBox must return the box widget, not the window.Casting
w.gtkWindowtoGtkBoxis invalid and may crash if used.func (w *Window) asGTKBox() *C.GtkBox { - return C.GTKBOX(w.gtkWindow) + return C.GTKBOX(unsafe.Pointer(w.vbox)) }
🧹 Nitpick comments (6)
v2/internal/frontend/desktop/linux/window_webkit6.go (4)
133-135: Remove unused variable.
buttonPressedNameis allocated and freed but never used.- buttonPressedName := C.CString("button-press-event") - defer C.free(unsafe.Pointer(buttonPressedName)) - C.ConnectButtons(unsafe.Pointer(webview)) + C.ConnectButtons(unsafe.Pointer(webview))
362-365: SetKeepAbove is a stub; document or feature-flag it.It does nothing on GTK4. Consider documenting the limitation or guarding the API to avoid misleading callers.
371-377: Prefergtk_window_set_default_sizeOR provide a resize API; current SetSize duplicates SetDefaultSize.If intentional, comment why. Otherwise, expose a
Resizethat changes current size.
222-232: Size() returns default size, not current size.If the intent is current geometry, consider using a GTK4-appropriate getter (or document this).
v2/internal/frontend/desktop/linux/window_webkit6.c (2)
187-195: Do not unref the CSS provider if you reuse it later.You store
windowCssProviderglobally and callload_from_datalater; keep a strong ref.- windowCssProvider = gtk_css_provider_new(); - gtk_style_context_add_provider( + windowCssProvider = gtk_css_provider_new(); + gtk_style_context_add_provider( gtk_widget_get_style_context(GTK_WIDGET(options->webviewBox)), GTK_STYLE_PROVIDER(windowCssProvider), GTK_STYLE_PROVIDER_PRIORITY_USER); - g_object_unref(windowCssProvider); + // keep our reference; free when tearing down the window if neededAlso applies to: 197-204
551-552: Remove unused stub.
onDeleteis defined but unused.-static void onDelete(GtkWidget* self) {} +// (removed unused stub)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
v2/internal/frontend/desktop/linux/window_webkit6.c(1 hunks)v2/internal/frontend/desktop/linux/window_webkit6.go(1 hunks)v2/internal/frontend/desktop/linux/window_webkit6.h(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
v2/internal/frontend/desktop/linux/window_webkit6.go (5)
v2/internal/frontend/desktop/linux/window.go (2)
NewWindow(62-149)Window(40-53)v2/internal/frontend/desktop/linux/window_webkit6.c (36)
SetupInvokeSignal(125-128)SetupWebview(554-605)ConnectButtons(351-361)DevtoolsEnabled(607-617)InstallF12Hotkey(915-925)DisableContextMenu(300-304)SetBackgroundColour(157-204)SetTitle(216-222)SetWindowIcon(131-147)SetWindowTransparency(149-153)GTKWIDGET(30-33)GTKWINDOW(35-38)GTKBOX(40-43)Fullscreen(455-471)ExecuteOnMainThread(25-28)UnFullscreen(473-478)Center(389-411)SetPosition(237-249)SetMinMaxSize(252-291)Show(413-418)Hide(420-425)Maximise(427-432)UnMaximise(434-439)Minimise(441-446)UnMinimise(448-453)IsFullscreen(363-367)IsMaximised(369-373)IsMinimised(375-385)LoadIndex(619-622)ExecuteJS(678-684)StartDrag(643-649)StartResize(669-676)AllocFileFilterArray(756-759)Opendialog(809-896)MessageDialog(704-752)ShowInspector(905-908)v2/pkg/options/linux/linux.go (2)
WebviewGpuPolicy(4-4)WebviewGpuPolicyNever(12-12)v2/pkg/options/options.go (5)
DragAndDrop(201-216)RGBA(111-116)WindowStartState(22-22)Minimised(27-27)Maximised(26-26)v2/internal/frontend/desktop/linux/calloc.go (1)
NewCalloc(18-20)
v2/internal/frontend/desktop/linux/window_webkit6.c (3)
v2/internal/frontend/runtime/desktop/events.js (1)
data(105-105)v2/internal/frontend/runtime/desktop/draganddrop.js (1)
files(136-136)v2/internal/frontend/desktop/linux/dialog.go (1)
GTK_FILE_CHOOSER_ACTION_SAVE(19-19)
v2/internal/frontend/desktop/linux/window_webkit6.h (1)
v2/internal/frontend/desktop/linux/window_webkit6.c (39)
ExecuteOnMainThread(25-28)GTKWIDGET(30-33)GTKWINDOW(35-38)GTKBOX(40-43)SetupInvokeSignal(125-128)SetWindowIcon(131-147)SetWindowTransparency(149-153)SetBackgroundColour(157-204)SetTitle(216-222)SetPosition(237-249)SetMinMaxSize(252-291)DisableContextMenu(300-304)ConnectButtons(351-361)IsFullscreen(363-367)IsMaximised(369-373)IsMinimised(375-385)Center(389-411)Show(413-418)Hide(420-425)Maximise(427-432)UnMaximise(434-439)Minimise(441-446)UnMinimise(448-453)Fullscreen(455-471)UnFullscreen(473-478)SetupWebview(554-605)LoadIndex(619-622)DevtoolsEnabled(607-617)ExecuteJS(678-684)StartDrag(643-649)StartResize(669-676)MessageDialog(704-752)AllocFileFilterArray(756-759)Opendialog(809-896)sendShowInspectorMessage(910-912)ShowInspector(905-908)InstallF12Hotkey(915-925)createApp(933-937)runApp(939-942)
🪛 Clang (14.0.6)
v2/internal/frontend/desktop/linux/window_webkit6.c
[error] 4-4: 'jsc/jsc.h' file not found
(clang-diagnostic-error)
v2/internal/frontend/desktop/linux/window_webkit6.h
[error] 7-7: 'jsc/jsc.h' file not found
(clang-diagnostic-error)
🔇 Additional comments (1)
v2/internal/frontend/desktop/linux/window_webkit6.go (1)
6-12: Based on my research, the original JavaScriptCore API (e.g. JSContextRef and JSObjectRef) has been replaced by the GObject-style JavaScriptCore API (e.g. [[email protected]] and [[email protected]]) that is available since 2.22, and this is available in javascriptcoregtk-6.0. Additionally, the Ubuntu bug tracker shows thatjsc/jsc.h: No such file or directoryerrors occur when the header is not properly included, and multiple real-world examples demonstrate that projects building with WebKit report missing javascriptcoregtk as a separate dependency requirement.The review comment is technically sound: the code includes
<jsc/jsc.h>, which requires a separate pkg-config declaration forjavascriptcoregtk-6.0. The suggested diff is correct.Add missing pkg-config for JavaScriptCore to fix 'jsc/jsc.h' include.
The JavaScriptCore 6.0 API is a separate package that must be declared in pkg-config flags. Without
javascriptcoregtk-6.0, compilation will fail.Apply:
/* -#cgo pkg-config: gtk4 webkitgtk-6.0 +#cgo pkg-config: gtk4 webkitgtk-6.0 javascriptcoregtk-6.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
♻️ Duplicate comments (9)
v2/internal/frontend/desktop/linux/window_webkit6.go (5)
350-351: Center() is a no‑op on GTK4; drop the call or annotate.Avoid misleading no‑op calls until implemented.
Apply this diff:
- w.Center() + // Center() is currently a no-op on GTK4/webkit_6.
327-331: SetWindowIcon currently calls a stub.No icon will be set under webkit_6. Either implement in C or gate this call behind availability and log a single warning.
181-183: Fix incorrect cast in asGTKBox().Casting GtkWindow to GtkBox is invalid; return the actual box.
Apply this diff:
func (w *Window) asGTKBox() *C.GtkBox { - return C.GTKBOX(w.gtkWindow) + return C.GTKBOX(unsafe.Pointer(w.vbox)) }
403-412: Quit() is a no‑op on GTK4; call GApplication quit.When mainLoop is nil, the app never exits. Keep the guard and also quit the GApplication on the GTK thread.
Apply this diff:
func (w *Window) Quit() { - if mainLoop == nil { - return - } - - C.g_main_loop_quit(mainLoop) - C.g_main_loop_unref(mainLoop) - - mainLoop = nil + if mainLoop != nil { + C.g_main_loop_quit(mainLoop) + C.g_main_loop_unref(mainLoop) + mainLoop = nil + } + invokeOnMainThread(func() { + C.g_application_quit((*C.GApplication)(unsafe.Pointer(w.gtkApp))) + }) }
500-514: Call MessageDialog on the GTK main thread (no goroutine).GTK APIs must run on the main thread.
Apply this diff:
func showModalDialogAndExit(title, message string) { - go func() { - data := C.MessageDialogOptions{ - title: C.CString(title), - message: C.CString(message), - messageType: C.int(1), - } - - C.MessageDialog(unsafe.Pointer(&data)) - }() + invokeOnMainThread(func() { + data := C.MessageDialogOptions{ + title: C.CString(title), + message: C.CString(message), + messageType: C.int(1), + } + C.MessageDialog(unsafe.Pointer(&data)) + }) <-messageDialogResult log.Fatal(message) }v2/internal/frontend/desktop/linux/window_webkit6.c (4)
393-416: Center() is intentionally a no‑op (GTK4 removed move).Either implement a GTK4 alternative later or keep as documented no‑op. Ensure the Go call site doesn’t invoke it (see window_webkit6.go Lines 350‑351).
642-647: Fix type passed to gdk_toplevel_begin_move.First arg must be GdkToplevel*. Convert from GtkWindow via GtkNative/GdkSurface.
Apply this diff:
- gdk_toplevel_begin_move(options->mainwindow, NULL, mouseButton, xroot, yroot, dragTime); + GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(options->mainwindow)); + gdk_toplevel_begin_move(GDK_TOPLEVEL(surface), NULL, mouseButton, xroot, yroot, dragTime);
669-673: Fix type passed to gdk_toplevel_begin_resize.Same conversion needed as for move.
Apply this diff:
- gdk_toplevel_begin_resize(options->mainwindow, options->edge, NULL, mouseButton, xroot, yroot, dragTime); + GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(options->mainwindow)); + gdk_toplevel_begin_resize(GDK_TOPLEVEL(surface), options->edge, NULL, mouseButton, xroot, yroot, dragTime);
760-760: Fix invalid C prototype order (“void extern”).C requires “extern void …”.
Apply this diff:
-void extern processOpenFileResult(void *); +extern void processOpenFileResult(void *);
🧹 Nitpick comments (2)
v2/internal/frontend/desktop/linux/window_webkit6.go (1)
6-9: Surface required system packages in “doctor” for -tags webkit_6.Add doctor checks to verify gtk4 and webkitgtk-6.0 dev packages and headers (e.g., jsc/jsc.h). This will preempt build failures.
v2/internal/frontend/desktop/linux/window_webkit6.h (1)
7-9: Build deps: ensure jsc/jsc.h is available.Document that webkitgtk-6.0 (packages providing JavaScriptCore headers) must be installed; consider adding a doctor check.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
v2/internal/frontend/desktop/linux/window_webkit6.c(1 hunks)v2/internal/frontend/desktop/linux/window_webkit6.go(1 hunks)v2/internal/frontend/desktop/linux/window_webkit6.h(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
v2/internal/frontend/desktop/linux/window_webkit6.go (4)
v2/internal/frontend/desktop/linux/window.go (2)
NewWindow(62-149)Window(40-53)v2/internal/frontend/desktop/linux/window_webkit6.c (36)
SetupInvokeSignal(130-133)SetupWebview(560-611)ConnectButtons(356-366)DevtoolsEnabled(613-623)InstallF12Hotkey(921-931)DisableContextMenu(305-309)SetBackgroundColour(162-209)SetTitle(221-227)SetWindowIcon(136-152)SetWindowTransparency(154-158)GTKWIDGET(30-33)GTKWINDOW(35-38)GTKBOX(40-43)Fullscreen(460-476)ExecuteOnMainThread(25-28)UnFullscreen(478-483)Center(394-416)SetPosition(242-254)SetMinMaxSize(257-296)Show(418-423)Hide(425-430)Maximise(432-437)UnMaximise(439-444)Minimise(446-451)UnMinimise(453-458)IsFullscreen(368-372)IsMaximised(374-378)IsMinimised(380-390)LoadIndex(625-628)ExecuteJS(684-690)StartDrag(649-655)StartResize(675-682)AllocFileFilterArray(762-765)Opendialog(815-902)MessageDialog(710-758)ShowInspector(911-914)v2/pkg/options/linux/linux.go (2)
WebviewGpuPolicy(4-4)WebviewGpuPolicyNever(12-12)v2/internal/frontend/desktop/linux/calloc.go (1)
NewCalloc(18-20)
v2/internal/frontend/desktop/linux/window_webkit6.c (2)
v2/internal/frontend/runtime/desktop/draganddrop.js (1)
files(136-136)v2/internal/frontend/desktop/linux/dialog.go (1)
GTK_FILE_CHOOSER_ACTION_SAVE(19-19)
v2/internal/frontend/desktop/linux/window_webkit6.h (1)
v2/internal/frontend/desktop/linux/window_webkit6.c (39)
ExecuteOnMainThread(25-28)GTKWIDGET(30-33)GTKWINDOW(35-38)GTKBOX(40-43)SetupInvokeSignal(130-133)SetWindowIcon(136-152)SetWindowTransparency(154-158)SetBackgroundColour(162-209)SetTitle(221-227)SetPosition(242-254)SetMinMaxSize(257-296)DisableContextMenu(305-309)ConnectButtons(356-366)IsFullscreen(368-372)IsMaximised(374-378)IsMinimised(380-390)Center(394-416)Show(418-423)Hide(425-430)Maximise(432-437)UnMaximise(439-444)Minimise(446-451)UnMinimise(453-458)Fullscreen(460-476)UnFullscreen(478-483)SetupWebview(560-611)LoadIndex(625-628)DevtoolsEnabled(613-623)ExecuteJS(684-690)StartDrag(649-655)StartResize(675-682)MessageDialog(710-758)AllocFileFilterArray(762-765)Opendialog(815-902)sendShowInspectorMessage(916-918)ShowInspector(911-914)InstallF12Hotkey(921-931)createApp(939-943)runApp(945-948)
🪛 Clang (14.0.6)
v2/internal/frontend/desktop/linux/window_webkit6.c
[error] 4-4: 'jsc/jsc.h' file not found
(clang-diagnostic-error)
v2/internal/frontend/desktop/linux/window_webkit6.h
[error] 7-7: 'jsc/jsc.h' file not found
(clang-diagnostic-error)
| func (w *Window) GetPosition() (int, int) { | ||
| //// TODO: gtk_window_get_position was removed in gtk4 | ||
| // var width, height C.int | ||
| // var wg sync.WaitGroup | ||
| // wg.Add(1) | ||
| // invokeOnMainThread(func() { | ||
| // C.gtk_window_get_position(w.asGTKWindow(), &width, &height) | ||
| // wg.Done() | ||
| // }) | ||
| // wg.Wait() | ||
| // return int(width), int(height) | ||
| return 0, 0 | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Position/min/max size are stubs; options are silently ignored.
GetPosition returns (0,0) and SetMin/MaxSize call a no-op C function. Either implement a GTK4-friendly fallback (size-allocate clamping) or clearly document the limitation and log once at startup.
Would you like a follow-up patch that clamps sizes via size-allocate and signals?
Also applies to: 247-261
🤖 Prompt for AI Agents
In v2/internal/frontend/desktop/linux/window_webkit6.go around lines 233-245
(and similarly for 247-261), GetPosition currently returns a hardcoded (0,0) and
SetMin/SetMaxSize are no-ops which silently ignore limits; replace these stubs
with a GTK4-compatible implementation or add a clear one-time startup log and
documented limitation: implement size clamping by connecting to the
"size-allocate" signal on the GTK window (on the main thread) to enforce min/max
constraints and maintain/return the last known position from allocate/configure
events, or if you cannot implement clamping now, add a single startup log
warning explaining that position/min/max are not supported on GTK4 and ensure
the functions return deterministic values and do not silently ignore inputs.
|
@leaanthony I don't see any workarounds for gtk4's removal of window positioning and I'll respect that that's the direction they want to go in so I've just left it as is. I've fixed checking window minimization state. Drag and drop should be working now. And I added window transparency but just be aware that the transparency affects the entire widget including the menu and all of the webview's contents. I'm marking this as ready. I've done all I can and it does successfully utilize webkitgtk-6. |
|
@leaanthony Are you able to look this over? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question: just wondering why you went with #ifdef in some files and separating out the different versions using the filename convention in others. I'm not against it but the separation pattern is what we have elsewhere. Might be easier to read? Just curious
|
Yeah, I don't consider it ideal either. But my intent was to reduce the amount of duplicated files/code where there was little to no change in the Go side of the code. Do you want me to migrate the |
|
I think it might be easier to follow/debug? Might be something an LLM can do reasonably quickly. I'm going to try and get a v2 release out today and will look at including this in the next release. I'll install a fresh linux to test today. |
|
Alright. That's great. I prefer to migrate it myself. But I'll try to get it done soon. |
|
The |
|
Legend! 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (14)
v2/internal/frontend/desktop/linux/clipboard.go(1 hunks)v2/internal/frontend/desktop/linux/clipboard_webkit6.go(1 hunks)v2/internal/frontend/desktop/linux/frontend.go(1 hunks)v2/internal/frontend/desktop/linux/frontend_webkit6.go(1 hunks)v2/internal/frontend/desktop/linux/keys.go(1 hunks)v2/internal/frontend/desktop/linux/keys_webkit6.go(1 hunks)v2/internal/frontend/desktop/linux/webkit2.go(1 hunks)v2/internal/frontend/desktop/linux/webkit6.go(1 hunks)v2/pkg/assetserver/webview/request_linux.go(1 hunks)v2/pkg/assetserver/webview/request_linux_webkit6.go(1 hunks)v2/pkg/assetserver/webview/responsewriter_linux.go(1 hunks)v2/pkg/assetserver/webview/responsewriter_linux_webkit6.go(1 hunks)v2/pkg/assetserver/webview/webkit2_36+.go(1 hunks)v2/pkg/assetserver/webview/webkit6.go(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- v2/pkg/assetserver/webview/webkit2_36+.go
🚧 Files skipped from review as they are similar to previous changes (5)
- v2/internal/frontend/desktop/linux/webkit2.go
- v2/pkg/assetserver/webview/responsewriter_linux.go
- v2/pkg/assetserver/webview/request_linux.go
- v2/internal/frontend/desktop/linux/keys.go
- v2/internal/frontend/desktop/linux/clipboard.go
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:29-30
Timestamp: 2025-08-08T10:25:32.415Z
Learning: For Wails v3 Linux nfpm template, Debian/Ubuntu WebKitGTK runtime package names differ: Debian 12 (Bookworm) uses libwebkit2gtk-4.1-0 while Ubuntu 22.04 (Jammy) uses libwebkit2gtk-4.0-37. Prefer an OR dependency "libwebkit2gtk-4.1-0 | libwebkit2gtk-4.0-37" in v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl to support both.
Learnt from: Sammy-T
Repo: wailsapp/wails PR: 4570
File: v2/internal/frontend/desktop/linux/window_webkit6.go:97-108
Timestamp: 2025-10-17T23:16:11.570Z
Learning: For webkit_6/GTK4 builds in v2/internal/frontend/desktop/linux/window_webkit6.go, GTK widget creation should not be wrapped in invokeOnMainThread. The activation mechanism (activateWg + onActivate export) already handles thread safety, and additional wrapping would cause issues.
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:37-38
Timestamp: 2025-08-08T11:10:17.787Z
Learning: In Wails v3 nfpm templates for RPM (RHEL-family), do not use a boolean OR between webkit2gtk3 and webkit2gtk4.1. Binaries built against WebKitGTK 4.1 are not ABI-compatible with 4.0, so the dependency must be pinned to the exact ABI: use webkit2gtk4.1 for 4.1 builds (e.g., RHEL/Rocky 10) and webkit2gtk3 for 4.0 builds (RHEL/Rocky 8/9).
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:29-30
Timestamp: 2025-08-08T10:25:32.415Z
Learning: Ubuntu 22.04 (Jammy) official repos include both WebKitGTK runtimes: libwebkit2gtk-4.0-37 and libwebkit2gtk-4.1-0 (Universe). For nfpm templates, depend on the exact SONAME matching the built ABI (use libwebkit2gtk-4.1-0 when targeting 4.1; use libwebkit2gtk-4.0-37 when targeting 4.0) rather than an OR across ABIs.
📚 Learning: 2025-10-17T23:16:11.570Z
Learnt from: Sammy-T
Repo: wailsapp/wails PR: 4570
File: v2/internal/frontend/desktop/linux/window_webkit6.go:97-108
Timestamp: 2025-10-17T23:16:11.570Z
Learning: For webkit_6/GTK4 builds in v2/internal/frontend/desktop/linux/window_webkit6.go, GTK widget creation should not be wrapped in invokeOnMainThread. The activation mechanism (activateWg + onActivate export) already handles thread safety, and additional wrapping would cause issues.
Applied to files:
v2/internal/frontend/desktop/linux/frontend.gov2/internal/frontend/desktop/linux/keys_webkit6.gov2/pkg/assetserver/webview/request_linux_webkit6.gov2/pkg/assetserver/webview/responsewriter_linux_webkit6.gov2/internal/frontend/desktop/linux/clipboard_webkit6.gov2/pkg/assetserver/webview/webkit6.gov2/internal/frontend/desktop/linux/webkit6.gov2/internal/frontend/desktop/linux/frontend_webkit6.go
📚 Learning: 2025-08-08T10:25:32.415Z
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:29-30
Timestamp: 2025-08-08T10:25:32.415Z
Learning: For Wails v3 Linux nfpm template, Debian/Ubuntu WebKitGTK runtime package names differ: Debian 12 (Bookworm) uses libwebkit2gtk-4.1-0 while Ubuntu 22.04 (Jammy) uses libwebkit2gtk-4.0-37. Prefer an OR dependency "libwebkit2gtk-4.1-0 | libwebkit2gtk-4.0-37" in v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl to support both.
Applied to files:
v2/internal/frontend/desktop/linux/frontend.gov2/pkg/assetserver/webview/webkit6.gov2/internal/frontend/desktop/linux/webkit6.go
📚 Learning: 2025-08-08T09:13:16.916Z
Learnt from: APshenkin
Repo: wailsapp/wails PR: 4480
File: v2/internal/frontend/desktop/darwin/message.h:17-19
Timestamp: 2025-08-08T09:13:16.916Z
Learning: In Wails v2 bindings origin verification, processBindingMessage intentionally has different signatures across platforms: Darwin includes an isMainFrame bool (WKWebKit provides it), Linux uses two params (message, source) as WebKitGTK doesn’t expose main-frame info there, and Windows handles origin checks in Go via WebView2 sender/args without a C bridge. This divergence is acceptable/expected per maintainer (APshenkin).
Applied to files:
v2/pkg/assetserver/webview/responsewriter_linux_webkit6.gov2/pkg/assetserver/webview/webkit6.gov2/internal/frontend/desktop/linux/webkit6.gov2/internal/frontend/desktop/linux/frontend_webkit6.go
📚 Learning: 2025-08-08T11:10:17.787Z
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:37-38
Timestamp: 2025-08-08T11:10:17.787Z
Learning: In Wails v3 nfpm templates for RPM (RHEL-family), do not use a boolean OR between webkit2gtk3 and webkit2gtk4.1. Binaries built against WebKitGTK 4.1 are not ABI-compatible with 4.0, so the dependency must be pinned to the exact ABI: use webkit2gtk4.1 for 4.1 builds (e.g., RHEL/Rocky 10) and webkit2gtk3 for 4.0 builds (RHEL/Rocky 8/9).
Applied to files:
v2/pkg/assetserver/webview/webkit6.gov2/internal/frontend/desktop/linux/webkit6.go
📚 Learning: 2025-08-08T10:25:32.415Z
Learnt from: Mihara
Repo: wailsapp/wails PR: 4481
File: v3/internal/commands/updatable_build_assets/linux/nfpm/nfpm.yaml.tmpl:29-30
Timestamp: 2025-08-08T10:25:32.415Z
Learning: Ubuntu 22.04 (Jammy) official repos include both WebKitGTK runtimes: libwebkit2gtk-4.0-37 and libwebkit2gtk-4.1-0 (Universe). For nfpm templates, depend on the exact SONAME matching the built ABI (use libwebkit2gtk-4.1-0 when targeting 4.1; use libwebkit2gtk-4.0-37 when targeting 4.0) rather than an OR across ABIs.
Applied to files:
v2/pkg/assetserver/webview/webkit6.gov2/internal/frontend/desktop/linux/webkit6.go
📚 Learning: 2024-09-30T06:13:46.595Z
Learnt from: leaanthony
Repo: wailsapp/wails PR: 3763
File: v3/examples/window/main.go:472-475
Timestamp: 2024-09-30T06:13:46.595Z
Learning: In `v3/examples/window/main.go`, `time.Sleep` is used within a goroutine and does not block the UI thread.
Applied to files:
v2/internal/frontend/desktop/linux/frontend_webkit6.go
🧬 Code graph analysis (5)
v2/internal/frontend/desktop/linux/keys_webkit6.go (1)
v2/pkg/menu/keys/keys.go (5)
Modifier(9-9)ShiftKey(17-17)ControlKey(21-21)CmdOrCtrlKey(13-13)OptionOrAltKey(15-15)
v2/pkg/assetserver/webview/request_linux_webkit6.go (2)
v2/pkg/assetserver/webview/request.go (1)
Request(8-17)v2/pkg/assetserver/webview/responsewriter.go (1)
ResponseWriter(20-25)
v2/internal/frontend/desktop/linux/clipboard_webkit6.go (1)
v2/internal/frontend/desktop/windows/win32/clipboard.go (2)
GetClipboardText(37-75)SetClipboardText(77-143)
v2/internal/frontend/desktop/linux/webkit6.go (1)
v2/pkg/assetserver/webview/webkit6.go (1)
Webkit2MinMinorVersion(23-23)
v2/internal/frontend/desktop/linux/frontend_webkit6.go (6)
v2/pkg/options/options.go (4)
SecondInstanceData(196-199)SingleInstanceLock(190-194)RGBA(111-116)DragAndDrop(201-216)v2/internal/frontend/originvalidator/originValidator.go (2)
OriginValidator(10-12)NewOriginValidator(15-23)v2/pkg/assetserver/assetserver.go (1)
NewAssetServerMainPage(53-59)v2/pkg/assetserver/webview/request.go (1)
Request(8-17)v2/pkg/assetserver/webview/request_linux.go (1)
NewRequest(23-29)v2/pkg/assetserver/webview/request_linux_webkit6.go (1)
NewRequest(21-27)
|


Description
This adds an option to run or build an app on Linux using webkitgtk-6.0.
Depends on:
Fixes #3193
Type of change
Important
Features which have been removed/deprecated from webkit or gtk4 have been marked with todos.
If they can be reimplemented, using this library option could potentially match the functionality of the current implementation.
How Has This Been Tested?
Ubuntu 22.04
The performance is usually noticeable on an app with scrolled content or a complex layout.
Running/Building the app with this PR's changes requires:
-tags webkit_6to the WailsdevorbuildcommandWarnings:
New application windows must be added after the GApplication::startup signal has been emitted.Test Configuration
Requires webkitgtk-6 and gtk4.
Checklist:
website/src/pages/changelog.mdxwith details of this PRSummary by CodeRabbit
New Features
Chores
New Features
✏️ Tip: You can customize this high-level summary in your review settings.