int _glfwPlatformInit(void) { if (!_glfwInitThreadLocalStorageWin32()) return GLFW_FALSE; // To make SetForegroundWindow work as we want, we need to fiddle // with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early // as possible in the hope of still being the foreground process) SystemParametersInfoW(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &_glfw.win32.foregroundLockTimeout, 0); SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0), SPIF_SENDCHANGE); if (!loadLibraries()) return GLFW_FALSE; createKeyTables(); if (_glfw_SetProcessDPIAwareness) _glfw_SetProcessDPIAwareness(PROCESS_PER_MONITOR_DPI_AWARE); else if (_glfw_SetProcessDPIAware) _glfw_SetProcessDPIAware(); if (!_glfwRegisterWindowClassWin32()) return GLFW_FALSE; _glfw.win32.helperWindow = createHelperWindow(); if (!_glfw.win32.helperWindow) return GLFW_FALSE; _glfwPlatformPollEvents(); #if defined(_GLFW_WGL) if (!_glfwInitWGL()) return GLFW_FALSE; #elif defined(_GLFW_EGL) if (!_glfwInitEGL()) return GLFW_FALSE; #endif _glfwInitTimerWin32(); _glfwInitJoysticksWin32(); return GLFW_TRUE; }
int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { if (window->monitor) { GLFWvidmode mode; _glfwPlatformGetVideoMode(window->monitor, &mode); mir_surface_set_state(window->mir.surface, mir_surface_state_fullscreen); if (wndconfig->width > mode.width || wndconfig->height > mode.height) { _glfwInputError(GLFW_PLATFORM_ERROR, "Mir: Requested surface size too large: %ix%i", wndconfig->width, wndconfig->height); return GLFW_FALSE; } } window->mir.width = wndconfig->width; window->mir.height = wndconfig->height; window->mir.currentCursor = NULL; if (!createSurface(window)) return GLFW_FALSE; window->mir.window = mir_buffer_stream_get_egl_native_window( mir_surface_get_buffer_stream(window->mir.surface)); if (ctxconfig->client != GLFW_NO_API) { if (!_glfwInitEGL()) return GLFW_FALSE; if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) return GLFW_FALSE; } return GLFW_TRUE; }
int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { if (!createNativeWindow(window, wndconfig)) return GLFW_FALSE; if (ctxconfig->client != GLFW_NO_API) { if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API) { if (!_glfwInitWGL()) return GLFW_FALSE; if (!_glfwCreateContextWGL(window, ctxconfig, fbconfig)) return GLFW_FALSE; } else { if (!_glfwInitEGL()) return GLFW_FALSE; if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) return GLFW_FALSE; } } if (window->monitor) { _glfwPlatformShowWindow(window); _glfwPlatformFocusWindow(window); if (!acquireMonitor(window)) return GLFW_FALSE; centerCursor(window); } return GLFW_TRUE; }
int _glfwPlatformInit(void) { #if !defined(X_HAVE_UTF8_STRING) // HACK: If the current locale is C, apply the environment's locale // This is done because the C locale breaks wide character input if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0) setlocale(LC_CTYPE, ""); #endif XInitThreads(); _glfw.x11.display = XOpenDisplay(NULL); if (!_glfw.x11.display) { const char* display = getenv("DISPLAY"); if (display) { _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to open display %s", display); } else { _glfwInputError(GLFW_PLATFORM_ERROR, "X11: The DISPLAY environment variable is missing"); } return GLFW_FALSE; } _glfw.x11.screen = DefaultScreen(_glfw.x11.display); _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen); _glfw.x11.context = XUniqueContext(); if (!initExtensions()) return GLFW_FALSE; _glfw.x11.cursor = createHiddenCursor(); if (XSupportsLocale()) { XSetLocaleModifiers(""); _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL); if (_glfw.x11.im) { if (!hasUsableInputMethodStyle()) { XCloseIM(_glfw.x11.im); _glfw.x11.im = NULL; } } } if (!_glfwInitThreadLocalStoragePOSIX()) return GLFW_FALSE; #if defined(_GLFW_GLX) if (!_glfwInitGLX()) return GLFW_FALSE; #elif defined(_GLFW_EGL) if (!_glfwInitEGL()) return GLFW_FALSE; #endif if (!_glfwInitJoysticksLinux()) return GLFW_FALSE; _glfwInitTimerPOSIX(); return GLFW_TRUE; }