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

From: Eijiro Sumii <[email-masked]>
Date: Tue, 30 Jul 2019 13:30:00 +0900

On Tue, Jul 30, 2019 at 12:16 AM martin rudalics <[email-masked]> wrote:
> Can you mark text with the mouse?

No, I cannot.

> Does the bug happen only when the
> entire frame is positioned to the right of 3840

Yes, that's the case.

> or do you see it with
> a frame starting before 3840 but extending to the right of the display
> as well?

This situation does *not* exhibit the bug.

> If you want to debug mouse clicks it should suffice to set a break
> point with gdb at the top of the body below the lines
>
>      case ButtonRelease:
>      case ButtonPress:
>
> of xterm.c (in Emacs 25 they are at line 8499 here) and look whether
> it triggers.  If it triggers, then the call of x_window_to_frame in
>
>          f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
>              : x_window_to_frame (dpyinfo, event->xbutton.window));
>
> should give us some preliminary information.

Thanks!  I built both Emacs 25.1 and 26.2 (latest release) from the
sources, and confirmed that *both* exhibits the same problem in my
environment.
I run gdb for the latter (Emacs 26.2) and the values of *dpyinfo and
event->xbutton at that code point (line 8848) are:

When the problem occurs:

(gdb) p *dpyinfo
$5 = {next = 0x0, terminal = 0x2c955d0, display = 0x2cae000, connection =
5, name_list_element = 19285939, reference_count = 1, screen = 0x2cac5b0,
  resx = 144, resy = 144, visual = 0x2cac640, cmap = 32, n_planes = 24,
grabbed = 0, icon_bitmap_id = -2, root_window = 51, client_leader_window =
0,
  vertical_scroll_bar_cursor = 25165834, horizontal_scroll_bar_cursor =
25165838, invisible_cursor = 25165843,
  toggle_visible_pointer = 0x4becb0 <x_toggle_visible_pointer>, xg_cursor =
0x2dfbcc0, xrdb = 0x2e068f0, smallest_char_width = 13,
  smallest_font_height = 25, scratch_cursor_gc = 0x34752e0, mouse_highlight
= {mouse_face_beg_row = -1, mouse_face_beg_col = -1, mouse_face_beg_x = 0,
    mouse_face_end_row = -1, mouse_face_end_col = -1, mouse_face_end_x = 0,
mouse_face_window = 0, mouse_face_face_id = 0, mouse_face_overlay = 0,
    mouse_face_mouse_frame = 0x1385c30 <bss_sbrk_buffer+7883952>,
mouse_face_mouse_x = 475, mouse_face_mouse_y = 151, mouse_face_past_end =
false,
    mouse_face_defer = false, mouse_face_hidden = false}, x_id = 1,
x_id_name = 0x2c34510 "emacs@LAPTOP-0TO7HGG8", n_fonts = 4, bitmaps = 0x0,
  bitmaps_size = 0, bitmaps_last = 0, meta_mod_mask = 8, shift_lock_mask =
0, alt_mod_mask = 0, super_mod_mask = 0, hyper_mod_mask = 0,
  Xatom_wm_protocols = 125, Xatom_wm_take_focus = 127,
Xatom_wm_save_yourself = 300, Xatom_wm_delete_window = 126,
Xatom_wm_change_state = 123,
  Xatom_wm_configure_denied = 301, Xatom_wm_window_moved = 302,
Xatom_wm_client_leader = 178, Xatom_editres = 303, Xatom_CLIPBOARD = 133,
  Xatom_TIMESTAMP = 304, Xatom_TEXT = 129, Xatom_DELETE = 305,
Xatom_COMPOUND_TEXT = 128, Xatom_UTF8_STRING = 135, Xatom_MULTIPLE = 306,
  Xatom_INCR = 307, Xatom_EMACS_TMP = 308, Xatom_TARGETS = 132, Xatom_NULL
= 309, Xatom_ATOM = 4, Xatom_ATOM_PAIR = 310, Xatom_CLIPBOARD_MANAGER = 311,
  Xatom_PIXEL_SIZE = 94, Xatom_AVERAGE_WIDTH = 98,
Xatom_MULE_BASELINE_OFFSET = 313, Xatom_MULE_RELATIVE_COMPOSE = 314,
Xatom_MULE_DEFAULT_ASCENT = 315,
  Xatom_DONE = 316, Xatom_PAGE = 317, Xatom_Scrollbar = 318,
Xatom_Horizontal_Scrollbar = 319, Xatom_XEMBED = 320, Xatom_XEMBED_INFO =
312,
  x_focus_frame = 0x1385c30 <bss_sbrk_buffer+7883952>, x_focus_event_frame
= 0x1385c30 <bss_sbrk_buffer+7883952>,
  x_highlight_frame = 0x1385c30 <bss_sbrk_buffer+7883952>,
x_pending_autoraise_frame = 0x0, last_mouse_frame = 0x0,
last_mouse_glyph_frame = 0x0,
  last_mouse_motion_frame = 0x1385c30 <bss_sbrk_buffer+7883952>,
last_mouse_scroll_bar = 0x0, last_user_time = 1091249789,
last_mouse_motion_x = 475,
  last_mouse_motion_y = 170, last_mouse_glyph = {x = 463, y = 150, width =
13, height = 25}, last_mouse_movement_time = 1091249693, gray = 25165839,
  xim = 0x2e445a0, xim_styles = 0x2cbb770, xim_callback_data = 0x2e39040,
color_names = 0x2df2920, color_cells = 0x0, ncolor_cells = 0, red_bits = 8,
  blue_bits = 8, green_bits = 8, red_offset = 16, blue_offset = 0,
green_offset = 8, wm_type = X_WMTYPE_UNKNOWN, x_dnd_atoms = 0x2e85520,
  x_dnd_atoms_size = 8, x_dnd_atoms_length = 6, Xatom_net_supported = 321,
Xatom_net_supporting_wm_check = 322, net_supported_atoms = 0x0,
  nr_net_supported_atoms = 0, net_supported_window = 0,
Xatom_net_window_type = 279, Xatom_net_window_type_tooltip = 287,
Xatom_net_active_window = 256,
  Xatom_net_wm_state = 266, Xatom_net_wm_state_fullscreen = 269,
Xatom_net_wm_state_maximized_horz = 273, Xatom_net_wm_state_maximized_vert
= 272,
  Xatom_net_wm_state_sticky = 276, Xatom_net_wm_state_above = 267,
Xatom_net_wm_state_below = 268, Xatom_net_wm_state_hidden = 270,
  Xatom_net_wm_state_skip_taskbar = 274, Xatom_net_frame_extents = 258,
Xatom_net_current_desktop = 257, Xatom_net_workarea = 324,
  Xatom_xsettings_sel = 295, Xatom_xsettings_prop = 326,
Xatom_xsettings_mgr = 327, xsettings_window = 0, Xatom_net_wm_name = 263,
  Xatom_net_wm_icon_name = 262, Xatom_net_wm_window_opacity = 323,
Xatom_SM_CLIENT_ID = 325, xrandr_major_version = 0, xrandr_minor_version =
0,
  xcb_connection = 0x2caf250, supports_xdbe = false}
(gdb) p event->xbutton
$6 = {type = 4, serial = 5265, send_event = 0, display = 0x2cae000, window
= 25166151, root = 51, subwindow = 0, time = 1091249789, x = 475, y = 170,
  x_root = 4326, y_root = 281, state = 0, button = 1, same_screen = 1}

When no problem occurs:

(gdb) p event->xbutton
$8 = {next = 0x0, terminal = 0x2c955d0, display = 0x2cae000, connection =
5, name_list_element = 19285939, reference_count = 1, screen = 0x2cac5b0,
  resx = 144, resy = 144, visual = 0x2cac640, cmap = 32, n_planes = 24,
grabbed = 0, icon_bitmap_id = -2, root_window = 51, client_leader_window =
0,
  vertical_scroll_bar_cursor = 25165834, horizontal_scroll_bar_cursor =
25165838, invisible_cursor = 25165843,
  toggle_visible_pointer = 0x4becb0 <x_toggle_visible_pointer>, xg_cursor =
0x2dfbcc0, xrdb = 0x2e068f0, smallest_char_width = 13,
  smallest_font_height = 25, scratch_cursor_gc = 0x34752e0, mouse_highlight
= {mouse_face_beg_row = -1, mouse_face_beg_col = -1, mouse_face_beg_x = 0,
    mouse_face_end_row = -1, mouse_face_end_col = -1, mouse_face_end_x = 0,
mouse_face_window = 0, mouse_face_face_id = 0, mouse_face_overlay = 0,
    mouse_face_mouse_frame = 0x1385c30 <bss_sbrk_buffer+7883952>,
mouse_face_mouse_x = 541, mouse_face_mouse_y = 118, mouse_face_past_end =
false,
    mouse_face_defer = false, mouse_face_hidden = false}, x_id = 1,
x_id_name = 0x2c34510 "emacs@LAPTOP-0TO7HGG8", n_fonts = 4, bitmaps = 0x0,
  bitmaps_size = 0, bitmaps_last = 0, meta_mod_mask = 8, shift_lock_mask =
0, alt_mod_mask = 0, super_mod_mask = 0, hyper_mod_mask = 0,
  Xatom_wm_protocols = 125, Xatom_wm_take_focus = 127,
Xatom_wm_save_yourself = 300, Xatom_wm_delete_window = 126,
Xatom_wm_change_state = 123,
  Xatom_wm_configure_denied = 301, Xatom_wm_window_moved = 302,
Xatom_wm_client_leader = 178, Xatom_editres = 303, Xatom_CLIPBOARD = 133,
  Xatom_TIMESTAMP = 304, Xatom_TEXT = 129, Xatom_DELETE = 305,
Xatom_COMPOUND_TEXT = 128, Xatom_UTF8_STRING = 135, Xatom_MULTIPLE = 306,
  Xatom_INCR = 307, Xatom_EMACS_TMP = 308, Xatom_TARGETS = 132, Xatom_NULL
= 309, Xatom_ATOM = 4, Xatom_ATOM_PAIR = 310, Xatom_CLIPBOARD_MANAGER = 311,
  Xatom_PIXEL_SIZE = 94, Xatom_AVERAGE_WIDTH = 98,
Xatom_MULE_BASELINE_OFFSET = 313, Xatom_MULE_RELATIVE_COMPOSE = 314,
Xatom_MULE_DEFAULT_ASCENT = 315,
  Xatom_DONE = 316, Xatom_PAGE = 317, Xatom_Scrollbar = 318,
Xatom_Horizontal_Scrollbar = 319, Xatom_XEMBED = 320, Xatom_XEMBED_INFO =
312,
  x_focus_frame = 0x1385c30 <bss_sbrk_buffer+7883952>, x_focus_event_frame
= 0x1385c30 <bss_sbrk_buffer+7883952>,
  x_highlight_frame = 0x1385c30 <bss_sbrk_buffer+7883952>,
x_pending_autoraise_frame = 0x0, last_mouse_frame = 0x0,
last_mouse_glyph_frame = 0x0,
  last_mouse_motion_frame = 0x1385c30 <bss_sbrk_buffer+7883952>,
last_mouse_scroll_bar = 0x0, last_user_time = 1091390837,
last_mouse_motion_x = 546,
  last_mouse_motion_y = 118, last_mouse_glyph = {x = 541, y = 100, width =
13, height = 25}, last_mouse_movement_time = 1091389269, gray = 25165839,
  xim = 0x2e445a0, xim_styles = 0x2cbb770, xim_callback_data = 0x2e39040,
color_names = 0x2df2920, color_cells = 0x0, ncolor_cells = 0, red_bits = 8,
  blue_bits = 8, green_bits = 8, red_offset = 16, blue_offset = 0,
green_offset = 8, wm_type = X_WMTYPE_UNKNOWN, x_dnd_atoms = 0x2e85520,
  x_dnd_atoms_size = 8, x_dnd_atoms_length = 6, Xatom_net_supported = 321,
Xatom_net_supporting_wm_check = 322, net_supported_atoms = 0x0,
  nr_net_supported_atoms = 0, net_supported_window = 0,
Xatom_net_window_type = 279, Xatom_net_window_type_tooltip = 287,
Xatom_net_active_window = 256,
  Xatom_net_wm_state = 266, Xatom_net_wm_state_fullscreen = 269,
Xatom_net_wm_state_maximized_horz = 273, Xatom_net_wm_state_maximized_vert
= 272,
  Xatom_net_wm_state_sticky = 276, Xatom_net_wm_state_above = 267,
Xatom_net_wm_state_below = 268, Xatom_net_wm_state_hidden = 270,
  Xatom_net_wm_state_skip_taskbar = 274, Xatom_net_frame_extents = 258,
Xatom_net_current_desktop = 257, Xatom_net_workarea = 324,
  Xatom_xsettings_sel = 295, Xatom_xsettings_prop = 326,
Xatom_xsettings_mgr = 327, xsettings_window = 0, Xatom_net_wm_name = 263,
  Xatom_net_wm_icon_name = 262, Xatom_net_wm_window_opacity = 323,
Xatom_SM_CLIENT_ID = 325, xrandr_major_version = 0, xrandr_minor_version =
0,
  xcb_connection = 0x2caf250, supports_xdbe = false}
$9 = {type = 4, serial = 9839, send_event = 0, display = 0x2cae000, window
= 25166151, root = 51, subwindow = 0, time = 1091390837, x = 546, y = 118,
  x_root = 2467, y_root = 229, state = 0, button = 1, same_screen = 1}

I haven't yet pursued further executions (I need to sit in front of the
second, 60-inch 4K display for this!), but will do (so, advice is welcome!).

        Eijiro