all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Dmitry Gutov <dgutov@yandex.ru>, emacs-devel <emacs-devel@gnu.org>
Subject: Re: Deiconifying GTK frames on GNOME shell
Date: Fri, 10 Sep 2021 10:33:07 +0200	[thread overview]
Message-ID: <5b621645-1d03-d102-f40f-02a07e2d9541@gmx.at> (raw)
In-Reply-To: <c496aa37-e0c6-ae8f-6660-f0c7d789f54f@yandex.ru>

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

 > If I don't do (1), BTW, I can do (2) twice, and that also makes the frame visible.
 >
 > Meaning
 >
 >    (make-frame-invisible frame)
 >    (make-frame-visible frame)
 >    (make-frame-invisible frame)
 >    (make-frame-visible frame)

I attach a patch based on this recipe but it causes (occasionally
terrible) flickers on other desktops so I would have to special-case it
on mutter anyway.  I still have no good idea what's really going on
here.

martin

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

diff --git a/src/w32term.c b/src/w32term.c
index ad4d1a3282..a1b20236d8 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -6903,11 +6903,6 @@ w32_make_frame_invisible (struct frame *f)

   my_show_window (f, FRAME_W32_WINDOW (f), SW_HIDE);

-  /* We can't distinguish this from iconification
-     just by the event that we get from the server.
-     So we can't win using the usual strategy of letting
-     FRAME_SAMPLE_VISIBILITY set this.  So do it by hand,
-     and synchronize with the server to make sure we agree.  */
   SET_FRAME_VISIBLE (f, 0);
   SET_FRAME_ICONIFIED (f, false);

diff --git a/src/xdisp.c b/src/xdisp.c
index e853c8c223..66535109b2 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -15675,9 +15675,6 @@ redisplay_internal (void)
       FRAME_TTY (sf)->previous_frame = sf;
     }

-  /* Set the visible flags for all frames.  Do this before checking for
-     resized or garbaged frames; they want to know if their frames are
-     visible.  See the comment in frame.h for FRAME_SAMPLE_VISIBILITY.  */
   number_of_visible_frames = 0;

   FOR_EACH_FRAME (tail, frame)
diff --git a/src/xterm.c b/src/xterm.c
index 1887c3255d..0de6be762c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8239,12 +8239,33 @@ handle_one_xevent (struct x_display_info *dpyinfo,
       f = x_window_to_frame (dpyinfo, event->xexpose.window);
       if (f)
         {
+	  if (CONSP (frame_size_history))
+	    {
+	      frame_size_history_extra
+		(f,
+		 FRAME_VISIBLE_P (f)
+		 ? build_string ("Expose, visible")
+		 : build_string ("Expose, not visible"),
+		 FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f),
+		 -1, -1, event->xexpose.width, event->xexpose.height);
+	    }
+
           if (!FRAME_VISIBLE_P (f))
             {
               block_input ();
 	      /* The following two are commented out to avoid that a
 		 plain invisible frame gets reported as iconified.  That
-		 problem occurred first for Emacs 26 and is described in
+		 problem occurred first for Emacs 26 with GTK3 and is
+		 the result of the following actions:
+
+		 (1) x_make_frame_invisible sets f->visible to 0.
+
+		 (2) We get an (unexpected) Expose event for f and here
+		     set f->visible to 1.
+
+		 (3) The subsequent UnmapNotify event finds f->visible
+		     is 1 and sets f->iconified true.
+
 		 https://lists.gnu.org/archive/html/emacs-devel/2017-02/msg00133.html.  */
 /** 	      SET_FRAME_VISIBLE (f, 1); **/
 /** 	      SET_FRAME_ICONIFIED (f, false); **/
@@ -8835,26 +8856,24 @@ handle_one_xevent (struct x_display_info *dpyinfo,
       goto OTHER;

     case FocusIn:
-#ifndef USE_GTK
       /* Some WMs (e.g. Mutter in Gnome Shell), don't unmap
          minimized/iconified windows; thus, for those WMs we won't get
          a MapNotify when unminimizing/deconifying.  Check here if we
-         are deiconizing a window (Bug42655).
-
-	 But don't do that on GTK since it may cause a plain invisible
-	 frame get reported as iconified, compare
-	 https://lists.gnu.org/archive/html/emacs-devel/2017-02/msg00133.html.
-	 That is fixed above but bites us here again.  */
+         are deiconifying a window (Bug42655).  */
       f = any;
+      /* Should we handle invisible frames here too?  */
       if (f && FRAME_ICONIFIED_P (f))
 	{
+	  if (CONSP (frame_size_history))
+	    frame_size_history_plain
+	      (f, build_string ("FocusIn, was iconified"));
+
           SET_FRAME_VISIBLE (f, 1);
           SET_FRAME_ICONIFIED (f, false);
           f->output_data.x->has_been_visible = true;
           inev.ie.kind = DEICONIFY_EVENT;
           XSETFRAME (inev.ie.frame_or_window, f);
         }
-#endif /* USE_GTK */

       x_detect_focus_change (dpyinfo, any, event, &inev.ie);
       goto OTHER;
@@ -9344,9 +9363,24 @@ handle_one_xevent (struct x_display_info *dpyinfo,

     case VisibilityNotify:
       f = x_top_window_to_frame (dpyinfo, event->xvisibility.window);
-      if (f && (event->xvisibility.state == VisibilityUnobscured
-		|| event->xvisibility.state == VisibilityPartiallyObscured))
-	SET_FRAME_VISIBLE (f, 1);
+      if (f)
+	{
+	  if (event->xvisibility.state == VisibilityUnobscured
+	      || event->xvisibility.state == VisibilityPartiallyObscured)
+	    {
+	      if (CONSP (frame_size_history))
+		frame_size_history_plain
+		  (f, build_string ("VisibilityNotify, visible"));
+
+	      SET_FRAME_VISIBLE (f, 1);
+	    }
+	  else
+	    {
+	      if (CONSP (frame_size_history))
+		frame_size_history_plain
+		  (f, build_string ("VisibilityNotify, invisible"));
+	    }
+	}

       goto OTHER;

@@ -11918,11 +11952,6 @@ x_make_frame_invisible (struct frame *f)

   x_sync (f);

-  /* We can't distinguish this from iconification
-     just by the event that we get from the server.
-     So we can't win using the usual strategy of letting
-     FRAME_SAMPLE_VISIBILITY set this.  So do it by hand,
-     and synchronize with the server to make sure we agree.  */
   SET_FRAME_VISIBLE (f, 0);
   SET_FRAME_ICONIFIED (f, false);

@@ -11937,7 +11966,18 @@ x_make_frame_invisible (struct frame *f)
 x_make_frame_visible_invisible (struct frame *f, bool visible)
 {
   if (visible)
+#if defined (USE_GTK)
+    if (FRAME_ICONIFIED_P (f))
+      {
+	x_make_frame_visible (f);
+	x_make_frame_invisible (f);
+	x_make_frame_visible (f);
+      }
+  else
     x_make_frame_visible (f);
+#else
+  x_make_frame_visible (f);
+#endif
   else
     x_make_frame_invisible (f);
 }

  parent reply	other threads:[~2021-09-10  8:33 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-05  9:39 Deiconifying GTK frames on GNOME shell martin rudalics
2021-09-05 10:26 ` Colin Baxter
2021-09-06  8:31   ` martin rudalics
2021-09-05 19:19 ` Dmitry Gutov
2021-09-06  8:32   ` martin rudalics
2021-09-07  0:45     ` Dmitry Gutov
2021-09-07  8:16       ` martin rudalics
2021-09-09 13:13         ` Madhu
2021-09-10  8:34           ` martin rudalics
2021-09-10 12:04             ` Madhu
2021-09-11  8:38               ` martin rudalics
2021-12-06 15:35                 ` Madhu
2021-12-08 11:00                   ` martin rudalics
2021-12-08 11:09                     ` Po Lu
2021-12-08 16:02                       ` Yuuki Harano
2021-12-09  0:28                         ` Po Lu
2021-12-09  2:30                           ` Madhu
2021-12-09  2:46                             ` Po Lu
2021-12-09  9:20                               ` Eli Zaretskii
2021-12-08 16:33                       ` Madhu
2021-12-09  0:31                         ` Po Lu
2021-12-09  2:33                           ` Madhu
2021-09-10  8:33       ` martin rudalics [this message]
2021-09-11 14:48         ` Dmitry Gutov
2021-09-11 16:43           ` 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

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

  git send-email \
    --in-reply-to=5b621645-1d03-d102-f40f-02a07e2d9541@gmx.at \
    --to=rudalics@gmx.at \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.