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

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

Issue 354933002: Connect X11 ConfigureNotify events to Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed X11 support for --start-fullscreen, --start-maximized Created 6 years, 5 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
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/native_viewport.h" 5 #include "mojo/services/native_viewport/native_viewport.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <X11/Xutil.h> 8 #include <X11/Xutil.h>
9 9
10 #include "base/command_line.h"
10 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "mojo/shell/switches.h"
Ben Goodger (Google) 2014/07/08 15:41:57 doesn't look like you need either of these #includ
11 #include "ui/events/event.h" 13 #include "ui/events/event.h"
12 #include "ui/events/event_utils.h" 14 #include "ui/events/event_utils.h"
13 #include "ui/events/platform/platform_event_dispatcher.h" 15 #include "ui/events/platform/platform_event_dispatcher.h"
14 #include "ui/events/platform/platform_event_source.h" 16 #include "ui/events/platform/platform_event_source.h"
15 #include "ui/events/platform/x11/x11_event_source.h" 17 #include "ui/events/platform/x11/x11_event_source.h"
16 #include "ui/gfx/rect.h" 18 #include "ui/gfx/rect.h"
17 #include "ui/gfx/x/x11_types.h" 19 #include "ui/gfx/x/x11_types.h"
18 20
19 namespace mojo { 21 namespace mojo {
20 namespace services { 22 namespace services {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // ui::PlatformEventDispatcher: 128 // ui::PlatformEventDispatcher:
127 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE { 129 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE {
128 // TODO(aa): This is going to have to be thought through more carefully. 130 // TODO(aa): This is going to have to be thought through more carefully.
129 // Which events are appropriate to pass to clients? 131 // Which events are appropriate to pass to clients?
130 switch (event->type) { 132 switch (event->type) {
131 case KeyPress: 133 case KeyPress:
132 case KeyRelease: 134 case KeyRelease:
133 case ButtonPress: 135 case ButtonPress:
134 case ButtonRelease: 136 case ButtonRelease:
135 case MotionNotify: 137 case MotionNotify:
138 case ConfigureNotify:
136 return true; 139 return true;
137 case ClientMessage: 140 case ClientMessage:
138 return event->xclient.message_type == atom_wm_protocols_; 141 return event->xclient.message_type == atom_wm_protocols_;
139 default: 142 default:
140 return false; 143 return false;
141 } 144 }
142 } 145 }
143 146
144 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE { 147 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE {
145 if (event->type == ClientMessage) { 148 if (event->type == ClientMessage) {
146 Atom protocol = static_cast<Atom>(event->xclient.data.l[0]); 149 Atom protocol = static_cast<Atom>(event->xclient.data.l[0]);
147 if (protocol == atom_wm_delete_window_) 150 if (protocol == atom_wm_delete_window_)
148 delegate_->OnDestroyed(); 151 delegate_->OnDestroyed();
149 } else if (event->type == KeyPress || event->type == KeyRelease) { 152 } else if (event->type == KeyPress || event->type == KeyRelease) {
150 ui::KeyEvent key_event(event, false); 153 ui::KeyEvent key_event(event, false);
151 delegate_->OnEvent(&key_event); 154 delegate_->OnEvent(&key_event);
152 } else if (event->type == ButtonPress || event->type == ButtonRelease || 155 } else if (event->type == ButtonPress || event->type == ButtonRelease ||
153 event->type == MotionNotify) { 156 event->type == MotionNotify) {
154 ui::EventType event_type = ui::EventTypeFromNative(event); 157 ui::EventType event_type = ui::EventTypeFromNative(event);
155 if (event_type == ui::ET_MOUSEWHEEL) { 158 if (event_type == ui::ET_MOUSEWHEEL) {
156 ui::MouseWheelEvent mouse_event(event); 159 ui::MouseWheelEvent mouse_event(event);
157 delegate_->OnEvent(&mouse_event); 160 delegate_->OnEvent(&mouse_event);
158 } else { 161 } else {
159 ui::MouseEvent mouse_event(event); 162 ui::MouseEvent mouse_event(event);
160 delegate_->OnEvent(&mouse_event); 163 delegate_->OnEvent(&mouse_event);
161 } 164 }
165 } else if (event->type == ConfigureNotify) {
166 bounds_ = gfx::Rect(event->xconfigure.width, event->xconfigure.height);
167 delegate_->OnBoundsChanged(bounds_);
162 } 168 }
163 return ui::POST_DISPATCH_NONE; 169 return ui::POST_DISPATCH_NONE;
164 } 170 }
165 171
166 scoped_ptr<ui::PlatformEventSource> event_source_; 172 scoped_ptr<ui::PlatformEventSource> event_source_;
167 NativeViewportDelegate* delegate_; 173 NativeViewportDelegate* delegate_;
168 gfx::Rect bounds_; 174 gfx::Rect bounds_;
169 XID window_; 175 XID window_;
170 Atom atom_wm_protocols_; 176 Atom atom_wm_protocols_;
171 Atom atom_wm_delete_window_; 177 Atom atom_wm_delete_window_;
172 178
173 DISALLOW_COPY_AND_ASSIGN(NativeViewportX11); 179 DISALLOW_COPY_AND_ASSIGN(NativeViewportX11);
174 }; 180 };
175 181
176 // static 182 // static
177 scoped_ptr<NativeViewport> NativeViewport::Create( 183 scoped_ptr<NativeViewport> NativeViewport::Create(
178 shell::Context* context, 184 shell::Context* context,
179 NativeViewportDelegate* delegate) { 185 NativeViewportDelegate* delegate) {
180 return scoped_ptr<NativeViewport>(new NativeViewportX11(delegate)).Pass(); 186 return scoped_ptr<NativeViewport>(new NativeViewportX11(delegate)).Pass();
181 } 187 }
182 188
183 } // namespace services 189 } // namespace services
184 } // namespace mojo 190 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698