mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-17 14:08:41 -09:00
Emit isMaximized on window geometry change
This commit is contained in:
parent
60d0927f85
commit
cbe95a45ea
5 changed files with 8 additions and 11 deletions
|
|
@ -221,7 +221,7 @@ export function newWindow(
|
||||||
// app buttons
|
// app buttons
|
||||||
for (const ev of ['maximize', 'unmaximize', 'minimize', 'restore'] as any) {
|
for (const ev of ['maximize', 'unmaximize', 'minimize', 'restore'] as any) {
|
||||||
window.on(ev, () => {
|
window.on(ev, () => {
|
||||||
rpc.emit('windowGeometry change', {});
|
rpc.emit('windowGeometry change', {isMaximized: window.isMaximized()});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
window.on('move', () => {
|
window.on('move', () => {
|
||||||
|
|
|
||||||
|
|
@ -102,9 +102,10 @@ export function setFontSmoothing() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function windowGeometryUpdated(): HyperActions {
|
export function windowGeometryUpdated({isMaximized}: {isMaximized: boolean}): HyperActions {
|
||||||
return {
|
return {
|
||||||
type: UI_WINDOW_GEOMETRY_CHANGED
|
type: UI_WINDOW_GEOMETRY_CHANGED,
|
||||||
|
isMaximized
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ export interface UIWindowUnmaximizeAction {
|
||||||
}
|
}
|
||||||
export interface UIWindowGeometryChangedAction {
|
export interface UIWindowGeometryChangedAction {
|
||||||
type: typeof UI_WINDOW_GEOMETRY_CHANGED;
|
type: typeof UI_WINDOW_GEOMETRY_CHANGED;
|
||||||
|
isMaximized: boolean;
|
||||||
}
|
}
|
||||||
export interface UIOpenFileAction {
|
export interface UIOpenFileAction {
|
||||||
type: typeof UI_OPEN_FILE;
|
type: typeof UI_OPEN_FILE;
|
||||||
|
|
|
||||||
|
|
@ -215,8 +215,8 @@ rpc.on('move', (window) => {
|
||||||
store_.dispatch(uiActions.windowMove(window));
|
store_.dispatch(uiActions.windowMove(window));
|
||||||
});
|
});
|
||||||
|
|
||||||
rpc.on('windowGeometry change', () => {
|
rpc.on('windowGeometry change', (data) => {
|
||||||
store_.dispatch(uiActions.windowGeometryUpdated());
|
store_.dispatch(uiActions.windowGeometryUpdated(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
rpc.on('add notification', ({text, url, dismissable}) => {
|
rpc.on('add notification', ({text, url, dismissable}) => {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
import {remote} from 'electron';
|
|
||||||
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
|
|
||||||
|
|
||||||
import Immutable, {Immutable as ImmutableType} from 'seamless-immutable';
|
import Immutable, {Immutable as ImmutableType} from 'seamless-immutable';
|
||||||
import {decorateUIReducer} from '../utils/plugins';
|
import {decorateUIReducer} from '../utils/plugins';
|
||||||
import {CONFIG_LOAD, CONFIG_RELOAD} from '../constants/config';
|
import {CONFIG_LOAD, CONFIG_RELOAD} from '../constants/config';
|
||||||
|
|
@ -113,8 +110,6 @@ const initial: uiState = Immutable<Mutable<uiState>>({
|
||||||
disableLigatures: false
|
disableLigatures: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const currentWindow = remote.getCurrentWindow();
|
|
||||||
|
|
||||||
const reducer: IUiReducer = (state = initial, action) => {
|
const reducer: IUiReducer = (state = initial, action) => {
|
||||||
let state_ = state;
|
let state_ = state;
|
||||||
let isMax;
|
let isMax;
|
||||||
|
|
@ -380,7 +375,7 @@ const reducer: IUiReducer = (state = initial, action) => {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UI_WINDOW_GEOMETRY_CHANGED:
|
case UI_WINDOW_GEOMETRY_CHANGED:
|
||||||
isMax = currentWindow.isMaximized();
|
isMax = action.isMaximized;
|
||||||
if (state.maximized !== isMax) {
|
if (state.maximized !== isMax) {
|
||||||
state_ = state.set('maximized', isMax);
|
state_ = state.set('maximized', isMax);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue