| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/message_center/views/desktop_popup_alignment_delegate.h" | 5 #include "ui/message_center/views/desktop_popup_alignment_delegate.h" |
| 6 | 6 |
| 7 #include "ui/display/display.h" | 7 #include "ui/display/display.h" |
| 8 #include "ui/display/screen.h" | 8 #include "ui/display/screen.h" |
| 9 #include "ui/gfx/geometry/rect.h" | 9 #include "ui/gfx/geometry/rect.h" |
| 10 #include "ui/message_center/message_center_style.h" | 10 #include "ui/message_center/message_center_style.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 ? POPUP_ALIGNMENT_LEFT | 82 ? POPUP_ALIGNMENT_LEFT |
| 83 : POPUP_ALIGNMENT_RIGHT; | 83 : POPUP_ALIGNMENT_RIGHT; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void DesktopPopupAlignmentDelegate::ConfigureWidgetInitParamsForContainer( | 86 void DesktopPopupAlignmentDelegate::ConfigureWidgetInitParamsForContainer( |
| 87 views::Widget* widget, | 87 views::Widget* widget, |
| 88 views::Widget::InitParams* init_params) { | 88 views::Widget::InitParams* init_params) { |
| 89 // Do nothing, which will use the default container. | 89 // Do nothing, which will use the default container. |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool DesktopPopupAlignmentDelegate::IsPrimaryDisplayForNotification() const { |
| 93 return true; |
| 94 } |
| 95 |
| 92 // Anytime the display configuration changes, we need to recompute the alignment | 96 // Anytime the display configuration changes, we need to recompute the alignment |
| 93 // on the primary display. But, we get different events on different platforms. | 97 // on the primary display. But, we get different events on different platforms. |
| 94 // On Windows, for example, when switching from a laptop display to an external | 98 // On Windows, for example, when switching from a laptop display to an external |
| 95 // monitor, we get a OnDisplayMetricsChanged() event. On Linux, we get a | 99 // monitor, we get a OnDisplayMetricsChanged() event. On Linux, we get a |
| 96 // OnDisplayRemoved() and a OnDisplayAdded() instead. In order to account for | 100 // OnDisplayRemoved() and a OnDisplayAdded() instead. In order to account for |
| 97 // these slightly different abstractions, we update on every event. | 101 // these slightly different abstractions, we update on every event. |
| 98 void DesktopPopupAlignmentDelegate::UpdatePrimaryDisplay() { | 102 void DesktopPopupAlignmentDelegate::UpdatePrimaryDisplay() { |
| 99 display::Display primary_display = screen_->GetPrimaryDisplay(); | 103 display::Display primary_display = screen_->GetPrimaryDisplay(); |
| 100 if (primary_display.id() != primary_display_id_) { | 104 if (primary_display.id() != primary_display_id_) { |
| 101 primary_display_id_ = primary_display.id(); | 105 primary_display_id_ = primary_display.id(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 119 void DesktopPopupAlignmentDelegate::OnDisplayMetricsChanged( | 123 void DesktopPopupAlignmentDelegate::OnDisplayMetricsChanged( |
| 120 const display::Display& display, | 124 const display::Display& display, |
| 121 uint32_t metrics) { | 125 uint32_t metrics) { |
| 122 // Set to kInvalidDisplayId so the alignment is updated regardless of whether | 126 // Set to kInvalidDisplayId so the alignment is updated regardless of whether |
| 123 // the primary display actually changed. | 127 // the primary display actually changed. |
| 124 primary_display_id_ = display::kInvalidDisplayId; | 128 primary_display_id_ = display::kInvalidDisplayId; |
| 125 UpdatePrimaryDisplay(); | 129 UpdatePrimaryDisplay(); |
| 126 } | 130 } |
| 127 | 131 |
| 128 } // namespace message_center | 132 } // namespace message_center |
| OLD | NEW |