GtkPaned: setting position sometimes results in unexpected position
Steps to reproduce
When I click on Switch
button, then i want to change the paned orientation and set position to 50%. Some when in past that works, at this moment, i got position which you can see on screenshots.
Here is my simple application for python3 with gi:
from gi import require_version
require_version('Gtk', '3.0') # noqa
from gi.repository import Gtk
WIDTH = 800
HEIGHT = 400
class Window(Gtk.Window):
def __init__(self):
super(Window, self).__init__()
self.set_default_size(WIDTH, HEIGHT)
box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
self.add(box)
button = Gtk.Button.new_with_label("Switch")
button.connect("clicked", self.on_clicked)
box.pack_start(button, False, False, 0)
self.paned = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL)
box.pack_start(self.paned, True, True, 0)
left_scroll = Gtk.ScrolledWindow()
left_scroll.add(Gtk.TextView())
self.paned.pack1(left_scroll, True, False)
right_scroll = Gtk.ScrolledWindow()
right_scroll.add(Gtk.TextView())
self.paned.pack2(right_scroll, True, False)
def on_clicked(self, button):
if self.paned.get_orientation() == Gtk.Orientation.VERTICAL:
self.paned.set_orientation(Gtk.Orientation.HORIZONTAL)
self.paned.set_position(self.paned.get_allocated_width()/2)
else:
self.paned.set_orientation(Gtk.Orientation.VERTICAL)
self.paned.set_position(self.paned.get_allocated_height()/2)
win = Window()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()
Current behavior
When i try to set position to 50%, i count it from allocated_size/2. Yes the allocated size returns right number. After set this position, i still got right number, but after event (in next event for example), i got another bad position from paned.
Version information
Linux Debian 10 - Buster (Testing), stable in few next weeks on amd64 libgtk-3-0 3.24.5-1 gir1.2-gtk-3.0 3.24.5-1 python3-gi 3.30.4-1
Running on X11 with 2048x1152, but the same on Wayland, or on 3840x2160 with 200% scale.
I'm not sure when i start observe this problem, and i was thing that is in my application Formiko (https://github.com/ondratu/formiko), then I try in this simple test application with the same behavior.