| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/drag_drop_types.h" | 7 #include "app/drag_drop_types.h" |
| 8 #include "app/gfx/path.h" | 8 #include "app/gfx/path.h" |
| 9 #include "app/os_exchange_data.h" | 9 #include "app/os_exchange_data.h" |
| 10 #include "app/os_exchange_data_provider_gtk.h" | 10 #include "app/os_exchange_data_provider_gtk.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 return NULL; | 44 return NULL; |
| 45 | 45 |
| 46 return WidgetGtk::GetViewForNative(gtk_widget); | 46 return WidgetGtk::GetViewForNative(gtk_widget); |
| 47 } | 47 } |
| 48 | 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(DropObserver); | 49 DISALLOW_COPY_AND_ASSIGN(DropObserver); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 // Returns the position of a widget on screen. | 52 // Returns the position of a widget on screen. |
| 53 static void GetWidgetPositionOnScreen(GtkWidget* widget, int* x, int *y) { | 53 static void GetWidgetPositionOnScreen(GtkWidget* widget, int* x, int *y) { |
| 54 while (widget) { | 54 // First get the root window. |
| 55 if (GTK_IS_WINDOW(widget)) { | 55 GtkWidget* root = widget; |
| 56 int window_x, window_y; | 56 while (root && !GTK_IS_WINDOW(root)) { |
| 57 gtk_window_get_position(GTK_WINDOW(widget), &window_x, &window_y); | 57 root = gtk_widget_get_parent(root); |
| 58 *x += window_x; | |
| 59 *y += window_y; | |
| 60 return; | |
| 61 } | |
| 62 // Not a window. | |
| 63 *x += widget->allocation.x; | |
| 64 *y += widget->allocation.y; | |
| 65 widget = gtk_widget_get_parent(widget); | |
| 66 } | 58 } |
| 59 DCHECK(root); |
| 60 // Translate the coordinate from widget to root window. |
| 61 gtk_widget_translate_coordinates(widget, root, 0, 0, x, y); |
| 62 // Then adjust the position with the position of the root window. |
| 63 int window_x, window_y; |
| 64 gtk_window_get_position(GTK_WINDOW(root), &window_x, &window_y); |
| 65 *x += window_x; |
| 66 *y += window_y; |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Returns the view::Event::flags for a GdkEventButton. | 69 // Returns the view::Event::flags for a GdkEventButton. |
| 70 static int GetFlagsForEventButton(const GdkEventButton& event) { | 70 static int GetFlagsForEventButton(const GdkEventButton& event) { |
| 71 int flags = Event::GetFlagsFromGdkState(event.state); | 71 int flags = Event::GetFlagsFromGdkState(event.state); |
| 72 switch (event.button) { | 72 switch (event.button) { |
| 73 case 1: | 73 case 1: |
| 74 flags |= Event::EF_LEFT_BUTTON_DOWN; | 74 flags |= Event::EF_LEFT_BUTTON_DOWN; |
| 75 break; | 75 break; |
| 76 case 2: | 76 case 2: |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 | 1109 |
| 1110 // static | 1110 // static |
| 1111 Widget* Widget::CreateTransparentPopupWidget(bool delete_on_destroy) { | 1111 Widget* Widget::CreateTransparentPopupWidget(bool delete_on_destroy) { |
| 1112 WidgetGtk* popup = new WidgetGtk(WidgetGtk::TYPE_POPUP); | 1112 WidgetGtk* popup = new WidgetGtk(WidgetGtk::TYPE_POPUP); |
| 1113 popup->set_delete_on_destroy(delete_on_destroy); | 1113 popup->set_delete_on_destroy(delete_on_destroy); |
| 1114 popup->MakeTransparent(); | 1114 popup->MakeTransparent(); |
| 1115 return popup; | 1115 return popup; |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 } // namespace views | 1118 } // namespace views |
| OLD | NEW |