| 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 "chrome/browser/ui/cocoa/status_bubble_mac.h" | 5 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 DCHECK_EQ([[window_ animator] alphaValue], 0.0); | 440 DCHECK_EQ([[window_ animator] alphaValue], 0.0); |
| 441 SetState(kBubbleHidden); | 441 SetState(kBubbleHidden); |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 } | 444 } |
| 445 | 445 |
| 446 void StatusBubbleMac::SetState(StatusBubbleState state) { | 446 void StatusBubbleMac::SetState(StatusBubbleState state) { |
| 447 if (state == state_) | 447 if (state == state_) |
| 448 return; | 448 return; |
| 449 | 449 |
| 450 if (state == kBubbleHidden) | 450 if (state == kBubbleHidden) { |
| 451 [window_ setFrame:NSMakeRect(0, 0, 1, 1) display:YES]; | 451 // When hidden (with alpha of 0), make the window have the minimum size, |
| 452 // while still keeping the same origin. It's important to not set the |
| 453 // origin to 0,0 as that will cause the window to use more space in |
| 454 // Expose/Mission Control. See http://crbug.com/81969. |
| 455 // |
| 456 // Also, doing it this way instead of detaching the window avoids bugs with |
| 457 // Spaces and Cmd-`. See http://crbug.com/31821 and http://crbug.com/61629. |
| 458 NSRect frame = [window_ frame]; |
| 459 frame.size = NSMakeSize(1, 1); |
| 460 [window_ setFrame:frame display:YES]; |
| 461 } |
| 452 | 462 |
| 453 if ([delegate_ respondsToSelector:@selector(statusBubbleWillEnterState:)]) | 463 if ([delegate_ respondsToSelector:@selector(statusBubbleWillEnterState:)]) |
| 454 [delegate_ statusBubbleWillEnterState:state]; | 464 [delegate_ statusBubbleWillEnterState:state]; |
| 455 | 465 |
| 456 state_ = state; | 466 state_ = state; |
| 457 } | 467 } |
| 458 | 468 |
| 459 void StatusBubbleMac::Fade(bool show) { | 469 void StatusBubbleMac::Fade(bool show) { |
| 460 DCHECK([NSThread isMainThread]); | 470 DCHECK([NSThread isMainThread]); |
| 461 | 471 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 } | 740 } |
| 731 | 741 |
| 732 // Round the top corners when the bubble is below the parent window. | 742 // Round the top corners when the bubble is below the parent window. |
| 733 if (NSMinY(window_frame) < NSMinY(parent_frame)) { | 743 if (NSMinY(window_frame) < NSMinY(parent_frame)) { |
| 734 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner; | 744 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner; |
| 735 } | 745 } |
| 736 } | 746 } |
| 737 | 747 |
| 738 return corner_flags; | 748 return corner_flags; |
| 739 } | 749 } |
| OLD | NEW |