Subject: bug#42655: 27.1; iconify-frame on a Lucid build may stuck the frame

From: Eli Zaretskii <[email-masked]>
Date: Sun, 09 Aug 2020 17:26:08 +0300

> From: Tino Calancha <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked],
>   [email-masked],  [email-masked]
> Date: Sat, 08 Aug 2020 13:52:53 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > Does anyone here have a clue why we don't get MapNotify in the GNOME
> > Shell case?
> All window managers I have tested so far (except Gnome Shell) agree on the
> following:
> 
> they send a 'VisibilityNotify event' when you select back the previously
> iconified window.

Our code expects MapNotify.  My reading of the code in xterm.c is that
we do nothing special when we receive VisibilityNotify.

I see in xterm.c that we already have some special treatment of the
Gnome Shell, see below.  Could you please put a breakpoint there, and
tell why we don't set the frame's visible flag and don't reset its
iconified flag when the PropertyNotify event is received?  Your event
log seems to indicate we get quite a few of PropertyNotify events when
the frame is de-iconified.

> Here is the comparison between window managers.
> for easier navigations, I recommend to copy the
> following lines and display it inside Emacs in a org mode buffer:

Thanks, this is very useful.

Here's the snippet from xterm.c that deals with PropertyNotify:

    case PropertyNotify:
      x_display_set_last_user_time (dpyinfo, event->xproperty.time);
      f = x_top_window_to_frame (dpyinfo, event->xproperty.window);
      if (f && event->xproperty.atom == dpyinfo->Xatom_net_wm_state)
	{
          bool not_hidden = x_handle_net_wm_state (f, &event->xproperty);
	  if (not_hidden && FRAME_ICONIFIED_P (f))
	    {
	      /* Gnome shell does not iconify us when C-z is pressed.
		 It hides the frame.  So if our state says we aren't
		 hidden anymore, treat it as deiconified.  */
	      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);
	    }
	  else if (! not_hidden && ! FRAME_ICONIFIED_P (f))
	    {
	      SET_FRAME_VISIBLE (f, 0);
	      SET_FRAME_ICONIFIED (f, true);
	      inev.ie.kind = ICONIFY_EVENT;
	      XSETFRAME (inev.ie.frame_or_window, f);
	    }
	}

      x_handle_property_notify (&event->xproperty);
      xft_settings_event (dpyinfo, event);
      goto OTHER;