diff options
Diffstat (limited to 'views/widget')
-rw-r--r-- | views/widget/native_widget_gtk.cc | 80 | ||||
-rw-r--r-- | views/widget/native_widget_gtk.h | 9 | ||||
-rw-r--r-- | views/widget/native_widget_private.h | 9 | ||||
-rw-r--r-- | views/widget/native_widget_views.cc | 18 | ||||
-rw-r--r-- | views/widget/native_widget_views.h | 3 | ||||
-rw-r--r-- | views/widget/native_widget_win.cc | 14 | ||||
-rw-r--r-- | views/widget/native_widget_win.h | 3 | ||||
-rw-r--r-- | views/widget/root_view.cc | 38 | ||||
-rw-r--r-- | views/widget/root_view.h | 8 | ||||
-rw-r--r-- | views/widget/widget.cc | 4 |
10 files changed, 6 insertions, 180 deletions
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc index 19c7b77..eb614ea 100644 --- a/views/widget/native_widget_gtk.cc +++ b/views/widget/native_widget_gtk.cc @@ -377,9 +377,7 @@ NativeWidgetGtk::NativeWidgetGtk(internal::NativeWidgetDelegate* delegate) is_double_buffered_(false), should_handle_menu_key_release_(false), dragged_view_(NULL), - painted_(false), - has_mouse_grab_(false), - has_keyboard_grab_(false) { + painted_(false) { #if defined(TOUCH_UI) && defined(HAVE_XINPUT2) // Make sure the touch factory is initialized so that it can setup XInput2 for // the widget. @@ -690,12 +688,6 @@ void NativeWidgetGtk::InitNativeWidget(const Widget::InitParams& params) { // Make container here. CreateGtkWidget(modified_params); - if (params.type == Widget::InitParams::TYPE_MENU) { - gtk_window_set_destroy_with_parent(GTK_WINDOW(GetNativeView()), TRUE); - gtk_window_set_type_hint(GTK_WINDOW(GetNativeView()), - GDK_WINDOW_TYPE_HINT_MENU); - } - if (View::get_use_acceleration_when_possible()) { if (Widget::compositor_factory()) { compositor_ = (*Widget::compositor_factory())(); @@ -921,72 +913,18 @@ void NativeWidgetGtk::SendNativeAccessibilityEvent( void NativeWidgetGtk::SetMouseCapture() { DCHECK(!HasMouseCapture()); - - // Release the current grab. - GtkWidget* current_grab_window = gtk_grab_get_current(); - if (current_grab_window) - gtk_grab_remove(current_grab_window); - - // Make sure all app mouse/keyboard events are targeted at us only. gtk_grab_add(window_contents_); - - // And do a grab. NOTE: we do this to ensure we get mouse events from other - // apps, a grab done with gtk_grab_add doesn't get events from other apps. - GdkGrabStatus pointer_grab_status = - gdk_pointer_grab(window_contents()->window, FALSE, - static_cast<GdkEventMask>( - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK), - NULL, NULL, GDK_CURRENT_TIME); - // NOTE: technically grab may fail. We may want to try and continue on in that - // case. - DCHECK_EQ(GDK_GRAB_SUCCESS, pointer_grab_status); - has_mouse_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS; - -#if defined(HAVE_XINPUT2) && defined(TOUCH_UI) - ::Window window = GDK_WINDOW_XID(window_contents()->window); - Display* display = GDK_WINDOW_XDISPLAY(window_contents()->window); - bool xi2grab = TouchFactory::GetInstance()->GrabTouchDevices(display, window); - has_mouse_grab_ = has_mouse_grab_ && xi2grab; -#endif } void NativeWidgetGtk::ReleaseMouseCapture() { if (HasMouseCapture()) gtk_grab_remove(window_contents_); - if (has_mouse_grab_) { - has_mouse_grab_ = false; - gdk_pointer_ungrab(GDK_CURRENT_TIME); - gdk_keyboard_ungrab(GDK_CURRENT_TIME); -#if defined(HAVE_XINPUT2) && defined(TOUCH_UI) - TouchFactory::GetInstance()->UngrabTouchDevices( - GDK_WINDOW_XDISPLAY(window_contents()->window)); -#endif - } } bool NativeWidgetGtk::HasMouseCapture() const { - return has_mouse_grab_; -} - -void NativeWidgetGtk::SetKeyboardCapture() { - DCHECK(!has_keyboard_grab_); - - GdkGrabStatus keyboard_grab_status = - gdk_keyboard_grab(window_contents()->window, FALSE, GDK_CURRENT_TIME); - has_keyboard_grab_ = keyboard_grab_status == GDK_GRAB_SUCCESS; - DCHECK_EQ(GDK_GRAB_SUCCESS, keyboard_grab_status); -} - -void NativeWidgetGtk::ReleaseKeyboardCapture() { - if (has_keyboard_grab_) { - has_keyboard_grab_ = false; - gdk_keyboard_ungrab(GDK_CURRENT_TIME); - } -} - -bool NativeWidgetGtk::HasKeyboardCapture() { - return has_keyboard_grab_; + // TODO(beng): Should be able to use gtk_widget_has_grab() here but the + // trybots don't have Gtk 2.18. + return GTK_WIDGET_HAS_GRAB(window_contents_); } InputMethod* NativeWidgetGtk::GetInputMethodNative() { @@ -1774,19 +1712,9 @@ gboolean NativeWidgetGtk::OnConfigureEvent(GtkWidget* widget, } void NativeWidgetGtk::HandleXGrabBroke() { - if (has_keyboard_grab_) - has_keyboard_grab_ = false; - if (has_mouse_grab_) { - has_mouse_grab_ = false; - delegate_->OnMouseCaptureLost(); - } } void NativeWidgetGtk::HandleGtkGrabBroke() { - if (has_keyboard_grab_) - ReleaseKeyboardCapture(); - if (has_mouse_grab_) - ReleaseMouseCapture(); delegate_->OnMouseCaptureLost(); } diff --git a/views/widget/native_widget_gtk.h b/views/widget/native_widget_gtk.h index 19a29ed..3473b33 100644 --- a/views/widget/native_widget_gtk.h +++ b/views/widget/native_widget_gtk.h @@ -181,9 +181,6 @@ class NativeWidgetGtk : public internal::NativeWidgetPrivate, virtual void SetMouseCapture() OVERRIDE; virtual void ReleaseMouseCapture() OVERRIDE; virtual bool HasMouseCapture() const OVERRIDE; - virtual void SetKeyboardCapture() OVERRIDE; - virtual void ReleaseKeyboardCapture() OVERRIDE; - virtual bool HasKeyboardCapture() OVERRIDE; virtual InputMethod* GetInputMethodNative() OVERRIDE; virtual void ReplaceInputMethod(InputMethod* input_method) OVERRIDE; virtual void CenterWindow(const gfx::Size& size) OVERRIDE; @@ -457,12 +454,6 @@ class NativeWidgetGtk : public internal::NativeWidgetPrivate, // The compositor for accelerated drawing. scoped_refptr<ui::Compositor> compositor_; - // Have we done a mouse and pointer grab? - bool has_mouse_grab_; - - // Have we done a keyboard grab? - bool has_keyboard_grab_; - DISALLOW_COPY_AND_ASSIGN(NativeWidgetGtk); }; diff --git a/views/widget/native_widget_private.h b/views/widget/native_widget_private.h index 567f49e..dab73f2 100644 --- a/views/widget/native_widget_private.h +++ b/views/widget/native_widget_private.h @@ -122,16 +122,9 @@ class NativeWidgetPrivate : public NativeWidget { virtual void SetMouseCapture() = 0; virtual void ReleaseMouseCapture() = 0; - // Returns true if this native widget is capturing mouse events. + // Returns true if this native widget is capturing all events. virtual bool HasMouseCapture() const = 0; - // Sets or release keyboard capture. - virtual void SetKeyboardCapture() = 0; - virtual void ReleaseKeyboardCapture() = 0; - - // Returns true if this native widget is capturing keyboard events. - virtual bool HasKeyboardCapture() = 0; - // Returns the InputMethod for this native widget. // Note that all widgets in a widget hierarchy share the same input method. // TODO(suzhe): rename to GetInputMethod() when NativeWidget implementation diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc index b68247a..6c6bbcc 100644 --- a/views/widget/native_widget_views.cc +++ b/views/widget/native_widget_views.cc @@ -160,35 +160,17 @@ void NativeWidgetViews::SendNativeAccessibilityEvent( } void NativeWidgetViews::SetMouseCapture() { - View* parent_root_view = GetParentNativeWidget()->GetWidget()->GetRootView(); - static_cast<internal::RootView*>(parent_root_view)->set_capture_view(view_); GetParentNativeWidget()->SetMouseCapture(); } void NativeWidgetViews::ReleaseMouseCapture() { - View* parent_root_view = GetParentNativeWidget()->GetWidget()->GetRootView(); - static_cast<internal::RootView*>(parent_root_view)->set_capture_view(NULL); GetParentNativeWidget()->ReleaseMouseCapture(); } bool NativeWidgetViews::HasMouseCapture() const { - // NOTE: we may need to tweak this to only return true if the parent native - // widget's RootView has us as the capture view. return GetParentNativeWidget()->HasMouseCapture(); } -void NativeWidgetViews::SetKeyboardCapture() { - GetParentNativeWidget()->SetKeyboardCapture(); -} - -void NativeWidgetViews::ReleaseKeyboardCapture() { - GetParentNativeWidget()->ReleaseKeyboardCapture(); -} - -bool NativeWidgetViews::HasKeyboardCapture() { - return GetParentNativeWidget()->HasKeyboardCapture(); -} - InputMethod* NativeWidgetViews::GetInputMethodNative() { return GetParentNativeWidget()->GetInputMethodNative(); } diff --git a/views/widget/native_widget_views.h b/views/widget/native_widget_views.h index dd60310..d2c81fa 100644 --- a/views/widget/native_widget_views.h +++ b/views/widget/native_widget_views.h @@ -65,9 +65,6 @@ class NativeWidgetViews : public internal::NativeWidgetPrivate { virtual void SetMouseCapture() OVERRIDE; virtual void ReleaseMouseCapture() OVERRIDE; virtual bool HasMouseCapture() const OVERRIDE; - virtual void SetKeyboardCapture() OVERRIDE; - virtual void ReleaseKeyboardCapture() OVERRIDE; - virtual bool HasKeyboardCapture() OVERRIDE; virtual InputMethod* GetInputMethodNative() OVERRIDE; virtual void ReplaceInputMethod(InputMethod* input_method) OVERRIDE; virtual void CenterWindow(const gfx::Size& size) OVERRIDE; diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc index 15f9720..8d2420e 100644 --- a/views/widget/native_widget_win.cc +++ b/views/widget/native_widget_win.cc @@ -626,19 +626,6 @@ bool NativeWidgetWin::HasMouseCapture() const { return GetCapture() == hwnd(); } -void NativeWidgetWin::SetKeyboardCapture() { - // Windows doesn't really support keyboard grabs. -} - -void NativeWidgetWin::ReleaseKeyboardCapture() { - // Windows doesn't really support keyboard grabs. -} - -bool NativeWidgetWin::HasKeyboardCapture() { - // Windows doesn't really support keyboard grabs. - return false; -} - InputMethod* NativeWidgetWin::GetInputMethodNative() { return input_method_.get(); } @@ -1179,7 +1166,6 @@ LRESULT NativeWidgetWin::OnAppCommand(HWND window, } void NativeWidgetWin::OnCancelMode() { - SetMsgHandled(FALSE); } void NativeWidgetWin::OnCaptureChanged(HWND hwnd) { diff --git a/views/widget/native_widget_win.h b/views/widget/native_widget_win.h index 965eb6d..eb8d391 100644 --- a/views/widget/native_widget_win.h +++ b/views/widget/native_widget_win.h @@ -216,9 +216,6 @@ class NativeWidgetWin : public ui::WindowImpl, virtual void SetMouseCapture() OVERRIDE; virtual void ReleaseMouseCapture() OVERRIDE; virtual bool HasMouseCapture() const OVERRIDE; - virtual void SetKeyboardCapture() OVERRIDE; - virtual void ReleaseKeyboardCapture() OVERRIDE; - virtual bool HasKeyboardCapture() OVERRIDE; virtual InputMethod* GetInputMethodNative() OVERRIDE; virtual void ReplaceInputMethod(InputMethod* input_method) OVERRIDE; virtual void CenterWindow(const gfx::Size& size) OVERRIDE; diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index ce35f8b..9b1a3c3 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -30,7 +30,6 @@ const char RootView::kViewClassName[] = "views/RootView"; RootView::RootView(Widget* widget) : widget_(widget), - capture_view_(NULL), mouse_pressed_handler_(NULL), mouse_move_handler_(NULL), last_click_handler_(NULL), @@ -168,10 +167,6 @@ void RootView::SchedulePaintInternal(const gfx::Rect& rect) { } bool RootView::OnMousePressed(const MouseEvent& event) { - if (capture_view_) { - MouseEvent e(event, this, capture_view_); - return capture_view_->OnMousePressed(e); - } MouseEvent e(event, this); UpdateCursor(e); @@ -247,11 +242,6 @@ bool RootView::OnMousePressed(const MouseEvent& event) { } bool RootView::OnMouseDragged(const MouseEvent& event) { - if (capture_view_) { - MouseEvent e(event, this, capture_view_); - return capture_view_->OnMouseDragged(e); - } - MouseEvent e(event, this); UpdateCursor(e); @@ -265,12 +255,6 @@ bool RootView::OnMouseDragged(const MouseEvent& event) { } void RootView::OnMouseReleased(const MouseEvent& event) { - if (capture_view_) { - MouseEvent e(event, this, capture_view_); - capture_view_->OnMouseReleased(e); - return; - } - MouseEvent e(event, this); UpdateCursor(e); @@ -286,13 +270,6 @@ void RootView::OnMouseReleased(const MouseEvent& event) { } void RootView::OnMouseCaptureLost() { - if (capture_view_) { - View* capture_view = capture_view_; - capture_view_ = NULL; - capture_view->OnMouseCaptureLost(); - return; - } - if (mouse_pressed_handler_) { // Synthesize a release event for UpdateCursor. MouseEvent release_event(ui::ET_MOUSE_RELEASED, last_mouse_event_x_, @@ -308,12 +285,6 @@ void RootView::OnMouseCaptureLost() { } void RootView::OnMouseMoved(const MouseEvent& event) { - if (capture_view_) { - MouseEvent e(event, this, capture_view_); - capture_view_->OnMouseMoved(e); - return; - } - MouseEvent e(event, this); View* v = GetEventHandlerForPoint(e.location()); // Find the first enabled view, or the existing move handler, whichever comes @@ -341,12 +312,6 @@ void RootView::OnMouseMoved(const MouseEvent& event) { } void RootView::OnMouseExited(const MouseEvent& event) { - if (capture_view_) { - MouseEvent e(event, this, capture_view_); - capture_view_->OnMouseExited(e); - return; - } - if (mouse_move_handler_ != NULL) { mouse_move_handler_->OnMouseExited(event); mouse_move_handler_ = NULL; @@ -354,9 +319,6 @@ void RootView::OnMouseExited(const MouseEvent& event) { } bool RootView::OnMouseWheel(const MouseWheelEvent& event) { - if (capture_view_) - return capture_view_->OnMouseWheel(event); - MouseWheelEvent e(event, this); bool consumed = false; View* v = GetFocusManager()->GetFocusedView(); diff --git a/views/widget/root_view.h b/views/widget/root_view.h index 0ba3d51..b33ecf5 100644 --- a/views/widget/root_view.h +++ b/views/widget/root_view.h @@ -64,11 +64,6 @@ class RootView : public View, // Input --------------------------------------------------------------------- - // If a capture view has been set all mouse events are forwarded to the - // capture view, regardless of whether the mouse is over the view. - void set_capture_view(View* v) { capture_view_ = v; } - View* capture_view() { return capture_view_; } - // Process a key event. Send the event to the focused view and up the focus // path, and finally to the default keyboard handler, until someone consumes // it. Returns whether anyone consumed the event. @@ -164,9 +159,6 @@ class RootView : public View, // Input --------------------------------------------------------------------- - // View capturing mouse input. - View* capture_view_; - // The view currently handing down - drag - up View* mouse_pressed_handler_; diff --git a/views/widget/widget.cc b/views/widget/widget.cc index a38b59c..d309917 100644 --- a/views/widget/widget.cc +++ b/views/widget/widget.cc @@ -832,9 +832,7 @@ bool Widget::OnMouseEvent(const MouseEvent& event) { switch (event.type()) { case ui::ET_MOUSE_PRESSED: last_mouse_event_was_move_ = false; - // Make sure we're still visible before we attempt capture as the mouse - // press processing may have made the window hide (as happens with menus). - if (GetRootView()->OnMousePressed(event) && IsVisible()) { + if (GetRootView()->OnMousePressed(event)) { is_mouse_button_pressed_ = true; if (!native_widget_->HasMouseCapture()) native_widget_->SetMouseCapture(); |