forked from joejulian/gio
app: enable creation of top most windows
Floating windows are rendered above all other non-floating windows. Apple Documentation: https://developer.apple.com/documentation/appkit/nswindow/level-swift.struct Signed-off-by: Thomas Banks <thomas@tombanks.me>
This commit is contained in:
@@ -45,6 +45,8 @@ type Config struct {
|
|||||||
CustomRenderer bool
|
CustomRenderer bool
|
||||||
// Decorated reports whether window decorations are provided automatically.
|
// Decorated reports whether window decorations are provided automatically.
|
||||||
Decorated bool
|
Decorated bool
|
||||||
|
// TopMost windows render above all other non-top-most windows.
|
||||||
|
TopMost bool
|
||||||
// Focused reports whether has the keyboard focus.
|
// Focused reports whether has the keyboard focus.
|
||||||
Focused bool
|
Focused bool
|
||||||
// decoHeight is the height of the fallback decoration for platforms such
|
// decoHeight is the height of the fallback decoration for platforms such
|
||||||
|
|||||||
@@ -241,6 +241,13 @@ static void setTitle(CFTypeRef windowRef, CFTypeRef titleRef) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setWindowLevel(CFTypeRef windowRef, NSWindowLevel level) {
|
||||||
|
@autoreleasepool {
|
||||||
|
NSWindow *window = (__bridge NSWindow *)windowRef;
|
||||||
|
window.level = level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int isWindowZoomed(CFTypeRef windowRef) {
|
static int isWindowZoomed(CFTypeRef windowRef) {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
NSWindow *window = (__bridge NSWindow *)windowRef;
|
NSWindow *window = (__bridge NSWindow *)windowRef;
|
||||||
@@ -495,6 +502,9 @@ func (w *window) Configure(options []Option) {
|
|||||||
barTrans = C.YES
|
barTrans = C.YES
|
||||||
titleVis = C.NSWindowTitleHidden
|
titleVis = C.NSWindowTitleHidden
|
||||||
}
|
}
|
||||||
|
if cnf.TopMost {
|
||||||
|
C.setWindowLevel(window, C.NSFloatingWindowLevel)
|
||||||
|
}
|
||||||
C.setWindowTitlebarAppearsTransparent(window, barTrans)
|
C.setWindowTitlebarAppearsTransparent(window, barTrans)
|
||||||
C.setWindowTitleVisibility(window, titleVis)
|
C.setWindowTitleVisibility(window, titleVis)
|
||||||
C.setWindowStyleMask(window, mask)
|
C.setWindowStyleMask(window, mask)
|
||||||
|
|||||||
@@ -969,6 +969,15 @@ func Decorated(enabled bool) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TopMost windows will be rendered above all other non-top-most windows.
|
||||||
|
//
|
||||||
|
// TopMost windows are only supported on MacOS currently.
|
||||||
|
func TopMost(enabled bool) Option {
|
||||||
|
return func(_ unit.Metric, cnf *Config) {
|
||||||
|
cnf.TopMost = enabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// flushEvent is sent to detect when the user program
|
// flushEvent is sent to detect when the user program
|
||||||
// has completed processing of all prior events. Its an
|
// has completed processing of all prior events. Its an
|
||||||
// [io/event.Event] but only for internal use.
|
// [io/event.Event] but only for internal use.
|
||||||
|
|||||||
Reference in New Issue
Block a user