From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#25408: Remove Decorations Around Emacs Frame (NS port) Date: Mon, 17 Apr 2017 15:56:13 +0100 Message-ID: <20170417145613.GA78089@breton.holly.idiocy.org> References: <9efbe1e3-e8aa-f056-bc5c-5a41f10b6d42@gmail.com> <58996EED.6030601@gmx.at> <3d34793f-4b7c-d4ea-74ec-49ce84214cc8@gmail.com> <589F1F58.1050807@gmx.at> <20170412173858.GB82486@breton.holly.idiocy.org> <58EE7C4B.90205@gmx.at> <20170412195121.GA95643@breton.holly.idiocy.org> <58EF2462.9010806@gmx.at> <20170415162922.GA47622@breton.holly.idiocy.org> <58F276F4.4030805@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="M9NhX3UHpAaciwkO" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1492441041 32679 195.159.176.226 (17 Apr 2017 14:57:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 17 Apr 2017 14:57:21 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: Arthur Miller , 25408@debbugs.gnu.org, =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel , Anders Lindgren To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 17 16:57:14 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d085Y-0008Fz-LK for geb-bug-gnu-emacs@m.gmane.org; Mon, 17 Apr 2017 16:57:12 +0200 Original-Received: from localhost ([::1]:37002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d085e-0008Tm-EZ for geb-bug-gnu-emacs@m.gmane.org; Mon, 17 Apr 2017 10:57:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d085S-0008RG-6O for bug-gnu-emacs@gnu.org; Mon, 17 Apr 2017 10:57:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d085O-00015l-5t for bug-gnu-emacs@gnu.org; Mon, 17 Apr 2017 10:57:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54415) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d085N-00015S-Vo for bug-gnu-emacs@gnu.org; Mon, 17 Apr 2017 10:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d085N-0007Eb-Oo for bug-gnu-emacs@gnu.org; Mon, 17 Apr 2017 10:57:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Apr 2017 14:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25408 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25408-submit@debbugs.gnu.org id=B25408.149244099027771 (code B ref 25408); Mon, 17 Apr 2017 14:57:01 +0000 Original-Received: (at 25408) by debbugs.gnu.org; 17 Apr 2017 14:56:30 +0000 Original-Received: from localhost ([127.0.0.1]:52614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d084r-0007Dr-Fh for submit@debbugs.gnu.org; Mon, 17 Apr 2017 10:56:30 -0400 Original-Received: from mail-wm0-f46.google.com ([74.125.82.46]:35287) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d084o-0007Dc-Fy for 25408@debbugs.gnu.org; Mon, 17 Apr 2017 10:56:27 -0400 Original-Received: by mail-wm0-f46.google.com with SMTP id w64so35561988wma.0 for <25408@debbugs.gnu.org>; Mon, 17 Apr 2017 07:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=OhST4ICkLxrEqAOCMLKDuSrzYirsb6WntEY3slaHojs=; b=pOjaDNXlevcvdgDZHYPlGbCWy9voCRtkHGNAiwtTOYra0bIwQsX0cgkJITAFmRn0q/ VNQMtg6YrUBkvpFLqln05LvKZaNCpTuBlZEacUncRGBCoiDHPME3fc3DinpzXe0PPdI2 cfsIPYowZUoOleMG8meo9xsqpgsFksC1ZohttAi8iuXaTyrhU4O2tZj9PYGL2DwMm1n/ HOQir5emXffhazaM6S01O80kOKh9OxN5Uu1TOaJLapo3Z8oqQ6SYiIoOQ0cE/Q+AiGit Qj77NqZr7ZiVIEKSJEF3a69vtbhn79G5Fv0i5l3P3WeZrxSIJYEdXC+uPwbr4YIJP8E4 U3sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=OhST4ICkLxrEqAOCMLKDuSrzYirsb6WntEY3slaHojs=; b=Fo6orTFeCFpsOpVNWAql1CplixEYyAwTHsNzwwBFCJ62citNsOoLDWbEQ4tgyIzIXT GZzQWkYYikEmra9yf/sQua6bV8j1sGbfqli88hQUCQA2DWSwHB40tIFhOR0Rtkri9fRp wkVp6lBd5qKoBIr1DxulDzTVnj/KouqieFGYR6gsnV3viWicJvJJW19L81TNfNRmBYXY quKRiETarbY9wkjHHDvhj/B0Dc3Ngh6VAnl4w7sXrcrM1AHvoVU9BQXJCm8L4ni3lDZ0 59j9+Npb+pGEkQ+Q6DKt2z5o/uE7p/LUhSscKnnghWpH4HYba4LIss7jC3TAMEdNUsLO tJXw== X-Gm-Message-State: AN3rC/5+9+p2igaNwtf7X/l1x7p10GJhIGSZMRyOAioPN52e19LKGmCG 3VINZgwiubuY7Q== X-Received: by 10.28.209.13 with SMTP id i13mr8431616wmg.31.1492440980788; Mon, 17 Apr 2017 07:56:20 -0700 (PDT) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-2908-211d-64ad-5635.holly.idiocy.org. [2001:8b0:3f8:8129:2908:211d:64ad:5635]) by smtp.gmail.com with ESMTPSA id 94sm14581392wrp.34.2017.04.17.07.56.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Apr 2017 07:56:19 -0700 (PDT) Content-Disposition: inline In-Reply-To: <58F276F4.4030805@gmx.at> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:131693 Archived-At: --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sat, Apr 15, 2017 at 09:39:32PM +0200, martin rudalics wrote: > > It appears that a child window in NS is just a normal window which > > moves and closes with its parent. So I think that means it’s more like > > X’s child windows, except they don’t get clipped at the parent > > window’s edges. They can also end up below the parent window. > > It sounds like NS can do more than Windows and X here. The clipping > issue is a nuisance. Could you try to create one and play around with > it a bit? I’ve attached a partial patch for NS. It should handle undecorated frames and parent‐child frame relationships. I’ll keep working on the rest, but thought I’d throw this out there in case anyone can spot anything obviously wrong. Anders, I hope it’s OK CCing you in. I think you might appreciate the following (after applying the patch): emacs -Q (set-frame-parameter nil 'undecorated t) (setq ns-auto-hide-menu-bar t) (toggle-frame-maximized) More info at: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25408#77 -- Alan Third --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=utf-8 Content-Description: parent and undecorated frames on NS Content-Disposition: attachment; filename="0001-Add-undecorated-and-parent-frames-to-NS-port.patch" Content-Transfer-Encoding: 8bit >From bd8ffa277c1af68a3ed8008683b01a0249fa108e Mon Sep 17 00:00:00 2001 From: Alan Third Date: Fri, 14 Apr 2017 10:02:38 +0100 Subject: [PATCH] Add undecorated and parent frames to NS port MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/frame.h: * src/frame.c: Enable ‘undecorated’ and ‘parent’ frame definitions. * src/nsfns.m: Add x_set_parent_frame and x_set_undecorated to handler struct. (Fx-create_frame): Handle ‘parent-frame’ and ‘undecorated’ frame parameter. * src/nsmenu.m (free_frame_tool_bar, update_frame_tool_bar): FRAME_TOOLBAR_HEIGHT is no longer a variable. * src/nsterm.h (NS_PARENT_WINDOW_LEFT_POS, NS_PARENT_WINDOW_TOP_POS): Add #defines to find the screen position of the parent frame. (EmacsView): Remove redundant toolbar variables and add createToolbar method. (FRAME_NS_TITLEBAR_HEIGHT, FRAME_TOOLBAR_HEIGHT): Always calculate the values instead of storing them in a variable. * src/nsterm.m (x_set_offset, windowDidMove): Take parent frame position into account when positioning frames. (initFrameFromEmacs): Link parent frame, and take position into account when creating new frame. (x_set_window_size): Remove toolbar height calculation. (x_set_parent_frame): (x_set_undecorated): New function. (updateFrameSize): Change NSTRACE message to reflect new reality and no longer reset frame size. (windowWillResize): Don’t change NS window name when the titlebar is invisible. (createToolbar): Move toolbar creation code into it’s own method. (initFrameFromEmacs): Handle case where frame is created without a titlebar and remove toolbar creation code. (toggleFullScreen): FRAME_TOOLBAR_HEIGHT and FRAME_NS_TITLEBAR_HEIGHT are no longer variables. --- src/frame.c | 2 - src/frame.h | 14 ++-- src/nsfns.m | 23 ++++++- src/nsmenu.m | 8 --- src/nsterm.h | 39 ++++++++++- src/nsterm.m | 217 +++++++++++++++++++++++++++++++++++++++++++---------------- 6 files changed, 221 insertions(+), 82 deletions(-) diff --git a/src/frame.c b/src/frame.c index 282b691c27..681a245ee0 100644 --- a/src/frame.c +++ b/src/frame.c @@ -683,7 +683,6 @@ make_frame (bool mini_p) f->vertical_scroll_bar_type = vertical_scroll_bar_none; f->horizontal_scroll_bars = false; f->want_fullscreen = FULLSCREEN_NONE; -#if ! defined (HAVE_NS) f->undecorated = false; #ifndef HAVE_NTGUI f->override_redirect = false; @@ -692,7 +691,6 @@ make_frame (bool mini_p) f->no_focus_on_map = false; f->no_accept_focus = false; f->z_group = z_group_none; -#endif #if ! defined (USE_GTK) && ! defined (HAVE_NS) f->last_tool_bar_item = -1; #endif diff --git a/src/frame.h b/src/frame.h index 36af6e6780..4aa7c34a29 100644 --- a/src/frame.h +++ b/src/frame.h @@ -75,10 +75,10 @@ struct frame Usually it is nil. */ Lisp_Object title; -#if defined (HAVE_WINDOW_SYSTEM) && !defined (HAVE_NS) +#if defined (HAVE_WINDOW_SYSTEM) /* This frame's parent frame, if it has one. */ Lisp_Object parent_frame; -#endif /* HAVE_WINDOW_SYSTEM and not HAVE_NS */ +#endif /* HAVE_WINDOW_SYSTEM */ /* The frame which should receive keystrokes that occur in this frame, or nil if they should go to the frame itself. This is @@ -332,7 +332,7 @@ struct frame bool_bf horizontal_scroll_bars : 1; #endif /* HAVE_WINDOW_SYSTEM */ -#if defined (HAVE_WINDOW_SYSTEM) && !defined (HAVE_NS) +#if defined (HAVE_WINDOW_SYSTEM) /* True if this is an undecorated frame. */ bool_bf undecorated : 1; @@ -570,7 +570,7 @@ fset_face_alist (struct frame *f, Lisp_Object val) { f->face_alist = val; } -#if defined (HAVE_WINDOW_SYSTEM) && !defined (HAVE_NS) +#if defined (HAVE_WINDOW_SYSTEM) INLINE void fset_parent_frame (struct frame *f, Lisp_Object val) { @@ -914,7 +914,7 @@ default_pixels_per_inch_y (void) #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) f, 0) #endif /* HAVE_WINDOW_SYSTEM */ -#if defined (HAVE_WINDOW_SYSTEM) && !defined (HAVE_NS) +#if defined (HAVE_WINDOW_SYSTEM) #define FRAME_UNDECORATED(f) ((f)->undecorated) #ifdef HAVE_NTGUI #define FRAME_OVERRIDE_REDIRECT(f) ((void) f, 0) @@ -934,7 +934,7 @@ default_pixels_per_inch_y (void) #define FRAME_Z_GROUP_ABOVE_SUSPENDED(f) \ ((f)->z_group == z_group_above_suspended) #define FRAME_Z_GROUP_BELOW(f) ((f)->z_group == z_group_below) -#else /* not HAVE_WINDOW_SYSTEM or HAVE_NS */ +#else /* not HAVE_WINDOW_SYSTEM */ #define FRAME_UNDECORATED(f) ((void) f, 0) #define FRAME_OVERRIDE_REDIRECT(f) ((void) f, 0) #define FRAME_PARENT_FRAME(f) ((void) f, NULL) @@ -945,7 +945,7 @@ default_pixels_per_inch_y (void) #define FRAME_Z_GROUP_NONE(f) ((void) f, true) #define FRAME_Z_GROUP_ABOVE(f) ((void) f, false) #define FRAME_Z_GROUP_BELOW(f) ((void) f, false) -#endif /* HAVE_WINDOW_SYSTEM and not HAVE_NS */ +#endif /* HAVE_WINDOW_SYSTEM */ /* Whether horizontal scroll bars are currently enabled for frame F. */ #if USE_HORIZONTAL_SCROLL_BARS diff --git a/src/nsfns.m b/src/nsfns.m index 8a923dd393..6dddc64cb4 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -972,8 +972,8 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side 0, /* x_set_sticky */ 0, /* x_set_tool_bar_position */ 0, /* x_set_inhibit_double_buffering */ - 0, /* x_set_undecorated */ - 0, /* x_set_parent_frame */ + x_set_undecorated, /* x_set_undecorated */ + x_set_parent_frame, /* x_set_parent_frame */ 0, /* x_set_skip_taskbar */ 0, /* x_set_no_focus_on_map */ 0, /* x_set_no_accept_focus */ @@ -1087,7 +1087,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side ptrdiff_t count = specpdl_ptr - specpdl; Lisp_Object display; struct ns_display_info *dpyinfo = NULL; - Lisp_Object parent; + Lisp_Object parent, parent_frame; struct kboard *kb; static int desc_ctr = 1; int x_width = 0, x_height = 0; @@ -1265,6 +1265,23 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, 1, Qx_create_frame_1); + tem = x_get_arg (dpyinfo, parms, Qundecorated, NULL, NULL, RES_TYPE_BOOLEAN); + FRAME_UNDECORATED (f) = !NILP (tem) && !EQ (tem, Qunbound); + store_frame_param (f, Qundecorated, FRAME_UNDECORATED (f) ? Qt : Qnil); + + parent_frame = x_get_arg (dpyinfo, parms, Qparent_frame, NULL, NULL, + RES_TYPE_SYMBOL); + /* Accept parent-frame iff parent-id was not specified. */ + if (!NILP (parent) + || EQ (parent_frame, Qunbound) + || NILP (parent_frame) + || !FRAMEP (parent_frame) + || !FRAME_LIVE_P (XFRAME (parent_frame))) + parent_frame = Qnil; + + fset_parent_frame (f, parent_frame); + store_frame_param (f, Qparent_frame, parent_frame); + /* The resources controlling the menu-bar and tool-bar are processed specially at startup, and reflected in the mode variables; ignore them here. */ diff --git a/src/nsmenu.m b/src/nsmenu.m index 59ea3855ed..1262c9cb4d 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -995,8 +995,6 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f block_input (); view->wait_for_tool_bar = NO; - FRAME_TOOLBAR_HEIGHT (f) = 0; - /* Note: This trigger an animation, which calls windowDidResize repeatedly. */ f->output_data.ns->in_animation = 1; @@ -1129,12 +1127,6 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f } #endif - FRAME_TOOLBAR_HEIGHT (f) = - NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)]) - - FRAME_NS_TITLEBAR_HEIGHT (f); - if (FRAME_TOOLBAR_HEIGHT (f) < 0) // happens if frame is fullscreen. - FRAME_TOOLBAR_HEIGHT (f) = 0; - if (oldh != FRAME_TOOLBAR_HEIGHT (f)) [view updateFrameSize:YES]; if (view->wait_for_tool_bar && FRAME_TOOLBAR_HEIGHT (f) > 0) diff --git a/src/nsterm.h b/src/nsterm.h index 53d9344cc7..34aab9c543 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -430,7 +430,7 @@ char const * nstrace_fullscreen_type_name (int); NSString *workingText; BOOL processingCompose; int fs_state, fs_before_fs, next_maximized; - int tibar_height, tobar_height, bwidth; + int bwidth; int maximized_width, maximized_height; NSWindow *nonfs_window; BOOL fs_is_native; @@ -454,6 +454,7 @@ char const * nstrace_fullscreen_type_name (int); /* Emacs-side interface */ - initFrameFromEmacs: (struct frame *) f; +- (void) createToolbar: (struct frame *)f; - (void) setRows: (int) r andColumns: (int) c; - (void) setWindowClosing: (BOOL)closing; - (EmacsToolbar *) toolbar; @@ -1012,8 +1013,6 @@ struct x_output #define NS_FACE_FOREGROUND(f) ((f)->foreground) #define NS_FACE_BACKGROUND(f) ((f)->background) -#define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height) -#define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height) #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID) @@ -1029,6 +1028,25 @@ struct x_output #define XNS_SCROLL_BAR(vec) XSAVE_POINTER (vec, 0) #endif +/* Compute pixel height of the frame's titlebar. */ +#define FRAME_NS_TITLEBAR_HEIGHT(f) \ + (NSHeight([FRAME_NS_VIEW (f) frame]) == 0 ? \ + 0 \ + : (int)(NSHeight([FRAME_NS_VIEW (f) window].frame) \ + - NSHeight([NSWindow contentRectForFrameRect: \ + [[FRAME_NS_VIEW (f) window] frame] \ + styleMask:[[FRAME_NS_VIEW (f) window] styleMask]]))) + +/* Compute pixel height of the toolbar. */ +#define FRAME_TOOLBAR_HEIGHT(f) \ + (([[FRAME_NS_VIEW (f) window] toolbar] == nil \ + || ! [[FRAME_NS_VIEW (f) window] toolbar].visible) ? \ + 0 \ + : (int)(NSHeight([NSWindow contentRectForFrameRect: \ + [[FRAME_NS_VIEW (f) window] frame] \ + styleMask:[[FRAME_NS_VIEW (f) window] styleMask]]) \ + - NSHeight([[[FRAME_NS_VIEW (f) window] contentView] frame]))) + /* Compute pixel size for vertical scroll bars */ #define NS_SCROLL_BAR_WIDTH(f) \ (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \ @@ -1066,6 +1084,17 @@ struct x_output #define NS_TOP_POS(f) ((f)->top_pos) #endif +/* Calculate system coordinates of the left and top of the parent + window or, if there is no parent window, the screen. */ +#define NS_PARENT_WINDOW_LEFT_POS(f) \ + (FRAME_PARENT_FRAME (f) != nil \ + ? [[FRAME_NS_VIEW (f) window] parentWindow].frame.origin.x : 0) +#define NS_PARENT_WINDOW_TOP_POS(f) \ + (FRAME_PARENT_FRAME (f) != nil \ + ? ([[FRAME_NS_VIEW (f) window] parentWindow].frame.origin.y \ + + [[FRAME_NS_VIEW (f) window] parentWindow].frame.size.height) \ + : [[[FRAME_NS_VIEW (f) window] screen] frame].size.height) + #define FRAME_NS_FONT_TABLE(f) (FRAME_DISPLAY_INFO (f)->font_table) #define FRAME_FONTSET(f) ((f)->output_data.ns->fontset) @@ -1185,6 +1214,10 @@ extern int x_display_pixel_width (struct ns_display_info *); /* This in nsterm.m */ extern float ns_antialias_threshold; extern void x_destroy_window (struct frame *f); +extern void x_set_undecorated (struct frame *f, Lisp_Object new_value, + Lisp_Object old_value); +extern void x_set_parent_frame (struct frame *f, Lisp_Object new_value, + Lisp_Object old_value); extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timespec const *timeout, sigset_t const *sigmask); diff --git a/src/nsterm.m b/src/nsterm.m index 162980a651..d614322ad1 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1711,8 +1711,9 @@ -(void)remove #endif /* Constrain the setFrameTopLeftPoint so we don't move behind the menu bar. */ - NSPoint pt = NSMakePoint (SCREENMAXBOUND (f->left_pos), - SCREENMAXBOUND ([fscreen frame].size.height + NSPoint pt = NSMakePoint (SCREENMAXBOUND (f->left_pos + + NS_PARENT_WINDOW_LEFT_POS (f)), + SCREENMAXBOUND (NS_PARENT_WINDOW_TOP_POS (f) - NS_TOP_POS (f))); NSTRACE_POINT ("setFrameTopLeftPoint", pt); [[view window] setFrameTopLeftPoint: pt]; @@ -1764,25 +1765,6 @@ -(void)remove pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, height); } - /* If we have a toolbar, take its height into account. */ - if (tb && ! [view isFullscreen]) - { - /* NOTE: previously this would generate wrong result if toolbar not - yet displayed and fixing toolbar_height=32 helped, but - now (200903) seems no longer needed */ - FRAME_TOOLBAR_HEIGHT (f) = - NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)]) - - FRAME_NS_TITLEBAR_HEIGHT (f); -#if 0 - /* Only breaks things here, removed by martin 2015-09-30. */ -#ifdef NS_IMPL_GNUSTEP - FRAME_TOOLBAR_HEIGHT (f) -= 3; -#endif -#endif - } - else - FRAME_TOOLBAR_HEIGHT (f) = 0; - wr.size.width = pixelwidth + f->border_width; wr.size.height = pixelheight; if (! [view isFullscreen]) @@ -1811,6 +1793,106 @@ -(void)remove unblock_input (); } +/** + * x_set_undecorated: + * + * Set frame F's `undecorated' parameter. If non-nil, F's window-system + * window is drawn without decorations, title, minimize/maximize boxes + * and external borders. This usually means that the window cannot be + * dragged, resized, iconified, maximized or deleted with the mouse. If + * nil, draw the frame with all the elements listed above unless these + * have been suspended via window manager settings. + * + * Some window managers may not honor this parameter. + */ +void +x_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) +{ + EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); + NSWindow *window = [view window]; + + if (!EQ (new_value, old_value)) + { + block_input (); + + if (NILP (new_value)) + { + FRAME_UNDECORATED (f) = false; + [window setStyleMask: ((window.styleMask | NSWindowStyleMaskTitled) + ^ NSWindowStyleMaskBorderless)]; + + [view createToolbar: f]; + } + else + { + [window setToolbar: nil]; + /* Do I need to release the toolbar here? */ + + FRAME_UNDECORATED (f) = true; + [window setStyleMask: ((window.styleMask | NSWindowStyleMaskBorderless) + ^ NSWindowStyleMaskTitled)]; + } + + /* At this point it seems we don't have an active NSResponder, + so some key presses (TAB) are swallowed by the system. */ + [window makeFirstResponder: view]; + + [view updateFrameSize: NO]; + unblock_input (); + } +} + +/** + * x_set_parent_frame: + * + * Set frame F's `parent-frame' parameter. If non-nil, make F a child + * frame of the frame specified by that parameter. Technically, this + * makes F's window-system window a child window of the parent frame's + * window-system window. If nil, make F's window-system window a + * top-level window--a child of its display's root window. + * + * A child frame's `left' and `top' parameters specify positions + * relative to the top-left corner of its parent frame's native + * rectangle. Usually, moving a parent frame moves all its child + * frames too, keeping their position relative to the parent + * unaltered. When a parent frame is iconified or made invisible, its + * child frames are made invisible. When a parent frame is deleted, + * its child frames are deleted too. + * + * Whether a child frame has a tool bar may be window-system or window + * manager dependent. It's advisable to disable it via the frame + * parameter settings. + * + * Some window managers may not honor this parameter. + */ +void +x_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) +{ + struct frame *p = NULL; + NSWindow *parent, *child; + + if (!NILP (new_value) + && (!FRAMEP (new_value) + || !FRAME_LIVE_P (p = XFRAME (new_value)) + || !FRAME_X_P (p))) + { + store_frame_param (f, Qparent_frame, old_value); + error ("Invalid specification of `parent-frame'"); + } + + if (p != FRAME_PARENT_FRAME (f)) + { + parent = [FRAME_NS_VIEW (p) window]; + child = [FRAME_NS_VIEW (f) window]; + + block_input (); + [parent addChildWindow: child + ordered: NSWindowAbove]; + unblock_input (); + + fset_parent_frame (f, new_value); + } +} static void ns_fullscreen_hook (struct frame *f) @@ -6399,7 +6481,8 @@ - (void) updateFrameSize: (BOOL) delay; newh = (int)wr.size.height - extra; NSTRACE_SIZE ("New size", NSMakeSize (neww, newh)); - NSTRACE_MSG ("tool_bar_height: %d", emacsframe->tool_bar_height); + NSTRACE_MSG ("FRAME_TOOLBAR_HEIGHT: %d", FRAME_TOOLBAR_HEIGHT (emacsframe)); + NSTRACE_MSG ("FRAME_NS_TITLEBAR_HEIGHT: %d", FRAME_NS_TITLEBAR_HEIGHT (emacsframe)); cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, neww); rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, newh); @@ -6424,9 +6507,11 @@ - (void) updateFrameSize: (BOOL) delay; SET_FRAME_GARBAGED (emacsframe); cancel_mouse_face (emacsframe); - wr = NSMakeRect (0, 0, neww, newh); + /* The next two lines appear to be setting the frame to the same + size as it already is. Why are they there? */ + // wr = NSMakeRect (0, 0, neww, newh); - [view setFrame: wr]; + // [view setFrame: wr]; // to do: consider using [NSNotificationCenter postNotificationName:]. [self windowDidMove: // Update top/left. @@ -6489,7 +6574,8 @@ - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize old_title = 0; } } - else if (fs_state == FULLSCREEN_NONE && ! maximizing_resize) + else if (fs_state == FULLSCREEN_NONE && ! maximizing_resize + && [[self window] titleVisibility]) { char *size_title; NSWindow *window = [self window]; @@ -6692,6 +6778,34 @@ - (BOOL)isOpaque } +- (void)createToolbar: (struct frame *)f +{ + EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); + NSWindow *window = [view window]; + + toolbar = [[EmacsToolbar alloc] initForView: self withIdentifier: + [NSString stringWithFormat: @"Emacs Frame %d", + ns_window_num]]; + [window setToolbar: toolbar]; + [toolbar setVisible: NO]; + + /* Don't set frame garbaged until tool bar is up to date? + This avoids an extra clear and redraw (flicker) at frame creation. */ + if (FRAME_EXTERNAL_TOOL_BAR (f)) wait_for_tool_bar = YES; + else wait_for_tool_bar = NO; + + +#ifdef NS_IMPL_COCOA + { + NSButton *toggleButton; + toggleButton = [window standardWindowButton: NSWindowToolbarButton]; + [toggleButton setTarget: self]; + [toggleButton setAction: @selector (toggleToolbar: )]; + } +#endif +} + + - initFrameFromEmacs: (struct frame *)f { NSRect r, wr; @@ -6729,11 +6843,13 @@ - (BOOL)isOpaque maximizing_resize = NO; #endif - win = [[EmacsWindow alloc] + win = [[EmacsFSWindow alloc] initWithContentRect: r styleMask: (NSWindowStyleMaskResizable | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - NSWindowStyleMaskTitled | + (FRAME_UNDECORATED (f) ? + NSWindowStyleMaskBorderless : + NSWindowStyleMaskTitled) | #endif NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskClosable) @@ -6746,7 +6862,6 @@ - (BOOL)isOpaque wr = [win frame]; bwidth = f->border_width = wr.size.width - r.size.width; - tibar_height = FRAME_NS_TITLEBAR_HEIGHT (f) = wr.size.height - r.size.height; [win setAcceptsMouseMovedEvents: YES]; [win setDelegate: self]; @@ -6766,42 +6881,32 @@ - (BOOL)isOpaque [win setTitle: name]; /* toolbar support */ - toolbar = [[EmacsToolbar alloc] initForView: self withIdentifier: - [NSString stringWithFormat: @"Emacs Frame %d", - ns_window_num]]; - [win setToolbar: toolbar]; - [toolbar setVisible: NO]; - - /* Don't set frame garbaged until tool bar is up to date? - This avoids an extra clear and redraw (flicker) at frame creation. */ - if (FRAME_EXTERNAL_TOOL_BAR (f)) wait_for_tool_bar = YES; - else wait_for_tool_bar = NO; - - -#ifdef NS_IMPL_COCOA - { - NSButton *toggleButton; - toggleButton = [win standardWindowButton: NSWindowToolbarButton]; - [toggleButton setTarget: self]; - [toggleButton setAction: @selector (toggleToolbar: )]; - } -#endif - FRAME_TOOLBAR_HEIGHT (f) = 0; + if (! FRAME_UNDECORATED (f)) + [self createToolbar: f]; tem = f->icon_name; if (!NILP (tem)) [win setMiniwindowTitle: [NSString stringWithUTF8String: SSDATA (tem)]]; + if (FRAME_PARENT_FRAME (f) != nil) + { + EmacsWindow *parent = [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window]; + [parent addChildWindow: win + ordered: NSWindowAbove]; + } + { NSScreen *screen = [win screen]; if (screen != 0) { NSPoint pt = NSMakePoint - (IN_BOUND (-SCREENMAX, f->left_pos, SCREENMAX), + (IN_BOUND (-SCREENMAX, f->left_pos + + NS_PARENT_WINDOW_LEFT_POS (f), SCREENMAX), IN_BOUND (-SCREENMAX, - [screen frame].size.height - NS_TOP_POS (f), SCREENMAX)); + NS_PARENT_WINDOW_TOP_POS (f) - NS_TOP_POS (f), + SCREENMAX)); [win setFrameTopLeftPoint: pt]; @@ -6843,9 +6948,9 @@ - (void)windowDidMove: sender return; if (screen != nil) { - emacsframe->left_pos = r.origin.x; + emacsframe->left_pos = r.origin.x - NS_PARENT_WINDOW_LEFT_POS (emacsframe); emacsframe->top_pos = - [screen frame].size.height - (r.origin.y + r.size.height); + NS_PARENT_WINDOW_TOP_POS (emacsframe) - (r.origin.y + r.size.height); } } @@ -7262,9 +7367,6 @@ - (void)toggleFullScreen: (id)sender [fw setOpaque: NO]; f->border_width = 0; - FRAME_NS_TITLEBAR_HEIGHT (f) = 0; - tobar_height = FRAME_TOOLBAR_HEIGHT (f); - FRAME_TOOLBAR_HEIGHT (f) = 0; nonfs_window = w; @@ -7298,9 +7400,6 @@ - (void)toggleFullScreen: (id)sender [w setOpaque: NO]; f->border_width = bwidth; - FRAME_NS_TITLEBAR_HEIGHT (f) = tibar_height; - if (FRAME_EXTERNAL_TOOL_BAR (f)) - FRAME_TOOLBAR_HEIGHT (f) = tobar_height; // to do: consider using [NSNotificationCenter postNotificationName:] to send notifications. -- 2.12.0 --M9NhX3UHpAaciwkO--