@@ -16,7 +16,7 @@ import { RemoteBridge } from "./ipc/RemoteBridge.js"
16
16
import { ASSET_PROTOCOL } from "./net/ProtocolProxy.js"
17
17
18
18
import { SseInfo } from "./sse/SseInfo.js"
19
- import { LazyLoaded } from "@tutao/tutanota-utils"
19
+ import { debounce , LazyLoaded } from "@tutao/tutanota-utils"
20
20
21
21
const TAG = "[DesktopWindowManager]"
22
22
@@ -109,6 +109,7 @@ export class WindowManager {
109
109
await this . loadStartingBounds ( )
110
110
const w : ApplicationWindow = await this . _newWindowFactory ( noAutoLogin )
111
111
windows . unshift ( w )
112
+
112
113
w . on ( "close" , ( ) => {
113
114
w . setUserId ( null )
114
115
} )
@@ -137,13 +138,20 @@ export class WindowManager {
137
138
w . setBounds ( this . _currentBounds )
138
139
if ( showWhenReady ) w . show ( )
139
140
} )
141
+ . on ( "move" , ( ) => {
142
+ // `move` event also fires on `resize` on windows and linux, but not on mac (so we also handle `resize`)
143
+ this . saveWindowBounds ( w )
144
+ } )
145
+ . on ( "resize" , ( ) => {
146
+ this . saveWindowBounds ( w )
147
+ } )
140
148
. webContents . on ( "did-start-navigation" , ( ) => {
141
149
this . _tray . clearBadge ( )
142
150
} )
143
151
. on ( "zoom-changed" , ( ev : Event , direction : "in" | "out" ) => {
144
152
let scale = ( this . _currentBounds . scale * 100 + ( direction === "out" ? - 5 : 5 ) ) / 100
145
153
this . changeZoom ( scale )
146
- this . saveBounds ( w . getBounds ( ) )
154
+ this . saveWindowBounds ( w )
147
155
} )
148
156
. on ( "did-navigate" , ( ) => {
149
157
// electron likes to override the zoom factor when the URL changes.
@@ -267,6 +275,10 @@ export class WindowManager {
267
275
this . _conf . setVar ( DesktopConfigKey . lastBounds , this . _currentBounds )
268
276
}
269
277
278
+ saveWindowBounds = debounce ( 100 , ( w : ApplicationWindow ) => {
279
+ this . saveBounds ( w . getBounds ( ) )
280
+ } )
281
+
270
282
_setSpellcheckLang ( l : string ) : void {
271
283
this . _electron . session . defaultSession . setSpellCheckerLanguages ( l === "" ? [ ] : [ l ] )
272
284
}
0 commit comments