From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#40200: bug#28872: [PATCH v4] Fix NS frame resizing issues (bug#40200, bug#28872) Date: Sat, 18 Apr 2020 16:26:22 +0100 Message-ID: <20200418152622.GA54462@breton.holly.idiocy.org> References: <20200406184411.GA48827@breton.holly.idiocy.org> <20200416182410.GC52374@breton.holly.idiocy.org> <20200418120714.GA53858@breton.holly.idiocy.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="114904"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 40200@debbugs.gnu.org, Andrii Kolomoiets To: HaiJun Zhang Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 18 17:27:14 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jPpNA-000Tln-1J for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Apr 2020 17:27:12 +0200 Original-Received: from localhost ([::1]:58842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPpN9-0005BM-32 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Apr 2020 11:27:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40209) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPpN1-0005BD-W1 for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2020 11:27:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jPpN0-0001HV-Mw for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2020 11:27:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60101) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jPpN0-0001HP-JG for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2020 11:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jPpN0-00041O-Fd for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2020 11:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Apr 2020 15:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40200 X-GNU-PR-Package: emacs Original-Received: via spool by 40200-submit@debbugs.gnu.org id=B40200.158722359115419 (code B ref 40200); Sat, 18 Apr 2020 15:27:02 +0000 Original-Received: (at 40200) by debbugs.gnu.org; 18 Apr 2020 15:26:31 +0000 Original-Received: from localhost ([127.0.0.1]:43414 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPpMV-00040d-Iw for submit@debbugs.gnu.org; Sat, 18 Apr 2020 11:26:31 -0400 Original-Received: from idiocy.org ([217.169.17.33]:63291 helo=breton.holly.idiocy.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPpMU-00040Q-Ag for 40200@debbugs.gnu.org; Sat, 18 Apr 2020 11:26:31 -0400 Original-Received: by breton.holly.idiocy.org (Postfix, from userid 501) id 2284D20221CF52; Sat, 18 Apr 2020 16:26:22 +0100 (BST) Mail-Followup-To: Alan Third , HaiJun Zhang , Andrii Kolomoiets , 40200@debbugs.gnu.org Content-Disposition: inline In-Reply-To: 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: 209.51.188.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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:178575 Archived-At: --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sat, Apr 18, 2020 at 10:12:27PM +0800, HaiJun Zhang wrote: > I can reproduce it with the following lines in ~/.emacs: > > (setq inhibit-startup-message t >    inhibit-startup-buffer-menu t) > > (setq default-frame-alist ‘( >        (width . 85) >        (height . 35) >        (vertical-scroll-bars . nil) >        (horizontal-scroll-bars . nil) >        )) > > (set-frame-font “Monospace 16”) Can you please try the attached patch. -- Alan Third --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-initial-frame-resizing-issue-on-NS-bug-40200.patch" >From 836c19eae4802a3aedee887669425f949971eb4a Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sat, 18 Apr 2020 16:22:06 +0100 Subject: [PATCH] Fix initial frame resizing issue on NS (bug#40200) * src/nsterm.m ([EmacsView viewDidResize:]): Don't try to determine the old size when not drawing to the buffer. --- src/nsterm.m | 51 +++++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index 9cd1c9d860..d85a579e38 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -7322,48 +7322,39 @@ - (void)viewDidEndLiveResize - (void)viewDidResize:(NSNotification *)notification { NSRect frame = [self frame]; - int oldw, oldh, neww, newh; + int neww, newh; if (! FRAME_LIVE_P (emacsframe)) return; + NSTRACE ("[EmacsView viewDidResize]"); + + neww = (int)NSWidth (frame); + newh = (int)NSHeight (frame); + NSTRACE_SIZE ("New size", NSMakeSize (neww, newh)); + #ifdef NS_DRAW_TO_BUFFER -#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 if ([self wantsUpdateLayer]) { -#endif CGFloat scale = [[self window] backingScaleFactor]; - oldw = (CGFloat)CGBitmapContextGetWidth (drawingBuffer) / scale; - oldh = (CGFloat)CGBitmapContextGetHeight (drawingBuffer) / scale; -#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 - } - else - { -#endif -#endif /* NS_DRAW_TO_BUFFER */ -#if !defined (NS_DRAW_TO_BUFFER) || MAC_OS_X_VERSION_MIN_REQUIRED < 101400 - oldw = FRAME_PIXEL_WIDTH (emacsframe); - oldh = FRAME_PIXEL_HEIGHT (emacsframe); -#endif -#if defined (NS_DRAW_TO_BUFFER) && MAC_OS_X_VERSION_MIN_REQUIRED < 101400 - } -#endif - - neww = (int)NSWidth (frame); - newh = (int)NSHeight (frame); + int oldw = (CGFloat)CGBitmapContextGetWidth (drawingBuffer) / scale; + int oldh = (CGFloat)CGBitmapContextGetHeight (drawingBuffer) / scale; - NSTRACE ("[EmacsView viewDidResize]"); + NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh)); - /* Don't want to do anything when the view size hasn't changed. */ - if ((oldh == newh && oldw == neww)) - { - NSTRACE_MSG ("No change"); - return; + /* Don't want to do anything when the view size hasn't changed. */ + if ((oldh == newh && oldw == neww)) + { + NSTRACE_MSG ("No change"); + return; + } } +#endif - NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh)); - NSTRACE_SIZE ("New size", NSMakeSize (neww, newh)); - + /* I'm not sure if it's safe to call this every time the view + changes size, as Emacs may already know about the change. + Unfortunately there doesn't seem to be a bullet-proof method of + determining whether we need to call it or not. */ change_frame_size (emacsframe, FRAME_PIXEL_TO_TEXT_WIDTH (emacsframe, neww), FRAME_PIXEL_TO_TEXT_HEIGHT (emacsframe, newh), -- 2.26.1 --Q68bSM7Ycu6FN28Q--