| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "views/controls/menu/menu_host_gtk.h" | 5 #include "views/controls/menu/menu_host_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 | 8 |
| 9 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) | 9 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) |
| 10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // window now, it means AcceleratorHandler attempts to use a window that has | 82 // window now, it means AcceleratorHandler attempts to use a window that has |
| 83 // been destroyed. | 83 // been destroyed. |
| 84 Close(); | 84 Close(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void MenuHostGtk::SetMenuHostBounds(const gfx::Rect& bounds) { | 87 void MenuHostGtk::SetMenuHostBounds(const gfx::Rect& bounds) { |
| 88 SetBounds(bounds); | 88 SetBounds(bounds); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void MenuHostGtk::ReleaseMenuHostCapture() { | 91 void MenuHostGtk::ReleaseMenuHostCapture() { |
| 92 ReleaseNativeCapture(); | 92 ReleaseMouseCapture(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 gfx::NativeWindow MenuHostGtk::GetMenuHostWindow() { | 95 gfx::NativeWindow MenuHostGtk::GetMenuHostWindow() { |
| 96 return GTK_WINDOW(GetNativeView()); | 96 return GTK_WINDOW(GetNativeView()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 //////////////////////////////////////////////////////////////////////////////// | 99 //////////////////////////////////////////////////////////////////////////////// |
| 100 // MenuHostGtk, WidgetGtk overrides: | 100 // MenuHostGtk, WidgetGtk overrides: |
| 101 | 101 |
| 102 RootView* MenuHostGtk::CreateRootView() { | 102 RootView* MenuHostGtk::CreateRootView() { |
| 103 return new MenuHostRootView(this, submenu_); | 103 return new MenuHostRootView(this, submenu_); |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool MenuHostGtk::ReleaseCaptureOnMouseReleased() { | 106 bool MenuHostGtk::ShouldReleaseCaptureOnMouseReleased() const { |
| 107 return false; | 107 return false; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void MenuHostGtk::ReleaseNativeCapture() { | 110 void MenuHostGtk::ReleaseMouseCapture() { |
| 111 WidgetGtk::ReleaseNativeCapture(); | 111 WidgetGtk::ReleaseMouseCapture(); |
| 112 if (did_input_grab_) { | 112 if (did_input_grab_) { |
| 113 did_input_grab_ = false; | 113 did_input_grab_ = false; |
| 114 gdk_pointer_ungrab(GDK_CURRENT_TIME); | 114 gdk_pointer_ungrab(GDK_CURRENT_TIME); |
| 115 gdk_keyboard_ungrab(GDK_CURRENT_TIME); | 115 gdk_keyboard_ungrab(GDK_CURRENT_TIME); |
| 116 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) | 116 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) |
| 117 TouchFactory::GetInstance()->UngrabTouchDevices( | 117 TouchFactory::GetInstance()->UngrabTouchDevices( |
| 118 GDK_WINDOW_XDISPLAY(window_contents()->window)); | 118 GDK_WINDOW_XDISPLAY(window_contents()->window)); |
| 119 #endif | 119 #endif |
| 120 } | 120 } |
| 121 } | 121 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 135 if (did_input_grab_ && !destroying_) { | 135 if (did_input_grab_ && !destroying_) { |
| 136 did_input_grab_ = false; | 136 did_input_grab_ = false; |
| 137 CancelAllIfNoDrag(); | 137 CancelAllIfNoDrag(); |
| 138 } | 138 } |
| 139 WidgetGtk::HandleXGrabBroke(); | 139 WidgetGtk::HandleXGrabBroke(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void MenuHostGtk::HandleGtkGrabBroke() { | 142 void MenuHostGtk::HandleGtkGrabBroke() { |
| 143 // Grab can be broken by drag & drop, other menu or screen locker. | 143 // Grab can be broken by drag & drop, other menu or screen locker. |
| 144 if (did_input_grab_ && !destroying_) { | 144 if (did_input_grab_ && !destroying_) { |
| 145 ReleaseNativeCapture(); | 145 ReleaseMouseCapture(); |
| 146 CancelAllIfNoDrag(); | 146 CancelAllIfNoDrag(); |
| 147 } | 147 } |
| 148 WidgetGtk::HandleGtkGrabBroke(); | 148 WidgetGtk::HandleGtkGrabBroke(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 //////////////////////////////////////////////////////////////////////////////// | 151 //////////////////////////////////////////////////////////////////////////////// |
| 152 // MenuHostGtk, private: | 152 // MenuHostGtk, private: |
| 153 | 153 |
| 154 void MenuHostGtk::DoCapture() { | 154 void MenuHostGtk::DoCapture() { |
| 155 DCHECK(!did_input_grab_); | 155 DCHECK(!did_input_grab_); |
| 156 | 156 |
| 157 // Release the current grab. | 157 // Release the current grab. |
| 158 GtkWidget* current_grab_window = gtk_grab_get_current(); | 158 GtkWidget* current_grab_window = gtk_grab_get_current(); |
| 159 if (current_grab_window) | 159 if (current_grab_window) |
| 160 gtk_grab_remove(current_grab_window); | 160 gtk_grab_remove(current_grab_window); |
| 161 | 161 |
| 162 // Make sure all app mouse/keyboard events are targetted at us only. | 162 // Make sure all app mouse/keyboard events are targetted at us only. |
| 163 SetNativeCapture(); | 163 SetMouseCapture(); |
| 164 | 164 |
| 165 // And do a grab. NOTE: we do this to ensure we get mouse/keyboard | 165 // And do a grab. NOTE: we do this to ensure we get mouse/keyboard |
| 166 // events from other apps, a grab done with gtk_grab_add doesn't get | 166 // events from other apps, a grab done with gtk_grab_add doesn't get |
| 167 // events from other apps. | 167 // events from other apps. |
| 168 GdkGrabStatus pointer_grab_status = | 168 GdkGrabStatus pointer_grab_status = |
| 169 gdk_pointer_grab(window_contents()->window, FALSE, | 169 gdk_pointer_grab(window_contents()->window, FALSE, |
| 170 static_cast<GdkEventMask>( | 170 static_cast<GdkEventMask>( |
| 171 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | 171 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | |
| 172 GDK_POINTER_MOTION_MASK), | 172 GDK_POINTER_MOTION_MASK), |
| 173 NULL, NULL, GDK_CURRENT_TIME); | 173 NULL, NULL, GDK_CURRENT_TIME); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 202 | 202 |
| 203 //////////////////////////////////////////////////////////////////////////////// | 203 //////////////////////////////////////////////////////////////////////////////// |
| 204 // NativeMenuHost, public: | 204 // NativeMenuHost, public: |
| 205 | 205 |
| 206 // static | 206 // static |
| 207 NativeMenuHost* NativeMenuHost::CreateNativeMenuHost(SubmenuView* submenu) { | 207 NativeMenuHost* NativeMenuHost::CreateNativeMenuHost(SubmenuView* submenu) { |
| 208 return new MenuHostGtk(submenu); | 208 return new MenuHostGtk(submenu); |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace views | 211 } // namespace views |
| OLD | NEW |