@ -56,26 +56,12 @@
# define _GLFW_XDND_VERSION 5
# define _GLFW_XDND_VERSION 5
// Wait for data to arrive on any of the specified file descriptors
// Wait for event data to arrive on any relevant file descriptor
// This avoids blocking other threads via the per-display Xlib lock that also
// covers GLX functions
//
//
static GLFWbool waitForEvent ( double * timeout )
static GLFWbool waitForData ( struct pollfd * fds , nfds_t count , double * timeout )
{
{
for ( ; ; )
for ( ; ; )
{
{
nfds_t count = 1 ;
struct pollfd fds [ 2 ] =
{
{ ConnectionNumber ( _glfw . x11 . display ) , POLLIN }
} ;
# if defined(__linux__)
if ( _glfw . joysticksInitialized )
fds [ count + + ] = ( struct pollfd ) { _glfw . linjs . inotify , POLLIN } ;
# endif
if ( timeout )
if ( timeout )
{
{
const int milliseconds = ( int ) ( * timeout * 1e3 ) ;
const int milliseconds = ( int ) ( * timeout * 1e3 ) ;
@ -105,6 +91,33 @@ static GLFWbool waitForEvent(double* timeout)
}
}
}
}
// Wait for event data to arrive on the X11 display socket
// This avoids blocking other threads via the per-display Xlib lock that also
// covers GLX functions
//
static GLFWbool waitForX11Event ( double * timeout )
{
struct pollfd fd = { ConnectionNumber ( _glfw . x11 . display ) , POLLIN } ;
return waitForData ( & fd , 1 , timeout ) ;
}
// Wait for event data to arrive on any event file descriptor
// This avoids blocking other threads via the per-display Xlib lock that also
// covers GLX functions
//
static GLFWbool waitForAnyEvent ( double * timeout )
{
nfds_t count = 1 ;
struct pollfd fds [ 2 ] = { { ConnectionNumber ( _glfw . x11 . display ) , POLLIN } } ;
# if defined(__linux__)
if ( _glfw . joysticksInitialized )
fds [ count + + ] = ( struct pollfd ) { _glfw . linjs . inotify , POLLIN } ;
# endif
return waitForData ( fds , count , timeout ) ;
}
// Waits until a VisibilityNotify event arrives for the specified window or the
// Waits until a VisibilityNotify event arrives for the specified window or the
// timeout period elapses (ICCCM section 4.2.2)
// timeout period elapses (ICCCM section 4.2.2)
//
//
@ -118,7 +131,7 @@ static GLFWbool waitForVisibilityNotify(_GLFWwindow* window)
VisibilityNotify ,
VisibilityNotify ,
& dummy ) )
& dummy ) )
{
{
if ( ! waitForEvent ( & timeout ) )
if ( ! waitForX11 Event ( & timeout ) )
return GLFW_FALSE ;
return GLFW_FALSE ;
}
}
@ -960,7 +973,7 @@ static const char* getSelectionString(Atom selection)
SelectionNotify ,
SelectionNotify ,
& notification ) )
& notification ) )
{
{
waitForEvent ( NULL ) ;
waitForX11 Event ( NULL ) ;
}
}
if ( notification . xselection . property = = None )
if ( notification . xselection . property = = None )
@ -996,7 +1009,7 @@ static const char* getSelectionString(Atom selection)
isSelPropNewValueNotify ,
isSelPropNewValueNotify ,
( XPointer ) & notification ) )
( XPointer ) & notification ) )
{
{
waitForEvent ( NULL ) ;
waitForX11 Event ( NULL ) ;
}
}
XFree ( data ) ;
XFree ( data ) ;
@ -1898,7 +1911,7 @@ void _glfwPushSelectionToManagerX11(void)
}
}
}
}
waitForEvent ( NULL ) ;
waitForX11 Event ( NULL ) ;
}
}
}
}
@ -2240,7 +2253,7 @@ void _glfwGetWindowFrameSizeX11(_GLFWwindow* window,
isFrameExtentsEvent ,
isFrameExtentsEvent ,
( XPointer ) window ) )
( XPointer ) window ) )
{
{
if ( ! waitForEvent ( & timeout ) )
if ( ! waitForX11 Event ( & timeout ) )
{
{
_glfwInputError ( GLFW_PLATFORM_ERROR ,
_glfwInputError ( GLFW_PLATFORM_ERROR ,
" X11: The window manager has a broken _NET_REQUEST_FRAME_EXTENTS implementation; please report this issue " ) ;
" X11: The window manager has a broken _NET_REQUEST_FRAME_EXTENTS implementation; please report this issue " ) ;
@ -2782,7 +2795,7 @@ void _glfwPollEventsX11(void)
void _glfwWaitEventsX11 ( void )
void _glfwWaitEventsX11 ( void )
{
{
while ( ! XPending ( _glfw . x11 . display ) )
while ( ! XPending ( _glfw . x11 . display ) )
waitForEvent ( NULL ) ;
waitForAny Event ( NULL ) ;
_glfwPollEventsX11 ( ) ;
_glfwPollEventsX11 ( ) ;
}
}
@ -2791,7 +2804,7 @@ void _glfwWaitEventsTimeoutX11(double timeout)
{
{
while ( ! XPending ( _glfw . x11 . display ) )
while ( ! XPending ( _glfw . x11 . display ) )
{
{
if ( ! waitForEvent ( & timeout ) )
if ( ! waitForAny Event ( & timeout ) )
break ;
break ;
}
}