| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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) |
| 10 #include <gdk/gdkx.h> |
| 11 #include <X11/extensions/XInput2.h> |
| 12 #endif |
| 13 |
| 9 #include "views/controls/menu/menu_controller.h" | 14 #include "views/controls/menu/menu_controller.h" |
| 10 #include "views/controls/menu/menu_host_root_view.h" | 15 #include "views/controls/menu/menu_host_root_view.h" |
| 11 #include "views/controls/menu/menu_item_view.h" | 16 #include "views/controls/menu/menu_item_view.h" |
| 12 #include "views/controls/menu/submenu_view.h" | 17 #include "views/controls/menu/submenu_view.h" |
| 13 | 18 |
| 19 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) |
| 20 #include "views/touchui/touch_factory.h" |
| 21 #endif |
| 22 |
| 14 namespace views { | 23 namespace views { |
| 15 | 24 |
| 16 // static | 25 // static |
| 17 MenuHost* MenuHost::Create(SubmenuView* submenu_view) { | 26 MenuHost* MenuHost::Create(SubmenuView* submenu_view) { |
| 18 return new MenuHostGtk(submenu_view); | 27 return new MenuHostGtk(submenu_view); |
| 19 } | 28 } |
| 20 | 29 |
| 21 MenuHostGtk::MenuHostGtk(SubmenuView* submenu) | 30 MenuHostGtk::MenuHostGtk(SubmenuView* submenu) |
| 22 : WidgetGtk(WidgetGtk::TYPE_POPUP), | 31 : WidgetGtk(WidgetGtk::TYPE_POPUP), |
| 23 destroying_(false), | 32 destroying_(false), |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 bool MenuHostGtk::ReleaseCaptureOnMouseReleased() { | 106 bool MenuHostGtk::ReleaseCaptureOnMouseReleased() { |
| 98 return false; | 107 return false; |
| 99 } | 108 } |
| 100 | 109 |
| 101 void MenuHostGtk::ReleaseGrab() { | 110 void MenuHostGtk::ReleaseGrab() { |
| 102 WidgetGtk::ReleaseGrab(); | 111 WidgetGtk::ReleaseGrab(); |
| 103 if (did_input_grab_) { | 112 if (did_input_grab_) { |
| 104 did_input_grab_ = false; | 113 did_input_grab_ = false; |
| 105 gdk_pointer_ungrab(GDK_CURRENT_TIME); | 114 gdk_pointer_ungrab(GDK_CURRENT_TIME); |
| 106 gdk_keyboard_ungrab(GDK_CURRENT_TIME); | 115 gdk_keyboard_ungrab(GDK_CURRENT_TIME); |
| 116 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) |
| 117 TouchFactory::GetInstance()->UngrabTouchDevices( |
| 118 GDK_WINDOW_XDISPLAY(window_contents()->window)); |
| 119 #endif |
| 107 } | 120 } |
| 108 } | 121 } |
| 109 | 122 |
| 110 void MenuHostGtk::OnDestroy(GtkWidget* object) { | 123 void MenuHostGtk::OnDestroy(GtkWidget* object) { |
| 111 if (!destroying_) { | 124 if (!destroying_) { |
| 112 // We weren't explicitly told to destroy ourselves, which means the menu was | 125 // We weren't explicitly told to destroy ourselves, which means the menu was |
| 113 // deleted out from under us (the window we're parented to was closed). Tell | 126 // deleted out from under us (the window we're parented to was closed). Tell |
| 114 // the SubmenuView to drop references to us. | 127 // the SubmenuView to drop references to us. |
| 115 submenu_->MenuHostDestroyed(); | 128 submenu_->MenuHostDestroyed(); |
| 116 } | 129 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 144 static_cast<GdkEventMask>( | 157 static_cast<GdkEventMask>( |
| 145 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | 158 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | |
| 146 GDK_POINTER_MOTION_MASK), | 159 GDK_POINTER_MOTION_MASK), |
| 147 NULL, NULL, GDK_CURRENT_TIME); | 160 NULL, NULL, GDK_CURRENT_TIME); |
| 148 GdkGrabStatus keyboard_grab_status = | 161 GdkGrabStatus keyboard_grab_status = |
| 149 gdk_keyboard_grab(window_contents()->window, FALSE, | 162 gdk_keyboard_grab(window_contents()->window, FALSE, |
| 150 GDK_CURRENT_TIME); | 163 GDK_CURRENT_TIME); |
| 151 | 164 |
| 152 did_input_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS && | 165 did_input_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS && |
| 153 keyboard_grab_status == GDK_GRAB_SUCCESS; | 166 keyboard_grab_status == GDK_GRAB_SUCCESS; |
| 167 |
| 168 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) |
| 169 ::Window window = GDK_WINDOW_XID(window_contents()->window); |
| 170 Display* display = GDK_WINDOW_XDISPLAY(window_contents()->window); |
| 171 bool xi2grab = TouchFactory::GetInstance()->GrabTouchDevices(display, window); |
| 172 did_input_grab_ = did_input_grab_ && xi2grab; |
| 173 #endif |
| 174 |
| 154 DCHECK(did_input_grab_); | 175 DCHECK(did_input_grab_); |
| 155 // need keyboard grab. | 176 // need keyboard grab. |
| 156 } | 177 } |
| 157 | 178 |
| 158 } // namespace views | 179 } // namespace views |
| OLD | NEW |