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 "mojo/services/native_viewport/platform_viewport.h" | 5 #include "mojo/services/native_viewport/platform_viewport.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "mojo/services/public/cpp/input_events/lib/mojo_extended_key_event_data
.h" | 9 #include "mojo/services/public/cpp/input_events/lib/mojo_extended_key_event_data
.h" |
10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 explicit PlatformViewportX11(Delegate* delegate) : delegate_(delegate) { | 24 explicit PlatformViewportX11(Delegate* delegate) : delegate_(delegate) { |
25 } | 25 } |
26 | 26 |
27 virtual ~PlatformViewportX11() { | 27 virtual ~PlatformViewportX11() { |
28 // Destroy the platform-window while |this| is still alive. | 28 // Destroy the platform-window while |this| is still alive. |
29 platform_window_.reset(); | 29 platform_window_.reset(); |
30 } | 30 } |
31 | 31 |
32 private: | 32 private: |
33 // Overridden from PlatformViewport: | 33 // Overridden from PlatformViewport: |
34 virtual void Init(const gfx::Rect& bounds) OVERRIDE { | 34 virtual void Init(const gfx::Rect& bounds) override { |
35 CHECK(!event_source_); | 35 CHECK(!event_source_); |
36 CHECK(!platform_window_); | 36 CHECK(!platform_window_); |
37 | 37 |
38 event_source_ = ui::PlatformEventSource::CreateDefault(); | 38 event_source_ = ui::PlatformEventSource::CreateDefault(); |
39 | 39 |
40 platform_window_.reset(new ui::X11Window(this)); | 40 platform_window_.reset(new ui::X11Window(this)); |
41 platform_window_->SetBounds(bounds); | 41 platform_window_->SetBounds(bounds); |
42 } | 42 } |
43 | 43 |
44 virtual void Show() OVERRIDE { | 44 virtual void Show() override { |
45 platform_window_->Show(); | 45 platform_window_->Show(); |
46 } | 46 } |
47 | 47 |
48 virtual void Hide() OVERRIDE { | 48 virtual void Hide() override { |
49 platform_window_->Hide(); | 49 platform_window_->Hide(); |
50 } | 50 } |
51 | 51 |
52 virtual void Close() OVERRIDE { | 52 virtual void Close() override { |
53 platform_window_->Close(); | 53 platform_window_->Close(); |
54 } | 54 } |
55 | 55 |
56 virtual gfx::Size GetSize() OVERRIDE { | 56 virtual gfx::Size GetSize() override { |
57 return bounds_.size(); | 57 return bounds_.size(); |
58 } | 58 } |
59 | 59 |
60 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE { | 60 virtual void SetBounds(const gfx::Rect& bounds) override { |
61 platform_window_->SetBounds(bounds); | 61 platform_window_->SetBounds(bounds); |
62 } | 62 } |
63 | 63 |
64 virtual void SetCapture() OVERRIDE { | 64 virtual void SetCapture() override { |
65 platform_window_->SetCapture(); | 65 platform_window_->SetCapture(); |
66 } | 66 } |
67 | 67 |
68 virtual void ReleaseCapture() OVERRIDE { | 68 virtual void ReleaseCapture() override { |
69 platform_window_->ReleaseCapture(); | 69 platform_window_->ReleaseCapture(); |
70 } | 70 } |
71 | 71 |
72 // ui::PlatformWindowDelegate: | 72 // ui::PlatformWindowDelegate: |
73 virtual void OnBoundsChanged(const gfx::Rect& new_bounds) OVERRIDE { | 73 virtual void OnBoundsChanged(const gfx::Rect& new_bounds) override { |
74 bounds_ = new_bounds; | 74 bounds_ = new_bounds; |
75 delegate_->OnBoundsChanged(new_bounds); | 75 delegate_->OnBoundsChanged(new_bounds); |
76 } | 76 } |
77 | 77 |
78 virtual void OnDamageRect(const gfx::Rect& damaged_region) OVERRIDE { | 78 virtual void OnDamageRect(const gfx::Rect& damaged_region) override { |
79 } | 79 } |
80 | 80 |
81 virtual void DispatchEvent(ui::Event* event) OVERRIDE { | 81 virtual void DispatchEvent(ui::Event* event) override { |
82 delegate_->OnEvent(event); | 82 delegate_->OnEvent(event); |
83 | 83 |
84 // We want to emulate the WM_CHAR generation behaviour of Windows. | 84 // We want to emulate the WM_CHAR generation behaviour of Windows. |
85 // | 85 // |
86 // On Linux, we've previously inserted characters by having | 86 // On Linux, we've previously inserted characters by having |
87 // InputMethodAuraLinux take all key down events and send a character event | 87 // InputMethodAuraLinux take all key down events and send a character event |
88 // to the TextInputClient. This causes a mismatch in code that has to be | 88 // to the TextInputClient. This causes a mismatch in code that has to be |
89 // shared between Windows and Linux, including blink code. Now that we're | 89 // shared between Windows and Linux, including blink code. Now that we're |
90 // trying to have one way of doing things, we need to standardize on and | 90 // trying to have one way of doing things, we need to standardize on and |
91 // emulate Windows character events. | 91 // emulate Windows character events. |
(...skipping 14 matching lines...) Expand all Loading... |
106 new MojoExtendedKeyEventData( | 106 new MojoExtendedKeyEventData( |
107 key_press_event->GetLocatedWindowsKeyboardCode(), | 107 key_press_event->GetLocatedWindowsKeyboardCode(), |
108 key_press_event->GetText(), | 108 key_press_event->GetText(), |
109 key_press_event->GetUnmodifiedText()))); | 109 key_press_event->GetUnmodifiedText()))); |
110 char_event.set_platform_keycode(key_press_event->platform_keycode()); | 110 char_event.set_platform_keycode(key_press_event->platform_keycode()); |
111 | 111 |
112 delegate_->OnEvent(&char_event); | 112 delegate_->OnEvent(&char_event); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 virtual void OnCloseRequest() OVERRIDE { | 116 virtual void OnCloseRequest() override { |
117 platform_window_->Close(); | 117 platform_window_->Close(); |
118 } | 118 } |
119 | 119 |
120 virtual void OnClosed() OVERRIDE { | 120 virtual void OnClosed() override { |
121 delegate_->OnDestroyed(); | 121 delegate_->OnDestroyed(); |
122 } | 122 } |
123 | 123 |
124 virtual void OnWindowStateChanged(ui::PlatformWindowState state) OVERRIDE { | 124 virtual void OnWindowStateChanged(ui::PlatformWindowState state) override { |
125 } | 125 } |
126 | 126 |
127 virtual void OnLostCapture() OVERRIDE { | 127 virtual void OnLostCapture() override { |
128 } | 128 } |
129 | 129 |
130 virtual void OnAcceleratedWidgetAvailable( | 130 virtual void OnAcceleratedWidgetAvailable( |
131 gfx::AcceleratedWidget widget) OVERRIDE { | 131 gfx::AcceleratedWidget widget) override { |
132 delegate_->OnAcceleratedWidgetAvailable(widget); | 132 delegate_->OnAcceleratedWidgetAvailable(widget); |
133 } | 133 } |
134 | 134 |
135 virtual void OnActivationChanged(bool active) OVERRIDE {} | 135 virtual void OnActivationChanged(bool active) override {} |
136 | 136 |
137 scoped_ptr<ui::PlatformEventSource> event_source_; | 137 scoped_ptr<ui::PlatformEventSource> event_source_; |
138 scoped_ptr<ui::PlatformWindow> platform_window_; | 138 scoped_ptr<ui::PlatformWindow> platform_window_; |
139 Delegate* delegate_; | 139 Delegate* delegate_; |
140 gfx::Rect bounds_; | 140 gfx::Rect bounds_; |
141 | 141 |
142 DISALLOW_COPY_AND_ASSIGN(PlatformViewportX11); | 142 DISALLOW_COPY_AND_ASSIGN(PlatformViewportX11); |
143 }; | 143 }; |
144 | 144 |
145 // static | 145 // static |
146 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) { | 146 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) { |
147 return scoped_ptr<PlatformViewport>(new PlatformViewportX11(delegate)).Pass(); | 147 return scoped_ptr<PlatformViewport>(new PlatformViewportX11(delegate)).Pass(); |
148 } | 148 } |
149 | 149 |
150 } // namespace mojo | 150 } // namespace mojo |
OLD | NEW |