Repository: qtile/qtile

Issue:
Fixed aspect ratio windows get too big if full screened
<!--
Please do not ask general questions here! There are [community
contact](https://github.com/qtile/qtile#community) options for that.
-->

# Issue description

Windows with fixed aspect ratio (like mpv) go over the screen area when full screened. I have 1920x1080 resolution screen, and if I full screen a mpv playing video with resolution 1920x1200, I get 1920x1200 screen instead of full screen, losing a part of the video. My guess is qtile forces the aspect ratio after resizing. Other window manager that also forces fixed aspect ratios for floating windows did not have that issue.

# Qtile version
Issue was not present int 0.17.0. It is present in current git version, hash 6799b6ae5ea09454e5d4ebeb82c0f0909af39439

# Stack traces

No meaningful logs from qtile. mpv when fullscreening:

```
[cplayer] Set property: fullscreen -> 1
[vo/gpu] Resize: 568x336
[vo/gpu] Window size: 568x336 (Borders: l=0 t=0 r=0 b=0)
[vo/gpu] Video source: 1920x1200 (1:1)
[vo/gpu] Video display: (0, 0) 1920x1200 -> (15, 0) 537x336
[vo/gpu] Video scale: 0.279687/0.280000
[vo/gpu] OSD borders: l=15 t=0 r=16 b=0
[vo/gpu] Video borders: l=15 t=0 r=16 b=0
[vo/gpu] Reported display depth: 8
[statusline] (Paused) AV: 00:00:01 / 00:10:41 (0%) A-V:  0.000
[cplayer] Set property: shared-script-properties -> 1
[vo/gpu] Resize: 1920x1200
[vo/gpu] Window size: 1920x1200 (Borders: l=0 t=0 r=0 b=0)
[vo/gpu] Video source: 1920x1200 (1:1)
[vo/gpu] Video display: (0, 0) 1920x1200 -> (0, 0) 1920x1200
[vo/gpu] Video scale: 1.000000/1.000000
[vo/gpu] OSD borders: l=0 t=0 r=0 b=0
[vo/gpu] Video borders: l=0 t=0 r=0 b=0
[vo/gpu] Reported display depth: 8
[cplayer] Set property: shared-script-properties -> 1
[statusline] (Paused) AV: 00:00:01 / 00:10:41 (0%) A-V:  0.000
[vo/gpu] Resize: 1920x1200
[vo/gpu] Window size: 1920x1200 (Borders: l=0 t=0 r=0 b=0)
[vo/gpu] Video source: 1920x1200 (1:1)
[vo/gpu] Video display: (0, 0) 1920x1200 -> (0, 0) 1920x1200
[vo/gpu] Video scale: 1.000000/1.000000
[vo/gpu] OSD borders: l=0 t=0 r=0 b=0
[vo/gpu] Video borders: l=0 t=0 r=0 b=0

```
# Configuration

Issue is present in default configuration.


Discussion:
I can confirm, I've seen this a few weeks after we merged the PAspect PR. We probably need to make an exception for fullscreen windows, or watch another flag. What other WM did you try that respect aspect but don't have this problem?
> What other WM did you try that respect aspect but don't have this problem?

That was i3wm.



Resolving patch:
diff --git a/libqtile/backend/x11/window.py b/libqtile/backend/x11/window.py
--- a/libqtile/backend/x11/window.py
+++ b/libqtile/backend/x11/window.py
@@ -769,7 +769,7 @@ def place(self, x, y, width, height, borderwidth, bordercolor,
             if "PMaxSize" in flags:
                 width = min(width, self.hints.get('max_width', 0)) or width
                 height = min(height, self.hints.get('max_height', 0)) or height
-            if "PAspect" in flags:
+            if "PAspect" in flags and self._float_state == FloatStates.FLOATING:
                 min_aspect = self.hints["min_aspect"]
                 max_aspect = self.hints["max_aspect"]
                 if width / height < min_aspect[0] / min_aspect[1]:


Test patch:
diff --git a/test/test_manager.py b/test/test_manager.py
--- a/test/test_manager.py
+++ b/test/test_manager.py
@@ -696,6 +696,18 @@ def size_hints():
     try:
         manager.create_window(size_hints)
         assert manager.c.window.info()['floating'] is True
+        info = manager.c.window.info()
+        assert info['width'] == 10
+        assert info['height'] == 10
+        manager.c.window.toggle_floating()
+        assert manager.c.window.info()['floating'] is False
+        info = manager.c.window.info()
+        assert info['width'] == 398
+        assert info['height'] == 578
+        manager.c.window.toggle_fullscreen()
+        info = manager.c.window.info()
+        assert info['width'] == 800
+        assert info['height'] == 600
     finally:
         w.kill_client()
         conn.finalize()