OLD | NEW |
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/wm/drag_window_resizer.h" | 5 #include "ash/wm/drag_window_resizer.h" |
6 | 6 |
7 #include "ash/display/mouse_cursor_event_filter.h" | 7 #include "ash/display/mouse_cursor_event_filter.h" |
8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/wm/coordinate_conversion.h" | 10 #include "ash/wm/coordinate_conversion.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 const float fraction_in_another_window = | 174 const float fraction_in_another_window = |
175 (bounds_in_another_root.width() * bounds_in_another_root.height()) / | 175 (bounds_in_another_root.width() * bounds_in_another_root.height()) / |
176 static_cast<float>(bounds.width() * bounds.height()); | 176 static_cast<float>(bounds.width() * bounds.height()); |
177 | 177 |
178 if (fraction_in_another_window > 0) { | 178 if (fraction_in_another_window > 0) { |
179 if (!drag_window_controller_) { | 179 if (!drag_window_controller_) { |
180 drag_window_controller_.reset( | 180 drag_window_controller_.reset( |
181 new DragWindowController(GetTarget())); | 181 new DragWindowController(GetTarget())); |
182 // Always show the drag phantom on the |another_root| window. | 182 // Always show the drag phantom on the |another_root| window. |
183 drag_window_controller_->SetDestinationDisplay( | 183 drag_window_controller_->SetDestinationDisplay( |
184 Shell::GetScreen()->GetDisplayNearestWindow(another_root)); | 184 Shell::GetScreen()->GetDisplayMatching( |
| 185 another_root->GetBoundsInScreen())); |
185 drag_window_controller_->Show(); | 186 drag_window_controller_->Show(); |
186 } else { | 187 } else { |
187 // No animation. | 188 // No animation. |
188 drag_window_controller_->SetBounds(bounds_in_screen); | 189 drag_window_controller_->SetBounds(bounds_in_screen); |
189 } | 190 } |
190 const float phantom_opacity = | 191 const float phantom_opacity = |
191 !in_original_root ? 1 : (kMaxOpacity * fraction_in_another_window); | 192 !in_original_root ? 1 : (kMaxOpacity * fraction_in_another_window); |
192 const float window_opacity = | 193 const float window_opacity = |
193 in_original_root ? 1 : (kMaxOpacity * (1 - fraction_in_another_window)); | 194 in_original_root ? 1 : (kMaxOpacity * (1 - fraction_in_another_window)); |
194 drag_window_controller_->SetOpacity(phantom_opacity); | 195 drag_window_controller_->SetOpacity(phantom_opacity); |
195 GetTarget()->layer()->SetOpacity(window_opacity); | 196 GetTarget()->layer()->SetOpacity(window_opacity); |
196 } else { | 197 } else { |
197 drag_window_controller_.reset(); | 198 drag_window_controller_.reset(); |
198 GetTarget()->layer()->SetOpacity(1.0f); | 199 GetTarget()->layer()->SetOpacity(1.0f); |
199 } | 200 } |
200 } | 201 } |
201 | 202 |
202 bool DragWindowResizer::ShouldAllowMouseWarp() { | 203 bool DragWindowResizer::ShouldAllowMouseWarp() { |
203 return (details_.window_component == HTCAPTION) && | 204 return (details_.window_component == HTCAPTION) && |
204 !GetTarget()->transient_parent() && | 205 !GetTarget()->transient_parent() && |
205 (GetTarget()->type() == aura::client::WINDOW_TYPE_NORMAL || | 206 (GetTarget()->type() == aura::client::WINDOW_TYPE_NORMAL || |
206 GetTarget()->type() == aura::client::WINDOW_TYPE_PANEL); | 207 GetTarget()->type() == aura::client::WINDOW_TYPE_PANEL); |
207 } | 208 } |
208 | 209 |
209 } // namespace internal | 210 } // namespace internal |
210 } // namespace ash | 211 } // namespace ash |
OLD | NEW |