diff options
author | Javier <dev.git@javispedro.com> | 2015-01-25 21:16:55 +0100 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2015-01-25 21:16:55 +0100 |
commit | 931afac3e1b29167489136f0fff4287385891659 (patch) | |
tree | 91db8bcaef7a38e50d22c5666e4f498f25610574 | |
parent | efad78e4d395a84ac3c8b39b2acb6625e8ff1563 (diff) | |
download | mdock-931afac3e1b29167489136f0fff4287385891659.tar.gz mdock-931afac3e1b29167489136f0fff4287385891659.zip |
raise the most recently active window when clicking on item
-rw-r--r-- | libmdock/mdock-item.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/libmdock/mdock-item.c b/libmdock/mdock-item.c index 4ae68f2..f4b06f1 100644 --- a/libmdock/mdock-item.c +++ b/libmdock/mdock-item.c @@ -31,8 +31,6 @@ struct _MDockItemPrivate guint icon_size; GdkPixbuf *icon; GList *windows; - - WnckWindow *last_active; }; G_DEFINE_TYPE (MDockItem, mdock_item, GTK_TYPE_WIDGET) @@ -367,9 +365,6 @@ void mdock_item_add_window(MDockItem *self, WnckWindow *window) void mdock_item_remove_window(MDockItem *self, WnckWindow *window) { self->priv->windows = g_list_remove(self->priv->windows, window); - if (self->priv->last_active == window) { - self->priv->last_active = NULL; - } if (!self->priv->windows) { // If there are no windows left, // we want to redraw in order to remove the "active" indicator. @@ -380,8 +375,17 @@ void mdock_item_remove_window(MDockItem *self, WnckWindow *window) void mdock_item_set_last_active_window(MDockItem *self, WnckWindow *window) { - g_return_if_fail(g_list_find(self->priv->windows, window)); - self->priv->last_active = window; + g_return_if_fail(self->priv->windows); + if (self->priv->windows->data == window) { + return; // Nothing to do + } + + // Move the last active window to the head of the window list. + GList *l = g_list_find(self->priv->windows, window); + g_return_if_fail(l); + + self->priv->windows = g_list_remove_link(self->priv->windows, l); + self->priv->windows = g_list_concat(l, self->priv->windows); } gint mdock_item_get_num_windows(MDockItem *self) |