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: Thu, 31 Mar 2022 17:43:09 +0100	[thread overview]
Message-ID: <YkXaHbhR+NS37uQ7@idiocy.org> (raw)
In-Reply-To: <232238068.1610928.1648723538459@mail1.libero.it>

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

On Thu, Mar 31, 2022 at 12:45:38PM +0200, Angelo Graziosi wrote:
> > Il 30/03/2022 23:52 Alan Third  ha scritto:
> >
> > I can't reproduce it on 10.14 either. I suspect it's some subtle
> > difference in layer handling between 10.13 and 10.14+.
> > 
> > 
> > Maybe the attached will help.
> 
> No.. I am afraid...
> 
> I applied it to current master and it builds but crashes when I try to start it.
> 
> Attached the report that the system produces (it is taken with 'Emacs -Q', but the same occurs when I start Emacs in normal way, i.e. cliking the icon on the Dock).

Can you try the new version attached to this email, please?

-- 
Alan Third

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

From ea124ec1849c4f800a8e0a81be41ed195853d0de Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
Date: Wed, 30 Mar 2022 22:40:03 +0100
Subject: [PATCH v2] Fix scrollbars on macOS 10.13 and below (bug#54623)

* src/nsterm.h (NSAppKitVersionNumber10_14): Required for
makeBackingLayer version check.
* src/nsterm.m (USING_EMACSLAYER): Check whether we're using layers
and whether the layer is an EmacsLayer class.
([EmacsView makeBackingLayer]): Only use EmacsLayer on macOS 10.14 and above.
([EmacsView lockFocus]):
([EmacsView unlockFocus]):
([EmacsView windowDidChangeBackingProperties:]):
([EmacsView copyRect:to:]): Replace check for wantsLayer with
USING_EMACSLAYER.
([EmacsView unlockFocus]): Remove call to flushWindow.
---
 src/nsterm.h |  4 ++++
 src/nsterm.m | 31 ++++++++++++++++++-------------
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/src/nsterm.h b/src/nsterm.h
index f027646123..ea92d8e893 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1239,6 +1239,10 @@ #define NSAppKitVersionNumber10_7 1138
 #ifndef NSAppKitVersionNumber10_10
 #define NSAppKitVersionNumber10_10 1343
 #endif
+
+#ifndef NSAppKitVersionNumber10_14
+#define NSAppKitVersionNumber10_14 1671
+#endif
 #endif /* NS_IMPL_COCOA */
 
 
diff --git a/src/nsterm.m b/src/nsterm.m
index fd56094c28..4b4ca44981 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -5954,6 +5954,9 @@ - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg
 
 @implementation EmacsView
 
+#define USING_EMACSLAYER \
+  ([self wantsLayer] && [[self layer] isKindOfClass:[EmacsLayer class]])
+
 /* Needed to inform when window closed from lisp.  */
 - (void) setWindowClosing: (BOOL)closing
 {
@@ -7864,12 +7867,17 @@ - (instancetype)toggleToolbar: (id)sender
 #ifdef NS_IMPL_COCOA
 - (CALayer *)makeBackingLayer;
 {
-  EmacsLayer *l = [[EmacsLayer alloc]
-                    initWithColorSpace:[[[self window] colorSpace] CGColorSpace]];
-  [l setDelegate:(id)self];
-  [l setContentsScale:[[self window] backingScaleFactor]];
+  if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_14)
+    {
+      EmacsLayer *l = [[EmacsLayer alloc]
+                        initWithColorSpace:[[[self window] colorSpace] CGColorSpace]];
+      [l setDelegate:(id)self];
+      [l setContentsScale:[[self window] backingScaleFactor]];
+
+      return l;
+    }
 
-  return l;
+  return [super makeBackingLayer];
 }
 
 
@@ -7877,7 +7885,7 @@ - (void)lockFocus
 {
   NSTRACE ("[EmacsView lockFocus]");
 
-  if ([self wantsLayer])
+  if (USING_EMACSLAYER)
     {
       CGContextRef context = [(EmacsLayer*)[self layer] getContext];
 
@@ -7897,17 +7905,14 @@ - (void)unlockFocus
 {
   NSTRACE ("[EmacsView unlockFocus]");
 
-  if ([self wantsLayer])
+  if (USING_EMACSLAYER)
     {
       [NSGraphicsContext setCurrentContext:nil];
       [self setNeedsDisplay:YES];
     }
 #if MAC_OS_X_VERSION_MIN_REQUIRED < 101400
   else
-    {
-      [super unlockFocus];
-      [super flushWindow];
-    }
+    [super unlockFocus];
 #endif
 }
 
@@ -7917,7 +7922,7 @@ - (void)windowDidChangeBackingProperties:(NSNotification *)notification
 {
   NSTRACE ("EmacsView windowDidChangeBackingProperties:]");
 
-  if ([self wantsLayer])
+  if (USING_EMACSLAYER)
     {
       NSRect frame = [self frame];
       EmacsLayer *layer = (EmacsLayer *)[self layer];
@@ -7942,7 +7947,7 @@ - (void)copyRect:(NSRect)srcRect to:(NSPoint)dest
                                NSHeight (srcRect));
 
 #ifdef NS_IMPL_COCOA
-  if ([self wantsLayer])
+  if (USING_EMACSLAYER)
     {
       double scale = [[self window] backingScaleFactor];
       CGContextRef context = [(EmacsLayer *)[self layer] getContext];
-- 
2.35.1


  reply	other threads:[~2022-03-31 16:43 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 [this message]
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
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=YkXaHbhR+NS37uQ7@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).