Root Tree State does not update
justahuman1 opened this issue · 6 comments
Preface: I'm not sure if this is an issue with the IPC or a feature of i3 itself but a confirmation would be nice.
If you change the attributes of a window in another workspace, the new attributes are not reflected in get_tree
until that window has received focus.
Ex:
1.) Create a window in workspace 1
2.) Go to Workspace 2
3.) Open & run command in terminal 1 python shell (leave shell open)
from i3ipc import Connection
i3 = Connection()
rect = i3.get_tree().find_by_id(<id_of_wkspc1_window>).rect
print(rect.__dict__)
4.) Open & run command in terminal 2 in bash shell
i3-msg [con_id=<id_of_wkspc1_window>] resize set 75ppt 75ppt
5.) Still in workspace 2, run in terminal 1 in the same python shell
rect = i3.get_tree().find_by_id(<id_of_wkspc1_window>).rect
print(rect.__dict__)
The rect
still contains the same values, even though it has been manipulated. If you now focus on workspace 1, go back to workspace 2 and rerun the same python command:
rect = i3.get_tree().find_by_id(<id_of_wkspc1_window>).rect
print(rect.__dict__)
The height and width attributes of rect
are now changed.. I am thinking this might be a lazy evaluation by i3 itself rather than an issue with the IPC. But maybe I am incorrect.
I have also tried reinstantiating a new Connection
instance with every run to no avail.
Any advice here would be great. Thank you!
It's very likely an issue with i3 because all the tree info is rerendered every time you call get_tree()
with what the ipc gives us.
Try to reproduce the issue with i3-msg -t get_tree
alone. If you do that, you can post it on the i3 tracker and it can get fixed there.
Tested it with the the raw i3-msg
cli and it did indeed update. After generating both trees and seeing the difference, I reran the command with the IPC and the update did not propagate (I changed it multiple times from 400 -> 420 -> 480, but the IPC was stuck at the first run, 400, until I focused on the window, at which case, it updated to 480).
i3-msg updating the value from 400 -> 420 -> 480 (as exactly manipulated)
Image of IPC commands (reran multiple times after switching from 400 -> 420 -> 480) stuck at 400.
I wonder if I am doing something wrong, because I agree, it's simply an IPC get.. Is there a cache involved at any point? If no one else has found this bug, maybe the feature isn't too important. Up to you for consideration and let me know if the same occurs with your test.
There's no cache that I know of for this on the library side. If you want to look into the code, it's pretty simple. And there's a nice test suite too.
https://github.com/altdesktop/i3ipc-python/blob/master/test/test_window.py
I should get around to doing a triage at some point.
Awesome, I'll take a look sometime this week and can submit a pull request if I'm able to find the bug. Thanks for your help here.
I think this test illustrates the problem
i3ipc-python/test/aio/test_window.py
Lines 76 to 102 in 0ec537d
Unfortunately, I've had little time to address this (and it's not a priority based on the comments for i3-grid). Feel free to close this issue and add a TODO (up to you).