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#30699: 26.0.91; buffer contents flicker on macOS frames when frames are resized Date: Sat, 10 Mar 2018 00:25:55 +0000 Message-ID: <20180310002555.GA54231@breton.holly.idiocy.org> References: <83tvtus8rc.fsf@gnu.org> <20180305192331.GA26656@breton.holly.idiocy.org> <83muzms3i6.fsf@gnu.org> <20180306225502.GA30546@breton.holly.idiocy.org> <83a7vjre52.fsf@gnu.org> <20180307202603.GA31176@breton.holly.idiocy.org> <83r2ounzty.fsf@gnu.org> <20180309120952.GA45581@breton.holly.idiocy.org> <837eqlwf1i.fsf@gnu.org> <20180309232415.GB51893@breton.holly.idiocy.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="NzB8fVQJ5HfG6fxh" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1520641517 26112 195.159.176.226 (10 Mar 2018 00:25:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 10 Mar 2018 00:25:17 +0000 (UTC) User-Agent: Mutt/1.9.3 (2018-01-21) Cc: 30699@debbugs.gnu.org, aaronjensen@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 10 01:25:13 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 1euSJv-0006cR-Mz for geb-bug-gnu-emacs@m.gmane.org; Sat, 10 Mar 2018 01:25:07 +0100 Original-Received: from localhost ([::1]:48689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euSLy-0007I7-Jm for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Mar 2018 19:27:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euSLp-0007Hi-8j for bug-gnu-emacs@gnu.org; Fri, 09 Mar 2018 19:27:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1euSLm-0006EH-2H for bug-gnu-emacs@gnu.org; Fri, 09 Mar 2018 19:27:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45058) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1euSLl-0006E8-TW for bug-gnu-emacs@gnu.org; Fri, 09 Mar 2018 19:27:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1euSLl-000050-HH for bug-gnu-emacs@gnu.org; Fri, 09 Mar 2018 19:27: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: Sat, 10 Mar 2018 00:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30699 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30699-submit@debbugs.gnu.org id=B30699.152064156632702 (code B ref 30699); Sat, 10 Mar 2018 00:27:01 +0000 Original-Received: (at 30699) by debbugs.gnu.org; 10 Mar 2018 00:26:06 +0000 Original-Received: from localhost ([127.0.0.1]:52955 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euSKs-0008VO-9X for submit@debbugs.gnu.org; Fri, 09 Mar 2018 19:26:06 -0500 Original-Received: from mail-wr0-f171.google.com ([209.85.128.171]:34846) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euSKq-0008Ut-Nk for 30699@debbugs.gnu.org; Fri, 09 Mar 2018 19:26:05 -0500 Original-Received: by mail-wr0-f171.google.com with SMTP id a27so2881895wra.2 for <30699@debbugs.gnu.org>; Fri, 09 Mar 2018 16:26:04 -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=aaj1aB1G7M4zpg9A3prsMwaOf7sVRmvfOLSeMYKAveY=; b=BnwNiANLrET7wWi16DPVR1vb0gx5u/GBFD49L4+uixPKSSBKDz0JPfw+jjqrL66u/w Lb2zXr9m995HLfyGSM4mdYahwrGpz/mEI8+J1z+4RWeR68H9+eAK1KltabAQVq33b9I3 0eHUgHq2whCt1yquOOq0n9IN29azaFw3+zMNrjJAy3AsEPQhNs82NvtE7Avynd5p+hBP L6g7PIR/gIsufdwIs8F8B04Y+82kIR3ibQomWRAQXhMoamLeGc1PCxnFfpa7fz+qVV9a aUUDqp026oajbK1f2xiocYmr7oXgJYoYLEc7RMgUfxnhBMskWsJMmVnpam81lq+IiG9p /Xrw== 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=aaj1aB1G7M4zpg9A3prsMwaOf7sVRmvfOLSeMYKAveY=; b=kql5EW8saTgsXH13n53xFEt5c2M/sJla2NOHNoUak9ijwgfqHuUiIYXA/nS454qIdD j3jTj9RcmerwrrHzczb4wwC/Hnl0H9bvB84qk5gnTqAwdQpkrtrJD3wPty3grdYXp0eP nD/6Ohdi+9HNEOpJtr7e9RjgJjhf1kqb4BFaGmH8sNgwMurJAcCmcoyLkf+BzK+Kcxqb JSoMANaVF6EreosMYkd4x5BcfQom+TV8PL+RN1SVrkFVeTIL9p84FV6Sx9FdcS+LH/7O bzeu/4wIIXhc7hvILhc1E+Ubo15f6DZDUUuCy0ZvtTgq8DQdxv2ZF3vDl0EylgR/SokX /l9A== X-Gm-Message-State: AElRT7HfrWSRRBNjPjSYQfbuhuO1Bnk91C/pERLta4v2FaP94WQh/hp1 /HOC8TNqYHIesR53tX+1oUA= X-Google-Smtp-Source: AG47ELtKpuS8jrjGocdCG4gsOXqRTx8Wvee9MjiJ4N7cFSsVGTDdhrEeXV3xw21C+LfhmID6fE+xpA== X-Received: by 10.223.195.108 with SMTP id e41mr217051wrg.170.1520641558815; Fri, 09 Mar 2018 16:25:58 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-5176-0ba2-62e5-311d.holly.idiocy.org. [2001:8b0:3f8:8129:5176:ba2:62e5:311d]) by smtp.gmail.com with ESMTPSA id m7sm3690231wrm.35.2018.03.09.16.25.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 16:25:57 -0800 (PST) Content-Disposition: inline In-Reply-To: <20180309232415.GB51893@breton.holly.idiocy.org> 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:144086 Archived-At: --NzB8fVQJ5HfG6fxh Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Fri, Mar 09, 2018 at 11:24:15PM +0000, Alan Third wrote: > The other solution I have is to use NSDisableScreenUpdates to prevent > updates being flushed to the screen until after redisplay, but that > completely breaks resizing with the mouse. I just realised that this isn’t actually hard to get right. Patch attached. I think this is a better solution than the last one. Disabling screen updates just stops them being flushed to the screen, when they’re enabled all the updates happen at once (including the window manager’s frame resize). I guess it’s like drawing to an off‐screen buffer then swapping. -- Alan Third --NzB8fVQJ5HfG6fxh Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-frame-resize-flicker-on-macOS-bug-30699.patch" >From c382338d44c3ff833e965e1d92106a90b75edec5 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sat, 10 Mar 2018 00:09:09 +0000 Subject: [PATCH] Fix frame resize flicker on macOS (bug#30699) * src/nsterm.h (ns_enable_screen_updates): New function. * src/nsterm.m (ns_enable_screen_updates): (ns_disable_screen_updates): New functions. (disable_screen_updates_count): Count of number of times we've called NSDisableScreenUpdates. (x_set_window_size): Disable screen updates when not in a live resize loop. * src/xdisp.c (redisplay_internal): Reenable NS screenupdates at end of redisplay. --- src/nsterm.h | 3 +++ src/nsterm.m | 30 ++++++++++++++++++++++++++++++ src/xdisp.c | 3 +++ 3 files changed, 36 insertions(+) diff --git a/src/nsterm.h b/src/nsterm.h index 8b985930ec..df59a7dbd9 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -1160,6 +1160,9 @@ extern void ns_release_autorelease_pool (void *); extern const char *ns_get_defaults_value (const char *key); extern void ns_init_locale (void); +#ifdef NS_IMPL_COCOA +extern void ns_enable_screen_updates (void); +#endif /* in nsmenu */ extern void update_frame_tool_bar (struct frame *f); diff --git a/src/nsterm.m b/src/nsterm.m index 1919c6defa..b4ec384aaf 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -288,6 +288,7 @@ - (NSColor *)colorUsingDefaultColorSpace static BOOL ns_fake_keydown = NO; #ifdef NS_IMPL_COCOA static BOOL ns_menu_bar_is_hidden = NO; +static int disable_screen_updates_count = 0; #endif /*static int debug_lock = 0; */ @@ -727,6 +728,26 @@ Free a pool and temporary objects it refers to (callable from C) } +#ifdef NS_IMPL_COCOA +static void +ns_disable_screen_updates (void) +{ + NSDisableScreenUpdates (); + disable_screen_updates_count++; +} + +void +ns_enable_screen_updates (void) +{ + while (disable_screen_updates_count > 0) + { + NSEnableScreenUpdates (); + disable_screen_updates_count--; + } +} +#endif + + static BOOL ns_menu_bar_should_be_hidden (void) /* True, if the menu bar should be hidden. */ @@ -1877,6 +1898,15 @@ -(void)remove block_input (); +#ifdef NS_IMPL_COCOA + /* To prevent showing the user a blank frame, stop updates being + flushed to the screen until after redisplay has completed. This + breaks live resize (resizing with a mouse), so don't do it if + we're in a live resize loop. */ + if (![view inLiveResize]) + ns_disable_screen_updates (); +#endif + if (pixelwise) { pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width); diff --git a/src/xdisp.c b/src/xdisp.c index 9170d6b777..d4fdb44b32 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -14599,6 +14599,9 @@ redisplay_internal (void) end_of_redisplay: #ifdef HAVE_NS ns_set_doc_edited (); +#ifdef NS_IMPL_COCOA + ns_enable_screen_updates (); +#endif #endif if (interrupt_input && interrupts_deferred) request_sigio (); -- 2.16.1 --NzB8fVQJ5HfG6fxh--