patch/rfc: gui_beval issue with gtk3

8 views
Skip to first unread message

Johannes Stezenbach

unread,
Jun 11, 2021, 6:00:38 AM6/11/21
to vim...@googlegroups.com
(resend, CONTRIBUTING.md points to
http://www.vim.org/maillist.php#vim-dev but mail
to vim...@vim.org apparently does not make it to the list)

Hi,

I'm suffering from an annoying issue with ballooneval as
used by the taglist plugin. When using gvim built with --enable-gui=gtk3
the balloon sometimes does not hide when the gvim window loses
focus, i.e. the ballon shows on top of other windows even
when gvim is completely hidden behind other windows, or even
when the gvim window is on a different virtual desktop.

This is not easy to reproduce at will, the ingredients to
reproduce it are awesome wm (awesomewm.org) and multiple
gvim and xterm windows on multiple virtual desktops (awesome uses
a concept of tags to implement them). Awesome is a tiling wm but
I'm using floating window layout, i.e. like a non-tiling wm,
i.e. with overlapping windows. Then after some desktop and
window switching the issue usually appears. I have not found
any deterministic way to reproduce it, though.

The issue appears with gvim from Debian unstable's vim-gtk3 package
(there is no gtk2 version anymore in Debian unstable). It can be
reproduced with current git built with
"./configure --prefix=/usr --enable-gui=gtk3 --disable-xim".

I debugged it using the attached vim-gdk-event-debug.patch
and got this log:

Good case:

target_event_cb 3 00203f0e
pointer_event 27 0
Gdk-Message: 10:39:58.996: leave notify: window 71303175
subwindow:0
device: 2
source device: 9
notify type: 3
crossing mode: 0
target_event_cb 11 00203f0e
target_event_cb: GDK_LEAVE_NOTIFY 0
mainwin_event_cb 11 00437310
mainwin_event_cb: GDK_LEAVE_NOTIFY 0
Gdk-Message: 10:39:59.026: focus out: window: 71303175, detail: NotifyNonlinear, mode: NotifyNormal
Gdk-Message: 10:39:59.026: focus out: window: 71303175, detail: NotifyNonlinearVirtual, mode: NotifyNormal
mainwin_event_cb 12 00437310
mainwin_event_cb: GDK_FOCUS_CHANGE


Bad case:

target_event_cb 3 00203f0e
pointer_event 15 0
Gdk-Message: 10:41:33.068: leave notify: window 56623548
subwindow:0
device: 2
source device: 9
notify type: 3
crossing mode: 0
Gdk-Message: 10:41:33.068: leave notify: window 56623108
subwindow:0
device: 2
source device: 9
notify type: 4
crossing mode: 0
mainwin_event_cb 11 00437310
mainwin_event_cb: GDK_LEAVE_NOTIFY 0
mainwin_event_cb 11 00437310
mainwin_event_cb: GDK_LEAVE_NOTIFY 0
Gdk-Message: 10:41:33.087: focus out: window: 56623108, detail: NotifyNonlinear, mode: NotifyNormal
Gdk-Message: 10:41:33.087: focus out: window: 56623108, detail: NotifyNonlinearVirtual, mode: NotifyNormal
mainwin_event_cb 12 00437310
mainwin_event_cb: GDK_FOCUS_CHANGE


I have no clue about the root cause, I suppose it could be
an issue in gtk3 but this is out of scope for me to debug.
The attached gvim-beval-fix.patch fixes (or works around)
the issue for me.

FWIW, the relevant X11 spec for the events is:
https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#events:pointer_window


Best Regards,
Johannes
vim-gdk-event-debug.patch
gvim-beval-fix.patch

Christian Brabandt

unread,
Jun 11, 2021, 6:03:42 AM6/11/21
to vim...@googlegroups.com

On Fr, 11 Jun 2021, Johannes Stezenbach wrote:

> (resend, CONTRIBUTING.md points to
> http://www.vim.org/maillist.php#vim-dev but mail
> to vim...@vim.org apparently does not make it to the list)

Oh it does, its just that the very first message from an author needs to
be moderated. And I did not get a notification for your message
yesterday, just now so I approved it.

I cannot say anything about the issue below however.

Best,
Christian
--
Wenn Sie nicht über die Zukunft nachdenken, können Sie keine haben.
Je weiter ein Ideal entfernt ist, desto schöner ist es.
-- John Galsworthy

Johannes Stezenbach

unread,
Jun 14, 2021, 3:07:14 PM6/14/21
to vim...@googlegroups.com, Bram Moolenaar
Hi Bram,

On Fri, Jun 11, 2021 at 11:53:16AM +0200, Johannes Stezenbach wrote:
> I'm suffering from an annoying issue with ballooneval as
> used by the taglist plugin. When using gvim built with --enable-gui=gtk3
> the balloon sometimes does not hide when the gvim window loses
> focus, i.e. the ballon shows on top of other windows even
> when gvim is completely hidden behind other windows, or even
> when the gvim window is on a different virtual desktop.

Could you please take a look at the issue and my proposed patch?

Thanks,
Johannes


--- snip ---
fix gtk3 GUI balloon failing to hide

In some rare cases the GDK_LEAVE_NOTIFY event does not
propagate to the target window but instead is sent
to the main window twice. This might be a gtk3 issue.

diff --git a/src/gui_beval.c b/src/gui_beval.c
index 57122ffa9ae2..d2bf8089a357 100644
--- a/src/gui_beval.c
+++ b/src/gui_beval.c
@@ -253,6 +253,9 @@ addEventHandler(GtkWidget *target, BalloonEval *beval)
if (gtk_socket_id == 0 && gui.mainwin != NULL
&& gtk_widget_is_ancestor(target, gui.mainwin))
{
+ gtk_widget_add_events(gui.mainwin,
+ GDK_LEAVE_NOTIFY_MASK);
+
g_signal_connect(G_OBJECT(gui.mainwin), "event",
G_CALLBACK(mainwin_event_cb),
beval);
@@ -360,6 +363,14 @@ mainwin_event_cb(GtkWidget *widget UNUSED, GdkEvent *event, gpointer data)
case GDK_KEY_RELEASE:
key_event(beval, event->key.keyval, FALSE);
break;
+ case GDK_LEAVE_NOTIFY:
+ /*
+ * Ignore LeaveNotify events that are not "normal".
+ * Apparently we also get it when somebody else grabs focus.
+ */
+ if (event->crossing.mode == GDK_CROSSING_NORMAL)
+ cancelBalloon(beval);
+ break;
default:
break;
}

Bram Moolenaar

unread,
Jun 14, 2021, 4:09:24 PM6/14/21
to Johannes Stezenbach, vim...@googlegroups.com

Johannes Stezenbach wrote:

> On Fri, Jun 11, 2021 at 11:53:16AM +0200, Johannes Stezenbach wrote:
> > I'm suffering from an annoying issue with ballooneval as
> > used by the taglist plugin. When using gvim built with --enable-gui=gtk3
> > the balloon sometimes does not hide when the gvim window loses
> > focus, i.e. the ballon shows on top of other windows even
> > when gvim is completely hidden behind other windows, or even
> > when the gvim window is on a different virtual desktop.
>
> Could you please take a look at the issue and my proposed patch?

I'm no GTK expert. If this fixes it for you and doesn't break anything
for others, it should be OK. Let me include it and await any comments.

--
Your company is doomed if your primary product is overhead transparencies.
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages