@@ -2,6 +2,7 @@ import AppState from '@/AppState';
22import { Settings } from '@/data/Constants' ;
33import Storage from '@/data/Storage' ;
44import { PageView } from '@/model/Page' ;
5+ import FramePropagator from '@/propagator/FramePropagator' ;
56import ViewPropagator from '@/propagator/ViewPropagator' ;
67import FrameService from '@/service/FrameService' ;
78import MenuService , { ContextMenuType } from '@/service/MenuService' ;
@@ -18,6 +19,17 @@ export type ChildWebContents = WebContents & { __parent__?: WebContents };
1819
1920class ViewService {
2021 private lastContextMenuLinkUrl = '' ;
22+
23+ constructor ( ) {
24+ this . registerEvents ( ) ;
25+ }
26+
27+ private registerEvents ( ) : void {
28+ const redirectFocus = ( ) => this . focus ( ) ;
29+ FramePropagator . on ( 'show' , redirectFocus ) ;
30+ ViewPropagator . on ( 'attached' , redirectFocus ) ;
31+ }
32+
2133 public getHomeUrl ( WebContentsView : WebContentsView ) : string {
2234 return WebContentsView . webContents . getURL ( ) ;
2335 }
@@ -68,7 +80,7 @@ class ViewService {
6880 return view . webContents . isLoading ( ) ;
6981 }
7082
71- public focus ( view = this . getCurrentView ( ) ) : void {
83+ private focus ( view = this . getCurrentView ( ) ) : void {
7284 if ( ! view ) { console . error ( 'Cannot focus without view.' ) ; return ; }
7385 const wc = view . webContents ;
7486 if ( ! wc || wc . isDestroyed ( ) ) { console . error ( 'Cannot focus with destroyed view.' ) ; return ; }
0 commit comments