Root win

classic Classic list List threaded Threaded
7 messages Options
jdp
Reply | Threaded
Open this post in threaded view
|

Root win

jdp
Hi,

Too bad it's not possible to draw into the root window -- desktop background.  As for a wallpaper.

Cheers,
John
Reply | Threaded
Open this post in threaded view
|

Re: Root win

Wade Walker
Administrator
Are there any programs that do that well? I guess you could write a native C program that traps the window function of the desktop, intercepts its WM_PAINT messages, and writes into its device context. But it seems like it would be hard to composite properly with a translucent window theme like in Vista or Windows 7
jdp
Reply | Threaded
Open this post in threaded view
|

Re: Root win

jdp
Well, in X11 its window ID zero AFAIK.  From looking through NEWT/X11 I'd guess that each port may make use of the root window.  And as well, I have no idea whether "drawing to the root window" has the same meaning everywhere (as "drawing to the desktop background").

If there was a way to do it in jogl, I'd use it.  But I've got too many open projects to hack it together just for myself.

Cheers,
John

Reply | Threaded
Open this post in threaded view
|

Re: Root win

Demoscene Passivist
Administrator
In reply to this post by Wade Walker
>Are there any programs that do that well?

"Bump Top" e.g. does/did that under Windows. Google acquired it recently, so its no longer available for free anymore :( ...

http://www.bumptop.com/
http://www.youtube.com/watch?v=M0ODskdEPnQ

Reply | Threaded
Open this post in threaded view
|

Re: Root win

Wade Walker
Administrator
Wow, Bump Top looks cool! Hopefully Google has them working on putting that ability into the Android OS.
Reply | Threaded
Open this post in threaded view
|

Re: Root win

Sven Gothel
Administrator
In reply to this post by jdp
On Sunday, January 09, 2011 00:46:29 jdp [via jogamp] wrote:
>
> Hi,
>
> Too bad it's not possible to draw into the root window -- desktop
> background.  As for a wallpaper.

Understood.

well, what one usually does is to 'replace' or draw to the root window,
using the windowmanager - as mentioned in this thread here.

you would need to use the root window as a parent,
and/or use it directly.

The latter might be restricted by your windowmanager (X11 and Win32..),
the former might need special attention/communication with the windowmanager
like replace desktop window .. etc.
I believe the solution is the former, ie use the root window as parent
and utilize some 'magic' windowmanager atom's and render transparent.

If you figure these things out for at least one platform,
sure we can add it NEWT.

Lately we added proper fullscreen window support which involves the above
mentioned windowmanager attention as well (for both, X11 and Win32).

Next on the NEWT feature list is transparency using the compositioning windowmanager,
ie Win7 and KDE/Gnome ..

~Sven
jdp
Reply | Threaded
Open this post in threaded view
|

Re: Root win

jdp
well, i can present this bit of a review for X11 a classic example is xearth. it demonstrates what the wm_spec calls virtual roots. from xearth//x11.c...
/* 
 * (taken nearly verbatim from the june 1993 comp.windows.x FAQ, item 148)
 */
static Window GetVRoot(dpy)
     Display *dpy;
{
  int          i;
  Window       rootReturn, parentReturn, *children;
  unsigned int numChildren;
  Atom         __SWM_VROOT = None;
  Window       rslt = root;

  __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
  XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren);
  for (i=0; i<numChildren; i++)
  {
    Atom          actual_type;
    int           actual_format;
    unsigned long nitems, bytesafter;
    Window       *newRoot = NULL;

    /* item 148 in the FAQ neglects to mention that there is a race
     * condition here; consider a child of the root window that
     * existed when XQueryTree() was called, but has disappeared
     * before XGetWindowProperty() gets called for that window ...
     */
    if ((XGetWindowProperty(dpy, children[i], __SWM_VROOT, 0, 1,
                            False, XA_WINDOW, &actual_type,
                            &actual_format, &nitems, &bytesafter,
                            (unsigned char **) &newRoot) == Success)
        && newRoot)
    {
      rslt = *newRoot;
      break;
    }
  }

  /* item 148 in the FAQ also neglects to mention that we probably
   * want to free the list of children after we're done with it ...
   */
  XFree((void *) children);

  return rslt;
}

it's using a funny atom, __SWM_VROOT that differs from the expected _NET_VIRTUAL_ROOTS. however, we see the same elsewhere as well
  //www.mail-archive.com/xorg-devel@lists.x.org/msg06346.html
from vroot.h...

static Window VirtualRootWindowOfScreen(Screen *screen)
{
       static Screen *save_screen = (Screen *)0;
       static Window root = (Window)0;

       if (screen != save_screen) {
               Display *dpy = DisplayOfScreen(screen);
               Atom __SWM_VROOT = None;
               int i;
               Window rootReturn, parentReturn, *children;
               unsigned int numChildren;

    /* first check for a hex or decimal window ID in the environment */
    const char *xss_id = getenv("XSCREENSAVER_WINDOW");
    if (xss_id && *xss_id) {
      unsigned long id = 0;
      char c;
      if (1 == sscanf (xss_id, " 0x%lx %c", &id, &c) ||
          1 == sscanf (xss_id, " %lu %c",   &id, &c)) {
        root = (Window) id;
        save_screen = screen;
        return root;
      }
    }

               root = RootWindowOfScreen(screen);

               /* go look for a virtual root */
               __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
               if (XQueryTree(dpy, root, &rootReturn, &parentReturn,
                                &children, &numChildren)) {
                       for (i = 0; i < numChildren; i++) {
                               Atom actual_type;
                               int actual_format;
                               unsigned long nitems, bytesafter;
                               unsigned char *newRoot = 0;

                               if (XGetWindowProperty(dpy, children[i],
                                       __SWM_VROOT, 0, 1, False, XA_WINDOW,
                                       &actual_type, &actual_format,
                                       &nitems, &bytesafter,
                                       &newRoot) == Success
                                   && newRoot) {
                                   root = *((Window *) newRoot);
                                   break;
                               }
                       }
                       if (children)
                               XFree((char *)children);
               }

               save_screen = screen;
       }

       return root;
}