Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: views/controls/menu/menu_host_gtk.cc

Issue 6300007: touch: Allow grabbing/ungrabbing touch devices for XInput2. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #if defined(HAVE_XINPUT2)
sky 2011/01/19 19:34:54 newline between 7 and 8
sadrul 2011/01/19 20:10:17 Done.
9 #include <gdk/gdkx.h>
10 #include <X11/extensions/XInput2.h>
11 #endif
8 12
9 #include "views/controls/menu/menu_controller.h" 13 #include "views/controls/menu/menu_controller.h"
10 #include "views/controls/menu/menu_host_root_view.h" 14 #include "views/controls/menu/menu_host_root_view.h"
11 #include "views/controls/menu/menu_item_view.h" 15 #include "views/controls/menu/menu_item_view.h"
12 #include "views/controls/menu/submenu_view.h" 16 #include "views/controls/menu/submenu_view.h"
17 #if defined(HAVE_XINPUT2)
sky 2011/01/19 19:34:54 newline between 16 and 17.
sadrul 2011/01/19 20:10:17 Done.
18 #include "views/touchui/touch_factory.h"
19 #endif
13 20
14 namespace views { 21 namespace views {
15 22
16 // static 23 // static
17 MenuHost* MenuHost::Create(SubmenuView* submenu_view) { 24 MenuHost* MenuHost::Create(SubmenuView* submenu_view) {
18 return new MenuHostGtk(submenu_view); 25 return new MenuHostGtk(submenu_view);
19 } 26 }
20 27
21 MenuHostGtk::MenuHostGtk(SubmenuView* submenu) 28 MenuHostGtk::MenuHostGtk(SubmenuView* submenu)
22 : WidgetGtk(WidgetGtk::TYPE_POPUP), 29 : WidgetGtk(WidgetGtk::TYPE_POPUP),
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bool MenuHostGtk::ReleaseCaptureOnMouseReleased() { 104 bool MenuHostGtk::ReleaseCaptureOnMouseReleased() {
98 return false; 105 return false;
99 } 106 }
100 107
101 void MenuHostGtk::ReleaseGrab() { 108 void MenuHostGtk::ReleaseGrab() {
102 WidgetGtk::ReleaseGrab(); 109 WidgetGtk::ReleaseGrab();
103 if (did_input_grab_) { 110 if (did_input_grab_) {
104 did_input_grab_ = false; 111 did_input_grab_ = false;
105 gdk_pointer_ungrab(GDK_CURRENT_TIME); 112 gdk_pointer_ungrab(GDK_CURRENT_TIME);
106 gdk_keyboard_ungrab(GDK_CURRENT_TIME); 113 gdk_keyboard_ungrab(GDK_CURRENT_TIME);
114 #if defined(HAVE_XINPUT2)
115 TouchFactory::GetInstance()->UngrabTouchDevices(
116 GDK_WINDOW_XDISPLAY(window_contents()->window));
117 #endif
107 } 118 }
108 } 119 }
109 120
110 void MenuHostGtk::OnDestroy(GtkWidget* object) { 121 void MenuHostGtk::OnDestroy(GtkWidget* object) {
111 if (!destroying_) { 122 if (!destroying_) {
112 // We weren't explicitly told to destroy ourselves, which means the menu was 123 // 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 124 // deleted out from under us (the window we're parented to was closed). Tell
114 // the SubmenuView to drop references to us. 125 // the SubmenuView to drop references to us.
115 submenu_->MenuHostDestroyed(); 126 submenu_->MenuHostDestroyed();
116 } 127 }
(...skipping 27 matching lines...) Expand all
144 static_cast<GdkEventMask>( 155 static_cast<GdkEventMask>(
145 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | 156 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
146 GDK_POINTER_MOTION_MASK), 157 GDK_POINTER_MOTION_MASK),
147 NULL, NULL, GDK_CURRENT_TIME); 158 NULL, NULL, GDK_CURRENT_TIME);
148 GdkGrabStatus keyboard_grab_status = 159 GdkGrabStatus keyboard_grab_status =
149 gdk_keyboard_grab(window_contents()->window, FALSE, 160 gdk_keyboard_grab(window_contents()->window, FALSE,
150 GDK_CURRENT_TIME); 161 GDK_CURRENT_TIME);
151 162
152 did_input_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS && 163 did_input_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS &&
153 keyboard_grab_status == GDK_GRAB_SUCCESS; 164 keyboard_grab_status == GDK_GRAB_SUCCESS;
165
166 #if defined(HAVE_XINPUT2)
167 ::Window window = GDK_WINDOW_XID(window_contents()->window);
168 Display* display = GDK_WINDOW_XDISPLAY(window_contents()->window);
169 bool xi2grab = TouchFactory::GetInstance()->GrabTouchDevices(display, window);
170 did_input_grab_ = did_input_grab_ && xi2grab;
171 #endif
172
154 DCHECK(did_input_grab_); 173 DCHECK(did_input_grab_);
155 // need keyboard grab. 174 // need keyboard grab.
156 } 175 }
157 176
158 } // namespace views 177 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698