unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Tassilo Horn <tsdh@gnu.org>
Cc: Garjola Dindi <garjola@garjola.net>, emacs-devel@gnu.org
Subject: Re: Proposing changes to adjust_frame_size
Date: Tue, 11 May 2021 10:29:45 +0200	[thread overview]
Message-ID: <fcd5a256-6ff3-6062-bfbc-15c295708851@gmx.at> (raw)
In-Reply-To: <871raebctt.fsf@gnu.org>

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

 >> OK.  Now please start with emacs -Q -iconic and tell me how it looks
 >> like when you deiconify it.
 >
 > Iconified frames/windows are nothing supported by sway.  If you don't
 > need a window but don't want to close it, you can send it to the
 > scratchpad workspace.

If there were an API for that we could support it.  I still don't get a
couple of things with sway: Does it support resize requests?  What
happens when you make an already visible frame invisible or iconified?
Does it support size hints?

 > Anyway, emacs -Q -iconic results in a frame where
 > only the menubar is shown and the toolbar is missing until I switch
 > focus back and forth, so just like a normal, non-iconic frame without
 > your latest patch.
 >
 >> Also please do a
 >>
 >> (setq frame (make-frame '((visibility . icon))))
 >
 > I get a new frame with a menubar but no toolbar (unless I'd resize it or
 > swith focus back and forth).

While here we could say "don't do that, then" ...

 >> followed by (make-frame-visible frame)
 >
 > No observable change.
 >
 >> and a
 >>
 >> (setq frame (make-frame '((visibility . nil))))
 >
 > Nothing happens which I guess is expected.

... this one looks like valid behavior ...

 >> (make-frame-visible frame)
 >
 > The frame appears with again a menubar but no toolbar (until I apply one
 > of my workarounds as above).

... and this is our usual annoyance.  I attached a new patch which
should handle these cases as well.  If there's anything else left,
please tell me.

martin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: frame-was-visible.diff --]
[-- Type: text/x-patch; name="frame-was-visible.diff", Size: 6825 bytes --]

diff --git a/lisp/faces.el b/lisp/faces.el
index 68bfbbae38..9969140f0c 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2118,7 +2118,23 @@ x-create-frame-with-faces
 	  (x-handle-reverse-video frame parameters)
 	  (frame-set-background-mode frame t)
 	  (face-set-after-frame-default frame parameters)
-	  (if (null visibility-spec)
+          ;; Mark frame as 'was-invisible' when it was created as
+          ;; invisible or iconified and PARAMETERS contains either a
+          ;; width or height specification.  This should be sufficient
+          ;; to handle Bug#24526 (where a frame is initially iconified
+          ;; to allow manipulating its size in a non-obtrusive way) and
+          ;; avoid that a tiling window manager for GTK3 gets a resize
+          ;; request it cannot handle (Bug#48268).  The 'was-invisible'
+          ;; flag is eventually processed in xterm.c after we receive a
+          ;; MapNotify event; non-X builds ignore it.
+          (frame--set-was-invisible
+           frame
+           (and visibility-spec
+                (memq (cdr visibility-spec) '(nil icon))
+                (or (assq 'width parameters)
+                    (assq 'height parameters))))
+
+          (if (null visibility-spec)
 	      (make-frame-visible frame)
 	    (modify-frame-parameters frame (list visibility-spec)))
 	  (setq success t))
diff --git a/src/frame.c b/src/frame.c
index 738bfe9a5c..15988a6c30 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -971,6 +971,7 @@ make_frame (bool mini_p)
   f->no_accept_focus = false;
   f->z_group = z_group_none;
   f->tooltip = false;
+  f->was_invisible = false;
   f->child_frame_border_width = -1;
   f->last_tab_bar_item = -1;
 #ifndef HAVE_EXT_TOOL_BAR
@@ -5907,7 +5908,18 @@ DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p,
   return decode_any_frame (frame)->pointer_invisible ? Qnil : Qt;
 }
 
+DEFUN ("frame--set-was-invisible", Fframe__set_was_invisible,
+       Sframe__set_was_invisible, 2, 2, 0,
+       doc: /* Set FRAME's was-invisible flag if WAS-INVISIBLE is non-nil.
+This function is for internal use only.  */)
+  (Lisp_Object frame, Lisp_Object was_invisible)
+{
+  struct frame *f = decode_live_frame (frame);
 
+  f->was_invisible = !NILP (was_invisible);
+
+  return f->was_invisible ? Qt : Qnil;
+}
 \f
 /***********************************************************************
 			Multimonitor data
@@ -6547,6 +6559,7 @@ focus (where a frame immediately loses focus when it's left by the mouse
   defsubr (&Sframe_position);
   defsubr (&Sset_frame_position);
   defsubr (&Sframe_pointer_visible_p);
+  defsubr (&Sframe__set_was_invisible);
   defsubr (&Sframe_window_state_change);
   defsubr (&Sset_frame_window_state_change);
   defsubr (&Sframe_scale_factor);
diff --git a/src/frame.h b/src/frame.h
index 744b95e1e0..75a0b184c1 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -456,7 +456,11 @@ #define EMACS_FRAME_H
   /* True when new_width or new_height were set by change_frame_size,
      false when they were set by adjust_frame_size internally or not
      set.  */
-  bool_bf new_size_p;
+  bool_bf new_size_p : 1;
+
+  /* True when frame was invisible before first MapNotify event.  Used
+     in X builds only.  */
+  bool_bf was_invisible : 1;
 
   /* Bitfield area ends here.  */
 
diff --git a/src/nsfns.m b/src/nsfns.m
index 1f281f75fd..d14f7b51ea 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1404,6 +1404,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
       else
         {
 	  /* Must have been Qnil.  */
+	  f->was_invisible = true;
         }
     }
 
diff --git a/src/w32fns.c b/src/w32fns.c
index 66baeaecbd..e5edd62abb 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -6107,6 +6107,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
 
 	  if (!NILP (visibility))
 	    w32_make_frame_visible (f);
+	  else
+	    f->was_invisible = true;
 	}
 
       store_frame_param (f, Qvisibility, visibility);
diff --git a/src/xfns.c b/src/xfns.c
index 782e0a483c..e46616e6d6 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4127,12 +4127,21 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
      cannot control visibility, so don't try.  */
   if (!f->output_data.x->explicit_parent)
     {
+      /* When called from `x-create-frame-with-faces' visibility is
+	 always explicitly nil.  */
       Lisp_Object visibility
 	= gui_display_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
                                RES_TYPE_SYMBOL);
+      Lisp_Object height
+	= gui_display_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
+      Lisp_Object width
+	= gui_display_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
 
       if (EQ (visibility, Qicon))
-	x_iconify_frame (f);
+	{
+	  f->was_invisible = true;
+	  x_iconify_frame (f);
+	}
       else
 	{
 	  if (EQ (visibility, Qunbound))
@@ -4140,8 +4149,17 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
 
 	  if (!NILP (visibility))
 	    x_make_frame_visible (f);
+	  else
+	    f->was_invisible = true;
 	}
 
+      /* Leave f->was_invisible true only if height or width were
+	 specified too.  This takes effect only when we are not called
+	 from `x-create-frame-with-faces' (see above comment).  */
+      f->was_invisible
+	= (f->was_invisible
+	   && (!EQ (height, Qunbound) || !EQ (width, Qunbound)));
+
       store_frame_param (f, Qvisibility, visibility);
     }
 
diff --git a/src/xterm.c b/src/xterm.c
index 9edaed9a34..a663a0f184 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8181,8 +8181,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 #if defined USE_GTK && defined HAVE_GTK3
 	      /* If GTK3 wants to impose some old size here (Bug#24526),
 		 tell it that the current size is what we want.  */
-	      xg_frame_set_char_size
-		(f, FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f));
+	      if (f->was_invisible)
+		{
+		  xg_frame_set_char_size
+		    (f, FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f));
+		  f->was_invisible = false;
+		}
 #endif
 	      XSETFRAME (inev.ie.frame_or_window, f);
 	    }
@@ -8443,8 +8447,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 #if defined USE_GTK && defined HAVE_GTK3
 	      /* If GTK3 wants to impose some old size here (Bug#24526),
 		 tell it that the current size is what we want.  */
-	      xg_frame_set_char_size
-		(f, FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f));
+	      if (f->was_invisible)
+		{
+		  xg_frame_set_char_size
+		    (f, FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f));
+		  f->was_invisible = false;
+		}
 #endif
 	      f->output_data.x->has_been_visible = true;
 	    }

  reply	other threads:[~2021-05-11  8:29 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-25 17:11 Proposing changes to adjust_frame_size martin rudalics
2021-04-27  8:22 ` martin rudalics
2021-04-27 14:16   ` Yuuki Harano
2021-05-02  8:46     ` martin rudalics
2021-05-02 11:21       ` Alan Third
2021-05-02 16:17         ` martin rudalics
2021-05-05  8:51       ` martin rudalics
2021-05-05 10:47         ` Yuuki Harano
2021-05-05 11:24           ` martin rudalics
2021-05-05 14:07             ` Yuuki Harano
2021-05-05 15:01               ` martin rudalics
2021-05-05 16:45                 ` martin rudalics
2021-05-05 18:54                   ` Tassilo Horn
2021-05-06  7:44                     ` martin rudalics
2021-05-06  7:59                       ` Tassilo Horn
2021-05-06  8:39                         ` martin rudalics
2021-05-06  8:49                           ` Tassilo Horn
2021-05-06 12:10                             ` martin rudalics
2021-05-06 12:31                               ` Tassilo Horn
2021-05-06 14:10                                 ` martin rudalics
2021-05-06 14:47                                   ` Tassilo Horn
2021-05-07  8:03                                     ` martin rudalics
2021-05-08  7:02                                       ` Tassilo Horn
2021-05-08  7:16                                         ` martin rudalics
2021-05-08 14:03                                           ` Tassilo Horn
2021-05-08 15:17                                             ` martin rudalics
2021-05-08 20:32                                               ` Tassilo Horn
2021-05-09  8:41                                                 ` martin rudalics
2021-05-09 10:09                                                   ` Garjola Dindi
2021-05-09 10:12                                                   ` Garjola Dindi
2021-05-09 18:48                                                   ` Tassilo Horn
2021-05-10  8:25                                                     ` martin rudalics
2021-05-10 12:27                                                       ` martin rudalics
2021-05-10 19:05                                                         ` Tassilo Horn
2021-05-10 19:21                                                           ` martin rudalics
2021-05-10 19:28                                                             ` Tassilo Horn
2021-05-11  8:29                                                               ` martin rudalics [this message]
2021-05-11  9:25                                                                 ` Tassilo Horn
2021-05-12  8:44                                                                   ` martin rudalics
2021-05-12 14:53                                                                     ` Tassilo Horn
2021-05-12 16:40                                                                       ` martin rudalics
2021-05-12 19:06                                                                         ` Tassilo Horn
2021-05-13  7:55                                                                           ` martin rudalics
2021-05-13  8:08                                                                             ` Tassilo Horn
2021-05-16  8:29                                                                               ` martin rudalics
2021-05-16  8:33                                                                                 ` Tassilo Horn
2021-05-16  9:14                                                                                   ` martin rudalics
2021-05-16  9:16                                                                                     ` Tassilo Horn
2021-05-16 12:24                                                                                       ` martin rudalics
2021-05-16 19:08                                                                                         ` Tassilo Horn
2021-05-17  7:33                                                                                           ` martin rudalics
2021-05-06 14:41                   ` Yuuki Harano
2021-05-09  9:32                     ` Yuuki Harano
2021-05-09 13:47                       ` martin rudalics
2021-05-09 15:30                         ` Yuuki Harano
2021-05-10  8:24                           ` martin rudalics
2021-05-10 13:18                             ` Yuuki Harano
2021-05-10 14:16                               ` martin rudalics
2021-05-10 15:41                                 ` Yuuki Harano
2021-05-10 19:20                                   ` martin rudalics
2021-05-11 14:32                                     ` Yuuki Harano
2021-05-12  8:47                                       ` martin rudalics
2021-05-13  8:48                                         ` Garjola Dindi
2021-05-01 18:59 ` Alan Third
2021-05-02  7:38   ` martin rudalics

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=fcd5a256-6ff3-6062-bfbc-15c295708851@gmx.at \
    --to=rudalics@gmx.at \
    --cc=emacs-devel@gnu.org \
    --cc=garjola@garjola.net \
    --cc=tsdh@gnu.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).