mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Register enter/leave fullscreen events in the main process
This will still notify render processes when such events are triggered without, however, incurring the additional cost of synchronously retrieving a `BrowserWindow` (and its properties) via `remote` during startup.
This commit is contained in:
@@ -80,6 +80,12 @@ class ApplicationDelegate
|
||||
setWindowFullScreen: (fullScreen=false) ->
|
||||
ipcHelpers.call('window-method', 'setFullScreen', fullScreen)
|
||||
|
||||
onDidEnterFullScreen: (callback) ->
|
||||
ipcHelpers.on(ipcRenderer, 'did-enter-full-screen', callback)
|
||||
|
||||
onDidLeaveFullScreen: (callback) ->
|
||||
ipcHelpers.on(ipcRenderer, 'did-leave-full-screen', callback)
|
||||
|
||||
openWindowDevTools: ->
|
||||
# Defer DevTools interaction to the next tick, because using them during
|
||||
# event handling causes some wrong input events to be triggered on
|
||||
|
||||
@@ -89,6 +89,12 @@ class AtomWindow
|
||||
@emit 'window:loaded'
|
||||
@resolveLoadedPromise()
|
||||
|
||||
@browserWindow.on 'enter-full-screen', =>
|
||||
@browserWindow.webContents.send('did-enter-full-screen')
|
||||
|
||||
@browserWindow.on 'leave-full-screen', =>
|
||||
@browserWindow.webContents.send('did-leave-full-screen')
|
||||
|
||||
@browserWindow.loadURL url.format
|
||||
protocol: 'file'
|
||||
pathname: "#{@resourcePath}/static/index.html"
|
||||
|
||||
@@ -20,14 +20,8 @@ class WindowEventHandler
|
||||
@subscriptions.add listen(@document, 'click', 'a', @handleLinkClick)
|
||||
@subscriptions.add listen(@document, 'submit', 'form', @handleFormSubmit)
|
||||
|
||||
browserWindow = @applicationDelegate.getCurrentWindow()
|
||||
browserWindow.on 'enter-full-screen', @handleEnterFullScreen
|
||||
@subscriptions.add new Disposable =>
|
||||
browserWindow.removeListener('enter-full-screen', @handleEnterFullScreen)
|
||||
|
||||
browserWindow.on 'leave-full-screen', @handleLeaveFullScreen
|
||||
@subscriptions.add new Disposable =>
|
||||
browserWindow.removeListener('leave-full-screen', @handleLeaveFullScreen)
|
||||
@subscriptions.add(@applicationDelegate.onDidEnterFullScreen(@handleEnterFullScreen))
|
||||
@subscriptions.add(@applicationDelegate.onDidLeaveFullScreen(@handleLeaveFullScreen))
|
||||
|
||||
@subscriptions.add @atomEnvironment.commands.add @window,
|
||||
'window:toggle-full-screen': @handleWindowToggleFullScreen
|
||||
|
||||
Reference in New Issue
Block a user