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/widget/native_widget_gtk.h" | 5 #include "views/widget/native_widget_gtk.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 #include <X11/extensions/shape.h> | 9 #include <X11/extensions/shape.h> |
10 #include <X11/Xatom.h> | 10 #include <X11/Xatom.h> |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "views/widget/drop_target_gtk.h" | 36 #include "views/widget/drop_target_gtk.h" |
37 #include "views/widget/gtk_views_fixed.h" | 37 #include "views/widget/gtk_views_fixed.h" |
38 #include "views/widget/gtk_views_window.h" | 38 #include "views/widget/gtk_views_window.h" |
39 #include "views/widget/native_widget_views.h" | 39 #include "views/widget/native_widget_views.h" |
40 #include "views/widget/root_view.h" | 40 #include "views/widget/root_view.h" |
41 #include "views/widget/widget_delegate.h" | 41 #include "views/widget/widget_delegate.h" |
42 #include "views/window/hit_test.h" | 42 #include "views/window/hit_test.h" |
43 | 43 |
44 #if defined(TOUCH_UI) | 44 #if defined(TOUCH_UI) |
45 #include "views/widget/tooltip_manager_views.h" | 45 #include "views/widget/tooltip_manager_views.h" |
46 #if defined(HAVE_XINPUT2) | |
47 #include <gdk/gdkx.h> | |
48 | |
49 #include "ui/gfx/gtk_util.h" | |
50 #include "views/touchui/touch_factory.h" | 46 #include "views/touchui/touch_factory.h" |
51 #endif | |
52 #else | 47 #else |
53 #include "views/widget/tooltip_manager_gtk.h" | 48 #include "views/widget/tooltip_manager_gtk.h" |
54 #endif | 49 #endif |
55 | 50 |
56 #if defined(HAVE_IBUS) | 51 #if defined(HAVE_IBUS) |
57 #include "views/ime/input_method_ibus.h" | 52 #include "views/ime/input_method_ibus.h" |
58 #endif | 53 #endif |
59 | 54 |
60 using ui::OSExchangeData; | 55 using ui::OSExchangeData; |
61 using ui::OSExchangeDataProviderGtk; | 56 using ui::OSExchangeDataProviderGtk; |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 transient_to_parent_(false), | 367 transient_to_parent_(false), |
373 got_initial_focus_in_(false), | 368 got_initial_focus_in_(false), |
374 has_focus_(false), | 369 has_focus_(false), |
375 always_on_top_(false), | 370 always_on_top_(false), |
376 is_double_buffered_(false), | 371 is_double_buffered_(false), |
377 should_handle_menu_key_release_(false), | 372 should_handle_menu_key_release_(false), |
378 dragged_view_(NULL), | 373 dragged_view_(NULL), |
379 painted_(false), | 374 painted_(false), |
380 has_mouse_grab_(false), | 375 has_mouse_grab_(false), |
381 has_keyboard_grab_(false) { | 376 has_keyboard_grab_(false) { |
382 #if defined(TOUCH_UI) && defined(HAVE_XINPUT2) | 377 #if defined(TOUCH_UI) |
383 // Make sure the touch factory is initialized so that it can setup XInput2 for | 378 // Make sure the touch factory is initialized so that it can setup XInput2 for |
384 // the widget. | 379 // the widget. |
385 TouchFactory::GetInstance(); | 380 TouchFactory::GetInstance(); |
386 #endif | 381 #endif |
387 static bool installed_message_loop_observer = false; | 382 static bool installed_message_loop_observer = false; |
388 if (!installed_message_loop_observer) { | 383 if (!installed_message_loop_observer) { |
389 installed_message_loop_observer = true; | 384 installed_message_loop_observer = true; |
390 MessageLoopForUI* loop = MessageLoopForUI::current(); | 385 MessageLoopForUI* loop = MessageLoopForUI::current(); |
391 if (loop) | 386 if (loop) |
392 loop->AddObserver(DropObserver::GetInstance()); | 387 loop->AddObserver(DropObserver::GetInstance()); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 gdk_pointer_grab(window_contents()->window, FALSE, | 907 gdk_pointer_grab(window_contents()->window, FALSE, |
913 static_cast<GdkEventMask>( | 908 static_cast<GdkEventMask>( |
914 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | 909 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | |
915 GDK_POINTER_MOTION_MASK), | 910 GDK_POINTER_MOTION_MASK), |
916 NULL, NULL, GDK_CURRENT_TIME); | 911 NULL, NULL, GDK_CURRENT_TIME); |
917 // NOTE: technically grab may fail. We may want to try and continue on in that | 912 // NOTE: technically grab may fail. We may want to try and continue on in that |
918 // case. | 913 // case. |
919 DCHECK_EQ(GDK_GRAB_SUCCESS, pointer_grab_status); | 914 DCHECK_EQ(GDK_GRAB_SUCCESS, pointer_grab_status); |
920 has_mouse_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS; | 915 has_mouse_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS; |
921 | 916 |
922 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) | 917 #if defined(TOUCH_UI) |
923 ::Window window = GDK_WINDOW_XID(window_contents()->window); | 918 ::Window window = GDK_WINDOW_XID(window_contents()->window); |
924 Display* display = GDK_WINDOW_XDISPLAY(window_contents()->window); | 919 Display* display = GDK_WINDOW_XDISPLAY(window_contents()->window); |
925 bool xi2grab = TouchFactory::GetInstance()->GrabTouchDevices(display, window); | 920 bool xi2grab = TouchFactory::GetInstance()->GrabTouchDevices(display, window); |
926 has_mouse_grab_ = has_mouse_grab_ && xi2grab; | 921 has_mouse_grab_ = has_mouse_grab_ && xi2grab; |
927 #endif | 922 #endif |
928 } | 923 } |
929 | 924 |
930 void NativeWidgetGtk::ReleaseMouseCapture() { | 925 void NativeWidgetGtk::ReleaseMouseCapture() { |
931 if (HasMouseCapture()) | 926 if (HasMouseCapture()) |
932 gtk_grab_remove(window_contents_); | 927 gtk_grab_remove(window_contents_); |
933 if (has_mouse_grab_) { | 928 if (has_mouse_grab_) { |
934 has_mouse_grab_ = false; | 929 has_mouse_grab_ = false; |
935 gdk_pointer_ungrab(GDK_CURRENT_TIME); | 930 gdk_pointer_ungrab(GDK_CURRENT_TIME); |
936 gdk_keyboard_ungrab(GDK_CURRENT_TIME); | 931 gdk_keyboard_ungrab(GDK_CURRENT_TIME); |
937 #if defined(HAVE_XINPUT2) && defined(TOUCH_UI) | 932 #if defined(TOUCH_UI) |
938 TouchFactory::GetInstance()->UngrabTouchDevices( | 933 TouchFactory::GetInstance()->UngrabTouchDevices( |
939 GDK_WINDOW_XDISPLAY(window_contents()->window)); | 934 GDK_WINDOW_XDISPLAY(window_contents()->window)); |
940 #endif | 935 #endif |
941 delegate_->OnMouseCaptureLost(); | 936 delegate_->OnMouseCaptureLost(); |
942 } | 937 } |
943 } | 938 } |
944 | 939 |
945 bool NativeWidgetGtk::HasMouseCapture() const { | 940 bool NativeWidgetGtk::HasMouseCapture() const { |
946 return has_mouse_grab_; | 941 return has_mouse_grab_; |
947 } | 942 } |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 // 2) widget_ is not drawable (mapped and visible) | 1295 // 2) widget_ is not drawable (mapped and visible) |
1301 // 3) If it's never painted before. The first expose event will | 1296 // 3) If it's never painted before. The first expose event will |
1302 // paint the area that has to be painted. | 1297 // paint the area that has to be painted. |
1303 if (widget_ && GTK_WIDGET_DRAWABLE(widget_) && painted_) { | 1298 if (widget_ && GTK_WIDGET_DRAWABLE(widget_) && painted_) { |
1304 gtk_widget_queue_draw_area(widget_, rect.x(), rect.y(), rect.width(), | 1299 gtk_widget_queue_draw_area(widget_, rect.x(), rect.y(), rect.width(), |
1305 rect.height()); | 1300 rect.height()); |
1306 } | 1301 } |
1307 } | 1302 } |
1308 | 1303 |
1309 void NativeWidgetGtk::SetCursor(gfx::NativeCursor cursor) { | 1304 void NativeWidgetGtk::SetCursor(gfx::NativeCursor cursor) { |
1310 #if defined(TOUCH_UI) && defined(HAVE_XINPUT2) | 1305 #if defined(TOUCH_UI) |
1311 if (TouchFactory::GetInstance()->keep_mouse_cursor()) | 1306 if (TouchFactory::GetInstance()->keep_mouse_cursor()) |
1312 cursor = gfx::GetCursor(GDK_ARROW); | 1307 cursor = gfx::GetCursor(GDK_ARROW); |
1313 else if (!TouchFactory::GetInstance()->is_cursor_visible()) | 1308 else if (!TouchFactory::GetInstance()->is_cursor_visible()) |
1314 cursor = gfx::GetCursor(GDK_BLANK_CURSOR); | 1309 cursor = gfx::GetCursor(GDK_BLANK_CURSOR); |
1315 #endif | 1310 #endif |
1316 // |window_contents_| is placed on top of |widget_|. So the cursor needs to be | 1311 // |window_contents_| is placed on top of |widget_|. So the cursor needs to be |
1317 // set on |window_contents_| instead of |widget_|. | 1312 // set on |window_contents_| instead of |widget_|. |
1318 if (window_contents_) | 1313 if (window_contents_) |
1319 gdk_window_set_cursor(window_contents_->window, cursor); | 1314 gdk_window_set_cursor(window_contents_->window, cursor); |
1320 } | 1315 } |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2231 button_pressed = event->type == GDK_BUTTON_PRESS || | 2226 button_pressed = event->type == GDK_BUTTON_PRESS || |
2232 event->type == GDK_2BUTTON_PRESS || | 2227 event->type == GDK_2BUTTON_PRESS || |
2233 event->type == GDK_3BUTTON_PRESS; | 2228 event->type == GDK_3BUTTON_PRESS; |
2234 gdk_event_free(event); | 2229 gdk_event_free(event); |
2235 } | 2230 } |
2236 return button_pressed; | 2231 return button_pressed; |
2237 } | 2232 } |
2238 | 2233 |
2239 } // namespace internal | 2234 } // namespace internal |
2240 } // namespace views | 2235 } // namespace views |
OLD | NEW |