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#29953: 26.0.90; Moving a child frame before making it visible makes the child frame not showing any more on macOS Date: Wed, 3 Jan 2018 14:07:04 +0000 Message-ID: <20180103140704.GA98841@breton.holly.idiocy.org> References: <5a4c1c86.0ac7df0a.a769a.93cbSMTPIN_ADDED_BROKEN@mx.google.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="fUYQa+Pmc3FrFX/N" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1514988381 11053 195.159.176.226 (3 Jan 2018 14:06:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 3 Jan 2018 14:06:21 +0000 (UTC) User-Agent: Mutt/1.9.1 (2017-09-22) Cc: 29953@debbugs.gnu.org To: Jiege Chen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 03 15:06:17 2018 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 1eWjgO-0002YG-Rk for geb-bug-gnu-emacs@m.gmane.org; Wed, 03 Jan 2018 15:06:17 +0100 Original-Received: from localhost ([::1]:53542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWjiN-0005eZ-W3 for geb-bug-gnu-emacs@m.gmane.org; Wed, 03 Jan 2018 09:08:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWjiC-0005b1-4i for bug-gnu-emacs@gnu.org; Wed, 03 Jan 2018 09:08:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWji6-0006p1-4O for bug-gnu-emacs@gnu.org; Wed, 03 Jan 2018 09:08:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53439) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWji5-0006os-U0 for bug-gnu-emacs@gnu.org; Wed, 03 Jan 2018 09:08:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eWji5-0007gW-HD for bug-gnu-emacs@gnu.org; Wed, 03 Jan 2018 09:08:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Jan 2018 14:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29953 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29953-submit@debbugs.gnu.org id=B29953.151498843629479 (code B ref 29953); Wed, 03 Jan 2018 14:08:01 +0000 Original-Received: (at 29953) by debbugs.gnu.org; 3 Jan 2018 14:07:16 +0000 Original-Received: from localhost ([127.0.0.1]:33887 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWjhL-0007fO-LT for submit@debbugs.gnu.org; Wed, 03 Jan 2018 09:07:15 -0500 Original-Received: from mail-wr0-f173.google.com ([209.85.128.173]:35534) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWjhJ-0007fA-Pf for 29953@debbugs.gnu.org; Wed, 03 Jan 2018 09:07:14 -0500 Original-Received: by mail-wr0-f173.google.com with SMTP id l19so1688651wrc.2 for <29953@debbugs.gnu.org>; Wed, 03 Jan 2018 06:07:13 -0800 (PST) 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=484Q+ifeJYY0l9WFYp3zk+0BzgD+1SXCM2yx3vXBGTk=; b=VFyovkESUX+fFGDZ+LjYQxUpezTF/3s+eAcfUnJozi3K2BZUrfLO3pE48orBNncCoa YIVBXVZan33fV4nHwSHCftMIhha0oubs7V7iiveo8o+jmq4rUZQEAO8B7G0d74HQykBS l+v+xQ4OBzyoKAOxCmBsGn2HI2wsdQioJVtcFYwYSH6SxTKgrqVBNb2pPJTAgjH4jd67 Vgq0sGUsHppU8x+LiLySTGz/Zwc2yrkhGZPo1NOKI6K9asYSm2HTucmlkvrXAcLf1c5R ATM8EjXJAe/C45jtgjUGA3viYUNdqLqlFinOHmCYXdOR1n4cN8gQISkdzJPR95xDtNQ0 4pEw== 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=484Q+ifeJYY0l9WFYp3zk+0BzgD+1SXCM2yx3vXBGTk=; b=KGTw1uT69dgLulBc9QG+YLS2pQmPIpURXIau7jtOjNf9fmwSmu1pJ6s8zLxToYq7+e 8O/4obRP9Tc7GBFgQuyRzjdtUKa2Rnhx0MYwWzsbW/rXhmPX77WS/1ALA5TDeVYVhSxZ F3214Y0YXJMOezrWjv/oTLGPl3afPkh6fEYsr7pnfKhJa+DY1s8DJk4aJkM7BgfTrleR qd+NiJSJwh9x1bNlzSggS6Kn3K/F+E1hBddcX4o5gogrgUNtNDHqlhjygoHYpoYmG47Z Ca9h5FshdNuff6CP1IAIdb6PRYO8jq8rMv8srZiE4jGIGdjeYdZxna0vohK5JcEDk76M ZZ0g== X-Gm-Message-State: AKGB3mKNeNuukPnfbVYH+6boP9WtIQ+m31Q51sqZR95pP4ANCEsoVb/K JWPo0Vd0hsQKkfPUU8BzT6g= X-Google-Smtp-Source: ACJfBoszNcNFj2JMQ4Q0di80jdaaFhcLYthSzGG/0BTP1tFSmibHqdRMzQWu19kg9Wkrn7cgbsXdrg== X-Received: by 10.223.130.36 with SMTP id 33mr1572627wrb.131.1514988428006; Wed, 03 Jan 2018 06:07:08 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-3ca9-c940-779f-ceae.holly.idiocy.org. [2001:8b0:3f8:8129:3ca9:c940:779f:ceae]) by smtp.gmail.com with ESMTPSA id r3sm1298900wmg.31.2018.01.03.06.07.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 06:07:06 -0800 (PST) Content-Disposition: inline In-Reply-To: <5a4c1c86.0ac7df0a.a769a.93cbSMTPIN_ADDED_BROKEN@mx.google.com> 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:141745 Archived-At: --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Wed, Jan 03, 2018 at 07:55:12AM +0800, Jiege Chen wrote: > > Snippet: > > This code uses `oddp', which might not be available from `emacs -Q'. You can replace it with (= 1 (mod count 2)) > On my macOS Sierra, the frame only shows once and never shows again. There were two issues interacting here: invisible child frames lose track of their parents in NS, and frames that are off‐screen don’t have an associated screen but our positioning code will only position a frame if it knows it’s screen. I’ve fixed the first issue so that we look up the parent through the Emacs frame structs, and the second by positioning according to the main screen if the frame doesn’t have a screen. I also fixed what I think is a bug when child frames are positioned with negative values. On X it looks as though a negative value always results in positioning according to the bottom‐right of the parent frame, but on NS it would be positioned to the left and above the parent frame. NS now behaves like X. Patch attached. > Related issue: https://github.com/emacs-lsp/lsp-ui/issues/21 . Are you using threads? GUI calls and threads don’t mix well yet, unfortunately. -- Alan Third --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-child-frame-placement-issues-bug-29953.patch" >From b54c5c18df91cbf887d653846edddeb1c853c141 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Wed, 3 Jan 2018 13:45:03 +0000 Subject: [PATCH] Fix child frame placement issues (bug#29953) * src/nsterm.h (NS_PARENT_WINDOW_LEFT_POS): (NS_PARENT_WINDOW_TOP_POS): Get the parent frame through the frame struct as invisible child windows are detached from their parents in NS. * src/nsterm.m (x_set_offset): Offscreen frames have `nil' screen value, so handle that gracefully. Child frames with negative left and top should be positioned relative to the bottom right of the parent frame. --- src/nsterm.h | 6 +++--- src/nsterm.m | 46 ++++++++++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/nsterm.h b/src/nsterm.h index c40ddf3284..588b9fc644 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -1073,11 +1073,11 @@ struct x_output window or, if there is no parent window, the screen. */ #define NS_PARENT_WINDOW_LEFT_POS(f) \ (FRAME_PARENT_FRAME (f) != NULL \ - ? [[FRAME_NS_VIEW (f) window] parentWindow].frame.origin.x : 0) + ? [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.origin.x : 0) #define NS_PARENT_WINDOW_TOP_POS(f) \ (FRAME_PARENT_FRAME (f) != NULL \ - ? ([[FRAME_NS_VIEW (f) window] parentWindow].frame.origin.y \ - + [[FRAME_NS_VIEW (f) window] parentWindow].frame.size.height \ + ? ([FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.origin.y \ + + [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.size.height \ - FRAME_NS_TITLEBAR_HEIGHT (FRAME_PARENT_FRAME (f))) \ : [[[NSScreen screens] objectAtIndex: 0] frame].size.height) diff --git a/src/nsterm.m b/src/nsterm.m index 5798f4fd0b..419a37033f 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1736,7 +1736,6 @@ -(void)remove { NSView *view = FRAME_NS_VIEW (f); NSArray *screens = [NSScreen screens]; - NSScreen *fscreen = [screens objectAtIndex: 0]; NSScreen *screen = [[view window] screen]; NSTRACE ("x_set_offset"); @@ -1746,26 +1745,41 @@ -(void)remove f->left_pos = xoff; f->top_pos = yoff; - if (view != nil && screen && fscreen) + if (view != nil) { - f->left_pos = f->size_hint_flags & XNegative - ? [screen visibleFrame].size.width + f->left_pos - FRAME_PIXEL_WIDTH (f) - : f->left_pos; - /* We use visibleFrame here to take menu bar into account. - Ideally we should also adjust left/top with visibleFrame.origin. */ - - f->top_pos = f->size_hint_flags & YNegative - ? ([screen visibleFrame].size.height + f->top_pos - - FRAME_PIXEL_HEIGHT (f) - FRAME_NS_TITLEBAR_HEIGHT (f) - - FRAME_TOOLBAR_HEIGHT (f)) - : f->top_pos; + if (FRAME_PARENT_FRAME (f) == NULL && screen) + { + f->left_pos = f->size_hint_flags & XNegative + ? [screen visibleFrame].size.width + f->left_pos - FRAME_PIXEL_WIDTH (f) + : f->left_pos; + /* We use visibleFrame here to take menu bar into account. + Ideally we should also adjust left/top with visibleFrame.origin. */ + + f->top_pos = f->size_hint_flags & YNegative + ? ([screen visibleFrame].size.height + f->top_pos + - FRAME_PIXEL_HEIGHT (f) - FRAME_NS_TITLEBAR_HEIGHT (f) + - FRAME_TOOLBAR_HEIGHT (f)) + : f->top_pos; #ifdef NS_IMPL_GNUSTEP - if (FRAME_PARENT_FRAME (f) == NULL) - { if (f->left_pos < 100) f->left_pos = 100; /* don't overlap menu */ - } #endif + } + else if (FRAME_PARENT_FRAME (f) != NULL) + { + struct frame *parent = FRAME_PARENT_FRAME (f); + + /* On X negative values for child frames always result in + positioning relative to the bottom right corner of the + parent frame. */ + if (f->left_pos < 0) + f->left_pos = FRAME_PIXEL_WIDTH (parent) - FRAME_PIXEL_WIDTH (f) + f->left_pos; + + if (f->top_pos < 0) + f->top_pos = FRAME_PIXEL_HEIGHT (parent) + FRAME_TOOLBAR_HEIGHT (parent) + - FRAME_PIXEL_HEIGHT (f) + f->top_pos; + } + /* Constrain the setFrameTopLeftPoint so we don't move behind the menu bar. */ NSPoint pt = NSMakePoint (SCREENMAXBOUND (f->left_pos -- 2.14.3 --fUYQa+Pmc3FrFX/N--