mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
app: detect fullscreen mode for macOS and Windows
When an application goes into or out of fullscreen mode, Gio now emits a ConfigEvent with the current window mode. Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
@@ -97,6 +97,11 @@ static void toggleFullScreen(CFTypeRef windowRef) {
|
||||
[window toggleFullScreen:nil];
|
||||
}
|
||||
|
||||
static NSWindowStyleMask getWindowStyleMask(CFTypeRef windowRef) {
|
||||
NSWindow *window = (__bridge NSWindow *)windowRef;
|
||||
return [window styleMask];
|
||||
}
|
||||
|
||||
static void closeWindow(CFTypeRef windowRef) {
|
||||
NSWindow* window = (__bridge NSWindow *)windowRef;
|
||||
[window performClose:nil];
|
||||
@@ -227,10 +232,20 @@ func (w *window) WriteClipboard(s string) {
|
||||
C.writeClipboard(chars, C.NSUInteger(len(u16)))
|
||||
}
|
||||
|
||||
func (w *window) updateWindowMode() {
|
||||
style := int(C.getWindowStyleMask(w.window))
|
||||
if style&C.NSWindowStyleMaskFullScreen > 0 {
|
||||
w.config.Mode = Fullscreen
|
||||
} else {
|
||||
w.config.Mode = Windowed
|
||||
}
|
||||
}
|
||||
|
||||
func (w *window) Configure(options []Option) {
|
||||
screenScale := float32(C.getScreenBackingScale())
|
||||
cfg := configFor(screenScale)
|
||||
prev := w.config
|
||||
w.updateWindowMode()
|
||||
cnf := w.config
|
||||
cnf.apply(cfg, options)
|
||||
cnf.Size = cnf.Size.Div(int(screenScale))
|
||||
@@ -473,6 +488,20 @@ func gio_onShow(view C.CFTypeRef) {
|
||||
w.setStage(system.StageRunning)
|
||||
}
|
||||
|
||||
//export gio_onFullscreen
|
||||
func gio_onFullscreen(view C.CFTypeRef) {
|
||||
w := mustView(view)
|
||||
w.config.Mode = Fullscreen
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
//export gio_onWindowed
|
||||
func gio_onWindowed(view C.CFTypeRef) {
|
||||
w := mustView(view)
|
||||
w.config.Mode = Windowed
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
//export gio_onAppHide
|
||||
func gio_onAppHide() {
|
||||
for _, w := range viewMap {
|
||||
|
||||
Reference in New Issue
Block a user