mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
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:
committed by
Travis McLane
parent
adae39efee
commit
758c4c2c8d
@@ -67,7 +67,7 @@ func (l *linuxApp) name() string {
|
||||
}
|
||||
|
||||
func (l *linuxApp) getCurrentWindowID() uint {
|
||||
return getCurrentWindowID(l.application, l.windows)
|
||||
return getCurrentWindowID(l.application, l.windowMap)
|
||||
}
|
||||
|
||||
type rnr struct {
|
||||
@@ -112,6 +112,17 @@ func (l *linuxApp) run() error {
|
||||
return appRun(l.application)
|
||||
}
|
||||
|
||||
func (l *linuxApp) unregisterWindow(w windowPointer) {
|
||||
l.windowMapLock.Lock()
|
||||
delete(l.windowMap, w)
|
||||
l.windowMapLock.Unlock()
|
||||
|
||||
// If this was the last window...
|
||||
if len(l.windowMap) == 0 && !l.parent.options.Linux.DisableQuitOnLastWindowClosed {
|
||||
l.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
func (l *linuxApp) destroy() {
|
||||
if !globalApplication.shouldQuit() {
|
||||
return
|
||||
@@ -126,9 +137,9 @@ func (l *linuxApp) isOnMainThread() bool {
|
||||
|
||||
// register our window to our parent mapping
|
||||
func (l *linuxApp) registerWindow(window pointer, id uint) {
|
||||
l.windowsLock.Lock()
|
||||
l.windows[windowPointer(window)] = id
|
||||
l.windowsLock.Unlock()
|
||||
l.windowMapLock.Lock()
|
||||
l.windowMap[windowPointer(window)] = id
|
||||
l.windowMapLock.Unlock()
|
||||
}
|
||||
|
||||
func (l *linuxApp) isDarkMode() bool {
|
||||
|
||||
@@ -110,6 +110,24 @@ func (w *linuxWebviewWindow) disableSizeConstraints() {
|
||||
w.setMinMaxSize(x, y, width*scale, height*scale)
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) unfullscreen() {
|
||||
windowUnfullscreen(w.window)
|
||||
w.unmaximise()
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) fullscreen() {
|
||||
w.maximise()
|
||||
//w.lastWidth, w.lastHeight = w.size()
|
||||
x, y, width, height, scale := windowGetCurrentMonitorGeometry(w.window)
|
||||
if x == -1 && y == -1 && width == -1 && height == -1 {
|
||||
return
|
||||
}
|
||||
w.setMinMaxSize(0, 0, width*scale, height*scale)
|
||||
w.setSize(width*scale, height*scale)
|
||||
windowFullscreen(w.window)
|
||||
w.setRelativePosition(0, 0)
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) unminimise() {
|
||||
w.present()
|
||||
}
|
||||
@@ -127,6 +145,27 @@ func (w *linuxWebviewWindow) windowZoom() {
|
||||
w.zoom() // FIXME> This should be removed
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) close() {
|
||||
windowClose(w.window)
|
||||
getNativeApplication().unregisterWindow(windowPointer(w.window))
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) zoomIn() {
|
||||
windowZoomIn(w.webview)
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) zoomOut() {
|
||||
windowZoomOut(w.webview)
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) zoomReset() {
|
||||
windowZoomSet(w.webview, 1.0)
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) reload() {
|
||||
windowReload(w.webview, "wails://")
|
||||
}
|
||||
|
||||
func (w *linuxWebviewWindow) forceReload() {
|
||||
w.reload()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user