diff options
author | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-14 08:03:30 +0000 |
---|---|---|
committer | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-14 08:03:30 +0000 |
commit | 5c320965fef19421538290eb27ea1819a2a04b87 (patch) | |
tree | d401109162be9ead524ef4bad37747f0884665cb /views/widget | |
parent | 7606b72dae9664f9da19f8f39e3d6f9c86a4092c (diff) | |
download | chromium_src-5c320965fef19421538290eb27ea1819a2a04b87.zip chromium_src-5c320965fef19421538290eb27ea1819a2a04b87.tar.gz chromium_src-5c320965fef19421538290eb27ea1819a2a04b87.tar.bz2 |
Clean up FocusManager
Use Widget API to get FocusManager for native_view/window.
Move FocusNatieView to native widget impl.
This is necessary for NativeWidgetX
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7351008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92497 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r-- | views/widget/native_widget_gtk.cc | 5 | ||||
-rw-r--r-- | views/widget/native_widget_gtk.h | 1 | ||||
-rw-r--r-- | views/widget/native_widget_private.h | 1 | ||||
-rw-r--r-- | views/widget/native_widget_views.cc | 4 | ||||
-rw-r--r-- | views/widget/native_widget_views.h | 1 | ||||
-rw-r--r-- | views/widget/native_widget_win.cc | 6 | ||||
-rw-r--r-- | views/widget/native_widget_win.h | 1 | ||||
-rw-r--r-- | views/widget/widget.cc | 4 | ||||
-rw-r--r-- | views/widget/widget.h | 3 |
9 files changed, 26 insertions, 0 deletions
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc index 7fbe649..d9dd8d2 100644 --- a/views/widget/native_widget_gtk.cc +++ b/views/widget/native_widget_gtk.cc @@ -1326,6 +1326,11 @@ void NativeWidgetGtk::ClearNativeFocus() { gtk_window_set_focus(GTK_WINDOW(GetNativeView()), NULL); } +void NativeWidgetGtk::FocusNativeView(gfx::NativeView native_view) { + if (native_view && !gtk_widget_is_focus(native_view)) + gtk_widget_grab_focus(native_view); +} + //////////////////////////////////////////////////////////////////////////////// // NativeWidgetGtk, protected: diff --git a/views/widget/native_widget_gtk.h b/views/widget/native_widget_gtk.h index 82f8f13..7c99e94 100644 --- a/views/widget/native_widget_gtk.h +++ b/views/widget/native_widget_gtk.h @@ -221,6 +221,7 @@ class NativeWidgetGtk : public internal::NativeWidgetPrivate, virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; virtual void ClearNativeFocus() OVERRIDE; + virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; protected: // Modifies event coordinates to the targeted widget contained by this widget. diff --git a/views/widget/native_widget_private.h b/views/widget/native_widget_private.h index 874612e..e1b6955 100644 --- a/views/widget/native_widget_private.h +++ b/views/widget/native_widget_private.h @@ -212,6 +212,7 @@ class NativeWidgetPrivate : public NativeWidget { virtual void SchedulePaintInRect(const gfx::Rect& rect) = 0; virtual void SetCursor(gfx::NativeCursor cursor) = 0; virtual void ClearNativeFocus() = 0; + virtual void FocusNativeView(gfx::NativeView native_view) = 0; // Overridden from NativeWidget: virtual internal::NativeWidgetPrivate* AsNativeWidgetPrivate() OVERRIDE; diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc index 47bb1a7..a69169b 100644 --- a/views/widget/native_widget_views.cc +++ b/views/widget/native_widget_views.cc @@ -459,6 +459,10 @@ void NativeWidgetViews::ClearNativeFocus() { GetParentNativeWidget()->ClearNativeFocus(); } +void NativeWidgetViews::FocusNativeView(gfx::NativeView native_view) { + GetParentNativeWidget()->FocusNativeView(native_view); +} + //////////////////////////////////////////////////////////////////////////////// // NativeWidgetViews, private: diff --git a/views/widget/native_widget_views.h b/views/widget/native_widget_views.h index 30567db..f1acf63 100644 --- a/views/widget/native_widget_views.h +++ b/views/widget/native_widget_views.h @@ -121,6 +121,7 @@ class NativeWidgetViews : public internal::NativeWidgetPrivate, virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; virtual void ClearNativeFocus() OVERRIDE; + virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; // Overridden from internal::InputMethodDelegate virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE; diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc index 17b28e9..da00f33 100644 --- a/views/widget/native_widget_win.cc +++ b/views/widget/native_widget_win.cc @@ -1088,6 +1088,12 @@ void NativeWidgetWin::ClearNativeFocus() { ::SetFocus(GetNativeView()); } +void NativeWidgetWin::FocusNativeView(gfx::NativeView native_view) { + // Only reset focus if hwnd is not already focused. + if (native_view && ::GetFocus() != native_view) + ::SetFocus(native_view); +} + //////////////////////////////////////////////////////////////////////////////// // NativeWidgetWin, MessageLoop::Observer implementation: diff --git a/views/widget/native_widget_win.h b/views/widget/native_widget_win.h index a6dd942..4d668d9 100644 --- a/views/widget/native_widget_win.h +++ b/views/widget/native_widget_win.h @@ -268,6 +268,7 @@ class NativeWidgetWin : public ui::WindowImpl, virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; virtual void ClearNativeFocus() OVERRIDE; + virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; protected: // Information saved before going into fullscreen mode, used to restore the diff --git a/views/widget/widget.cc b/views/widget/widget.cc index 69386a6..d26937f 100644 --- a/views/widget/widget.cc +++ b/views/widget/widget.cc @@ -633,6 +633,10 @@ void Widget::ClearNativeFocus() { native_widget_->ClearNativeFocus(); } +void Widget::FocusNativeView(gfx::NativeView native_view) { + native_widget_->FocusNativeView(native_view); +} + void Widget::UpdateFrameAfterFrameChange() { native_widget_->UpdateFrameAfterFrameChange(); } diff --git a/views/widget/widget.h b/views/widget/widget.h index af9a899..aea6ff9 100644 --- a/views/widget/widget.h +++ b/views/widget/widget.h @@ -437,6 +437,9 @@ class Widget : public internal::NativeWidgetDelegate, // Clear native focus set to the Widget's NativeWidget. void ClearNativeFocus(); + // Sets the focus to |native_view|. + void FocusNativeView(gfx::NativeView native_view); + // Updates the frame after an event caused it to be changed. virtual void UpdateFrameAfterFrameChange(); |