| 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/browser/automation/ui_controls.h" | 5 #include "chrome/browser/automation/ui_controls.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
| 9 | 9 |
| 10 #include "base/gfx/rect.h" | 10 #include "base/gfx/rect.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 (shift ? GDK_SHIFT_MASK : 0); | 190 (shift ? GDK_SHIFT_MASK : 0); |
| 191 rv = rv && SendKeyEvent(event_window, true, GDK_Alt_L, state); | 191 rv = rv && SendKeyEvent(event_window, true, GDK_Alt_L, state); |
| 192 } | 192 } |
| 193 | 193 |
| 194 // TODO(estade): handle other state flags besides control, shift, alt? | 194 // TODO(estade): handle other state flags besides control, shift, alt? |
| 195 // For example caps lock. | 195 // For example caps lock. |
| 196 guint state = (control ? GDK_CONTROL_MASK : 0) | | 196 guint state = (control ? GDK_CONTROL_MASK : 0) | |
| 197 (shift ? GDK_SHIFT_MASK : 0) | | 197 (shift ? GDK_SHIFT_MASK : 0) | |
| 198 (alt ? GDK_MOD1_MASK : 0); | 198 (alt ? GDK_MOD1_MASK : 0); |
| 199 | 199 |
| 200 guint gdk_key = base::GdkKeyCodeForWindowsKeyCode(key); | 200 guint gdk_key = base::GdkKeyCodeForWindowsKeyCode(key, shift); |
| 201 rv = rv && SendKeyEvent(event_window, true, gdk_key, state); | 201 rv = rv && SendKeyEvent(event_window, true, gdk_key, state); |
| 202 rv = rv && SendKeyEvent(event_window, false, gdk_key, state); | 202 rv = rv && SendKeyEvent(event_window, false, gdk_key, state); |
| 203 | 203 |
| 204 if (alt) { | 204 if (alt) { |
| 205 guint state = (control ? GDK_CONTROL_MASK : 0) | | 205 guint state = (control ? GDK_CONTROL_MASK : 0) | |
| 206 (shift ? GDK_SHIFT_MASK : 0); | 206 (shift ? GDK_SHIFT_MASK : 0) | GDK_MOD1_MASK; |
| 207 rv = rv && SendKeyEvent(event_window, false, GDK_Alt_L, state); | 207 rv = rv && SendKeyEvent(event_window, false, GDK_Alt_L, state); |
| 208 } | 208 } |
| 209 | 209 |
| 210 if (shift) { | 210 if (shift) { |
| 211 rv = rv && SendKeyEvent(event_window, false, GDK_Shift_L, | 211 rv = rv && SendKeyEvent(event_window, false, GDK_Shift_L, |
| 212 control ? GDK_CONTROL_MASK : 0); | 212 (control ? GDK_CONTROL_MASK : 0) | GDK_SHIFT_MASK); |
| 213 } | 213 } |
| 214 | 214 |
| 215 if (control) | 215 if (control) |
| 216 rv = rv && SendKeyEvent(event_window, false, GDK_Control_L, 0); | 216 rv = rv && SendKeyEvent(event_window, false, GDK_Control_L, |
| 217 GDK_CONTROL_MASK); |
| 217 | 218 |
| 218 return rv; | 219 return rv; |
| 219 } | 220 } |
| 220 | 221 |
| 221 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, | 222 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, |
| 222 base::KeyboardCode key, | 223 base::KeyboardCode key, |
| 223 bool control, bool shift, bool alt, | 224 bool control, bool shift, bool alt, |
| 224 Task* task) { | 225 Task* task) { |
| 225 int release_count = 1; | 226 int release_count = 1; |
| 226 if (control) | 227 if (control) |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 int state, | 340 int state, |
| 340 Task* task) { | 341 Task* task) { |
| 341 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget); | 342 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget); |
| 342 SendMouseMoveNotifyWhenDone(bounds.x() + bounds.width() / 2, | 343 SendMouseMoveNotifyWhenDone(bounds.x() + bounds.width() / 2, |
| 343 bounds.y() + bounds.height() / 2, | 344 bounds.y() + bounds.height() / 2, |
| 344 new ClickTask(button, state, task)); | 345 new ClickTask(button, state, task)); |
| 345 } | 346 } |
| 346 #endif | 347 #endif |
| 347 | 348 |
| 348 } // namespace ui_controls | 349 } // namespace ui_controls |
| OLD | NEW |