| 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 "ui/views/widget/native_widget_gtk.h" | 5 #include "ui/views/widget/native_widget_gtk.h" |
| 6 | 6 |
| 7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 #include <X11/extensions/shape.h> | 9 #include <X11/extensions/shape.h> |
| 10 #include <gdk/gdk.h> | 10 #include <gdk/gdk.h> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "ui/gfx/screen.h" | 35 #include "ui/gfx/screen.h" |
| 36 #include "ui/views/bubble/bubble_delegate.h" | 36 #include "ui/views/bubble/bubble_delegate.h" |
| 37 #include "ui/views/focus/view_storage.h" | 37 #include "ui/views/focus/view_storage.h" |
| 38 #include "ui/views/ime/input_method_gtk.h" | 38 #include "ui/views/ime/input_method_gtk.h" |
| 39 #include "views/controls/textfield/native_textfield_views.h" | 39 #include "views/controls/textfield/native_textfield_views.h" |
| 40 #include "views/views_delegate.h" | 40 #include "views/views_delegate.h" |
| 41 #include "ui/views/widget/drop_target_gtk.h" | 41 #include "ui/views/widget/drop_target_gtk.h" |
| 42 #include "ui/views/widget/gtk_views_fixed.h" | 42 #include "ui/views/widget/gtk_views_fixed.h" |
| 43 #include "ui/views/widget/gtk_views_window.h" | 43 #include "ui/views/widget/gtk_views_window.h" |
| 44 #include "ui/views/widget/root_view.h" | 44 #include "ui/views/widget/root_view.h" |
| 45 #include "ui/views/widget/tooltip_manager_gtk.h" |
| 45 #include "ui/views/widget/widget_delegate.h" | 46 #include "ui/views/widget/widget_delegate.h" |
| 46 | 47 |
| 47 #if defined(TOUCH_UI) | |
| 48 #include "ui/base/touch/touch_factory.h" | |
| 49 #include "ui/views/widget/tooltip_manager_views.h" | |
| 50 #else | |
| 51 #include "ui/views/widget/tooltip_manager_gtk.h" | |
| 52 #endif | |
| 53 | |
| 54 #if defined(HAVE_IBUS) | 48 #if defined(HAVE_IBUS) |
| 55 #include "ui/views/ime/input_method_ibus.h" | 49 #include "ui/views/ime/input_method_ibus.h" |
| 56 #endif | 50 #endif |
| 57 | 51 |
| 58 using ui::OSExchangeData; | 52 using ui::OSExchangeData; |
| 59 using ui::OSExchangeDataProviderGtk; | 53 using ui::OSExchangeDataProviderGtk; |
| 60 using ui::ActiveWindowWatcherX; | 54 using ui::ActiveWindowWatcherX; |
| 61 | 55 |
| 62 namespace views { | 56 namespace views { |
| 63 | 57 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // have no way to tell the difference between a normal drag leave and a drop. | 250 // have no way to tell the difference between a normal drag leave and a drop. |
| 257 // To work around that we listen for DROP_START, then ignore the subsequent | 251 // To work around that we listen for DROP_START, then ignore the subsequent |
| 258 // drag-leave that GTK generates. | 252 // drag-leave that GTK generates. |
| 259 class NativeWidgetGtk::DropObserver : public MessageLoopForUI::Observer { | 253 class NativeWidgetGtk::DropObserver : public MessageLoopForUI::Observer { |
| 260 public: | 254 public: |
| 261 DropObserver() {} | 255 DropObserver() {} |
| 262 | 256 |
| 263 static DropObserver* GetInstance() { | 257 static DropObserver* GetInstance() { |
| 264 return Singleton<DropObserver>::get(); | 258 return Singleton<DropObserver>::get(); |
| 265 } | 259 } |
| 266 #if defined(TOUCH_UI) | |
| 267 virtual base::EventStatus WillProcessEvent( | |
| 268 const base::NativeEvent& event) OVERRIDE { | |
| 269 return base::EVENT_CONTINUE; | |
| 270 } | |
| 271 | 260 |
| 272 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { | |
| 273 } | |
| 274 #else | |
| 275 virtual void WillProcessEvent(GdkEvent* event) { | 261 virtual void WillProcessEvent(GdkEvent* event) { |
| 276 if (event->type == GDK_DROP_START) { | 262 if (event->type == GDK_DROP_START) { |
| 277 NativeWidgetGtk* widget = GetNativeWidgetGtkForEvent(event); | 263 NativeWidgetGtk* widget = GetNativeWidgetGtkForEvent(event); |
| 278 if (widget) | 264 if (widget) |
| 279 widget->ignore_drag_leave_ = true; | 265 widget->ignore_drag_leave_ = true; |
| 280 } | 266 } |
| 281 } | 267 } |
| 282 | 268 |
| 283 virtual void DidProcessEvent(GdkEvent* event) { | 269 virtual void DidProcessEvent(GdkEvent* event) { |
| 284 } | 270 } |
| 285 #endif | |
| 286 | 271 |
| 287 private: | 272 private: |
| 288 NativeWidgetGtk* GetNativeWidgetGtkForEvent(GdkEvent* event) { | 273 NativeWidgetGtk* GetNativeWidgetGtkForEvent(GdkEvent* event) { |
| 289 GtkWidget* gtk_widget = gtk_get_event_widget(event); | 274 GtkWidget* gtk_widget = gtk_get_event_widget(event); |
| 290 if (!gtk_widget) | 275 if (!gtk_widget) |
| 291 return NULL; | 276 return NULL; |
| 292 | 277 |
| 293 return static_cast<NativeWidgetGtk*>( | 278 return static_cast<NativeWidgetGtk*>( |
| 294 internal::NativeWidgetPrivate::GetNativeWidgetForNativeView( | 279 internal::NativeWidgetPrivate::GetNativeWidgetForNativeView( |
| 295 gtk_widget)); | 280 gtk_widget)); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 always_on_top_(false), | 368 always_on_top_(false), |
| 384 is_double_buffered_(false), | 369 is_double_buffered_(false), |
| 385 should_handle_menu_key_release_(false), | 370 should_handle_menu_key_release_(false), |
| 386 dragged_view_(NULL), | 371 dragged_view_(NULL), |
| 387 painted_(false), | 372 painted_(false), |
| 388 has_pointer_grab_(false), | 373 has_pointer_grab_(false), |
| 389 has_keyboard_grab_(false), | 374 has_keyboard_grab_(false), |
| 390 grab_notify_signal_id_(0), | 375 grab_notify_signal_id_(0), |
| 391 is_menu_(false), | 376 is_menu_(false), |
| 392 signal_registrar_(new ui::GtkSignalRegistrar) { | 377 signal_registrar_(new ui::GtkSignalRegistrar) { |
| 393 #if defined(TOUCH_UI) | |
| 394 // Make sure the touch factory is initialized so that it can setup XInput2 for | |
| 395 // the widget. | |
| 396 ui::TouchFactory::GetInstance(); | |
| 397 #endif | |
| 398 static bool installed_message_loop_observer = false; | 378 static bool installed_message_loop_observer = false; |
| 399 if (!installed_message_loop_observer) { | 379 if (!installed_message_loop_observer) { |
| 400 installed_message_loop_observer = true; | 380 installed_message_loop_observer = true; |
| 401 MessageLoopForUI* loop = MessageLoopForUI::current(); | 381 MessageLoopForUI* loop = MessageLoopForUI::current(); |
| 402 if (loop) | 382 if (loop) |
| 403 loop->AddObserver(DropObserver::GetInstance()); | 383 loop->AddObserver(DropObserver::GetInstance()); |
| 404 } | 384 } |
| 405 } | 385 } |
| 406 | 386 |
| 407 NativeWidgetGtk::~NativeWidgetGtk() { | 387 NativeWidgetGtk::~NativeWidgetGtk() { |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 signal_registrar_->Connect(window_contents_, "drag_end", | 776 signal_registrar_->Connect(window_contents_, "drag_end", |
| 797 G_CALLBACK(&OnDragEndThunk), this); | 777 G_CALLBACK(&OnDragEndThunk), this); |
| 798 signal_registrar_->Connect(window_contents_, "drag_failed", | 778 signal_registrar_->Connect(window_contents_, "drag_failed", |
| 799 G_CALLBACK(&OnDragFailedThunk), this); | 779 G_CALLBACK(&OnDragFailedThunk), this); |
| 800 signal_registrar_->Connect(G_OBJECT(widget_), "window-state-event", | 780 signal_registrar_->Connect(G_OBJECT(widget_), "window-state-event", |
| 801 G_CALLBACK(&OnWindowStateEventThunk), this); | 781 G_CALLBACK(&OnWindowStateEventThunk), this); |
| 802 | 782 |
| 803 ui::GObjectDestructorFILO::GetInstance()->Connect( | 783 ui::GObjectDestructorFILO::GetInstance()->Connect( |
| 804 G_OBJECT(widget_), &OnDestroyedThunk, this); | 784 G_OBJECT(widget_), &OnDestroyedThunk, this); |
| 805 | 785 |
| 806 #if defined(TOUCH_UI) | |
| 807 if (params.type != Widget::InitParams::TYPE_TOOLTIP) { | |
| 808 views::TooltipManagerViews* manager = new views::TooltipManagerViews( | |
| 809 static_cast<internal::RootView*>(GetWidget()->GetRootView())); | |
| 810 tooltip_manager_.reset(manager); | |
| 811 } | |
| 812 #else | |
| 813 tooltip_manager_.reset(new TooltipManagerGtk(this)); | 786 tooltip_manager_.reset(new TooltipManagerGtk(this)); |
| 814 #endif | |
| 815 | 787 |
| 816 // Register for tooltips. | 788 // Register for tooltips. |
| 817 g_object_set(G_OBJECT(window_contents_), "has-tooltip", TRUE, NULL); | 789 g_object_set(G_OBJECT(window_contents_), "has-tooltip", TRUE, NULL); |
| 818 signal_registrar_->Connect(window_contents_, "query_tooltip", | 790 signal_registrar_->Connect(window_contents_, "query_tooltip", |
| 819 G_CALLBACK(&OnQueryTooltipThunk), this); | 791 G_CALLBACK(&OnQueryTooltipThunk), this); |
| 820 | 792 |
| 821 if (child_) { | 793 if (child_) { |
| 822 if (modified_params.parent) | 794 if (modified_params.parent) |
| 823 SetBounds(params.bounds); | 795 SetBounds(params.bounds); |
| 824 } else { | 796 } else { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 GdkGrabStatus pointer_grab_status = | 916 GdkGrabStatus pointer_grab_status = |
| 945 gdk_pointer_grab(window_contents()->window, FALSE, | 917 gdk_pointer_grab(window_contents()->window, FALSE, |
| 946 static_cast<GdkEventMask>( | 918 static_cast<GdkEventMask>( |
| 947 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | | 919 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | |
| 948 GDK_POINTER_MOTION_MASK), | 920 GDK_POINTER_MOTION_MASK), |
| 949 NULL, NULL, GDK_CURRENT_TIME); | 921 NULL, NULL, GDK_CURRENT_TIME); |
| 950 // NOTE: technically grab may fail. We may want to try and continue on in | 922 // NOTE: technically grab may fail. We may want to try and continue on in |
| 951 // that case. | 923 // that case. |
| 952 DCHECK_EQ(GDK_GRAB_SUCCESS, pointer_grab_status); | 924 DCHECK_EQ(GDK_GRAB_SUCCESS, pointer_grab_status); |
| 953 has_pointer_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS; | 925 has_pointer_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS; |
| 954 | |
| 955 #if defined(TOUCH_UI) | |
| 956 ::Window window = GDK_WINDOW_XID(window_contents()->window); | |
| 957 Display* display = GDK_WINDOW_XDISPLAY(window_contents()->window); | |
| 958 bool xi2grab = | |
| 959 ui::TouchFactory::GetInstance()->GrabTouchDevices(display, window); | |
| 960 // xi2grab should always succeed if has_pointer_grab_ succeeded. | |
| 961 DCHECK(xi2grab); | |
| 962 has_pointer_grab_ = has_pointer_grab_ && xi2grab; | |
| 963 #endif | |
| 964 } | 926 } |
| 965 } | 927 } |
| 966 | 928 |
| 967 void NativeWidgetGtk::ReleaseMouseCapture() { | 929 void NativeWidgetGtk::ReleaseMouseCapture() { |
| 968 bool delegate_lost_capture = HasMouseCapture(); | 930 bool delegate_lost_capture = HasMouseCapture(); |
| 969 if (GTK_WIDGET_HAS_GRAB(window_contents_)) | 931 if (GTK_WIDGET_HAS_GRAB(window_contents_)) |
| 970 gtk_grab_remove(window_contents_); | 932 gtk_grab_remove(window_contents_); |
| 971 if (grab_notify_signal_id_) { | 933 if (grab_notify_signal_id_) { |
| 972 g_signal_handler_disconnect(window_contents_, grab_notify_signal_id_); | 934 g_signal_handler_disconnect(window_contents_, grab_notify_signal_id_); |
| 973 grab_notify_signal_id_ = 0; | 935 grab_notify_signal_id_ = 0; |
| 974 } | 936 } |
| 975 if (has_pointer_grab_) { | 937 if (has_pointer_grab_) { |
| 976 has_pointer_grab_ = false; | 938 has_pointer_grab_ = false; |
| 977 gdk_pointer_ungrab(GDK_CURRENT_TIME); | 939 gdk_pointer_ungrab(GDK_CURRENT_TIME); |
| 978 #if defined(TOUCH_UI) | |
| 979 ui::TouchFactory::GetInstance()->UngrabTouchDevices( | |
| 980 GDK_WINDOW_XDISPLAY(window_contents()->window)); | |
| 981 #endif | |
| 982 } | 940 } |
| 983 if (delegate_lost_capture) | 941 if (delegate_lost_capture) |
| 984 delegate_->OnMouseCaptureLost(); | 942 delegate_->OnMouseCaptureLost(); |
| 985 } | 943 } |
| 986 | 944 |
| 987 bool NativeWidgetGtk::HasMouseCapture() const { | 945 bool NativeWidgetGtk::HasMouseCapture() const { |
| 988 return GTK_WIDGET_HAS_GRAB(window_contents_) || has_pointer_grab_; | 946 return GTK_WIDGET_HAS_GRAB(window_contents_) || has_pointer_grab_; |
| 989 } | 947 } |
| 990 | 948 |
| 991 InputMethod* NativeWidgetGtk::CreateInputMethod() { | 949 InputMethod* NativeWidgetGtk::CreateInputMethod() { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 } | 1187 } |
| 1230 | 1188 |
| 1231 void NativeWidgetGtk::SetAlwaysOnTop(bool on_top) { | 1189 void NativeWidgetGtk::SetAlwaysOnTop(bool on_top) { |
| 1232 DCHECK(!child_); | 1190 DCHECK(!child_); |
| 1233 always_on_top_ = on_top; | 1191 always_on_top_ = on_top; |
| 1234 if (widget_) | 1192 if (widget_) |
| 1235 gtk_window_set_keep_above(GTK_WINDOW(widget_), on_top); | 1193 gtk_window_set_keep_above(GTK_WINDOW(widget_), on_top); |
| 1236 } | 1194 } |
| 1237 | 1195 |
| 1238 void NativeWidgetGtk::Maximize() { | 1196 void NativeWidgetGtk::Maximize() { |
| 1239 #if defined(TOUCH_UI) | |
| 1240 // There may not be a window manager. So maximize ourselves: move to the | |
| 1241 // top-left corner and resize to the entire bounds of the screen. | |
| 1242 gfx::Rect screen = gfx::Screen::GetMonitorAreaNearestWindow(GetNativeView()); | |
| 1243 gtk_window_move(GTK_WINDOW(GetNativeWindow()), screen.x(), screen.y()); | |
| 1244 // TODO(backer): Remove this driver bug workaround once it is fixed. | |
| 1245 gtk_window_resize(GTK_WINDOW(GetNativeWindow()), | |
| 1246 screen.width() - 1, screen.height()); | |
| 1247 #else | |
| 1248 gtk_window_maximize(GetNativeWindow()); | 1197 gtk_window_maximize(GetNativeWindow()); |
| 1249 #endif | |
| 1250 } | 1198 } |
| 1251 | 1199 |
| 1252 void NativeWidgetGtk::Minimize() { | 1200 void NativeWidgetGtk::Minimize() { |
| 1253 gtk_window_iconify(GetNativeWindow()); | 1201 gtk_window_iconify(GetNativeWindow()); |
| 1254 } | 1202 } |
| 1255 | 1203 |
| 1256 bool NativeWidgetGtk::IsMaximized() const { | 1204 bool NativeWidgetGtk::IsMaximized() const { |
| 1257 return window_state_ & GDK_WINDOW_STATE_MAXIMIZED; | 1205 return window_state_ & GDK_WINDOW_STATE_MAXIMIZED; |
| 1258 } | 1206 } |
| 1259 | 1207 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 // 2) widget_ is not drawable (mapped and visible) | 1261 // 2) widget_ is not drawable (mapped and visible) |
| 1314 // 3) If it's never painted before. The first expose event will | 1262 // 3) If it's never painted before. The first expose event will |
| 1315 // paint the area that has to be painted. | 1263 // paint the area that has to be painted. |
| 1316 if (widget_ && GTK_WIDGET_DRAWABLE(widget_) && painted_) { | 1264 if (widget_ && GTK_WIDGET_DRAWABLE(widget_) && painted_) { |
| 1317 gtk_widget_queue_draw_area(widget_, rect.x(), rect.y(), rect.width(), | 1265 gtk_widget_queue_draw_area(widget_, rect.x(), rect.y(), rect.width(), |
| 1318 rect.height()); | 1266 rect.height()); |
| 1319 } | 1267 } |
| 1320 } | 1268 } |
| 1321 | 1269 |
| 1322 void NativeWidgetGtk::SetCursor(gfx::NativeCursor cursor) { | 1270 void NativeWidgetGtk::SetCursor(gfx::NativeCursor cursor) { |
| 1323 #if defined(TOUCH_UI) | |
| 1324 if (!ui::TouchFactory::GetInstance()->is_cursor_visible()) | |
| 1325 cursor = gfx::GetCursor(GDK_BLANK_CURSOR); | |
| 1326 #endif | |
| 1327 // |window_contents_| is placed on top of |widget_|. So the cursor needs to be | 1271 // |window_contents_| is placed on top of |widget_|. So the cursor needs to be |
| 1328 // set on |window_contents_| instead of |widget_|. | 1272 // set on |window_contents_| instead of |widget_|. |
| 1329 if (window_contents_) | 1273 if (window_contents_) |
| 1330 gdk_window_set_cursor(window_contents_->window, cursor); | 1274 gdk_window_set_cursor(window_contents_->window, cursor); |
| 1331 } | 1275 } |
| 1332 | 1276 |
| 1333 void NativeWidgetGtk::ClearNativeFocus() { | 1277 void NativeWidgetGtk::ClearNativeFocus() { |
| 1334 DCHECK(!child_); | 1278 DCHECK(!child_); |
| 1335 if (!GetNativeView()) { | 1279 if (!GetNativeView()) { |
| 1336 NOTREACHED(); | 1280 NOTREACHED(); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 | 1653 |
| 1710 // Returns true to prevent GtkWindow's default key event handler. | 1654 // Returns true to prevent GtkWindow's default key event handler. |
| 1711 return true; | 1655 return true; |
| 1712 } | 1656 } |
| 1713 | 1657 |
| 1714 gboolean NativeWidgetGtk::OnQueryTooltip(GtkWidget* widget, | 1658 gboolean NativeWidgetGtk::OnQueryTooltip(GtkWidget* widget, |
| 1715 gint x, | 1659 gint x, |
| 1716 gint y, | 1660 gint y, |
| 1717 gboolean keyboard_mode, | 1661 gboolean keyboard_mode, |
| 1718 GtkTooltip* tooltip) { | 1662 GtkTooltip* tooltip) { |
| 1719 #if defined(TOUCH_UI) | |
| 1720 return false; // Tell GTK not to draw tooltips as we draw tooltips in views | |
| 1721 #else | |
| 1722 return static_cast<TooltipManagerGtk*>(tooltip_manager_.get())-> | 1663 return static_cast<TooltipManagerGtk*>(tooltip_manager_.get())-> |
| 1723 ShowTooltip(x, y, keyboard_mode, tooltip); | 1664 ShowTooltip(x, y, keyboard_mode, tooltip); |
| 1724 #endif | |
| 1725 } | 1665 } |
| 1726 | 1666 |
| 1727 gboolean NativeWidgetGtk::OnVisibilityNotify(GtkWidget* widget, | 1667 gboolean NativeWidgetGtk::OnVisibilityNotify(GtkWidget* widget, |
| 1728 GdkEventVisibility* event) { | 1668 GdkEventVisibility* event) { |
| 1729 return false; | 1669 return false; |
| 1730 } | 1670 } |
| 1731 | 1671 |
| 1732 gboolean NativeWidgetGtk::OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event) { | 1672 gboolean NativeWidgetGtk::OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event) { |
| 1733 if (!has_pointer_grab_ && !has_keyboard_grab_) { | 1673 if (!has_pointer_grab_ && !has_keyboard_grab_) { |
| 1734 // We don't have any grabs; don't attempt to do anything. | 1674 // We don't have any grabs; don't attempt to do anything. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1749 // Mouse grab was broke. | 1689 // Mouse grab was broke. |
| 1750 has_pointer_grab_ = false; | 1690 has_pointer_grab_ = false; |
| 1751 if (has_keyboard_grab_) { | 1691 if (has_keyboard_grab_) { |
| 1752 has_keyboard_grab_ = false; | 1692 has_keyboard_grab_ = false; |
| 1753 gdk_keyboard_ungrab(GDK_CURRENT_TIME); | 1693 gdk_keyboard_ungrab(GDK_CURRENT_TIME); |
| 1754 } | 1694 } |
| 1755 delegate_->OnMouseCaptureLost(); | 1695 delegate_->OnMouseCaptureLost(); |
| 1756 } | 1696 } |
| 1757 ReleaseMouseCapture(); | 1697 ReleaseMouseCapture(); |
| 1758 | 1698 |
| 1759 #if defined(TOUCH_UI) | |
| 1760 ui::TouchFactory::GetInstance()->UngrabTouchDevices( | |
| 1761 GDK_WINDOW_XDISPLAY(window_contents()->window)); | |
| 1762 #endif | |
| 1763 return false; // To let other widgets get the event. | 1699 return false; // To let other widgets get the event. |
| 1764 } | 1700 } |
| 1765 | 1701 |
| 1766 void NativeWidgetGtk::OnGrabNotify(GtkWidget* widget, gboolean was_grabbed) { | 1702 void NativeWidgetGtk::OnGrabNotify(GtkWidget* widget, gboolean was_grabbed) { |
| 1767 // Sent when gtk_grab_add changes. | 1703 // Sent when gtk_grab_add changes. |
| 1768 if (!window_contents_) | 1704 if (!window_contents_) |
| 1769 return; // Grab broke after window destroyed, don't try processing it. | 1705 return; // Grab broke after window destroyed, don't try processing it. |
| 1770 if (!was_grabbed) // Indicates we've been shadowed (lost grab). | 1706 if (!was_grabbed) // Indicates we've been shadowed (lost grab). |
| 1771 HandleGtkGrabBroke(); | 1707 HandleGtkGrabBroke(); |
| 1772 } | 1708 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1790 delegate_->OnNativeWidgetDestroyed(); | 1726 delegate_->OnNativeWidgetDestroyed(); |
| 1791 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 1727 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 1792 delete this; | 1728 delete this; |
| 1793 } | 1729 } |
| 1794 | 1730 |
| 1795 void NativeWidgetGtk::OnShow(GtkWidget* widget) { | 1731 void NativeWidgetGtk::OnShow(GtkWidget* widget) { |
| 1796 delegate_->OnNativeWidgetVisibilityChanged(true); | 1732 delegate_->OnNativeWidgetVisibilityChanged(true); |
| 1797 } | 1733 } |
| 1798 | 1734 |
| 1799 void NativeWidgetGtk::OnMap(GtkWidget* widget) { | 1735 void NativeWidgetGtk::OnMap(GtkWidget* widget) { |
| 1800 #if defined(TOUCH_UI) | |
| 1801 // Force an expose event to trigger OnPaint for touch. This is | |
| 1802 // a workaround for a bug that X Expose event does not trigger | |
| 1803 // Gdk's expose signal. This happens when you try to open views menu | |
| 1804 // while a virtual keyboard gets kicked in or out. This seems to be | |
| 1805 // a bug in message_pump_x.cc as we do get X Expose event but | |
| 1806 // it doesn't trigger gtk's expose signal. We're not going to fix this | |
| 1807 // as we're removing gtk and migrating to new compositor. | |
| 1808 gdk_window_process_all_updates(); | |
| 1809 #endif | |
| 1810 } | 1736 } |
| 1811 | 1737 |
| 1812 void NativeWidgetGtk::OnHide(GtkWidget* widget) { | 1738 void NativeWidgetGtk::OnHide(GtkWidget* widget) { |
| 1813 delegate_->OnNativeWidgetVisibilityChanged(false); | 1739 delegate_->OnNativeWidgetVisibilityChanged(false); |
| 1814 } | 1740 } |
| 1815 | 1741 |
| 1816 gboolean NativeWidgetGtk::OnWindowStateEvent(GtkWidget* widget, | 1742 gboolean NativeWidgetGtk::OnWindowStateEvent(GtkWidget* widget, |
| 1817 GdkEventWindowState* event) { | 1743 GdkEventWindowState* event) { |
| 1818 if (GetWidget()->non_client_view() && | 1744 if (GetWidget()->non_client_view() && |
| 1819 !(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN)) { | 1745 !(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN)) { |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2294 button_pressed = event->type == GDK_BUTTON_PRESS || | 2220 button_pressed = event->type == GDK_BUTTON_PRESS || |
| 2295 event->type == GDK_2BUTTON_PRESS || | 2221 event->type == GDK_2BUTTON_PRESS || |
| 2296 event->type == GDK_3BUTTON_PRESS; | 2222 event->type == GDK_3BUTTON_PRESS; |
| 2297 gdk_event_free(event); | 2223 gdk_event_free(event); |
| 2298 } | 2224 } |
| 2299 return button_pressed; | 2225 return button_pressed; |
| 2300 } | 2226 } |
| 2301 | 2227 |
| 2302 } // namespace internal | 2228 } // namespace internal |
| 2303 } // namespace views | 2229 } // namespace views |
| OLD | NEW |