Source

macports / aqua / emacs-app / files / patch-lion-fullscreen.diff

--- src/nsterm.m.old	2011-11-25 22:36:38.000000000 +0900
+++ src/nsterm.m	2011-11-25 22:59:56.000000000 +0900
@@ -5182,6 +5182,7 @@
   [win setAcceptsMouseMovedEvents: YES];
   [win setDelegate: self];
   [win useOptimizedDrawing: YES];
+  [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
 
   sz.width = FRAME_COLUMN_WIDTH (f);
   sz.height = FRAME_LINE_HEIGHT (f);
@@ -5671,6 +5672,43 @@
   cols = c;
 }
 
+- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions {
+    return proposedOptions | NSApplicationPresentationAutoHideToolbar;
+}
+
+- (NSSize)window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)proposedSize {
+    NSRect r = NSMakeRect(0.f, 0.f, proposedSize.width, proposedSize.height);
+    int cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS(emacsframe, r.size.width);
+    int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(emacsframe, r.size.height);
+
+    change_frame_size (emacsframe, rows, cols, 0, 1, 0); /* pretend, delay, safe */
+    FRAME_PIXEL_WIDTH (emacsframe) = (int)r.size.width;
+    FRAME_PIXEL_HEIGHT (emacsframe) = (int)r.size.height;
+
+    emacsframe->border_width = [window frame].size.width - r.size.width;
+    FRAME_NS_TITLEBAR_HEIGHT (emacsframe) = 0;
+
+    return proposedSize;
+}
+
+- (void)windowDidExitFullScreen:(NSNotification *)notification {
+    NSWindow* window = [notification object];
+
+    NSRect r = [window contentRectForFrameRect:[window frame]];
+    int cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS(emacsframe, r.size.width);
+    int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(emacsframe, r.size.height);
+
+    change_frame_size (emacsframe, rows, cols, 0, 1, 0); /* pretend, delay, safe */
+    FRAME_PIXEL_WIDTH (emacsframe) = (int)r.size.width;
+    FRAME_PIXEL_HEIGHT (emacsframe) = (int)r.size.height;
+
+    emacsframe->border_width = [window frame].size.width - r.size.width;
+    FRAME_NS_TITLEBAR_HEIGHT (emacsframe) =
+        [window frame].size.height - r.size.height;
+
+    [[window delegate] windowDidMove:nil];
+}
+
 @end  /* EmacsView */