[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: kdebase: netscape-remote command does not work on kde21 desktop



Ernst Kloppenburg <ernst.kloppenburg@gmx.de> writes:

> > 
> > When I call 'netscape-remote' directly, I get the following error
> > message: 'root window has no children on display :0'
> > 
> > This can be verified with 'xwininfo -children -root' which gives a
> > very short output in this case. With fvwm running the output of the
> > command gives a lot of children windows.

In fact in kde-2.1 the root window is "overloaded" by a kde specific
root window (done by kdesktop). The solution is to use the following
tips (given to me by Martin Schenk) :

/******************************************************

   XQueryTree to make netscape / xquote work with KDE 


compile as a dynamic library and use LD_PRELOAD to
replace the original XQueryTree

*******************************************************/
#include <X11/X.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <dlfcn.h>

typedef Status (*XQT) (Display*, Window, Window*, Window*, Window**, unsigned int *);

static Window vroot;
static XQT xqt=NULL;
static Screen *save_screen = (Screen *)0;


Status XQueryTree(dpy, w, root_return, parent_return,
       children_return, nchildren_return)
       Display *dpy;
       Window w;
       Window *root_return;
       Window *parent_return;
       Window **children_return;
       unsigned int *nchildren_return;
{
	Screen *scr=DefaultScreenOfDisplay(dpy);
	Status s;
	if (xqt==NULL) /* Initialize  xqt */
	{
		xqt=dlsym(RTLD_NEXT, "XQueryTree");
		if (!xqt) { printf("no XQueryTree ?\n"); exit(1); }
	}
	if (save_screen != scr)	/* initialize vroot */
	{
		Atom __SWM_VROOT = None;
		vroot=RootWindowOfScreen(scr);
		__SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
		if (xqt(dpy, vroot, root_return, parent_return, children_return,
			nchildren_return))
		{
			unsigned int i;
                        for (i = 0; i < *nchildren_return; i++) {
                                Atom actual_type;
                                int actual_format;
                                unsigned long nitems, bytesafter;
                                Window *newRoot = (Window *)0;
 
                                if (XGetWindowProperty(dpy,
					(*children_return)[i],
                                        __SWM_VROOT, 0, 1, False, XA_WINDOW,
                                        &actual_type, &actual_format,
                                        &nitems, &bytesafter,
                                        (unsigned char **) &newRoot) == Success
                                    && newRoot) {
                                    vroot = *newRoot;
                                    break;
                                }
                        }
                        if (*children_return)
                                XFree((char *)*children_return);
		}
		save_screen=scr;
	}
	s=xqt(dpy,w,root_return,parent_return,children_return,
		nchildren_return);
	if ((w==vroot) && (! (*children_return && *nchildren_return)) &&
		 (vroot!=*root_return))
	{	/* we want real root window */
		s=xqt(dpy,*root_return,root_return,parent_return,
			children_return, nchildren_return);
	}
	return s;
}
---------------------------------------------
To compile the code, the following should work:
	gcc -fPIC -c -I/usr/X11R6/include xq.c
	gcc -o xq.so -shared xq.o

To use it just set LD_PRELOAD to the path:
	export LD_PRELOAD=/usr/local/lib/xq.so

If you just want to have netscape use it, put this "export LD_PRELOAD..." 
in the shellscript that starts netscape (typically /usr/X11R6/bin/netscape 
just is a script).
---------------------------------------------

Now I am using kde-2.2 beta, and the problem is solved. Note that this
tips can be used for any program that needs the root window.

HTH.

-- 
Julien Gilles.

Reply to: