Loading ...
Sorry, an error occurred while loading the content.

[PATCH] fix fullscreen mode for secondary monitors

Expand Messages
  • Nicolas Weber
    ... src/MacVim/MMFullscreenWindow.m | 64 ++++++++++++++++++++++++++++++++++++-- 1 files changed, 60 insertions(+), 4 deletions(-) diff --git
    Message 1 of 1 , Jan 7, 2008
    • 0 Attachment
      ---
      src/MacVim/MMFullscreenWindow.m | 64 ++++++++++++++++++++++++++++++++++++--
      1 files changed, 60 insertions(+), 4 deletions(-)

      diff --git a/src/MacVim/MMFullscreenWindow.m b/src/MacVim/MMFullscreenWindow.m
      index fe78167..2955f24 100644
      --- a/src/MacVim/MMFullscreenWindow.m
      +++ b/src/MacVim/MMFullscreenWindow.m
      @@ -23,6 +23,14 @@
      #import <Carbon/Carbon.h>


      +static int numFullscreenWindows = 0;
      +
      +@interface MMFullscreenWindow (Private)
      +- (void)centerView;
      +- (BOOL)isOnPrimaryScreen;
      +- (void)hideDockIfAppropriate;
      +- (void)revealDockIfAppropriate;
      +@end

      @implementation MMFullscreenWindow

      @@ -40,7 +48,10 @@
      styleMask:NSBorderlessWindowMask
      backing:NSBackingStoreBuffered
      defer:YES
      - screen:screen];
      + // since we're passing [screen frame] above,
      + // we want the content rect to be relative to
      + // the main screen (ie, pass nil for screen).
      + screen:nil];

      if (self == nil)
      return nil;
      @@ -76,8 +87,7 @@

      - (void)enterFullscreen
      {
      - // hide menu and dock, both appear on demand
      - SetSystemUIMode(kUIModeAllSuppressed, 0); //requires 10.3
      + [self hideDockIfAppropriate];

      // fade to black
      Boolean didBlend = NO;
      @@ -177,8 +187,54 @@
      CGReleaseDisplayFadeReservation(token);
      }

      + [self revealDockIfAppropriate];
      +}
      +
      +- (BOOL)isOnPrimaryScreen
      +{
      + // The primary screen is the screen the menu bar is on. This is different
      + // from [NSScreen mainScreen] (which returns the screen containing the
      + // key window).
      + NSArray *screens = [NSScreen screens];
      + if (screens == nil || [screens count] < 1)
      + return NO;
      +
      + return [self screen] == [screens objectAtIndex:0];
      +}
      +
      +- (void)hideDockIfAppropriate
      +{
      + // Hide menu and dock, both appear on demand.
      + //
      + // Don't hide the dock if going fullscreen on a non-primary screen. Also,
      + // if there are several fullscreen windows on the primary screen, only
      + // hide dock and friends for the first fullscreen window (and display
      + // them again after the last fullscreen window has been closed).
      + //
      + // Another way to deal with several fullscreen windows would be to hide/
      + // reveal the dock each time a fullscreen window gets/loses focus, but
      + // this way it's less distracting.
      +
      + // XXX: If you have a fullscreen window on a secondary monitor and unplug
      + // the monitor, this will probably not work right.
      +
      + if ([self isOnPrimaryScreen]) {
      + if (numFullscreenWindows == 0) {
      + SetSystemUIMode(kUIModeAllSuppressed, 0); //requires 10.3
      + }
      + ++numFullscreenWindows;
      + }
      +}
      +
      +- (void)revealDockIfAppropriate
      +{
      // order menu and dock back in
      - SetSystemUIMode(kUIModeNormal, 0);
      + if ([self isOnPrimaryScreen]) {
      + --numFullscreenWindows;
      + if (numFullscreenWindows == 0) {
      + SetSystemUIMode(kUIModeNormal, 0);
      + }
      + }
      }

      // Title-less windows normally don't receive key presses, override this
      --
      1.5.3.4


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.