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/widget_gtk.h" | 5 #include "views/widget/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 | 10 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 | 258 |
259 //////////////////////////////////////////////////////////////////////////////// | 259 //////////////////////////////////////////////////////////////////////////////// |
260 // WidgetGtk, public: | 260 // WidgetGtk, public: |
261 | 261 |
262 WidgetGtk::WidgetGtk(Type type) | 262 WidgetGtk::WidgetGtk(Type type) |
263 : is_window_(false), | 263 : is_window_(false), |
264 ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)), | 264 ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)), |
265 type_(type), | 265 type_(type), |
266 widget_(NULL), | 266 widget_(NULL), |
267 window_contents_(NULL), | 267 window_contents_(NULL), |
268 is_mouse_down_(false), | |
269 last_mouse_event_was_move_(false), | |
270 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), | 268 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), |
271 delete_on_destroy_(true), | 269 delete_on_destroy_(true), |
272 transparent_(false), | 270 transparent_(false), |
273 ignore_events_(false), | 271 ignore_events_(false), |
274 ignore_drag_leave_(false), | 272 ignore_drag_leave_(false), |
275 opacity_(255), | 273 opacity_(255), |
276 drag_data_(NULL), | 274 drag_data_(NULL), |
277 is_active_(false), | 275 is_active_(false), |
278 transient_to_parent_(false), | 276 transient_to_parent_(false), |
279 got_initial_focus_in_(false), | 277 got_initial_focus_in_(false), |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
681 // Trigger VKEY_MENU when only this key is pressed and released, and both | 679 // Trigger VKEY_MENU when only this key is pressed and released, and both |
682 // press and release events are not handled by others. | 680 // press and release events are not handled by others. |
683 Accelerator accelerator(ui::VKEY_MENU, false, false, false); | 681 Accelerator accelerator(ui::VKEY_MENU, false, false, false); |
684 handled = GetFocusManager()->ProcessAccelerator(accelerator); | 682 handled = GetFocusManager()->ProcessAccelerator(accelerator); |
685 } | 683 } |
686 | 684 |
687 return handled; | 685 return handled; |
688 } | 686 } |
689 | 687 |
690 // static | 688 // static |
691 int WidgetGtk::GetFlagsForEventButton(const GdkEventButton& event) { | |
692 int flags = Event::GetFlagsFromGdkState(event.state); | |
693 switch (event.button) { | |
694 case 1: | |
695 flags |= ui::EF_LEFT_BUTTON_DOWN; | |
696 break; | |
697 case 2: | |
698 flags |= ui::EF_MIDDLE_BUTTON_DOWN; | |
699 break; | |
700 case 3: | |
701 flags |= ui::EF_RIGHT_BUTTON_DOWN; | |
702 break; | |
703 default: | |
704 // We only deal with 1-3. | |
705 break; | |
706 } | |
707 if (event.type == GDK_2BUTTON_PRESS) | |
708 flags |= ui::EF_IS_DOUBLE_CLICK; | |
709 return flags; | |
710 } | |
711 | |
712 // static | |
713 void WidgetGtk::EnableDebugPaint() { | 689 void WidgetGtk::EnableDebugPaint() { |
714 debug_paint_enabled_ = true; | 690 debug_paint_enabled_ = true; |
715 } | 691 } |
716 | 692 |
717 //////////////////////////////////////////////////////////////////////////////// | 693 //////////////////////////////////////////////////////////////////////////////// |
718 // WidgetGtk, NativeWidget implementation: | 694 // WidgetGtk, NativeWidget implementation: |
719 | 695 |
720 Widget* WidgetGtk::GetWidget() { | 696 Widget* WidgetGtk::GetWidget() { |
721 return this; | 697 return this; |
722 } | 698 } |
723 | 699 |
724 void WidgetGtk::SetNativeWindowProperty(const char* name, void* value) { | 700 void WidgetGtk::SetNativeWindowProperty(const char* name, void* value) { |
725 g_object_set_data(G_OBJECT(widget_), name, value); | 701 g_object_set_data(G_OBJECT(widget_), name, value); |
726 } | 702 } |
727 | 703 |
728 void* WidgetGtk::GetNativeWindowProperty(const char* name) { | 704 void* WidgetGtk::GetNativeWindowProperty(const char* name) { |
729 return g_object_get_data(G_OBJECT(widget_), name); | 705 return g_object_get_data(G_OBJECT(widget_), name); |
730 } | 706 } |
731 | 707 |
732 TooltipManager* WidgetGtk::GetTooltipManager() const { | 708 TooltipManager* WidgetGtk::GetTooltipManager() const { |
733 return tooltip_manager_.get(); | 709 return tooltip_manager_.get(); |
734 } | 710 } |
735 | 711 |
736 bool WidgetGtk::IsScreenReaderActive() const { | 712 bool WidgetGtk::IsScreenReaderActive() const { |
737 return false; | 713 return false; |
738 } | 714 } |
739 | 715 |
740 void WidgetGtk::SetNativeCapture() { | 716 void WidgetGtk::SetMouseCapture() { |
741 DCHECK(!HasNativeCapture()); | 717 DCHECK(!HasMouseCapture()); |
742 gtk_grab_add(window_contents_); | 718 gtk_grab_add(window_contents_); |
743 } | 719 } |
744 | 720 |
745 void WidgetGtk::ReleaseNativeCapture() { | 721 void WidgetGtk::ReleaseMouseCapture() { |
746 if (HasNativeCapture()) | 722 if (HasMouseCapture()) |
747 gtk_grab_remove(window_contents_); | 723 gtk_grab_remove(window_contents_); |
748 } | 724 } |
749 | 725 |
750 bool WidgetGtk::HasNativeCapture() const { | 726 bool WidgetGtk::HasMouseCapture() const { |
751 // TODO(beng): Should be able to use gtk_widget_has_grab() here but the | 727 // TODO(beng): Should be able to use gtk_widget_has_grab() here but the |
752 // trybots don't have Gtk 2.18. | 728 // trybots don't have Gtk 2.18. |
753 return GTK_WIDGET_HAS_GRAB(window_contents_); | 729 return GTK_WIDGET_HAS_GRAB(window_contents_); |
754 } | 730 } |
755 | 731 |
732 bool WidgetGtk::ShouldReleaseCaptureOnMouseReleased() const { | |
733 return true; | |
734 } | |
735 | |
756 gfx::Rect WidgetGtk::GetWindowScreenBounds() const { | 736 gfx::Rect WidgetGtk::GetWindowScreenBounds() const { |
757 // Client == Window bounds on Gtk. | 737 // Client == Window bounds on Gtk. |
758 return GetClientAreaScreenBounds(); | 738 return GetClientAreaScreenBounds(); |
759 } | 739 } |
760 | 740 |
761 gfx::Rect WidgetGtk::GetClientAreaScreenBounds() const { | 741 gfx::Rect WidgetGtk::GetClientAreaScreenBounds() const { |
762 // Due to timing we can get a request for bounds after Close(). | 742 // Due to timing we can get a request for bounds after Close(). |
763 // TODO(beng): Figure out if this is bogus. | 743 // TODO(beng): Figure out if this is bogus. |
764 if (!widget_) | 744 if (!widget_) |
765 return gfx::Rect(size_); | 745 return gfx::Rect(size_); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1052 GdkDragContext* context, | 1032 GdkDragContext* context, |
1053 gint x, | 1033 gint x, |
1054 gint y, | 1034 gint y, |
1055 guint time) { | 1035 guint time) { |
1056 if (!drop_target_.get()) | 1036 if (!drop_target_.get()) |
1057 drop_target_.reset(new DropTargetGtk(GetRootView(), context)); | 1037 drop_target_.reset(new DropTargetGtk(GetRootView(), context)); |
1058 return drop_target_->OnDragMotion(context, x, y, time); | 1038 return drop_target_->OnDragMotion(context, x, y, time); |
1059 } | 1039 } |
1060 | 1040 |
1061 gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) { | 1041 gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) { |
1062 if (last_mouse_event_was_move_ && last_mouse_move_x_ == event->x_root && | 1042 if (HasMouseCapture() && event->mode == GDK_CROSSING_GRAB) { |
1063 last_mouse_move_y_ == event->y_root) { | |
1064 // Don't generate a mouse event for the same location as the last. | |
1065 return false; | |
1066 } | |
1067 | |
1068 if (HasNativeCapture() && event->mode == GDK_CROSSING_GRAB) { | |
1069 // Doing a grab results an async enter event, regardless of where the mouse | 1043 // Doing a grab results an async enter event, regardless of where the mouse |
1070 // is. We don't want to generate a mouse move in this case. | 1044 // is. We don't want to generate a mouse move in this case. |
1071 return false; | 1045 return false; |
1072 } | 1046 } |
1073 | 1047 |
1074 if (!last_mouse_event_was_move_ && !is_mouse_down_) { | 1048 if (!last_mouse_event_was_move_ && !is_mouse_down_) { |
1075 // When a mouse button is pressed gtk generates a leave, enter, press. | 1049 // When a mouse button is pressed gtk generates a leave, enter, press. |
1076 // RootView expects to get a mouse move before a press, otherwise enter is | 1050 // RootView expects to get a mouse move before a press, otherwise enter is |
1077 // not set. So we generate a move here. | 1051 // not set. So we generate a move here. |
1078 last_mouse_move_x_ = event->x_root; | |
1079 last_mouse_move_y_ = event->y_root; | |
1080 last_mouse_event_was_move_ = true; | |
1081 | |
1082 int x = 0, y = 0; | 1052 int x = 0, y = 0; |
1083 GetContainedWidgetEventCoordinates(event, &x, &y); | 1053 GetContainedWidgetEventCoordinates(event, &x, &y); |
1054 int flags = Event::GetFlagsFromGdkEvent(reinterpret_cast<GdkEvent*>(event)); | |
1084 | 1055 |
1085 // If this event is the result of pressing a button then one of the button | 1056 // If this event is the result of pressing a button then one of the button |
1086 // modifiers is set. Unset it as we're compensating for the leave generated | 1057 // modifiers is set. Unset it as we're compensating for the leave generated |
1087 // when you press a button. | 1058 // when you press a button. |
1088 int flags = (Event::GetFlagsFromGdkState(event->state) & | 1059 flags &= ~(ui::EF_LEFT_BUTTON_DOWN | |
1089 ~(ui::EF_LEFT_BUTTON_DOWN | | 1060 ui::EF_MIDDLE_BUTTON_DOWN | |
1090 ui::EF_MIDDLE_BUTTON_DOWN | | 1061 ui::EF_RIGHT_BUTTON_DOWN); |
1091 ui::EF_RIGHT_BUTTON_DOWN)); | 1062 |
1092 MouseEvent mouse_move(ui::ET_MOUSE_MOVED, x, y, flags); | 1063 MouseEvent mouse_move(ui::ET_MOUSE_MOVED, x, y, flags); |
1093 GetRootView()->OnMouseMoved(mouse_move); | 1064 ProcessMouseMoved(mouse_move); |
1094 } | 1065 } |
1095 | 1066 |
1096 return false; | 1067 return false; |
1097 } | 1068 } |
1098 | 1069 |
1099 gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) { | 1070 gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) { |
1100 last_mouse_event_was_move_ = false; | 1071 last_mouse_event_was_move_ = false; |
1101 if (!HasNativeCapture() && !is_mouse_down_) { | 1072 if (!HasMouseCapture() && !is_mouse_down_) { |
1102 MouseEvent mouse_event(reinterpret_cast<GdkEvent*>(event)); | 1073 MouseEvent mouse_event(reinterpret_cast<GdkEvent*>(event)); |
1103 GetRootView()->OnMouseExited(mouse_event); | 1074 GetRootView()->OnMouseExited(mouse_event); |
1104 } | 1075 } |
1105 return false; | 1076 return false; |
1106 } | 1077 } |
1107 | 1078 |
1108 gboolean WidgetGtk::OnMotionNotify(GtkWidget* widget, GdkEventMotion* event) { | 1079 gboolean WidgetGtk::OnMotionNotify(GtkWidget* widget, GdkEventMotion* event) { |
1109 int x = 0, y = 0; | 1080 int x = 0, y = 0; |
1110 GetContainedWidgetEventCoordinates(event, &x, &y); | 1081 GetContainedWidgetEventCoordinates(event, &x, &y); |
1111 | 1082 int flags = Event::GetFlagsFromGdkEvent(reinterpret_cast<GdkEvent*>(event)); |
1112 if (HasNativeCapture() && is_mouse_down_) { | 1083 MouseEvent mouse_event((HasMouseCapture() && is_mouse_down_) ? |
1113 last_mouse_event_was_move_ = false; | 1084 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED, x, y, flags); |
1114 int flags = Event::GetFlagsFromGdkState(event->state); | 1085 ProcessMouseMoved(mouse_event); |
Ben Goodger (Google)
2011/03/30 23:22:55
Now that you've renamed this method and moved it t
msw
2011/03/31 14:01:18
Done; I'll investigate and document our coordinate
| |
1115 MouseEvent mouse_drag(ui::ET_MOUSE_DRAGGED, x, y, flags); | |
1116 GetRootView()->OnMouseDragged(mouse_drag); | |
1117 return true; | |
1118 } | |
1119 gfx::Point screen_loc(event->x_root, event->y_root); | |
1120 if (last_mouse_event_was_move_ && last_mouse_move_x_ == screen_loc.x() && | |
1121 last_mouse_move_y_ == screen_loc.y()) { | |
1122 // Don't generate a mouse event for the same location as the last. | |
1123 return true; | |
1124 } | |
1125 last_mouse_move_x_ = screen_loc.x(); | |
1126 last_mouse_move_y_ = screen_loc.y(); | |
1127 last_mouse_event_was_move_ = true; | |
1128 int flags = Event::GetFlagsFromGdkState(event->state); | |
1129 MouseEvent mouse_move(ui::ET_MOUSE_MOVED, x, y, flags); | |
1130 GetRootView()->OnMouseMoved(mouse_move); | |
1131 return true; | 1086 return true; |
1132 } | 1087 } |
1133 | 1088 |
1134 gboolean WidgetGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) { | 1089 gboolean WidgetGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) { |
1135 return ProcessMousePressed(event); | 1090 if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) { |
1091 // The sequence for double clicks is press, release, press, 2press, release. | |
1092 // This means that at the time we get the second 'press' we don't know | |
1093 // whether it corresponds to a double click or not. For now we're completely | |
1094 // ignoring the 2press/3press events as they are duplicate. To make this | |
1095 // work right we need to write our own code that detects if the press is a | |
1096 // double/triple. For now we're completely punting, which means we always | |
1097 // get single clicks. | |
1098 // TODO: fix this. | |
1099 return true; | |
1100 } | |
1101 | |
1102 // An event may come from a contained widget which has its own gdk window. | |
1103 // Translate it to the widget's coordinates. | |
1104 int x = 0, y = 0; | |
1105 GetContainedWidgetEventCoordinates(event, &x, &y); | |
1106 int flags = Event::GetFlagsFromGdkEvent(reinterpret_cast<GdkEvent*>(event)); | |
1107 MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, x, y, flags); | |
1108 | |
1109 // Returns true to consume the event when widget is not transparent. | |
1110 return ProcessMousePressed(mouse_pressed) || !transparent_; | |
1136 } | 1111 } |
1137 | 1112 |
1138 gboolean WidgetGtk::OnButtonRelease(GtkWidget* widget, GdkEventButton* event) { | 1113 gboolean WidgetGtk::OnButtonRelease(GtkWidget* widget, GdkEventButton* event) { |
1139 ProcessMouseReleased(event); | 1114 // GTK generates a mouse release at the end of dnd. We need to ignore it. |
1115 if (drag_data_) | |
1116 return true; | |
1117 | |
1118 // An event may come from a contained widget which has its own gdk window. | |
1119 // Translate it to the widget's coordinates. | |
1120 int x = 0, y = 0; | |
1121 GetContainedWidgetEventCoordinates(event, &x, &y); | |
1122 int flags = Event::GetFlagsFromGdkEvent(reinterpret_cast<GdkEvent*>(event)); | |
1123 MouseEvent mouse_up(ui::ET_MOUSE_RELEASED, x, y, flags); | |
1124 ProcessMouseReleased(mouse_up); | |
1140 return true; | 1125 return true; |
1141 } | 1126 } |
1142 | 1127 |
1143 gboolean WidgetGtk::OnScroll(GtkWidget* widget, GdkEventScroll* event) { | 1128 gboolean WidgetGtk::OnScroll(GtkWidget* widget, GdkEventScroll* event) { |
1144 return ProcessScroll(event); | 1129 // An event may come from a contained widget which has its own gdk window. |
1130 // Translate it to the widget's coordinates. | |
1131 int x = 0, y = 0; | |
1132 GetContainedWidgetEventCoordinates(event, &x, &y); | |
1133 GdkEventScroll translated_event = *event; | |
1134 translated_event.x = x; | |
1135 translated_event.y = y; | |
1136 | |
1137 MouseWheelEvent wheel_event(reinterpret_cast<GdkEvent*>(&translated_event)); | |
1138 return GetRootView()->OnMouseWheel(wheel_event); | |
1145 } | 1139 } |
1146 | 1140 |
1147 gboolean WidgetGtk::OnFocusIn(GtkWidget* widget, GdkEventFocus* event) { | 1141 gboolean WidgetGtk::OnFocusIn(GtkWidget* widget, GdkEventFocus* event) { |
1148 if (has_focus_) | 1142 if (has_focus_) |
1149 return false; // This is the second focus-in event in a row, ignore it. | 1143 return false; // This is the second focus-in event in a row, ignore it. |
1150 has_focus_ = true; | 1144 has_focus_ = true; |
1151 | 1145 |
1152 should_handle_menu_key_release_ = false; | 1146 should_handle_menu_key_release_ = false; |
1153 | 1147 |
1154 if (type_ == TYPE_CHILD) | 1148 if (type_ == TYPE_CHILD) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1263 // SchedulePaintInRect calls for the widget will have happened before the | 1257 // SchedulePaintInRect calls for the widget will have happened before the |
1264 // widget was drawable. This means that gtk_widget_queue_draw_area wasn't | 1258 // widget was drawable. This means that gtk_widget_queue_draw_area wasn't |
1265 // called, and so the widget will not get any expose events. Consequently, the | 1259 // called, and so the widget will not get any expose events. Consequently, the |
1266 // widget won't paint itself until something else triggers a paint call. | 1260 // widget won't paint itself until something else triggers a paint call. |
1267 gdk_window_process_updates(widget_->window, true); | 1261 gdk_window_process_updates(widget_->window, true); |
1268 } | 1262 } |
1269 | 1263 |
1270 void WidgetGtk::OnHide(GtkWidget* widget) { | 1264 void WidgetGtk::OnHide(GtkWidget* widget) { |
1271 } | 1265 } |
1272 | 1266 |
1273 bool WidgetGtk::ReleaseCaptureOnMouseReleased() { | |
1274 return true; | |
1275 } | |
1276 | |
1277 void WidgetGtk::HandleXGrabBroke() { | 1267 void WidgetGtk::HandleXGrabBroke() { |
1278 } | 1268 } |
1279 | 1269 |
1280 void WidgetGtk::HandleGtkGrabBroke() { | 1270 void WidgetGtk::HandleGtkGrabBroke() { |
1281 if (is_mouse_down_) | 1271 ProcessMouseCaptureLost(); |
1282 GetRootView()->OnMouseCaptureLost(); | |
1283 is_mouse_down_ = false; | |
1284 } | 1272 } |
1285 | 1273 |
1286 //////////////////////////////////////////////////////////////////////////////// | 1274 //////////////////////////////////////////////////////////////////////////////// |
1287 // WidgetGtk, private: | 1275 // WidgetGtk, private: |
1288 | 1276 |
1289 RootView* WidgetGtk::CreateRootView() { | 1277 RootView* WidgetGtk::CreateRootView() { |
1290 return new RootView(this); | 1278 return new RootView(this); |
1291 } | 1279 } |
1292 | 1280 |
1293 gfx::AcceleratedWidget WidgetGtk::GetAcceleratedWidget() { | 1281 gfx::AcceleratedWidget WidgetGtk::GetAcceleratedWidget() { |
1294 DCHECK(window_contents_ && window_contents_->window); | 1282 DCHECK(window_contents_ && window_contents_->window); |
1295 return GDK_WINDOW_XID(window_contents_->window); | 1283 return GDK_WINDOW_XID(window_contents_->window); |
1296 } | 1284 } |
1297 | 1285 |
1298 gboolean WidgetGtk::OnWindowPaint(GtkWidget* widget, GdkEventExpose* event) { | 1286 gboolean WidgetGtk::OnWindowPaint(GtkWidget* widget, GdkEventExpose* event) { |
1299 // Clear the background to be totally transparent. We don't need to | 1287 // Clear the background to be totally transparent. We don't need to |
1300 // paint the root view here as that is done by OnPaint. | 1288 // paint the root view here as that is done by OnPaint. |
1301 DCHECK(transparent_); | 1289 DCHECK(transparent_); |
1302 DrawTransparentBackground(widget, event); | 1290 DrawTransparentBackground(widget, event); |
1303 return false; | 1291 return false; |
1304 } | 1292 } |
1305 | 1293 |
1306 bool WidgetGtk::ProcessMousePressed(GdkEventButton* event) { | |
1307 if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) { | |
1308 // The sequence for double clicks is press, release, press, 2press, release. | |
1309 // This means that at the time we get the second 'press' we don't know | |
1310 // whether it corresponds to a double click or not. For now we're completely | |
1311 // ignoring the 2press/3press events as they are duplicate. To make this | |
1312 // work right we need to write our own code that detects if the press is a | |
1313 // double/triple. For now we're completely punting, which means we always | |
1314 // get single clicks. | |
1315 // TODO: fix this. | |
1316 return true; | |
1317 } | |
1318 | |
1319 // An event may come from a contained widget which has its own gdk window. | |
1320 // Translate it to the widget's coordinates. | |
1321 int x = 0; | |
1322 int y = 0; | |
1323 GetContainedWidgetEventCoordinates(event, &x, &y); | |
1324 last_mouse_event_was_move_ = false; | |
1325 MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, x, y, | |
1326 GetFlagsForEventButton(*event)); | |
1327 | |
1328 if (GetRootView()->OnMousePressed(mouse_pressed)) { | |
1329 is_mouse_down_ = true; | |
1330 if (!HasNativeCapture()) | |
1331 SetNativeCapture(); | |
1332 return true; | |
1333 } | |
1334 | |
1335 // Returns true to consume the event when widget is not transparent. | |
1336 return !transparent_; | |
1337 } | |
1338 | |
1339 void WidgetGtk::ProcessMouseReleased(GdkEventButton* event) { | |
1340 int x = 0, y = 0; | |
1341 GetContainedWidgetEventCoordinates(event, &x, &y); | |
1342 | |
1343 last_mouse_event_was_move_ = false; | |
1344 MouseEvent mouse_up(ui::ET_MOUSE_RELEASED, x, y, | |
1345 GetFlagsForEventButton(*event)); | |
1346 // Release the capture first, that way we don't get confused if | |
1347 // OnMouseReleased blocks. | |
1348 if (HasNativeCapture() && ReleaseCaptureOnMouseReleased()) | |
1349 ReleaseNativeCapture(); | |
1350 is_mouse_down_ = false; | |
1351 // GTK generates a mouse release at the end of dnd. We need to ignore it. | |
1352 if (!drag_data_) | |
1353 GetRootView()->OnMouseReleased(mouse_up); | |
1354 } | |
1355 | |
1356 bool WidgetGtk::ProcessScroll(GdkEventScroll* event) { | |
1357 // An event may come from a contained widget which has its own gdk window. | |
1358 // Translate it to the widget's coordinates. | |
1359 int x = 0, y = 0; | |
1360 GetContainedWidgetEventCoordinates(event, &x, &y); | |
1361 GdkEventScroll translated_event = *event; | |
1362 translated_event.x = x; | |
1363 translated_event.y = y; | |
1364 | |
1365 MouseWheelEvent wheel_event(reinterpret_cast<GdkEvent*>(&translated_event)); | |
1366 return GetRootView()->OnMouseWheel(wheel_event); | |
1367 } | |
1368 | |
1369 // static | 1294 // static |
1370 Window* WidgetGtk::GetWindowImpl(GtkWidget* widget) { | 1295 Window* WidgetGtk::GetWindowImpl(GtkWidget* widget) { |
1371 GtkWidget* parent = widget; | 1296 GtkWidget* parent = widget; |
1372 while (parent) { | 1297 while (parent) { |
1373 WidgetGtk* widget_gtk = static_cast<WidgetGtk*>( | 1298 WidgetGtk* widget_gtk = static_cast<WidgetGtk*>( |
1374 NativeWidget::GetNativeWidgetForNativeView(parent)); | 1299 NativeWidget::GetNativeWidgetForNativeView(parent)); |
1375 if (widget_gtk && widget_gtk->is_window_) | 1300 if (widget_gtk && widget_gtk->is_window_) |
1376 return static_cast<WindowGtk*>(widget_gtk); | 1301 return static_cast<WindowGtk*>(widget_gtk); |
1377 parent = gtk_widget_get_parent(parent); | 1302 parent = gtk_widget_get_parent(parent); |
1378 } | 1303 } |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1634 | 1559 |
1635 NativeWidget* native_widget = GetNativeWidgetForNativeView(native_view); | 1560 NativeWidget* native_widget = GetNativeWidgetForNativeView(native_view); |
1636 if (native_widget) | 1561 if (native_widget) |
1637 children->insert(native_widget); | 1562 children->insert(native_widget); |
1638 gtk_container_foreach(GTK_CONTAINER(native_view), | 1563 gtk_container_foreach(GTK_CONTAINER(native_view), |
1639 EnumerateChildWidgetsForNativeWidgets, | 1564 EnumerateChildWidgetsForNativeWidgets, |
1640 reinterpret_cast<gpointer>(children)); | 1565 reinterpret_cast<gpointer>(children)); |
1641 } | 1566 } |
1642 | 1567 |
1643 } // namespace views | 1568 } // namespace views |
OLD | NEW |