emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r110388: Handle fullscreen parameter


From: Jan D.
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110388: Handle fullscreen parameter in initial/defult-frame-alist for NS.
Date: Sat, 06 Oct 2012 19:31:11 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110388
committer: Jan D. <address@hidden>
branch nick: trunk
timestamp: Sat 2012-10-06 19:31:11 +0200
message:
  Handle fullscreen parameter in initial/defult-frame-alist for NS.
  
  * nsfns.m (Fx_create_frame): Call x_default_parameter with
  fullscreen/Fullscreen.
  
  * nsterm.h (EmacsView): Rename tbar_height to tibar_height.
  tobar_height is new.
  
  * nsterm.m (x_make_frame_visible): Check for fullscreen.
  (ns_fullscreen_hook): Activate old style fullscreen with a timer.
  (ns_term_init): Set activateIgnoringOtherApps if old style fullscreen.
  (windowDidResize:): Check for correct window if old style fullscreen.
  Capitalize word in comment.  Remove incorrect comment.
  (initFrameFromEmacs:): tbar_height renamed tibar_height.
  (windowDidEnterFullScreen:): Toggle toolbar for fullscreen to fix
  error in drawing background.
  (toggleFullScreen:): Remove comment. Rearrange calls.
  Set toolbar values to zero, save old height in tobar_height.
  Restore tool bar height when leaving fullscreen.
  (canBecomeMainWindow): New function.
modified:
  src/ChangeLog
  src/nsfns.m
  src/nsterm.h
  src/nsterm.m
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-10-06 12:55:09 +0000
+++ b/src/ChangeLog     2012-10-06 17:31:11 +0000
@@ -1,3 +1,24 @@
+2012-10-06  Jan Djärv  <address@hidden>
+
+       * nsfns.m (Fx_create_frame): Call x_default_parameter with
+       fullscreen/Fullscreen.
+
+       * nsterm.h (EmacsView): Rename tbar_height to tibar_height.
+       tobar_height is new.
+
+       * nsterm.m (x_make_frame_visible): Check for fullscreen.
+       (ns_fullscreen_hook): Activate old style fullscreen with a timer.
+       (ns_term_init): Set activateIgnoringOtherApps if old style fullscreen.
+       (windowDidResize:): Check for correct window if old style fullscreen.
+       Capitalize word in comment.  Remove incorrect comment.
+       (initFrameFromEmacs:): tbar_height renamed tibar_height.
+       (windowDidEnterFullScreen:): Toggle toolbar for fullscreen to fix
+       error in drawing background.
+       (toggleFullScreen:): Remove comment. Rearrange calls.
+       Set toolbar values to zero, save old height in tobar_height.
+       Restore tool bar height when leaving fullscreen.
+       (canBecomeMainWindow): New function.
+
 2012-10-06  Paul Eggert  <address@hidden>
 
        * keyboard.c (read_char): Remove unnecessary 'volatile's and label.

=== modified file 'src/nsfns.m'
--- a/src/nsfns.m       2012-09-30 13:43:47 +0000
+++ b/src/nsfns.m       2012-10-06 17:31:11 +0000
@@ -1346,6 +1346,8 @@
                        RES_TYPE_NUMBER);
   x_default_parameter (f, parms, Qalpha, Qnil,
                        "alpha", "Alpha", RES_TYPE_NUMBER);
+  x_default_parameter (f, parms, Qfullscreen, Qnil,
+                       "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
 
   width = FRAME_COLS (f);
   height = FRAME_LINES (f);

=== modified file 'src/nsterm.h'
--- a/src/nsterm.h      2012-09-30 12:50:09 +0000
+++ b/src/nsterm.h      2012-10-06 17:31:11 +0000
@@ -86,7 +86,8 @@
    BOOL windowClosing;
    NSString *workingText;
    BOOL processingCompose;
-   int fs_state, fs_before_fs, next_maximized, tbar_height, bwidth;
+   int fs_state, fs_before_fs, next_maximized;
+   int tibar_height, tobar_height, bwidth;
    int maximized_width, maximized_height;
    NSWindow *nonfs_window;
 @public

=== modified file 'src/nsterm.m'
--- a/src/nsterm.m      2012-10-02 18:51:51 +0000
+++ b/src/nsterm.m      2012-10-06 17:31:11 +0000
@@ -1068,8 +1068,23 @@
      if this ends up the case again, comment this out again. */
   if (!FRAME_VISIBLE_P (f))
     {
+      EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
       f->async_visible = 1;
       ns_raise_frame (f);
+
+#ifdef NEW_STYLE_FS
+      /* Making a new frame from a fullscreen frame will make the new frame
+         fullscreen also.  So skip handleFS as this will print an error.  */
+      if (f->want_fullscreen == FULLSCREEN_BOTH
+          && ([[view window] styleMask] & NSFullScreenWindowMask) != 0)
+        return;
+#endif
+      if (f->want_fullscreen != FULLSCREEN_NONE)
+        {
+          block_input ();
+          [view handleFS];
+          unblock_input ();
+        }
     }
 }
 
@@ -1317,6 +1332,18 @@
   EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
   
   if (! f->async_visible) return;
+#ifndef NEW_STYLE_FS
+  if (f->want_fullscreen == FULLSCREEN_BOTH)
+    {
+      /* Old style fs don't initiate correctly if created from
+         init/default-frame alist, so use a timer (not nice...).
+      */
+      [NSTimer scheduledTimerWithTimeInterval: 0.5 target: view
+                                     selector: @selector (handleFS)
+                                     userInfo: nil repeats: NO];
+      return;
+    }
+#endif
 
   block_input ();
   [view handleFS];
@@ -4210,6 +4237,11 @@
                             NSColorPboardType,
                             NSFontPboardType, nil] retain];
 
+#ifndef NEW_STYLE_FS
+  /* If fullscreen is in init/default-frame-alist, focus isn't set
+     right for fullscreen windows, so set this.  */
+  [NSApp activateIgnoringOtherApps:YES];
+#endif
 
   [NSApp run];
   ns_do_open_file = YES;
@@ -5505,10 +5537,17 @@
 
 - (void)windowDidResize: (NSNotification *)notification
 {
+
+#if !defined (NEW_STYLE_FS) && ! defined (NS_IMPL_GNUSTEP)
+  NSWindow *theWindow = [notification object];
+  /* We can get notification on the non-FS window when in fullscreen mode.  */
+  if ([self window] != theWindow) return;
+#endif
+
 #ifdef NS_IMPL_GNUSTEP
   NSWindow *theWindow = [notification object];
 
-   /* in GNUstep, at least currently, it's possible to get a didResize
+   /* In GNUstep, at least currently, it's possible to get a didResize
       without getting a willResize.. therefore we need to act as if we got
       the willResize now */
   NSSize sz = [theWindow frame].size;
@@ -5526,10 +5565,6 @@
     }
 #endif /* NS_IMPL_COCOA */
 
-  /* Avoid loop under GNUstep due to call at beginning of this function.
-     (x_set_window_size causes a resize which causes
-     a "windowDidResize" which calls x_set_window_size).  */
-#ifndef NS_IMPL_GNUSTEP
   if (cols > 0 && rows > 0)
     {
       if (ns_in_resize)
@@ -5539,7 +5574,6 @@
           [self updateFrameSize: YES];
         }
     }
-#endif
 
   ns_send_appdefined (-1);
 }
@@ -5661,7 +5695,7 @@
 
   wr = [win frame];
   bwidth = f->border_width = wr.size.width - r.size.width;
-  tbar_height = FRAME_NS_TITLEBAR_HEIGHT (f) = wr.size.height - r.size.height;
+  tibar_height = FRAME_NS_TITLEBAR_HEIGHT (f) = wr.size.height - r.size.height;
 
   [win setAcceptsMouseMovedEvents: YES];
   [win setDelegate: self];
@@ -5870,8 +5904,16 @@
 - (void)windowDidEnterFullScreen:(NSNotification *)notification
 {
   [self setFSValue: FULLSCREEN_BOTH];
-#ifndef NEW_STYLE_FS
+#ifdef NEW_STYLE_FS
+  // Fix bad background.
+  if ([toolbar isVisible])
+    {
+      [toolbar setVisible:NO];
+      [toolbar setVisible:YES];
+    }
+#else
   [self windowDidBecomeKey:notification];
+  [nonfs_window orderOut:self];
 #endif
 }
 
@@ -5891,11 +5933,6 @@
 
 - (void)toggleFullScreen: (id)sender
 {
-  /* Bugs remain:
-     1) Having fullscreen in initial/default frame alist.
-     2) Fullscreen in default frame alist only applied to first frame.
-  */
-
 #ifdef NEW_STYLE_FS
   [[self window] toggleFullScreen:sender];
 #else
@@ -5904,7 +5941,7 @@
                          isEqual:[[NSScreen screens] objectAtIndex:0]];
   struct frame *f = emacsframe;
   NSSize sz;
-  NSRect r;
+  NSRect r, wr = [w frame];
   NSColor *col = ns_lookup_indexed_color (NS_FACE_BACKGROUND
                                           (FRAME_DEFAULT_FACE (f)),
                                           f);
@@ -5930,7 +5967,7 @@
         }
 
       fw = [[EmacsFSWindow alloc]
-                       initWithContentRect:[w contentRectForFrameRect:[w 
frame]]
+                       initWithContentRect:[w contentRectForFrameRect:wr]
                                  styleMask:NSBorderlessWindowMask
                                    backing:NSBackingStoreBuffered
                                      defer:YES
@@ -5938,9 +5975,7 @@
 
       [fw setContentView:[w contentView]];
       [fw setTitle:[w title]];
-      [fw makeKeyAndOrderFront:NSApp];
       [fw setDelegate:self];
-      [fw makeFirstResponder:self];
       [fw setAcceptsMouseMovedEvents: YES];
       [fw useOptimizedDrawing: YES];
       [fw setResizeIncrements: sz];
@@ -5950,18 +5985,26 @@
 
       f->border_width = 0;
       FRAME_NS_TITLEBAR_HEIGHT (f) = 0;
+      tobar_height = FRAME_TOOLBAR_HEIGHT (f);
+      FRAME_TOOLBAR_HEIGHT (f) = 0;
+      FRAME_EXTERNAL_TOOL_BAR (f) = 0;
 
       nonfs_window = w;
+
       [self windowWillEnterFullScreen:nil];
+      [fw makeKeyAndOrderFront:NSApp];
+      [fw makeFirstResponder:self];
       [w orderOut:self];
       r = [fw frameRectForContentRect:[[fw screen] frame]];
       [fw setFrame: r display:YES animate:YES];
       [self windowDidEnterFullScreen:nil];
+      [fw display];
     }
   else
     {
       fw = w;
       w = nonfs_window;
+      nonfs_window = nil;
 
       if (onFirstScreen)
         {
@@ -5980,7 +6023,10 @@
         [w setOpaque: NO];
       
       f->border_width = bwidth;
-      FRAME_NS_TITLEBAR_HEIGHT (f) = tbar_height;
+      FRAME_NS_TITLEBAR_HEIGHT (f) = tibar_height;
+      FRAME_TOOLBAR_HEIGHT (f) = tobar_height;
+      if (tobar_height)
+        FRAME_EXTERNAL_TOOL_BAR (f) = 1;
 
       [self windowWillExitFullScreen:nil];
       [fw setFrame: [w frame] display:YES animate:YES];
@@ -6553,6 +6599,11 @@
   return YES;
 }
 
+- (BOOL)canBecomeMainWindow
+{
+  return YES;
+}
+
 @end
 
 /* ==========================================================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]