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

Side by Side Diff: ash/magnifier/partial_magnification_controller.cc

Issue 2686383002: cros: Use runtime stylus detection for ash palette. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « ash/laser/laser_pointer_controller.cc ('k') | ash/shell/shell_delegate_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/magnifier/partial_magnification_controller.h" 5 #include "ash/magnifier/partial_magnification_controller.h"
6 6
7 #include "ash/common/system/chromeos/palette/palette_utils.h" 7 #include "ash/common/system/chromeos/palette/palette_utils.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "third_party/skia/include/core/SkDrawLooper.h" 9 #include "third_party/skia/include/core/SkDrawLooper.h"
10 #include "ui/aura/window_event_dispatcher.h" 10 #include "ui/aura/window_event_dispatcher.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return; 274 return;
275 275
276 // Compute the event location in screen space. 276 // Compute the event location in screen space.
277 aura::Window* target = static_cast<aura::Window*>(event->target()); 277 aura::Window* target = static_cast<aura::Window*>(event->target());
278 aura::Window* event_root = target->GetRootWindow(); 278 aura::Window* event_root = target->GetRootWindow();
279 gfx::Point screen_point = event->root_location(); 279 gfx::Point screen_point = event->root_location();
280 wm::ConvertPointToScreen(event_root, &screen_point); 280 wm::ConvertPointToScreen(event_root, &screen_point);
281 281
282 // If the stylus is pressed on the palette icon or widget, do not activate. 282 // If the stylus is pressed on the palette icon or widget, do not activate.
283 if (event->type() == ui::ET_TOUCH_PRESSED && 283 if (event->type() == ui::ET_TOUCH_PRESSED &&
284 !PaletteContainsPointInScreen(screen_point)) { 284 !palette_utils::PaletteContainsPointInScreen(screen_point)) {
285 SetActive(true); 285 SetActive(true);
286 } 286 }
287 287
288 if (event->type() == ui::ET_TOUCH_RELEASED) 288 if (event->type() == ui::ET_TOUCH_RELEASED)
289 SetActive(false); 289 SetActive(false);
290 290
291 if (!is_active_) 291 if (!is_active_)
292 return; 292 return;
293 293
294 // If the previous root window was detached host_widget_ will be null; 294 // If the previous root window was detached host_widget_ will be null;
295 // reconstruct it. We also need to change the root window if the cursor has 295 // reconstruct it. We also need to change the root window if the cursor has
296 // crossed display boundries. 296 // crossed display boundries.
297 SwitchTargetRootWindowIfNeeded(GetCurrentRootWindow()); 297 SwitchTargetRootWindowIfNeeded(GetCurrentRootWindow());
298 298
299 // If that failed for any reason return. 299 // If that failed for any reason return.
300 if (!host_widget_) { 300 if (!host_widget_) {
301 SetActive(false); 301 SetActive(false);
302 return; 302 return;
303 } 303 }
304 304
305 // Remap point from where it was captured to the display it is actually on. 305 // Remap point from where it was captured to the display it is actually on.
306 gfx::Point point = event->root_location(); 306 gfx::Point point = event->root_location();
307 aura::Window::ConvertPointToTarget( 307 aura::Window::ConvertPointToTarget(
308 event_root, host_widget_->GetNativeView()->GetRootWindow(), &point); 308 event_root, host_widget_->GetNativeView()->GetRootWindow(), &point);
309 host_widget_->SetBounds(GetBounds(point)); 309 host_widget_->SetBounds(GetBounds(point));
310 310
311 // If the stylus is over the palette icon or widget, do not consume the event. 311 // If the stylus is over the palette icon or widget, do not consume the event.
312 if (!PaletteContainsPointInScreen(screen_point)) 312 if (!palette_utils::PaletteContainsPointInScreen(screen_point))
313 event->StopPropagation(); 313 event->StopPropagation();
314 } 314 }
315 315
316 void PartialMagnificationController::CreateMagnifierWindow( 316 void PartialMagnificationController::CreateMagnifierWindow(
317 aura::Window* root_window) { 317 aura::Window* root_window) {
318 if (host_widget_ || !root_window) 318 if (host_widget_ || !root_window)
319 return; 319 return;
320 320
321 root_window->AddObserver(this); 321 root_window->AddObserver(this);
322 322
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 371
372 void PartialMagnificationController::RemoveZoomWidgetObservers() { 372 void PartialMagnificationController::RemoveZoomWidgetObservers() {
373 DCHECK(host_widget_); 373 DCHECK(host_widget_);
374 host_widget_->RemoveObserver(this); 374 host_widget_->RemoveObserver(this);
375 aura::Window* root_window = host_widget_->GetNativeView()->GetRootWindow(); 375 aura::Window* root_window = host_widget_->GetNativeView()->GetRootWindow();
376 DCHECK(root_window); 376 DCHECK(root_window);
377 root_window->RemoveObserver(this); 377 root_window->RemoveObserver(this);
378 } 378 }
379 379
380 } // namespace ash 380 } // namespace ash
OLDNEW
« no previous file with comments | « ash/laser/laser_pointer_controller.cc ('k') | ash/shell/shell_delegate_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698