[Xfce4-commits] <xfwm4:master> Don't select the window when it gets mouse focus
Nick Schermer
noreply at xfce.org
Sun Feb 23 21:10:18 CET 2014
Updating branch refs/heads/master
to fd296893527c2c1cccf3ce6202a7f9340992d481 (commit)
from 3de6a9bf12ee4e6cd94126c14d200719f82d1431 (commit)
commit fd296893527c2c1cccf3ce6202a7f9340992d481
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Tue Nov 26 16:14:05 2013 +0300
Don't select the window when it gets mouse focus
Instead of selecting the window, just update the labels in the
tabwin window when the window icon gets the focus. If the user
clicks on the window icon then the widget the mouse is hovering
over will be selected and the tabwin window will disappear.
Signed-off-by: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
src/cycle.c | 33 +++++++++++----------------
src/tabwin.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
src/tabwin.h | 4 +++-
3 files changed, 80 insertions(+), 28 deletions(-)
diff --git a/src/cycle.c b/src/cycle.c
index 79989ed..3af6aea 100644
--- a/src/cycle.c
+++ b/src/cycle.c
@@ -227,7 +227,6 @@ clientCycleEventFilter (XEvent * xevent, gpointer data)
DisplayInfo *display_info;
ClientCycleData *passdata;
Client *c, *removed;
- static Client *last_selected = NULL;
eventFilterStatus status;
KeyCode cancel, left, right, up, down;
int key, modifiers;
@@ -329,8 +328,18 @@ clientCycleEventFilter (XEvent * xevent, gpointer data)
{
cycling = FALSE;
}
+ }
- if (!c)
+ if (cycling)
+ {
+ if (c)
+ {
+ if (passdata->wireframe)
+ {
+ wireframeUpdate (c, passdata->wireframe);
+ }
+ }
+ else
{
cycling = FALSE;
}
@@ -357,11 +366,6 @@ clientCycleEventFilter (XEvent * xevent, gpointer data)
/* window of the event, we might accept it later */
mouse_window = xevent->xbutton.window;
break;
- case MotionNotify:
- status = EVENT_FILTER_CONTINUE;
- /* window of the event, we might accept it later */
- mouse_window = xevent->xcrossing.window;
- break;
default:
status = EVENT_FILTER_CONTINUE;
break;
@@ -374,20 +378,9 @@ clientCycleEventFilter (XEvent * xevent, gpointer data)
{
if (GDK_WINDOW_XID (gtk_widget_get_window (li->data)) == mouse_window)
{
- c = tabwinSelectWidget (passdata->tabwin, li->data);
- break;
- }
- }
- }
+ c = tabwinSelectHoveredWidget (passdata->tabwin);
- if (cycling)
- {
- if (c)
- {
- if (passdata->wireframe && last_selected != c)
- {
- last_selected = c;
- wireframeUpdate (c, passdata->wireframe);
+ break;
}
}
}
diff --git a/src/tabwin.c b/src/tabwin.c
index 0758d36..35e96b8 100644
--- a/src/tabwin.c
+++ b/src/tabwin.c
@@ -312,15 +312,54 @@ getMinMonitorWidth (ScreenInfo *screen_info)
static gboolean
cb_window_button_enter (GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
- Tabwin *t = user_data;
+ TabwinWidget *tbw = user_data;
+ Client *c;
+ GtkWidget *buttonbox, *buttonlabel;
+ gchar *classname;
+
+ TRACE ("entering");
+
+ g_return_val_if_fail (tbw != NULL, FALSE);
+
+ c = g_object_get_data (G_OBJECT (widget), "client-ptr-val");
+
+ /* keep track of which widget we're hovered over */
+ tbw->tabwin->hovered = widget;
+
+ /* when hovering over a window icon, display it's label but don't
+ * select it */
+ if (c != NULL)
+ {
+ buttonbox = GTK_WIDGET( gtk_container_get_children(GTK_CONTAINER(widget))[0].data );
+ buttonlabel = GTK_WIDGET( g_list_nth_data( gtk_container_get_children(GTK_CONTAINER(buttonbox)), 1) );
+
+ classname = g_strdup(c->class.res_class);
+ tabwinSetLabel (tbw, buttonlabel, classname, c->name, c->win_workspace);
+ g_free (classname);
+ }
+
+ return FALSE;
+}
+
+static gboolean
+cb_window_button_leave (GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+ TabwinWidget *tbw = user_data;
TRACE ("entering");
- g_return_val_if_fail (t != NULL, FALSE);
+ g_return_val_if_fail (tbw != NULL, FALSE);
+
+ /* don't do anything if we have the focus */
+ if (gtk_widget_is_focus (widget))
+ {
+ return FALSE;
+ }
+
+ tbw->tabwin->hovered = NULL;
- /* On mouse over we grab the focus for the window button and select it */
- gtk_widget_grab_focus (widget);
- tabwinSelectWidget (t, widget);
+ /* reselect the selected widget, it will clear everything else out */
+ tabwinSelectWidget (tbw->tabwin);
return FALSE;
}
@@ -359,7 +398,8 @@ createWindowlist (ScreenInfo *screen_info, TabwinWidget *tbw)
gtk_button_set_relief (GTK_BUTTON (window_button), GTK_RELIEF_NONE);
gtk_widget_set_size_request (GTK_WIDGET (window_button), icon_size+24, icon_size+24);
g_object_set_data (G_OBJECT (window_button), "client-ptr-val", c);
- g_signal_connect (window_button, "enter-notify-event", G_CALLBACK (cb_window_button_enter), t);
+ g_signal_connect (window_button, "enter-notify-event", G_CALLBACK (cb_window_button_enter), tbw);
+ g_signal_connect (window_button, "leave-notify-event", G_CALLBACK (cb_window_button_leave), tbw);
gtk_widget_add_events (window_button, GDK_ENTER_NOTIFY_MASK);
buttonbox = gtk_vbox_new (FALSE, 0);
@@ -800,7 +840,7 @@ tabwinSelectDelta (Tabwin *t, int row_delta, int col_delta)
}
Client*
-tabwinSelectWidget (Tabwin *t, GtkWidget * w)
+tabwinSelectWidget (Tabwin *t)
{
GList *tabwin_list, *widgets, *selected;
GtkWidget *window_button, *buttonbox, *buttonlabel;
@@ -840,6 +880,23 @@ tabwinSelectWidget (Tabwin *t, GtkWidget * w)
return tabwinGetSelected (t);
}
+Client*
+tabwinSelectHoveredWidget (Tabwin *t)
+{
+ TRACE ("entering");
+
+ g_return_val_if_fail (t != NULL, NULL);
+
+ if (!t->hovered)
+ {
+ return NULL;
+ }
+
+ gtk_widget_grab_focus (t->hovered);
+
+ return tabwinSelectWidget (t);
+}
+
void
tabwinDestroy (Tabwin *t)
{
diff --git a/src/tabwin.h b/src/tabwin.h
index fb802c4..67e5dd2 100644
--- a/src/tabwin.h
+++ b/src/tabwin.h
@@ -40,6 +40,7 @@ struct _Tabwin
GList *tabwin_list;
GList **client_list;
GList *selected;
+ GtkWidget *hovered;
gboolean display_workspace;
};
@@ -75,7 +76,8 @@ Client *tabwinSelectHead (Tabwin *);
Client *tabwinSelectNext (Tabwin *);
Client *tabwinSelectPrev (Tabwin *);
Client *tabwinSelectDelta (Tabwin *, int, int);
-Client *tabwinSelectWidget (Tabwin *, GtkWidget *);
+Client *tabwinSelectWidget (Tabwin *);
+Client *tabwinSelectHoveredWidget (Tabwin *);
Client *tabwinRemoveClient (Tabwin *,
Client *);
void tabwinDestroy (Tabwin *);
More information about the Xfce4-commits
mailing list