From 1ce0d8d9efee60d7bc6d4b81c7e7d6be508c0b7b Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 13 Jun 2022 09:42:12 +0800 Subject: [PATCH] Keep tooltip position in sync with monitor changes * src/xterm.c (x_dnd_update_tooltip_now): New function. (x_monitors_changed_cb): (handle_one_xevent): Call that function on monitor change. --- src/xterm.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/xterm.c b/src/xterm.c index b1e877566fa..4bc4c53eea2 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -15322,6 +15322,31 @@ x_dnd_update_tooltip_position (int root_x, int root_y) } } +static void +x_dnd_update_tooltip_now (void) +{ + int root_x, root_y; + Window root, child; + int win_x, win_y; + unsigned int mask; + Bool rc; + struct x_display_info *dpyinfo; + + if (!x_dnd_in_progress || !x_dnd_update_tooltip) + return; + + dpyinfo = FRAME_DISPLAY_INFO (XFRAME (x_dnd_frame)); + + rc = XQueryPointer (dpyinfo->display, + dpyinfo->root_window, + &root, &child, &root_x, + &root_y, &win_x, &win_y, + &mask); + + if (rc) + x_dnd_update_tooltip_position (root_x, root_y); +} + /* Get the window underneath the pointer, see if it moved, and update the DND state accordingly. */ static void @@ -15702,6 +15727,8 @@ x_monitors_changed_cb (GdkScreen *gscr, gpointer user_data) if (x_dnd_in_progress && x_dnd_update_tooltip) x_dnd_monitors = current_monitors; + + x_dnd_update_tooltip_now (); } #endif @@ -21520,6 +21547,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, if (x_dnd_in_progress && x_dnd_update_tooltip) x_dnd_monitors = current_monitors; + + x_dnd_update_tooltip_now (); } #endif OTHER: -- 2.39.2