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

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: jochen comments (inc. git cl format) 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(
614 const gfx::Display& display,
615 DisplayObserver::DisplayMetrics metrics) {
616 if (!(metrics & (DISPLAY_METRICS_BOUNDS | DISPLAY_METRICS_ROTATION |
617 DISPLAY_METRICS_DEVICE_SCALE_FACTOR)))
618 return;
619
620 const DisplayInfo& display_info =
621 GetDisplayManager()->GetDisplayInfo(display.id());
622 DCHECK(!display_info.bounds_in_native().IsEmpty());
623 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()];
624 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native());
625 SetDisplayPropertiesOnHost(ash_host, display);
626 }
627
621 void DisplayController::OnHostResized(const aura::WindowTreeHost* host) { 628 void DisplayController::OnHostResized(const aura::WindowTreeHost* host) {
622 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( 629 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow(
623 const_cast<aura::Window*>(host->window())); 630 const_cast<aura::Window*>(host->window()));
624 631
625 DisplayManager* display_manager = GetDisplayManager(); 632 DisplayManager* display_manager = GetDisplayManager();
626 if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) { 633 if (display_manager->UpdateDisplayBounds(display.id(), host->GetBounds())) {
627 mirror_window_controller_->UpdateWindow(); 634 mirror_window_controller_->UpdateWindow();
628 cursor_window_controller_->UpdateContainer(); 635 cursor_window_controller_->UpdateContainer();
629 } 636 }
630 } 637 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 std::string name = 755 std::string name =
749 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; 756 root_windows[i] == primary ? "aura_root_0" : "aura_root_x";
750 gfx::AcceleratedWidget xwindow = 757 gfx::AcceleratedWidget xwindow =
751 root_windows[i]->GetHost()->GetAcceleratedWidget(); 758 root_windows[i]->GetHost()->GetAcceleratedWidget();
752 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); 759 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str());
753 } 760 }
754 #endif 761 #endif
755 } 762 }
756 763
757 } // namespace ash 764 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698