mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 02:38:52 -05:00
Made invisible cursor object shared by windows.
This commit is contained in:
parent
93979781af
commit
93bfa847ff
|
@ -208,7 +208,6 @@ typedef struct _GLFWwindowX11
|
||||||
Atom wmState; // _NET_WM_STATE atom
|
Atom wmState; // _NET_WM_STATE atom
|
||||||
Atom wmStateFullscreen; // _NET_WM_STATE_FULLSCREEN atom
|
Atom wmStateFullscreen; // _NET_WM_STATE_FULLSCREEN atom
|
||||||
Atom wmActiveWindow; // _NET_ACTIVE_WINDOW atom
|
Atom wmActiveWindow; // _NET_ACTIVE_WINDOW atom
|
||||||
Cursor cursor; // Invisible cursor for hidden cursor
|
|
||||||
|
|
||||||
// Various platform specific internal variables
|
// Various platform specific internal variables
|
||||||
GLboolean hasEWMH; // True if window manager supports EWMH
|
GLboolean hasEWMH; // True if window manager supports EWMH
|
||||||
|
@ -230,6 +229,7 @@ typedef struct _GLFWlibraryX11
|
||||||
Display* display;
|
Display* display;
|
||||||
int screen;
|
int screen;
|
||||||
Window root;
|
Window root;
|
||||||
|
Cursor cursor; // Invisible cursor for hidden cursor
|
||||||
|
|
||||||
// Server-side GLX version
|
// Server-side GLX version
|
||||||
int glxMajor, glxMinor;
|
int glxMajor, glxMinor;
|
||||||
|
|
|
@ -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
|
// Terminate X11 display
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void terminateDisplay(void)
|
static void terminateDisplay(void)
|
||||||
{
|
{
|
||||||
|
if (_glfwLibrary.X11.cursor)
|
||||||
|
{
|
||||||
|
XFreeCursor(_glfwLibrary.X11.display, _glfwLibrary.X11.cursor);
|
||||||
|
_glfwLibrary.X11.cursor = (Cursor) 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (_glfwLibrary.X11.display)
|
if (_glfwLibrary.X11.display)
|
||||||
{
|
{
|
||||||
XCloseDisplay(_glfwLibrary.X11.display);
|
XCloseDisplay(_glfwLibrary.X11.display);
|
||||||
|
@ -166,6 +202,8 @@ int _glfwPlatformInit(void)
|
||||||
if (!initDisplay())
|
if (!initDisplay())
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
|
_glfwLibrary.X11.cursor = createNULLCursor();
|
||||||
|
|
||||||
// Try to load libGL.so if necessary
|
// Try to load libGL.so if necessary
|
||||||
initLibraries();
|
initLibraries();
|
||||||
|
|
||||||
|
|
|
@ -347,36 +347,6 @@ static int translateChar(XKeyEvent* event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Create a blank cursor (for locked mouse mode)
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static Cursor createNULLCursor(Display* display, Window root)
|
|
||||||
{
|
|
||||||
Pixmap cursormask;
|
|
||||||
XGCValues xgc;
|
|
||||||
GC gc;
|
|
||||||
XColor col;
|
|
||||||
Cursor cursor;
|
|
||||||
|
|
||||||
// TODO: Add error checks
|
|
||||||
|
|
||||||
cursormask = XCreatePixmap(display, root, 1, 1, 1);
|
|
||||||
xgc.function = GXclear;
|
|
||||||
gc = XCreateGC(display, cursormask, GCFunction, &xgc);
|
|
||||||
XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);
|
|
||||||
col.pixel = 0;
|
|
||||||
col.red = 0;
|
|
||||||
col.flags = 4;
|
|
||||||
cursor = XCreatePixmapCursor(display, cursormask, cursormask,
|
|
||||||
&col,&col, 0,0);
|
|
||||||
XFreePixmap(display, cursormask);
|
|
||||||
XFreeGC(display, gc);
|
|
||||||
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Returns the specified attribute of the specified GLXFBConfig
|
// Returns the specified attribute of the specified GLXFBConfig
|
||||||
// NOTE: Do not call this unless we have found GLX 1.3+ or GLX_SGIX_fbconfig
|
// NOTE: Do not call this unless we have found GLX 1.3+ or GLX_SGIX_fbconfig
|
||||||
|
@ -1409,9 +1379,6 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||||
window->refreshRate = wndconfig->refreshRate;
|
window->refreshRate = wndconfig->refreshRate;
|
||||||
window->windowNoResize = wndconfig->windowNoResize;
|
window->windowNoResize = wndconfig->windowNoResize;
|
||||||
|
|
||||||
// Create the invisible cursor for hidden cursor mode
|
|
||||||
window->X11.cursor = createNULLCursor(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
|
|
||||||
|
|
||||||
initGLXExtensions(window);
|
initGLXExtensions(window);
|
||||||
|
|
||||||
// Choose the best available fbconfig
|
// Choose the best available fbconfig
|
||||||
|
@ -1534,12 +1501,6 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
||||||
XFreeColormap(_glfwLibrary.X11.display, window->X11.colormap);
|
XFreeColormap(_glfwLibrary.X11.display, window->X11.colormap);
|
||||||
window->X11.colormap = (Colormap) 0;
|
window->X11.colormap = (Colormap) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->X11.cursor)
|
|
||||||
{
|
|
||||||
XFreeCursor(_glfwLibrary.X11.display, window->X11.cursor);
|
|
||||||
window->X11.cursor = (Cursor) 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1838,7 +1799,7 @@ void _glfwPlatformHideMouseCursor(_GLFWwindow* window)
|
||||||
// Hide cursor
|
// Hide cursor
|
||||||
if (!window->X11.pointerHidden)
|
if (!window->X11.pointerHidden)
|
||||||
{
|
{
|
||||||
XDefineCursor(_glfwLibrary.X11.display, window->X11.handle, window->X11.cursor);
|
XDefineCursor(_glfwLibrary.X11.display, window->X11.handle, _glfwLibrary.X11.cursor);
|
||||||
window->X11.pointerHidden = GL_TRUE;
|
window->X11.pointerHidden = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user