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

Fixed an issue with X11 window state judgment caused by the order of Atoms. #16921

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

walterlv
Copy link
Contributor

@walterlv walterlv commented Sep 4, 2024

What does the pull request do?

Let's see a atom list of a sample Avalonia window:

_NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_HIDDEN, _NET_WM_STATE_FULLSCREEN

Before this PR, the WindowState.Maximized condition will be true first and return. So the window WindowState property will be set to Maximized but the window is actually Hidden.

After this PR, the WindowState.Hidden condition will be checked first and return. So the window WindowState property will be set to Minimized and the window is actually Hidden.

What is the current behavior?

There is only one loop to check the atom list. The order of atoms will affect the result of the window state judgment.

What is the updated/expected behavior with this PR?

The window state judgment is more accurate.

How was the solution implemented (if it's not obvious)?

I changed the loop from a single one to per-atom specific.

Checklist

Breaking changes

Nothing.

Obsoletions / Deprecations

Fixed issues

@walterlv walterlv changed the title Fixed an issue with window state judgment caused by the order of Atoms. Fixed an issue with X11 window state judgment caused by the order of Atoms. Sep 4, 2024
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0051654-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@@ -763,6 +737,38 @@ private void OnPropertyChange(IntPtr atom, bool hasValue)

}

private WindowState AtomsToWindowState(IntPtr nitems, IntPtr* pitems)
{
for (var c = 0; c < nitems.ToInt32(); c++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please replace this with a single iteration and set local variable flags minimized/fullscreen/maximized? Then check the flags after the loop and return the correct state.

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

Successfully merging this pull request may close these issues.

4 participants