Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root Tree State does not update #165

Open
justahuman1 opened this issue Oct 31, 2020 · 6 comments
Open

Root Tree State does not update #165

justahuman1 opened this issue Oct 31, 2020 · 6 comments

Comments

@justahuman1
Copy link

justahuman1 commented Oct 31, 2020

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!

@acrisci
Copy link
Member

acrisci commented Oct 31, 2020

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.

@justahuman1
Copy link
Author

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.

@acrisci
Copy link
Member

acrisci commented Nov 2, 2020

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.

@justahuman1
Copy link
Author

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.

@acrisci
Copy link
Member

acrisci commented Nov 10, 2020

I think this test illustrates the problem

@pytest.mark.asyncio
async def test_resize(self, i3):
ws1 = await self.fresh_workspace()
win = self.open_window()
await self.command_checked(f'[id="{win}"] floating enable')
# XXX: uncomment and it will fail
# ws2 = await self.fresh_workspace()
def height_width(c):
return c.rect.height + c.deco_rect.height, c.rect.width
async def do_resize(h, w):
result = await self.command_checked(f'[id="{win}"] resize set {w}px {h}px')
size1 = 200, 250
size2 = 350, 300
await do_resize(*size1)
con = (await i3.get_tree()).find_by_window(win)
await do_resize(*size2)
con2 = (await i3.get_tree()).find_by_window(win)
assert height_width(con) == size1
assert height_width(con2) == size2

@justahuman1
Copy link
Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants