MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / centerWindow

Function centerWindow

src/gui2/imhex_overrides/splash_window.cpp:115–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113
114
115 static void centerWindow(GLFWwindow *window) {
116 // Wayland does not allow applications to set the position of their windows
117 // so we skip centering the splash screen to avoid error message spamming
118 #if (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 + GLFW_VERSION_REVISION) >= 3400
119 if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND)
120 return;
121 #endif
122
123 // Get the primary monitor
124 GLFWmonitor *monitor = glfwGetPrimaryMonitor();
125 if (!monitor)
126 return;
127
128 // Get information about the monitor
129 const GLFWvidmode *mode = glfwGetVideoMode(monitor);
130 if (!mode)
131 return;
132
133 // Get the position of the monitor's viewport on the virtual screen
134 int monitorX, monitorY;
135 glfwGetMonitorPos(monitor, &monitorX, &monitorY);
136
137 // Get the window size
138 int windowWidth, windowHeight;
139 glfwGetWindowSize(window, &windowWidth, &windowHeight);
140
141 // Center the splash screen on the monitor
142 glfwSetWindowPos(window, monitorX + (mode->width - windowWidth) / 2, monitorY + (mode->height - windowHeight) / 2);
143 }
144
145 void WindowSplash::createTask(const Task& task) {
146 auto runTask = [&, task] {

Callers 1

fullFrameMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected