From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: Deiconifying GTK frames on GNOME shell Date: Fri, 10 Sep 2021 10:33:07 +0200 Message-ID: <5b621645-1d03-d102-f40f-02a07e2d9541@gmx.at> References: <87e1a3cb-430d-ff6d-6244-6e20bbdced94@gmx.at> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------D2C1F12BFD0B536AFC5D48DA" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37253"; mail-complaints-to="usenet@ciao.gmane.io" To: Dmitry Gutov , emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 10 10:34:24 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mObzL-0009OZ-H3 for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Sep 2021 10:34:23 +0200 Original-Received: from localhost ([::1]:37642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mObzK-0004YE-7w for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Sep 2021 04:34:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mObyF-0003Jy-GM for emacs-devel@gnu.org; Fri, 10 Sep 2021 04:33:15 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:57847) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mObyC-0003eS-T8 for emacs-devel@gnu.org; Fri, 10 Sep 2021 04:33:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1631262788; bh=eGVeSpIVtn1uyucipYYYKD+iYSn3pIHryTUm3eEkitI=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=hRtWf0SMF6lwQWuR8wP6mvmLFVxZ0jdqwuSCX+UfwgUYFs1z7J35EEViVgw1oI4YQ EoP79QTFsX9bSpo+dFkzMFjuc7wx5SI5uHHw8Jx/OkmXbzK0mUEotCfTCOLrnTdBJi iNzGsJJUEcqbhe8kytikIbCWZufzOpKLqrUleLQc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [192.168.1.101] ([212.95.5.135]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M9Fnj-1mKTdj0iIB-006Mzo; Fri, 10 Sep 2021 10:33:08 +0200 In-Reply-To: Content-Language: en-US X-Provags-ID: V03:K1:jrSMeq29VyNwuia0Le0OgGZFXir9YCV81qY1PcqfyOA+sK48WLp 8sp012lV4Beallow45e95ybGGnumKDvYvxaRlBDNy8gSxgpSLL0I2gY3FUdI0bw/rS3vTHE fcptiJwHGCEYAEGCykiVVYv7G5BWvFLngQ+7eZUHmwmYeddXH+ei4MdrV1M8XuBetO5/p0S 05xSnzTflen6tdorl6ggg== X-UI-Out-Filterresults: notjunk:1;V03:K0:zzJfpn0LYCQ=:6dVIh10qGZ5Yj2irJOWrQY 3dNjplPPPq78P8SNsuEZ6x27P8KeYqO+qB4mSFrHaU/ZwQq6CO/SK0NC0cO76CwmBPOTU9OLS N8YhpJR3co4Bk95iZ8gk+41HFL9aAMIVngEewyoj3X2Ltx0e64gJpU5JqroeDT+qKYeJO8WrL i/IKRyMhml86cLrTQazSPtAeCzCyF8hMvQ+VG4XiFxDD0tKhPjtK2e+VKzzotBF4/Sxmx5Ef9 DhLsT7m4ejLvwt/2VkV2CWoGEjNHMocSj8WrYHTZaxL38cAfzO4V7F+RZkpbx7/wpnsv+fnYH +/qa853n4WB4KhZiWTKsEv7FMuCTivLdz8CSw37ov3w51oqgemBJAvYNr7oPhOCj36qUSnRbh BTy0NIGJQTUtYILOY+ondz0SQwXS6dBBpyrVwX/6+qpLjk0DWKoqpHVyF8+BGNwhGQY633o6u OZpx/y7NRv7syXdpjXUggw5G5kH6kM8Lua/QaueHiM8UoyqXVOxQQfLoDOkYBo4Ug9WSyUCMn w64tjCwbqw1td/yhCa9+tgBIyeWPTYG7ODf65BnhWJJ2X4sAb1hFXxUqqkd79qksuCVy88Il8 9vSOANbgNJrhlesuEV2Pyd9DLrbSCKcY9peA1JbEA/47MYVr2gkdXQcNKRR624yR9rWAQjWkh vvjUM4YyDJ1FOEd0DW0YolyfK0rH0vkBedyVoevzY1icJueE+/4nYau3SGTVfnUn9cJULMZQF 0y80d6dLAw2WkXr0HkchiNK+EabyJuBAUkIH+hhwPq0KfyFnI9xa9ahfNma28aaK1u06pzqP Received-SPF: pass client-ip=212.227.17.21; envelope-from=rudalics@gmx.at; helo=mout.gmx.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:274507 Archived-At: This is a multi-part message in MIME format. --------------D2C1F12BFD0B536AFC5D48DA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit > 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 --------------D2C1F12BFD0B536AFC5D48DA Content-Type: text/x-patch; name="viv.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="viv.diff" diff --git a/src/w32term.c b/src/w32term.c index ad4d1a3282..a1b20236d8 100644 =2D-- 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 =2D-- a/src/xdisp.c +++ b/src/xdisp.c @@ -15675,9 +15675,6 @@ redisplay_internal (void) FRAME_TTY (sf)->previous_frame =3D 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 =3D 0; FOR_EACH_FRAME (tail, frame) diff --git a/src/xterm.c b/src/xterm.c index 1887c3255d..0de6be762c 100644 =2D-- a/src/xterm.c +++ b/src/xterm.c @@ -8239,12 +8239,33 @@ handle_one_xevent (struct x_display_info *dpyinfo, f =3D 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 =3D 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 =3D true; inev.ie.kind =3D 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 =3D x_top_window_to_frame (dpyinfo, event->xvisibility.window); - if (f && (event->xvisibility.state =3D=3D VisibilityUnobscured - || event->xvisibility.state =3D=3D VisibilityPartiallyObscured)) - SET_FRAME_VISIBLE (f, 1); + if (f) + { + if (event->xvisibility.state =3D=3D VisibilityUnobscured + || event->xvisibility.state =3D=3D 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); } --------------D2C1F12BFD0B536AFC5D48DA--