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/shelf_layout_manager.h" | 5 #include "ash/wm/shelf_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/launcher/launcher.h" | 9 #include "ash/launcher/launcher.h" |
10 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 Shell::GetInstance()->status_area_widget(); | 175 Shell::GetInstance()->status_area_widget(); |
176 if (status_area_widget) | 176 if (status_area_widget) |
177 Shell::GetInstance()->status_area_widget()->SetShelfAlignment(alignment); | 177 Shell::GetInstance()->status_area_widget()->SetShelfAlignment(alignment); |
178 LayoutShelf(); | 178 LayoutShelf(); |
179 return true; | 179 return true; |
180 } | 180 } |
181 | 181 |
182 gfx::Rect ShelfLayoutManager::GetIdealBounds() { | 182 gfx::Rect ShelfLayoutManager::GetIdealBounds() { |
183 // TODO(oshima): this is wrong. Figure out what display shelf is on | 183 // TODO(oshima): this is wrong. Figure out what display shelf is on |
184 // and everything should be based on it. | 184 // and everything should be based on it. |
185 gfx::Rect bounds(ScreenAsh::GetDisplayParentBounds( | 185 gfx::Rect bounds(ScreenAsh::GetDisplayBoundsInParent( |
186 status_->GetNativeView())); | 186 status_->GetNativeView())); |
187 int width = 0, height = 0; | 187 int width = 0, height = 0; |
188 GetShelfSize(&width, &height); | 188 GetShelfSize(&width, &height); |
189 switch (alignment_) { | 189 switch (alignment_) { |
190 case SHELF_ALIGNMENT_BOTTOM: | 190 case SHELF_ALIGNMENT_BOTTOM: |
191 return gfx::Rect(bounds.x(), bounds.bottom() - height, | 191 return gfx::Rect(bounds.x(), bounds.bottom() - height, |
192 bounds.width(), height); | 192 bounds.width(), height); |
193 case SHELF_ALIGNMENT_LEFT: | 193 case SHELF_ALIGNMENT_LEFT: |
194 return gfx::Rect(bounds.x(), bounds.y(), width, bounds.height()); | 194 return gfx::Rect(bounds.x(), bounds.y(), width, bounds.height()); |
195 case SHELF_ALIGNMENT_RIGHT: | 195 case SHELF_ALIGNMENT_RIGHT: |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 void ShelfLayoutManager::OnWindowActivated(aura::Window* active, | 316 void ShelfLayoutManager::OnWindowActivated(aura::Window* active, |
317 aura::Window* old_active) { | 317 aura::Window* old_active) { |
318 UpdateAutoHideStateNow(); | 318 UpdateAutoHideStateNow(); |
319 } | 319 } |
320 | 320 |
321 //////////////////////////////////////////////////////////////////////////////// | 321 //////////////////////////////////////////////////////////////////////////////// |
322 // ShelfLayoutManager, private: | 322 // ShelfLayoutManager, private: |
323 | 323 |
324 gfx::Rect ShelfLayoutManager::GetMaximizedWindowBounds( | 324 gfx::Rect ShelfLayoutManager::GetMaximizedWindowBounds( |
325 aura::Window* window) { | 325 aura::Window* window) { |
326 gfx::Rect bounds(ScreenAsh::GetDisplayParentBounds(window)); | 326 gfx::Rect bounds(ScreenAsh::GetDisplayBoundsInParent(window)); |
327 if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT || | 327 if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT || |
328 auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) { | 328 auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) { |
329 AdjustBoundsBasedOnAlignment(kAutoHideSize, &bounds); | 329 AdjustBoundsBasedOnAlignment(kAutoHideSize, &bounds); |
330 return bounds; | 330 return bounds; |
331 } | 331 } |
332 // SHELF_AUTO_HIDE_BEHAVIOR_NEVER maximized windows don't get any taller. | 332 // SHELF_AUTO_HIDE_BEHAVIOR_NEVER maximized windows don't get any taller. |
333 return GetUnmaximizedWorkAreaBounds(window); | 333 return GetUnmaximizedWorkAreaBounds(window); |
334 } | 334 } |
335 | 335 |
336 gfx::Rect ShelfLayoutManager::GetUnmaximizedWorkAreaBounds( | 336 gfx::Rect ShelfLayoutManager::GetUnmaximizedWorkAreaBounds( |
337 aura::Window* window) { | 337 aura::Window* window) { |
338 gfx::Rect bounds(ScreenAsh::GetDisplayParentBounds(window)); | 338 gfx::Rect bounds(ScreenAsh::GetDisplayBoundsInParent(window)); |
339 int size; | 339 int size; |
340 if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) { | 340 if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) { |
341 size = kAutoHideSize; | 341 size = kAutoHideSize; |
342 } else { | 342 } else { |
343 int width, height; | 343 int width, height; |
344 GetShelfSize(&width, &height); | 344 GetShelfSize(&width, &height); |
345 size = std::max(width, height); | 345 size = std::max(width, height); |
346 } | 346 } |
347 AdjustBoundsBasedOnAlignment(size, &bounds); | 347 AdjustBoundsBasedOnAlignment(size, &bounds); |
348 return bounds; | 348 return bounds; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 } | 408 } |
409 | 409 |
410 void ShelfLayoutManager::StopAnimating() { | 410 void ShelfLayoutManager::StopAnimating() { |
411 if (launcher_widget()) | 411 if (launcher_widget()) |
412 GetLayer(launcher_widget())->GetAnimator()->StopAnimating(); | 412 GetLayer(launcher_widget())->GetAnimator()->StopAnimating(); |
413 GetLayer(status_)->GetAnimator()->StopAnimating(); | 413 GetLayer(status_)->GetAnimator()->StopAnimating(); |
414 } | 414 } |
415 | 415 |
416 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { | 416 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { |
417 *width = *height = 0; | 417 *width = *height = 0; |
418 gfx::Rect status_bounds(status_->GetWindowScreenBounds()); | 418 gfx::Rect status_bounds(status_->GetWindowBoundsInScreen()); |
419 gfx::Size launcher_size = launcher_ ? | 419 gfx::Size launcher_size = launcher_ ? |
420 launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size(); | 420 launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size(); |
421 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) | 421 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) |
422 *height = std::max(launcher_size.height(), status_bounds.height()); | 422 *height = std::max(launcher_size.height(), status_bounds.height()); |
423 else | 423 else |
424 *width = std::max(launcher_size.width(), status_bounds.width()); | 424 *width = std::max(launcher_size.width(), status_bounds.width()); |
425 } | 425 } |
426 | 426 |
427 void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset, | 427 void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset, |
428 gfx::Rect* bounds) const { | 428 gfx::Rect* bounds) const { |
429 switch (alignment_) { | 429 switch (alignment_) { |
430 case SHELF_ALIGNMENT_BOTTOM: | 430 case SHELF_ALIGNMENT_BOTTOM: |
431 bounds->Inset(gfx::Insets(0, 0, inset, 0)); | 431 bounds->Inset(gfx::Insets(0, 0, inset, 0)); |
432 break; | 432 break; |
433 case SHELF_ALIGNMENT_LEFT: | 433 case SHELF_ALIGNMENT_LEFT: |
434 bounds->Inset(gfx::Insets(0, inset, 0, 0)); | 434 bounds->Inset(gfx::Insets(0, inset, 0, 0)); |
435 break; | 435 break; |
436 case SHELF_ALIGNMENT_RIGHT: | 436 case SHELF_ALIGNMENT_RIGHT: |
437 bounds->Inset(gfx::Insets(0, 0, 0, inset)); | 437 bounds->Inset(gfx::Insets(0, 0, 0, inset)); |
438 break; | 438 break; |
439 } | 439 } |
440 } | 440 } |
441 | 441 |
442 void ShelfLayoutManager::CalculateTargetBounds( | 442 void ShelfLayoutManager::CalculateTargetBounds( |
443 const State& state, | 443 const State& state, |
444 TargetBounds* target_bounds) { | 444 TargetBounds* target_bounds) { |
445 const gfx::Rect& available_bounds( | 445 const gfx::Rect& available_bounds( |
446 status_->GetNativeView()->GetRootWindow()->bounds()); | 446 status_->GetNativeView()->GetRootWindow()->bounds()); |
447 gfx::Rect status_bounds(status_->GetWindowScreenBounds()); | 447 gfx::Rect status_bounds(status_->GetWindowBoundsInScreen()); |
448 gfx::Size launcher_size = launcher_ ? | 448 gfx::Size launcher_size = launcher_ ? |
449 launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size(); | 449 launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size(); |
450 int shelf_size = 0; | 450 int shelf_size = 0; |
451 int shelf_width = 0, shelf_height = 0; | 451 int shelf_width = 0, shelf_height = 0; |
452 GetShelfSize(&shelf_width, &shelf_height); | 452 GetShelfSize(&shelf_width, &shelf_height); |
453 if (state.visibility_state == VISIBLE || | 453 if (state.visibility_state == VISIBLE || |
454 (state.visibility_state == AUTO_HIDE && | 454 (state.visibility_state == AUTO_HIDE && |
455 state.auto_hide_state == AUTO_HIDE_SHOWN)) { | 455 state.auto_hide_state == AUTO_HIDE_SHOWN)) { |
456 shelf_size = std::max(shelf_width, shelf_height); | 456 shelf_size = std::max(shelf_width, shelf_height); |
457 } else if (state.visibility_state == AUTO_HIDE && | 457 } else if (state.visibility_state == AUTO_HIDE && |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 | 545 |
546 if (launcher_widget()->IsActive() || status_->IsActive()) | 546 if (launcher_widget()->IsActive() || status_->IsActive()) |
547 return AUTO_HIDE_SHOWN; | 547 return AUTO_HIDE_SHOWN; |
548 | 548 |
549 // Don't show if the user is dragging the mouse. | 549 // Don't show if the user is dragging the mouse. |
550 if (event_filter_.get() && event_filter_->in_mouse_drag()) | 550 if (event_filter_.get() && event_filter_->in_mouse_drag()) |
551 return AUTO_HIDE_HIDDEN; | 551 return AUTO_HIDE_HIDDEN; |
552 | 552 |
553 aura::RootWindow* root = launcher_widget()->GetNativeView()->GetRootWindow(); | 553 aura::RootWindow* root = launcher_widget()->GetNativeView()->GetRootWindow(); |
554 bool mouse_over_launcher = | 554 bool mouse_over_launcher = |
555 launcher_widget()->GetWindowScreenBounds().Contains( | 555 launcher_widget()->GetWindowBoundsInScreen().Contains( |
556 root->last_mouse_location()); | 556 root->last_mouse_location()); |
557 return mouse_over_launcher ? AUTO_HIDE_SHOWN : AUTO_HIDE_HIDDEN; | 557 return mouse_over_launcher ? AUTO_HIDE_SHOWN : AUTO_HIDE_HIDDEN; |
558 } | 558 } |
559 | 559 |
560 void ShelfLayoutManager::UpdateHitTestBounds() { | 560 void ShelfLayoutManager::UpdateHitTestBounds() { |
561 gfx::Insets insets; | 561 gfx::Insets insets; |
562 // Only modify the hit test when the shelf is visible, so we don't mess with | 562 // Only modify the hit test when the shelf is visible, so we don't mess with |
563 // hover hit testing in the auto-hide state. | 563 // hover hit testing in the auto-hide state. |
564 if (state_.visibility_state == VISIBLE) { | 564 if (state_.visibility_state == VISIBLE) { |
565 // Let clicks at the very top of the launcher through so windows can be | 565 // Let clicks at the very top of the launcher through so windows can be |
(...skipping 27 matching lines...) Expand all Loading... |
593 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 593 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
594 if (state.visibility_state == VISIBLE) | 594 if (state.visibility_state == VISIBLE) |
595 return size; | 595 return size; |
596 if (state.visibility_state == AUTO_HIDE) | 596 if (state.visibility_state == AUTO_HIDE) |
597 return kAutoHideSize; | 597 return kAutoHideSize; |
598 return 0; | 598 return 0; |
599 } | 599 } |
600 | 600 |
601 } // namespace internal | 601 } // namespace internal |
602 } // namespace ash | 602 } // namespace ash |
OLD | NEW |