@@ -7,6 +7,7 @@ import {ipcRenderer} from "electron";
7
7
import { KeyCode } from "../Enums" ;
8
8
import { remote } from "electron" ;
9
9
import * as css from "./css/main" ;
10
+ import { restoreWindowBounds , saveWindowBounds } from "./ViewUtils" ;
10
11
11
12
interface State {
12
13
sessions : Session [ ] ;
@@ -18,21 +19,31 @@ export default class ApplicationComponent extends React.Component<{}, State> {
18
19
19
20
constructor ( props : { } ) {
20
21
super ( props ) ;
22
+ const focusedWindow = remote . BrowserWindow . getFocusedWindow ( ) ;
23
+
24
+ restoreWindowBounds ( focusedWindow ) ;
21
25
22
26
this . addTab ( ) ;
23
27
this . state = { sessions : this . activeTab . sessions } ;
24
28
25
- $ ( window ) . resize ( ( ) => {
26
- for ( const tab of this . tabs ) {
27
- tab . updateAllSessionsDimensions ( ) ;
28
- }
29
- } ) ;
29
+ focusedWindow
30
+ . on ( "move" , ( ) => saveWindowBounds ( focusedWindow ) )
31
+ . on ( "resize" , ( ) => {
32
+ saveWindowBounds ( focusedWindow ) ;
33
+
34
+ for ( const tab of this . tabs ) {
35
+ tab . updateAllSessionsDimensions ( ) ;
36
+ }
37
+ } ) ;
30
38
31
39
ipcRenderer . on ( "change-working-directory" , ( event : Electron . IpcRendererEvent , directory : string ) =>
32
40
this . activeTab . activeSession ( ) . directory = directory
33
41
) ;
34
42
35
- window . onbeforeunload = ( ) => this . closeAllTabs ( ) ;
43
+ window . onbeforeunload = ( ) => {
44
+ focusedWindow . removeAllListeners ( ) ;
45
+ this . closeAllTabs ( ) ;
46
+ }
36
47
}
37
48
38
49
handleKeyDown ( event : KeyboardEvent ) {
0 commit comments