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

re-evaluate switch from event based operation #28

Open
ZimbiX opened this issue Apr 10, 2022 · 4 comments
Open

re-evaluate switch from event based operation #28

ZimbiX opened this issue Apr 10, 2022 · 4 comments
Labels
code hygiene Changes to improve the code or internal behavior

Comments

@ZimbiX
Copy link

ZimbiX commented Apr 10, 2022

There is a slight delay where the window is its initial size/position before Smart Auto Move changes it. This applies to non-maximised windows (it seems that Gnome remembers the maximised state by itself; so that's fast). In coming from Maxi, I was expecting the resize to be quicker.

I can see that this extension uses polling, from playing with the 'sync frequency' setting (when setting this to 5000ms, there can be a few seconds before a new window is resized), and looking at the source. I tried reducing the polling interval from the default of 100ms, but it has a minimum of 50ms, which does not eliminate the stutter. At that polling rate, the CPU use of gnome-shell is ~10% higher than with the extension disabled, which is not great.

Would it be possible to switch over to being event-based? Maxi is event-based, but that only has to listen for window creation, not also having to deal with saving window sizes; but perhaps there are resize/maximise/unmaximise events?

Thanks for making this extension =)

@ZimbiX
Copy link
Author

ZimbiX commented Apr 10, 2022

I think I found the docs for the necessary signals:

@khimaros
Copy link
Owner

thank you for the suggestion, @ZimbiX

the first implementation of smart-auto-move actually used this strategy. you can see the change that started to move away from signal based window management here: 00c189e

there are limitations with the shell extension framework that made it problematic. in particular, if you change the properties of a window inside of an event instead of in the mainloop, they do not hold.

from the original documentation: "changing a window's frame rect inside of [the windows-changed] handler does not actually move the window, so it instead needs to happen in the Mainloop." -- which also required an arbitrary timeout.

managing this inconsistency resulted in some race conditions and technical debt, so i switched to the polling method.

@ZimbiX
Copy link
Author

ZimbiX commented Apr 10, 2022

Interesting. Thanks for the context!

It looks like Maxi waits on a subsequent event, focus before maximising - would that help? Or does maximising not have the same restrictions as resizing?

On the saving side of things, was there a reason that needed to use polling too?

@khimaros khimaros added the code hygiene Changes to improve the code or internal behavior label Jun 12, 2022
@khimaros khimaros changed the title Avoid resize delay and reduce CPU usage by listening for events rather than polling re-evaluate switch from event based operation May 13, 2023
@khimaros
Copy link
Owner

switching to an event based mechanism would most likely help with issues like the one mentioned in #31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code hygiene Changes to improve the code or internal behavior
Projects
None yet
Development

No branches or pull requests

2 participants