Bug 354993 - Maximize effect misbehaves when going from fullscreen to maximize
Summary: Maximize effect misbehaves when going from fullscreen to maximize
Status: RESOLVED DUPLICATE of bug 336467
Alias: None
Product: gwenview
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Gwenview Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-07 14:21 UTC by Mark
Modified: 2015-11-07 21:03 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark 2015-11-07 14:21:34 UTC
I think i can describe this without making a video of it, if it's still unclear i will just do that instead.

When the maximize effect is enabled (which it is by default) then maximizing a window is animated. Restoring back to the original size (unmaximize) is also animated. This works as long as fullscreen isn't involved.

For the steps to reproduce, take gwenview as an example since it's easy to enter fullscreen mode in there and reproduce this issue.

Reproducible: Always

Steps to Reproduce:
1. Open gwenview on an image. Make sure the gwenview isn _not_ in maximize state, Resize gwenview to some small window, that will give you the most annoying resize animation issue later on.
2. Now (when gwenview is small) hit the maximize icon (^) to make gwenview use all available screen space. You should now have a maximized gwenview.
3. Now double click the image in gwenview to enter fullscreen mode (or press CTRL + SHIFT + F). You will now see gwenview animating from the unmaximized size (it was maximized!) to the fullscreen size. Double pressing it again (to leave fullscreen and go back to maximize) gives you an animation from fullscreen to unmaximized where it's quickly jumping to maximized after the animation is done.


Expected Results:  
The animation should either go from maximize -> fullscreen (and back) or no animation at all
Comment 1 Thomas Lübking 2015-11-07 14:37:59 UTC
bug #336467 ?

Try some other client (though this may even work with gwenview), resize small, maximize, then use the alt+f3 menu (titlebar context) to set the window fullscreen (more actions) - same behavior?

You can also compare the outputs of "xprop _NET_WM_STATE" on either fullscreen window.
Comment 2 Mark 2015-11-07 14:59:51 UTC
Oke, tried that just now.

The states with gwenview:
Fullscreen:
_NET_WM_STATE(ATOM) = _NET_WM_STATE_FULLSCREEN

Maximized:
_NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ

MPV (it does not animate!):
Fullscreen:
_NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_FULLSCREEN

Maximized:
_NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ

VLC (it does not animate)
Fullscreen:
_NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_FULLSCREEN

Maximized:
_NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ


Does this mean that gwenview is missing the _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ attributes when in fullscreen mode and that's somehow preventing the animation to kick in?

I tried "tricking" fullscreen by doing it via kwin on for instance dolphin, and it also gets 3 flags then: _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_FULLSCREEN and didn't animate.
Comment 3 Thomas Lübking 2015-11-07 15:07:14 UTC
(In reply to Mark from comment #2)

> Does this mean that gwenview is missing the _NET_WM_STATE_MAXIMIZED_VERT,
> _NET_WM_STATE_MAXIMIZED_HORZ

No, it means gwenview does not just go fullscreen, but unmaximizes and /then/ goes fullscreen (from the unmaximized state - for whatever reason)
You see what you get *shrug*, the maximize effect could somehow cut animations when the window reaches the fullscreen state to cover this or something similar.

However gwenview is rather not doing itself a favor by this behavior, since it includes an additional resize/repaint (and resizing GL contexts isn't cheap, notably slow on the nvidia blob)

> I tried "tricking" fullscreen by doing it via kwin
Fyi, that's not "tricking", kwin simply provides a general way for every client to set the _NET_WM_STATE_FULLSCREEN flag.
Comment 4 Mark 2015-11-07 15:13:13 UTC
(In reply to Thomas Lübking from comment #3)
> (In reply to Mark from comment #2)
> 
> > Does this mean that gwenview is missing the _NET_WM_STATE_MAXIMIZED_VERT,
> > _NET_WM_STATE_MAXIMIZED_HORZ
> 
> No, it means gwenview does not just go fullscreen, but unmaximizes and
> /then/ goes fullscreen (from the unmaximized state - for whatever reason)
> You see what you get *shrug*, the maximize effect could somehow cut
> animations when the window reaches the fullscreen state to cover this or
> something similar.
> 
> However gwenview is rather not doing itself a favor by this behavior, since
> it includes an additional resize/repaint (and resizing GL contexts isn't
> cheap, notably slow on the nvidia blob)
> 
> > I tried "tricking" fullscreen by doing it via kwin
> Fyi, that's not "tricking", kwin simply provides a general way for every
> client to set the _NET_WM_STATE_FULLSCREEN flag.

And you already changed it to gwenview. Thank you for the quick help and diagnostics :)
Comment 5 Thomas Lübking 2015-11-07 15:21:35 UTC
Completely untested patch (no gwenview installed and smplayer doesn't start because that stupid SNI thing hangs forever, boosts the CPU and blocks the eventqueue - for a stupid systray nonsense.... *sigh*)


diff --git a/effects/maximize/package/contents/code/maximize.js b/effects/maximize/package/contents/code/maximize.js
index 3077ad4..556bd11 100644
--- a/effects/maximize/package/contents/code/maximize.js
+++ b/effects/maximize/package/contents/code/maximize.js
@@ -35,7 +35,7 @@ var maximizeEffect = {
             oldGeometry = window.olderGeometry;
         window.olderGeometry = window.oldGeometry;
         window.oldGeometry = newGeometry;
-        animate({
+        window.maximizeEffectA1 = animate({
             window: window,
             duration: maximizeEffect.duration,
             animations: [{
@@ -61,7 +61,7 @@ var maximizeEffect = {
             }]
         });
         if (!window.resize) {
-            animate({
+            window.maximizeEffectA2 = animate({
                 window: window,
                 duration: maximizeEffect.duration,
                 animations: [{
@@ -74,6 +74,10 @@ var maximizeEffect = {
     },
     geometryChange: function (window, oldGeometry) {
         "use strict";
+        cancel(window.maximizeEffectA1);
+        delete window.maximizeEffectA1;
+        cancel(window.maximizeEffectA2);
+        delete window.maximizeEffectA2;
         window.oldGeometry = window.geometry;
         window.olderGeometry = oldGeometry;
     },
Comment 6 Mark 2015-11-07 15:40:57 UTC
(In reply to Thomas Lübking from comment #5)
> Completely untested patch (no gwenview installed and smplayer doesn't start
> because that stupid SNI thing hangs forever, boosts the CPU and blocks the
> eventqueue - for a stupid systray nonsense.... *sigh*)
> 
> 
> diff --git a/effects/maximize/package/contents/code/maximize.js
> b/effects/maximize/package/contents/code/maximize.js
> index 3077ad4..556bd11 100644
> --- a/effects/maximize/package/contents/code/maximize.js
> +++ b/effects/maximize/package/contents/code/maximize.js
> @@ -35,7 +35,7 @@ var maximizeEffect = {
>              oldGeometry = window.olderGeometry;
>          window.olderGeometry = window.oldGeometry;
>          window.oldGeometry = newGeometry;
> -        animate({
> +        window.maximizeEffectA1 = animate({
>              window: window,
>              duration: maximizeEffect.duration,
>              animations: [{
> @@ -61,7 +61,7 @@ var maximizeEffect = {
>              }]
>          });
>          if (!window.resize) {
> -            animate({
> +            window.maximizeEffectA2 = animate({
>                  window: window,
>                  duration: maximizeEffect.duration,
>                  animations: [{
> @@ -74,6 +74,10 @@ var maximizeEffect = {
>      },
>      geometryChange: function (window, oldGeometry) {
>          "use strict";
> +        cancel(window.maximizeEffectA1);
> +        delete window.maximizeEffectA1;
> +        cancel(window.maximizeEffectA2);
> +        delete window.maximizeEffectA2;
>          window.oldGeometry = window.geometry;
>          window.olderGeometry = oldGeometry;
>      },

Nope, doesn't work.
No more resize animation at all after i apply that, yes the plugin is on.
Comment 7 Thomas Lübking 2015-11-07 20:50:45 UTC
Indeed - and now i know what "strict" implies =)

diff --git a/effects/maximize/package/contents/code/maximize.js b/effects/maximize/package/contents/code/maximize.js
index 3077ad4..d381a68 100644
--- a/effects/maximize/package/contents/code/maximize.js
+++ b/effects/maximize/package/contents/code/maximize.js
@@ -35,7 +35,7 @@ var maximizeEffect = {
             oldGeometry = window.olderGeometry;
         window.olderGeometry = window.oldGeometry;
         window.oldGeometry = newGeometry;
-        animate({
+        window.maximizeAnimation1 = animate({
             window: window,
             duration: maximizeEffect.duration,
             animations: [{
@@ -61,7 +61,7 @@ var maximizeEffect = {
             }]
         });
         if (!window.resize) {
-            animate({
+            window.maximizeAnimation2 =animate({
                 window: window,
                 duration: maximizeEffect.duration,
                 animations: [{
@@ -74,6 +74,17 @@ var maximizeEffect = {
     },
     geometryChange: function (window, oldGeometry) {
         "use strict";
+        if (window.maximizeAnimation1) {
+            if (window.geometry.width != window.oldGeometry.width ||
+                window.geometry.height != window.oldGeometry.height) {
+                cancel(window.maximizeAnimation1);
+                delete window.maximizeAnimation1;
+                if (window.maximizeAnimation2) {
+                    cancel(window.maximizeAnimation2);
+                    delete window.maximizeAnimation2;
+                }
+            }
+        }
         window.oldGeometry = window.geometry;
         window.olderGeometry = oldGeometry;
     },
Comment 8 Thomas Lübking 2015-11-07 21:03:15 UTC
Dupe downstream bug says this is QWidget::showFullscreen, so the clients aren't gonna fix it.

*** This bug has been marked as a duplicate of bug 336467 ***