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

Side by Side Diff: mojo/services/native_viewport/platform_viewport_x11.cc

Issue 667223002: Mojo: More virtual/override style fixes in mojo/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
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/converters/input_events/mojo_extended_key_event_data.h" 9 #include "mojo/converters/input_events/mojo_extended_key_event_data.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
11 #include "ui/events/event_utils.h" 11 #include "ui/events/event_utils.h"
12 #include "ui/events/platform/platform_event_dispatcher.h" 12 #include "ui/events/platform/platform_event_dispatcher.h"
13 #include "ui/events/platform/platform_event_source.h" 13 #include "ui/events/platform/platform_event_source.h"
14 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
15 #include "ui/platform_window/platform_window.h" 15 #include "ui/platform_window/platform_window.h"
16 #include "ui/platform_window/platform_window_delegate.h" 16 #include "ui/platform_window/platform_window_delegate.h"
17 #include "ui/platform_window/x11/x11_window.h" 17 #include "ui/platform_window/x11/x11_window.h"
18 18
19 namespace mojo { 19 namespace mojo {
20 20
21 class PlatformViewportX11 : public PlatformViewport, 21 class PlatformViewportX11 : public PlatformViewport,
22 public ui::PlatformWindowDelegate { 22 public ui::PlatformWindowDelegate {
23 public: 23 public:
24 explicit PlatformViewportX11(Delegate* delegate) : delegate_(delegate) { 24 explicit PlatformViewportX11(Delegate* delegate) : delegate_(delegate) {
25 } 25 }
26 26
27 virtual ~PlatformViewportX11() { 27 ~PlatformViewportX11() override {
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 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 void Show() override { platform_window_->Show(); }
45 platform_window_->Show();
46 }
47 45
48 virtual void Hide() override { 46 void Hide() override { platform_window_->Hide(); }
49 platform_window_->Hide();
50 }
51 47
52 virtual void Close() override { 48 void Close() override { platform_window_->Close(); }
53 platform_window_->Close();
54 }
55 49
56 virtual gfx::Size GetSize() override { 50 gfx::Size GetSize() override { return bounds_.size(); }
57 return bounds_.size();
58 }
59 51
60 virtual void SetBounds(const gfx::Rect& bounds) override { 52 void SetBounds(const gfx::Rect& bounds) override {
61 platform_window_->SetBounds(bounds); 53 platform_window_->SetBounds(bounds);
62 } 54 }
63 55
64 virtual void SetCapture() override { 56 void SetCapture() override { platform_window_->SetCapture(); }
65 platform_window_->SetCapture();
66 }
67 57
68 virtual void ReleaseCapture() override { 58 void ReleaseCapture() override { platform_window_->ReleaseCapture(); }
69 platform_window_->ReleaseCapture();
70 }
71 59
72 // ui::PlatformWindowDelegate: 60 // ui::PlatformWindowDelegate:
73 virtual void OnBoundsChanged(const gfx::Rect& new_bounds) override { 61 void OnBoundsChanged(const gfx::Rect& new_bounds) override {
74 bounds_ = new_bounds; 62 bounds_ = new_bounds;
75 delegate_->OnBoundsChanged(new_bounds); 63 delegate_->OnBoundsChanged(new_bounds);
76 } 64 }
77 65
78 virtual void OnDamageRect(const gfx::Rect& damaged_region) override { 66 void OnDamageRect(const gfx::Rect& damaged_region) override {}
79 }
80 67
81 virtual void DispatchEvent(ui::Event* event) override { 68 void DispatchEvent(ui::Event* event) override {
82 delegate_->OnEvent(event); 69 delegate_->OnEvent(event);
83 70
84 // We want to emulate the WM_CHAR generation behaviour of Windows. 71 // We want to emulate the WM_CHAR generation behaviour of Windows.
85 // 72 //
86 // On Linux, we've previously inserted characters by having 73 // On Linux, we've previously inserted characters by having
87 // InputMethodAuraLinux take all key down events and send a character event 74 // 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 75 // 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 76 // 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 77 // trying to have one way of doing things, we need to standardize on and
91 // emulate Windows character events. 78 // emulate Windows character events.
(...skipping 14 matching lines...) Expand all
106 new MojoExtendedKeyEventData( 93 new MojoExtendedKeyEventData(
107 key_press_event->GetLocatedWindowsKeyboardCode(), 94 key_press_event->GetLocatedWindowsKeyboardCode(),
108 key_press_event->GetText(), 95 key_press_event->GetText(),
109 key_press_event->GetUnmodifiedText()))); 96 key_press_event->GetUnmodifiedText())));
110 char_event.set_platform_keycode(key_press_event->platform_keycode()); 97 char_event.set_platform_keycode(key_press_event->platform_keycode());
111 98
112 delegate_->OnEvent(&char_event); 99 delegate_->OnEvent(&char_event);
113 } 100 }
114 } 101 }
115 102
116 virtual void OnCloseRequest() override { 103 void OnCloseRequest() override { platform_window_->Close(); }
117 platform_window_->Close();
118 }
119 104
120 virtual void OnClosed() override { 105 void OnClosed() override { delegate_->OnDestroyed(); }
121 delegate_->OnDestroyed();
122 }
123 106
124 virtual void OnWindowStateChanged(ui::PlatformWindowState state) override { 107 void OnWindowStateChanged(ui::PlatformWindowState state) override {}
125 }
126 108
127 virtual void OnLostCapture() override { 109 void OnLostCapture() override {}
128 }
129 110
130 virtual void OnAcceleratedWidgetAvailable( 111 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override {
131 gfx::AcceleratedWidget widget) override {
132 delegate_->OnAcceleratedWidgetAvailable(widget); 112 delegate_->OnAcceleratedWidgetAvailable(widget);
133 } 113 }
134 114
135 virtual void OnActivationChanged(bool active) override {} 115 void OnActivationChanged(bool active) override {}
136 116
137 scoped_ptr<ui::PlatformEventSource> event_source_; 117 scoped_ptr<ui::PlatformEventSource> event_source_;
138 scoped_ptr<ui::PlatformWindow> platform_window_; 118 scoped_ptr<ui::PlatformWindow> platform_window_;
139 Delegate* delegate_; 119 Delegate* delegate_;
140 gfx::Rect bounds_; 120 gfx::Rect bounds_;
141 121
142 DISALLOW_COPY_AND_ASSIGN(PlatformViewportX11); 122 DISALLOW_COPY_AND_ASSIGN(PlatformViewportX11);
143 }; 123 };
144 124
145 // static 125 // static
146 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) { 126 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) {
147 return scoped_ptr<PlatformViewport>(new PlatformViewportX11(delegate)).Pass(); 127 return scoped_ptr<PlatformViewport>(new PlatformViewportX11(delegate)).Pass();
148 } 128 }
149 129
150 } // namespace mojo 130 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/python/src/python_system_helper.cc ('k') | mojo/services/public/cpp/view_manager/lib/view_manager_test_suite.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698