From 6161c366b5c0aa4b7d69ac37f668898560af0f78 Mon Sep 17 00:00:00 2001 From: Martin Geier Date: Tue, 24 Dec 2013 23:08:54 +0100 Subject: [PATCH] Add Clickable Icons in Alt-tab Dialog Signed-off-by: Martin Geier --- src/cycle.c | 47 +++++++++++++++++++++++++++++++++-------------- src/tabwin.c | 49 +++++++++++++++++++++++++++++++++++++++++++++---- src/tabwin.h | 1 + 3 files changed, 79 insertions(+), 18 deletions(-) diff --git a/src/cycle.c b/src/cycle.c index b5e45f1..4dac6de 100644 --- a/src/cycle.c +++ b/src/cycle.c @@ -87,6 +87,18 @@ clientGetCycleRange (ScreenInfo *screen_info) return range; } +static void +clientUpdateWireframe(Client *c, ClientCycleData *data, gboolean cycling) +{ + if(cycling && c) + { + if (data->wireframe) + { + wireframeUpdate (c, data->wireframe); + } + } +} + static GList * clientCycleCreateList (Client *c) { @@ -328,19 +340,11 @@ clientCycleEventFilter (XEvent * xevent, gpointer data) } } - if (cycling) + clientUpdateWireframe(c, passdata, cycling); + + if(!c) { - if (c) - { - if (passdata->wireframe) - { - wireframeUpdate (c, passdata->wireframe); - } - } - else - { - cycling = FALSE; - } + cycling = FALSE; } } break; @@ -359,9 +363,24 @@ clientCycleEventFilter (XEvent * xevent, gpointer data) break; case ButtonPress: case ButtonRelease: - case EnterNotify: + { + c = tabwinSelectCoordinates(passdata->tabwin, xevent->xbutton.x, xevent->xbutton.y); + clientUpdateWireframe(c, passdata, cycling); + + if(c && xevent->type == ButtonRelease) + { + cycling = FALSE; + } + } + break; case MotionNotify: + { + c = tabwinSelectCoordinates(passdata->tabwin, xevent->xmotion.x, xevent->xmotion.y); + clientUpdateWireframe(c, passdata, cycling); + } break; + case EnterNotify: + break; default: status = EVENT_FILTER_CONTINUE; break; @@ -429,7 +448,7 @@ clientCycle (Client * c, XKeyEvent * ev) } g1 = myScreenGrabKeyboard (screen_info, ev->time); - g2 = myScreenGrabPointer (screen_info, LeaveWindowMask, None, ev->time); + g2 = myScreenGrabPointer (screen_info, LeaveWindowMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask, None, ev->time); if (!g1 || !g2) { diff --git a/src/tabwin.c b/src/tabwin.c index c130418..fbea1a4 100644 --- a/src/tabwin.c +++ b/src/tabwin.c @@ -590,11 +590,11 @@ tabwinSelectHead (Tabwin *t) { icon = GTK_WIDGET (widgets->data); if (((Client *) g_object_get_data (G_OBJECT(icon), "client-ptr-val")) == head->data) - { - tabwinSetSelected (tbw, icon); - gtk_widget_queue_draw (GTK_WIDGET(tbw)); - } + { + tabwinSetSelected (tbw, icon); + gtk_widget_queue_draw (GTK_WIDGET(tbw)); } + } } return tabwinGetSelected (t); @@ -710,6 +710,47 @@ tabwinSelectDelta (Tabwin *t, int row_delta, int col_delta) return tabwinChange2Selected (t, selected); } +Client * +tabwinSelectCoordinates (Tabwin *t, int x, int y) +{ + TabwinWidget *tbw; + gint wx, wy; + GList *widgets; + GtkWidget *icon; + + g_return_val_if_fail (t != NULL, NULL); + + tbw = (TabwinWidget *) t->tabwin_list->data; + + g_return_val_if_fail (tbw != NULL, NULL); + + gdk_window_get_origin (gtk_widget_get_window (tbw->container), &wx, &wy); + for (widgets = tbw->widgets; widgets; widgets = g_list_next (widgets)) + { + icon = GTK_WIDGET (widgets->data); + + if (x > wx + icon->allocation.x - WIN_ICON_BORDER && + x <= wx + icon->allocation.x + icon->allocation.width + WIN_ICON_BORDER && + y > wy + icon->allocation.y - WIN_ICON_BORDER && + y <= wy + icon->allocation.y + icon->allocation.height + WIN_ICON_BORDER) + { + GList *selected; + for (selected = *t->client_list; selected; selected = g_list_next (selected)) + { + if (((Client *) g_object_get_data (G_OBJECT(icon), "client-ptr-val")) == selected->data) + { + t->selected = selected; + } + } + tabwinSetSelected (tbw, icon); + gtk_widget_queue_draw (GTK_WIDGET(tbw)); + return tabwinGetSelected(t); + } + } + + return NULL; +} + void tabwinDestroy (Tabwin *t) { diff --git a/src/tabwin.h b/src/tabwin.h index 3511cca..2480e1f 100644 --- a/src/tabwin.h +++ b/src/tabwin.h @@ -76,6 +76,7 @@ Client *tabwinSelectHead (Tabwin *); Client *tabwinSelectNext (Tabwin *); Client *tabwinSelectPrev (Tabwin *); Client *tabwinSelectDelta (Tabwin *, int, int); +Client *tabwinSelectCoordinates (Tabwin *, int, int); Client *tabwinRemoveClient (Tabwin *, Client *); void tabwinDestroy (Tabwin *); -- 1.8.3.2