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

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

Issue 738243002: Notify primary display reassignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 const DisplayLayout layout = GetCurrentDisplayLayout(); 338 const DisplayLayout layout = GetCurrentDisplayLayout();
339 UpdateDisplayBoundsForLayoutById( 339 UpdateDisplayBoundsForLayoutById(
340 layout, primary, 340 layout, primary,
341 ScreenUtil::GetSecondaryDisplay().id()); 341 ScreenUtil::GetSecondaryDisplay().id());
342 342
343 // Primary's bounds stay the same. Just notify bounds change 343 // Primary's bounds stay the same. Just notify bounds change
344 // on the secondary. 344 // on the secondary.
345 screen_ash_->NotifyMetricsChanged( 345 screen_ash_->NotifyMetricsChanged(
346 ScreenUtil::GetSecondaryDisplay(), 346 ScreenUtil::GetSecondaryDisplay(),
347 gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS | 347 gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS |
348 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 348 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
349 if (delegate_) 349 if (delegate_)
350 delegate_->PostDisplayConfigurationChange(); 350 delegate_->PostDisplayConfigurationChange();
351 } 351 }
352 } 352 }
353 353
354 const gfx::Display& DisplayManager::GetDisplayForId(int64 id) const { 354 const gfx::Display& DisplayManager::GetDisplayForId(int64 id) const {
355 gfx::Display* display = 355 gfx::Display* display =
356 const_cast<DisplayManager*>(this)->FindDisplayForId(id); 356 const_cast<DisplayManager*>(this)->FindDisplayForId(id);
357 return display ? *display : GetInvalidDisplay(); 357 return display ? *display : GetInvalidDisplay();
358 } 358 }
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 ++curr_iter; 831 ++curr_iter;
832 } else { 832 } else {
833 // more displays in new list between ids, which means it is added. 833 // more displays in new list between ids, which means it is added.
834 added_display_indices.push_back(new_displays.size()); 834 added_display_indices.push_back(new_displays.size());
835 InsertAndUpdateDisplayInfo(*new_info_iter); 835 InsertAndUpdateDisplayInfo(*new_info_iter);
836 new_displays.push_back( 836 new_displays.push_back(
837 CreateDisplayFromDisplayInfoById(new_info_iter->id())); 837 CreateDisplayFromDisplayInfoById(new_info_iter->id()));
838 ++new_info_iter; 838 ++new_info_iter;
839 } 839 }
840 } 840 }
841 gfx::Display old_primary;
842 if (delegate_)
843 old_primary = screen_ash_->GetPrimaryDisplay();
841 844
842 // Clear focus if the display has been removed, but don't clear focus if 845 // Clear focus if the display has been removed, but don't clear focus if
843 // the destkop has been moved from one display to another 846 // the destkop has been moved from one display to another
844 // (mirror -> docked, docked -> single internal). 847 // (mirror -> docked, docked -> single internal).
845 bool clear_focus = 848 bool clear_focus =
846 !removed_displays.empty() && 849 !removed_displays.empty() &&
847 !(removed_displays.size() == 1 && added_display_indices.size() == 1); 850 !(removed_displays.size() == 1 && added_display_indices.size() == 1);
848 if (delegate_) 851 if (delegate_)
849 delegate_->PreDisplayConfigurationChange(clear_focus); 852 delegate_->PreDisplayConfigurationChange(clear_focus);
850 853
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 // Close the mirroring window here to avoid creating two compositor on 899 // Close the mirroring window here to avoid creating two compositor on
897 // one display. 900 // one display.
898 if (!has_mirroring_display && delegate_) 901 if (!has_mirroring_display && delegate_)
899 delegate_->CloseMirroringDisplay(); 902 delegate_->CloseMirroringDisplay();
900 903
901 for (std::vector<size_t>::iterator iter = added_display_indices.begin(); 904 for (std::vector<size_t>::iterator iter = added_display_indices.begin();
902 iter != added_display_indices.end(); ++iter) { 905 iter != added_display_indices.end(); ++iter) {
903 screen_ash_->NotifyDisplayAdded(displays_[*iter]); 906 screen_ash_->NotifyDisplayAdded(displays_[*iter]);
904 } 907 }
905 908
909 bool notify_primary_change =
910 delegate_ ? old_primary.id() != screen_->GetPrimaryDisplay().id() : false;
911
906 for (std::map<size_t, uint32_t>::iterator iter = display_changes.begin(); 912 for (std::map<size_t, uint32_t>::iterator iter = display_changes.begin();
907 iter != display_changes.end(); 913 iter != display_changes.end();
908 ++iter) { 914 ++iter) {
909 screen_ash_->NotifyMetricsChanged(displays_[iter->first], iter->second); 915 uint32_t metrics = iter->second;
916 const gfx::Display& updated_display = displays_[iter->first];
917
918 if (notify_primary_change &&
919 updated_display.id() == screen_->GetPrimaryDisplay().id()) {
920 metrics |= gfx::DisplayObserver::DISPLAY_METRIC_PRIMARY;
921 notify_primary_change = false;
922 }
923 screen_ash_->NotifyMetricsChanged(updated_display, metrics);
910 } 924 }
925
926 if (notify_primary_change) {
927 // This happens when a primary display has moved to anther display without
928 // bounds change.
929 const gfx::Display& primary = screen_->GetPrimaryDisplay();
930 if (primary.id() != old_primary.id()) {
931 uint32_t metrics = gfx::DisplayObserver::DISPLAY_METRIC_PRIMARY;
932 if (primary.size() != old_primary.size()) {
933 metrics |= (gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS |
934 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
935 }
936 if (primary.device_scale_factor() != old_primary.device_scale_factor())
937 metrics |= gfx::DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR;
938
939 screen_ash_->NotifyMetricsChanged(primary, metrics);
940 }
941 }
942
911 if (delegate_) 943 if (delegate_)
912 delegate_->PostDisplayConfigurationChange(); 944 delegate_->PostDisplayConfigurationChange();
913 945
914 #if defined(USE_X11) && defined(OS_CHROMEOS) 946 #if defined(USE_X11) && defined(OS_CHROMEOS)
915 if (!display_changes.empty() && base::SysInfo::IsRunningOnChromeOS()) 947 if (!display_changes.empty() && base::SysInfo::IsRunningOnChromeOS())
916 ui::ClearX11DefaultRootWindow(); 948 ui::ClearX11DefaultRootWindow();
917 #endif 949 #endif
918 950
919 // Create the mirroring window asynchronously after all displays 951 // Create the mirroring window asynchronously after all displays
920 // are added so that it can mirror the display newly added. This can 952 // are added so that it can mirror the display newly added. This can
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 new_secondary_origin.Offset(-secondary_bounds.width(), offset); 1272 new_secondary_origin.Offset(-secondary_bounds.width(), offset);
1241 break; 1273 break;
1242 } 1274 }
1243 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); 1275 gfx::Insets insets = secondary_display->GetWorkAreaInsets();
1244 secondary_display->set_bounds( 1276 secondary_display->set_bounds(
1245 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 1277 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
1246 secondary_display->UpdateWorkAreaFromInsets(insets); 1278 secondary_display->UpdateWorkAreaFromInsets(insets);
1247 } 1279 }
1248 1280
1249 } // namespace ash 1281 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698