Skip to content

Commit 52935d9

Browse files
cocoaui: fix became/resigned key handler in DdbSeekBar, PlaylistHeaderView and DdbTabStrip
1 parent 8bb8403 commit 52935d9

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

plugins/cocoaui/DdbTabStrip/DdbTabStrip.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,17 @@ - (void)setup {
208208
[NSNotificationCenter.defaultCenter addObserver:self
209209
selector:@selector(windowDidBecomeKey:)
210210
name:NSWindowDidBecomeKeyNotification
211-
object:self.window];
211+
object:nil];
212212
[NSNotificationCenter.defaultCenter addObserver:self
213213
selector:@selector(windowDidBecomeKey:)
214214
name:NSWindowDidResignKeyNotification
215-
object:self.window];
215+
object:nil];
216216
}
217217

218-
- (void)windowDidBecomeKey:(id)sender {
219-
self.needsDisplay = YES;
218+
- (void)windowDidBecomeKey:(NSNotification *)notification {
219+
if (notification.object == self.window) {
220+
self.needsDisplay = YES;
221+
}
220222
}
221223

222224
- (int)tabWidthForIndex:(int)tab {

plugins/cocoaui/Playlist/PlaylistHeaderView.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,19 @@ - (PlaylistHeaderView *)initWithFrame:(NSRect)rect {
9393
[NSNotificationCenter.defaultCenter addObserver:self
9494
selector:@selector(windowDidBecomeOrResignKey:)
9595
name:NSWindowDidBecomeKeyNotification
96-
object:self.window];
96+
object:nil];
9797
[NSNotificationCenter.defaultCenter addObserver:self
9898
selector:@selector(windowDidBecomeOrResignKey:)
9999
name:NSWindowDidResignKeyNotification
100-
object:self.window];
100+
object:nil];
101101

102102
return self;
103103
}
104104

105105
- (void)windowDidBecomeOrResignKey:(NSNotification *)notification {
106-
self.needsDisplay = YES;
106+
if (notification.object == self.window) {
107+
self.needsDisplay = YES;
108+
}
107109
}
108110

109111
- (void)drawColumnHeader:(DdbListviewCol_t)col inRect:(NSRect)rect {

plugins/cocoaui/widgets/DdbSeekBar.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ - (void)updateThumbColors {
232232
}
233233

234234
- (void)becameKey:(NSNotification *)notification {
235+
if (notification.object != self.window) {
236+
return;
237+
}
235238
[CATransaction begin];
236239
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
237240
self.isKey = YES;
@@ -242,6 +245,9 @@ - (void)becameKey:(NSNotification *)notification {
242245
}
243246

244247
- (void)resignedKey:(NSNotification *)notification {
248+
if (notification.object != self.window) {
249+
return;
250+
}
245251
[CATransaction begin];
246252
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
247253
self.isKey = NO;

0 commit comments

Comments
 (0)