Merge pull request #14494 from electron/fix-focus-3-0-x
fix: notify focus change right away rather not on next tick (3-0-x)
This commit is contained in:
commit
27a33cc1cf
6 changed files with 22 additions and 22 deletions
|
@ -163,11 +163,11 @@ void TopLevelWindow::OnWindowEndSession() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopLevelWindow::OnWindowBlur() {
|
void TopLevelWindow::OnWindowBlur() {
|
||||||
Emit("blur");
|
EmitEventSoon("blur");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopLevelWindow::OnWindowFocus() {
|
void TopLevelWindow::OnWindowFocus() {
|
||||||
Emit("focus");
|
EmitEventSoon("focus");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopLevelWindow::OnWindowShow() {
|
void TopLevelWindow::OnWindowShow() {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "atom/browser/native_window.h"
|
#include "atom/browser/native_window.h"
|
||||||
#include "atom/browser/native_window_observer.h"
|
#include "atom/browser/native_window_observer.h"
|
||||||
#include "atom/common/api/atom_api_native_image.h"
|
#include "atom/common/api/atom_api_native_image.h"
|
||||||
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "native_mate/handle.h"
|
#include "native_mate/handle.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
@ -215,6 +216,14 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
||||||
// Remove this window from parent window's |child_windows_|.
|
// Remove this window from parent window's |child_windows_|.
|
||||||
void RemoveFromParentChildWindows();
|
void RemoveFromParentChildWindows();
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
void EmitEventSoon(base::StringPiece eventName) {
|
||||||
|
content::BrowserThread::PostTask(
|
||||||
|
content::BrowserThread::UI, FROM_HERE,
|
||||||
|
base::BindOnce(base::IgnoreResult(&TopLevelWindow::Emit<Args...>),
|
||||||
|
weak_factory_.GetWeakPtr(), eventName));
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
typedef std::map<UINT, MessageCallback> MessageCallbackMap;
|
typedef std::map<UINT, MessageCallback> MessageCallbackMap;
|
||||||
MessageCallbackMap messages_callback_map_;
|
MessageCallbackMap messages_callback_map_;
|
||||||
|
|
|
@ -1104,12 +1104,10 @@ void NativeWindowViews::OnWidgetActivationChanged(views::Widget* changed_widget,
|
||||||
if (changed_widget != widget())
|
if (changed_widget != widget())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Post the notification to next tick.
|
if (active)
|
||||||
content::BrowserThread::PostTask(
|
NativeWindow::NotifyWindowFocus();
|
||||||
content::BrowserThread::UI, FROM_HERE,
|
else
|
||||||
base::Bind(active ? &NativeWindow::NotifyWindowFocus
|
NativeWindow::NotifyWindowBlur();
|
||||||
: &NativeWindow::NotifyWindowBlur,
|
|
||||||
GetWeakPtr()));
|
|
||||||
|
|
||||||
// Hide menu bar when window is blured.
|
// Hide menu bar when window is blured.
|
||||||
if (!active && IsMenuBarAutoHide() && IsMenuBarVisible())
|
if (!active && IsMenuBarAutoHide() && IsMenuBarVisible())
|
||||||
|
|
|
@ -399,8 +399,7 @@ describe('BrowserWindow module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO(alexeykuzmin): [Ch66] Enable the test. Passes locally.
|
describe('BrowserWindow.getFocusedWindow()', (done) => {
|
||||||
xdescribe('BrowserWindow.getFocusedWindow()', (done) => {
|
|
||||||
it('returns the opener window when dev tools window is focused', (done) => {
|
it('returns the opener window when dev tools window is focused', (done) => {
|
||||||
w.show()
|
w.show()
|
||||||
w.webContents.once('devtools-focused', () => {
|
w.webContents.once('devtools-focused', () => {
|
||||||
|
@ -611,8 +610,7 @@ describe('BrowserWindow module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO(alexeykuzmin): [Ch66] Enable the test. Passes locally.
|
describe('BrowserWindow.alwaysOnTop() resets level on minimize', () => {
|
||||||
xdescribe('BrowserWindow.alwaysOnTop() resets level on minimize', () => {
|
|
||||||
before(function () {
|
before(function () {
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
this.skip()
|
this.skip()
|
||||||
|
@ -1817,8 +1815,7 @@ describe('BrowserWindow module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO(alexeykuzmin): [Ch66] Enable the tests. They pass locally.
|
describe('document.visibilityState/hidden', () => {
|
||||||
xdescribe('document.visibilityState/hidden', () => {
|
|
||||||
beforeEach(() => { w.destroy() })
|
beforeEach(() => { w.destroy() })
|
||||||
|
|
||||||
function onVisibilityChange (callback) {
|
function onVisibilityChange (callback) {
|
||||||
|
@ -2421,7 +2418,6 @@ describe('BrowserWindow module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO(alexeykuzmin): [Ch66] Enable the test. It passes locally.
|
|
||||||
describe('kiosk state', () => {
|
describe('kiosk state', () => {
|
||||||
before(function () {
|
before(function () {
|
||||||
// Only implemented on macOS.
|
// Only implemented on macOS.
|
||||||
|
@ -2469,8 +2465,7 @@ describe('BrowserWindow module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO(alexeykuzmin): [Ch66] Enable the tests. They pass locally.
|
describe('fullscreen state', () => {
|
||||||
xdescribe('fullscreen state', () => {
|
|
||||||
before(function () {
|
before(function () {
|
||||||
// Only implemented on macOS.
|
// Only implemented on macOS.
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
|
@ -2618,8 +2613,7 @@ describe('BrowserWindow module', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO(alexeykuzmin): [Ch66] Enable the test. Fails on CI bots, passes locally.
|
it('exits HTML fullscreen when window leaves fullscreen', (done) => {
|
||||||
xit('exits HTML fullscreen when window leaves fullscreen', (done) => {
|
|
||||||
w.destroy()
|
w.destroy()
|
||||||
w = new BrowserWindow()
|
w = new BrowserWindow()
|
||||||
w.webContents.once('did-finish-load', () => {
|
w.webContents.once('did-finish-load', () => {
|
||||||
|
|
|
@ -335,8 +335,7 @@ describe('webContents module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO(alexeykuzmin): [Ch66] Enable the test. Passes locally.
|
describe('focus()', () => {
|
||||||
xdescribe('focus()', () => {
|
|
||||||
describe('when the web contents is hidden', () => {
|
describe('when the web contents is hidden', () => {
|
||||||
it('does not blur the focused window', (done) => {
|
it('does not blur the focused window', (done) => {
|
||||||
ipcMain.once('answer', (event, parentFocused, childFocused) => {
|
ipcMain.once('answer', (event, parentFocused, childFocused) => {
|
||||||
|
|
2
vendor/libchromiumcontent
vendored
2
vendor/libchromiumcontent
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 0309588604aedd159793b611ae14a9015e4f65d0
|
Subproject commit aa665e3e903dd448cea87443c5735a7cac32a56e
|
Loading…
Add table
Reference in a new issue