Skip to content

Commit

Permalink
app: [macOS] ignore focus changes not meant for the Gio view
Browse files Browse the repository at this point in the history
Extracted from #138 by inkeliz.

Signed-off-by: Elias Naur <[email protected]>
  • Loading branch information
eliasnaur committed Jun 16, 2024
1 parent 1151eac commit e878dbc
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions app/os_macos.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ - (void)windowDidChangeScreen:(NSNotification *)notification {
}
- (void)windowDidBecomeKey:(NSNotification *)notification {
NSWindow *window = (NSWindow *)[notification object];
GioView *view = (GioView *)window.contentView;
gio_onFocus(view.handle, 1);
GioView *view = (GioView *)window.contentView;
if ([window firstResponder] == view) {
gio_onFocus(view.handle, 1);
}
}
- (void)windowDidResignKey:(NSNotification *)notification {
NSWindow *window = (NSWindow *)[notification object];
GioView *view = (GioView *)window.contentView;
gio_onFocus(view.handle, 0);
GioView *view = (GioView *)window.contentView;
if ([window firstResponder] == view) {
gio_onFocus(view.handle, 0);
}
}
@end

Expand Down Expand Up @@ -205,6 +209,14 @@ - (void)applicationDidHide:(NSNotification *)notification {
- (void)dealloc {
gio_onDestroy(self.handle);
}
- (BOOL) becomeFirstResponder {
gio_onFocus(self.handle, 1);
return [super becomeFirstResponder];
}
- (BOOL) resignFirstResponder {
gio_onFocus(self.handle, 0);
return [super resignFirstResponder];
}
@end

// Delegates are weakly referenced from their peers. Nothing
Expand Down

0 comments on commit e878dbc

Please sign in to comment.