mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
uis/app: (macos) relay system focus events
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -130,6 +130,12 @@ func gio_onDraw(view C.CFTypeRef) {
|
|||||||
w.draw(true)
|
w.draw(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//export gio_onFocus
|
||||||
|
func gio_onFocus(view C.CFTypeRef, focus C.BOOL) {
|
||||||
|
w := views[view]
|
||||||
|
w.w.event(key.Focus{Focus: focus == C.YES})
|
||||||
|
}
|
||||||
|
|
||||||
func (w *window) draw(sync bool) {
|
func (w *window) draw(sync bool) {
|
||||||
width, height := int(C.gio_viewWidth(w.view)+.5), int(C.gio_viewHeight(w.view)+.5)
|
width, height := int(C.gio_viewWidth(w.view)+.5), int(C.gio_viewHeight(w.view)+.5)
|
||||||
if width == 0 || height == 0 {
|
if width == 0 || height == 0 {
|
||||||
|
|||||||
+10
-4
@@ -33,6 +33,12 @@
|
|||||||
CGDirectDisplayID dispID = [[[self.window screen] deviceDescription][@"NSScreenNumber"] unsignedIntValue];
|
CGDirectDisplayID dispID = [[[self.window screen] deviceDescription][@"NSScreenNumber"] unsignedIntValue];
|
||||||
gio_updateDisplayLink((__bridge CFTypeRef)self.window.contentView, dispID);
|
gio_updateDisplayLink((__bridge CFTypeRef)self.window.contentView, dispID);
|
||||||
}
|
}
|
||||||
|
- (void)windowDidBecomeKey:(NSNotification *)notification {
|
||||||
|
gio_onFocus((__bridge CFTypeRef)self.window.contentView, YES);
|
||||||
|
}
|
||||||
|
- (void)windowDidResignKey:(NSNotification *)notification {
|
||||||
|
gio_onFocus((__bridge CFTypeRef)self.window.contentView, NO);
|
||||||
|
}
|
||||||
- (void)windowWillClose:(NSNotification *)notification {
|
- (void)windowWillClose:(NSNotification *)notification {
|
||||||
gio_onTerminate((__bridge CFTypeRef)self.window.contentView);
|
gio_onTerminate((__bridge CFTypeRef)self.window.contentView);
|
||||||
self.window.delegate = nil;
|
self.window.delegate = nil;
|
||||||
@@ -106,14 +112,14 @@ void gio_main(CFTypeRef viewRef, const char *title, CGFloat width, CGFloat heigh
|
|||||||
[window cascadeTopLeftFromPoint:NSMakePoint(20,20)];
|
[window cascadeTopLeftFromPoint:NSMakePoint(20,20)];
|
||||||
[window setAcceptsMouseMovedEvents:YES];
|
[window setAcceptsMouseMovedEvents:YES];
|
||||||
|
|
||||||
[window setContentView:view];
|
gio_onCreate((__bridge CFTypeRef)view);
|
||||||
[window makeFirstResponder:view];
|
|
||||||
|
|
||||||
GioDelegate *del = [[GioDelegate alloc] init];
|
GioDelegate *del = [[GioDelegate alloc] init];
|
||||||
del.window = window;
|
del.window = window;
|
||||||
[window setDelegate:del];
|
[window setDelegate:del];
|
||||||
[NSApp setDelegate:del];
|
[NSApp setDelegate:del];
|
||||||
gio_onCreate((__bridge CFTypeRef)view);
|
[window setContentView:view];
|
||||||
|
[window makeFirstResponder:view];
|
||||||
|
|
||||||
|
|
||||||
[NSApp run];
|
[NSApp run];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user