| 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 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" | 5 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #import "base/mac/mac_util.h" | 10 #import "base/mac/mac_util.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 PresentationModeController* self = | 45 PresentationModeController* self = |
| 46 static_cast<PresentationModeController*>(context); | 46 static_cast<PresentationModeController*>(context); |
| 47 | 47 |
| 48 // If Chrome has multiple fullscreen windows in their own space, the Handler | 48 // If Chrome has multiple fullscreen windows in their own space, the Handler |
| 49 // becomes flaky and might start receiving kMenuBarRevealEventKind events | 49 // becomes flaky and might start receiving kMenuBarRevealEventKind events |
| 50 // from another space. Since the menubar in the another space is in either a | 50 // from another space. Since the menubar in the another space is in either a |
| 51 // shown or hidden state, it will give us a reveal fraction of 0.0 or 1.0. | 51 // shown or hidden state, it will give us a reveal fraction of 0.0 or 1.0. |
| 52 // As such, we should ignore the kMenuBarRevealEventKind event if it gives | 52 // As such, we should ignore the kMenuBarRevealEventKind event if it gives |
| 53 // us a fraction of 0.0 or 1.0, and rely on kEventMenuBarShown and | 53 // us a fraction of 0.0 or 1.0, and rely on kEventMenuBarShown and |
| 54 // kEventMenuBarHidden to set these values. | 54 // kEventMenuBarHidden to set these values. |
| 55 if ([self isMainWindow]) { | 55 if ([self isMainWindow] && ![self isFullscreenTransitionInProgress]) { |
| 56 if (GetEventKind(event) == kMenuBarRevealEventKind) { | 56 if (GetEventKind(event) == kMenuBarRevealEventKind) { |
| 57 CGFloat revealFraction = 0; | 57 CGFloat revealFraction = 0; |
| 58 GetEventParameter(event, FOUR_CHAR_CODE('rvlf'), typeCGFloat, NULL, | 58 GetEventParameter(event, FOUR_CHAR_CODE('rvlf'), typeCGFloat, NULL, |
| 59 sizeof(CGFloat), NULL, &revealFraction); | 59 sizeof(CGFloat), NULL, &revealFraction); |
| 60 if (revealFraction > 0.0 && revealFraction < 1.0) | 60 if (revealFraction > 0.0 && revealFraction < 1.0) |
| 61 [self setMenuBarRevealProgress:revealFraction]; | 61 [self setMenuBarRevealProgress:revealFraction]; |
| 62 } else if (GetEventKind(event) == kEventMenuBarShown) { | 62 } else if (GetEventKind(event) == kEventMenuBarShown) { |
| 63 [self setMenuBarRevealProgress:1.0]; | 63 [self setMenuBarRevealProgress:1.0]; |
| 64 } else { | 64 } else { |
| 65 [self setMenuBarRevealProgress:0.0]; | 65 [self setMenuBarRevealProgress:0.0]; |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 // the logic is correct and not fragile. | 424 // the logic is correct and not fragile. |
| 425 - (CGFloat)menubarOffset { | 425 - (CGFloat)menubarOffset { |
| 426 if ([browserController_ isInAppKitFullscreen]) | 426 if ([browserController_ isInAppKitFullscreen]) |
| 427 return -std::floor(menubarFraction_ * [self floatingBarVerticalOffset]); | 427 return -std::floor(menubarFraction_ * [self floatingBarVerticalOffset]); |
| 428 | 428 |
| 429 return [self shouldShowMenubarInImmersiveFullscreen] | 429 return [self shouldShowMenubarInImmersiveFullscreen] |
| 430 ? -[self floatingBarVerticalOffset] | 430 ? -[self floatingBarVerticalOffset] |
| 431 : 0; | 431 : 0; |
| 432 } | 432 } |
| 433 | 433 |
| 434 - (BOOL)isFullscreenTransitionInProgress { |
| 435 return [browserController_ isFullscreenTransitionInProgress]; |
| 436 } |
| 437 |
| 434 - (BOOL)isMainWindow { | 438 - (BOOL)isMainWindow { |
| 435 return [browserController_ window].isMainWindow; | 439 return [browserController_ window].isMainWindow; |
| 436 } | 440 } |
| 437 | 441 |
| 438 // Used to activate the floating bar in presentation mode. | 442 // Used to activate the floating bar in presentation mode. |
| 439 - (void)mouseEntered:(NSEvent*)event { | 443 - (void)mouseEntered:(NSEvent*)event { |
| 440 DCHECK(inPresentationMode_); | 444 DCHECK(inPresentationMode_); |
| 441 | 445 |
| 442 // Having gotten a mouse entered, we no longer need to do exit checks. | 446 // Having gotten a mouse entered, we no longer need to do exit checks. |
| 443 [self cancelMouseExitCheck]; | 447 [self cancelMouseExitCheck]; |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 [self updateMenuBarAndDockVisibility]; | 761 [self updateMenuBarAndDockVisibility]; |
| 758 | 762 |
| 759 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 | 763 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 |
| 760 } | 764 } |
| 761 | 765 |
| 762 - (BOOL)shouldShowMenubarInImmersiveFullscreen { | 766 - (BOOL)shouldShowMenubarInImmersiveFullscreen { |
| 763 return [self doesScreenHaveMenuBar] && toolbarFraction_ > 0.99; | 767 return [self doesScreenHaveMenuBar] && toolbarFraction_ > 0.99; |
| 764 } | 768 } |
| 765 | 769 |
| 766 @end | 770 @end |
| OLD | NEW |