Tk Source Code

View Ticket
Login
2018-12-04
17:03 Ticket [22172f3732] "raise" command fails on recent linux status still Open with 3 other changes artifact: dcebd2dd7f user: marty.sereno
16:49 Ticket [22172f3732]: 3 changes artifact: fdaf79dc16 user: marty.sereno
2018-12-03
23:11 New ticket [22172f3732]. artifact: 2a5adabf21 user: marty.sereno

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: 75. wish Assigned To: nobody
Priority: 5 Medium Severity: Important
Status: Open Last Modified: 2018-12-04 17:03:40
Resolution: None Closed By: nobody
    Closed on:
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: 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.