void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement) { if (action == GLFW_CONNECTED) { _glfw.monitorCount++; _glfw.monitors = realloc(_glfw.monitors, sizeof(_GLFWmonitor*) * _glfw.monitorCount); if (placement == _GLFW_INSERT_FIRST) { memmove(_glfw.monitors + 1, _glfw.monitors, (_glfw.monitorCount - 1) * sizeof(_GLFWmonitor*)); _glfw.monitors[0] = monitor; } else _glfw.monitors[_glfw.monitorCount - 1] = monitor; } else if (action == GLFW_DISCONNECTED) { int i; _GLFWwindow* window; for (window = _glfw.windowListHead; window; window = window->next) { if (window->monitor == monitor) { int width, height, xoff, yoff; _glfwPlatformGetWindowSize(window, &width, &height); _glfwPlatformSetWindowMonitor(window, NULL, 0, 0, width, height, 0); _glfwPlatformGetWindowFrameSize(window, &xoff, &yoff, NULL, NULL); _glfwPlatformSetWindowPos(window, xoff, yoff); } } for (i = 0; i < _glfw.monitorCount; i++) { if (_glfw.monitors[i] == monitor) { _glfw.monitorCount--; memmove(_glfw.monitors + i, _glfw.monitors + i + 1, (_glfw.monitorCount - i) * sizeof(_GLFWmonitor*)); break; } } } if (_glfw.callbacks.monitor) _glfw.callbacks.monitor((GLFWmonitor*) monitor, action); if (action == GLFW_DISCONNECTED) _glfwFreeMonitor(monitor); }
GLFWAPI void GLFWAPIENTRY glfwSetWindowPos( int x, int y ) { if( !_glfwInitialized || !_glfwWin.opened || _glfwWin.fullscreen || _glfwWin.iconified ) { return; } // Set window position _glfwPlatformSetWindowPos( x, y ); }
GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos) { _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); _GLFW_REQUIRE_INIT(); if (window->monitor) return; _glfwPlatformSetWindowPos(window, xpos, ypos); }
GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos) { _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT(); if (window->monitor) { _glfwInputError(GLFW_INVALID_VALUE, "Full screen windows cannot be moved"); return; } _glfwPlatformSetWindowPos(window, xpos, ypos); }
// Enter fullscreen mode // static void enterFullscreenMode(_GLFWwindow* window) { if (_glfw.x11.saver.count == 0) { // Remember old screen saver settings XGetScreenSaver(_glfw.x11.display, &_glfw.x11.saver.timeout, &_glfw.x11.saver.interval, &_glfw.x11.saver.blanking, &_glfw.x11.saver.exposure); // Disable screen saver XSetScreenSaver(_glfw.x11.display, 0, 0, DontPreferBlanking, DefaultExposures); } _glfw.x11.saver.count++; _glfwSetVideoMode(window->monitor, &window->videoMode); if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR) { const unsigned long value = 1; XChangeProperty(_glfw.x11.display, window->x11.handle, _glfw.x11.NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, PropModeReplace, (unsigned char*) &value, 1); } if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN) { int x, y; _glfwPlatformGetMonitorPos(window->monitor, &x, &y); _glfwPlatformSetWindowPos(window, x, y); if (_glfw.x11.NET_ACTIVE_WINDOW) { // Ask the window manager to raise and focus the GLFW window // Only focused windows with the _NET_WM_STATE_FULLSCREEN state end // up on top of all other windows ("Stacking order" in EWMH spec) XEvent event; memset(&event, 0, sizeof(event)); event.type = ClientMessage; event.xclient.window = window->x11.handle; event.xclient.format = 32; // Data is 32-bit longs event.xclient.message_type = _glfw.x11.NET_ACTIVE_WINDOW; event.xclient.data.l[0] = 1; // Sender is a normal application event.xclient.data.l[1] = 0; // We don't really know the timestamp XSendEvent(_glfw.x11.display, _glfw.x11.root, False, SubstructureNotifyMask | SubstructureRedirectMask, &event); } // Ask the window manager to make the GLFW window a fullscreen window // Fullscreen windows are undecorated and, when focused, are kept // on top of all other windows XEvent event; memset(&event, 0, sizeof(event)); event.type = ClientMessage; event.xclient.window = window->x11.handle; event.xclient.format = 32; // Data is 32-bit longs event.xclient.message_type = _glfw.x11.NET_WM_STATE; event.xclient.data.l[0] = _NET_WM_STATE_ADD; event.xclient.data.l[1] = _glfw.x11.NET_WM_STATE_FULLSCREEN; event.xclient.data.l[2] = 0; // No secondary property event.xclient.data.l[3] = 1; // Sender is a normal application XSendEvent(_glfw.x11.display, _glfw.x11.root, False, SubstructureNotifyMask | SubstructureRedirectMask, &event); } else if (window->x11.overrideRedirect) { // In override-redirect mode we have divorced ourselves from the // window manager, so we need to do everything manually GLFWvidmode mode; _glfwPlatformGetVideoMode(window->monitor, &mode); XRaiseWindow(_glfw.x11.display, window->x11.handle); XSetInputFocus(_glfw.x11.display, window->x11.handle, RevertToParent, CurrentTime); XMoveWindow(_glfw.x11.display, window->x11.handle, 0, 0); XResizeWindow(_glfw.x11.display, window->x11.handle, mode.width, mode.height); } }