Skip to content

Commit

Permalink
Round down X pos and height to nearest integer
Browse files Browse the repository at this point in the history
This fixes window draw issues when compositing is enabled for un-evenly
divisible X-axis dimensions (e.g. for thirds or sixths). This script
will return a float to kwin, which X11 will balk at. When trying to
resize windows to non-integer dimensions, the window will fail to be
drawn correctly and can not be interacted with.

---

The patch described in merge request linked below does not appear to fix
this particular issue, even though it _should_. I tested using the
Archlinux `kwin` package at 5.26.2.1-2 (which should include the patch;
see below link), but the issue still persisted.

So, instead, we can round our dimensions down to an integer before it's
even sent to kwin. This may be unnecessary in the future, if the
upstream bug is ever fixed, but it will not cause any harm except for an
undetectable waste of CPU cycles to floor() the dimensions.

---

Possible upstream fix: https://invent.kde.org/plasma/kwin/-/merge_requests/3123
Archlinux kwin package: archlinux/svntogit-packages@53384fe
  • Loading branch information
zhimsel committed Nov 3, 2022
1 parent b39ba73 commit 74012d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions contents/code/tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ var resizeAndMove = function(size_dividend, size_multiple, pos_dividend, pos_ind
geo.height = workGeo.height;

// horizontal position (from left edge)
geo.x = (workGeo.width / pos_dividend) * pos_index;
geo.x = Math.floor((workGeo.width / pos_dividend) * pos_index);

// width
geo.width = (workGeo.width / size_dividend) * size_multiple;
geo.width = Math.floor((workGeo.width / size_dividend) * size_multiple);

// HACK: unset "maximized" since kwin doesn't do it when you resize an already-maximized window with .geometry
activeClient.setMaximize(false, false);
Expand Down
2 changes: 1 addition & 1 deletion metadata.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ X-KDE-PluginInfo-Author=Zach Himsel
X-KDE-PluginInfo-Name=Ultrawide-Tiling
X-KDE-PluginKeyword=Ultrawide-Tiling
X-KDE-ParentComponents=Ultrawide-Tiling
X-KDE-PluginInfo-Version=1.0.1
X-KDE-PluginInfo-Version=1.0.2

X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
Expand Down

0 comments on commit 74012d3

Please sign in to comment.