Renamed X11 window handle, minor formatting of X11 window structure.

This commit is contained in:
Camilla Berglund 2010-09-11 15:34:03 +02:00
parent 728d52dc50
commit 93979781af
3 changed files with 48 additions and 51 deletions

View File

@ -202,7 +202,7 @@ typedef struct _GLFWwindowX11
{ {
// Platform specific window resources // Platform specific window resources
Colormap colormap; // Window colormap Colormap colormap; // Window colormap
Window window; // Window Window handle; // Window handle
Atom wmDeleteWindow; // WM_DELETE_WINDOW atom Atom wmDeleteWindow; // WM_DELETE_WINDOW atom
Atom wmPing; // _NET_WM_PING atom Atom wmPing; // _NET_WM_PING atom
Atom wmState; // _NET_WM_STATE atom Atom wmState; // _NET_WM_STATE atom
@ -210,14 +210,14 @@ typedef struct _GLFWwindowX11
Atom wmActiveWindow; // _NET_ACTIVE_WINDOW atom Atom wmActiveWindow; // _NET_ACTIVE_WINDOW atom
Cursor cursor; // Invisible cursor for hidden cursor Cursor cursor; // Invisible cursor for hidden cursor
int mouseMoved, cursorPosX, cursorPosY;
// 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
GLboolean overrideRedirect; // True if window is OverrideRedirect GLboolean overrideRedirect; // True if window is OverrideRedirect
GLboolean keyboardGrabbed; // True if keyboard is currently grabbed GLboolean keyboardGrabbed; // True if keyboard is currently grabbed
GLboolean pointerGrabbed; // True if pointer is currently grabbed GLboolean pointerGrabbed; // True if pointer is currently grabbed
GLboolean pointerHidden; // True if pointer is currently hidden GLboolean pointerHidden; // True if pointer is currently hidden
GLboolean mouseMoved;
int cursorPosX, cursorPosY;
} _GLFWwindowX11; } _GLFWwindowX11;

View File

@ -54,7 +54,7 @@ void _glfwPlatformEnableSystemKeys(_GLFWwindow* window)
void _glfwPlatformDisableSystemKeys(_GLFWwindow* window) void _glfwPlatformDisableSystemKeys(_GLFWwindow* window)
{ {
if (XGrabKeyboard(_glfwLibrary.X11.display, window->X11.window, if (XGrabKeyboard(_glfwLibrary.X11.display, window->X11.handle,
True, GrabModeAsync, GrabModeAsync, CurrentTime) True, GrabModeAsync, GrabModeAsync, CurrentTime)
== GrabSuccess) == GrabSuccess)
{ {

View File

@ -749,7 +749,7 @@ static GLboolean createWindow(_GLFWwindow* window,
wamask |= CWBackPixel; wamask |= CWBackPixel;
} }
window->X11.window = XCreateWindow( window->X11.handle = XCreateWindow(
_glfwLibrary.X11.display, _glfwLibrary.X11.display,
_glfwLibrary.X11.root, _glfwLibrary.X11.root,
0, 0, // Upper left corner of this window on root 0, 0, // Upper left corner of this window on root
@ -762,7 +762,7 @@ static GLboolean createWindow(_GLFWwindow* window,
&wa &wa
); );
if (!window->X11.window) if (!window->X11.handle)
{ {
// TODO: Handle all the various error codes here // TODO: Handle all the various error codes here
_glfwSetError(GLFW_INTERNAL_ERROR); _glfwSetError(GLFW_INTERNAL_ERROR);
@ -786,7 +786,7 @@ static GLboolean createWindow(_GLFWwindow* window,
XSetWindowAttributes attributes; XSetWindowAttributes attributes;
attributes.override_redirect = True; attributes.override_redirect = True;
XChangeWindowAttributes(_glfwLibrary.X11.display, XChangeWindowAttributes(_glfwLibrary.X11.display,
window->X11.window, window->X11.handle,
CWOverrideRedirect, CWOverrideRedirect,
&attributes); &attributes);
@ -816,7 +816,7 @@ static GLboolean createWindow(_GLFWwindow* window,
if (count > 0) if (count > 0)
{ {
XSetWMProtocols(_glfwLibrary.X11.display, window->X11.window, XSetWMProtocols(_glfwLibrary.X11.display, window->X11.handle,
protocols, count); protocols, count);
} }
} }
@ -833,7 +833,7 @@ static GLboolean createWindow(_GLFWwindow* window,
hints->flags = StateHint; hints->flags = StateHint;
hints->initial_state = NormalState; hints->initial_state = NormalState;
XSetWMHints(_glfwLibrary.X11.display, window->X11.window, hints); XSetWMHints(_glfwLibrary.X11.display, window->X11.handle, hints);
XFree(hints); XFree(hints);
} }
@ -855,16 +855,16 @@ static GLboolean createWindow(_GLFWwindow* window,
hints->min_height = hints->max_height = window->height; hints->min_height = hints->max_height = window->height;
} }
XSetWMNormalHints(_glfwLibrary.X11.display, window->X11.window, hints); XSetWMNormalHints(_glfwLibrary.X11.display, window->X11.handle, hints);
XFree(hints); XFree(hints);
} }
_glfwPlatformSetWindowTitle(window, "GLFW Window"); _glfwPlatformSetWindowTitle(window, "GLFW Window");
// Make sure the window is mapped before proceeding // Make sure the window is mapped before proceeding
XMapWindow(_glfwLibrary.X11.display, window->X11.window); XMapWindow(_glfwLibrary.X11.display, window->X11.handle);
XPeekIfEvent(_glfwLibrary.X11.display, &event, isMapNotify, XPeekIfEvent(_glfwLibrary.X11.display, &event, isMapNotify,
(char*) window->X11.window); (char*) window->X11.handle);
return GL_TRUE; return GL_TRUE;
} }
@ -910,7 +910,7 @@ static void enterFullscreenMode(_GLFWwindow* window)
memset(&event, 0, sizeof(event)); memset(&event, 0, sizeof(event));
event.type = ClientMessage; event.type = ClientMessage;
event.xclient.window = window->X11.window; event.xclient.window = window->X11.handle;
event.xclient.format = 32; // Data is 32-bit longs event.xclient.format = 32; // Data is 32-bit longs
event.xclient.message_type = window->X11.wmActiveWindow; event.xclient.message_type = window->X11.wmActiveWindow;
event.xclient.data.l[0] = 1; // Sender is a normal application event.xclient.data.l[0] = 1; // Sender is a normal application
@ -931,7 +931,7 @@ static void enterFullscreenMode(_GLFWwindow* window)
memset(&event, 0, sizeof(event)); memset(&event, 0, sizeof(event));
event.type = ClientMessage; event.type = ClientMessage;
event.xclient.window = window->X11.window; event.xclient.window = window->X11.handle;
event.xclient.format = 32; // Data is 32-bit longs event.xclient.format = 32; // Data is 32-bit longs
event.xclient.message_type = window->X11.wmState; event.xclient.message_type = window->X11.wmState;
event.xclient.data.l[0] = _NET_WM_STATE_ADD; event.xclient.data.l[0] = _NET_WM_STATE_ADD;
@ -950,11 +950,11 @@ static void enterFullscreenMode(_GLFWwindow* window)
// In override-redirect mode, we have divorced ourselves from the // In override-redirect mode, we have divorced ourselves from the
// window manager, so we need to do everything manually // window manager, so we need to do everything manually
XRaiseWindow(_glfwLibrary.X11.display, window->X11.window); XRaiseWindow(_glfwLibrary.X11.display, window->X11.handle);
XSetInputFocus(_glfwLibrary.X11.display, window->X11.window, XSetInputFocus(_glfwLibrary.X11.display, window->X11.handle,
RevertToParent, CurrentTime); RevertToParent, CurrentTime);
XMoveWindow(_glfwLibrary.X11.display, window->X11.window, 0, 0); XMoveWindow(_glfwLibrary.X11.display, window->X11.handle, 0, 0);
XResizeWindow(_glfwLibrary.X11.display, window->X11.window, XResizeWindow(_glfwLibrary.X11.display, window->X11.handle,
window->width, window->height); window->width, window->height);
} }
@ -964,8 +964,8 @@ static void enterFullscreenMode(_GLFWwindow* window)
// HACK: Try to get window inside viewport (for virtual displays) by moving // HACK: Try to get window inside viewport (for virtual displays) by moving
// the mouse cursor to the upper left corner (and then to the center) // the mouse cursor to the upper left corner (and then to the center)
// This hack should be harmless on saner systems as well // This hack should be harmless on saner systems as well
XWarpPointer(_glfwLibrary.X11.display, None, window->X11.window, 0,0,0,0, 0,0); XWarpPointer(_glfwLibrary.X11.display, None, window->X11.handle, 0,0,0,0, 0,0);
XWarpPointer(_glfwLibrary.X11.display, None, window->X11.window, 0,0,0,0, XWarpPointer(_glfwLibrary.X11.display, None, window->X11.handle, 0,0,0,0,
window->width / 2, window->height / 2); window->width / 2, window->height / 2);
} }
@ -1001,7 +1001,7 @@ static void leaveFullscreenMode(_GLFWwindow* window)
memset(&event, 0, sizeof(event)); memset(&event, 0, sizeof(event));
event.type = ClientMessage; event.type = ClientMessage;
event.xclient.window = window->X11.window; event.xclient.window = window->X11.handle;
event.xclient.format = 32; // Data is 32-bit longs event.xclient.format = 32; // Data is 32-bit longs
event.xclient.message_type = window->X11.wmState; event.xclient.message_type = window->X11.wmState;
event.xclient.data.l[0] = _NET_WM_STATE_REMOVE; event.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
@ -1030,7 +1030,7 @@ static _GLFWwindow* findWindow(Window handle)
for (window = _glfwLibrary.windowListHead; window; window = window->next) for (window = _glfwLibrary.windowListHead; window; window = window->next)
{ {
if (window->X11.window == handle) if (window->X11.handle == handle)
return window; return window;
} }
@ -1448,7 +1448,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
if (_glfwLibrary.X11.XRandR.available) if (_glfwLibrary.X11.XRandR.available)
{ {
XRRSelectInput(_glfwLibrary.X11.display, XRRSelectInput(_glfwLibrary.X11.display,
window->X11.window, window->X11.handle,
RRScreenChangeNotifyMask); RRScreenChangeNotifyMask);
} }
#endif #endif
@ -1465,7 +1465,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
unsigned int mask; unsigned int mask;
XQueryPointer(_glfwLibrary.X11.display, XQueryPointer(_glfwLibrary.X11.display,
window->X11.window, window->X11.handle,
&cursorRoot, &cursorRoot,
&cursorWindow, &cursorWindow,
&rootX, &rootY, &rootX, &rootY,
@ -1491,7 +1491,7 @@ int _glfwPlatformMakeWindowCurrent(_GLFWwindow* window)
if (window) if (window)
{ {
glXMakeCurrent(_glfwLibrary.X11.display, glXMakeCurrent(_glfwLibrary.X11.display,
window->X11.window, window->X11.handle,
window->GLX.context); window->GLX.context);
} }
else else
@ -1508,9 +1508,6 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
if (window->mode == GLFW_FULLSCREEN) if (window->mode == GLFW_FULLSCREEN)
leaveFullscreenMode(window); leaveFullscreenMode(window);
if (_glfwLibrary.activeWindow == window)
_glfwLibrary.activeWindow = NULL;
if (window->GLX.context) if (window->GLX.context)
{ {
// Release and destroy the context // Release and destroy the context
@ -1525,11 +1522,11 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
window->GLX.visual = NULL; window->GLX.visual = NULL;
} }
if (window->X11.window) if (window->X11.handle)
{ {
XUnmapWindow(_glfwLibrary.X11.display, window->X11.window); XUnmapWindow(_glfwLibrary.X11.display, window->X11.handle);
XDestroyWindow(_glfwLibrary.X11.display, window->X11.window); XDestroyWindow(_glfwLibrary.X11.display, window->X11.handle);
window->X11.window = (Window) 0; window->X11.handle = (Window) 0;
} }
if (window->X11.colormap) if (window->X11.colormap)
@ -1553,8 +1550,8 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
{ {
// Set window & icon title // Set window & icon title
XStoreName(_glfwLibrary.X11.display, window->X11.window, title); XStoreName(_glfwLibrary.X11.display, window->X11.handle, title);
XSetIconName(_glfwLibrary.X11.display, window->X11.window, title); XSetIconName(_glfwLibrary.X11.display, window->X11.handle, title);
} }
@ -1585,14 +1582,14 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
sizehints->min_width = sizehints->max_width = width; sizehints->min_width = sizehints->max_width = width;
sizehints->min_height = sizehints->max_height = height; sizehints->min_height = sizehints->max_height = height;
XSetWMNormalHints(_glfwLibrary.X11.display, window->X11.window, sizehints); XSetWMNormalHints(_glfwLibrary.X11.display, window->X11.handle, sizehints);
XFree(sizehints); XFree(sizehints);
} }
// Change window size before changing fullscreen mode? // Change window size before changing fullscreen mode?
if (window->mode == GLFW_FULLSCREEN && (width > window->width)) if (window->mode == GLFW_FULLSCREEN && (width > window->width))
{ {
XResizeWindow(_glfwLibrary.X11.display, window->X11.window, width, height); XResizeWindow(_glfwLibrary.X11.display, window->X11.handle, width, height);
sizeChanged = GL_TRUE; sizeChanged = GL_TRUE;
} }
@ -1604,7 +1601,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
// Set window size (if not already changed) // Set window size (if not already changed)
if (!sizeChanged) if (!sizeChanged)
XResizeWindow(_glfwLibrary.X11.display, window->X11.window, width, height); XResizeWindow(_glfwLibrary.X11.display, window->X11.handle, width, height);
} }
@ -1614,7 +1611,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y) void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
{ {
XMoveWindow(_glfwLibrary.X11.display, window->X11.window, x, y); XMoveWindow(_glfwLibrary.X11.display, window->X11.handle, x, y);
} }
@ -1631,7 +1628,7 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
return; return;
} }
XIconifyWindow(_glfwLibrary.X11.display, window->X11.window, _glfwLibrary.X11.screen); XIconifyWindow(_glfwLibrary.X11.display, window->X11.handle, _glfwLibrary.X11.screen);
} }
@ -1648,7 +1645,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
return; return;
} }
XMapWindow(_glfwLibrary.X11.display, window->X11.window); XMapWindow(_glfwLibrary.X11.display, window->X11.handle);
} }
@ -1659,7 +1656,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
void _glfwPlatformSwapBuffers(void) void _glfwPlatformSwapBuffers(void)
{ {
glXSwapBuffers(_glfwLibrary.X11.display, glXSwapBuffers(_glfwLibrary.X11.display,
_glfwLibrary.currentWindow->X11.window); _glfwLibrary.currentWindow->X11.handle);
} }
@ -1841,17 +1838,17 @@ void _glfwPlatformHideMouseCursor(_GLFWwindow* window)
// Hide cursor // Hide cursor
if (!window->X11.pointerHidden) if (!window->X11.pointerHidden)
{ {
XDefineCursor(_glfwLibrary.X11.display, window->X11.window, window->X11.cursor); XDefineCursor(_glfwLibrary.X11.display, window->X11.handle, window->X11.cursor);
window->X11.pointerHidden = GL_TRUE; window->X11.pointerHidden = GL_TRUE;
} }
// Grab cursor to user window // Grab cursor to user window
if (!window->X11.pointerGrabbed) if (!window->X11.pointerGrabbed)
{ {
if (XGrabPointer(_glfwLibrary.X11.display, window->X11.window, True, if (XGrabPointer(_glfwLibrary.X11.display, window->X11.handle, True,
ButtonPressMask | ButtonReleaseMask | ButtonPressMask | ButtonReleaseMask |
PointerMotionMask, GrabModeAsync, GrabModeAsync, PointerMotionMask, GrabModeAsync, GrabModeAsync,
window->X11.window, None, CurrentTime) == window->X11.handle, None, CurrentTime) ==
GrabSuccess) GrabSuccess)
{ {
window->X11.pointerGrabbed = GL_TRUE; window->X11.pointerGrabbed = GL_TRUE;
@ -1878,7 +1875,7 @@ void _glfwPlatformShowMouseCursor(_GLFWwindow* window)
// Show cursor // Show cursor
if (window->X11.pointerHidden) if (window->X11.pointerHidden)
{ {
XUndefineCursor(_glfwLibrary.X11.display, window->X11.window); XUndefineCursor(_glfwLibrary.X11.display, window->X11.handle);
window->X11.pointerHidden = GL_FALSE; window->X11.pointerHidden = GL_FALSE;
} }
} }
@ -1894,6 +1891,6 @@ void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
window->X11.cursorPosX = x; window->X11.cursorPosX = x;
window->X11.cursorPosY = y; window->X11.cursorPosY = y;
XWarpPointer(_glfwLibrary.X11.display, None, window->X11.window, 0,0,0,0, x, y); XWarpPointer(_glfwLibrary.X11.display, None, window->X11.handle, 0,0,0,0, x, y);
} }