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/logging.h" | 10 #include "base/logging.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 bool SendKeyPress(gfx::NativeWindow window, | 47 bool SendKeyPress(gfx::NativeWindow window, |
48 wchar_t key, bool control, bool shift, bool alt) { | 48 wchar_t key, bool control, bool shift, bool alt) { |
49 // TODO(estade): send a release as well? | 49 // TODO(estade): send a release as well? |
50 GdkEvent* event = gdk_event_new(GDK_KEY_PRESS); | 50 GdkEvent* event = gdk_event_new(GDK_KEY_PRESS); |
51 | 51 |
52 event->key.type = GDK_KEY_PRESS; | 52 event->key.type = GDK_KEY_PRESS; |
53 event->key.window = GTK_WIDGET(window)->window; | 53 event->key.window = GTK_WIDGET(window)->window; |
54 g_object_ref(event->key.window); | 54 g_object_ref(event->key.window); |
55 event->key.send_event = false; | 55 event->key.send_event = false; |
56 // TODO(estade): Put the real time? | 56 |
57 event->key.time = GDK_CURRENT_TIME; | 57 struct timespec ts; |
| 58 clock_gettime(CLOCK_MONOTONIC, &ts); |
| 59 event->key.time = ts.tv_sec * 1000 + ts.tv_nsec / 1000000; |
| 60 |
58 // TODO(estade): handle other state flags besides control, shift, alt? | 61 // TODO(estade): handle other state flags besides control, shift, alt? |
59 // For example caps lock. | 62 // For example caps lock. |
60 event->key.state = (control ? GDK_CONTROL_MASK : 0) | | 63 event->key.state = (control ? GDK_CONTROL_MASK : 0) | |
61 (shift ? GDK_SHIFT_MASK : 0) | | 64 (shift ? GDK_SHIFT_MASK : 0) | |
62 (alt ? GDK_MOD1_MASK : 0); | 65 (alt ? GDK_MOD1_MASK : 0); |
63 event->key.keyval = key; | 66 event->key.keyval = key; |
64 // TODO(estade): fill in the string? | 67 // TODO(estade): fill in the string? |
65 | 68 |
66 GdkKeymapKey* keys; | 69 GdkKeymapKey* keys; |
67 gint n_keys; | 70 gint n_keys; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 119 |
117 // TODO(estade): need to figure out a better type for this than View. | 120 // TODO(estade): need to figure out a better type for this than View. |
118 void MoveMouseToCenterAndPress(views::View* view, | 121 void MoveMouseToCenterAndPress(views::View* view, |
119 MouseButton button, | 122 MouseButton button, |
120 int state, | 123 int state, |
121 Task* task) { | 124 Task* task) { |
122 NOTIMPLEMENTED(); | 125 NOTIMPLEMENTED(); |
123 } | 126 } |
124 | 127 |
125 } // namespace ui_controls | 128 } // namespace ui_controls |
OLD | NEW |