Subject: bug#36779: 25.1; mouse click not recognized for frames with large left position

From: Eijiro Sumii <[email-masked]>
Date: Wed, 7 Aug 2019 12:07:00 +0900

After more investigations (with Emacs 26.2 and GTK 3.22.11 - the
latter is old but easier to compile in my environment), it turned out
that the x-coordinates given to (GTK and) Emacs from the X server are
sometimes (though not always) incorrect and negative:

Thread 1 "emacs" hit Breakpoint 1, handle_one_xevent (dpyinfo=0x2da2c60,
event=0x7ffffffecf40, finish=0xc42d8c <current_finish>,
hold_quit=0x7ffffffed210)    at xterm.c:8838
8838            bool tool_bar_p = false;
(gdb) display event->xbutton
1: event->xbutton = {type = 4, serial = 3674, send_event = 0, display =
0x2d6d000, window = 12583239, root = 51, subwindow = 0, time = 1342862408,
  x = -601, y = 206, x_root = 1919, y_root = 372, state = 0, button = 1,
same_screen = 1}
(gdb) up
#1  0x0000000000519853 in event_handler_gdk (gxev=0x7ffffffecf40,
ev=0x2d87b50, data=0x0) at xterm.c:7594
7594          += handle_one_xevent (dpyinfo, xev, &current_finish,
(gdb)
#2  0x00007ffffdb85dc8 in gdk_event_apply_filters (xevent=0x7ffffffecf40,
event=0x2d87b50, window=0x0) at gdkeventsource.c:79
79          result = filter->function (xevent, event, filter->data);
(gdb)
#3  0x00007ffffdb861ba in gdk_event_source_translate_event
(event_source=0x2d87780, xevent=0x7ffffffecf40) at gdkeventsource.c:198
198          result = gdk_event_apply_filters (xevent, event, NULL);
(gdb)
#4  0x00007ffffdb86543 in _gdk_x11_display_queue_events (display=0x2d79100)
at gdkeventsource.c:341
341          event = gdk_event_source_translate_event (event_source,
&xevent);
(gdb)
#5  0x00007ffffdb3846a in gdk_display_get_event (display=0x2d79100) at
gdkdisplay.c:438
438        GDK_DISPLAY_GET_CLASS (display)->queue_events (display);
(gdb) down
#4  0x00007ffffdb86543 in _gdk_x11_display_queue_events (display=0x2d79100)
at gdkeventsource.c:341
341          event = gdk_event_source_translate_event (event_source,
&xevent);
(gdb) display xevent->xbutton
2: xevent->xbutton = {type = 4, serial = 3674, send_event = 0, display =
0x2d6d000, window = 12583239, root = 51, subwindow = 0, time = 1342862408,
  x = -601, y = 206, x_root = 1919, y_root = 372, state = 0, button = 1,
same_screen = 1}

According to the user support, this is a limitation of the
(proprietary) X server when multiple monitors and resolutions are
switched after it has started.  Why this happens only to Emacs (not
other X clients or GTK applications) is still a mystery to me, but I
think we can close this issue.  Sorry and _many_ thanks for all the
help!