Fixed issue #433 (layout sometimes ignores ratio)#442
Merged
mattrose merged 1 commit intognome-terminator:masterfrom Jun 1, 2021
Merged
Fixed issue #433 (layout sometimes ignores ratio)#442mattrose merged 1 commit intognome-terminator:masterfrom
mattrose merged 1 commit intognome-terminator:masterfrom
Conversation
Member
|
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! |
Member
|
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. |
Member
|
Any other bugs you feel like fixing? 😃 |
Member
Author
|
Sure! I've plenty of time, I'll try to fix some stuff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_ratioindirectly callsnew_size(through Gtk.main_iteration()) which callsself.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())fromnew_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.