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

Fixed issue #433 (layout sometimes ignores ratio) #442

Merged
merged 1 commit into from
Jun 1, 2021

Conversation

Vulcalien
Copy link
Member

Since the bug is well explained in the issue, let's talk about the patch.

I studied this problem for a few hours.
Apparently, this bug always occurs when there are two terminals (horizontal or vertical, doesn't matter).
It also occurs when there are more than two, but I didn't figure out any logical pattern.

Technical details

Basically, while loading a layout, the function set_position_by_ratio indirectly calls new_size (through Gtk.main_iteration()) which calls self.set_position(self.get_position()).
Only after set_position is executed the position is actually set (inside set_position_by_ratio), based on the ratio.
But the problem is that set_position takes self.get_position() as argument, while it still hasn't been set. So it calculates the new ratio, which is always about 0.5.

Fix

Initially, I wanted to remove self.set_position(self.get_position()) from new_size, but that would break stuff. (When splitting a terminal, the ratio has to be calculated again because of that line of separation between the terminals).
So I instead just store self.ratio on a temp variable and restore the value after Gtk.main_iteration() has done.

@mattrose
Copy link
Member

mattrose commented Jun 1, 2021

Thank you so much! I must admit I looked at that for a little while when it came in and it was not immediately obvious. I'll pull this down this evening and give it a once-over but you've explained very clearly what's gone wrong and how you fixed it, so I'm sure it'll get merged in very soon.

Thanks again!

@mattrose
Copy link
Member

mattrose commented Jun 1, 2021

Works brilliantly. This seems to be the second hack around inconsistent GTK calls, and now I think I know why they're getting rid of the GTK.Container() class in GTK4. It does mean that paned.py will need to be re-written from scratch when we go to GTK4, but that will probably be a good thing.

@mattrose mattrose merged commit 0133361 into gnome-terminator:master Jun 1, 2021
@mattrose
Copy link
Member

mattrose commented Jun 1, 2021

Any other bugs you feel like fixing? 😃

@Vulcalien
Copy link
Member Author

Sure! I've plenty of time, I'll try to fix some stuff

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

Successfully merging this pull request may close these issues.

None yet

2 participants