unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Third <alan@idiocy.org>
To: Angelo Graziosi <angelo.g0@libero.it>
Cc: 54623@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#54623: No scroll bars on macOS builds
Date: Sat, 2 Apr 2022 09:07:49 +0100	[thread overview]
Message-ID: <YkgEVba0iG9CRpS4@idiocy.org> (raw)
In-Reply-To: <855785195.1995564.1648852653736@mail1.libero.it>

[-- Attachment #1: Type: text/plain, Size: 525 bytes --]

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

[-- Attachment #2: v4-0001-Fix-scrollbars-on-macOS-10.13-and-below-bug-54623.patch --]
[-- Type: text/x-diff, Size: 8301 bytes --]

From a2b78c8b93b7c52fce1c3d1c6b6c478d86419a0d Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
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


  reply	other threads:[~2022-04-02  8:07 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 11:50 bug#54623: No scroll bars on macOS builds Angelo Graziosi
2022-03-29 12:44 ` Lars Ingebrigtsen
2022-03-29 19:53   ` Angelo Graziosi
2022-03-30  0:39     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-31 11:56     ` Lars Ingebrigtsen
2022-03-31 20:06       ` Alan Third
2022-03-31 22:31         ` Angelo Graziosi
2022-03-30 21:52   ` Alan Third
2022-03-31 10:45     ` Angelo Graziosi
2022-03-31 16:43       ` Alan Third
2022-03-31 22:27         ` Angelo Graziosi
2022-04-01 20:59           ` Alan Third
2022-04-01 22:37             ` Angelo Graziosi
2022-04-02  8:07               ` Alan Third [this message]
2022-04-02  9:42                 ` Angelo Graziosi
2022-04-02 11:00                   ` Angelo Graziosi
2022-04-03 13:36                     ` Alan Third
2022-04-03 20:00                       ` Angelo Graziosi
2022-04-04 20:30                         ` Angelo Graziosi
2022-04-08 21:47                           ` Alan Third
2022-04-09 10:20                             ` Angelo Graziosi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YkgEVba0iG9CRpS4@idiocy.org \
    --to=alan@idiocy.org \
    --cc=54623@debbugs.gnu.org \
    --cc=angelo.g0@libero.it \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).