@@ -47,13 +47,17 @@ - (void)windowDidChangeScreen:(NSNotification *)notification {
4747}
4848- (void )windowDidBecomeKey : (NSNotification *)notification {
4949 NSWindow *window = (NSWindow *)[notification object ];
50- GioView *view = (GioView *)window.contentView ;
51- gio_onFocus (view.handle , 1 );
50+ GioView *view = (GioView *)window.contentView ;
51+ if ([window firstResponder ] == view) {
52+ gio_onFocus (view.handle , 1 );
53+ }
5254}
5355- (void )windowDidResignKey : (NSNotification *)notification {
5456 NSWindow *window = (NSWindow *)[notification object ];
55- GioView *view = (GioView *)window.contentView ;
56- gio_onFocus (view.handle , 0 );
57+ GioView *view = (GioView *)window.contentView ;
58+ if ([window firstResponder ] == view) {
59+ gio_onFocus (view.handle , 0 );
60+ }
5761}
5862@end
5963
@@ -205,6 +209,14 @@ - (void)applicationDidHide:(NSNotification *)notification {
205209- (void )dealloc {
206210 gio_onDestroy (self.handle );
207211}
212+ - (BOOL ) becomeFirstResponder {
213+ gio_onFocus (self.handle , 1 );
214+ return [super becomeFirstResponder ];
215+ }
216+ - (BOOL ) resignFirstResponder {
217+ gio_onFocus (self.handle , 0 );
218+ return [super resignFirstResponder ];
219+ }
208220@end
209221
210222// Delegates are weakly referenced from their peers. Nothing
0 commit comments