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

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

Issue 184903003: Window ownership -> WindowTreeHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ash/display/cursor_window_controller.cc ('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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // We don't care about actual distance, only relative to other displays, so 510 // We don't care about actual distance, only relative to other displays, so
511 // using the LengthSquared() is cheaper than Length(). 511 // using the LengthSquared() is cheaper than Length().
512 512
513 int64 distance_squared = (center - point_in_screen).LengthSquared(); 513 int64 distance_squared = (center - point_in_screen).LengthSquared();
514 if (closest_distance_squared < 0 || 514 if (closest_distance_squared < 0 ||
515 closest_distance_squared > distance_squared) { 515 closest_distance_squared > distance_squared) {
516 aura::Window* root_window = GetRootWindowForDisplayId(display.id()); 516 aura::Window* root_window = GetRootWindowForDisplayId(display.id());
517 aura::client::ScreenPositionClient* client = 517 aura::client::ScreenPositionClient* client =
518 aura::client::GetScreenPositionClient(root_window); 518 aura::client::GetScreenPositionClient(root_window);
519 client->ConvertPointFromScreen(root_window, &center); 519 client->ConvertPointFromScreen(root_window, &center);
520 root_window->GetDispatcher()->host()->ConvertPointToNativeScreen(&center); 520 root_window->GetHost()->ConvertPointToNativeScreen(&center);
521 dst_root_window = root_window; 521 dst_root_window = root_window;
522 target_location_in_native = center; 522 target_location_in_native = center;
523 closest_distance_squared = distance_squared; 523 closest_distance_squared = distance_squared;
524 } 524 }
525 } 525 }
526 dst_root_window->GetDispatcher()->host()->ConvertPointFromNativeScreen( 526 dst_root_window->GetHost()->ConvertPointFromNativeScreen(
527 &target_location_in_native); 527 &target_location_in_native);
528 dst_root_window->MoveCursorTo(target_location_in_native); 528 dst_root_window->MoveCursorTo(target_location_in_native);
529 } 529 }
530 530
531 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( 531 bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow(
532 const aura::Window* window, 532 const aura::Window* window,
533 const gfx::Insets& insets) { 533 const gfx::Insets& insets) {
534 const aura::Window* root_window = window->GetRootWindow(); 534 const aura::Window* root_window = window->GetRootWindow();
535 int64 id = internal::GetRootWindowSettings(root_window)->display_id; 535 int64 id = internal::GetRootWindowSettings(root_window)->display_id;
536 // if id is |kInvaildDisplayID|, it's being deleted. 536 // if id is |kInvaildDisplayID|, it's being deleted.
537 DCHECK(id != gfx::Display::kInvalidDisplayID); 537 DCHECK(id != gfx::Display::kInvalidDisplayID);
538 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); 538 return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets);
539 } 539 }
540 540
541 void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) { 541 void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) {
542 const internal::DisplayInfo& display_info = 542 const internal::DisplayInfo& display_info =
543 GetDisplayManager()->GetDisplayInfo(display.id()); 543 GetDisplayManager()->GetDisplayInfo(display.id());
544 DCHECK(!display_info.bounds_in_native().IsEmpty()); 544 DCHECK(!display_info.bounds_in_native().IsEmpty());
545 aura::WindowEventDispatcher* dispatcher = 545 aura::WindowTreeHost* host = root_windows_[display.id()]->GetHost();
546 root_windows_[display.id()]->GetDispatcher(); 546 host->SetBounds(display_info.bounds_in_native());
547 dispatcher->host()->SetBounds(display_info.bounds_in_native()); 547 SetDisplayPropertiesOnHost(host, display);
548 SetDisplayPropertiesOnHost(dispatcher->host(), display);
549 } 548 }
550 549
551 void DisplayController::OnDisplayAdded(const gfx::Display& display) { 550 void DisplayController::OnDisplayAdded(const gfx::Display& display) {
552 if (primary_root_window_for_replace_) { 551 if (primary_root_window_for_replace_) {
553 DCHECK(root_windows_.empty()); 552 DCHECK(root_windows_.empty());
554 primary_display_id = display.id(); 553 primary_display_id = display.id();
555 root_windows_[display.id()] = primary_root_window_for_replace_; 554 root_windows_[display.id()] = primary_root_window_for_replace_;
556 internal::GetRootWindowSettings(primary_root_window_for_replace_)-> 555 internal::GetRootWindowSettings(primary_root_window_for_replace_)->
557 display_id = display.id(); 556 display_id = display.id();
558 primary_root_window_for_replace_ = NULL; 557 primary_root_window_for_replace_ = NULL;
559 const internal::DisplayInfo& display_info = 558 const internal::DisplayInfo& display_info =
560 GetDisplayManager()->GetDisplayInfo(display.id()); 559 GetDisplayManager()->GetDisplayInfo(display.id());
561 aura::WindowEventDispatcher* dispatcher = 560 aura::WindowTreeHost* host = root_windows_[display.id()]->GetHost();
562 root_windows_[display.id()]->GetDispatcher(); 561 host->SetBounds(display_info.bounds_in_native());
563 dispatcher->host()->SetBounds(display_info.bounds_in_native()); 562 SetDisplayPropertiesOnHost(host, display);
564 SetDisplayPropertiesOnHost(dispatcher->host(), display);
565 } else { 563 } else {
566 if (primary_display_id == gfx::Display::kInvalidDisplayID) 564 if (primary_display_id == gfx::Display::kInvalidDisplayID)
567 primary_display_id = display.id(); 565 primary_display_id = display.id();
568 DCHECK(!root_windows_.empty()); 566 DCHECK(!root_windows_.empty());
569 aura::WindowTreeHost* host = AddWindowTreeHostForDisplay(display); 567 aura::WindowTreeHost* host = AddWindowTreeHostForDisplay(display);
570 internal::RootWindowController::CreateForSecondaryDisplay(host); 568 internal::RootWindowController::CreateForSecondaryDisplay(host);
571 } 569 }
572 } 570 }
573 571
574 void DisplayController::OnDisplayRemoved(const gfx::Display& display) { 572 void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging()); 655 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging());
658 focus_activation_store_->Store(clear_focus); 656 focus_activation_store_->Store(clear_focus);
659 gfx::Screen* screen = Shell::GetScreen(); 657 gfx::Screen* screen = Shell::GetScreen();
660 gfx::Point point_in_screen = screen->GetCursorScreenPoint(); 658 gfx::Point point_in_screen = screen->GetCursorScreenPoint();
661 gfx::Display display = screen->GetDisplayNearestPoint(point_in_screen); 659 gfx::Display display = screen->GetDisplayNearestPoint(point_in_screen);
662 aura::Window* root_window = GetRootWindowForDisplayId(display.id()); 660 aura::Window* root_window = GetRootWindowForDisplayId(display.id());
663 661
664 aura::client::ScreenPositionClient* client = 662 aura::client::ScreenPositionClient* client =
665 aura::client::GetScreenPositionClient(root_window); 663 aura::client::GetScreenPositionClient(root_window);
666 client->ConvertPointFromScreen(root_window, &point_in_screen); 664 client->ConvertPointFromScreen(root_window, &point_in_screen);
667 root_window->GetDispatcher()->host()->ConvertPointToNativeScreen( 665 root_window->GetHost()->ConvertPointToNativeScreen(&point_in_screen);
668 &point_in_screen);
669 cursor_location_in_native_coords_for_restore_ = point_in_screen; 666 cursor_location_in_native_coords_for_restore_ = point_in_screen;
670 } 667 }
671 668
672 void DisplayController::PostDisplayConfigurationChange() { 669 void DisplayController::PostDisplayConfigurationChange() {
673 if (limiter_) 670 if (limiter_)
674 limiter_->SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs); 671 limiter_->SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs);
675 672
676 focus_activation_store_->Restore(); 673 focus_activation_store_->Restore();
677 674
678 internal::DisplayManager* display_manager = GetDisplayManager(); 675 internal::DisplayManager* display_manager = GetDisplayManager();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 #if defined(USE_X11) 738 #if defined(USE_X11)
742 // crbug.com/120229 - set the window title for the primary dislpay 739 // crbug.com/120229 - set the window title for the primary dislpay
743 // to "aura_root_0" so gtalk can find the primary root window to broadcast. 740 // to "aura_root_0" so gtalk can find the primary root window to broadcast.
744 // TODO(jhorwich) Remove this once Chrome supports window-based broadcasting. 741 // TODO(jhorwich) Remove this once Chrome supports window-based broadcasting.
745 aura::Window* primary = Shell::GetPrimaryRootWindow(); 742 aura::Window* primary = Shell::GetPrimaryRootWindow();
746 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 743 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
747 for (size_t i = 0; i < root_windows.size(); ++i) { 744 for (size_t i = 0; i < root_windows.size(); ++i) {
748 std::string name = 745 std::string name =
749 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; 746 root_windows[i] == primary ? "aura_root_0" : "aura_root_x";
750 gfx::AcceleratedWidget xwindow = 747 gfx::AcceleratedWidget xwindow =
751 root_windows[i]->GetDispatcher()->host()->GetAcceleratedWidget(); 748 root_windows[i]->GetHost()->GetAcceleratedWidget();
752 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); 749 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str());
753 } 750 }
754 #endif 751 #endif
755 } 752 }
756 753
757 } // namespace ash 754 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/cursor_window_controller.cc ('k') | ash/display/display_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698