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