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/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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 return false; | 125 return false; |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE { | 129 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE { |
130 if (event->type == ClientMessage) { | 130 if (event->type == ClientMessage) { |
131 Atom protocol = static_cast<Atom>(event->xclient.data.l[0]); | 131 Atom protocol = static_cast<Atom>(event->xclient.data.l[0]); |
132 if (protocol == atom_wm_delete_window_) | 132 if (protocol == atom_wm_delete_window_) |
133 delegate_->OnDestroyed(); | 133 delegate_->OnDestroyed(); |
134 } else if (event->type == KeyPress || event->type == KeyRelease) { | 134 } else if (event->type == KeyPress || event->type == KeyRelease) { |
135 ui::KeyEvent key_event(event, true); | 135 ui::KeyEvent key_event(event, false); |
darin (slow to review)
2014/06/19 05:12:15
heh, I have this in my tree too!
| |
136 delegate_->OnEvent(&key_event); | 136 delegate_->OnEvent(&key_event); |
137 } else if (event->type == ButtonPress || event->type == ButtonRelease || | 137 } else if (event->type == ButtonPress || event->type == ButtonRelease || |
138 event->type == MotionNotify) { | 138 event->type == MotionNotify) { |
139 ui::MouseEvent mouse_event(event); | 139 ui::MouseEvent mouse_event(event); |
140 delegate_->OnEvent(&mouse_event); | 140 delegate_->OnEvent(&mouse_event); |
141 } | 141 } |
142 return ui::POST_DISPATCH_NONE; | 142 return ui::POST_DISPATCH_NONE; |
143 } | 143 } |
144 | 144 |
145 scoped_ptr<ui::PlatformEventSource> event_source_; | 145 scoped_ptr<ui::PlatformEventSource> event_source_; |
146 NativeViewportDelegate* delegate_; | 146 NativeViewportDelegate* delegate_; |
147 gfx::Rect bounds_; | 147 gfx::Rect bounds_; |
148 XID window_; | 148 XID window_; |
149 Atom atom_wm_protocols_; | 149 Atom atom_wm_protocols_; |
150 Atom atom_wm_delete_window_; | 150 Atom atom_wm_delete_window_; |
151 | 151 |
152 DISALLOW_COPY_AND_ASSIGN(NativeViewportX11); | 152 DISALLOW_COPY_AND_ASSIGN(NativeViewportX11); |
153 }; | 153 }; |
154 | 154 |
155 // static | 155 // static |
156 scoped_ptr<NativeViewport> NativeViewport::Create( | 156 scoped_ptr<NativeViewport> NativeViewport::Create( |
157 shell::Context* context, | 157 shell::Context* context, |
158 NativeViewportDelegate* delegate) { | 158 NativeViewportDelegate* delegate) { |
159 return scoped_ptr<NativeViewport>(new NativeViewportX11(delegate)).Pass(); | 159 return scoped_ptr<NativeViewport>(new NativeViewportX11(delegate)).Pass(); |
160 } | 160 } |
161 | 161 |
162 } // namespace services | 162 } // namespace services |
163 } // namespace mojo | 163 } // namespace mojo |
OLD | NEW |