From: Po Lu Date: Tue, 8 Feb 2022 01:25:24 +0000 (+0800) Subject: Don't allow tooltips to be transient for override redirect windows X-Git-Tag: emacs-29.0.90~2445 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cdf7e2e02130d980c9e70f4d5a019b52d7914de6;p=emacs.git Don't allow tooltips to be transient for override redirect windows * src/xfns.c (Fx_show_tip): Delete WM_TRANSIENT_FOR if the child window is override-redirect. * src/xterm.c (x_term_init): Intern new atom. * src/xterm.h (struct x_display_info): New atom `Xatom_wm_transient_for'. --- diff --git a/src/xfns.c b/src/xfns.c index 7878ee62f5e..2fd9ad6b054 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -7788,6 +7788,7 @@ Text larger than the specified size is clipped. */) ptrdiff_t count_1; Lisp_Object window, size, tip_buf; Window child; + XWindowAttributes child_attrs; int dest_x_return, dest_y_return; AUTO_STRING (tip, " *tip*"); @@ -8028,11 +8029,24 @@ Text larger than the specified size is clipped. */) FRAME_DISPLAY_INFO (f)->root_window, root_x, root_y, &dest_x_return, &dest_y_return, &child)) - XSetTransientForHint (FRAME_X_DISPLAY (tip_f), - FRAME_X_WINDOW (tip_f), child); + { + /* But only if the child is not override-redirect, which can + happen if the pointer is above a menu. */ + + if (XGetWindowAttributes (FRAME_X_DISPLAY (f), + child, &child_attrs) + || child_attrs.override_redirect) + XDeleteProperty (FRAME_X_DISPLAY (tip_f), + FRAME_X_WINDOW (tip_f), + FRAME_DISPLAY_INFO (tip_f)->Xatom_wm_transient_for); + else + XSetTransientForHint (FRAME_X_DISPLAY (tip_f), + FRAME_X_WINDOW (tip_f), child); + } else - XSetTransientForHint (FRAME_X_DISPLAY (tip_f), - FRAME_X_WINDOW (tip_f), None); + XDeleteProperty (FRAME_X_DISPLAY (tip_f), + FRAME_X_WINDOW (tip_f), + FRAME_DISPLAY_INFO (tip_f)->Xatom_wm_transient_for); #ifndef USE_XCB XMoveResizeWindow (FRAME_X_DISPLAY (tip_f), FRAME_X_WINDOW (tip_f), diff --git a/src/xterm.c b/src/xterm.c index 38f181e5df8..b49441ddb79 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -15984,6 +15984,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) ATOM_REFS_INIT ("WM_CONFIGURE_DENIED", Xatom_wm_configure_denied) ATOM_REFS_INIT ("WM_MOVED", Xatom_wm_window_moved) ATOM_REFS_INIT ("WM_CLIENT_LEADER", Xatom_wm_client_leader) + ATOM_REFS_INIT ("WM_TRANSIENT_FOR", Xatom_wm_transient_for) ATOM_REFS_INIT ("Editres", Xatom_editres) ATOM_REFS_INIT ("CLIPBOARD", Xatom_CLIPBOARD) ATOM_REFS_INIT ("TIMESTAMP", Xatom_TIMESTAMP) diff --git a/src/xterm.h b/src/xterm.h index 63956fd6434..854d87c83ce 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -364,6 +364,8 @@ struct x_display_info Atom Xatom_wm_configure_denied; /* When our config request is denied */ Atom Xatom_wm_window_moved; /* When the WM moves us. */ Atom Xatom_wm_client_leader; /* Id of client leader window. */ + Atom Xatom_wm_transient_for; /* Id of whatever window we are + transient for. */ /* EditRes protocol */ Atom Xatom_editres;