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

Flicker/Lag when restoring floating window from Maximized state #149

Closed
skyneps opened this issue Apr 16, 2020 · 1 comment
Closed

Flicker/Lag when restoring floating window from Maximized state #149

skyneps opened this issue Apr 16, 2020 · 1 comment

Comments

@skyneps
Copy link
Contributor

skyneps commented Apr 16, 2020

When restoring WindowState of LayoutFloatingWindowControl externally (i.e. dragging the floating window from the top of the screen to restore instead of using the built in title bar button), the WindowState is set again. This results in flickering of the floating window as it struggles to go from Maximized -> Normal -> Maximized -> Normal.

Steps to repro:

  • Start TestApp
  • Float any window
  • Use title bar button to maximize
  • Use title bar button to restore (observe no flicker/lag)
  • Drag window using title bar to the top of screen to maximize
  • Drag window using title bar from maximized state so it automatically restores

Observation
Visible flickering and lag when restoring by dragging, especially on slower computers or when there is heavy layout updating. Might be harder to spot with the demo if you are using a higher-end computer.

Issue
I have pinpointed the problem to line 183 of the OnStateChanged override in LayoutFloatingWindowControl.cs:

WindowState = IsMaximized ? WindowState.Maximized : WindowState.Normal;

Here, I believe the issue is when WindowState is manually set rather than IsMaximized. When the user drags the window from a maximized state to restore, OnStateChanged will fire with WindowState == WindowState.Normal, but IsMaximized is still true.

I believe the intention was to update IsMaximized to match WindowState. I resolved the issue via the following changes:

lines 180-183, LayoutFloatingWindowControl.cs

if (WindowState == WindowState.Maximized)
    UpdateMaximizedState(true);
else
    WindowState = IsMaximized ? WindowState.Maximized : WindowState.Normal;

to:

UpdateMaximizedState(WindowState == WindowState.Maximized);

in order to ensure IsMaximized matches WindowState without causing multiple changes to 'WindowState'. The flickering and lag no longer happens after that.

Notes
I have not delved too deep into AvalonDock's floating window code to find out if there was a reason for needing to set WindowState in OnStateChanged, and have only tested the change by observing whether the flicker/lag was happening again.

Is there an intended reason for this behavior?

Dirkster99 added a commit that referenced this issue Apr 18, 2020
Flicker/Lag when restoring floating window from Maximized state
@Dirkster99
Copy link
Owner

Hi, thanx for the hint. I've tested your suggested change (see above reference on this ticket) with 2 monitors etc... and could not find any problem either. I cannot tell you much about the original intention since I am neither the original author nor the previous maintainer (for versions 2.0 - 3.2).

But sine this change is now part of the commit history and the ticket linkage on GitHub we'll be able to answer the question for original intention (here is another example) as long as this project continous to live here :-)

Thanx a lot for your input, Drk

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

No branches or pull requests

2 participants