|
@@ -30,6 +30,8 @@
|
|
|
|
|
|
#include "internal.h"
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
+#include <sys/select.h>
|
|
|
|
+
|
|
#include <string.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
@@ -226,10 +228,6 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|
|
|
|
|
_glfwPlatformSetWindowTitle(window, wndconfig->title);
|
|
_glfwPlatformSetWindowTitle(window, wndconfig->title);
|
|
|
|
|
|
- // Make sure the window is mapped before proceeding
|
|
|
|
- XMapWindow(_glfwLibrary.X11.display, window->X11.handle);
|
|
|
|
- XFlush(_glfwLibrary.X11.display);
|
|
|
|
-
|
|
|
|
return GL_TRUE;
|
|
return GL_TRUE;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -460,34 +458,31 @@ static _GLFWwindow* findWindow(Window handle)
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
//========================================================================
|
|
-// Get and process next X event (called by _glfwPlatformPollEvents)
|
|
|
|
|
|
+// Process the specified X event
|
|
//========================================================================
|
|
//========================================================================
|
|
|
|
|
|
-static void processSingleEvent(void)
|
|
|
|
|
|
+static void processEvent(XEvent *event)
|
|
{
|
|
{
|
|
_GLFWwindow* window;
|
|
_GLFWwindow* window;
|
|
|
|
|
|
- XEvent event;
|
|
|
|
- XNextEvent(_glfwLibrary.X11.display, &event);
|
|
|
|
-
|
|
|
|
- switch (event.type)
|
|
|
|
|
|
+ switch (event->type)
|
|
{
|
|
{
|
|
case KeyPress:
|
|
case KeyPress:
|
|
{
|
|
{
|
|
// A keyboard key was pressed
|
|
// A keyboard key was pressed
|
|
- window = findWindow(event.xkey.window);
|
|
|
|
|
|
+ window = findWindow(event->xkey.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
- _glfwInputKey(window, translateKey(event.xkey.keycode), GLFW_PRESS);
|
|
|
|
- _glfwInputChar(window, translateChar(&event.xkey));
|
|
|
|
|
|
+ _glfwInputKey(window, translateKey(event->xkey.keycode), GLFW_PRESS);
|
|
|
|
+ _glfwInputChar(window, translateChar(&event->xkey));
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
case KeyRelease:
|
|
case KeyRelease:
|
|
{
|
|
{
|
|
// A keyboard key was released
|
|
// A keyboard key was released
|
|
- window = findWindow(event.xkey.window);
|
|
|
|
|
|
+ window = findWindow(event->xkey.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -501,15 +496,15 @@ static void processSingleEvent(void)
|
|
XPeekEvent(_glfwLibrary.X11.display, &nextEvent);
|
|
XPeekEvent(_glfwLibrary.X11.display, &nextEvent);
|
|
|
|
|
|
if (nextEvent.type == KeyPress &&
|
|
if (nextEvent.type == KeyPress &&
|
|
- nextEvent.xkey.window == event.xkey.window &&
|
|
|
|
- nextEvent.xkey.keycode == event.xkey.keycode)
|
|
|
|
|
|
+ nextEvent.xkey.window == event->xkey.window &&
|
|
|
|
+ nextEvent.xkey.keycode == event->xkey.keycode)
|
|
{
|
|
{
|
|
// This last check is a hack to work around key repeats
|
|
// This last check is a hack to work around key repeats
|
|
// leaking through due to some sort of time drift
|
|
// leaking through due to some sort of time drift
|
|
// Toshiyuki Takahashi can press a button 16 times per
|
|
// Toshiyuki Takahashi can press a button 16 times per
|
|
// second so it's fairly safe to assume that no human is
|
|
// second so it's fairly safe to assume that no human is
|
|
// pressing the key 50 times per second (value is ms)
|
|
// pressing the key 50 times per second (value is ms)
|
|
- if ((nextEvent.xkey.time - event.xkey.time) < 20)
|
|
|
|
|
|
+ if ((nextEvent.xkey.time - event->xkey.time) < 20)
|
|
{
|
|
{
|
|
// Do not report anything for this event
|
|
// Do not report anything for this event
|
|
break;
|
|
break;
|
|
@@ -517,34 +512,34 @@ static void processSingleEvent(void)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- _glfwInputKey(window, translateKey(event.xkey.keycode), GLFW_RELEASE);
|
|
|
|
|
|
+ _glfwInputKey(window, translateKey(event->xkey.keycode), GLFW_RELEASE);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
case ButtonPress:
|
|
case ButtonPress:
|
|
{
|
|
{
|
|
// A mouse button was pressed or a scrolling event occurred
|
|
// A mouse button was pressed or a scrolling event occurred
|
|
- window = findWindow(event.xbutton.window);
|
|
|
|
|
|
+ window = findWindow(event->xbutton.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
- if (event.xbutton.button == Button1)
|
|
|
|
|
|
+ if (event->xbutton.button == Button1)
|
|
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS);
|
|
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS);
|
|
- else if (event.xbutton.button == Button2)
|
|
|
|
|
|
+ else if (event->xbutton.button == Button2)
|
|
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS);
|
|
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS);
|
|
- else if (event.xbutton.button == Button3)
|
|
|
|
|
|
+ else if (event->xbutton.button == Button3)
|
|
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS);
|
|
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS);
|
|
|
|
|
|
// XFree86 3.3.2 and later translates mouse wheel up/down into
|
|
// XFree86 3.3.2 and later translates mouse wheel up/down into
|
|
// mouse button 4 & 5 presses
|
|
// mouse button 4 & 5 presses
|
|
- else if (event.xbutton.button == Button4)
|
|
|
|
|
|
+ else if (event->xbutton.button == Button4)
|
|
_glfwInputScroll(window, 0.0, 1.0);
|
|
_glfwInputScroll(window, 0.0, 1.0);
|
|
- else if (event.xbutton.button == Button5)
|
|
|
|
|
|
+ else if (event->xbutton.button == Button5)
|
|
_glfwInputScroll(window, 0.0, -1.0);
|
|
_glfwInputScroll(window, 0.0, -1.0);
|
|
|
|
|
|
- else if (event.xbutton.button == Button6)
|
|
|
|
|
|
+ else if (event->xbutton.button == Button6)
|
|
_glfwInputScroll(window, -1.0, 0.0);
|
|
_glfwInputScroll(window, -1.0, 0.0);
|
|
- else if (event.xbutton.button == Button7)
|
|
|
|
|
|
+ else if (event->xbutton.button == Button7)
|
|
_glfwInputScroll(window, 1.0, 0.0);
|
|
_glfwInputScroll(window, 1.0, 0.0);
|
|
|
|
|
|
break;
|
|
break;
|
|
@@ -553,23 +548,23 @@ static void processSingleEvent(void)
|
|
case ButtonRelease:
|
|
case ButtonRelease:
|
|
{
|
|
{
|
|
// A mouse button was released
|
|
// A mouse button was released
|
|
- window = findWindow(event.xbutton.window);
|
|
|
|
|
|
+ window = findWindow(event->xbutton.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
- if (event.xbutton.button == Button1)
|
|
|
|
|
|
+ if (event->xbutton.button == Button1)
|
|
{
|
|
{
|
|
_glfwInputMouseClick(window,
|
|
_glfwInputMouseClick(window,
|
|
GLFW_MOUSE_BUTTON_LEFT,
|
|
GLFW_MOUSE_BUTTON_LEFT,
|
|
GLFW_RELEASE);
|
|
GLFW_RELEASE);
|
|
}
|
|
}
|
|
- else if (event.xbutton.button == Button2)
|
|
|
|
|
|
+ else if (event->xbutton.button == Button2)
|
|
{
|
|
{
|
|
_glfwInputMouseClick(window,
|
|
_glfwInputMouseClick(window,
|
|
GLFW_MOUSE_BUTTON_MIDDLE,
|
|
GLFW_MOUSE_BUTTON_MIDDLE,
|
|
GLFW_RELEASE);
|
|
GLFW_RELEASE);
|
|
}
|
|
}
|
|
- else if (event.xbutton.button == Button3)
|
|
|
|
|
|
+ else if (event->xbutton.button == Button3)
|
|
{
|
|
{
|
|
_glfwInputMouseClick(window,
|
|
_glfwInputMouseClick(window,
|
|
GLFW_MOUSE_BUTTON_RIGHT,
|
|
GLFW_MOUSE_BUTTON_RIGHT,
|
|
@@ -581,7 +576,7 @@ static void processSingleEvent(void)
|
|
case EnterNotify:
|
|
case EnterNotify:
|
|
{
|
|
{
|
|
// The cursor entered the window
|
|
// The cursor entered the window
|
|
- window = findWindow(event.xcrossing.window);
|
|
|
|
|
|
+ window = findWindow(event->xcrossing.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -595,7 +590,7 @@ static void processSingleEvent(void)
|
|
case LeaveNotify:
|
|
case LeaveNotify:
|
|
{
|
|
{
|
|
// The cursor left the window
|
|
// The cursor left the window
|
|
- window = findWindow(event.xcrossing.window);
|
|
|
|
|
|
+ window = findWindow(event->xcrossing.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -609,12 +604,12 @@ static void processSingleEvent(void)
|
|
case MotionNotify:
|
|
case MotionNotify:
|
|
{
|
|
{
|
|
// The cursor was moved
|
|
// The cursor was moved
|
|
- window = findWindow(event.xmotion.window);
|
|
|
|
|
|
+ window = findWindow(event->xmotion.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
- if (event.xmotion.x != window->X11.cursorPosX ||
|
|
|
|
- event.xmotion.y != window->X11.cursorPosY)
|
|
|
|
|
|
+ if (event->xmotion.x != window->X11.cursorPosX ||
|
|
|
|
+ event->xmotion.y != window->X11.cursorPosY)
|
|
{
|
|
{
|
|
// The cursor was moved by something other than GLFW
|
|
// The cursor was moved by something other than GLFW
|
|
|
|
|
|
@@ -625,17 +620,17 @@ static void processSingleEvent(void)
|
|
if (_glfwLibrary.activeWindow != window)
|
|
if (_glfwLibrary.activeWindow != window)
|
|
break;
|
|
break;
|
|
|
|
|
|
- x = event.xmotion.x - window->X11.cursorPosX;
|
|
|
|
- y = event.xmotion.y - window->X11.cursorPosY;
|
|
|
|
|
|
+ x = event->xmotion.x - window->X11.cursorPosX;
|
|
|
|
+ y = event->xmotion.y - window->X11.cursorPosY;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- x = event.xmotion.x;
|
|
|
|
- y = event.xmotion.y;
|
|
|
|
|
|
+ x = event->xmotion.x;
|
|
|
|
+ y = event->xmotion.y;
|
|
}
|
|
}
|
|
|
|
|
|
- window->X11.cursorPosX = event.xmotion.x;
|
|
|
|
- window->X11.cursorPosY = event.xmotion.y;
|
|
|
|
|
|
+ window->X11.cursorPosX = event->xmotion.x;
|
|
|
|
+ window->X11.cursorPosY = event->xmotion.y;
|
|
window->X11.cursorCentered = GL_FALSE;
|
|
window->X11.cursorCentered = GL_FALSE;
|
|
|
|
|
|
_glfwInputCursorMotion(window, x, y);
|
|
_glfwInputCursorMotion(window, x, y);
|
|
@@ -647,17 +642,17 @@ static void processSingleEvent(void)
|
|
case ConfigureNotify:
|
|
case ConfigureNotify:
|
|
{
|
|
{
|
|
// The window configuration changed somehow
|
|
// The window configuration changed somehow
|
|
- window = findWindow(event.xconfigure.window);
|
|
|
|
|
|
+ window = findWindow(event->xconfigure.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
_glfwInputWindowSize(window,
|
|
_glfwInputWindowSize(window,
|
|
- event.xconfigure.width,
|
|
|
|
- event.xconfigure.height);
|
|
|
|
|
|
+ event->xconfigure.width,
|
|
|
|
+ event->xconfigure.height);
|
|
|
|
|
|
_glfwInputWindowPos(window,
|
|
_glfwInputWindowPos(window,
|
|
- event.xconfigure.x,
|
|
|
|
- event.xconfigure.y);
|
|
|
|
|
|
+ event->xconfigure.x,
|
|
|
|
+ event->xconfigure.y);
|
|
|
|
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -665,11 +660,11 @@ static void processSingleEvent(void)
|
|
case ClientMessage:
|
|
case ClientMessage:
|
|
{
|
|
{
|
|
// Custom client message, probably from the window manager
|
|
// Custom client message, probably from the window manager
|
|
- window = findWindow(event.xclient.window);
|
|
|
|
|
|
+ window = findWindow(event->xclient.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
- if ((Atom) event.xclient.data.l[0] == _glfwLibrary.X11.wmDeleteWindow)
|
|
|
|
|
|
+ if ((Atom) event->xclient.data.l[0] == _glfwLibrary.X11.wmDeleteWindow)
|
|
{
|
|
{
|
|
// The window manager was asked to close the window, for example by
|
|
// The window manager was asked to close the window, for example by
|
|
// the user pressing a 'close' window decoration button
|
|
// the user pressing a 'close' window decoration button
|
|
@@ -677,17 +672,17 @@ static void processSingleEvent(void)
|
|
_glfwInputWindowCloseRequest(window);
|
|
_glfwInputWindowCloseRequest(window);
|
|
}
|
|
}
|
|
else if (_glfwLibrary.X11.wmPing != None &&
|
|
else if (_glfwLibrary.X11.wmPing != None &&
|
|
- (Atom) event.xclient.data.l[0] == _glfwLibrary.X11.wmPing)
|
|
|
|
|
|
+ (Atom) event->xclient.data.l[0] == _glfwLibrary.X11.wmPing)
|
|
{
|
|
{
|
|
// The window manager is pinging the application to ensure it's
|
|
// The window manager is pinging the application to ensure it's
|
|
// still responding to events
|
|
// still responding to events
|
|
|
|
|
|
- event.xclient.window = _glfwLibrary.X11.root;
|
|
|
|
|
|
+ event->xclient.window = _glfwLibrary.X11.root;
|
|
XSendEvent(_glfwLibrary.X11.display,
|
|
XSendEvent(_glfwLibrary.X11.display,
|
|
- event.xclient.window,
|
|
|
|
|
|
+ event->xclient.window,
|
|
False,
|
|
False,
|
|
SubstructureNotifyMask | SubstructureRedirectMask,
|
|
SubstructureNotifyMask | SubstructureRedirectMask,
|
|
- &event);
|
|
|
|
|
|
+ event);
|
|
}
|
|
}
|
|
|
|
|
|
break;
|
|
break;
|
|
@@ -696,10 +691,11 @@ static void processSingleEvent(void)
|
|
case MapNotify:
|
|
case MapNotify:
|
|
{
|
|
{
|
|
// The window was mapped
|
|
// The window was mapped
|
|
- window = findWindow(event.xmap.window);
|
|
|
|
|
|
+ window = findWindow(event->xmap.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
+ _glfwInputWindowVisibility(window, GL_TRUE);
|
|
_glfwInputWindowIconify(window, GL_FALSE);
|
|
_glfwInputWindowIconify(window, GL_FALSE);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -707,10 +703,11 @@ static void processSingleEvent(void)
|
|
case UnmapNotify:
|
|
case UnmapNotify:
|
|
{
|
|
{
|
|
// The window was unmapped
|
|
// The window was unmapped
|
|
- window = findWindow(event.xmap.window);
|
|
|
|
|
|
+ window = findWindow(event->xmap.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
+ _glfwInputWindowVisibility(window, GL_FALSE);
|
|
_glfwInputWindowIconify(window, GL_TRUE);
|
|
_glfwInputWindowIconify(window, GL_TRUE);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -718,7 +715,7 @@ static void processSingleEvent(void)
|
|
case FocusIn:
|
|
case FocusIn:
|
|
{
|
|
{
|
|
// The window gained focus
|
|
// The window gained focus
|
|
- window = findWindow(event.xfocus.window);
|
|
|
|
|
|
+ window = findWindow(event->xfocus.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -733,7 +730,7 @@ static void processSingleEvent(void)
|
|
case FocusOut:
|
|
case FocusOut:
|
|
{
|
|
{
|
|
// The window lost focus
|
|
// The window lost focus
|
|
- window = findWindow(event.xfocus.window);
|
|
|
|
|
|
+ window = findWindow(event->xfocus.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -748,7 +745,7 @@ static void processSingleEvent(void)
|
|
case Expose:
|
|
case Expose:
|
|
{
|
|
{
|
|
// The window's contents was damaged
|
|
// The window's contents was damaged
|
|
- window = findWindow(event.xexpose.window);
|
|
|
|
|
|
+ window = findWindow(event->xexpose.window);
|
|
if (window == NULL)
|
|
if (window == NULL)
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -769,7 +766,7 @@ static void processSingleEvent(void)
|
|
{
|
|
{
|
|
// The selection conversion status is available
|
|
// The selection conversion status is available
|
|
|
|
|
|
- XSelectionEvent* request = &event.xselection;
|
|
|
|
|
|
+ XSelectionEvent* request = &event->xselection;
|
|
|
|
|
|
if (_glfwReadSelection(request))
|
|
if (_glfwReadSelection(request))
|
|
_glfwLibrary.X11.selection.status = _GLFW_CONVERSION_SUCCEEDED;
|
|
_glfwLibrary.X11.selection.status = _GLFW_CONVERSION_SUCCEEDED;
|
|
@@ -783,7 +780,7 @@ static void processSingleEvent(void)
|
|
{
|
|
{
|
|
// The contents of the selection was requested
|
|
// The contents of the selection was requested
|
|
|
|
|
|
- XSelectionRequestEvent* request = &event.xselectionrequest;
|
|
|
|
|
|
+ XSelectionRequestEvent* request = &event->xselectionrequest;
|
|
|
|
|
|
XEvent response;
|
|
XEvent response;
|
|
memset(&response, 0, sizeof(response));
|
|
memset(&response, 0, sizeof(response));
|
|
@@ -808,11 +805,11 @@ static void processSingleEvent(void)
|
|
default:
|
|
default:
|
|
{
|
|
{
|
|
#if defined(_GLFW_HAS_XRANDR)
|
|
#if defined(_GLFW_HAS_XRANDR)
|
|
- switch (event.type - _glfwLibrary.X11.RandR.eventBase)
|
|
|
|
|
|
+ switch (event->type - _glfwLibrary.X11.RandR.eventBase)
|
|
{
|
|
{
|
|
case RRScreenChangeNotify:
|
|
case RRScreenChangeNotify:
|
|
{
|
|
{
|
|
- XRRUpdateConfiguration(&event);
|
|
|
|
|
|
+ XRRUpdateConfiguration(event);
|
|
_glfwRefreshMonitors();
|
|
_glfwRefreshMonitors();
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -958,7 +955,6 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
|
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|
{
|
|
{
|
|
int mode = 0, rate, sizeChanged = GL_FALSE;
|
|
int mode = 0, rate, sizeChanged = GL_FALSE;
|
|
- XSizeHints* sizehints;
|
|
|
|
|
|
|
|
rate = window->refreshRate;
|
|
rate = window->refreshRate;
|
|
|
|
|
|
@@ -972,14 +968,14 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|
{
|
|
{
|
|
// Update window size restrictions to match new window size
|
|
// Update window size restrictions to match new window size
|
|
|
|
|
|
- sizehints = XAllocSizeHints();
|
|
|
|
- sizehints->flags = 0;
|
|
|
|
|
|
+ XSizeHints* hints = XAllocSizeHints();
|
|
|
|
|
|
- sizehints->min_width = sizehints->max_width = width;
|
|
|
|
- sizehints->min_height = sizehints->max_height = height;
|
|
|
|
|
|
+ hints->flags |= (PMinSize | PMaxSize);
|
|
|
|
+ hints->min_width = hints->max_width = width;
|
|
|
|
+ hints->min_height = hints->max_height = height;
|
|
|
|
|
|
- XSetWMNormalHints(_glfwLibrary.X11.display, window->X11.handle, sizehints);
|
|
|
|
- XFree(sizehints);
|
|
|
|
|
|
+ XSetWMNormalHints(_glfwLibrary.X11.display, window->X11.handle, hints);
|
|
|
|
+ XFree(hints);
|
|
}
|
|
}
|
|
|
|
|
|
// Change window size before changing fullscreen mode?
|
|
// Change window size before changing fullscreen mode?
|
|
@@ -1047,6 +1043,28 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+//========================================================================
|
|
|
|
+// Show window
|
|
|
|
+//========================================================================
|
|
|
|
+
|
|
|
|
+void _glfwPlatformShowWindow(_GLFWwindow* window)
|
|
|
|
+{
|
|
|
|
+ XMapRaised(_glfwLibrary.X11.display, window->X11.handle);
|
|
|
|
+ XFlush(_glfwLibrary.X11.display);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//========================================================================
|
|
|
|
+// Hide window
|
|
|
|
+//========================================================================
|
|
|
|
+
|
|
|
|
+void _glfwPlatformHideWindow(_GLFWwindow* window)
|
|
|
|
+{
|
|
|
|
+ XUnmapWindow(_glfwLibrary.X11.display, window->X11.handle);
|
|
|
|
+ XFlush(_glfwLibrary.X11.display);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
//========================================================================
|
|
//========================================================================
|
|
// Read back framebuffer parameters from the context
|
|
// Read back framebuffer parameters from the context
|
|
//========================================================================
|
|
//========================================================================
|
|
@@ -1094,13 +1112,18 @@ void _glfwPlatformRefreshWindowParams(_GLFWwindow* window)
|
|
|
|
|
|
void _glfwPlatformPollEvents(void)
|
|
void _glfwPlatformPollEvents(void)
|
|
{
|
|
{
|
|
- _GLFWwindow* window;
|
|
|
|
|
|
+ XEvent event;
|
|
|
|
|
|
- // Process all pending events
|
|
|
|
- while (XPending(_glfwLibrary.X11.display))
|
|
|
|
- processSingleEvent();
|
|
|
|
|
|
+ while (XCheckMaskEvent(_glfwLibrary.X11.display, ~0, &event) ||
|
|
|
|
+ XCheckTypedEvent(_glfwLibrary.X11.display, ClientMessage, &event))
|
|
|
|
+ {
|
|
|
|
+ processEvent(&event);
|
|
|
|
+ }
|
|
|
|
|
|
- // Did the cursor move in an active window that has captured the cursor
|
|
|
|
|
|
+ // Check whether the cursor has moved inside an active window that has
|
|
|
|
+ // captured the cursor (because then it needs to be re-centered)
|
|
|
|
+
|
|
|
|
+ _GLFWwindow* window;
|
|
window = _glfwLibrary.activeWindow;
|
|
window = _glfwLibrary.activeWindow;
|
|
if (window)
|
|
if (window)
|
|
{
|
|
{
|
|
@@ -1127,13 +1150,18 @@ void _glfwPlatformPollEvents(void)
|
|
|
|
|
|
void _glfwPlatformWaitEvents(void)
|
|
void _glfwPlatformWaitEvents(void)
|
|
{
|
|
{
|
|
- XEvent event;
|
|
|
|
|
|
+ int fd;
|
|
|
|
+ fd_set fds;
|
|
|
|
+
|
|
|
|
+ fd = ConnectionNumber(_glfwLibrary.X11.display);
|
|
|
|
|
|
- // Block waiting for an event to arrive
|
|
|
|
- XNextEvent(_glfwLibrary.X11.display, &event);
|
|
|
|
- XPutBackEvent(_glfwLibrary.X11.display, &event);
|
|
|
|
|
|
+ FD_ZERO(&fds);
|
|
|
|
+ FD_SET(fd, &fds);
|
|
|
|
+
|
|
|
|
+ XFlush(_glfwLibrary.X11.display);
|
|
|
|
|
|
- _glfwPlatformPollEvents();
|
|
|
|
|
|
+ if (select(fd + 1, &fds, NULL, NULL, NULL) > 0)
|
|
|
|
+ _glfwPlatformPollEvents();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|