OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/renderer_host/input/web_input_event_builders_gtk.h" | 5 #include "content/browser/renderer_host/input/web_input_event_builders_gtk.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "content/browser/renderer_host/input/web_input_event_util_posix.h" | 12 #include "content/browser/renderer_host/input/web_input_event_util_posix.h" |
13 #include "third_party/WebKit/public/web/WebInputEvent.h" | 13 #include "third_party/WebKit/public/web/WebInputEvent.h" |
14 #include "ui/events/keycodes/keyboard_code_conversion_gtk.h" | 14 #include "ui/events/keycodes/keyboard_code_conversion_gtk.h" |
15 | 15 |
16 using WebKit::WebInputEvent; | 16 using blink::WebInputEvent; |
17 using WebKit::WebMouseEvent; | 17 using blink::WebMouseEvent; |
18 using WebKit::WebMouseWheelEvent; | 18 using blink::WebMouseWheelEvent; |
19 using WebKit::WebKeyboardEvent; | 19 using blink::WebKeyboardEvent; |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 // For click count tracking. | 23 // For click count tracking. |
24 static int num_clicks = 0; | 24 static int num_clicks = 0; |
25 static GdkWindow* last_click_event_window = 0; | 25 static GdkWindow* last_click_event_window = 0; |
26 static gint last_click_time = 0; | 26 static gint last_click_time = 0; |
27 static gint last_click_x = 0; | 27 static gint last_click_x = 0; |
28 static gint last_click_y = 0; | 28 static gint last_click_y = 0; |
29 static WebMouseEvent::Button last_click_button = WebMouseEvent::ButtonNone; | 29 static WebMouseEvent::Button last_click_button = WebMouseEvent::ButtonNone; |
(...skipping 16 matching lines...) Expand all Loading... |
46 std::abs(x - last_click_x) > double_click_distance || | 46 std::abs(x - last_click_x) > double_click_distance || |
47 std::abs(y - last_click_y) > double_click_distance; | 47 std::abs(y - last_click_y) > double_click_distance; |
48 } | 48 } |
49 | 49 |
50 void ResetClickCountState() { | 50 void ResetClickCountState() { |
51 num_clicks = 0; | 51 num_clicks = 0; |
52 last_click_event_window = 0; | 52 last_click_event_window = 0; |
53 last_click_time = 0; | 53 last_click_time = 0; |
54 last_click_x = 0; | 54 last_click_x = 0; |
55 last_click_y = 0; | 55 last_click_y = 0; |
56 last_click_button = WebKit::WebMouseEvent::ButtonNone; | 56 last_click_button = blink::WebMouseEvent::ButtonNone; |
57 } | 57 } |
58 | 58 |
59 bool IsKeyPadKeyval(guint keyval) { | 59 bool IsKeyPadKeyval(guint keyval) { |
60 // Keypad keyvals all fall into one range. | 60 // Keypad keyvals all fall into one range. |
61 return keyval >= GDK_KP_Space && keyval <= GDK_KP_9; | 61 return keyval >= GDK_KP_Space && keyval <= GDK_KP_9; |
62 } | 62 } |
63 | 63 |
64 double GdkEventTimeToWebEventTime(guint32 time) { | 64 double GdkEventTimeToWebEventTime(guint32 time) { |
65 // Convert from time in ms to time in sec. | 65 // Convert from time in ms to time in sec. |
66 return time / 1000.0; | 66 return time / 1000.0; |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 388 |
389 WebKeyboardEvent WebKeyboardEventBuilder::Build(wchar_t character, | 389 WebKeyboardEvent WebKeyboardEventBuilder::Build(wchar_t character, |
390 int state, | 390 int state, |
391 double timeStampSeconds) { | 391 double timeStampSeconds) { |
392 // keyboardEvent(const GdkEventKey*) depends on the GdkEventKey object and | 392 // keyboardEvent(const GdkEventKey*) depends on the GdkEventKey object and |
393 // it is hard to use/ it from signal handlers which don't use GdkEventKey | 393 // it is hard to use/ it from signal handlers which don't use GdkEventKey |
394 // objects (e.g. GtkIMContext signal handlers.) For such handlers, this | 394 // objects (e.g. GtkIMContext signal handlers.) For such handlers, this |
395 // function creates a WebInputEvent::Char event without using a | 395 // function creates a WebInputEvent::Char event without using a |
396 // GdkEventKey object. | 396 // GdkEventKey object. |
397 WebKeyboardEvent result; | 397 WebKeyboardEvent result; |
398 result.type = WebKit::WebInputEvent::Char; | 398 result.type = blink::WebInputEvent::Char; |
399 result.timeStampSeconds = timeStampSeconds; | 399 result.timeStampSeconds = timeStampSeconds; |
400 result.modifiers = GdkStateToWebEventModifiers(state); | 400 result.modifiers = GdkStateToWebEventModifiers(state); |
401 result.windowsKeyCode = character; | 401 result.windowsKeyCode = character; |
402 result.nativeKeyCode = character; | 402 result.nativeKeyCode = character; |
403 result.text[0] = character; | 403 result.text[0] = character; |
404 result.unmodifiedText[0] = character; | 404 result.unmodifiedText[0] = character; |
405 | 405 |
406 // According to MSDN: | 406 // According to MSDN: |
407 // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx | 407 // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx |
408 // Key events with Alt modifier and F10 are system key events. | 408 // Key events with Alt modifier and F10 are system key events. |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 case GDK_SCROLL_RIGHT: | 594 case GDK_SCROLL_RIGHT: |
595 result.deltaX = -scrollbarPixelsPerTick; | 595 result.deltaX = -scrollbarPixelsPerTick; |
596 result.wheelTicksX = -1; | 596 result.wheelTicksX = -1; |
597 break; | 597 break; |
598 } | 598 } |
599 | 599 |
600 return result; | 600 return result; |
601 } | 601 } |
602 | 602 |
603 } // namespace content | 603 } // namespace content |
OLD | NEW |