BunsenLabs / bunsen-utilities

https://pkg.bunsenlabs.org/debian/pool/main/b/bunsen-utilities/
GNU General Public License v3.0
31 stars 21 forks source link

Repeated snapping causes a cumulative offset #17

Closed capn-damo closed 5 years ago

capn-damo commented 9 years ago

Repeated snapping results in X/Y position of active window increasing by several px each time, after using ToggleMaximize.

Hjdskes commented 9 years ago

Can you test this, too? :smile: I think it is fixed, but I'm not sure how you reproduce this issue exactly.

Hjdskes commented 9 years ago

Now that I switched to using the parent window (https://github.com/Unia/bunsen-utilities/commit/5bc730a6eaacb89ce92ae6ffc2b4bd0cae17c982), this issue is back:

~/code/bunsen-utilities master $= 12:54:57
> ./bl-aerosnap --right
Restoring to: 201 115 852 615

~/code/bunsen-utilities master $= 12:54:58
> cat /tmp/bl-aerosnap-1000 
{}
~/code/bunsen-utilities master $= 12:55:01
> ./bl-aerosnap --right
Snapping window from : 201 115 852 629
Snapping window to: 683.0 0 683.0

~/code/bunsen-utilities master $= 12:55:03
> cat /tmp/bl-aerosnap-1000 
{"<class 'Xlib.display.Window'>(0x00200543)-0": [201, 115, 852, 629]}
~/code/bunsen-utilities master $= 12:55:09
> ./bl-aerosnap --right
Restoring to: 201 115 852 629

~/code/bunsen-utilities master $= 12:55:15
> cat /tmp/bl-aerosnap-1000 
{}
~/code/bunsen-utilities master $= 12:55:25
> ./bl-aerosnap --right
Snapping window from : 201 114 852 643
Snapping window to: 683.0 0 683.0

Cumulative snapping increases the height by (in my case, perhaps this is my window frame's height) 14 pixels every time.

Hjdskes commented 9 years ago

Indeed, this ugly hack resolves my issue:

diff --git a/bl-aerosnap b/bl-aerosnap
index 785b16c..de7cb6f 100755
--- a/bl-aerosnap
+++ b/bl-aerosnap
@@ -198,7 +198,7 @@ def get_window_geometry(win):

     :param win: the X Window object"""
     geom = win.get_geometry()
-    return [geom.x, geom.y, geom.width, geom.height]
+    return [geom.x, geom.y, geom.width, geom.height-14]

 def get_window_id(ewmh, win):
     """Returns a unique identifier for an X Window, made up of its "to string" and proces' PID.

Not sure what to do about this. Perhaps I need to use the x,y from the parent but the width,height from the actual window. Will test this now.

Hjdskes commented 9 years ago

It is definitely the window frames that are messing things up: undecorated windows work fine still.

Hjdskes commented 9 years ago

Latest push seems to have fixed the issue. However, I occasionally get this (bl-aerosnap says it is moving the window to the right half of the screen, but as you can see it does not occupy the full right half, even though the coordinates and dimensions reported are correct): Photo hosted by zimagez.com

johnraff commented 8 years ago

@Hjdskes is your code now ready to merge into deuterium?

Hjdskes commented 8 years ago

No, it's not done yet.

johnraff commented 5 years ago

For lack of interest, bl-aerosnap has been removed from bunsen-utilities.