Skip to content

Commit bda9fc4

Browse files
committed
GPU Wayland Display: Refactoring for correct windows / pixel sizes with HighDPI screen and scaling, fixed maximized windows, several other fixes by Claude
1 parent 527b698 commit bda9fc4

12 files changed

Lines changed: 429 additions & 124 deletions

‎GPU/GPUTracking/Definitions/GPUSettingsList.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ AddOption(camLookOrigin, bool, false, "", 0, "Make the camera look at the origin
499499
AddOption(camYUp, bool, false, "", 0, "Orient the camera such that the y-axis is always upwards")
500500
AddOption(cameraMode, int32_t, 0, "", 0, "Camera mode")
501501
AddOption(fullScreen, bool, false, "", 0, "Full Screen")
502-
AddOption(maximized, bool, false, "", 0, "Full Screen")
502+
AddOption(maximized, bool, true, "", 0, "Maximized window")
503503
AddOption(openGLCore, bool, false, "", 0, "Use renderer path for OpenGL core profile")
504504
AddOption(drawQualityMSAA, int32_t, 0, "", 0, "MultiSample Anti Aliasing")
505505
AddOption(drawQualityDownsampleFSAA, int32_t, 0, "", 0, "Downsampling Anti Aliasing")

‎GPU/GPUTracking/display/GPUDisplay.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class GPUTPCGMPropagator;
4141

4242
class GPUDisplay : public GPUDisplayInterface
4343
{
44+
friend class GPUDisplayFrontend;
45+
4446
public:
4547
GPUDisplay(GPUDisplayFrontend* frontend, GPUChainTracking* chain, GPUQA* qa, const GPUParam* param = nullptr, const GPUCalibObjectsConst* calib = nullptr, const GPUSettingsDisplay* config = nullptr, const GPUSettingsProcessing* proc = nullptr);
4648
GPUDisplay(const GPUDisplay&) = delete;

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
#include "GPUDisplayFrontendGlut.h"
3232
#endif
3333
#ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND
34-
#include "GPUDisplayFrontendWayland.h"
34+
namespace o2::gpu
35+
{
36+
GPUDisplayFrontend* createGPUDisplayFrontendWayland();
37+
} // namespace o2::gpu
3538
#endif
3639
#include "GPUDisplayFrontendNone.h"
3740

@@ -171,7 +174,7 @@ GPUDisplayFrontend* GPUDisplayFrontend::getFrontend(const char* type)
171174
#endif
172175
#ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND
173176
if (strcmp(type, "wayland") == 0 || (strcmp(type, "auto") == 0 && getenv("XDG_SESSION_TYPE") && strcmp(getenv("XDG_SESSION_TYPE"), "wayland") == 0)) {
174-
return new GPUDisplayFrontendWayland;
177+
return createGPUDisplayFrontendWayland();
175178
} else
176179
#endif
177180
#ifdef GPUCA_BUILD_EVENT_DISPLAY_GLUT
@@ -192,6 +195,21 @@ GPUDisplayBackend* GPUDisplayFrontend::backend()
192195
return mDisplay->backend();
193196
}
194197

198+
void GPUDisplayFrontend::setWindowState(bool fullScreen, bool maximized)
199+
{
200+
mDisplay->mCfgR.fullScreen = fullScreen;
201+
mDisplay->mCfgR.maximized = maximized;
202+
}
203+
204+
void GPUDisplayFrontend::applyInitialWindowState()
205+
{
206+
if (mDisplay->cfgR().fullScreen) {
207+
SwitchFullscreen(true);
208+
} else if (mDisplay->cfgR().maximized) {
209+
ToggleMaximized(true);
210+
}
211+
}
212+
195213
int32_t& GPUDisplayFrontend::drawTextFontSize()
196214
{
197215
return mDisplay->drawTextFontSize();

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontend.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
6262
GPUDisplayBackend* backend();
6363
static GPUDisplayFrontend* getFrontend(const char* type);
6464
virtual void getSize(int32_t& width, int32_t& height) { width = height = 0; }
65+
virtual float getDisplayScale() const { return 1.f; } // HiDPI scale factor: physical pixels per logical pixel, text positions and sizes are scaled by it
6566
virtual int32_t getVulkanSurface(void* instance, void* surface) { return 1; }
6667
virtual uint32_t getReqVulkanExtensions(const char**& p) { return 0; };
6768

@@ -150,6 +151,8 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
150151
int32_t InitDisplay(bool initFailure = false); // Callback to initialize the GL Display (to be called in StartDisplay)
151152
void ExitDisplay(); // Callback to clean up the GL Display
152153
int32_t& drawTextFontSize();
154+
void setWindowState(bool fullScreen, bool maximized); // Sync the settings if the window manager changed the window state
155+
void applyInitialWindowState(); // Switch to fullscreen / maximize at startup according to the settings
153156
};
154157
} // namespace o2::gpu
155158

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.cxx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ void GPUDisplayFrontendGlfw::cursorPos_callback(GLFWwindow* window, double x, do
229229

230230
void GPUDisplayFrontendGlfw::resize_callback(GLFWwindow* window, int32_t width, int32_t height) { me->ResizeScene(width, height); }
231231

232+
void GPUDisplayFrontendGlfw::maximize_callback(GLFWwindow* window, int32_t maximized) { me->setWindowState(glfwGetWindowMonitor(window) != nullptr, maximized); }
233+
232234
#ifndef GPUCA_STANDALONE
233235
void GPUDisplayFrontendGlfw::DisplayLoop()
234236
{
@@ -251,7 +253,6 @@ int32_t GPUDisplayFrontendGlfw::FrontendMain()
251253
}
252254
glfwSetErrorCallback(error_callback);
253255

254-
glfwWindowHint(GLFW_MAXIMIZED, 1);
255256
if (backend()->backendType() == GPUDisplayBackend::TYPE_VULKAN) {
256257
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
257258
}
@@ -277,6 +278,8 @@ int32_t GPUDisplayFrontendGlfw::FrontendMain()
277278
glfwSetScrollCallback(mWindow, scroll_callback);
278279
glfwSetCursorPosCallback(mWindow, cursorPos_callback);
279280
glfwSetWindowSizeCallback(mWindow, resize_callback);
281+
glfwSetWindowMaximizeCallback(mWindow, maximize_callback);
282+
applyInitialWindowState();
280283
if (backend()->backendType() == GPUDisplayBackend::TYPE_OPENGL) {
281284
glfwSwapInterval(1);
282285
}

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class GPUDisplayFrontendGlfw : public GPUDisplayFrontend
4949
static void scroll_callback(GLFWwindow* mWindow, double x, double y);
5050
static void cursorPos_callback(GLFWwindow* mWindow, double x, double y);
5151
static void resize_callback(GLFWwindow* mWindow, int32_t width, int32_t height);
52+
static void maximize_callback(GLFWwindow* mWindow, int32_t maximized);
5253
static int32_t GetKey(int32_t key);
5354
static void GetKey(int32_t keyin, int32_t scancode, int32_t mods, int32_t& keyOut, int32_t& keyPressOut);
5455

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ int32_t GPUDisplayFrontendGlut::FrontendMain()
259259
glutMotionFunc(mouseMoveFunc);
260260
glutPassiveMotionFunc(mouseMoveFunc);
261261
glutMouseWheelFunc(mMouseWheelFunc);
262-
ToggleMaximized(true);
262+
applyInitialWindowState();
263263

264264
pthread_mutex_lock(&mSemLockExit);
265265
mDisplayRunning = true;

0 commit comments

Comments
 (0)