XSetWMName fails to set the window title

Glynn Clements glynn at gclements.plus.com
Wed Jun 13 07:50:04 PDT 2007


Jon Kristensen wrote:

> tis 2007-06-12 klockan 16:33 +0100 skrev Glynn Clements: 
> > Jon Kristensen wrote:
> > 
> > > I have a little problem using the X11 library, and I thought there might
> > > be someone on this list that wanted to help me out a bit. If this mail
> > > is off-topic or something, then I'm sorry.
> > > 
> > > I want to set the window title, and below follows how I try to do it. I
> > > know that the window handle unsigned long is correct, becuase I've
> > > converted the number to hex and compared it to the output of `xwininfo'.
> > > 
> > > I get no errors, the window title just doesn't get set.
> > > 
> > > Any help would be greatly appreciated! :o)
> > 
> > > // Code for GNU systems goes here. We open the X11 display.
> > > static Display *display = XOpenDisplay (NULL);
> > 
> > You should use the Display* which is associated with the window. A
> > different Display* (even if it happens to refer to the same X server)
> > may not work, as the X server will see two different clients: one owns
> > the window, the other is calling XSetWMName(). The fact that both
> > connections belong to the same process doesn't count (X may not even
> > be aware of this, particularly if TCP connections are used).
> > 
> > Although I'm not certain that this is the cause of your problem, it
> > could be, and I don't see anything else wrong with the code.
> 
> Thank you so very much for your reply, I've been trying to solve it on
> my own but havn't succeded! It means a lot!
> 
> I have two questions:
> 
> 1) How do I get the Display* that is associated with the window, like
> you describe?

That depends upon the toolkit which you're using. I note that you get
the Window with:

        this->window->getCustomAttribute("WINDOW", &windowHandle);

Maybe there's something similar for the Display*? Or maybe it's a
global variable.

Also, something I overlooked last time: are you sure that you're using
the correct window (i.e. the top-level window which the application
created, not the WM's frame)? Use "xprop -id ..." to list the
properties; if it's the correct window, it should have the various
WM_* properties.

> 2) If this isn't the problem, how would you go about isolating the
> problem? XSetWMName() returns void so I can't check for info there. I
> call XSetWMName 15 times and tried recording the X events using Xnee*
> but since I only got event ids and other numbers, it didn't give me very
> much. The output from Xnee follows.
> 
> (Note that request range 18-20 covers X_ChangeProperty, X_DeleteProperty
> and X_GetProperty.)

I haven't used Xnee, but maybe this option helps:

	# Human printout of X11 data (instead of Xnee format)
	# human-printout  

Failing that, try using xmon.

-- 
Glynn Clements <glynn at gclements.plus.com>



More information about the xorg mailing list