Merge branch 'master' of github.com:elmindreda/glfw Conflicts: CMakeLists.txt src/egl_context.c
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5838b1c..96f322f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -30,6 +30,9 @@ find_package(OpenGL REQUIRED) endif() +set(CMAKE_THREAD_PREFER_PTHREAD OFF) +find_package(Threads REQUIRED) + #-------------------------------------------------------------------- # Enable all warnings on GCC, regardless of OS #-------------------------------------------------------------------- @@ -239,39 +242,8 @@ set(CMAKE_REQUIRED_LIBRARIES ${EGL_LIBRARY}) - if (_GLFW_X11) + if (UNIX) set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} egl") - - include(CheckFunctionExists) - - check_function_exists(eglGetProcAddress _GLFW_HAS_EGLGETPROCADDRESS) - - if (NOT _GLFW_HAS_EGLGETPROCADDRESS) - message(WARNING "No eglGetProcAddress found") - - # Check for dlopen support as a fallback - - find_library(DL_LIBRARY dl) - mark_as_advanced(DL_LIBRARY) - if (DL_LIBRARY) - set(CMAKE_REQUIRED_LIBRARIES ${DL_LIBRARY}) - else() - set(CMAKE_REQUIRED_LIBRARIES "") - endif() - - check_function_exists(dlopen _GLFW_HAS_DLOPEN) - - if (NOT _GLFW_HAS_DLOPEN) - message(FATAL_ERROR "No entry point retrieval mechanism found") - endif() - - if (DL_LIBRARY) - list(APPEND glfw_LIBRARIES ${DL_LIBRARY}) - set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -ldl") - endif() - endif() - elseif (_GLFW_WIN32) - set(_GLFW_HAS_EGLGETPROCADDRESS 1) endif() endif()
diff --git a/src/config.h.in b/src/config.h.in index d391fcd..61178f9 100644 --- a/src/config.h.in +++ b/src/config.h.in
@@ -72,9 +72,6 @@ // Define this to 1 if glXGetProcAddressEXT is available #cmakedefine _GLFW_HAS_GLXGETPROCADDRESSEXT -// Define this to 1 if eglGetProcAddress is available -#cmakedefine _GLFW_HAS_EGLGETPROCADDRESS - // The GLFW version as used by glfwGetVersionString #define _GLFW_VERSION_FULL "@GLFW_VERSION_FULL@"
diff --git a/src/egl_context.c b/src/egl_context.c index fc41f2c..eb2815f 100644 --- a/src/egl_context.c +++ b/src/egl_context.c
@@ -361,31 +361,6 @@ int _glfwInitOpenGL(void) { -#if defined(_GLFW_DLOPEN_LIBEGL) - int i; - char* libEGL_names[ ] = - { - "libEGL.so", - "libEGL.so.1", - "/usr/lib/libEGL.so", - "/usr/lib/libEGL.so.1", - NULL - }; - - for (i = 0; libEGL_names[i] != NULL; i++) - { - _glfw.egl.libEGL = dlopen(libEGL_names[i], RTLD_LAZY | RTLD_GLOBAL); - if (_glfw.egl.libEGL) - break; - } - - if (!_glfw.egl.libEGL) - { - _glfwInputError(GLFW_PLATFORM_ERROR, "EGL: Failed to find libEGL"); - return GL_FALSE; - } -#endif - _glfw.egl.display = eglGetDisplay(_GLFW_EGL_NATIVE_DISPLAY); if (_glfw.egl.display == EGL_NO_DISPLAY) { @@ -414,14 +389,6 @@ void _glfwTerminateOpenGL(void) { -#if defined(_GLFW_DLOPEN_LIBEGL) - if (_glfw.egl.libEGL != NULL) - { - dlclose(_glfw.egl.libEGL); - _glfw.egl.libEGL = NULL; - } -#endif - eglTerminate(_glfw.egl.display); } @@ -603,6 +570,6 @@ GLFWglproc _glfwPlatformGetProcAddress(const char* procname) { - return _glfw_eglGetProcAddress(procname); + return eglGetProcAddress(procname); }
diff --git a/src/egl_platform.h b/src/egl_platform.h index 6eeb9e5..065b49f 100644 --- a/src/egl_platform.h +++ b/src/egl_platform.h
@@ -43,17 +43,6 @@ #include <dlfcn.h> #endif -// We support two different ways for getting addresses for EGL -// extension functions: eglGetProcAddress and dlsym -#if defined(_GLFW_HAS_EGLGETPROCADDRESS) - #define _glfw_eglGetProcAddress(x) eglGetProcAddress(x) -#elif defined(_GLFW_HAS_DLOPEN) - #define _glfw_eglGetProcAddress(x) dlsym(_glfw.egl.libEGL, x) - #define _GLFW_DLOPEN_LIBEGL -#else - #error "No OpenGL entry point retrieval mechanism was enabled" -#endif - #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextEGL egl #define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryEGL egl @@ -87,9 +76,6 @@ GLboolean KHR_create_context; -#if defined(_GLFW_DLOPEN_LIBEGL) - void* libEGL; // dlopen handle for libEGL.so -#endif } _GLFWlibraryEGL;
diff --git a/src/win32_window.c b/src/win32_window.c index 40f9913..688d555 100644 --- a/src/win32_window.c +++ b/src/win32_window.c
@@ -715,47 +715,29 @@ const _GLFWwndconfig* wndconfig, const _GLFWfbconfig* fbconfig) { - DWORD dwStyle, dwExStyle; int positionX, positionY, fullWidth, fullHeight; POINT pos; WCHAR* wideTitle; - // Set common window styles - dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN; - dwExStyle = WS_EX_APPWINDOW; + // Set window styles common to all window modes + window->win32.dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + window->win32.dwExStyle = WS_EX_APPWINDOW; - // Set window style, depending on fullscreen mode + // Add mode-dependent window styles if (window->monitor) - { - dwStyle |= WS_POPUP; - - // Here's a trick for helping us getting window focus - // (SetForegroundWindow doesn't work properly under - // Win98/ME/2K/.NET/+) - /* - if (_glfw.Sys.WinVer != _GLFW_WIN_95 && - _glfw.Sys.WinVer != _GLFW_WIN_NT4 && - _glfw.Sys.WinVer != _GLFW_WIN_XP) - { - dwStyle |= WS_MINIMIZE; - } - */ - } + window->win32.dwStyle |= WS_POPUP; else { - dwStyle |= WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; + window->win32.dwStyle |= WS_OVERLAPPED | WS_CAPTION | + WS_SYSMENU | WS_MINIMIZEBOX; if (wndconfig->resizable) { - dwStyle |= (WS_MAXIMIZEBOX | WS_SIZEBOX); - dwExStyle |= WS_EX_WINDOWEDGE; + window->win32.dwStyle |= WS_MAXIMIZEBOX | WS_SIZEBOX; + window->win32.dwExStyle |= WS_EX_WINDOWEDGE; } } - // Remember window styles (used by getFullWindowSize) - window->win32.dwStyle = dwStyle; - window->win32.dwExStyle = dwExStyle; - // Adjust window size for frame and title bar getFullWindowSize(window, window->width, window->height, &fullWidth, &fullHeight);
diff --git a/src/window.c b/src/window.c index cc2f559..124e7e4 100644 --- a/src/window.c +++ b/src/window.c
@@ -221,8 +221,11 @@ return NULL; } - // We need to copy these values before doing anything that can fail, as the - // window hints should be cleared after each call even if it fails + if (width <= 0 || height <= 0) + { + _glfwInputError(GLFW_INVALID_VALUE, "Invalid window size"); + return GL_FALSE; + } // Set up desired framebuffer config fbconfig.redBits = Max(_glfw.hints.redBits, 0); @@ -260,15 +263,6 @@ if (!_glfwIsValidContextConfig(&wndconfig)) return GL_FALSE; - // Save the currently current context so it can be restored later - previous = glfwGetCurrentContext(); - - if (width <= 0 || height <= 0) - { - _glfwInputError(GLFW_INVALID_VALUE, "Invalid window size"); - return GL_FALSE; - } - window = (_GLFWwindow*) calloc(1, sizeof(_GLFWwindow)); if (!window) { @@ -295,6 +289,9 @@ window->videoMode.blueBits = fbconfig.blueBits; } + // Save the currently current context so it can be restored later + previous = glfwGetCurrentContext(); + // Open the actual window and create its context if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig)) {
diff --git a/src/x11_init.c b/src/x11_init.c index cffbc7c..72fc90a 100644 --- a/src/x11_init.c +++ b/src/x11_init.c
@@ -395,7 +395,7 @@ // Check whether the running window manager is EWMH-compliant //======================================================================== -static void initEWMH(void) +static void detectEWMH(void) { Window* windowFromRoot = NULL; Window* windowFromChild = NULL; @@ -549,6 +549,9 @@ // the keyboard mapping. updateKeyCodeLUT(); + // Detect whether an EWMH-conformant window manager is running + detectEWMH(); + // Find or create selection property atom _glfw.x11.selection.property = XInternAtom(_glfw.x11.display, "GLFW_SELECTION", False); @@ -638,14 +641,11 @@ if (!_glfwInitOpenGL()) return GL_FALSE; - initEWMH(); - _glfw.x11.cursor = createNULLCursor(); if (!_glfwInitJoysticks()) return GL_FALSE; - // Start the timer _glfwInitTimer(); return GL_TRUE; @@ -672,7 +672,6 @@ terminateDisplay(); - // Free clipboard memory if (_glfw.x11.selection.string) free(_glfw.x11.selection.string); } @@ -708,12 +707,8 @@ " glXGetProcAddressARB" #elif defined(_GLFW_HAS_GLXGETPROCADDRESSEXT) " glXGetProcAddressEXT" -#elif defined(_GLFW_HAS_EGLGETPROCADDRESS) - " eglGetProcAddress" #elif defined(_GLFW_DLOPEN_LIBGL) " dlsym(libGL)" -#elif defined(_GLFW_DLOPEN_LIBEGL) - " dlsym(libEGL)" #else " no-extension-support" #endif
diff --git a/src/x11_platform.h b/src/x11_platform.h index 1ffb0e1..a1e5198 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h
@@ -124,7 +124,9 @@ Display* display; int screen; Window root; - Cursor cursor; // Invisible cursor for hidden cursor + + // Invisible cursor for hidden cursor mode + Cursor cursor; Atom wmDeleteWindow; // WM_DELETE_WINDOW atom Atom wmName; // _NET_WM_NAME atom @@ -161,10 +163,9 @@ int versionMinor; } xkb; - // Key code LUT (mapping X11 key codes to GLFW key codes) + // LUT for mapping X11 key codes to GLFW key codes int keyCodeLUT[256]; - // Screensaver data struct { GLboolean changed; int timeout; @@ -173,14 +174,12 @@ int exposure; } saver; - // Timer data struct { GLboolean monotonic; double resolution; uint64_t base; } timer; - // Selection data struct { Atom atom; Atom formats[_GLFW_CLIPBOARD_FORMAT_COUNT];
diff --git a/src/x11_window.c b/src/x11_window.c index e328f3b..7fb7747 100644 --- a/src/x11_window.c +++ b/src/x11_window.c
@@ -109,9 +109,9 @@ if (wndconfig->monitor == NULL) { - // The /only/ reason for setting the background pixel here is that - // otherwise our window won't get any decorations on systems using - // certain versions of Compiz on Intel hardware + // HACK: This is a workaround for windows without a background pixel + // not getting any decorations on certain older versions of Compiz + // running on Intel hardware wa.background_pixel = BlackPixel(_glfw.x11.display, _glfw.x11.screen); wamask |= CWBackPixel; @@ -400,13 +400,6 @@ XResizeWindow(_glfw.x11.display, window->x11.handle, window->width, window->height); } - - // HACK: Try to get window inside viewport (for virtual displays) by moving - // the cursor to the upper left corner (and then to the center) - // This hack should be harmless on saner systems as well - XWarpPointer(_glfw.x11.display, None, window->x11.handle, 0,0,0,0, 0,0); - XWarpPointer(_glfw.x11.display, None, window->x11.handle, 0,0,0,0, - window->width / 2, window->height / 2); }