GTK3 redraw GtkDrawingArea without it resizing

I have some GTK3 drawing areas that have their minimum height and widths defined.
When I try to programmatically redraw them ( with gtk_widget_queue_draw ) because the underlying data changes, the widget (and whole dialog) resizes to the defined sizes (even though I’ve resized it to be bigger).
The docs for the widget draw signal say that the widget redraw signal will call gtk_widget_get_allocated_width(). Presumably this is what is resetting the size.

How can I redraw but keep the existing window size (if it’s bigger than the minimum)??
Michael

Hello,

I’m not sure I understand the issue…

Do you resize the dialog manually, or does it resizes by itself?
In loop, or just once?
How and when do you set the (minimal) size of the drawing area?

The minimum size is set in the glade/xml (width-request/height-request).
I use the mouse to expand application window and the drawing widgets also expand. I get new data and call gtk_widget_queue_draw to redraw the drawing area. When I do this the whole application shrinks to the original size (as when the application starts).

              <object class="GtkDrawingArea" id="WID_DrawingArea_Plot_B">
                <property name="width-request">720</property>
                <property name="height-request">550</property>
                <property name="visible">True</property>
                <property name="can-focus">False</property>
                <property name="margin-start">4</property>
                <property name="margin-end">4</property>
                <property name="margin-top">4</property>
                <property name="margin-bottom">4</property>
                <signal name="button-press-event" handler="CB_DrawingArea_Plot_B_MouseButton" swapped="no"/>
                <signal name="draw" handler="CB_DrawingArea_B_Draw" swapped="no"/>
                <signal name="enter-notify-event" handler="CB_DrawingArea_B_MouseAction" swapped="no"/>
                <signal name="leave-notify-event" handler="CB_DrawingArea_B_MouseAction" swapped="no"/>
                <signal name="motion-notify-event" handler="CB_DrawingArea_B_MouseAction" swapped="no"/>
                <signal name="realize" handler="CB_DrawingArea_Plot_B_Realize" swapped="no"/>
              </object>

weird… it’s not supposed to happen…

Which exact version of gtk3?
x11, wayland or Windows?
Do you return values from the signals callbacks?

Its gtk3-3.24.39 (Xorg i.e X11 not Wayland)

I’m returning FALSE to the draw signal callbacks (but I just tried changing this to TRUE and there’s no difference)

What’s the parent widget of the DrawingAreas?

Would be nice if you could provide a minimal code sample reproducing the issue.

It turns out this was an ‘own goal’ :smirk_cat: Part of my code was actually setting the app window size - Gtk3 was doing what it was told!

1 Like

Good news! :slight_smile:

it’s good you could figure it out, because I was really out of ideas

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.