Commit 3d5b1043 authored by Leonard Grey's avatar Leonard Grey Committed by Commit Bot

Mac: move most key status change handling to NativeWidgetMac

This is prep for always displaying a widget as key if one of its children is key.

No behavior change intended.

Bug: 1046540
Change-Id: I3b667e5f285ac1b8c681f25714647dec8242bf6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2031427Reviewed-by: default avatarccameron <ccameron@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737330}
parent 290641cb
......@@ -1021,25 +1021,14 @@ void NativeWidgetMacNSWindowHost::OnWindowKeyStatusChanged(
bool is_key,
bool is_content_first_responder,
bool full_keyboard_access_enabled) {
// Explicitly set the keyboard accessibility state on regaining key
// window status.
if (is_key && is_content_first_responder)
SetKeyboardAccessible(full_keyboard_access_enabled);
accessibility_focus_overrider_.SetWindowIsKey(is_key);
is_window_key_ = is_key;
Widget* widget = native_widget_mac_->GetWidget();
if (!widget->OnNativeWidgetActivationChanged(is_key))
return;
// The contentView is the BridgedContentView hosting the views::RootView. The
// focus manager will already know if a native subview has focus.
if (is_content_first_responder) {
if (is_key) {
widget->OnNativeFocus();
// Explicitly set the keyboard accessibility state on regaining key
// window status.
SetKeyboardAccessible(full_keyboard_access_enabled);
widget->GetFocusManager()->RestoreFocusedView();
} else {
widget->OnNativeBlur();
widget->GetFocusManager()->StoreFocusedView(true);
}
}
native_widget_mac_->OnWindowKeyStatusChanged(is_key,
is_content_first_responder);
}
void NativeWidgetMacNSWindowHost::OnWindowStateRestorationDataChanged(
......
......@@ -32,7 +32,7 @@ namespace test {
class HitTestNativeWidgetMac;
class MockNativeWidgetMac;
class WidgetTest;
}
} // namespace test
class NativeWidgetMacNSWindowHost;
class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate,
......@@ -52,6 +52,9 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate,
// destroyed.
void WindowDestroyed();
// Called when the backing NSWindow gains or loses key status.
void OnWindowKeyStatusChanged(bool is_key, bool is_content_first_responder);
// The vertical position from which sheets should be anchored, from the top
// of the content view.
virtual int32_t SheetOffsetY();
......
......@@ -143,6 +143,26 @@ void NativeWidgetMac::WindowDestroyed() {
delete this;
}
void NativeWidgetMac::OnWindowKeyStatusChanged(
bool is_key,
bool is_content_first_responder) {
Widget* widget = GetWidget();
if (!widget->OnNativeWidgetActivationChanged(is_key))
return;
// The contentView is the BridgedContentView hosting the views::RootView. The
// focus manager will already know if a native subview has focus.
if (!is_content_first_responder)
return;
if (is_key) {
widget->OnNativeFocus();
widget->GetFocusManager()->RestoreFocusedView();
} else {
widget->OnNativeBlur();
widget->GetFocusManager()->StoreFocusedView(true);
}
}
int32_t NativeWidgetMac::SheetOffsetY() {
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment