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

Side by Side Diff: ash/display/display_controller.cc

Issue 971753008: Do not show the mouse cursor when the display is rotated in TouchView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rotate_display
Patch Set: Created 5 years, 9 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 | « no previous file | ui/aura/window_event_dispatcher.h » ('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/display/display_controller.h" 5 #include "ash/display/display_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <map> 9 #include <map>
10 10
(...skipping 12 matching lines...) Expand all
23 #include "ash/shell.h" 23 #include "ash/shell.h"
24 #include "ash/shell_delegate.h" 24 #include "ash/shell_delegate.h"
25 #include "ash/wm/coordinate_conversion.h" 25 #include "ash/wm/coordinate_conversion.h"
26 #include "base/command_line.h" 26 #include "base/command_line.h"
27 #include "base/stl_util.h" 27 #include "base/stl_util.h"
28 #include "base/strings/stringprintf.h" 28 #include "base/strings/stringprintf.h"
29 #include "base/strings/utf_string_conversions.h" 29 #include "base/strings/utf_string_conversions.h"
30 #include "ui/aura/client/capture_client.h" 30 #include "ui/aura/client/capture_client.h"
31 #include "ui/aura/client/focus_client.h" 31 #include "ui/aura/client/focus_client.h"
32 #include "ui/aura/client/screen_position_client.h" 32 #include "ui/aura/client/screen_position_client.h"
33 #include "ui/aura/env.h"
33 #include "ui/aura/window.h" 34 #include "ui/aura/window.h"
34 #include "ui/aura/window_event_dispatcher.h" 35 #include "ui/aura/window_event_dispatcher.h"
35 #include "ui/aura/window_property.h" 36 #include "ui/aura/window_property.h"
36 #include "ui/aura/window_tracker.h" 37 #include "ui/aura/window_tracker.h"
37 #include "ui/aura/window_tree_host.h" 38 #include "ui/aura/window_tree_host.h"
38 #include "ui/compositor/compositor.h" 39 #include "ui/compositor/compositor.h"
39 #include "ui/compositor/compositor_vsync_manager.h" 40 #include "ui/compositor/compositor_vsync_manager.h"
40 #include "ui/gfx/display.h" 41 #include "ui/gfx/display.h"
41 #include "ui/gfx/screen.h" 42 #include "ui/gfx/screen.h"
42 #include "ui/wm/core/coordinate_conversion.h" 43 #include "ui/wm/core/coordinate_conversion.h"
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 } 580 }
580 } 581 }
581 582
582 gfx::Point target_location_in_root = target_location_in_native; 583 gfx::Point target_location_in_root = target_location_in_native;
583 dst_root_window->GetHost()->ConvertPointFromNativeScreen( 584 dst_root_window->GetHost()->ConvertPointFromNativeScreen(
584 &target_location_in_root); 585 &target_location_in_root);
585 586
586 #if defined(USE_OZONE) 587 #if defined(USE_OZONE)
587 gfx::Point target_location_in_screen = target_location_in_root; 588 gfx::Point target_location_in_screen = target_location_in_root;
588 ::wm::ConvertPointToScreen(dst_root_window, &target_location_in_screen); 589 ::wm::ConvertPointToScreen(dst_root_window, &target_location_in_screen);
589 int64 target_display_id = 590 const gfx::Display& target_display =
590 display_manager->FindDisplayContainingPoint(target_location_in_screen) 591 display_manager->FindDisplayContainingPoint(target_location_in_screen);
591 .id(); 592 int64 target_display_id = target_display.id();
592 593
593 // Do not move the cursor if the cursor's location did not change. This avoids 594 // Do not move the cursor if the cursor's location did not change. This avoids
594 // moving (and showing) the cursor on startup. 595 // moving (and showing) the cursor:
595 // - |cursor_location_in_screen_coords_for_restore_| is checked to ensure that 596 // - At startup.
596 // the cursor is moved when the cursor's native position does not change but 597 // - When the device is rotated in maximized mode.
597 // the scale factor or rotation of the display it is on have changed. 598 // |cursor_display_id_for_restore_| is checked to ensure that the cursor is
598 // - |cursor_display_id_for_restore_| is checked to ensure that the cursor is 599 // moved when the cursor's native position does not change but the display
599 // moved when the cursor's native position and screen position do not change 600 // that it is on has changed. This occurs when swapping the primary display.
600 // but the display that it is on has changed. This occurs when swapping the
601 // primary display.
602 if (target_location_in_native != 601 if (target_location_in_native !=
603 cursor_location_in_native_coords_for_restore_ || 602 cursor_location_in_native_coords_for_restore_ ||
604 target_location_in_screen !=
605 cursor_location_in_screen_coords_for_restore_ ||
606 target_display_id != cursor_display_id_for_restore_) { 603 target_display_id != cursor_display_id_for_restore_) {
607 dst_root_window->MoveCursorTo(target_location_in_root); 604 dst_root_window->MoveCursorTo(target_location_in_root);
605 } else if (target_location_in_screen !=
606 cursor_location_in_screen_coords_for_restore_) {
607 // The cursor's native position did not change but its screen position did
608 // change. This occurs when the scale factor or the rotation of the display
609 // that the cursor is on changes.
610 Shell::GetInstance()->cursor_manager()->SetDisplay(target_display);
611
612 // Dispatch a synthetic mouse move. Synthetic mouse moves do not affect the
613 // cursor's visibility.
sadrul 2015/03/04 00:53:49 Can you update the comment to explain why we want
614 aura::Env::GetInstance()->set_last_mouse_location(
615 target_location_in_screen);
616 dst_root_window->GetHost()->dispatcher()->PostSynthesizeMouseMove();
608 } 617 }
609 #else 618 #else
610 dst_root_window->MoveCursorTo(target_location_in_root); 619 dst_root_window->MoveCursorTo(target_location_in_root);
611 #endif 620 #endif
612 } 621 }
613 622
614 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( 623 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow(
615 const aura::Window* window, 624 const aura::Window* window,
616 const gfx::Insets& insets) { 625 const gfx::Insets& insets) {
617 const aura::Window* root_window = window->GetRootWindow(); 626 const aura::Window* root_window = window->GetRootWindow();
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 std::string name = 849 std::string name =
841 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; 850 root_windows[i] == primary ? "aura_root_0" : "aura_root_x";
842 gfx::AcceleratedWidget xwindow = 851 gfx::AcceleratedWidget xwindow =
843 root_windows[i]->GetHost()->GetAcceleratedWidget(); 852 root_windows[i]->GetHost()->GetAcceleratedWidget();
844 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); 853 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str());
845 } 854 }
846 #endif 855 #endif
847 } 856 }
848 857
849 } // namespace ash 858 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/aura/window_event_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698