Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting when a GTK window is done moving/resizing by the user

I want to detect when the user finished re-sizing or moving the GTK window. Basically an equivalent of WM_EXITSIZEMOVE in windows.

I have looked at GTK detecting window resize from the user and am able to detect size/location changes using the configure-event; however because of how my other code is architect I want to know when the resizing is done. Almost like ValueChanged instead of ValueChanging event.

I was thinking if i could find out is the mouse button is released or not and then try to detect if it was the last event I got. But can't find a way to do that either for a window object.

like image 889
Manny Avatar asked Nov 02 '22 14:11

Manny


1 Answers

You could use a timeout function that gets called once the resizing is done. The timeout is in ms, you might want to play with the value to get a balance between the delay in calling resize_done and triggering it before the resize is really done.

#define TIMEOUT 250

gboolean resize_done (gpointer data)
{
  guint *id = data;
  *id = 0;
  /* call your existing code here */
  return FALSE;
}

gboolean on_configure_event (GtkWidget *window, GdkEvent *event, gpointer data)
{
  static guint id = 0;
  if (id)
    g_source_remove (id);
  id = g_timeout_add (TIMEOUT, resize_done, &id);
  return FALSE;
}
like image 150
Phillip Wood Avatar answered Nov 15 '22 05:11

Phillip Wood