Setting properties on every mapped client window - Xwindows

This is a discussion on Setting properties on every mapped client window - Xwindows ; Hello, I'm trying to set the _NET_WM_DESKTOP property on every client window as it is mapped without any help from the window manager. I've Selected for SubstructureNotifyMask on the root window and I reliably find out about each window as ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Setting properties on every mapped client window

  1. Setting properties on every mapped client window

    Hello,

    I'm trying to set the _NET_WM_DESKTOP property on every client window as
    it is mapped without any help from the window manager. I've Selected
    for SubstructureNotifyMask on the root window and I reliably find out
    about each window as the WM maps it. But I only hear about the WM's
    frame windows -- I need the client's window that the WM is framing. So
    when I get a MapNotify event "e" I do this:

    w = XmuClientWindow(Disp, e->window);
    if (w != e->window) {
    SET_WIN_DESKTOP( w, currentWS );
    } else {

    }

    Unfortunately, this fails pretty frequently. I am unable to figure out
    why it fails when it fails, but I'm guessing the MapNotify gets
    delivered to me before the client window itself has been mapped, or
    maybe before the client window sets its WM_STATE atom, which is what
    XmuClientWindow looks for. It often fails for the first window
    displayed when X11 starts running.

    Can anybody suggest a reliable method for finding the client window of a
    newly-mapped WM window? It's ok to assume the window is fairly
    well-behaved (e.g. it's not going to be unmapped before you can find it).

    Thanks,
    -n8

    P.S. Why am I doing this? Because I'm on OS X, working to integrate
    Desktop Manager, a native virtual desktop system, with X11 apps.
    Apple's window manager, quartzwm, is closed-source and not
    virtual-desktop-aware.

  2. Re: Setting properties on every mapped client window

    Nathaniel Gray wrote:
    >Hello,
    >
    >I'm trying to set the _NET_WM_DESKTOP property on every client window as
    >it is mapped without any help from the window manager. I've Selected
    >for SubstructureNotifyMask on the root window and I reliably find out
    >about each window as the WM maps it. But I only hear about the WM's
    >frame windows -- I need the client's window that the WM is framing. So
    >when I get a MapNotify event "e" I do this:
    >
    > w = XmuClientWindow(Disp, e->window);
    > if (w != e->window) {
    > SET_WIN_DESKTOP( w, currentWS );
    > } else {
    >
    > }
    >
    >Unfortunately, this fails pretty frequently. I am unable to figure out
    >why it fails when it fails, but I'm guessing the MapNotify gets
    >delivered to me before the client window itself has been mapped, or
    >maybe before the client window sets its WM_STATE atom, which is what
    >XmuClientWindow looks for. It often fails for the first window
    >displayed when X11 starts running.
    >
    >Can anybody suggest a reliable method for finding the client window of a
    >newly-mapped WM window? It's ok to assume the window is fairly
    >well-behaved (e.g. it's not going to be unmapped before you can find it).
    >
    >Thanks,
    >-n8
    >
    >P.S. Why am I doing this? Because I'm on OS X, working to integrate
    >Desktop Manager, a native virtual desktop system, with X11 apps.
    >Apple's window manager, quartzwm, is closed-source and not
    >virtual-desktop-aware.


    The sequence of events is something like this:

    client creates window (in withdrawn state)
    client adds properties
    client maps window
    wm catches map request
    wm creates frame window
    wm reparents client window
    wm maps both frame and client windows
    wm adds WM_STATE property, meaning client has fully entered normal state

    I think you can see the race. I would suggest logic as follows:

    receive reparent notify on root window
    XGrabServer
    XGetWindowAttributes on reparented window
    -> if this succeeds, add _NET_WM_DESKTOP property
    -> if it fails, client window has disappeared
    XUngrabServer


  3. Re: Setting properties on every mapped client window

    Kip Rugger wrote:
    > The sequence of events is something like this:
    >
    > client creates window (in withdrawn state)
    > client adds properties
    > client maps window
    > wm catches map request
    > wm creates frame window
    > wm reparents client window
    > wm maps both frame and client windows
    > wm adds WM_STATE property, meaning client has fully entered normal state
    >
    > I think you can see the race. I would suggest logic as follows:
    >
    > receive reparent notify on root window
    > XGrabServer
    > XGetWindowAttributes on reparented window
    > -> if this succeeds, add _NET_WM_DESKTOP property
    > -> if it fails, client window has disappeared
    > XUngrabServer


    Thanks! This works really well.

    Cheers,
    -n8


+ Reply to Thread