Skip to content
Snippets Groups Projects
Select Git revision
  • 5ae781586f1c88d977067804f28dc67844399b57
  • for-vairdraw default protected
  • multi-context-windows
3 results

x11_window.c

Blame
    • A. Tombs's avatar
      5ae78158
      X11: Handle Selection* events despite NULL window · 5ae78158
      A. Tombs authored
      X11 event processing currently discards events that can not be mapped to
      a current GLFW window.  However, this breaks clipboard functionality by
      failing to respond to SelectionRequest and SelectionClear events.
      
      This commit moves processing of these important clipboard events to
      before the NULL window test so that they are always considered.
      
      Fixes #961.
      Closes #963.
      5ae78158
      History
      X11: Handle Selection* events despite NULL window
      A. Tombs authored
      X11 event processing currently discards events that can not be mapped to
      a current GLFW window.  However, this breaks clipboard functionality by
      failing to respond to SelectionRequest and SelectionClear events.
      
      This commit moves processing of these important clipboard events to
      before the NULL window test so that they are always considered.
      
      Fixes #961.
      Closes #963.
    x11_window.c 83.48 KiB
    //========================================================================
    // GLFW 3.3 X11 - www.glfw.org
    //------------------------------------------------------------------------
    // Copyright (c) 2002-2006 Marcus Geelnard
    // Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
    //
    // This software is provided 'as-is', without any express or implied
    // warranty. In no event will the authors be held liable for any damages
    // arising from the use of this software.
    //
    // Permission is granted to anyone to use this software for any purpose,
    // including commercial applications, and to alter it and redistribute it
    // freely, subject to the following restrictions:
    //
    // 1. The origin of this software must not be misrepresented; you must not
    //    claim that you wrote the original software. If you use this software
    //    in a product, an acknowledgment in the product documentation would
    //    be appreciated but is not required.
    //
    // 2. Altered source versions must be plainly marked as such, and must not
    //    be misrepresented as being the original software.
    //
    // 3. This notice may not be removed or altered from any source
    //    distribution.
    //
    //========================================================================
    
    #include "internal.h"
    
    #include <X11/cursorfont.h>
    #include <X11/Xmd.h>
    
    #include <sys/select.h>
    
    #include <string.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <limits.h>
    #include <errno.h>
    #include <assert.h>
    
    // Action for EWMH client messages
    #define _NET_WM_STATE_REMOVE        0
    #define _NET_WM_STATE_ADD           1
    #define _NET_WM_STATE_TOGGLE        2
    
    // Additional mouse button names for XButtonEvent
    #define Button6            6
    #define Button7            7
    
    
    // Wait for data to arrive using select
    // This avoids blocking other threads via the per-display Xlib lock that also
    // covers GLX functions
    //
    static GLFWbool waitForEvent(double* timeout)
    {
        fd_set fds;
        const int fd = ConnectionNumber(_glfw.x11.display);
        int count = fd + 1;
    
    #if defined(__linux__)
        if (_glfw.linjs.inotify > fd)
            count = _glfw.linjs.inotify + 1;
    #endif
        for (;;)
        {
            FD_ZERO(&fds);
            FD_SET(fd, &fds);
    #if defined(__linux__)