OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/host/ash_window_tree_host_x11.h" | 5 #include "ash/host/ash_window_tree_host_x11.h" |
6 | 6 |
7 #include <X11/extensions/Xfixes.h> | 7 #include <X11/extensions/Xfixes.h> |
8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "ui/events/event.h" | 26 #include "ui/events/event.h" |
27 #include "ui/events/event_utils.h" | 27 #include "ui/events/event_utils.h" |
28 #include "ui/events/null_event_targeter.h" | 28 #include "ui/events/null_event_targeter.h" |
29 #include "ui/events/platform/platform_event_source.h" | 29 #include "ui/events/platform/platform_event_source.h" |
30 #include "ui/gfx/geometry/rect.h" | 30 #include "ui/gfx/geometry/rect.h" |
31 #include "ui/gfx/screen.h" | 31 #include "ui/gfx/screen.h" |
32 | 32 |
33 namespace ash { | 33 namespace ash { |
34 | 34 |
35 AshWindowTreeHostX11::AshWindowTreeHostX11(const gfx::Rect& initial_bounds) | 35 AshWindowTreeHostX11::AshWindowTreeHostX11(const gfx::Rect& initial_bounds) |
36 : WindowTreeHostX11(initial_bounds), | 36 : WindowTreeHostX11(initial_bounds), transformer_helper_(this) { |
37 transformer_helper_(this), | |
38 display_ids_(std::make_pair(gfx::Display::kInvalidDisplayID, | |
39 gfx::Display::kInvalidDisplayID)) { | |
40 aura::Env::GetInstance()->AddObserver(this); | 37 aura::Env::GetInstance()->AddObserver(this); |
41 } | 38 } |
42 | 39 |
43 AshWindowTreeHostX11::~AshWindowTreeHostX11() { | 40 AshWindowTreeHostX11::~AshWindowTreeHostX11() { |
44 aura::Env::GetInstance()->RemoveObserver(this); | 41 aura::Env::GetInstance()->RemoveObserver(this); |
45 UnConfineCursor(); | 42 UnConfineCursor(); |
46 } | 43 } |
47 | 44 |
48 void AshWindowTreeHostX11::ToggleFullScreen() { NOTIMPLEMENTED(); } | 45 void AshWindowTreeHostX11::ToggleFullScreen() { NOTIMPLEMENTED(); } |
49 | 46 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 ConfineCursorToRootWindow(); | 116 ConfineCursorToRootWindow(); |
120 } | 117 } |
121 } | 118 } |
122 | 119 |
123 gfx::Insets AshWindowTreeHostX11::GetHostInsets() const { | 120 gfx::Insets AshWindowTreeHostX11::GetHostInsets() const { |
124 return transformer_helper_.GetHostInsets(); | 121 return transformer_helper_.GetHostInsets(); |
125 } | 122 } |
126 | 123 |
127 aura::WindowTreeHost* AshWindowTreeHostX11::AsWindowTreeHost() { return this; } | 124 aura::WindowTreeHost* AshWindowTreeHostX11::AsWindowTreeHost() { return this; } |
128 | 125 |
129 void AshWindowTreeHostX11::UpdateDisplayID(int64 id1, int64 id2) { | |
130 display_ids_.first = id1; | |
131 display_ids_.second = id2; | |
132 } | |
133 | |
134 void AshWindowTreeHostX11::PrepareForShutdown() { | 126 void AshWindowTreeHostX11::PrepareForShutdown() { |
135 // Block the root window from dispatching events because it is weird for a | 127 // Block the root window from dispatching events because it is weird for a |
136 // ScreenPositionClient not to be attached to the root window and for | 128 // ScreenPositionClient not to be attached to the root window and for |
137 // ui::EventHandlers to be unable to convert the event's location to screen | 129 // ui::EventHandlers to be unable to convert the event's location to screen |
138 // coordinates. | 130 // coordinates. |
139 window()->SetEventTargeter( | 131 window()->SetEventTargeter( |
140 scoped_ptr<ui::EventTargeter>(new ui::NullEventTargeter)); | 132 scoped_ptr<ui::EventTargeter>(new ui::NullEventTargeter)); |
141 | 133 |
142 if (ui::PlatformEventSource::GetInstance()) { | 134 if (ui::PlatformEventSource::GetInstance()) { |
143 // Block X events which are not turned into ui::Events from getting | 135 // Block X events which are not turned into ui::Events from getting |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 // For touch event, check if the root window is residing on the according | 198 // For touch event, check if the root window is residing on the according |
207 // touch display. | 199 // touch display. |
208 switch (type) { | 200 switch (type) { |
209 case ui::ET_TOUCH_MOVED: | 201 case ui::ET_TOUCH_MOVED: |
210 case ui::ET_TOUCH_PRESSED: | 202 case ui::ET_TOUCH_PRESSED: |
211 case ui::ET_TOUCH_CANCELLED: | 203 case ui::ET_TOUCH_CANCELLED: |
212 case ui::ET_TOUCH_RELEASED: { | 204 case ui::ET_TOUCH_RELEASED: { |
213 #if defined(OS_CHROMEOS) | 205 #if defined(OS_CHROMEOS) |
214 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data); | 206 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data); |
215 int64 touch_display_id = | 207 int64 touch_display_id = |
216 ui::DeviceDataManager::GetInstance()->GetDisplayForTouchDevice( | 208 ui::DeviceDataManager::GetInstance()->GetTargetDisplayForTouchDevice( |
217 xiev->deviceid); | 209 xiev->deviceid); |
218 // If we don't have record of display id for this touch device, check | 210 // If we don't have record of display id for this touch device, check |
219 // that if the event is within the bound of the root window. Note | 211 // that if the event is within the bound of the root window. Note |
220 // that in multi-monitor case, the event position is in framebuffer | 212 // that in multi-monitor case, the event position is in framebuffer |
221 // space so the bounds check will not work so well. | 213 // space so the bounds check will not work so well. |
222 if (touch_display_id == gfx::Display::kInvalidDisplayID) { | 214 if (touch_display_id == gfx::Display::kInvalidDisplayID) { |
223 if (base::SysInfo::IsRunningOnChromeOS() && | 215 if (base::SysInfo::IsRunningOnChromeOS() && |
224 !bounds().Contains(ui::EventLocationFromNative(xev))) | 216 !bounds().Contains(ui::EventLocationFromNative(xev))) |
225 return false; | 217 return false; |
226 } else if (touch_display_id != display_ids_.first && | 218 } else { |
227 touch_display_id != display_ids_.second) { | 219 gfx::Screen* screen = gfx::Screen::GetScreenFor(window()); |
228 return false; | 220 gfx::Display display = screen->GetDisplayNearestWindow(window()); |
| 221 return touch_display_id == display.id(); |
229 } | 222 } |
230 #endif // defined(OS_CHROMEOS) | 223 #endif // defined(OS_CHROMEOS) |
231 return true; | 224 return true; |
232 } | 225 } |
233 default: | 226 default: |
234 return true; | 227 return true; |
235 } | 228 } |
236 } | 229 } |
237 void AshWindowTreeHostX11::TranslateAndDispatchLocatedEvent( | 230 void AshWindowTreeHostX11::TranslateAndDispatchLocatedEvent( |
238 ui::LocatedEvent* event) { | 231 ui::LocatedEvent* event) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 277 } |
285 } | 278 } |
286 #endif | 279 #endif |
287 | 280 |
288 AshWindowTreeHost* AshWindowTreeHost::Create( | 281 AshWindowTreeHost* AshWindowTreeHost::Create( |
289 const AshWindowTreeHostInitParams& init_params) { | 282 const AshWindowTreeHostInitParams& init_params) { |
290 return new AshWindowTreeHostX11(init_params.initial_bounds); | 283 return new AshWindowTreeHostX11(init_params.initial_bounds); |
291 } | 284 } |
292 | 285 |
293 } // namespace ash | 286 } // namespace ash |
OLD | NEW |