Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get desktop bounds correctly on X11 #101

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

ajerick
Copy link

@ajerick ajerick commented Jul 21, 2024

Partially fix aseprite issue 3118.
X11 was never made with multi-monitor support in mind and, as a result, finding the workarea on multi-monitor setups is impossible without awful hacks. Instead, use the Xrandr X11 extension to query monitors, and their properties, to replace X11's display property in the operating-system level "Screen" implementation.

With this patch, screen bounds will be correct on multi-monitor setups in X11 however the illusive workarea property will mirror the bounds.

I agree that my contributions are licensed under the MIT License.

@ajerick
Copy link
Author

ajerick commented Jul 30, 2024

I fixed the issue with Windows and OSX builds not compiling (I accidentally included an X11-specific file into the global sources instead of the linux sources 😅), however the Ubuntu target failed to compile with the complaint that Xrandr was not found and I am not sure why. For the time being this compile error fix has been rebased onto the first commit I made.

@ajerick
Copy link
Author

ajerick commented Jul 30, 2024

Appending the libxrandr-devdependency to ubuntu-latest's build.yml should fix the compiling issue.

ajerick added 2 commits July 31, 2024 22:39
Use Xrandr's XRRGetMonitors function to find find the position,
bounds, and "main screen" status of all monitors.

On X11, there is no supported method to find the workarea of a monitor.
This includes the _NET_WORKAREA atom, which breaks multi-monitor
setups. This may not be an issue as most window managers aggressively
and correctly enforce their, albeit private, workarea for windows.
Introduce parity to X11 from Windows. Respect per-monitor bounds.
@ajerick
Copy link
Author

ajerick commented Aug 1, 2024

I have rebased the dependency into the build workflow as I suggested above and all targets build now!
I have saved the workflow run details in the hideous, split, and irrelevant to this PR "xrandr" branch if you wish to inquire me for details.
pitiful_split
build_works

@dacap dacap self-assigned this Aug 8, 2024
@dacap
Copy link
Member

dacap commented Aug 9, 2024

Thanks for this @ajerick, it will take me some time to test this PR with a proper scenario (multiple monitors), but I'm planning to merge it.

@dacap
Copy link
Member

dacap commented Sep 12, 2024

I was testing this PR to merge it (at least on beta branch), and it looks like we have some regressions in listscreens and multiple_windows examples:


In current main and beta branches, listscreens output:

Screens (1):
screen=0 bounds=(0 0 1920 1080) workarea=(0 32 1920 972)

multiple_windows screenshot:

Screenshot from 2024-09-12 19-41-36


With this PR, listscreens output (workarea == bounds, there is no menubar/taskbar area):

Screens (1):
main screen=0 bounds=(0 0 1920 1080) workarea=(0 0 1920 1080)

multiple_windows screenshot (windows are overlapped):

Screenshot from 2024-09-12 19-41-02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get desktop workarea correctly on Linux (we cannot use _NET_WORKAREA)
2 participants