XSetWMName fails to set the window title
Jon Kristensen
jon.kristensen at dedikerad.se
Mon Jun 11 20:46:52 PDT 2007
Hello X.Org hackers!
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)
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <GL/glx.h>
...
// Code for GNU systems goes here. We open the X11 display.
static Display *display = XOpenDisplay (NULL);
// Could we open the X11 display?
if(display)
{
// Get a `unsigned long' window handle.
unsigned long windowHandle = 0;
this->window->getCustomAttribute("WINDOW", &windowHandle);
// Select the default screen and store (cast) the `Window'.
static int screen = DefaultScreen(display);
Window win = (Window)windowHandle;
// We use the XTextProperty structure to store the title.
XTextProperty windowName;
windowName.value = (unsigned char *) "Simulation";
windowName.encoding = XA_STRING;
windowName.format = 8;
windowName.nitems = strlen((char *) windowName.value);
/**
* Tell X to ask the window manager to set the window title. (X
* itself doesn't provide window title functionality.)
*/
XSetWMName(display, win, &windowName);
}
--
Jon Kristensen
More information about the xorg
mailing list