From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#54623: No scroll bars on macOS builds Date: Sat, 2 Apr 2022 09:07:49 +0100 Message-ID: References: <542747779.525811.1648554603075@mail1.libero.it> <875ynxapxv.fsf@gnus.org> <232238068.1610928.1648723538459@mail1.libero.it> <1573705019.892210.1648765645434@mail1.libero.it> <855785195.1995564.1648852653736@mail1.libero.it> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="T5EK1sIK++y0ay6R" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17161"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 54623@debbugs.gnu.org, Lars Ingebrigtsen To: Angelo Graziosi Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 02 10:09:15 2022 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 1naYot-0004Fu-6m for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 02 Apr 2022 10:09:15 +0200 Original-Received: from localhost ([::1]:47660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1naYor-00077m-KB for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 02 Apr 2022 04:09:13 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:47676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1naYog-00076L-J4 for bug-gnu-emacs@gnu.org; Sat, 02 Apr 2022 04:09:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1naYog-0004wX-9T for bug-gnu-emacs@gnu.org; Sat, 02 Apr 2022 04:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1naYog-0000b6-1W for bug-gnu-emacs@gnu.org; Sat, 02 Apr 2022 04:09: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, 02 Apr 2022 08:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54623 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 54623-submit@debbugs.gnu.org id=B54623.16488868822225 (code B ref 54623); Sat, 02 Apr 2022 08:09:01 +0000 Original-Received: (at 54623) by debbugs.gnu.org; 2 Apr 2022 08:08:02 +0000 Original-Received: from localhost ([127.0.0.1]:44537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1naYnh-0000Zc-LW for submit@debbugs.gnu.org; Sat, 02 Apr 2022 04:08:02 -0400 Original-Received: from outbound.soverin.net ([116.202.126.228]:55101) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1naYnf-0000ZD-4e for 54623@debbugs.gnu.org; Sat, 02 Apr 2022 04:08:00 -0400 Original-Received: from smtp.soverin.net (unknown [10.10.3.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id 5E0F4316; Sat, 2 Apr 2022 08:07:52 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [10.10.4.99]) by soverin.net DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin; t=1648886871; bh=D0JtrC1m+/DJlqcf6crI3Ex7F1hPeJvwFX20fb5PYUg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Nq3aKU2FzIZD73q+Md3qsN7fLqMO+jWP5PugtKviJbyFKngVQJYdxuAmcCh6BYLqW ivk8+WOOW2TjDcY5aSG6CoJrUmrf+MGIngXotTe7DKWbGZh2Wjqk3tdL5tw4YaTagE T/WYAUC/47vLCLROz/VKAUJXJMRvgwE21aZp1ZCtE7uhsXWhoSWWi3qtvQyg1K43Xj anPSy5TuGynxPGUDUOq+E/Sny+EeVfVd+L1R5B5yS8lzM9l9tO2bH68iKghHE084Ma w5fx024V6i/M52R+b0UZh5PvEhC6M5qy81qMDWKiN6iH2BHlaXep30UJ4Zm3E2wzPp aXny1CrUyOkjA== Original-Received: from alan by faroe.holly.idiocy.org with local (Exim 4.95) (envelope-from ) id 1naYnV-000JbD-7E; Sat, 02 Apr 2022 09:07:49 +0100 Mail-Followup-To: Alan Third , Angelo Graziosi , Lars Ingebrigtsen , 54623@debbugs.gnu.org Content-Disposition: inline In-Reply-To: <855785195.1995564.1648852653736@mail1.libero.it> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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:229257 Archived-At: --T5EK1sIK++y0ay6R Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Apr 02, 2022 at 12:37:33AM +0200, Angelo Graziosi wrote: > Undefined symbols for architecture x86_64: > "_OBJC_CLASS_$_EmacsLayer", referenced from: > objc-class-ref in nsterm.o > ld: symbol(s) not found for architecture x86_64 > clang: error: linker command failed with exit code 1 (use -v to see invocation) > make[1]: *** [temacs] Error 1 > make: *** [src] Error 2 > Error: Failure running MAKE *sigh* missed a zero in the version number in one of the #if things. Please try the attached. -- Alan Third --T5EK1sIK++y0ay6R Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0001-Fix-scrollbars-on-macOS-10.13-and-below-bug-54623.patch" >From a2b78c8b93b7c52fce1c3d1c6b6c478d86419a0d Mon Sep 17 00:00:00 2001 From: Alan Third Date: Wed, 30 Mar 2022 22:40:03 +0100 Subject: [PATCH v4] Fix scrollbars on macOS 10.13 and below (bug#54623) Make any build on macOS 10.13 and below follow the same drawing path as the GNUstep port. macOS 10.14 and above will use EmacsLayer. * src/nsterm.h (EmacsLayer): * src/nsterm.m ([EmacsView makeBackingLayer]): ([EmacsView unlockFocus]): ([EmacsView windowDidChangeBackingProperties:]): ([EmacsView copyRect:to:]): Remove any code required for macOS 10.13 and below, and fix the #if's to enforce strict separation of the drawing paths. --- src/nsterm.h | 4 +- src/nsterm.m | 124 +++++++++++++++++++-------------------------------- 2 files changed, 48 insertions(+), 80 deletions(-) diff --git a/src/nsterm.h b/src/nsterm.h index f027646123..4cba5c0be8 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -487,7 +487,7 @@ #define NSTRACE_UNSILENCE() #endif - (int)fullscreenState; -#ifdef NS_IMPL_COCOA +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 - (void)lockFocus; - (void)unlockFocus; #endif @@ -698,7 +698,7 @@ #define NSTRACE_UNSILENCE() + (CGFloat)scrollerWidth; @end -#ifdef NS_IMPL_COCOA +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 @interface EmacsLayer : CALayer { NSMutableArray *cache; diff --git a/src/nsterm.m b/src/nsterm.m index fd56094c28..a093b6a67d 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -7197,7 +7197,7 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f [[EmacsWindow alloc] initWithEmacsFrame:f]; -#ifdef NS_IMPL_COCOA +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 /* These settings mean AppKit will retain the contents of the frame on resize. Unfortunately it also means the frame will not be automatically marked for display, but we can do that ourselves in @@ -7861,7 +7861,7 @@ - (instancetype)toggleToolbar: (id)sender } -#ifdef NS_IMPL_COCOA +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 - (CALayer *)makeBackingLayer; { EmacsLayer *l = [[EmacsLayer alloc] @@ -7877,19 +7877,12 @@ - (void)lockFocus { NSTRACE ("[EmacsView lockFocus]"); - if ([self wantsLayer]) - { - CGContextRef context = [(EmacsLayer*)[self layer] getContext]; + CGContextRef context = [(EmacsLayer*)[self layer] getContext]; - [NSGraphicsContext + [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithCGContext:context flipped:YES]]; - } -#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 - else - [super lockFocus]; -#endif } @@ -7897,18 +7890,8 @@ - (void)unlockFocus { NSTRACE ("[EmacsView unlockFocus]"); - if ([self wantsLayer]) - { - [NSGraphicsContext setCurrentContext:nil]; - [self setNeedsDisplay:YES]; - } -#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 - else - { - [super unlockFocus]; - [super flushWindow]; - } -#endif + [NSGraphicsContext setCurrentContext:nil]; + [self setNeedsDisplay:YES]; } @@ -7917,19 +7900,16 @@ - (void)windowDidChangeBackingProperties:(NSNotification *)notification { NSTRACE ("EmacsView windowDidChangeBackingProperties:]"); - if ([self wantsLayer]) - { - NSRect frame = [self frame]; - EmacsLayer *layer = (EmacsLayer *)[self layer]; + NSRect frame = [self frame]; + EmacsLayer *layer = (EmacsLayer *)[self layer]; - [layer setContentsScale:[[notification object] backingScaleFactor]]; - [layer setColorSpace:[[[notification object] colorSpace] CGColorSpace]]; + [layer setContentsScale:[[notification object] backingScaleFactor]]; + [layer setColorSpace:[[[notification object] colorSpace] CGColorSpace]]; - ns_clear_frame (emacsframe); - expose_frame (emacsframe, 0, 0, NSWidth (frame), NSHeight (frame)); - } + ns_clear_frame (emacsframe); + expose_frame (emacsframe, 0, 0, NSWidth (frame), NSHeight (frame)); } -#endif /* NS_IMPL_COCOA */ +#endif - (void)copyRect:(NSRect)srcRect to:(NSPoint)dest @@ -7941,57 +7921,45 @@ - (void)copyRect:(NSRect)srcRect to:(NSPoint)dest NSRect dstRect = NSMakeRect (dest.x, dest.y, NSWidth (srcRect), NSHeight (srcRect)); -#ifdef NS_IMPL_COCOA - if ([self wantsLayer]) - { - double scale = [[self window] backingScaleFactor]; - CGContextRef context = [(EmacsLayer *)[self layer] getContext]; - int bpp = CGBitmapContextGetBitsPerPixel (context) / 8; - void *pixels = CGBitmapContextGetData (context); - int rowSize = CGBitmapContextGetBytesPerRow (context); - int srcRowSize = NSWidth (srcRect) * scale * bpp; - void *srcPixels = (char *) pixels - + (int) (NSMinY (srcRect) * scale * rowSize - + NSMinX (srcRect) * scale * bpp); - void *dstPixels = (char *) pixels - + (int) (dest.y * scale * rowSize - + dest.x * scale * bpp); - - if (NSIntersectsRect (srcRect, dstRect) - && NSMinY (srcRect) < NSMinY (dstRect)) - for (int y = NSHeight (srcRect) * scale - 1 ; y >= 0 ; y--) - memmove ((char *) dstPixels + y * rowSize, - (char *) srcPixels + y * rowSize, - srcRowSize); - else - for (int y = 0 ; y < NSHeight (srcRect) * scale ; y++) - memmove ((char *) dstPixels + y * rowSize, - (char *) srcPixels + y * rowSize, - srcRowSize); - - } -#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 + double scale = [[self window] backingScaleFactor]; + CGContextRef context = [(EmacsLayer *)[self layer] getContext]; + int bpp = CGBitmapContextGetBitsPerPixel (context) / 8; + void *pixels = CGBitmapContextGetData (context); + int rowSize = CGBitmapContextGetBytesPerRow (context); + int srcRowSize = NSWidth (srcRect) * scale * bpp; + void *srcPixels = (char *) pixels + + (int) (NSMinY (srcRect) * scale * rowSize + + NSMinX (srcRect) * scale * bpp); + void *dstPixels = (char *) pixels + + (int) (dest.y * scale * rowSize + + dest.x * scale * bpp); + + if (NSIntersectsRect (srcRect, dstRect) + && NSMinY (srcRect) < NSMinY (dstRect)) + for (int y = NSHeight (srcRect) * scale - 1 ; y >= 0 ; y--) + memmove ((char *) dstPixels + y * rowSize, + (char *) srcPixels + y * rowSize, + srcRowSize); else - { -#endif -#endif /* NS_IMPL_COCOA */ + for (int y = 0 ; y < NSHeight (srcRect) * scale ; y++) + memmove ((char *) dstPixels + y * rowSize, + (char *) srcPixels + y * rowSize, + srcRowSize); -#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MIN_REQUIRED < 101400 - hide_bell(); // Ensure the bell image isn't scrolled. +#else + 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_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED < 101400 - } + 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 } -#ifdef NS_IMPL_COCOA +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 /* If the frame has been garbaged but the toolkit wants to draw, for example when resizing the frame, we end up with a blank screen. Sometimes this results in an unpleasant flicker, so try to @@ -9435,7 +9403,7 @@ - (void) scrollWheel: (NSEvent *)theEvent @end /* EmacsScroller */ -#ifdef NS_IMPL_COCOA +#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 /* ========================================================================== -- 2.35.1 --T5EK1sIK++y0ay6R--