summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-03-21 14:27:20 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-03-21 14:27:20 -0700
commite88c4259e05bc0b299d86f8237886db3c5210f41 (patch)
tree85481e4226365247b931275d2ee5b67feae781d6 /src
parent642b63f5a64b1dfda2ecd041fed3a008645d72cc (diff)
gtk_fb: s/configure-event/size-allocate/
The existing code made assumptions about the top-level window's configure-event dimensions reflecting the underlying GtkImage's dimensions. This happened to be true most of the time on X11 desktops, but client-side decorations have broken this assumption. Instead resize the fb on size-allocate, and get the size allocation out of the GtkImage widget *after* event propagation finishes. Thanks to chergert@redhat.com for assistance with quickly sorting this out and providing the patch, and elektron@halo.nu reporting the issue after testing on a librem5/phosh.
Diffstat (limited to 'src')
-rw-r--r--src/gtk_fb.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/gtk_fb.c b/src/gtk_fb.c
index 4520df7..c62614d 100644
--- a/src/gtk_fb.c
+++ b/src/gtk_fb.c
@@ -39,21 +39,23 @@ struct gtk_fb_page_t {
};
-/* called on "configure-event" for the fb's gtk window */
+/* called on "size-allocate" for the fb's gtk window */
static gboolean resized(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
gtk_fb_t *c = user_data;
+ GtkAllocation alloc;
- if (c->width != event->configure.width ||
- c->height != event->configure.height) {
+ gtk_widget_get_allocation(c->image, &alloc);
+ if (c->width != alloc.width ||
+ c->height != alloc.height) {
/* just cache the new dimensions and set a resized flag, these will
* become realized @ flip time where the fb is available by telling
* the fb to rebuild via fb_rebuild() and clearing the resized flag.
*/
- c->width = event->configure.width;
- c->height = event->configure.height;
+ c->width = alloc.width;
+ c->height = alloc.height;
c->resized = 1;
}
@@ -94,7 +96,7 @@ static int gtk_fb_init(const til_settings_t *settings, void **res_context)
c->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_realize(c->window);
- g_signal_connect(c->window, "configure-event", G_CALLBACK(resized), c);
+ g_signal_connect_after(c->window, "size-allocate", G_CALLBACK(resized), c);
*res_context = c;
© All Rights Reserved