Refactor Linux application handling in webview

This update introduces a LinuxOptions struct for Linux-specific application configurations and refines webview for Linux. The 'windows' map has been renamed to 'windowMap' to avoid confusion. Moreover, a method to unregister Windows has been added to ensure the Linux application automatically quits when the last window closes, unless explicitly disabled in the new LinuxOptions structure. Reset Window position after hiding. Some debug output has been removed.
This commit is contained in:
Lea Anthony
2024-03-06 11:42:19 -06:00
committed by Travis McLane
parent 4c7b643295
commit 809863d61a
4 changed files with 47 additions and 24 deletions
+19 -17
View File
@@ -21,18 +21,19 @@ type dragInfo struct {
}
type linuxWebviewWindow struct {
id uint
application pointer
window pointer
webview pointer
parent *WebviewWindow
menubar pointer
vbox pointer
menu *Menu
accels pointer
lastWidth int
lastHeight int
drag dragInfo
id uint
application pointer
window pointer
webview pointer
parent *WebviewWindow
menubar pointer
vbox pointer
menu *Menu
accels pointer
lastWidth int
lastHeight int
drag dragInfo
lastX, lastY int
}
var (
@@ -109,9 +110,12 @@ func (w *linuxWebviewWindow) focus() {
func (w *linuxWebviewWindow) show() {
windowShow(w.window)
w.setAbsolutePosition(w.lastX, w.lastY)
}
func (w *linuxWebviewWindow) hide() {
// save position
w.lastX, w.lastY = windowGetAbsolutePosition(w.window)
windowHide(w.window)
}
@@ -140,7 +144,7 @@ func (w *linuxWebviewWindow) unfullscreen() {
func (w *linuxWebviewWindow) fullscreen() {
w.maximise()
w.lastWidth, w.lastHeight = w.size()
//w.lastWidth, w.lastHeight = w.size()
x, y, width, height, scale := windowGetCurrentMonitorGeometry(w.window)
if x == -1 && y == -1 && width == -1 && height == -1 {
return
@@ -172,9 +176,7 @@ func (w *linuxWebviewWindow) flash(enabled bool) {
}
func (w *linuxWebviewWindow) on(eventID uint) {
// Don't think this is correct!
// GTK Events are strings
fmt.Println("on()", eventID)
// TODO: Test register/unregister listener for linux events
//C.registerListener(C.uint(eventID))
}
@@ -188,6 +190,7 @@ func (w *linuxWebviewWindow) windowZoom() {
func (w *linuxWebviewWindow) close() {
windowClose(w.window)
getNativeApplication().unregisterWindow(windowPointer(w.window))
}
func (w *linuxWebviewWindow) zoomIn() {
@@ -388,7 +391,6 @@ func (w *linuxWebviewWindow) run() {
if w.parent.options.X != 0 || w.parent.options.Y != 0 {
w.setRelativePosition(w.parent.options.X, w.parent.options.Y)
} else {
fmt.Println("attempting to set in the center")
w.center()
}
switch w.parent.options.StartState {