bluescan / tacentview

An image and texture viewer for tga, png, apng, exr, dds, pvr, ktx, ktx2, astc, pkm, qoi, gif, hdr, jpg, tif, ico, webp, and bmp files. Uses Dear ImGui, OpenGL, and Tacent. Useful for game devs as it displays information like the presence of an alpha channel and querying specific pixels for their colour.
ISC License
371 stars 35 forks source link

Implement proper multi-monitor support for both platforms. #44

Open ClangPan opened 2 years ago

ClangPan commented 2 years ago

Hi, I recently got a dual monitor setup and noticed an annoying bug on Linux with KDE, the window always appear on the left-most monitor (which is my 2nd screen for me)

I actually identified the cause: before loading the window settings, the program clamps the position value, but it doesn't take into account that the origin point shift to the left-most point in a multi-monitor setup on Linux (at least on X11, I didn't test Windows or Wayland)

If the intent was to prevent the window from spawning out-of-bounds, it is unnecessary because this is done automatically (either by GLFW or X11, I don't know). It also does it for the size

Thank you again for the program!

bluescan commented 2 years ago

Hi Frousties,

So this one is a little tricky... with the additional snag that I don't have a dual monitor setup -- although I do run KDE / X11 (Kubuntu)

Notes: a) In windows 11, if I don't clamp, the window can end up off screen with no way to restore (set screen resolution large, drag window off to bottom right, close, change reolution to something small, open). b) This is not an issue with Linux. As you mentioned, it automatically fixes it up.

At the very least I could remove the clamps for Linux.. which woud presumably solve your problem. Another, maybe better, solution is to enumerate all the attached monitors and add up all the widths (but not heights) to get a total desktop width.

The benefit of the second approach is dual monitors would work on windows too. The downside is 1) If monitors have different reolutions, there will be rectanguar 'holes'. 2) To do it properly I'd need to know the arrangment of monitors (are the horizontal or vertical?). eg. If horizonal, you'd add widths and probably take the max height, if vertical vice-versa. I'm sure this info is available, but hard to get right without actually being able to test it.

Still, if it's supported in Linux it would be nice to support windows too. If I did the second approach I'd just assume the monitors where horizontally arranged For I'll probably do the Linux-only ifdef quickly and give you a commit hash when it's in.

ClangPan commented 2 years ago

Huh, weird behavior, would've expected Windows between the two to clamp windows automatically I think it would be fine to remove the clamp for now on Linux only, I'll make some tests on Windows to check how it behaves there

bluescan commented 2 years ago

Cool. Assuming you are able to buid the project, give d020aa415efb86d85fdcd04b09868053ee536823 a go. I still clamp minimum size, but that's all. I'm out for a bit.. but I think it will work.

ClangPan commented 2 years ago

Sorry for the very late reply (life got crazy), but it seems to be working perfectly, on Windows and on Linux

bluescan commented 2 years ago

NP. Thanks for testing. I'm renaming this issue to just refer to improving multi-monitor in general (esp in Windows). Want to keep the comments.