unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Kirill A. Korinsky" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Alan Third <alan@idiocy.org>
Cc: 50534@debbugs.gnu.org
Subject: bug#50534: 28.0.50; Toolbar shows despite tool-bar-mode being disabled on macOS
Date: Tue, 14 Sep 2021 00:21:27 +0200	[thread overview]
Message-ID: <BC298DB6-BB39-46DB-ACF2-DF742739C951@korins.ky> (raw)
In-Reply-To: <E04155E0-DF7B-4EEB-A186-AA79AB0A6E4D@korins.ky>


[-- Attachment #1.1: Type: text/plain, Size: 880 bytes --]

Maybe it can be for some use.

I've attached the minimal patch which fixed issue for me.

This patch reverted some of your changes.

Because when I move to full screen => toolbar is dissapear, I feel that the root cause is replacing layoutSublayersOfLayer to layout.

Anyway, I don't know quartz and I can't minimize it future.

--
wbr, Kirill



> On 13. Sep 2021, at 22:42, Kirill A. Korinsky <kirill@korins.ky> wrote:
> 
> Same.
> 
> --
> wbr, Kirill
> 
>> On 13. Sep 2021, at 21:11, Alan Third <alan@idiocy.org <mailto:alan@idiocy.org>> wrote:
>> 
>> On Mon, Sep 13, 2021 at 08:57:12PM +0200, Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote:
>>> Nope, toolbar exists
>> 
>> Please try the attached patch.
>> --
>> Alan Third
>> <v3-0001-Fix-incorrectly-appearing-toolbar-on-NS-bug-50534.patch>
> 


[-- Attachment #1.2.1: Type: text/html, Size: 1289 bytes --]

[-- Attachment #1.2.2: worckaround-bug-50534.diff --]
[-- Type: application/octet-stream, Size: 5318 bytes --]

index 8d88f7bd3d..2ee502fa99 100644
--- src/nsterm.m
+++ src/nsterm.m
@@ -6956,6 +6956,43 @@ - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
 }


+- (void)windowDidResize: (NSNotification *)notification
+{
+  NSTRACE ("[EmacsView windowDidResize:]");
+  if (!FRAME_LIVE_P (emacsframe))
+    {
+      NSTRACE_MSG ("Ignored (frame dead)");
+      return;
+    }
+  if (emacsframe->output_data.ns->in_animation)
+    {
+      NSTRACE_MSG ("Ignored (in animation)");
+      return;
+    }
+
+  if (! [self fsIsNative])
+    {
+      NSWindow *theWindow = [notification object];
+      /* We can get notification on the non-FS window when in
+         fullscreen mode.  */
+      if ([self window] != theWindow) return;
+    }
+
+  NSTRACE_RECT ("frame", [[notification object] frame]);
+
+#ifdef NS_IMPL_GNUSTEP
+  NSWindow *theWindow = [notification object];
+
+   /* In GNUstep, at least currently, it's possible to get a didResize
+      without getting a willResize, therefore we need to act as if we got
+      the willResize now.  */
+  NSSize sz = [theWindow frame].size;
+  sz = [self windowWillResize: theWindow toSize: sz];
+#endif /* NS_IMPL_GNUSTEP */
+
+  ns_send_appdefined (-1);
+}
+
 #ifdef NS_IMPL_COCOA
 - (void)viewDidEndLiveResize
 {
@@ -6973,30 +7010,38 @@ - (void)viewDidEndLiveResize
 #endif /* NS_IMPL_COCOA */


-- (void)resizeWithOldSuperviewSize: (NSSize)oldSize
+- (void)viewDidResize:(NSNotification *)notification
 {
-  NSRect frame;
-  int width, height;
-
-  NSTRACE ("[EmacsView resizeWithOldSuperviewSize:]");
-
-  [super resizeWithOldSuperviewSize:oldSize];
+  NSRect frame = [self frame];
+  int neww, newh, oldw, oldh;

   if (! FRAME_LIVE_P (emacsframe))
     return;

-  frame = [self frame];
-  width = (int)NSWidth (frame);
-  height = (int)NSHeight (frame);
+  NSTRACE ("[EmacsView viewDidResize]");
+
+  neww = (int)NSWidth (frame);
+  newh = (int)NSHeight (frame);
+  oldw = FRAME_PIXEL_WIDTH (emacsframe);
+  oldh = FRAME_PIXEL_HEIGHT (emacsframe);

-  NSTRACE_SIZE ("New size", NSMakeSize (width, height));
-  NSTRACE_SIZE ("Original size", size);
+  /* Don't want to do anything when the view size hasn't changed. */
+  if (emacsframe->new_size_p
+      ? (newh == emacsframe->new_height
+         && neww == emacsframe->new_width)
+      : (oldh == newh && oldw == neww))
+    {
+      NSTRACE_MSG ("No change");
+      return;
+    }

-  change_frame_size (emacsframe, width, height, false, YES, false);
+  NSTRACE_SIZE ("New size", NSMakeSize (neww, newh));
+  NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh));
+
+  change_frame_size (emacsframe, neww, newh, false, YES, false);

   SET_FRAME_GARBAGED (emacsframe);
   cancel_mouse_face (emacsframe);
-  ns_send_appdefined (-1);
 }


@@ -7132,7 +7177,7 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
   /* 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
-     resizeWithOldSuperviewSize.  */
+     viewDidResize.  */
   [self setWantsLayer:YES];
   [self setLayerContentsRedrawPolicy:
           NSViewLayerContentsRedrawOnSetNeedsDisplay];
@@ -7152,6 +7197,13 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
   [NSApp registerServicesMenuSendTypes: ns_send_types
                            returnTypes: [NSArray array]];

+  /* Set up view resize notifications.  */
+  [self setPostsFrameChangedNotifications:YES];
+  [[NSNotificationCenter defaultCenter]
+      addObserver:self
+         selector:@selector (viewDidResize:)
+             name:NSViewFrameDidChangeNotification object:nil];
+
   ns_window_num++;
   return self;
 }
@@ -7938,28 +7990,24 @@ - (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect
    redisplay before drawing.

    This used to be done in viewWillDraw, but with the custom layer
-   that method is not called.  We cannot call redisplay directly from
-   [NSView layout], because it may trigger another round of layout by
-   changing the frame size and recursive layout calls are banned.  It
-   appears to be safe to call redisplay here.  */
-- (void)layoutSublayersOfLayer:(CALayer *)layer
-{
-  if (!redisplaying_p && FRAME_GARBAGED_P (emacsframe))
-    {
-      /* If there is IO going on when redisplay is run here Emacs
-         crashes.  I think it's because this code will always be run
-         within the run loop and for whatever reason processing input
-         is dangerous.  This technique was stolen wholesale from
-         nsmenu.m and seems to work.  */
-      bool owfi = waiting_for_input;
-      waiting_for_input = 0;
-      block_input ();
+   that method is not called.  */
+- (void)layout
+{
+  [super layout];
+
+  /* If there is IO going on when redisplay is run here Emacs
+     crashes.  I think it's because this code will always be run
+     within the run loop and for whatever reason processing input
+     is dangerous.  This technique was stolen wholesale from
+     nsmenu.m and seems to work.  */
+  bool owfi = waiting_for_input;
+  waiting_for_input = 0;
+  block_input ();

-      redisplay ();
+  redisplay ();

-      unblock_input ();
-      waiting_for_input = owfi;
-    }
+  unblock_input ();
+  waiting_for_input = owfi;
 }
 #endif

[-- Attachment #1.2.3: Type: text/html, Size: 1960 bytes --]

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-09-13 22:21 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-12  0:29 bug#50534: 28.0.50; Toolbar shows despite tool-bar-mode being disabled on macOS Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found] ` <handler.50534.B.16314065846903.ack@debbugs.gnu.org>
2021-09-12  9:25   ` bug#50534: Acknowledgement (28.0.50; Toolbar shows despite tool-bar-mode being disabled on macOS) Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-12 11:48 ` bug#50534: 28.0.50; Toolbar shows despite tool-bar-mode being disabled on macOS Alan Third
2021-09-12 12:54   ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-12 15:33     ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-12 15:44     ` Alan Third
2021-09-12 16:40       ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-12 19:43         ` Alan Third
2021-09-12 19:52           ` Alan Third
2021-09-12 20:14             ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-12 20:35               ` Alan Third
2021-09-12 21:02                 ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-13 18:44                   ` Alan Third
2021-09-13 18:52                     ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-13 18:54                       ` Alan Third
2021-09-13 18:57                         ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-13 19:11                           ` Alan Third
2021-09-13 20:42                             ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-13 22:21                               ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-09-13 23:25                                 ` Alan Third
2021-09-14  0:05                                   ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-14  9:21                                     ` Alan Third
2021-09-14 11:26                                       ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-14 12:13                                         ` Alan Third
2021-09-14 12:54                                           ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-14 14:17                                           ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-14 14:35                                             ` Alan Third
2021-09-14 14:43                                               ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-17 17:26                                               ` Alan Third
2021-09-26 10:56                                                 ` Alan Third
2021-09-26 16:23                                                   ` Mattias Engdegård
2021-09-27 10:10                                                     ` Alan Third
2021-09-28 19:00                                                       ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-28 19:14                                                         ` Alan Third
2021-09-29 10:53                                                           ` Kirill A. Korinsky via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-14 16:07                                         ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=BC298DB6-BB39-46DB-ACF2-DF742739C951@korins.ky \
    --to=bug-gnu-emacs@gnu.org \
    --cc=50534@debbugs.gnu.org \
    --cc=alan@idiocy.org \
    --cc=kirill@korins.ky \
    /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).