Made invisible cursor object shared by windows.

This commit is contained in:
Camilla Berglund
2010-09-11 15:39:21 +02:00
parent 93979781af
commit 93bfa847ff
3 changed files with 40 additions and 41 deletions
+38
View File
@@ -139,12 +139,48 @@ static GLboolean initDisplay(void)
}
//========================================================================
// Create a blank cursor (for locked mouse mode)
//========================================================================
static Cursor createNULLCursor(void)
{
Pixmap cursormask;
XGCValues xgc;
GC gc;
XColor col;
Cursor cursor;
// TODO: Add error checks
cursormask = XCreatePixmap(_glfwLibrary.X11.display, _glfwLibrary.X11.root, 1, 1, 1);
xgc.function = GXclear;
gc = XCreateGC(_glfwLibrary.X11.display, cursormask, GCFunction, &xgc);
XFillRectangle(_glfwLibrary.X11.display, cursormask, gc, 0, 0, 1, 1);
col.pixel = 0;
col.red = 0;
col.flags = 4;
cursor = XCreatePixmapCursor(_glfwLibrary.X11.display, cursormask, cursormask,
&col, &col, 0, 0);
XFreePixmap(_glfwLibrary.X11.display, cursormask);
XFreeGC(_glfwLibrary.X11.display, gc);
return cursor;
}
//========================================================================
// Terminate X11 display
//========================================================================
static void terminateDisplay(void)
{
if (_glfwLibrary.X11.cursor)
{
XFreeCursor(_glfwLibrary.X11.display, _glfwLibrary.X11.cursor);
_glfwLibrary.X11.cursor = (Cursor) 0;
}
if (_glfwLibrary.X11.display)
{
XCloseDisplay(_glfwLibrary.X11.display);
@@ -166,6 +202,8 @@ int _glfwPlatformInit(void)
if (!initDisplay())
return GL_FALSE;
_glfwLibrary.X11.cursor = createNULLCursor();
// Try to load libGL.so if necessary
initLibraries();