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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 gfx::Transform AshWindowTreeHostX11::GetInverseRootTransform() const { | 148 gfx::Transform AshWindowTreeHostX11::GetInverseRootTransform() const { |
149 return transformer_helper_.GetInverseTransform(); | 149 return transformer_helper_.GetInverseTransform(); |
150 } | 150 } |
151 | 151 |
152 void AshWindowTreeHostX11::UpdateRootWindowSize(const gfx::Size& host_size) { | 152 void AshWindowTreeHostX11::UpdateRootWindowSize(const gfx::Size& host_size) { |
153 transformer_helper_.UpdateWindowSize(host_size); | 153 transformer_helper_.UpdateWindowSize(host_size); |
154 } | 154 } |
155 | 155 |
156 void AshWindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { | 156 void AshWindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) { |
| 157 #if defined(OS_CHROMEOS) |
157 SetCrOSTapPaused(!show); | 158 SetCrOSTapPaused(!show); |
| 159 #endif |
158 } | 160 } |
159 | 161 |
160 void AshWindowTreeHostX11::OnWindowInitialized(aura::Window* window) {} | 162 void AshWindowTreeHostX11::OnWindowInitialized(aura::Window* window) {} |
161 | 163 |
162 void AshWindowTreeHostX11::OnHostInitialized(aura::WindowTreeHost* host) { | 164 void AshWindowTreeHostX11::OnHostInitialized(aura::WindowTreeHost* host) { |
163 if (host != AsWindowTreeHost()) | 165 if (host != AsWindowTreeHost()) |
164 return; | 166 return; |
165 | 167 |
| 168 #if defined(OS_CHROMEOS) |
166 // We have to enable Tap-to-click by default because the cursor is set to | 169 // We have to enable Tap-to-click by default because the cursor is set to |
167 // visible in Shell::InitRootWindowController. | 170 // visible in Shell::InitRootWindowController. |
168 SetCrOSTapPaused(false); | 171 SetCrOSTapPaused(false); |
| 172 #endif |
169 } | 173 } |
170 | 174 |
171 void AshWindowTreeHostX11::OnConfigureNotify() { | 175 void AshWindowTreeHostX11::OnConfigureNotify() { |
172 // Always update barrier and mouse location because |bounds_| might | 176 // Always update barrier and mouse location because |bounds_| might |
173 // have already been updated in |SetBounds|. | 177 // have already been updated in |SetBounds|. |
174 if (pointer_barriers_) { | 178 if (pointer_barriers_) { |
175 UnConfineCursor(); | 179 UnConfineCursor(); |
176 ConfineCursorToRootWindow(); | 180 ConfineCursorToRootWindow(); |
177 } | 181 } |
178 } | 182 } |
179 | 183 |
180 bool AshWindowTreeHostX11::CanDispatchEvent(const ui::PlatformEvent& event) { | 184 bool AshWindowTreeHostX11::CanDispatchEvent(const ui::PlatformEvent& event) { |
181 if(!WindowTreeHostX11::CanDispatchEvent(event)) | 185 if(!WindowTreeHostX11::CanDispatchEvent(event)) |
182 return false; | 186 return false; |
183 XEvent* xev = event; | 187 XEvent* xev = event; |
184 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data); | |
185 ui::EventType type = ui::EventTypeFromNative(xev); | 188 ui::EventType type = ui::EventTypeFromNative(xev); |
186 // For touch event, check if the root window is residing on the according | 189 // For touch event, check if the root window is residing on the according |
187 // touch display. | 190 // touch display. |
188 switch (type) { | 191 switch (type) { |
189 case ui::ET_TOUCH_MOVED: | 192 case ui::ET_TOUCH_MOVED: |
190 case ui::ET_TOUCH_PRESSED: | 193 case ui::ET_TOUCH_PRESSED: |
191 case ui::ET_TOUCH_CANCELLED: | 194 case ui::ET_TOUCH_CANCELLED: |
192 case ui::ET_TOUCH_RELEASED: { | 195 case ui::ET_TOUCH_RELEASED: { |
193 #if defined(OS_CHROMEOS) | 196 #if defined(OS_CHROMEOS) |
| 197 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data); |
194 int64 touch_display_id = | 198 int64 touch_display_id = |
195 ui::DeviceDataManager::GetInstance()->GetDisplayForTouchDevice( | 199 ui::DeviceDataManager::GetInstance()->GetDisplayForTouchDevice( |
196 xiev->deviceid); | 200 xiev->deviceid); |
197 // If we don't have record of display id for this touch device, check | 201 // If we don't have record of display id for this touch device, check |
198 // that if the event is within the bound of the root window. Note | 202 // that if the event is within the bound of the root window. Note |
199 // that in multi-monitor case, the event position is in framebuffer | 203 // that in multi-monitor case, the event position is in framebuffer |
200 // space so the bounds check will not work so well. | 204 // space so the bounds check will not work so well. |
201 if (touch_display_id == gfx::Display::kInvalidDisplayID) { | 205 if (touch_display_id == gfx::Display::kInvalidDisplayID) { |
202 if (base::SysInfo::IsRunningOnChromeOS() && | 206 if (base::SysInfo::IsRunningOnChromeOS() && |
203 !bounds().Contains(ui::EventLocationFromNative(xev))) | 207 !bounds().Contains(ui::EventLocationFromNative(xev))) |
(...skipping 28 matching lines...) Expand all Loading... |
232 &location); | 236 &location); |
233 screen_position_client->ConvertPointFromScreen(root_window, &location); | 237 screen_position_client->ConvertPointFromScreen(root_window, &location); |
234 ConvertPointToHost(&location); | 238 ConvertPointToHost(&location); |
235 event->set_location(location); | 239 event->set_location(location); |
236 event->set_root_location(location); | 240 event->set_root_location(location); |
237 } | 241 } |
238 } | 242 } |
239 SendEventToProcessor(event); | 243 SendEventToProcessor(event); |
240 } | 244 } |
241 | 245 |
| 246 #if defined(OS_CHROMEOS) |
242 void AshWindowTreeHostX11::SetCrOSTapPaused(bool state) { | 247 void AshWindowTreeHostX11::SetCrOSTapPaused(bool state) { |
243 if (!ui::IsXInput2Available()) | 248 if (!ui::IsXInput2Available()) |
244 return; | 249 return; |
245 // Temporarily pause tap-to-click when the cursor is hidden. | 250 // Temporarily pause tap-to-click when the cursor is hidden. |
246 Atom prop = atom_cache()->GetAtom("Tap Paused"); | 251 Atom prop = atom_cache()->GetAtom("Tap Paused"); |
247 unsigned char value = state; | 252 unsigned char value = state; |
248 XIDeviceList dev_list = | 253 XIDeviceList dev_list = |
249 ui::DeviceListCacheX::GetInstance()->GetXI2DeviceList(xdisplay()); | 254 ui::DeviceListCacheX::GetInstance()->GetXI2DeviceList(xdisplay()); |
250 | 255 |
251 // Only slave pointer devices could possibly have tap-paused property. | 256 // Only slave pointer devices could possibly have tap-paused property. |
(...skipping 22 matching lines...) Expand all Loading... |
274 dev_list[i].deviceid, | 279 dev_list[i].deviceid, |
275 prop, | 280 prop, |
276 XA_INTEGER, | 281 XA_INTEGER, |
277 8, | 282 8, |
278 PropModeReplace, | 283 PropModeReplace, |
279 &value, | 284 &value, |
280 1); | 285 1); |
281 } | 286 } |
282 } | 287 } |
283 } | 288 } |
| 289 #endif |
284 | 290 |
285 AshWindowTreeHost* AshWindowTreeHost::Create( | 291 AshWindowTreeHost* AshWindowTreeHost::Create( |
286 const AshWindowTreeHostInitParams& init_params) { | 292 const AshWindowTreeHostInitParams& init_params) { |
287 return new AshWindowTreeHostX11(init_params.initial_bounds); | 293 return new AshWindowTreeHostX11(init_params.initial_bounds); |
288 } | 294 } |
289 | 295 |
290 } // namespace ash | 296 } // namespace ash |
OLD | NEW |