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

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
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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( 536 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow(
537 const aura::Window* window, 537 const aura::Window* window,
538 const gfx::Insets& insets) { 538 const gfx::Insets& insets) {
539 const aura::Window* root_window = window->GetRootWindow(); 539 const aura::Window* root_window = window->GetRootWindow();
540 int64 id = GetRootWindowSettings(root_window)->display_id; 540 int64 id = GetRootWindowSettings(root_window)->display_id;
541 // if id is |kInvaildDisplayID|, it's being deleted. 541 // if id is |kInvaildDisplayID|, it's being deleted.
542 DCHECK(id != gfx::Display::kInvalidDisplayID); 542 DCHECK(id != gfx::Display::kInvalidDisplayID);
543 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); 543 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets);
544 } 544 }
545 545
546 void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) {
547 const DisplayInfo& display_info =
548 GetDisplayManager()->GetDisplayInfo(display.id());
549 DCHECK(!display_info.bounds_in_native().IsEmpty());
550 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()];
551 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native());
552 SetDisplayPropertiesOnHost(ash_host, display);
553 }
554
555 void DisplayController::OnDisplayAdded(const gfx::Display& display) { 546 void DisplayController::OnDisplayAdded(const gfx::Display& display) {
556 if (primary_tree_host_for_replace_) { 547 if (primary_tree_host_for_replace_) {
557 DCHECK(window_tree_hosts_.empty()); 548 DCHECK(window_tree_hosts_.empty());
558 primary_display_id = display.id(); 549 primary_display_id = display.id();
559 window_tree_hosts_[display.id()] = primary_tree_host_for_replace_; 550 window_tree_hosts_[display.id()] = primary_tree_host_for_replace_;
560 GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_)) 551 GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_))
561 ->display_id = display.id(); 552 ->display_id = display.id();
562 primary_tree_host_for_replace_ = NULL; 553 primary_tree_host_for_replace_ = NULL;
563 const DisplayInfo& display_info = 554 const DisplayInfo& display_info =
564 GetDisplayManager()->GetDisplayInfo(display.id()); 555 GetDisplayManager()->GetDisplayInfo(display.id());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 589
599 // Delete the other host instead. 590 // Delete the other host instead.
600 host_to_delete = window_tree_hosts_[primary_display_id]; 591 host_to_delete = window_tree_hosts_[primary_display_id];
601 GetRootWindowSettings(GetWindow(host_to_delete))->display_id = display.id(); 592 GetRootWindowSettings(GetWindow(host_to_delete))->display_id = display.id();
602 593
603 // Setup primary root. 594 // Setup primary root.
604 window_tree_hosts_[primary_display_id] = primary_host; 595 window_tree_hosts_[primary_display_id] = primary_host;
605 GetRootWindowSettings(GetWindow(primary_host))->display_id = 596 GetRootWindowSettings(GetWindow(primary_host))->display_id =
606 primary_display_id; 597 primary_display_id;
607 598
608 OnDisplayBoundsChanged( 599 OnDisplayMetricsChanged(
609 GetDisplayManager()->GetDisplayForId(primary_display_id)); 600 GetDisplayManager()->GetDisplayForId(primary_display_id),
601 DISPLAY_METRICS_BOUNDS);
610 } 602 }
611 RootWindowController* controller = 603 RootWindowController* controller =
612 GetRootWindowController(GetWindow(host_to_delete)); 604 GetRootWindowController(GetWindow(host_to_delete));
613 DCHECK(controller); 605 DCHECK(controller);
614 controller->MoveWindowsTo(GetPrimaryRootWindow()); 606 controller->MoveWindowsTo(GetPrimaryRootWindow());
615 // Delete most of root window related objects, but don't delete 607 // Delete most of root window related objects, but don't delete
616 // root window itself yet because the stack may be using it. 608 // root window itself yet because the stack may be using it.
617 controller->Shutdown(); 609 controller->Shutdown();
618 base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller); 610 base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller);
619 } 611 }
620 612
613 void DisplayController::OnDisplayMetricsChanged(const gfx::Display& display,
614 DisplayObserver::DisplayMetrics metrics) {
615 if (!(metrics & (DISPLAY_METRICS_BOUNDS | DISPLAY_METRICS_ROTATION |
616 DISPLAY_METRICS_DEVICE_SCALE_FACTOR)))
617 return;
618
619 const DisplayInfo& display_info =
620 GetDisplayManager()->GetDisplayInfo(display.id());
621 DCHECK(!display_info.bounds_in_native().IsEmpty());
622 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()];
623 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native());
624 SetDisplayPropertiesOnHost(ash_host, display);
625 }
626
621 void DisplayController::OnHostResized(const aura::WindowTreeHost* host) { 627 void DisplayController::OnHostResized(const aura::WindowTreeHost* host) {
622 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( 628 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow(
623 const_cast<aura::Window*>(host->window())); 629 const_cast<aura::Window*>(host->window()));
624 630
625 DisplayManager* display_manager = GetDisplayManager(); 631 DisplayManager* display_manager = GetDisplayManager();
626 if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) { 632 if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) {
627 mirror_window_controller_->UpdateWindow(); 633 mirror_window_controller_->UpdateWindow();
628 cursor_window_controller_->UpdateContainer(); 634 cursor_window_controller_->UpdateContainer();
629 } 635 }
630 } 636 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 std::string name = 754 std::string name =
749 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; 755 root_windows[i] == primary ? "aura_root_0" : "aura_root_x";
750 gfx::AcceleratedWidget xwindow = 756 gfx::AcceleratedWidget xwindow =
751 root_windows[i]->GetHost()->GetAcceleratedWidget(); 757 root_windows[i]->GetHost()->GetAcceleratedWidget();
752 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); 758 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str());
753 } 759 }
754 #endif 760 #endif
755 } 761 }
756 762
757 } // namespace ash 763 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698