Bug#947989: libgtk-3-0: Mouse button presses ignored at edge of screen

Benjamin Moody benjamin.moody at gmail.com
Fri Jan 3 02:09:16 GMT 2020


Package: libgtk-3-0
Version: 3.24.5-1
Severity: normal

Dear Maintainer,

If a GTK window is placed adjacent to the top or left edge of the
screen, it sometimes fails to handle mouse clicks.

For example, with the standard MATE panel configuration, the
"Applications" menu is in the top left corner.  Yet, if I move the
mouse to coordinates (0, 10) and try to click the button, then
sometimes, nothing happens.

On the other hand, 'xdotool mousemove 0 10 click 1' works as expected.

The problem seems to be that, if the mouse cursor is "pushed" against
the edge of the screen, the XInput 2 extension sometimes reports a
*negative* sub-pixel position, and even though the event is correctly
delivered to the X client, GTK doesn't recognize the negative position
as belonging to a widget.

A test program is below.  If I run that program, then click several
times while sliding the pointer along the left edge of the screen, I
see output like:

XI_ButtonPress at 0, 71.670608520507812
 -> 1 pressed at 0, 71.670608520507812
XI_ButtonPress at 0, 88.633712768554688
 -> 1 pressed at 0, 88.633712768554688
XI_ButtonPress at -0.9815216064453125, 111.44589233398438
XI_ButtonPress at 0, 130.43672180175781
 -> 1 pressed at 0, 130.43672180175781
XI_ButtonPress at -0.9422607421875, 135.76339721679688
XI_ButtonPress at -0.935089111328125, 149.22447204589844

indicating that Xlib receives the button-press events, but GTK doesn't
transmit them to the widget.

This problem appears to affect the top and left edges of the screen,
but not the right or bottom edges.

Not sure if this should be considered a bug in GTK, a bug in X, a bug
in libinput, or even a bug in MATE, but it's rather annoying.

This is using:
* xserver-xorg-core 2:1.20.4-1
* xserver-xorg-input-libinput 0.28.2-2
* libinput10 1.12.6-2

---- Example program ----
#define _GNU_SOURCE
#include <stdio.h>
#include <dlfcn.h>
#include <gtk/gtk.h>
#include <X11/Xlib.h>
#include <X11/extensions/XInput2.h>

int XNextEvent(Display *dpy, XEvent *ev)
{
  static int (*real_XNextEvent)(Display *dpy, XEvent *ev);
  static int xi2extension;
  int op, evt, err;
  XIDeviceEvent *devev;

  if (!real_XNextEvent) {
    real_XNextEvent = dlsym(RTLD_NEXT, "XNextEvent");
    if (XQueryExtension(dpy, "XInputExtension", &op, &evt, &err))
      xi2extension = op;
  }

  (*real_XNextEvent)(dpy, ev);

  if (ev) {
    if (ev->type == ButtonPress) {
      printf("ButtonPress at %d, %d\n", ev->xbutton.x, ev->xbutton.y);
    }
    if (ev->type == GenericEvent
        && ev->xgeneric.extension == xi2extension
        && ev->xgeneric.evtype == XI_ButtonPress) {
      if (XGetEventData(dpy, &ev->xcookie)) {
        devev = ev->xcookie.data;
        printf("XI_ButtonPress at %.17g, %.17g\n",
               devev->event_x, devev->event_y);
      }
      /* welp, guess if gdk doesn't call XFreeEventData then we leak. */
    }
  }

  return 0;
}

static gboolean button_press(GtkWidget *w, GdkEventButton *ev)
{
  printf(" -> %d pressed at %.17g, %.17g\n", ev->button, ev->x, ev->y);
  return FALSE;
}

int main(int argc, char **argv)
{
  void *window, *da;
  gtk_init(&argc, &argv);
  window = gtk_window_new(GTK_WINDOW_POPUP);
  da = gtk_drawing_area_new();
  gtk_widget_add_events(da, GDK_BUTTON_PRESS_MASK);
  g_signal_connect(da, "button-press-event", G_CALLBACK(button_press), NULL);
  gtk_container_add(window, da);
  gtk_widget_show_all(window);
  gtk_window_parse_geometry(window, "300x300+0+0");
  gtk_main();
  return 0;
}


-- System Information:
Debian Release: 10.2
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-debug'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-6-amd64 (SMP w/40 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libgtk-3-0 depends on:
ii  adwaita-icon-theme   3.30.1-1
ii  hicolor-icon-theme   0.17-2
ii  libatk-bridge2.0-0   2.30.0-5
ii  libatk1.0-0          2.30.0-2
ii  libc6                2.28-10
ii  libcairo-gobject2    1.16.0-4
ii  libcairo2            1.16.0-4
ii  libcolord2           1.4.3-4
ii  libcups2             2.2.10-6+deb10u1
ii  libepoxy0            1.5.3-0.1
ii  libfontconfig1       2.13.1-2
ii  libfreetype6         2.9.1-3+deb10u1
ii  libgdk-pixbuf2.0-0   2.38.1+dfsg-1
ii  libglib2.0-0         2.58.3-2+deb10u2
ii  libgtk-3-common      3.24.5-1
ii  libharfbuzz0b        2.3.1-1
ii  libjson-glib-1.0-0   1.4.4-2
ii  libpango-1.0-0       1.42.4-7~deb10u1
ii  libpangocairo-1.0-0  1.42.4-7~deb10u1
ii  libpangoft2-1.0-0    1.42.4-7~deb10u1
ii  librest-0.7-0        0.8.1-1
ii  libsoup2.4-1         2.64.2-2
ii  libwayland-client0   1.16.0-1
ii  libwayland-cursor0   1.16.0-1
ii  libwayland-egl1      1.16.0-1
ii  libx11-6             2:1.6.7-1
ii  libxcomposite1       1:0.4.4-2
ii  libxcursor1          1:1.1.15-2
ii  libxdamage1          1:1.1.4-3+b3
ii  libxext6             2:1.3.3-1+b2
ii  libxfixes3           1:5.0.3-1
ii  libxi6               2:1.7.9-1
ii  libxinerama1         2:1.1.4-2
ii  libxkbcommon0        0.8.2-1
ii  libxml2              2.9.4+dfsg1-7+b3
ii  libxrandr2           2:1.5.1-1
ii  shared-mime-info     1.10-1

Versions of packages libgtk-3-0 recommends:
ii  libgtk-3-bin  3.24.5-1

Versions of packages libgtk-3-0 suggests:
ii  gvfs             1.38.1-5
ii  librsvg2-common  2.44.10-2.1

Versions of packages libgtk-3-0 is related to:
pn  appmenu-gtk3-module       <none>
pn  fcitx-frontend-gtk3       <none>
pn  gcin-gtk3-immodule        <none>
pn  gtk-vector-screenshot     <none>
pn  gtk3-engines-xfce         <none>
pn  gtk3-im-libthai           <none>
pn  hime-gtk3-immodule        <none>
ii  ibus-gtk3                 1.5.19-4+deb10u1
pn  imhangul-gtk3             <none>
ii  libcanberra-gtk3-module   0.30-7
pn  libcaribou-gtk3-module    <none>
ii  libgtk3-nocsd0            3-1
pn  maliit-inputcontext-gtk3  <none>
pn  packagekit-gtk3-module    <none>
pn  scim-gtk-immodule         <none>
pn  topmenu-gtk3              <none>
pn  uim-gtk3                  <none>
pn  uim-gtk3-immodule         <none>

-- debconf-show failed



More information about the pkg-gnome-maintainers mailing list