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 "chrome/common/gtk_util.h" | 5 #include "chrome/common/gtk_util.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 | 9 |
10 #include <cstdarg> | 10 #include <cstdarg> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 if ((event_flags & GDK_BUTTON2_MASK) || (event_flags & GDK_CONTROL_MASK)) { | 54 if ((event_flags & GDK_BUTTON2_MASK) || (event_flags & GDK_CONTROL_MASK)) { |
55 return (event_flags & GDK_SHIFT_MASK) ? | 55 return (event_flags & GDK_SHIFT_MASK) ? |
56 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; | 56 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; |
57 } | 57 } |
58 | 58 |
59 if (event_flags & GDK_SHIFT_MASK) | 59 if (event_flags & GDK_SHIFT_MASK) |
60 return NEW_WINDOW; | 60 return NEW_WINDOW; |
61 return false /*event.IsAltDown()*/ ? SAVE_TO_DISK : CURRENT_TAB; | 61 return false /*event.IsAltDown()*/ ? SAVE_TO_DISK : CURRENT_TAB; |
62 } | 62 } |
63 | 63 |
| 64 guint32 GetGdkEventTime(GdkEvent* event) { |
| 65 // The order of these entries in the switch statement match the GDK enum. |
| 66 switch (event->type) { |
| 67 case GDK_NOTHING: |
| 68 case GDK_DELETE: |
| 69 case GDK_DESTROY: |
| 70 case GDK_EXPOSE: |
| 71 return 0; |
| 72 |
| 73 case GDK_MOTION_NOTIFY: |
| 74 return reinterpret_cast<GdkEventMotion*>(event)->time; |
| 75 |
| 76 case GDK_BUTTON_PRESS: |
| 77 case GDK_2BUTTON_PRESS: |
| 78 case GDK_3BUTTON_PRESS: |
| 79 case GDK_BUTTON_RELEASE: |
| 80 return reinterpret_cast<GdkEventButton*>(event)->time; |
| 81 |
| 82 case GDK_KEY_PRESS: |
| 83 case GDK_KEY_RELEASE: |
| 84 return reinterpret_cast<GdkEventKey*>(event)->time; |
| 85 |
| 86 case GDK_ENTER_NOTIFY: |
| 87 case GDK_LEAVE_NOTIFY: |
| 88 return reinterpret_cast<GdkEventCrossing*>(event)->time; |
| 89 |
| 90 case GDK_FOCUS_CHANGE: |
| 91 case GDK_CONFIGURE: |
| 92 case GDK_MAP: |
| 93 case GDK_UNMAP: |
| 94 return 0; |
| 95 |
| 96 case GDK_PROPERTY_NOTIFY: |
| 97 return reinterpret_cast<GdkEventProperty*>(event)->time; |
| 98 |
| 99 case GDK_SELECTION_CLEAR: |
| 100 case GDK_SELECTION_REQUEST: |
| 101 case GDK_SELECTION_NOTIFY: |
| 102 return reinterpret_cast<GdkEventSelection*>(event)->time; |
| 103 |
| 104 case GDK_PROXIMITY_IN: |
| 105 case GDK_PROXIMITY_OUT: |
| 106 return reinterpret_cast<GdkEventProximity*>(event)->time; |
| 107 |
| 108 case GDK_DRAG_ENTER: |
| 109 case GDK_DRAG_LEAVE: |
| 110 case GDK_DRAG_MOTION: |
| 111 case GDK_DRAG_STATUS: |
| 112 case GDK_DROP_START: |
| 113 case GDK_DROP_FINISHED: |
| 114 return reinterpret_cast<GdkEventDND*>(event)->time; |
| 115 |
| 116 case GDK_CLIENT_EVENT: |
| 117 case GDK_VISIBILITY_NOTIFY: |
| 118 case GDK_NO_EXPOSE: |
| 119 return 0; |
| 120 |
| 121 case GDK_SCROLL: |
| 122 return reinterpret_cast<GdkEventScroll*>(event)->time; |
| 123 |
| 124 case GDK_WINDOW_STATE: |
| 125 case GDK_SETTING: |
| 126 return 0; |
| 127 |
| 128 case GDK_OWNER_CHANGE: |
| 129 return reinterpret_cast<GdkEventOwnerChange*>(event)->time; |
| 130 |
| 131 case GDK_GRAB_BROKEN: |
| 132 default: |
| 133 return 0; |
| 134 } |
| 135 } |
| 136 |
64 } // namespace event_utils | 137 } // namespace event_utils |
65 | 138 |
66 namespace gtk_util { | 139 namespace gtk_util { |
67 | 140 |
68 GtkWidget* CreateLabeledControlsGroup(const char* text, ...) { | 141 GtkWidget* CreateLabeledControlsGroup(const char* text, ...) { |
69 va_list ap; | 142 va_list ap; |
70 va_start(ap, text); | 143 va_start(ap, text); |
71 GtkWidget* table = gtk_table_new(0, 2, FALSE); | 144 GtkWidget* table = gtk_table_new(0, 2, FALSE); |
72 gtk_table_set_col_spacing(GTK_TABLE(table), 0, kLabelSpacing); | 145 gtk_table_set_col_spacing(GTK_TABLE(table), 0, kLabelSpacing); |
73 gtk_table_set_row_spacings(GTK_TABLE(table), kControlSpacing); | 146 gtk_table_set_row_spacings(GTK_TABLE(table), kControlSpacing); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // GTK_NO_WINDOW widgets, and are relative to widget->allocation.x, | 357 // GTK_NO_WINDOW widgets, and are relative to widget->allocation.x, |
285 // widget->allocation.y for widgets that are GTK_NO_WINDOW widgets. | 358 // widget->allocation.y for widgets that are GTK_NO_WINDOW widgets. |
286 // | 359 // |
287 // So the base is always (0,0). | 360 // So the base is always (0,0). |
288 gfx::Rect widget_allocation(0, 0, widget->allocation.width, | 361 gfx::Rect widget_allocation(0, 0, widget->allocation.width, |
289 widget->allocation.height); | 362 widget->allocation.height); |
290 return widget_allocation.Contains(x, y); | 363 return widget_allocation.Contains(x, y); |
291 } | 364 } |
292 | 365 |
293 } // namespace gtk_util | 366 } // namespace gtk_util |
OLD | NEW |