| 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 "chrome/browser/automation/ui_controls.h" | 5 #include "chrome/browser/automation/ui_controls.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 gdk_event_free(event); | 91 gdk_event_free(event); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace | 94 } // namespace |
| 95 | 95 |
| 96 namespace ui_controls { | 96 namespace ui_controls { |
| 97 | 97 |
| 98 bool SendKeyPress(gfx::NativeWindow window, | 98 bool SendKeyPress(gfx::NativeWindow window, |
| 99 ui::KeyboardCode key, | 99 ui::KeyboardCode key, |
| 100 bool control, bool shift, bool alt, bool command) { | 100 bool control, bool shift, bool alt, bool command) { |
| 101 DCHECK(command == false); // No command key on Linux | 101 DCHECK_EQ(command, false); // No command key on Linux |
| 102 GdkWindow* event_window = NULL; | 102 GdkWindow* event_window = NULL; |
| 103 GtkWidget* grab_widget = gtk_grab_get_current(); | 103 GtkWidget* grab_widget = gtk_grab_get_current(); |
| 104 if (grab_widget) { | 104 if (grab_widget) { |
| 105 // If there is a grab, send all events to the grabbed widget. | 105 // If there is a grab, send all events to the grabbed widget. |
| 106 event_window = grab_widget->window; | 106 event_window = grab_widget->window; |
| 107 } else if (window) { | 107 } else if (window) { |
| 108 event_window = GTK_WIDGET(window)->window; | 108 event_window = GTK_WIDGET(window)->window; |
| 109 } else { | 109 } else { |
| 110 // No target was specified. Send the events to the active toplevel. | 110 // No target was specified. Send the events to the active toplevel. |
| 111 GList* windows = gtk_window_list_toplevels(); | 111 GList* windows = gtk_window_list_toplevels(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 133 } | 133 } |
| 134 | 134 |
| 135 return true; | 135 return true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, | 138 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, |
| 139 ui::KeyboardCode key, | 139 ui::KeyboardCode key, |
| 140 bool control, bool shift, | 140 bool control, bool shift, |
| 141 bool alt, bool command, | 141 bool alt, bool command, |
| 142 Task* task) { | 142 Task* task) { |
| 143 DCHECK(command == false); // No command key on Linux | 143 DCHECK_EQ(command, false); // No command key on Linux |
| 144 int release_count = 1; | 144 int release_count = 1; |
| 145 if (control) | 145 if (control) |
| 146 release_count++; | 146 release_count++; |
| 147 if (shift) | 147 if (shift) |
| 148 release_count++; | 148 release_count++; |
| 149 if (alt) | 149 if (alt) |
| 150 release_count++; | 150 release_count++; |
| 151 // This object will delete itself after running |task|. | 151 // This object will delete itself after running |task|. |
| 152 new EventWaiter(task, GDK_KEY_RELEASE, release_count); | 152 new EventWaiter(task, GDK_KEY_RELEASE, release_count); |
| 153 return SendKeyPress(window, key, control, shift, alt, command); | 153 return SendKeyPress(window, key, control, shift, alt, command); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 int state, | 258 int state, |
| 259 Task* task) { | 259 Task* task) { |
| 260 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget); | 260 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget); |
| 261 SendMouseMoveNotifyWhenDone(bounds.x() + bounds.width() / 2, | 261 SendMouseMoveNotifyWhenDone(bounds.x() + bounds.width() / 2, |
| 262 bounds.y() + bounds.height() / 2, | 262 bounds.y() + bounds.height() / 2, |
| 263 new ClickTask(button, state, task)); | 263 new ClickTask(button, state, task)); |
| 264 } | 264 } |
| 265 #endif | 265 #endif |
| 266 | 266 |
| 267 } // namespace ui_controls | 267 } // namespace ui_controls |
| OLD | NEW |