[Xfce4-commits] <xfwm4:ochosi/tabwin> Tabwin buttons are clickable
Simon Steinbeiss
noreply at xfce.org
Tue Nov 19 10:28:01 CET 2013
Updating branch refs/heads/ochosi/tabwin
to 380c869951d6da19eeccc41b62b7c5f9f920ec0d (commit)
from 1e3925e01cfe9584cc35cd46b96c5ee8b0db3523 (commit)
commit 380c869951d6da19eeccc41b62b7c5f9f920ec0d
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Tue Nov 19 06:50:52 2013 +0300
Tabwin buttons are clickable
Signed-off-by: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
src/cycle.c | 50 ++++++++++++++++++++++++++++++++++++++-----------
src/tabwin.c | 59 +++++++++++++++++++++++++++++++++++++++++++++-------------
src/tabwin.h | 1 +
3 files changed, 86 insertions(+), 24 deletions(-)
diff --git a/src/cycle.c b/src/cycle.c
index 6913ff4..d405d9b 100644
--- a/src/cycle.c
+++ b/src/cycle.c
@@ -361,14 +361,11 @@ clientCycleEventFilter (XEvent * xevent, gpointer data)
break;
case ButtonPress:
case ButtonRelease:
+ status = EVENT_FILTER_CONTINUE;
/* window of the event, we might accept it later */
mouse_window = xevent->xbutton.window;
break;
- case EnterNotify:
- case LeaveNotify:
- /* window of the event, we might accept it later */
- mouse_window = xevent->xcrossing.window;
- break;
+
default:
status = EVENT_FILTER_CONTINUE;
break;
@@ -376,13 +373,39 @@ clientCycleEventFilter (XEvent * xevent, gpointer data)
if (mouse_window != 0)
{
+ Client *c2 = NULL;
+
/* only accept events for the tab windows */
for (li = passdata->tabwin->tabwin_list; li != NULL; li = li->next)
+ {
if (GDK_WINDOW_XID (gtk_widget_get_window (li->data)) == mouse_window)
{
- status = EVENT_FILTER_CONTINUE;
+ c2 = tabwinSelectWidget (passdata->tabwin, li->data);
+ if (c2)
+ {
+ c = c2;
+ }
+
+ if (c)
+ {
+ if (passdata->wireframe)
+ {
+ wireframeUpdate (c, passdata->wireframe);
+ }
+ }
+ else
+ {
+ cycling = FALSE;
+ }
break;
}
+ }
+
+ if (c2 == NULL)
+ {
+ status = EVENT_FILTER_STOP;
+ cycling = FALSE;
+ }
}
if (!cycling)
@@ -391,6 +414,14 @@ clientCycleEventFilter (XEvent * xevent, gpointer data)
gtk_main_quit ();
}
+ if (status == EVENT_FILTER_STOP)
+ {
+ /* If there's any chance of a leftover grab, release it. This happens
+ * when the user clicks outside of the tabwin window area onto another
+ * window */
+ myScreenUngrabPointer (screen_info, myDisplayGetCurrentTime (display_info));
+ }
+
return status;
}
@@ -401,7 +432,7 @@ clientCycle (Client * c, XKeyEvent * ev)
DisplayInfo *display_info;
ClientCycleData passdata;
GList *client_list, *selected;
- gboolean g1, g2;
+ gboolean g1;
int key, modifier;
Client *c2;
@@ -448,15 +479,13 @@ clientCycle (Client * c, XKeyEvent * ev)
}
g1 = myScreenGrabKeyboard (screen_info, ev->time);
- g2 = myScreenGrabPointer (screen_info, EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonMotionMask | PointerMotionMask | ButtonReleaseMask, None, ev->time);
- if (!g1 || !g2)
+ if (!g1)
{
TRACE ("grab failed in clientCycle");
gdk_beep ();
myScreenUngrabKeyboard (screen_info, myDisplayGetCurrentTime (display_info));
- myScreenUngrabPointer (screen_info, myDisplayGetCurrentTime (display_info));
g_list_free (client_list);
return;
@@ -496,7 +525,6 @@ clientCycle (Client * c, XKeyEvent * ev)
g_list_free (client_list);
myScreenUngrabKeyboard (screen_info, myDisplayGetCurrentTime (display_info));
- myScreenUngrabPointer (screen_info, myDisplayGetCurrentTime (display_info));
}
gboolean
diff --git a/src/tabwin.c b/src/tabwin.c
index bad1e56..747ec2f 100644
--- a/src/tabwin.c
+++ b/src/tabwin.c
@@ -365,6 +365,7 @@ createWindowlist (ScreenInfo *screen_info, TabwinWidget *tbw)
{
selected = window_button;
selected_label = buttonlabel;
+ gtk_widget_grab_focus (selected);
}
}
if (selected)
@@ -493,20 +494,12 @@ tabwinCreateWidget (Tabwin *tabwin, ScreenInfo *screen_info, gint monitor_num)
gtk_label_set_use_markup (GTK_LABEL (tbw->label), TRUE);
gtk_label_set_justify (GTK_LABEL (tbw->label), GTK_JUSTIFY_CENTER);
gtk_label_set_ellipsize (GTK_LABEL (tbw->label), PANGO_ELLIPSIZE_END);
- //gtk_widget_set_size_request (GTK_WIDGET (tbw->label), 240, -1);
gtk_box_pack_end (GTK_BOX (vbox), tbw->label, TRUE, TRUE, 0);
windowlist = createWindowlist (screen_info, tbw);
tbw->container = windowlist;
gtk_box_pack_start (GTK_BOX (vbox), windowlist, TRUE, TRUE, 0);
-#if 0
- if (GTK_CHECK_VERSION (2, 6, 2))
- {
- gtk_label_set_ellipsize (GTK_LABEL (tbw->label), PANGO_ELLIPSIZE_END);
- }
-#endif
-
g_signal_connect_swapped (tbw, "configure-event",
GTK_SIGNAL_FUNC (tabwinConfigure), (gpointer) tbw);
g_signal_connect (tbw, "expose-event", GTK_SIGNAL_FUNC (tabwin_expose), (gpointer) tbw);
@@ -667,11 +660,11 @@ tabwinSelectHead (Tabwin *t)
buttonbox = GTK_WIDGET( gtk_container_get_children(GTK_CONTAINER(window_button))[0].data );
buttonlabel = GTK_WIDGET( g_list_nth_data( gtk_container_get_children(GTK_CONTAINER(buttonbox)), 1) );
if (((Client *) g_object_get_data (G_OBJECT(window_button), "client-ptr-val")) == head->data)
- {
- tabwinSetSelected (tbw, window_button, buttonlabel);
- gtk_widget_queue_draw (GTK_WIDGET(tbw));
- }
+ {
+ tabwinSetSelected (tbw, window_button, buttonlabel);
+ gtk_widget_queue_draw (GTK_WIDGET(tbw));
}
+ }
}
return tabwinGetSelected (t);
@@ -787,6 +780,47 @@ tabwinSelectDelta (Tabwin *t, int row_delta, int col_delta)
return tabwinChange2Selected (t, selected);
}
+Client*
+tabwinSelectWidget (Tabwin *t, GtkWidget * w)
+{
+ GList *tabwin_list, *widgets, *selected;
+ GtkWidget *window_button, *buttonbox, *buttonlabel;
+ TabwinWidget *tbw;
+ Client *c;
+
+ g_return_val_if_fail (t != NULL, NULL);
+ TRACE ("entering tabwinSelectWidget");
+
+ for (tabwin_list = t->tabwin_list; tabwin_list; tabwin_list = g_list_next (tabwin_list))
+ {
+ tbw = (TabwinWidget *) tabwin_list->data;
+ for (widgets = tbw->widgets; widgets; widgets = g_list_next (widgets))
+ {
+ window_button = GTK_WIDGET (widgets->data);
+ gtk_button_set_relief (GTK_BUTTON (window_button), GTK_RELIEF_NONE);
+ buttonbox = GTK_WIDGET( gtk_container_get_children(GTK_CONTAINER (window_button))[0].data );
+ buttonlabel = GTK_WIDGET( g_list_nth_data( gtk_container_get_children (GTK_CONTAINER(buttonbox)), 1) );
+ gtk_label_set_text (GTK_LABEL (buttonlabel), "");
+
+ if (gtk_widget_is_focus (window_button))
+ {
+ c = g_object_get_data (G_OBJECT (window_button), "client-ptr-val");
+ selected = g_list_find (*t->client_list, c);
+
+ if (selected)
+ {
+ t->selected = selected;
+ }
+
+ tabwinSetSelected (tbw, window_button, buttonlabel);
+ gtk_widget_queue_draw (GTK_WIDGET (tbw));
+ }
+ }
+ }
+
+ return tabwinGetSelected (t);
+}
+
void
tabwinDestroy (Tabwin *t)
{
@@ -796,7 +830,6 @@ tabwinDestroy (Tabwin *t)
g_return_if_fail (t != NULL);
TRACE ("entering tabwinDestroy");
- g_return_if_fail (t != NULL);
for (tabwin_list = t->tabwin_list; tabwin_list; tabwin_list = g_list_next (tabwin_list))
{
tbw = (TabwinWidget *) tabwin_list->data;
diff --git a/src/tabwin.h b/src/tabwin.h
index ee1cadb..fb802c4 100644
--- a/src/tabwin.h
+++ b/src/tabwin.h
@@ -75,6 +75,7 @@ Client *tabwinSelectHead (Tabwin *);
Client *tabwinSelectNext (Tabwin *);
Client *tabwinSelectPrev (Tabwin *);
Client *tabwinSelectDelta (Tabwin *, int, int);
+Client *tabwinSelectWidget (Tabwin *, GtkWidget *);
Client *tabwinRemoveClient (Tabwin *,
Client *);
void tabwinDestroy (Tabwin *);
More information about the Xfce4-commits
mailing list