gerritdevriese / kzones

KDE KWin Script for snapping windows into zones
https://store.kde.org/p/1909220
GNU General Public License v3.0
238 stars 14 forks source link

Improved `oldGeometry` logic and performance #29

Closed codeswhite closed 11 months ago

codeswhite commented 1 year ago

The main idea behind this refactor is that saving geometry to the client.oldGeometry object should be done only once before "assigning" a client to a zone.

Therefore:

... moveClientToZone ...

if (client.zone === -1) {
    // Save client geometry before moving to a zone
    saveWindowGeometries(client)
}

This refactor started with the cleanup of onClientStartUserMovedResized Which turned out to contain obsolete code that was showing the OSD when the user first starts to move a window. After removing the obsolete code i made a performance improvement by moving the code that restores old geometry from the onClientStepUserMovedResized fucntion to the onClientStartUserMovedResized function.

This way we restore the geometry only once the window is "picked up" after it has been assigned to a zone (and given an oldGeometry property).

gerritdevriese commented 1 year ago

When I build this, the OSD isn't shown while moving a window (Ctrl+Alt+C works) Does it work on your system?

Also, the reason I am restoring the geometry in onClientStepUserMovedResized is that if I don't do that, the window doesn't stay under the cursor after unsnapping, otherwise it moves to the left resulting in weird behavior.