mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
Set MacOS window levels (NSWindow) (#3674)
* set nswindow levels via mac options * add changelog description * update changelog to conform with others
This commit is contained in:
parent
1ed6966cbe
commit
b756bce67f
3 changed files with 52 additions and 0 deletions
|
|
@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Add flag `-port` to dev command and support environment variable `WAILS_VITE_PORT` by [@abichinger](https://github.com/abichinger) in [#3429](https://github.com/wailsapp/wails/pull/3429)
|
||||
- Add tests for bound method calls by [@abichinger](https://github.com/abichinger) in [#3431](https://github.com/wailsapp/wails/pull/3431)
|
||||
- [windows] add `SetIgnoreMouseEvents` for already created window by [@bruxaodev](https://github.com/bruxaodev) in [#3667](https://github.com/wailsapp/wails/pull/3667)
|
||||
- [darwin] Add ability to set a window's stacking level (order) by [@OlegGulevskyy](https://github.com/OlegGulevskyy) in [#3674](https://github.com/wailsapp/wails/pull/3674)
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
|||
|
|
@ -216,6 +216,15 @@ void windowSetAlwaysOnTop(void* nsWindow, bool alwaysOnTop) {
|
|||
[(WebviewWindow*)nsWindow setLevel:alwaysOnTop ? NSFloatingWindowLevel : NSNormalWindowLevel];
|
||||
}
|
||||
|
||||
void setNormalWindowLevel(void* nsWindow) { [(WebviewWindow*)nsWindow setLevel:NSNormalWindowLevel]; }
|
||||
void setFloatingWindowLevel(void* nsWindow) { [(WebviewWindow*)nsWindow setLevel:NSFloatingWindowLevel];}
|
||||
void setPopUpMenuWindowLevel(void* nsWindow) { [(WebviewWindow*)nsWindow setLevel:NSPopUpMenuWindowLevel]; }
|
||||
void setMainMenuWindowLevel(void* nsWindow) { [(WebviewWindow*)nsWindow setLevel:NSMainMenuWindowLevel]; }
|
||||
void setStatusWindowLevel(void* nsWindow) { [(WebviewWindow*)nsWindow setLevel:NSStatusWindowLevel]; }
|
||||
void setModalPanelWindowLevel(void* nsWindow) { [(WebviewWindow*)nsWindow setLevel:NSModalPanelWindowLevel]; }
|
||||
void setScreenSaverWindowLevel(void* nsWindow) { [(WebviewWindow*)nsWindow setLevel:NSScreenSaverWindowLevel]; }
|
||||
void setTornOffMenuWindowLevel(void* nsWindow) { [(WebviewWindow*)nsWindow setLevel:NSTornOffMenuWindowLevel]; }
|
||||
|
||||
// Load URL in NSWindow
|
||||
void navigationLoadURL(void* nsWindow, char* url) {
|
||||
// Load URL on main thread
|
||||
|
|
@ -1072,6 +1081,27 @@ func (w *macosWebviewWindow) setRelativePosition(x, y int) {
|
|||
C.windowSetRelativePosition(w.nsWindow, C.int(x), C.int(y))
|
||||
}
|
||||
|
||||
func (w *macosWebviewWindow) setWindowLevel(level MacWindowLevel) {
|
||||
switch level {
|
||||
case MacWindowLevelNormal:
|
||||
C.setNormalWindowLevel(w.nsWindow)
|
||||
case MacWindowLevelFloating:
|
||||
C.setFloatingWindowLevel(w.nsWindow)
|
||||
case MacWindowLevelTornOffMenu:
|
||||
C.setTornOffMenuWindowLevel(w.nsWindow)
|
||||
case MacWindowLevelModalPanel:
|
||||
C.setModalPanelWindowLevel(w.nsWindow)
|
||||
case MacWindowLevelMainMenu:
|
||||
C.setMainMenuWindowLevel(w.nsWindow)
|
||||
case MacWindowLevelStatus:
|
||||
C.setStatusWindowLevel(w.nsWindow)
|
||||
case MacWindowLevelPopUpMenu:
|
||||
C.setPopUpMenuWindowLevel(w.nsWindow)
|
||||
case MacWindowLevelScreenSaver:
|
||||
C.setScreenSaverWindowLevel(w.nsWindow)
|
||||
}
|
||||
}
|
||||
|
||||
func (w *macosWebviewWindow) width() int {
|
||||
var width C.int
|
||||
var wg sync.WaitGroup
|
||||
|
|
@ -1158,6 +1188,11 @@ func (w *macosWebviewWindow) run() {
|
|||
case MacBackdropNormal:
|
||||
}
|
||||
|
||||
if macOptions.WindowLevel == "" {
|
||||
macOptions.WindowLevel = MacWindowLevelNormal
|
||||
}
|
||||
w.setWindowLevel(macOptions.WindowLevel)
|
||||
|
||||
// Initialise the window buttons
|
||||
w.setMinimiseButtonState(options.MinimiseButtonState)
|
||||
w.setMaximiseButtonState(options.MaximiseButtonState)
|
||||
|
|
|
|||
|
|
@ -380,8 +380,24 @@ type MacWindow struct {
|
|||
|
||||
// WebviewPreferences contains preferences for the webview
|
||||
WebviewPreferences MacWebviewPreferences
|
||||
|
||||
// WindowLevel sets the window level to control the order of windows in the screen
|
||||
WindowLevel MacWindowLevel
|
||||
}
|
||||
|
||||
type MacWindowLevel string
|
||||
|
||||
const (
|
||||
MacWindowLevelNormal MacWindowLevel = "normal"
|
||||
MacWindowLevelFloating MacWindowLevel = "floating"
|
||||
MacWindowLevelTornOffMenu MacWindowLevel = "tornOffMenu"
|
||||
MacWindowLevelModalPanel MacWindowLevel = "modalPanel"
|
||||
MacWindowLevelMainMenu MacWindowLevel = "mainMenu"
|
||||
MacWindowLevelStatus MacWindowLevel = "status"
|
||||
MacWindowLevelPopUpMenu MacWindowLevel = "popUpMenu"
|
||||
MacWindowLevelScreenSaver MacWindowLevel = "screenSaver"
|
||||
)
|
||||
|
||||
// MacWebviewPreferences contains preferences for the Mac webview
|
||||
type MacWebviewPreferences struct {
|
||||
// TabFocusesLinks will enable tabbing to links
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue