Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: chrome/browser/ui/cocoa/presentation_mode_controller.mm

Issue 1979663002: Fix for Fullscreen toolbar with multiple monitors on OSX (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/presentation_mode_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 isOnActiveSpace]) { 55 if ([self isMainWindow]) {
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
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)isOnActiveSpace { 434 - (BOOL)isMainWindow {
435 return [browserController_ window].onActiveSpace; 435 return [browserController_ window].isMainWindow;
436 } 436 }
437 437
438 // Used to activate the floating bar in presentation mode. 438 // Used to activate the floating bar in presentation mode.
439 - (void)mouseEntered:(NSEvent*)event { 439 - (void)mouseEntered:(NSEvent*)event {
440 DCHECK(inPresentationMode_); 440 DCHECK(inPresentationMode_);
441 441
442 // Having gotten a mouse entered, we no longer need to do exit checks. 442 // Having gotten a mouse entered, we no longer need to do exit checks.
443 [self cancelMouseExitCheck]; 443 [self cancelMouseExitCheck];
444 444
445 NSTrackingArea* trackingArea = [event trackingArea]; 445 NSTrackingArea* trackingArea = [event trackingArea];
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 if (!currentAnimation_.get()) 514 if (!currentAnimation_.get())
515 [browserController_ layoutSubviews]; 515 [browserController_ layoutSubviews];
516 } 516 }
517 517
518 @end 518 @end
519 519
520 520
521 @implementation PresentationModeController (PrivateMethods) 521 @implementation PresentationModeController (PrivateMethods)
522 522
523 - (void)updateMenuBarAndDockVisibility { 523 - (void)updateMenuBarAndDockVisibility {
524 if (![[browserController_ window] isMainWindow] || 524 if (![self isMainWindow] || ![browserController_ isInImmersiveFullscreen]) {
525 ![browserController_ isInImmersiveFullscreen]) {
526 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeNormal]; 525 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeNormal];
527 return; 526 return;
528 } 527 }
529 528
530 // The screen does not have a menu bar, so there's no need to hide it. 529 // The screen does not have a menu bar, so there's no need to hide it.
531 if (![self doesScreenHaveMenuBar]) { 530 if (![self doesScreenHaveMenuBar]) {
532 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeHideDock]; 531 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeHideDock];
533 return; 532 return;
534 } 533 }
535 534
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 [self updateMenuBarAndDockVisibility]; 757 [self updateMenuBarAndDockVisibility];
759 758
760 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 759 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956
761 } 760 }
762 761
763 - (BOOL)shouldShowMenubarInImmersiveFullscreen { 762 - (BOOL)shouldShowMenubarInImmersiveFullscreen {
764 return [self doesScreenHaveMenuBar] && toolbarFraction_ > 0.99; 763 return [self doesScreenHaveMenuBar] && toolbarFraction_ > 0.99;
765 } 764 }
766 765
767 @end 766 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/presentation_mode_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698