@@ -8,7 +8,7 @@ import { DeferredPromise, RunOnceScheduler, timeout, Delayer } from '../../../ba
8
8
import { CancellationToken } from '../../../base/common/cancellation.js' ;
9
9
import { toErrorMessage } from '../../../base/common/errorMessage.js' ;
10
10
import { Emitter , Event } from '../../../base/common/event.js' ;
11
- import { Disposable , IDisposable , MutableDisposable } from '../../../base/common/lifecycle.js' ;
11
+ import { Disposable , DisposableStore , IDisposable , MutableDisposable , toDisposable } from '../../../base/common/lifecycle.js' ;
12
12
import { FileAccess , Schemas } from '../../../base/common/network.js' ;
13
13
import { getMarks , mark } from '../../../base/common/performance.js' ;
14
14
import { isBigSurOrNewer , isLinux , isMacintosh , isWindows } from '../../../base/common/platform.js' ;
@@ -173,7 +173,7 @@ export abstract class BaseWindow extends Disposable implements IBaseWindow {
173
173
this . dispose ( ) ;
174
174
} ) ) ;
175
175
this . _register ( Event . fromNodeEventEmitter ( win , 'focus' ) ( ( ) => {
176
- this . clearFocusNotificationBadge ( ) ;
176
+ this . clearNotifyFocus ( ) ;
177
177
178
178
this . _lastFocusTime = Date . now ( ) ;
179
179
} ) ) ;
@@ -347,23 +347,7 @@ export abstract class BaseWindow extends Disposable implements IBaseWindow {
347
347
break ;
348
348
349
349
case FocusMode . Notify :
350
- if ( isMacintosh ) {
351
- this . showFocusNotificationBadge ( ) ;
352
-
353
- // On macOS we have direct API to bounce the dock icon
354
- electron . app . dock ?. bounce ( 'informational' ) ;
355
- } else if ( isWindows ) {
356
- this . showFocusNotificationBadge ( ) ;
357
-
358
- // On Windows, calling focus() will bounce the taskbar icon
359
- // https://github.com/electron/electron/issues/2867
360
- this . win ?. focus ( ) ;
361
- } else if ( isLinux ) {
362
- this . showFocusNotificationBadge ( ) ;
363
-
364
- // On Linux, there seems to be no way to bounce the taskbar icon
365
- // as calling focus() will actually steal focus away.
366
- }
350
+ this . showNotifyFocus ( ) ;
367
351
break ;
368
352
369
353
case FocusMode . Force :
@@ -375,16 +359,26 @@ export abstract class BaseWindow extends Disposable implements IBaseWindow {
375
359
}
376
360
}
377
361
378
- private readonly focusNotificationBadgeDisposable = this . _register ( new MutableDisposable ( ) ) ;
362
+ private readonly notifyFocusDisposable = this . _register ( new MutableDisposable ( ) ) ;
363
+
364
+ private showNotifyFocus ( ) : void {
365
+ const disposables = new DisposableStore ( ) ;
366
+ this . notifyFocusDisposable . value = disposables ;
367
+
368
+ // Badge
369
+ disposables . add ( DockBadgeManager . INSTANCE . acquireBadge ( this ) ) ;
379
370
380
- private showFocusNotificationBadge ( ) : void {
381
- if ( ! this . focusNotificationBadgeDisposable . value ) {
382
- this . focusNotificationBadgeDisposable . value = DockBadgeManager . INSTANCE . acquireBadge ( this ) ;
371
+ // Flash/Bounce
372
+ if ( isWindows ) {
373
+ this . win ?. flashFrame ( true ) ;
374
+ disposables . add ( toDisposable ( ( ) => this . win ?. flashFrame ( false ) ) ) ;
375
+ } else if ( isMacintosh ) {
376
+ electron . app . dock ?. bounce ( 'informational' ) ;
383
377
}
384
378
}
385
379
386
- private clearFocusNotificationBadge ( ) : void {
387
- this . focusNotificationBadgeDisposable . clear ( ) ;
380
+ private clearNotifyFocus ( ) : void {
381
+ this . notifyFocusDisposable . clear ( ) ;
388
382
}
389
383
390
384
private doFocusWindow ( ) {
0 commit comments