diff options
Diffstat (limited to 'libmdock/mdock-item.c')
-rw-r--r-- | libmdock/mdock-item.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libmdock/mdock-item.c b/libmdock/mdock-item.c index f4b06f1..5b6e0f9 100644 --- a/libmdock/mdock-item.c +++ b/libmdock/mdock-item.c @@ -79,8 +79,37 @@ static void mdock_item_update_icon(MDockItem *self) gtk_widget_queue_draw(GTK_WIDGET(self)); } +static void mdock_item_update_icon_geometry_for_window(MDockItem *self, WnckWindow *window) +{ + if (!gtk_widget_get_realized(GTK_WIDGET(self))) return; + + GdkWindow *self_window = gtk_widget_get_window(GTK_WIDGET(self)); + gint x, y, width, height; + gdk_window_get_origin(self_window, &x, &y); + gdk_window_get_size(self_window, &width, &height); + + wnck_window_set_icon_geometry(window, x, y, width, height); +} + +static void mdock_item_update_icon_geometry(MDockItem *self) +{ + if (!gtk_widget_get_realized(GTK_WIDGET(self))) return; + if (!self->priv->windows) return; + + GdkWindow *self_window = gtk_widget_get_window(GTK_WIDGET(self)); + gint x, y, width, height; + gdk_window_get_origin(self_window, &x, &y); + gdk_window_get_size(self_window, &width, &height); + + for (GList *l = self->priv->windows; l; l = g_list_next(l)) { + WnckWindow *window = WNCK_WINDOW(l->data); + wnck_window_set_icon_geometry(window, x, y, width, height); + } +} + static void mdock_item_realize(GtkWidget *widget) { + MDockItem *self = MDOCK_ITEM(widget); GdkWindowAttr attributes; guint attributes_mask; @@ -102,6 +131,8 @@ static void mdock_item_realize(GtkWidget *widget) gtk_widget_set_realized(widget, TRUE); widget->style = gtk_style_attach(widget->style, widget->window); + + mdock_item_update_icon_geometry(self); } static void mdock_item_size_request(GtkWidget *widget, GtkRequisition *requisition) @@ -115,6 +146,7 @@ static void mdock_item_size_allocate(GtkWidget *widget, GtkAllocation *allocatio self->priv->icon_size = MIN(allocation->width, allocation->height); GTK_WIDGET_CLASS(mdock_item_parent_class)->size_allocate(widget, allocation); mdock_item_update_icon(self); + mdock_item_update_icon_geometry(self); } static gboolean mdock_item_expose(GtkWidget *widget, GdkEventExpose *event) @@ -359,6 +391,7 @@ void mdock_item_add_window(MDockItem *self, WnckWindow *window) if (!self->priv->icon) { mdock_item_update_icon(self); } + mdock_item_update_icon_geometry_for_window(self, window); g_object_notify_by_pspec(G_OBJECT(self), obj_properties[PROP_N_WINDOWS]); } |