| Ticket UUID: | 22172f373225a982586f8aa4ec1a69d446a0fbfb | |||
| Title: | "raise" command fails on recent linux | |||
| Type: | Bug | Version: | 8.5.18 | |
| Submitter: | marty.sereno | Created on: | 2018-12-03 23:11:41 | |
| Subsystem: | 67. Unix Window Operations | Assigned To: | jan.nijtmans | |
| Priority: | 5 Medium | Severity: | Important | |
| Status: | Closed | Last Modified: | 2026-10-09 15:22:44 | |
| Resolution: | Fixed | Closed By: | jan.nijtmans | |
| Closed on: | 2026-10-09 15:22:44 | |||
| Description: |
On a default CentOS 7.5 install, after a default compile of tk8.5.18, the command "raise ." fails, using the default Gnome desktop. It generates a non-informative upper right pop-up with only two lines, for example:
wish
wish is ready
This is likely due to Linux window managers ignoring XRaiseWindow (for the last decade).
Here is an example of a tiny wrapper for XRaiseWindow that solves this problem on CentOS 7 and many other linux distributions, by sending a message to the window manager, whoever that is. Perhaps it could be adapted to fix the tk "raise" command.
#include <X11/Xlib.h>
static Display *display;
static Window glxwindow;
void raise_window(void)
{
#ifdef Linux /* metacity "focus stealing prevention" intercepts XRaiseWindow */
XEvent xev;
Window rootwindow;
xev.type = ClientMessage;
xev.xclient.display = display;
xev.xclient.window = glxwindow;
xev.xclient.message_type = XInternAtom(display,"_NET_ACTIVE_WINDOW",0);
xev.xclient.format = 32;
xev.xclient.data.l[0] = 2L;
xev.xclient.data.l[1] = CurrentTime;
rootwindow = XDefaultRootWindow(display);
XSendEvent(display, rootwindow, 0,
SubstructureNotifyMask | SubstructureRedirectMask, &xev);
#endif
XRaiseWindow(display, glxwindow);
XFlush(display);
}
| |||
| User Comments: |
jan.nijtmans added on 2026-10-09 15:22:44:
Looks good to me. So merged to [341051203d21523b|trunk] now, and also to core-9-0-branch and core-8-6-branch. Just re-open if something turns out to be wrong with it. marty.sereno added on 2026-09-20 02:56:50: thx! (and for the explanation) cheers, marty serhiy.storchaka added on 2026-09-19 20:33:50: raise now also sends the EWMH _NET_RESTACK_WINDOW request, which KWin and Mutter honor for a window which is not active (they ignore the plain XReconfigureWMWindow request); tested with KWin 6.6. It restacks without activating the window, as raise is documented. Fixed in [753272357c] (branch x11-raise-ewmh). serhiy.storchaka added on 2026-09-19 20:18:09: Your code sends _NET_ACTIVE_WINDOW, which I tested too. Current mutter and KWin honour it (as well as _NET_RESTACK_WINDOW, which raises without activating) only when the user has not interacted with another window more recently; otherwise they only mark the window as demanding attention (the "wish is ready" notification). That is the window managers' focus stealing prevention, which no client request can override. Tk could still send _NET_RESTACK_WINDOW in addition to XReconfigureWMWindow, so that raise works whenever the window manager allows it; I will look into that. marty.sereno added on 2026-09-19 18:09:03: "nothing can be done on the Tk side" But the code above/below is on the tk side (?) serhiy.storchaka added on 2026-09-18 19:31:21: Reproduced with mutter 50 and KWin 6.6. The behavior is controlled by the window manager (focus stealing prevention), nothing can be done on the Tk side. See also [ee3361a3ad]. marty.sereno added on 2018-12-04 17:03:40: Sorry for the multiple messages. One more data point: if the code messaging the window manager is inserted into: ./tk8.5.18/unix/tkUnixWm.c:TkWmRestackToplevel() just *before* the call to: XReconfigureWMWindow() (rather than after the call, as described above), then the annoying Gnome popup doesn't appear. marty.sereno added on 2018-12-04 16:49:27: If the following test code:
#if 1
XEvent xev;
Window rootwindow;
xev.type = ClientMessage;
xev.xclient.display = winPtr->display;
xev.xclient.window = wrapperPtr->window;
xev.xclient.message_type =
XInternAtom(winPtr->display,"_NET_ACTIVE_WINDOW",0);
xev.xclient.format = 32;
xev.xclient.data.l[0] = 2L;
xev.xclient.data.l[1] = CurrentTime;
rootwindow = XDefaultRootWindow(winPtr->display);
XSendEvent(winPtr->display, rootwindow, 0,
SubstructureNotifyMask | SubstructureRedirectMask, &xev);
#endif
is added to the very bottom of:
./tk8.5.18/unix/tkUnixWm.c:TkWmRestackToplevel()
after an otherwise default compile of tk8.5.18 on CentOS 7.5, tk "raise" works again. The annoying, large, almost empty, upper right, Gnome popup window containing only:
wish
wish is ready
still appears, but unlike the original case where "raise" was failing, now instantly disappears.
| |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki