mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-25 00:25:03 +08:00
fix(win): fix frame settings on windows
This commit is contained in:
parent
78b19a4d42
commit
f2a53e57c8
4 changed files with 35 additions and 35 deletions
|
@ -19,7 +19,8 @@ class NylasWindow
|
||||||
isSpec: null
|
isSpec: null
|
||||||
|
|
||||||
constructor: (settings={}) ->
|
constructor: (settings={}) ->
|
||||||
{title,
|
{frame,
|
||||||
|
title,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
toolbar,
|
toolbar,
|
||||||
|
@ -44,28 +45,13 @@ class NylasWindow
|
||||||
# Normalize to make sure drive letter case is consistent on Windows
|
# Normalize to make sure drive letter case is consistent on Windows
|
||||||
@resourcePath = path.normalize(@resourcePath) if @resourcePath
|
@resourcePath = path.normalize(@resourcePath) if @resourcePath
|
||||||
|
|
||||||
# Mac: We'll render a CSS toolbar if `toolbar=true`. No frame required.
|
browserWindowOptions =
|
||||||
# Win / Linux: We don't render a toolbar in CSS - include frame if the
|
|
||||||
# window requests a toolbar. Remove this code once we have custom toolbars
|
|
||||||
# on win/linux.
|
|
||||||
|
|
||||||
toolbar ?= true
|
|
||||||
if process.platform is 'darwin'
|
|
||||||
frame = false
|
|
||||||
else
|
|
||||||
frame = toolbar
|
|
||||||
|
|
||||||
if @isSpec
|
|
||||||
frame = true
|
|
||||||
toolbar = false
|
|
||||||
|
|
||||||
options =
|
|
||||||
show: false
|
show: false
|
||||||
title: title ? 'Nylas N1'
|
title: title ? 'Nylas N1'
|
||||||
frame: frame
|
frame: frame
|
||||||
width: width
|
width: width
|
||||||
height: height
|
height: height
|
||||||
resizable: resizable ? true
|
resizable: resizable
|
||||||
webPreferences:
|
webPreferences:
|
||||||
directWrite: true
|
directWrite: true
|
||||||
|
|
||||||
|
@ -76,7 +62,7 @@ class NylasWindow
|
||||||
# This option is no longer working according to
|
# This option is no longer working according to
|
||||||
# https://github.com/atom/electron/issues/3225
|
# https://github.com/atom/electron/issues/3225
|
||||||
# Look into using option --disable-renderer-backgrounding
|
# Look into using option --disable-renderer-backgrounding
|
||||||
options.webPreferences.pageVisibility = true
|
browserWindowOptions.webPreferences.pageVisibility = true
|
||||||
|
|
||||||
# Don't set icon on Windows so the exe's ico will be used as window and
|
# Don't set icon on Windows so the exe's ico will be used as window and
|
||||||
# taskbar's icon. See https://github.com/atom/atom/issues/4811 for more.
|
# taskbar's icon. See https://github.com/atom/atom/issues/4811 for more.
|
||||||
|
@ -85,15 +71,14 @@ class NylasWindow
|
||||||
WindowIconPath = path.resolve(__dirname, '..', '..', 'nylas.png')
|
WindowIconPath = path.resolve(__dirname, '..', '..', 'nylas.png')
|
||||||
unless fs.existsSync(WindowIconPath)
|
unless fs.existsSync(WindowIconPath)
|
||||||
WindowIconPath = path.resolve(__dirname, '..', '..', 'build', 'resources', 'nylas.png')
|
WindowIconPath = path.resolve(__dirname, '..', '..', 'build', 'resources', 'nylas.png')
|
||||||
options.icon = WindowIconPath
|
browserWindowOptions.icon = WindowIconPath
|
||||||
|
|
||||||
@browserWindow = new BrowserWindow(options)
|
@browserWindow = new BrowserWindow(browserWindowOptions)
|
||||||
@browserWindow.updateLoadSettings = @updateLoadSettings
|
@browserWindow.updateLoadSettings = @updateLoadSettings
|
||||||
|
|
||||||
@handleEvents()
|
@handleEvents()
|
||||||
|
|
||||||
loadSettings = _.extend({}, settings)
|
loadSettings = _.extend({}, settings)
|
||||||
loadSettings.toolbar = toolbar
|
|
||||||
loadSettings.windowState ?= '{}'
|
loadSettings.windowState ?= '{}'
|
||||||
loadSettings.appVersion = app.getVersion()
|
loadSettings.appVersion = app.getVersion()
|
||||||
loadSettings.resourcePath = @resourcePath
|
loadSettings.resourcePath = @resourcePath
|
||||||
|
|
|
@ -17,9 +17,12 @@ export default class WindowLauncher {
|
||||||
|
|
||||||
constructor(appOpts) {
|
constructor(appOpts) {
|
||||||
this.defaultWindowOpts = {
|
this.defaultWindowOpts = {
|
||||||
|
frame: process.platform !== "darwin",
|
||||||
hidden: false,
|
hidden: false,
|
||||||
|
toolbar: true,
|
||||||
devMode: appOpts.devMode,
|
devMode: appOpts.devMode,
|
||||||
safeMode: appOpts.safeMode,
|
safeMode: appOpts.safeMode,
|
||||||
|
resizable: true,
|
||||||
windowType: WindowLauncher.EMPTY_WINDOW,
|
windowType: WindowLauncher.EMPTY_WINDOW,
|
||||||
resourcePath: appOpts.resourcePath,
|
resourcePath: appOpts.resourcePath,
|
||||||
configDirPath: appOpts.configDirPath,
|
configDirPath: appOpts.configDirPath,
|
||||||
|
@ -38,7 +41,7 @@ export default class WindowLauncher {
|
||||||
win = new NylasWindow(opts)
|
win = new NylasWindow(opts)
|
||||||
} else {
|
} else {
|
||||||
opts.bootstrapScript = this._secondaryWindowBootstrap()
|
opts.bootstrapScript = this._secondaryWindowBootstrap()
|
||||||
if (opts.coldStartOnly) {
|
if (this._unableToModifyHotWindow(opts) || opts.coldStartOnly) {
|
||||||
// Useful for the Worker Window: A secondary window that shouldn't
|
// Useful for the Worker Window: A secondary window that shouldn't
|
||||||
// be hot-loaded
|
// be hot-loaded
|
||||||
win = new NylasWindow(opts)
|
win = new NylasWindow(opts)
|
||||||
|
@ -81,6 +84,13 @@ export default class WindowLauncher {
|
||||||
this.hotWindow.browserWindow.destroy()
|
this.hotWindow.browserWindow.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some properties, like the `frame` or `toolbar` can't be updated once
|
||||||
|
// a window has been setup. If we detect this case we have to bootup a
|
||||||
|
// plain NylasWindow instead of using a hot window.
|
||||||
|
_unableToModifyHotWindow(opts) {
|
||||||
|
return this.defaultWindowOpts.frame !== (!!opts.frame)
|
||||||
|
}
|
||||||
|
|
||||||
_secondaryWindowBootstrap() {
|
_secondaryWindowBootstrap() {
|
||||||
if (!this._bootstrap) {
|
if (!this._bootstrap) {
|
||||||
this._bootstrap = require.resolve("../secondary-window-bootstrap")
|
this._bootstrap = require.resolve("../secondary-window-bootstrap")
|
||||||
|
|
|
@ -98,10 +98,10 @@ class WindowManager
|
||||||
neverClose: true
|
neverClose: true
|
||||||
bootstrapScript: require.resolve("../window-bootstrap")
|
bootstrapScript: require.resolve("../window-bootstrap")
|
||||||
mainWindow: true
|
mainWindow: true
|
||||||
width: 640
|
width: 640 # Gets reset once app boots up
|
||||||
height: 396
|
height: 396 # Gets reset once app boots up
|
||||||
center: true
|
center: true # Gets reset once app boots up
|
||||||
resizable: false
|
resizable: false # Gets reset once app boots up
|
||||||
initializeInBackground: @initializeInBackground
|
initializeInBackground: @initializeInBackground
|
||||||
|
|
||||||
coreWinOpts[WindowManager.WORK_WINDOW] =
|
coreWinOpts[WindowManager.WORK_WINDOW] =
|
||||||
|
@ -109,7 +109,6 @@ class WindowManager
|
||||||
windowType: WindowManager.WORK_WINDOW
|
windowType: WindowManager.WORK_WINDOW
|
||||||
coldStartOnly: true # It's a secondary window, but not a hot window
|
coldStartOnly: true # It's a secondary window, but not a hot window
|
||||||
title: "Activity"
|
title: "Activity"
|
||||||
toolbar: true
|
|
||||||
hidden: true
|
hidden: true
|
||||||
neverClose: true
|
neverClose: true
|
||||||
width: 800
|
width: 800
|
||||||
|
@ -118,17 +117,20 @@ class WindowManager
|
||||||
coreWinOpts[WindowManager.ONBOARDING_WINDOW] =
|
coreWinOpts[WindowManager.ONBOARDING_WINDOW] =
|
||||||
windowKey: WindowManager.ONBOARDING_WINDOW
|
windowKey: WindowManager.ONBOARDING_WINDOW
|
||||||
windowType: WindowManager.ONBOARDING_WINDOW
|
windowType: WindowManager.ONBOARDING_WINDOW
|
||||||
resizable: false
|
|
||||||
toolbar: false
|
|
||||||
hidden: true # Displayed by PageRouter::_initializeWindowSize
|
hidden: true # Displayed by PageRouter::_initializeWindowSize
|
||||||
|
frame: false # Always false on Mac, explicitly set for Win & Linux
|
||||||
|
toolbar: false
|
||||||
|
resizable: false
|
||||||
|
|
||||||
# The SPEC_WINDOW gets passed its own bootstrapScript
|
# The SPEC_WINDOW gets passed its own bootstrapScript
|
||||||
coreWinOpts[WindowManager.SPEC_WINDOW] =
|
coreWinOpts[WindowManager.SPEC_WINDOW] =
|
||||||
windowKey: WindowManager.SPEC_WINDOW
|
windowKey: WindowManager.SPEC_WINDOW
|
||||||
windowType: WindowManager.SPEC_WINDOW
|
windowType: WindowManager.SPEC_WINDOW
|
||||||
|
frame: true,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
isSpec: true,
|
isSpec: true,
|
||||||
devMode: true,
|
devMode: true,
|
||||||
|
toolbar: false
|
||||||
|
|
||||||
defaultOptions = coreWinOpts[winId] ? {}
|
defaultOptions = coreWinOpts[winId] ? {}
|
||||||
|
|
||||||
|
|
|
@ -717,18 +717,21 @@ class NylasEnvConstructor extends Model
|
||||||
@loadSettings = loadSettings
|
@loadSettings = loadSettings
|
||||||
@constructor.loadSettings = loadSettings
|
@constructor.loadSettings = loadSettings
|
||||||
|
|
||||||
{width, height, windowProps, windowType, hidden} = loadSettings
|
@packages.loadPackages(loadSettings.windowType)
|
||||||
|
|
||||||
@packages.loadPackages(windowType)
|
|
||||||
@deserializePackageStates()
|
@deserializePackageStates()
|
||||||
@packages.activate()
|
@packages.activate()
|
||||||
|
|
||||||
@emitter.emit('window-props-received', windowProps ? {})
|
@emitter.emit('window-props-received', loadSettings.windowProps ? {})
|
||||||
|
|
||||||
|
{width, height} = loadSettings
|
||||||
if width and height
|
if width and height
|
||||||
@setWindowDimensions({width, height})
|
@setWindowDimensions({width, height})
|
||||||
|
browserWindow = @getCurrentWindow()
|
||||||
|
if browserWindow.isResizable() isnt loadSettings.resizable
|
||||||
|
console.log(loadSettings.resizable)
|
||||||
|
browserWindow.setResizable(loadSettings.resizable)
|
||||||
|
|
||||||
@displayWindow() unless hidden
|
@displayWindow() unless loadSettings.hidden
|
||||||
|
|
||||||
# We extend nylas observables with our own methods. This happens on
|
# We extend nylas observables with our own methods. This happens on
|
||||||
# require of nylas-observables
|
# require of nylas-observables
|
||||||
|
|
Loading…
Reference in a new issue