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()->GetDisplayMatching( | 184 Shell::GetScreen()->GetDisplayNearestWindow(another_root)); |
185 another_root->GetBoundsInScreen())); | |
186 drag_window_controller_->Show(); | 185 drag_window_controller_->Show(); |
187 } else { | 186 } else { |
188 // No animation. | 187 // No animation. |
189 drag_window_controller_->SetBounds(bounds_in_screen); | 188 drag_window_controller_->SetBounds(bounds_in_screen); |
190 } | 189 } |
191 const float phantom_opacity = | 190 const float phantom_opacity = |
192 !in_original_root ? 1 : (kMaxOpacity * fraction_in_another_window); | 191 !in_original_root ? 1 : (kMaxOpacity * fraction_in_another_window); |
193 const float window_opacity = | 192 const float window_opacity = |
194 in_original_root ? 1 : (kMaxOpacity * (1 - fraction_in_another_window)); | 193 in_original_root ? 1 : (kMaxOpacity * (1 - fraction_in_another_window)); |
195 drag_window_controller_->SetOpacity(phantom_opacity); | 194 drag_window_controller_->SetOpacity(phantom_opacity); |
196 GetTarget()->layer()->SetOpacity(window_opacity); | 195 GetTarget()->layer()->SetOpacity(window_opacity); |
197 } else { | 196 } else { |
198 drag_window_controller_.reset(); | 197 drag_window_controller_.reset(); |
199 GetTarget()->layer()->SetOpacity(1.0f); | 198 GetTarget()->layer()->SetOpacity(1.0f); |
200 } | 199 } |
201 } | 200 } |
202 | 201 |
203 bool DragWindowResizer::ShouldAllowMouseWarp() { | 202 bool DragWindowResizer::ShouldAllowMouseWarp() { |
204 return (details_.window_component == HTCAPTION) && | 203 return (details_.window_component == HTCAPTION) && |
205 !GetTarget()->transient_parent() && | 204 !GetTarget()->transient_parent() && |
206 (GetTarget()->type() == aura::client::WINDOW_TYPE_NORMAL || | 205 (GetTarget()->type() == aura::client::WINDOW_TYPE_NORMAL || |
207 GetTarget()->type() == aura::client::WINDOW_TYPE_PANEL); | 206 GetTarget()->type() == aura::client::WINDOW_TYPE_PANEL); |
208 } | 207 } |
209 | 208 |
210 } // namespace internal | 209 } // namespace internal |
211 } // namespace ash | 210 } // namespace ash |
OLD | NEW |