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

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

Issue 6975045: touch: Always expect XInput2 availability. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 6 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) 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(TOUCH_UI)
10 #include <gdk/gdkx.h> 10 #include <gdk/gdkx.h>
11 #include <X11/extensions/XInput2.h> 11 #include <X11/extensions/XInput2.h>
12 #endif 12 #endif
13 13
14 #include "views/controls/menu/native_menu_host_delegate.h" 14 #include "views/controls/menu/native_menu_host_delegate.h"
15 15
16 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) 16 #if defined(TOUCH_UI)
17 #include "views/touchui/touch_factory.h" 17 #include "views/touchui/touch_factory.h"
18 #endif 18 #endif
19 19
20 namespace views { 20 namespace views {
21 21
22 //////////////////////////////////////////////////////////////////////////////// 22 ////////////////////////////////////////////////////////////////////////////////
23 // MenuHostGtk, public: 23 // MenuHostGtk, public:
24 24
25 MenuHostGtk::MenuHostGtk(internal::NativeMenuHostDelegate* delegate) 25 MenuHostGtk::MenuHostGtk(internal::NativeMenuHostDelegate* delegate)
26 : NativeWidgetGtk(delegate->AsNativeWidgetDelegate()), 26 : NativeWidgetGtk(delegate->AsNativeWidgetDelegate()),
(...skipping 30 matching lines...) Expand all
57 GdkGrabStatus keyboard_grab_status = 57 GdkGrabStatus keyboard_grab_status =
58 gdk_keyboard_grab(window_contents()->window, FALSE, 58 gdk_keyboard_grab(window_contents()->window, FALSE,
59 GDK_CURRENT_TIME); 59 GDK_CURRENT_TIME);
60 60
61 did_input_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS && 61 did_input_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS &&
62 keyboard_grab_status == GDK_GRAB_SUCCESS; 62 keyboard_grab_status == GDK_GRAB_SUCCESS;
63 63
64 DCHECK_EQ(GDK_GRAB_SUCCESS, pointer_grab_status); 64 DCHECK_EQ(GDK_GRAB_SUCCESS, pointer_grab_status);
65 DCHECK_EQ(GDK_GRAB_SUCCESS, keyboard_grab_status); 65 DCHECK_EQ(GDK_GRAB_SUCCESS, keyboard_grab_status);
66 66
67 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) 67 #if defined(TOUCH_UI)
68 ::Window window = GDK_WINDOW_XID(window_contents()->window); 68 ::Window window = GDK_WINDOW_XID(window_contents()->window);
69 Display* display = GDK_WINDOW_XDISPLAY(window_contents()->window); 69 Display* display = GDK_WINDOW_XDISPLAY(window_contents()->window);
70 bool xi2grab = TouchFactory::GetInstance()->GrabTouchDevices(display, window); 70 bool xi2grab = TouchFactory::GetInstance()->GrabTouchDevices(display, window);
71 did_input_grab_ = did_input_grab_ && xi2grab; 71 did_input_grab_ = did_input_grab_ && xi2grab;
72 #endif 72 #endif
73 73
74 DCHECK(did_input_grab_); 74 DCHECK(did_input_grab_);
75 // need keyboard grab. 75 // need keyboard grab.
76 } 76 }
77 77
(...skipping 11 matching lines...) Expand all
89 gtk_window_set_type_hint(GTK_WINDOW(GetNativeView()), 89 gtk_window_set_type_hint(GTK_WINDOW(GetNativeView()),
90 GDK_WINDOW_TYPE_HINT_MENU); 90 GDK_WINDOW_TYPE_HINT_MENU);
91 } 91 }
92 92
93 void MenuHostGtk::ReleaseMouseCapture() { 93 void MenuHostGtk::ReleaseMouseCapture() {
94 NativeWidgetGtk::ReleaseMouseCapture(); 94 NativeWidgetGtk::ReleaseMouseCapture();
95 if (did_input_grab_) { 95 if (did_input_grab_) {
96 did_input_grab_ = false; 96 did_input_grab_ = false;
97 gdk_pointer_ungrab(GDK_CURRENT_TIME); 97 gdk_pointer_ungrab(GDK_CURRENT_TIME);
98 gdk_keyboard_ungrab(GDK_CURRENT_TIME); 98 gdk_keyboard_ungrab(GDK_CURRENT_TIME);
99 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) 99 #if defined(TOUCH_UI)
100 TouchFactory::GetInstance()->UngrabTouchDevices( 100 TouchFactory::GetInstance()->UngrabTouchDevices(
101 GDK_WINDOW_XDISPLAY(window_contents()->window)); 101 GDK_WINDOW_XDISPLAY(window_contents()->window));
102 #endif 102 #endif
103 } 103 }
104 } 104 }
105 105
106 void MenuHostGtk::OnDestroy(GtkWidget* object) { 106 void MenuHostGtk::OnDestroy(GtkWidget* object) {
107 delegate_->OnNativeMenuHostDestroy(); 107 delegate_->OnNativeMenuHostDestroy();
108 NativeWidgetGtk::OnDestroy(object); 108 NativeWidgetGtk::OnDestroy(object);
109 } 109 }
(...skipping 19 matching lines...) Expand all
129 //////////////////////////////////////////////////////////////////////////////// 129 ////////////////////////////////////////////////////////////////////////////////
130 // NativeMenuHost, public: 130 // NativeMenuHost, public:
131 131
132 // static 132 // static
133 NativeMenuHost* NativeMenuHost::CreateNativeMenuHost( 133 NativeMenuHost* NativeMenuHost::CreateNativeMenuHost(
134 internal::NativeMenuHostDelegate* delegate) { 134 internal::NativeMenuHostDelegate* delegate) {
135 return new MenuHostGtk(delegate); 135 return new MenuHostGtk(delegate);
136 } 136 }
137 137
138 } // namespace views 138 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698