X11: Use background_pixel instead of background_pixmap to workaround a BadMatch error

Günther Brammer 2009-05-08 21:49:37 +02:00
parent 145e647df1
commit cada2e8537
1 changed files with 22 additions and 16 deletions

View File

@ -75,13 +75,8 @@ CStdWindow * CStdWindow::Init(CStdApp * pApp, const char * Title, CStdWindow * p
// Various properties // Various properties
XSetWindowAttributes attr; XSetWindowAttributes attr;
// Hide the mouse cursor
XColor cursor_color;
// We do not care what color the invisible cursor has
memset(&cursor_color, 0, sizeof(cursor_color));
Pixmap bitmap = XCreateBitmapFromData(dpy, DefaultRootWindow(dpy), "\000", 1, 1);
attr.cursor = XCreatePixmapCursor(dpy, bitmap, bitmap, &cursor_color, &cursor_color, 0, 0);
attr.border_pixel = 0; attr.border_pixel = 0;
attr.background_pixel = 0;
// Which events we want to receive // Which events we want to receive
attr.event_mask = attr.event_mask =
//EnterWindowMask | //EnterWindowMask |
@ -93,18 +88,28 @@ CStdWindow * CStdWindow::Init(CStdApp * pApp, const char * Title, CStdWindow * p
PointerMotionMask | PointerMotionMask |
ButtonPressMask | ButtonPressMask |
ButtonReleaseMask; ButtonReleaseMask;
attr.background_pixmap = None;
attr.border_pixmap = None;
attr.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy), ((XVisualInfo*)Info)->visual, AllocNone); attr.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy), ((XVisualInfo*)Info)->visual, AllocNone);
unsigned long attrmask = CWBackPixmap | CWBorderPixmap | CWColormap | CWEventMask; unsigned long attrmask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
if (HideCursor) attrmask |= CWCursor; Pixmap bitmap;
if (HideCursor)
{
// Hide the mouse cursor
XColor cursor_color;
// We do not care what color the invisible cursor has
memset(&cursor_color, 0, sizeof(cursor_color));
bitmap = XCreateBitmapFromData(dpy, DefaultRootWindow(dpy), "\000", 1, 1);
attr.cursor = XCreatePixmapCursor(dpy, bitmap, bitmap, &cursor_color, &cursor_color, 0, 0);
attrmask |= CWCursor;
}
wnd = XCreateWindow(dpy, DefaultRootWindow(dpy), wnd = XCreateWindow(dpy, DefaultRootWindow(dpy),
0, 0, 640, 480, 0, ((XVisualInfo*)Info)->depth, InputOutput, ((XVisualInfo*)Info)->visual, 0, 0, 640, 480, 0, ((XVisualInfo*)Info)->depth, InputOutput, ((XVisualInfo*)Info)->visual,
attrmask, attrmask, &attr);
&attr); if (HideCursor)
XFreeCursor(dpy, attr.cursor); {
XFreePixmap(dpy, bitmap); XFreeCursor(dpy, attr.cursor);
XFreePixmap(dpy, bitmap);
}
if (!wnd) { if (!wnd) {
Log("Error creating window."); Log("Error creating window.");
return 0; return 0;
@ -190,11 +195,12 @@ bool CStdWindow::FindInfo()
// get an appropriate visual // get an appropriate visual
// attributes for a single buffered visual in RGBA format with at least 4 bits per color // attributes for a single buffered visual in RGBA format with at least 4 bits per color
static int attrListSgl[] = { GLX_RGBA, static int attrListSgl[] = { GLX_RGBA,
GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, //GLX_DEPTH_SIZE, 16, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4,
None }; None };
// attributes for a double buffered visual in RGBA format with at least 4 bits per color // attributes for a double buffered visual in RGBA format with at least 4 bits per color
static int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER, static int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, //GLX_DEPTH_SIZE, 16, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4,
GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
None }; None };
// doublebuffered is the best // doublebuffered is the best
Info = glXChooseVisual(dpy, DefaultScreen(dpy), attrListDbl); Info = glXChooseVisual(dpy, DefaultScreen(dpy), attrListDbl);