Ticket #34844: patch-fullscreen.diff
File patch-fullscreen.diff, 7.0 KB (added by seanfarley (Sean Farley), 12 years ago) |
---|
-
lisp/term/ns-win.el
old new 1263 1263 (add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system)) 1264 1264 1265 1265 1266 (declare-function ns-toggle-fullscreen-internal "nsfns.m" ()) 1267 (defun ns-toggle-fullscreen () 1268 (interactive) 1269 (ns-toggle-fullscreen-internal)) 1270 1266 1271 (provide 'ns-win) 1267 1272 1268 1273 ;; arch-tag: eb138a45-4e2e-4d68-b1c9-a39665731644 -
src/nsfns.m
old new 2599 2599 2600 2600 #endif 2601 2601 2602 DEFUN ("ns-toggle-fullscreen-internal", Fns_toggle_fullscreen_internal, Sns_toggle_fullscreen_internal, 2603 0, 0, 0, 2604 doc: /* Toggle fulscreen mode */) 2605 () 2606 { 2607 struct frame *f = SELECTED_FRAME(); 2608 EmacsWindow *window = ns_get_window(f); 2609 2610 EmacsWindow *new_window = [window toggleFullscreen]; 2611 FRAME_NS_WINDOW(f) = new_window; 2612 2613 NSRect r = [new_window contentRectForFrameRect:[new_window frame]]; 2614 int cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, r.size.width); 2615 int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, r.size.height); 2616 2617 change_frame_size (f, rows, cols, 0, 1, 0); /* pretend, delay, safe */ 2618 FRAME_PIXEL_WIDTH (f) = (int)r.size.width; 2619 FRAME_PIXEL_HEIGHT (f) = (int)r.size.height; 2620 2621 f->border_width = [new_window frame].size.width - r.size.width; 2622 FRAME_NS_TITLEBAR_HEIGHT (f) = 2623 [new_window frame].size.height - r.size.height; 2624 2625 [[new_window delegate] windowDidMove:nil]; 2626 2627 return Qnil; 2628 } 2629 2602 2630 2603 2631 /* ========================================================================== 2604 2632 … … 2684 2712 defsubr (&Sx_show_tip); 2685 2713 defsubr (&Sx_hide_tip); 2686 2714 2715 defsubr (&Sns_toggle_fullscreen_internal); 2716 2687 2717 /* used only in fontset.c */ 2688 2718 check_window_system_func = check_ns; 2689 2719 -
src/nsterm.h
old new 95 95 { 96 96 NSPoint grabOffset; 97 97 } 98 99 -(EmacsWindow *)toggleFullscreen; 100 101 @end 102 103 /* 10.5 or below is not supported [NSWindow setStyleMask:], so require content swap hack */ 104 @interface EmacsFullWindow : EmacsWindow { 105 EmacsWindow *normalWindow; 106 } 107 108 -(id)initWithNormalWindow:(EmacsWindow *)window; 109 -(EmacsWindow *)getNormalWindow; 110 98 111 @end 99 112 113 // dummy for 10.5- 114 #define NSApplicationPresentationDefault 0 115 #define NSApplicationPresentationAutoHideDock (1 << 0) 116 #define NSApplicationPresentationAutoHideMenuBar (1 << 2) 100 117 101 118 /* ========================================================================== 102 119 -
src/nsterm.m
old new 685 685 /*debug_lock--; */ 686 686 } 687 687 688 if (view) { 689 EmacsFullWindow *win = [view window]; 690 if ([win isKindOfClass:[EmacsFullWindow class]]) { 691 [[win getNormalWindow] orderOut:nil]; 692 } 693 } 694 688 695 if (view) 689 696 #ifdef NS_IMPL_GNUSTEP 690 697 r ? [view lockFocusInRect: u] : [view lockFocus]; … … 1130 1137 f->scroll_bar_actual_width = NS_SCROLL_BAR_WIDTH (f); 1131 1138 compute_fringe_widths (f, 0); 1132 1139 1133 pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); 1134 pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows); 1140 if ([window isKindOfClass:[EmacsFullWindow class]]) { 1141 pixelwidth = [[window screen] frame].size.width; 1142 pixelheight = [[window screen] frame].size.height; 1143 } 1144 else { 1145 pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); 1146 pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows); 1147 } 1135 1148 1136 1149 /* If we have a toolbar, take its height into account. */ 1137 1150 if (tb) … … 1149 1162 + FRAME_NS_TOOLBAR_HEIGHT (f); 1150 1163 1151 1164 /* constrain to screen if we can */ 1152 if (screen )1165 if (screen && ![window isKindOfClass:[EmacsFullWindow class]]) 1153 1166 { 1154 1167 NSSize sz = [screen visibleFrame].size; 1155 1168 NSSize ez = { wr.size.width - sz.width, wr.size.height - sz.height }; … … 1196 1209 change_frame_size (f, rows, cols, 0, 1, 0); /* pretend, delay, safe */ 1197 1210 FRAME_PIXEL_WIDTH (f) = pixelwidth; 1198 1211 FRAME_PIXEL_HEIGHT (f) = pixelheight; 1199 /* SET_FRAME_GARBAGED (f); // this short-circuits expose call in drawRect */1212 /* SET_FRAME_GARBAGED (f); // this short-circuits expose call in drawRect */ 1200 1213 1201 1214 mark_window_cursors_off (XWINDOW (f->root_window)); 1202 1215 cancel_mouse_face (f); … … 5589 5602 5590 5603 @implementation EmacsWindow 5591 5604 5605 -(NSWindow *)toggleFullscreen { 5606 BOOL isFullscreen = [[self className] isEqualToString:@"EmacsFullWindow"]; 5607 NSWindow *win; 5608 5609 if (isFullscreen) { 5610 EmacsFullWindow *f = (EmacsFullWindow *)self; 5611 EmacsWindow *w = [f getNormalWindow]; 5612 5613 [w setContentView:[f contentView]]; 5614 [w makeKeyAndOrderFront:nil]; 5615 5616 [f close]; 5617 5618 win = w; 5619 5620 if ([[self screen] isEqual:[[NSScreen screens] objectAtIndex:0]]) { 5621 if ([NSApp respondsToSelector:@selector(setPresentationOptions:)]) { 5622 [NSApp setPresentationOptions:NSApplicationPresentationDefault]; 5623 } 5624 else { 5625 [NSMenu setMenuBarVisible:YES]; 5626 } 5627 } 5628 } 5629 else { 5630 [self deminiaturize:nil]; 5631 5632 if ([[self screen] isEqual:[[NSScreen screens] objectAtIndex:0]]) { 5633 if ([NSApp respondsToSelector:@selector(setPresentationOptions:)]) { 5634 [NSApp setPresentationOptions:NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar]; 5635 } 5636 else { 5637 [NSMenu setMenuBarVisible:NO]; 5638 } 5639 } 5640 5641 [self orderOut:nil]; 5642 5643 EmacsFullWindow *f = [[EmacsFullWindow alloc] initWithNormalWindow:self]; 5644 EmacsView *view = (EmacsView *)[self delegate]; 5645 [f setDelegate:view]; 5646 [f makeFirstResponder:view]; 5647 [f setContentView:[self contentView]]; 5648 [f setContentSize:[[self screen] frame].size]; 5649 [f setTitle:[self title]]; 5650 [f makeKeyAndOrderFront:nil]; 5651 5652 win = f; 5653 } 5654 5655 return win; 5656 } 5657 5592 5658 /* called only on resize clicks by special case in EmacsApp-sendEvent */ 5593 5659 - (void)mouseDown: (NSEvent *)theEvent 5594 5660 { … … 5647 5713 5648 5714 @end /* EmacsWindow */ 5649 5715 5716 @implementation EmacsFullWindow 5717 5718 -(BOOL)canBecomeKeyWindow { 5719 return YES; 5720 } 5721 5722 -(id)initWithNormalWindow:(EmacsWindow *)window { 5723 self = [super initWithContentRect:[window contentRectForFrameRect:[[window screen] frame]] 5724 styleMask:NSBorderlessWindowMask 5725 backing:NSBackingStoreBuffered 5726 defer:YES]; 5727 if (self) { 5728 normalWindow = window; 5729 [self setAcceptsMouseMovedEvents: YES]; 5730 [self useOptimizedDrawing: YES]; 5731 } 5732 5733 return self; 5734 } 5735 5736 -(EmacsWindow *)getNormalWindow { 5737 return normalWindow; 5738 } 5739 5740 @end /* EmacsFullWindow */ 5741 5650 5742 5651 5743 /* ========================================================================== 5652 5744