Skip to content

Instantly share code, notes, and snippets.

@AriT93
Created November 25, 2011 19:46
Show Gist options
  • Save AriT93/1394288 to your computer and use it in GitHub Desktop.
Save AriT93/1394288 to your computer and use it in GitHub Desktop.
emacs 24 fullscreen
diff --git a/src/nsterm.m b/src/nsterm.m
index c5b28d5..8ff4e3e 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -5488,9 +5488,7 @@ ns_term_shutdown (int sig)
win = [[EmacsWindow alloc]
initWithContentRect: r
styleMask: (NSResizableWindowMask |
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
NSTitledWindowMask |
-#endif
NSMiniaturizableWindowMask |
NSClosableWindowMask)
backing: NSBackingStoreBuffered
@@ -5503,6 +5501,7 @@ ns_term_shutdown (int sig)
[win setAcceptsMouseMovedEvents: YES];
[win setDelegate: self];
[win useOptimizedDrawing: YES];
+ [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
sz.width = FRAME_COLUMN_WIDTH (f);
sz.height = FRAME_LINE_HEIGHT (f);
@@ -6018,6 +6017,43 @@ ns_term_shutdown (int sig)
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 */
@AriT93
Copy link
Author

AriT93 commented Nov 26, 2011

this is based on typesters feature branch at https://github.com/typester/emacs this worked off a pull of the git repo at savannah.org today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment