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

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

Issue 2840043003: chromeos: Makes mushrome use simplified display management (Closed)
Patch Set: merge Created 3 years, 7 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/display/mirror_window_controller.cc ('k') | ash/host/transformer_helper.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/window_tree_host_manager.h" 5 #include "ash/display/window_tree_host_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 // that it is on has changed. This occurs when swapping the primary display. 517 // that it is on has changed. This occurs when swapping the primary display.
518 if (target_location_in_native != 518 if (target_location_in_native !=
519 cursor_location_in_native_coords_for_restore_ || 519 cursor_location_in_native_coords_for_restore_ ||
520 target_display_id != cursor_display_id_for_restore_) { 520 target_display_id != cursor_display_id_for_restore_) {
521 dst_root_window->MoveCursorTo(target_location_in_root); 521 dst_root_window->MoveCursorTo(target_location_in_root);
522 } else if (target_location_in_screen != 522 } else if (target_location_in_screen !=
523 cursor_location_in_screen_coords_for_restore_) { 523 cursor_location_in_screen_coords_for_restore_) {
524 // The cursor's native position did not change but its screen position did 524 // The cursor's native position did not change but its screen position did
525 // change. This occurs when the scale factor or the rotation of the display 525 // change. This occurs when the scale factor or the rotation of the display
526 // that the cursor is on changes. 526 // that the cursor is on changes.
527 Shell::Get()->cursor_manager()->SetDisplay(target_display); 527 // TODO: conditional should not be necessary. http://crbug.com/631103.
528 if (Shell::Get()->cursor_manager())
529 Shell::Get()->cursor_manager()->SetDisplay(target_display);
528 530
529 // Update the cursor's root location. This ends up dispatching a synthetic 531 // Update the cursor's root location. This ends up dispatching a synthetic
530 // mouse move. The synthetic mouse move updates the composited cursor's 532 // mouse move. The synthetic mouse move updates the composited cursor's
531 // location and hover effects. Synthetic mouse moves do not affect the 533 // location and hover effects. Synthetic mouse moves do not affect the
532 // cursor's visibility. 534 // cursor's visibility.
533 dst_root_window->GetHost()->dispatcher()->OnCursorMovedToRootLocation( 535 dst_root_window->GetHost()->dispatcher()->OnCursorMovedToRootLocation(
534 target_location_in_root); 536 target_location_in_root);
535 } 537 }
536 #else 538 #else
537 dst_root_window->MoveCursorTo(target_location_in_root); 539 dst_root_window->MoveCursorTo(target_location_in_root);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 AshWindowTreeHost* WindowTreeHostManager::AddWindowTreeHostForDisplay( 808 AshWindowTreeHost* WindowTreeHostManager::AddWindowTreeHostForDisplay(
807 const display::Display& display, 809 const display::Display& display,
808 const AshWindowTreeHostInitParams& init_params) { 810 const AshWindowTreeHostInitParams& init_params) {
809 static int host_count = 0; 811 static int host_count = 0;
810 const display::ManagedDisplayInfo& display_info = 812 const display::ManagedDisplayInfo& display_info =
811 GetDisplayManager()->GetDisplayInfo(display.id()); 813 GetDisplayManager()->GetDisplayInfo(display.id());
812 AshWindowTreeHostInitParams params_with_bounds(init_params); 814 AshWindowTreeHostInitParams params_with_bounds(init_params);
813 params_with_bounds.initial_bounds = display_info.bounds_in_native(); 815 params_with_bounds.initial_bounds = display_info.bounds_in_native();
814 params_with_bounds.offscreen = 816 params_with_bounds.offscreen =
815 display.id() == display::DisplayManager::kUnifiedDisplayId; 817 display.id() == display::DisplayManager::kUnifiedDisplayId;
818 params_with_bounds.display_id = display.id();
819 params_with_bounds.device_scale_factor = display.device_scale_factor();
820 params_with_bounds.ui_scale_factor = display_info.configured_ui_scale();
816 // The AshWindowTreeHost ends up owned by the RootWindowControllers created 821 // The AshWindowTreeHost ends up owned by the RootWindowControllers created
817 // by this class. 822 // by this class.
818 AshWindowTreeHost* ash_host = 823 AshWindowTreeHost* ash_host =
819 AshWindowTreeHost::Create(params_with_bounds).release(); 824 AshWindowTreeHost::Create(params_with_bounds).release();
820 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); 825 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost();
821 if (!input_method_) { // Singleton input method instance for Ash. 826 // TODO: Config::MUS should not install an InputMethod.
822 input_method_ = ui::CreateInputMethod(this, host->GetAcceleratedWidget()); 827 // http://crbug.com/706913
823 // Makes sure the input method is focused by default when created, because 828 if (!host->has_input_method()) {
824 // Ash uses singleton InputMethod and it won't call OnFocus/OnBlur when the 829 if (!input_method_) { // Singleton input method instance for Ash.
825 // active window changed. 830 input_method_ = ui::CreateInputMethod(this, host->GetAcceleratedWidget());
826 input_method_->OnFocus(); 831 // Makes sure the input method is focused by default when created, because
827 input_method_event_handler_.reset( 832 // Ash uses singleton InputMethod and it won't call OnFocus/OnBlur when
828 new InputMethodEventHandler(input_method_.get())); 833 // the active window changed.
834 input_method_->OnFocus();
835 input_method_event_handler_.reset(
836 new InputMethodEventHandler(input_method_.get()));
837 }
838 host->SetSharedInputMethod(input_method_.get());
839 ash_host->set_input_method_handler(input_method_event_handler_.get());
829 } 840 }
830 host->SetSharedInputMethod(input_method_.get());
831 ash_host->set_input_method_handler(input_method_event_handler_.get());
832 841
833 host->window()->SetName(base::StringPrintf( 842 host->window()->SetName(base::StringPrintf(
834 "%sRootWindow-%d", params_with_bounds.offscreen ? "Offscreen" : "", 843 "%sRootWindow-%d", params_with_bounds.offscreen ? "Offscreen" : "",
835 host_count++)); 844 host_count++));
836 host->window()->SetTitle(base::UTF8ToUTF16(display_info.name())); 845 host->window()->SetTitle(base::UTF8ToUTF16(display_info.name()));
837 host->compositor()->SetBackgroundColor(SK_ColorBLACK); 846 host->compositor()->SetBackgroundColor(SK_ColorBLACK);
838 // No need to remove our observer observer because the WindowTreeHostManager 847 // No need to remove our observer observer because the WindowTreeHostManager
839 // outlives the host. 848 // outlives the host.
840 host->AddObserver(this); 849 host->AddObserver(this);
841 InitRootWindowSettings(host->window())->display_id = display.id(); 850 InitRootWindowSettings(host->window())->display_id = display.id();
842 host->InitHost(); 851 host->InitHost();
843 host->window()->Show(); 852 host->window()->Show();
844 853
845 window_tree_hosts_[display.id()] = ash_host; 854 window_tree_hosts_[display.id()] = ash_host;
846 SetDisplayPropertiesOnHost(ash_host, display); 855 SetDisplayPropertiesOnHost(ash_host, display);
847 856
848 if (switches::ConstrainPointerToRoot()) 857 if (switches::ConstrainPointerToRoot())
849 ash_host->ConfineCursorToRootWindow(); 858 ash_host->ConfineCursorToRootWindow();
850 return ash_host; 859 return ash_host;
851 } 860 }
852 861
853 } // namespace ash 862 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/mirror_window_controller.cc ('k') | ash/host/transformer_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698