Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: ui/base/events/event.cc

Issue 17265006: wayland patch for inspection Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/cursor/cursor_wayland.cc ('k') | ui/base/ime/fake_input_method.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/base/events/event.h" 5 #include "ui/base/events/event.h"
6 6
7 #if defined(USE_X11) 7 #if defined(USE_X11)
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 #endif 9 #endif
10 10
11 #include <cmath> 11 #include <cmath>
12 #include <cstring> 12 #include <cstring>
13 13
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "ui/base/events/event_utils.h" 16 #include "ui/base/events/event_utils.h"
17 #include "ui/base/keycodes/keyboard_code_conversion.h" 17 #include "ui/base/keycodes/keyboard_code_conversion.h"
18 #include "ui/gfx/point3_f.h" 18 #include "ui/gfx/point3_f.h"
19 #include "ui/gfx/point_conversions.h" 19 #include "ui/gfx/point_conversions.h"
20 #include "ui/gfx/transform.h" 20 #include "ui/gfx/transform.h"
21 #include "ui/gfx/transform_util.h" 21 #include "ui/gfx/transform_util.h"
22 22
23 #if defined(USE_X11) 23 #if defined(USE_WAYLAND)
24 #include "base/wayland/wayland_event.h"
25 #include "ui/base/keycodes/keyboard_code_conversion_wayland.h"
26 #elif defined(USE_X11)
24 #include "ui/base/keycodes/keyboard_code_conversion_x.h" 27 #include "ui/base/keycodes/keyboard_code_conversion_x.h"
25 #endif 28 #endif
26 29
27 namespace { 30 namespace {
28 31
29 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { 32 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) {
30 #if defined(USE_X11) 33 #if defined(USE_WAYLAND)
34 if (!event)
35 return NULL;
36 base::wayland::WaylandEvent* copy = new base::wayland::WaylandEvent;
37 *copy = *event;
38 return copy;
39 #elif defined(USE_X11)
31 if (!event || event->type == GenericEvent) 40 if (!event || event->type == GenericEvent)
32 return NULL; 41 return NULL;
33 XEvent* copy = new XEvent; 42 XEvent* copy = new XEvent;
34 *copy = *event; 43 *copy = *event;
35 return copy; 44 return copy;
36 #elif defined(OS_WIN) 45 #elif defined(OS_WIN)
37 return event; 46 return event;
38 #else 47 #else
39 NOTREACHED() << 48 NOTREACHED() <<
40 "Don't know how to copy base::NativeEvent for this platform"; 49 "Don't know how to copy base::NativeEvent for this platform";
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 case ui::ET_LAST: NOTREACHED(); return std::string(); 107 case ui::ET_LAST: NOTREACHED(); return std::string();
99 // Don't include default, so that we get an error when new type is added. 108 // Don't include default, so that we get an error when new type is added.
100 } 109 }
101 #undef CASE_TYPE 110 #undef CASE_TYPE
102 111
103 NOTREACHED(); 112 NOTREACHED();
104 return std::string(); 113 return std::string();
105 } 114 }
106 115
107 bool IsX11SendEventTrue(const base::NativeEvent& event) { 116 bool IsX11SendEventTrue(const base::NativeEvent& event) {
108 #if defined(USE_X11) 117 #if defined(USE_WAYLAND)
118 return false;
119 #elif defined(USE_X11)
109 if (event && event->xany.send_event) 120 if (event && event->xany.send_event)
110 return true; 121 return true;
111 #endif 122 #endif
112 return false; 123 return false;
113 } 124 }
114 125
115 } // namespace 126 } // namespace
116 127
117 namespace ui { 128 namespace ui {
118 129
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 unmodified_character_(0) { 513 unmodified_character_(0) {
503 } 514 }
504 515
505 uint16 KeyEvent::GetCharacter() const { 516 uint16 KeyEvent::GetCharacter() const {
506 if (character_) 517 if (character_)
507 return character_; 518 return character_;
508 519
509 #if defined(OS_WIN) 520 #if defined(OS_WIN)
510 return (native_event().message == WM_CHAR) ? key_code_ : 521 return (native_event().message == WM_CHAR) ? key_code_ :
511 GetCharacterFromKeyCode(key_code_, flags()); 522 GetCharacterFromKeyCode(key_code_, flags());
523 #elif defined(USE_WAYLAND)
524 if (!native_event())
525 return ui::GetCharacterFromKeyCode(key_code_, flags());
526
527 uint16 ch = 0;
528 if (!IsControlDown())
529 ch = ui::GetCharacterFromWaylandEvent(native_event());
530 return ch ? ch : ui::GetCharacterFromKeyCode(key_code_, flags());
512 #elif defined(USE_X11) 531 #elif defined(USE_X11)
513 if (!native_event()) 532 if (!native_event())
514 return GetCharacterFromKeyCode(key_code_, flags()); 533 return GetCharacterFromKeyCode(key_code_, flags());
515 534
516 DCHECK(native_event()->type == KeyPress || 535 DCHECK(native_event()->type == KeyPress ||
517 native_event()->type == KeyRelease); 536 native_event()->type == KeyRelease);
518 537
519 uint16 ch = 0; 538 uint16 ch = 0;
520 if (!IsControlDown()) 539 if (!IsControlDown())
521 ch = GetCharacterFromXEvent(native_event()); 540 ch = GetCharacterFromXEvent(native_event());
522 return ch ? ch : GetCharacterFromKeyCode(key_code_, flags()); 541 return ch ? ch : GetCharacterFromKeyCode(key_code_, flags());
523 #else 542 #else
524 NOTIMPLEMENTED(); 543 NOTIMPLEMENTED();
525 return 0; 544 return 0;
526 #endif 545 #endif
527 } 546 }
528 547
529 uint16 KeyEvent::GetUnmodifiedCharacter() const { 548 uint16 KeyEvent::GetUnmodifiedCharacter() const {
530 if (unmodified_character_) 549 if (unmodified_character_)
531 return unmodified_character_; 550 return unmodified_character_;
532 551
533 #if defined(OS_WIN) 552 #if defined(OS_WIN)
534 // Looks like there is no way to get unmodified character on Windows. 553 // Looks like there is no way to get unmodified character on Windows.
535 return (native_event().message == WM_CHAR) ? key_code_ : 554 return (native_event().message == WM_CHAR) ? key_code_ :
536 GetCharacterFromKeyCode(key_code_, flags() & EF_SHIFT_DOWN); 555 GetCharacterFromKeyCode(key_code_, flags() & EF_SHIFT_DOWN);
556 #elif defined(USE_WAYLAND)
557 if (!native_event())
558 return ui::GetCharacterFromKeyCode(key_code_, flags() & ui::EF_SHIFT_DOWN);
559
560 uint16 ch = ui::GetCharacterFromWaylandEvent(native_event());
561 return ch ? ch :
562 ui::GetCharacterFromKeyCode(key_code_, flags() & ui::EF_SHIFT_DOWN);
537 #elif defined(USE_X11) 563 #elif defined(USE_X11)
538 if (!native_event()) 564 if (!native_event())
539 return GetCharacterFromKeyCode(key_code_, flags() & EF_SHIFT_DOWN); 565 return GetCharacterFromKeyCode(key_code_, flags() & EF_SHIFT_DOWN);
540 566
541 DCHECK(native_event()->type == KeyPress || 567 DCHECK(native_event()->type == KeyPress ||
542 native_event()->type == KeyRelease); 568 native_event()->type == KeyRelease);
543 569
544 static const unsigned int kIgnoredModifiers = ControlMask | LockMask | 570 static const unsigned int kIgnoredModifiers = ControlMask | LockMask |
545 Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask; 571 Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask;
546 572
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 int GestureEvent::GetLowestTouchId() const { 758 int GestureEvent::GetLowestTouchId() const {
733 if (touch_ids_bitfield_ == 0) 759 if (touch_ids_bitfield_ == 0)
734 return -1; 760 return -1;
735 int i = -1; 761 int i = -1;
736 // Find the index of the least significant 1 bit 762 // Find the index of the least significant 1 bit
737 while (!(1 << ++i & touch_ids_bitfield_)); 763 while (!(1 << ++i & touch_ids_bitfield_));
738 return i; 764 return i;
739 } 765 }
740 766
741 } // namespace ui 767 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/cursor/cursor_wayland.cc ('k') | ui/base/ime/fake_input_method.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698