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

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

Issue 259253002: Add OnDisplayMetricsChanged in DisplayObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@update_orientation
Patch Set: Created 6 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/display_controller.h ('k') | ash/display/display_controller_unittest.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/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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( 542 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow(
543 const aura::Window* window, 543 const aura::Window* window,
544 const gfx::Insets& insets) { 544 const gfx::Insets& insets) {
545 const aura::Window* root_window = window->GetRootWindow(); 545 const aura::Window* root_window = window->GetRootWindow();
546 int64 id = GetRootWindowSettings(root_window)->display_id; 546 int64 id = GetRootWindowSettings(root_window)->display_id;
547 // if id is |kInvaildDisplayID|, it's being deleted. 547 // if id is |kInvaildDisplayID|, it's being deleted.
548 DCHECK(id != gfx::Display::kInvalidDisplayID); 548 DCHECK(id != gfx::Display::kInvalidDisplayID);
549 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); 549 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets);
550 } 550 }
551 551
552 void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) {
553 const DisplayInfo& display_info =
554 GetDisplayManager()->GetDisplayInfo(display.id());
555 DCHECK(!display_info.bounds_in_native().IsEmpty());
556 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()];
557 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native());
558 SetDisplayPropertiesOnHost(ash_host, display);
559 }
560
561 void DisplayController::OnDisplayAdded(const gfx::Display& display) { 552 void DisplayController::OnDisplayAdded(const gfx::Display& display) {
562 if (primary_tree_host_for_replace_) { 553 if (primary_tree_host_for_replace_) {
563 DCHECK(window_tree_hosts_.empty()); 554 DCHECK(window_tree_hosts_.empty());
564 primary_display_id = display.id(); 555 primary_display_id = display.id();
565 window_tree_hosts_[display.id()] = primary_tree_host_for_replace_; 556 window_tree_hosts_[display.id()] = primary_tree_host_for_replace_;
566 GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_)) 557 GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_))
567 ->display_id = display.id(); 558 ->display_id = display.id();
568 primary_tree_host_for_replace_ = NULL; 559 primary_tree_host_for_replace_ = NULL;
569 const DisplayInfo& display_info = 560 const DisplayInfo& display_info =
570 GetDisplayManager()->GetDisplayInfo(display.id()); 561 GetDisplayManager()->GetDisplayInfo(display.id());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 596
606 // Delete the other host instead. 597 // Delete the other host instead.
607 host_to_delete = window_tree_hosts_[primary_display_id]; 598 host_to_delete = window_tree_hosts_[primary_display_id];
608 GetRootWindowSettings(GetWindow(host_to_delete))->display_id = display.id(); 599 GetRootWindowSettings(GetWindow(host_to_delete))->display_id = display.id();
609 600
610 // Setup primary root. 601 // Setup primary root.
611 window_tree_hosts_[primary_display_id] = primary_host; 602 window_tree_hosts_[primary_display_id] = primary_host;
612 GetRootWindowSettings(GetWindow(primary_host))->display_id = 603 GetRootWindowSettings(GetWindow(primary_host))->display_id =
613 primary_display_id; 604 primary_display_id;
614 605
615 OnDisplayBoundsChanged( 606 OnDisplayMetricsChanged(
616 GetDisplayManager()->GetDisplayForId(primary_display_id)); 607 GetDisplayManager()->GetDisplayForId(primary_display_id),
608 DISPLAY_METRIC_BOUNDS);
617 } 609 }
618 RootWindowController* controller = 610 RootWindowController* controller =
619 GetRootWindowController(GetWindow(host_to_delete)); 611 GetRootWindowController(GetWindow(host_to_delete));
620 DCHECK(controller); 612 DCHECK(controller);
621 controller->MoveWindowsTo(GetPrimaryRootWindow()); 613 controller->MoveWindowsTo(GetPrimaryRootWindow());
622 // Delete most of root window related objects, but don't delete 614 // Delete most of root window related objects, but don't delete
623 // root window itself yet because the stack may be using it. 615 // root window itself yet because the stack may be using it.
624 controller->Shutdown(); 616 controller->Shutdown();
625 base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller); 617 base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller);
626 } 618 }
627 619
620 void DisplayController::OnDisplayMetricsChanged(const gfx::Display& display,
621 uint32_t metrics) {
622 if (!(metrics & (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_ROTATION |
623 DISPLAY_METRIC_DEVICE_SCALE_FACTOR)))
624 return;
625
626 const DisplayInfo& display_info =
627 GetDisplayManager()->GetDisplayInfo(display.id());
628 DCHECK(!display_info.bounds_in_native().IsEmpty());
629 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()];
630 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native());
631 SetDisplayPropertiesOnHost(ash_host, display);
632 }
633
628 void DisplayController::OnHostResized(const aura::WindowTreeHost* host) { 634 void DisplayController::OnHostResized(const aura::WindowTreeHost* host) {
629 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( 635 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow(
630 const_cast<aura::Window*>(host->window())); 636 const_cast<aura::Window*>(host->window()));
631 637
632 DisplayManager* display_manager = GetDisplayManager(); 638 DisplayManager* display_manager = GetDisplayManager();
633 if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) { 639 if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) {
634 mirror_window_controller_->UpdateWindow(); 640 mirror_window_controller_->UpdateWindow();
635 cursor_window_controller_->UpdateContainer(); 641 cursor_window_controller_->UpdateContainer();
636 } 642 }
637 } 643 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 std::string name = 763 std::string name =
758 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; 764 root_windows[i] == primary ? "aura_root_0" : "aura_root_x";
759 gfx::AcceleratedWidget xwindow = 765 gfx::AcceleratedWidget xwindow =
760 root_windows[i]->GetHost()->GetAcceleratedWidget(); 766 root_windows[i]->GetHost()->GetAcceleratedWidget();
761 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); 767 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str());
762 } 768 }
763 #endif 769 #endif
764 } 770 }
765 771
766 } // namespace ash 772 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_controller.h ('k') | ash/display/display_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698