From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Konstantinos Efstathiou Newsgroups: gmane.emacs.bugs Subject: bug#10014: Patch for fullscreen under Mac OS X 10.7 (Lion) Date: Thu, 10 Nov 2011 20:05:50 +0100 Message-ID: <54B660FD-3FC7-4AE8-8CBE-47468155BA6F@efstathiou.gr> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1320956584 12186 80.91.229.12 (10 Nov 2011 20:23:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 10 Nov 2011 20:23:04 +0000 (UTC) To: 10014@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 10 21:22:59 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ROb9F-00049C-Hm for geb-bug-gnu-emacs@m.gmane.org; Thu, 10 Nov 2011 21:22:57 +0100 Original-Received: from localhost ([::1]:58654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROb9F-0002n3-0C for geb-bug-gnu-emacs@m.gmane.org; Thu, 10 Nov 2011 15:22:57 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:51694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROb9A-0002mY-DW for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2011 15:22:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROb99-0003Ai-2I for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2011 15:22:52 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROb98-0003Ad-VE for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2011 15:22:51 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1ROb9L-0003Ct-45 for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2011 15:23:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Konstantinos Efstathiou Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Nov 2011 20:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 10014 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.132095655212274 (code B ref -1); Thu, 10 Nov 2011 20:23:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Nov 2011 20:22:32 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ROb8p-0003Bu-Ap for submit@debbugs.gnu.org; Thu, 10 Nov 2011 15:22:31 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ROZx0-0000hR-NL for submit@debbugs.gnu.org; Thu, 10 Nov 2011 14:06:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROZwi-000449-A6 for submit@debbugs.gnu.org; Thu, 10 Nov 2011 14:05:57 -0500 Original-Received: from lists.gnu.org ([140.186.70.17]:53944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROZwi-000445-6t for submit@debbugs.gnu.org; Thu, 10 Nov 2011 14:05:56 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:38285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROZwg-0004QR-Qq for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2011 14:05:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROZwf-00043H-4W for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2011 14:05:54 -0500 Original-Received: from hemel.efstathiou.gr ([178.79.145.232]:49354) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROZwe-00042d-Sy for bug-gnu-emacs@gnu.org; Thu, 10 Nov 2011 14:05:53 -0500 Original-Received: from Konstantinos Efstathiou; ESMTPSA id 10A488005 for ; Thu, 10 Nov 2011 20:05:50 +0100 (CET) X-Sent-From: konstantinos@efstathiou.gr X-Mailer: Apple Mail (2.1251.1) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Thu, 10 Nov 2011 15:22:30 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 10 Nov 2011 15:23:03 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:53793 Archived-At: ** Description The attached patch adds fullscreen support to Cocoa Emacs running under = Lion. The fullscreen support works only under OS X 10.7 and takes = advantage of the support for fullscreen applications that appeared in = this version. In particular the fullscreen window is assigned its own = space (here window means Emacs frame). The patch reuses some code from = previous patches that add support for fullscreen under OS X <=3D 10.6 = but were never included in Emacs. The code works by implementing the fullscreen APIs provided in 10.7, = especially the NSWindowDelegate methods windowDidEnterFullScreen:, = windowDidExitFullScreen:, and = window:willUseFullScreenPresentationOptions:. Furthermore, the Emacs = Lisp function ns-toggle-fullscreen is added. The most potentially dangerous changes are the ones to = free_frame_tool_bar and update_frame_tool_bar (in src/nsmenu.m) where = the window toolbar is now set to nil in the former function and to [view = toolbar] in the latter. Before, only the visibility of the toolbar would = change in these functions. This interacted badly with fullscreen support = under Lion because when the window would go fullscreen its toolbar would = become visible even if it was empty. One bug that exists is that if one toggles the toolbar visibility while = the window is fullscreen, the toolbar stops working properly. Finally, I have removed the code that was used to add the window size to = the window title when the window was resized. This should be determined = by appropriately modifying frame-title-format and not by low-level C = code because in the latter case this behavior cannot be modified by the = user. ** ChangeLog * lisp/term/ns-win.el, src/nsterm.m, src/nsfns.m, src/nsmenu.m, = src/nsterm.h: Add fullscreen support to Cocoa Emacs under Mac OS X 10.7 = (Lion). ** Patch =3D=3D=3D modified file 'lisp/term/ns-win.el' *** lisp/term/ns-win.el 2011-10-01 20:32:01 +0000 --- lisp/term/ns-win.el 2011-11-10 16:22:51 +0000 *************** See the documentation of `create-fontset *** 928,933 **** --- 928,937 ---- (add-to-list 'frame-creation-function-alist '(ns . = x-create-frame-with-faces)) (add-to-list 'window-system-initialization-alist '(ns . = ns-initialize-window-system)) =20 + (declare-function ns-toggle-fullscreen-internal "nsfns.m" ()) + (defun ns-toggle-fullscreen () + (interactive) + (ns-toggle-fullscreen-internal)) =20 (provide 'ns-win) =20 =3D=3D=3D modified file 'src/nsfns.m' *** src/nsfns.m 2011-11-05 12:25:01 +0000 --- src/nsfns.m 2011-11-10 18:54:31 +0000 *************** Value is t if tooltip was open, nil othe *** 2567,2572 **** --- 2567,2588 ---- } =20 =20 + DEFUN ("ns-toggle-fullscreen-internal", = Fns_toggle_fullscreen_internal, Sns_toggle_fullscreen_internal, + 0, 0, 0, + doc: /* Toggle fulscreen mode */) + () + { + struct frame *f =3D SELECTED_FRAME(); + EmacsWindow *window =3D ns_get_window(f); +=20 + #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >=3D = MAC_OS_X_VERSION_10_7 + [window toggleFullScreen:nil]; + #endif +=20 + return Qnil; + } +=20 +=20 /* = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 Class implementations *************** be used as the image of the icon represe *** 2724,2729 **** --- 2740,2747 ---- defsubr (&Sx_show_tip); defsubr (&Sx_hide_tip); =20 + defsubr (&Sns_toggle_fullscreen_internal); +=20 /* used only in fontset.c */ check_window_system_func =3D check_ns; =20 =3D=3D=3D modified file 'src/nsmenu.m' *** src/nsmenu.m 2011-07-29 05:31:12 +0000 --- src/nsmenu.m 2011-11-10 16:22:51 +0000 *************** free_frame_tool_bar (FRAME_PTR f) *** 986,992 **** = --------------------------------------------------------------------------= */ { BLOCK_INPUT; ! [[FRAME_NS_VIEW (f) toolbar] setVisible: NO]; FRAME_TOOLBAR_HEIGHT (f) =3D 0; UNBLOCK_INPUT; } --- 986,992 ---- = --------------------------------------------------------------------------= */ { BLOCK_INPUT; ! [[FRAME_NS_VIEW (f) window] setToolbar: nil]; FRAME_TOOLBAR_HEIGHT (f) =3D 0; UNBLOCK_INPUT; } *************** update_frame_tool_bar (FRAME_PTR f) *** 1003,1008 **** --- 1003,1010 ---- EmacsToolbar *toolbar =3D [view toolbar]; =20 BLOCK_INPUT; + [window setToolbar: toolbar]; +=20 [toolbar clearActive]; =20 /* update EmacsToolbar as in GtkUtils, build items list */ =3D=3D=3D modified file 'src/nsterm.h' *** src/nsterm.h 2011-09-09 01:06:52 +0000 --- src/nsterm.h 2011-11-10 18:39:22 +0000 *************** along with GNU Emacs. If not, see =3D = MAC_OS_X_VERSION_10_7 + - (void)windowDidEnterFullScreen:(NSNotification *)notification + { + NSTRACE (windowDidEnterFullScreen); + /* NSLog(@"Calling windowDidEnterFullScreen"); */ + =20 + NSWindow *window =3D [self window]; + NSRect wr =3D [window frame]; + int w =3D (int)wr.size.width - emacsframe->border_width; + int h =3D (int)wr.size.height; + cols =3D FRAME_PIXEL_WIDTH_TO_TEXT_COLS(emacsframe, w); + rows =3D FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(emacsframe, h); + /* NSLog(@"window_size=3D%dx%d (%dx%d)", w, h, cols, rows); */ + FRAME_PIXEL_WIDTH (emacsframe) =3D w; + FRAME_PIXEL_HEIGHT (emacsframe) =3D h; + change_frame_size (emacsframe, rows, cols, 0, 1, 0); + SET_FRAME_GARBAGED (emacsframe); + cancel_mouse_face (emacsframe); + ns_send_appdefined (-1); + } + #endif +=20 + #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >=3D = MAC_OS_X_VERSION_10_7 + - (void)windowDidExitFullScreen:(NSNotification *)notification + { + NSTRACE (windowDidExitFullScreen); + /* NSLog(@"Calling windowDidExitFullScreen"); */ + =20 + NSWindow *window =3D [self window]; + NSRect wr =3D [window frame]; + int w =3D (int)wr.size.width - emacsframe->border_width; + int h =3D (int)wr.size.height + - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) + - FRAME_TOOLBAR_HEIGHT (emacsframe); + cols =3D FRAME_PIXEL_WIDTH_TO_TEXT_COLS(emacsframe, w); + rows =3D FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(emacsframe, h); + /* NSLog(@"window_size=3D%dx%d (%dx%d)", w, h, cols, rows); */ + FRAME_PIXEL_WIDTH (emacsframe) =3D w; + FRAME_PIXEL_HEIGHT (emacsframe) =3D h; + change_frame_size (emacsframe, rows, cols, 0, 1, 0); + SET_FRAME_GARBAGED (emacsframe); + cancel_mouse_face (emacsframe); + ns_send_appdefined (-1); + } + #endif +=20 + #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >=3D = MAC_OS_X_VERSION_10_7 + - (NSApplicationPresentationOptions)window:(NSWindow *)window = willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)pro= posedOptions + { + /* NSLog(@"Calling window:willUseFullScreenPresentationOptions: = %d", proposedOptions); */ + return proposedOptions | NSApplicationPresentationAutoHideToolbar; + } + #endif +=20 =20 - (void)windowDidBecomeKey: (NSNotification *)notification /* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() = */ *************** ns_term_shutdown (int sig) *** 5559,5564 **** --- 5573,5586 ---- [NSApp registerServicesMenuSendTypes: ns_send_types returnTypes: nil]; =20 + #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >=3D = MAC_OS_X_VERSION_10_7 + if (NSApp !=3D nil && [NSApp isActive]) + { + [NSApp setPresentationOptions: NSApplicationPresentationFullScreen = | [NSApp presentationOptions] ]; + [win setCollectionBehavior: = NSWindowCollectionBehaviorFullScreenPrimary | [win collectionBehavior] = ]; + } + #endif +=20 ns_window_num++; return self; }