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#39883: 28.0.50; macOS blank frame Date: Sun, 12 Apr 2020 10:53:53 +0100 Message-ID: <20200412095353.GA79593@breton.holly.idiocy.org> References: <20200329181351.GA80513@breton.holly.idiocy.org> <3CA96F9B-66CF-4D3C-92F5-AC06334D50B2@lostca.se> <4e2737dfdc33b25c5158bcbfdc91e3b3@lostca.se> <20200331165235.GB81462@breton.holly.idiocy.org> <9e1f0f34-ec8e-b399-8344-5f1aeb03dfaf@lostca.se> <20200401185307.GB83597@breton.holly.idiocy.org> <07ff9665-2dc5-7071-14b5-6357b7a705c9@lostca.se> <20200411132925.GA77949@breton.holly.idiocy.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="X1bOJ3K7DJ5YkBrT" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="91731"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 39883@debbugs.gnu.org To: Ashish SHUKLA Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 12 11:55:21 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 1jNZKi-000Nm9-CY for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Apr 2020 11:55:20 +0200 Original-Received: from localhost ([::1]:60222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jNZKh-00080g-FZ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Apr 2020 05:55:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42709) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jNZKT-0007yq-NH for bug-gnu-emacs@gnu.org; Sun, 12 Apr 2020 05:55:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jNZKR-0004UT-Lq for bug-gnu-emacs@gnu.org; Sun, 12 Apr 2020 05:55:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45848) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jNZKR-0004UJ-GA for bug-gnu-emacs@gnu.org; Sun, 12 Apr 2020 05:55:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jNZKQ-000171-FZ for bug-gnu-emacs@gnu.org; Sun, 12 Apr 2020 05:55: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: Sun, 12 Apr 2020 09:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39883 X-GNU-PR-Package: emacs Original-Received: via spool by 39883-submit@debbugs.gnu.org id=B39883.15866852454203 (code B ref 39883); Sun, 12 Apr 2020 09:55:02 +0000 Original-Received: (at 39883) by debbugs.gnu.org; 12 Apr 2020 09:54:05 +0000 Original-Received: from localhost ([127.0.0.1]:57394 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jNZJV-00015j-7P for submit@debbugs.gnu.org; Sun, 12 Apr 2020 05:54:05 -0400 Original-Received: from idiocy.org ([217.169.17.33]:58592 helo=breton.holly.idiocy.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jNZJS-00014y-Cj for 39883@debbugs.gnu.org; Sun, 12 Apr 2020 05:54:03 -0400 Original-Received: by breton.holly.idiocy.org (Postfix, from userid 501) id 99D942021C10B1; Sun, 12 Apr 2020 10:53:53 +0100 (BST) Mail-Followup-To: Alan Third , Ashish SHUKLA , 39883@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:178227 Archived-At: --X1bOJ3K7DJ5YkBrT Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sun, Apr 12, 2020 at 11:54:53AM +0530, Ashish SHUKLA wrote: > On Apr 11, 2020, at 18:59, Alan Third wrote: > > > > You may have to set this CFLAG to enable the changes: > > > > -DMAC_OS_X_VERSION_MAX_ALLOWED=101500 > > Hi > > Without setting CFLAGS following error occurred: > > ================================================================== > CC image.o > CC json.o > CC nsterm.o > CC nsfns.o > CC nsmenu.o > CC nsselect.o > CC nsimage.o > CC macfont.o > CC terminfo.o > CC lastfile.o > nsterm.m:6300:21: error: use of undeclared identifier 'drawingBuffer' > CGContextRelease (drawingBuffer); > ^ > 1 error generated. I’m surprised this didn’t show up before. > In file included from :360: > :4:9: warning: 'MAC_OS_X_VERSION_MAX_ALLOWED' macro redefined [-Wmacro-redefined] > #define MAC_OS_X_VERSION_MAX_ALLOWED 101500 > ^ > :3:9: note: previous definition is here > #define MAC_OS_X_VERSION_MAX_ALLOWED 101200 > ^ This looks suspiciously like you’re already setting that define in your configure command. If you’re building with nix check the build script. You, or whoever created it, probably had to add the define to 101200 (which is macOS 10.12) so it would correctly handle some features added since macOS 10.10. I know that John Weigley uses (or used) that value. There’s a possibility it will appear in a different form, but it will be something that either has 101200 or 10.12. > nsterm.m:1148:8: error: use of undeclared identifier 'self' > if ([self wantsUpdateLayer]) > ^ Silly mistake on my part. New patch attached. You still have to use the other patch from my last email as well. -- Alan Third --X1bOJ3K7DJ5YkBrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-Allow-dynamic-choice-of-drawing-path-on-NS-bug-39.patch" >From 7b0d5e99e0b12fd6792cf2cf76d539128687f520 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sat, 11 Apr 2020 14:18:39 +0100 Subject: [PATCH v2] Allow dynamic choice of drawing path on NS (bug#39883) * src/nsterm.h (NS_DRAW_TO_BUFFER): Let this be enabled on versions older than 10.14. * src/nsterm.m (ns_update_begin): (ns_update_end): (ns_focus): (ns_unfocus): ([EmacsView viewDidResize:]): ([EmacsView createDrawingBuffer]): ([EmacsView windowDidChangeBackingProperties:]): ([EmacsView copyRect:to:]): ([EmacsView wantsUpdateLayer]): Dynamically switch between drawing to a buffer and drawing to the screen, depending on the version of AppKit in use. ([EmacsView dealloc]): We can't release the context unless NS_DRAW_TO_BUFFER is defined. --- src/nsterm.h | 10 +-- src/nsterm.m | 229 +++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 167 insertions(+), 72 deletions(-) diff --git a/src/nsterm.h b/src/nsterm.h index e142dbd4f0..f5d3c32b8b 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -343,14 +343,8 @@ #define NSTRACE_UNSILENCE() therefore we draw to an offscreen buffer and swap it in when the toolkit wants to draw the frame. GNUstep and macOS 10.7 and below do not support this method, so we revert to drawing directly to the - glass. - - FIXME: Should we make this macOS 10.8+, or macOS 10.14+? I'm - inclined to go with 10.14+ as there have been some reports of funny - behaviour on 10.13 and below. It may be worth adding a variable to - allow people in the overlapping region to switch between drawing - paths. */ -#if defined (NS_IMPL_COCOA) && defined (MAC_OS_X_VERSION_10_14) + glass. */ +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 #define NS_DRAW_TO_BUFFER 1 #endif diff --git a/src/nsterm.m b/src/nsterm.m index 9dd1a89d0c..f5cf033b4e 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1144,10 +1144,25 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) ns_updating_frame = f; #ifdef NS_DRAW_TO_BUFFER - [view focusOnDrawingBuffer]; -#else - [view lockFocus]; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + if ([FRAME_NS_VIEW (f) wantsUpdateLayer]) + { #endif + [view focusOnDrawingBuffer]; +#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 + [view lockFocus]; +#endif +#if defined (NS_DRAW_TO_BUFFER) && MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + } +#endif + } @@ -1166,15 +1181,29 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) MOUSE_HL_INFO (f)->mouse_face_defer = 0; #ifdef NS_DRAW_TO_BUFFER - [NSGraphicsContext setCurrentContext:nil]; - [view setNeedsDisplay:YES]; -#else - block_input (); +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + if ([FRAME_NS_VIEW (f) wantsUpdateLayer]) + { +#endif + [NSGraphicsContext setCurrentContext:nil]; + [view setNeedsDisplay:YES]; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + } + else + { +#endif +#endif /* NS_DRAW_TO_BUFFER */ - [view unlockFocus]; - [[view window] flushWindow]; +#if !defined (NS_DRAW_TO_BUFFER) || MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + block_input (); - unblock_input (); + [view unlockFocus]; + [[view window] flushWindow]; + + unblock_input (); +#endif +#if defined (NS_DRAW_TO_BUFFER) && MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + } #endif ns_updating_frame = NULL; } @@ -1199,24 +1228,39 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) } if (f != ns_updating_frame) -#ifdef NS_DRAW_TO_BUFFER - [view focusOnDrawingBuffer]; -#else { - if (view != focus_view) +#ifdef NS_DRAW_TO_BUFFER +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + if ([FRAME_NS_VIEW (f) wantsUpdateLayer]) { - if (focus_view != NULL) +#endif + [view focusOnDrawingBuffer]; +#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 + if (view != focus_view) { - [focus_view unlockFocus]; - [[focus_view window] flushWindow]; - } + if (focus_view != NULL) + { + [focus_view unlockFocus]; + [[focus_view window] flushWindow]; + } - if (view) - [view lockFocus]; - focus_view = view; + if (view) + [view lockFocus]; + focus_view = view; + } +#endif +#if defined (NS_DRAW_TO_BUFFER) && MAC_OS_X_VERSION_MIN_REQUIRED < 101400 } - } #endif + } + /* clipping */ if (r) @@ -1246,16 +1290,30 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) } #ifdef NS_DRAW_TO_BUFFER - [FRAME_NS_VIEW (f) setNeedsDisplay:YES]; -#else - if (f != ns_updating_frame) + #if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + if ([FRAME_NS_VIEW (f) wantsUpdateLayer]) + { +#endif + [FRAME_NS_VIEW (f) setNeedsDisplay:YES]; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + } + else { - if (focus_view != NULL) +#endif +#endif /* NS_DRAW_TO_BUFFER */ + +#if !defined (NS_DRAW_TO_BUFFER) || MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + if (f != ns_updating_frame) { - [focus_view unlockFocus]; - [[focus_view window] flushWindow]; - focus_view = NULL; + if (focus_view != NULL) + { + [focus_view unlockFocus]; + [[focus_view window] flushWindow]; + focus_view = NULL; + } } +#endif +#if defined (NS_DRAW_TO_BUFFER) && MAC_OS_X_VERSION_MIN_REQUIRED < 101400 } #endif } @@ -6239,7 +6297,9 @@ - (void)dealloc name:NSViewFrameDidChangeNotification object:nil]; +#ifdef NS_DRAW_TO_BUFFER CGContextRelease (drawingBuffer); +#endif [toolbar release]; if (fs_state == FULLSCREEN_BOTH) @@ -7253,13 +7313,27 @@ - (void)viewDidResize:(NSNotification *)notification return; #ifdef NS_DRAW_TO_BUFFER - CGFloat scale = [[self window] backingScaleFactor]; - oldw = (CGFloat)CGBitmapContextGetWidth (drawingBuffer) / scale; - oldh = (CGFloat)CGBitmapContextGetHeight (drawingBuffer) / scale; -#else - oldw = FRAME_PIXEL_WIDTH (emacsframe); - oldh = FRAME_PIXEL_HEIGHT (emacsframe); +#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); @@ -8289,6 +8363,9 @@ - (void)createDrawingBuffer { NSTRACE ("EmacsView createDrawingBuffer]"); + if (! [self wantsUpdateLayer]) + return; + NSGraphicsContext *screen; CGColorSpaceRef colorSpace = [[[self window] colorSpace] CGColorSpace]; CGFloat scale = [[self window] backingScaleFactor]; @@ -8324,6 +8401,9 @@ - (void)windowDidChangeBackingProperties:(NSNotification *)notification { NSTRACE ("EmacsView windowDidChangeBackingProperties:]"); + if (! [self wantsUpdateLayer]) + return; + CGFloat old = [[[notification userInfo] objectForKey:@"NSBackingPropertyOldScaleFactorKey"] doubleValue]; @@ -8347,41 +8427,56 @@ - (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect NSTRACE_RECT ("Destination", dstRect); #ifdef NS_DRAW_TO_BUFFER - CGImageRef copy; - NSRect frame = [self frame]; - NSAffineTransform *setOrigin = [NSAffineTransform transform]; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + if ([self wantsUpdateLayer]) + { +#endif + CGImageRef copy; + NSRect frame = [self frame]; + NSAffineTransform *setOrigin = [NSAffineTransform transform]; - [[NSGraphicsContext currentContext] saveGraphicsState]; + [[NSGraphicsContext currentContext] saveGraphicsState]; - /* Set the clipping before messing with the buffer's - orientation. */ - NSRectClip (dstRect); + /* Set the clipping before messing with the buffer's + orientation. */ + NSRectClip (dstRect); - /* Unflip the buffer as the copied image will be unflipped, and - offset the top left so when we draw back into the buffer the - correct part of the image is drawn. */ - CGContextScaleCTM(drawingBuffer, 1, -1); - CGContextTranslateCTM(drawingBuffer, - NSMinX (dstRect) - NSMinX (srcRect), - -NSHeight (frame) - (NSMinY (dstRect) - NSMinY (srcRect))); + /* Unflip the buffer as the copied image will be unflipped, and + offset the top left so when we draw back into the buffer the + correct part of the image is drawn. */ + CGContextScaleCTM(drawingBuffer, 1, -1); + CGContextTranslateCTM(drawingBuffer, + NSMinX (dstRect) - NSMinX (srcRect), + -NSHeight (frame) - (NSMinY (dstRect) - NSMinY (srcRect))); - /* Take a copy of the buffer and then draw it back to the buffer, - limited by the clipping rectangle. */ - copy = CGBitmapContextCreateImage (drawingBuffer); - CGContextDrawImage (drawingBuffer, frame, copy); + /* Take a copy of the buffer and then draw it back to the buffer, + limited by the clipping rectangle. */ + copy = CGBitmapContextCreateImage (drawingBuffer); + CGContextDrawImage (drawingBuffer, frame, copy); - CGImageRelease (copy); + CGImageRelease (copy); - [[NSGraphicsContext currentContext] restoreGraphicsState]; - [self setNeedsDisplayInRect:dstRect]; -#else - hide_bell(); // Ensure the bell image isn't scrolled. + [[NSGraphicsContext currentContext] restoreGraphicsState]; + [self setNeedsDisplayInRect:dstRect]; - ns_focus (emacsframe, &dstRect, 1); - [self scrollRect: srcRect - by: NSMakeSize (dstRect.origin.x - srcRect.origin.x, - dstRect.origin.y - srcRect.origin.y)]; - ns_unfocus (emacsframe); +#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 + hide_bell(); // Ensure the bell image isn't scrolled. + + ns_focus (emacsframe, &dstRect, 1); + [self scrollRect: srcRect + by: NSMakeSize (dstRect.origin.x - srcRect.origin.x, + dstRect.origin.y - srcRect.origin.y)]; + ns_unfocus (emacsframe); +#endif +#if defined (NS_DRAW_TO_BUFFER) && MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + } #endif } @@ -8389,7 +8484,13 @@ - (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect #ifdef NS_DRAW_TO_BUFFER - (BOOL)wantsUpdateLayer { - return YES; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 + if (NSAppKitVersionNumber < 1671) + return NO; +#endif + + /* Running on macOS 10.14 or above. */ + return YES; } -- 2.26.0 --X1bOJ3K7DJ5YkBrT--