Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] fix: avoid blurring window when using Character Viewer pop-up on macOS #19128

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 1 addition & 10 deletions shell/browser/api/atom_api_browser_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,13 @@ void BrowserWindow::OnWindowClosed() {

void BrowserWindow::OnWindowBlur() {
web_contents()->StoreFocus();
#if defined(OS_MACOSX)
auto* rwhv = web_contents()->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetActive(false);
#endif

TopLevelWindow::OnWindowBlur();
}

void BrowserWindow::OnWindowFocus() {
web_contents()->RestoreFocus();
#if defined(OS_MACOSX)
auto* rwhv = web_contents()->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetActive(true);
#else
#if !defined(OS_MACOSX)
if (!api_web_contents_->IsDevToolsOpened())
web_contents()->Focus();
#endif
Expand Down
10 changes: 9 additions & 1 deletion shell/browser/ui/cocoa/atom_ns_window_delegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,15 @@ - (void)windowDidBecomeKey:(NSNotification*)notification {
}

- (void)windowDidResignKey:(NSNotification*)notification {
shell_->NotifyWindowBlur();
NSWindow* resigningWindow = notification.object;
NSWindow* newKeyWindow = [NSApp keyWindow];
// macOS character palette will not be detected as the
// app's key window. We don't want to send a blur
// event when the palette activates because we don't want
// the original window's input to lose focus
if (newKeyWindow != resigningWindow) {
shell_->NotifyWindowBlur();
}
}

- (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize {
Expand Down