File tree 6 files changed +24
-10
lines changed
6 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export {
21
21
toggleMainWindowShadeMode ,
22
22
windowsHaveBeenCentered ,
23
23
centerWindowsIfNeeded ,
24
- ensureWindowsAreOnScreen
24
+ browserWindowSizeChanged
25
25
} from "./windows" ;
26
26
export {
27
27
play ,
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
10
10
TOGGLE_WINDOW_SHADE_MODE ,
11
11
SET_WINDOW_VISIBILITY ,
12
12
WINDOWS_HAVE_BEEN_CENTERED ,
13
- RESET_WINDOW_LAYOUT
13
+ BROWSER_WINDOW_SIZE_CHANGED
14
14
} from "../actionTypes" ;
15
15
16
16
import { getPositionDiff , SizeDiff } from "../resizeUtils" ;
@@ -115,10 +115,6 @@ export function windowsHaveBeenCentered(): Dispatchable {
115
115
return { type : WINDOWS_HAVE_BEEN_CENTERED } ;
116
116
}
117
117
118
- export function resetWindowLayout ( ) : Dispatchable {
119
- return { type : RESET_WINDOW_LAYOUT } ;
120
- }
121
-
122
118
export function centerWindowsIfNeeded ( container : HTMLElement ) : Dispatchable {
123
119
return ( dispatch , getState ) => {
124
120
const state = getState ( ) ;
@@ -187,6 +183,11 @@ export function centerWindowsIfNeeded(container: HTMLElement): Dispatchable {
187
183
} ;
188
184
}
189
185
186
+ export function browserWindowSizeChanged ( ) {
187
+ const { height, width } = Utils . getWindowSize ( ) ;
188
+ return { type : BROWSER_WINDOW_SIZE_CHANGED , height, width } ;
189
+ }
190
+
190
191
export function ensureWindowsAreOnScreen ( ) : Dispatchable {
191
192
return ( dispatch , getState ) => {
192
193
const state = getState ( ) ;
Original file line number Diff line number Diff line change @@ -74,3 +74,4 @@ export const CLOSE_REQUESTED = "CLOSE_REQUESTED";
74
74
export const LOAD_SERIALIZED_STATE = "LOAD_SERIALIZED_STATE" ;
75
75
export const WINDOWS_HAVE_BEEN_CENTERED = "WINDOWS_HAVE_BEEN_CENTERED" ;
76
76
export const RESET_WINDOW_LAYOUT = "RESET_WINDOW_LAYOUT" ;
77
+ export const BROWSER_WINDOW_SIZE_CHANGED = "BROWSER_WINDOW_SIZE_CHANGED" ;
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ import {
10
10
WINDOW_SIZE_CHANGED ,
11
11
TOGGLE_WINDOW_SHADE_MODE ,
12
12
LOAD_SERIALIZED_STATE ,
13
- RESET_WINDOW_LAYOUT
13
+ RESET_WINDOW_LAYOUT ,
14
+ BROWSER_WINDOW_SIZE_CHANGED
14
15
} from "../actionTypes" ;
15
16
import * as Utils from "../utils" ;
16
17
@@ -19,6 +20,7 @@ export interface WindowsState {
19
20
centerRequested : boolean ;
20
21
genWindows : { [ name : string ] : WebampWindow } ;
21
22
positions : WindowPositions ;
23
+ browserWindowSize : { height : number ; width : number } | null ;
22
24
}
23
25
24
26
interface SerializedWindow {
@@ -77,7 +79,8 @@ const defaultWindowsState: WindowsState = {
77
79
hotkey : "Alt+E"
78
80
}
79
81
} ,
80
- positions : { }
82
+ positions : { } ,
83
+ browserWindowSize : null
81
84
} ;
82
85
83
86
const windows = (
@@ -224,6 +227,11 @@ const windows = (
224
227
focused
225
228
} ;
226
229
}
230
+ case BROWSER_WINDOW_SIZE_CHANGED :
231
+ return {
232
+ ...state ,
233
+ browserWindowSize : { height : action . height , width : action . width }
234
+ } ;
227
235
228
236
default :
229
237
return state ;
Original file line number Diff line number Diff line change @@ -350,7 +350,8 @@ export type Action =
350
350
type : "LOAD_SERIALIZED_STATE" ;
351
351
serializedState : SerializedStateV1 ;
352
352
}
353
- | { type : "RESET_WINDOW_LAYOUT" } ;
353
+ | { type : "RESET_WINDOW_LAYOUT" }
354
+ | { type : "BROWSER_WINDOW_SIZE_CHANGED" ; height : number ; width : number } ;
354
355
355
356
export interface WebampWindow {
356
357
title : string ;
Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ import {
13
13
setWindowSize ,
14
14
updateWindowPositions ,
15
15
loadSerializedState ,
16
- ensureWindowsAreOnScreen
16
+ ensureWindowsAreOnScreen ,
17
+ browserWindowSizeChanged
17
18
} from "./actionCreators" ;
18
19
import { LOAD_STYLE } from "./constants" ;
19
20
import * as Utils from "./utils" ;
@@ -124,8 +125,10 @@ class Winamp {
124
125
this . store . dispatch ( { type : NETWORK_DISCONNECTED } )
125
126
) ;
126
127
128
+ this . store . dispatch ( browserWindowSizeChanged ( ) ) ;
127
129
window . addEventListener ( "resize" , ( ) => {
128
130
this . store . dispatch ( ensureWindowsAreOnScreen ( ) ) ;
131
+ this . store . dispatch ( browserWindowSizeChanged ( ) ) ;
129
132
} ) ;
130
133
131
134
if ( initialSkin ) {
You can’t perform that action at this time.
0 commit comments