Ticket #34844: patch-fullscreen.diff

File patch-fullscreen.diff, 7.0 KB (added by seanfarley (Sean Farley), 12 years ago)

updated patch for fullscreen

  • lisp/term/ns-win.el

    old new  
    12631263(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
    12641264
    12651265
     1266(declare-function ns-toggle-fullscreen-internal "nsfns.m" ())
     1267(defun ns-toggle-fullscreen ()
     1268  (interactive)
     1269  (ns-toggle-fullscreen-internal))
     1270
    12661271(provide 'ns-win)
    12671272
    12681273;; arch-tag: eb138a45-4e2e-4d68-b1c9-a39665731644
  • src/nsfns.m

    old new  
    25992599
    26002600#endif
    26012601
     2602DEFUN ("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
    26022630
    26032631/* ==========================================================================
    26042632
     
    26842712  defsubr (&Sx_show_tip);
    26852713  defsubr (&Sx_hide_tip);
    26862714
     2715  defsubr (&Sns_toggle_fullscreen_internal);
     2716
    26872717  /* used only in fontset.c */
    26882718  check_window_system_func = check_ns;
    26892719
  • src/nsterm.h

    old new  
    9595{
    9696  NSPoint grabOffset;
    9797}
     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
    98111@end
    99112
     113// dummy for 10.5-
     114#define NSApplicationPresentationDefault 0
     115#define NSApplicationPresentationAutoHideDock (1 <<  0)
     116#define NSApplicationPresentationAutoHideMenuBar (1 <<  2)
    100117
    101118/* ==========================================================================
    102119
  • src/nsterm.m

    old new  
    685685/*debug_lock--; */
    686686            }
    687687
     688          if (view) {
     689              EmacsFullWindow *win = [view window];
     690              if ([win isKindOfClass:[EmacsFullWindow class]]) {
     691                  [[win getNormalWindow] orderOut:nil];
     692              }
     693          }
     694
    688695          if (view)
    689696#ifdef NS_IMPL_GNUSTEP
    690697            r ? [view lockFocusInRect: u] : [view lockFocus];
     
    11301137  f->scroll_bar_actual_width = NS_SCROLL_BAR_WIDTH (f);
    11311138  compute_fringe_widths (f, 0);
    11321139
    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  }
    11351148
    11361149  /* If we have a toolbar, take its height into account. */
    11371150  if (tb)
     
    11491162                  + FRAME_NS_TOOLBAR_HEIGHT (f);
    11501163
    11511164  /* constrain to screen if we can */
    1152   if (screen)
     1165  if (screen && ![window isKindOfClass:[EmacsFullWindow class]])
    11531166    {
    11541167      NSSize sz = [screen visibleFrame].size;
    11551168      NSSize ez = { wr.size.width - sz.width, wr.size.height - sz.height };
     
    11961209  change_frame_size (f, rows, cols, 0, 1, 0); /* pretend, delay, safe */
    11971210  FRAME_PIXEL_WIDTH (f) = pixelwidth;
    11981211  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 */
    12001213
    12011214  mark_window_cursors_off (XWINDOW (f->root_window));
    12021215  cancel_mouse_face (f);
     
    55895602
    55905603@implementation EmacsWindow
    55915604
     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
    55925658/* called only on resize clicks by special case in EmacsApp-sendEvent */
    55935659- (void)mouseDown: (NSEvent *)theEvent
    55945660{
     
    56475713
    56485714@end /* EmacsWindow */
    56495715
     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
    56505742
    56515743/* ==========================================================================
    56525744