[Xfce4-commits] r25137 - xfwm4/trunk/src
Olivier Fourdan
olivier at xfce.org
Thu Mar 8 22:46:34 CET 2007
Author: olivier
Date: 2007-03-08 21:46:34 +0000 (Thu, 08 Mar 2007)
New Revision: 25137
Modified:
xfwm4/trunk/src/events.c
xfwm4/trunk/src/focus.c
xfwm4/trunk/src/focus.h
xfwm4/trunk/src/stacking.c
xfwm4/trunk/src/stacking.h
Log:
Rework delayed focus
Modified: xfwm4/trunk/src/events.c
===================================================================
--- xfwm4/trunk/src/events.c 2007-03-08 17:48:11 UTC (rev 25136)
+++ xfwm4/trunk/src/events.c 2007-03-08 21:46:34 UTC (rev 25137)
@@ -79,20 +79,11 @@
SuperMask | \
HyperMask)
-static guint raise_timeout = 0;
-static guint focus_timeout = 0; // Focus time-out
static GdkAtom atom_rcfiles = GDK_NONE;
static xfwmWindow menu_event_window;
static int edge_scroll_x = 0;
static int edge_scroll_y = 0;
-static struct _focus_info
-{
- ScreenInfo *screen_info;
- Client *c;
- Time timestamp;
-} focus_info;
-
/* Forward decl. */
static void handleEvent (DisplayInfo *display_info,
@@ -248,7 +239,7 @@
passdata.allow_double_click = allow_double_click;
passdata.timeout = g_timeout_add_full (G_PRIORITY_DEFAULT,
display_info->dbl_click_time,
- (GtkFunction) typeOfClick_break,
+ (GSourceFunc) typeOfClick_break,
(gpointer) &passdata, NULL);
TRACE ("entering typeOfClick loop");
@@ -279,70 +270,6 @@
#endif
static void
-clear_timeout (void)
-{
- if (raise_timeout)
- {
- g_source_remove (raise_timeout);
- raise_timeout = 0;
- }
-}
-
-static gboolean
-raise_cb (gpointer data)
-{
- Client *c;
-
- TRACE ("entering raise_cb");
-
- clear_timeout ();
- c = clientGetFocus ();
-
- if (c)
- {
- clientRaise (c, None);
- }
- return (TRUE);
-}
-
-static void
-reset_timeout (ScreenInfo *screen_info)
-{
- if (raise_timeout)
- {
- g_source_remove (raise_timeout);
- }
- raise_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT,
- screen_info->params->raise_delay,
- (GtkFunction) raise_cb,
- NULL, NULL);
-}
-
-static void
-clear_focus_timeout (void)
-{
- if(focus_timeout)
- {
- g_source_remove (focus_timeout);
- focus_timeout = 0;
- }
-}
-
-static gboolean
-focus_cb (gpointer data)
-{
- Client *c;
-
- TRACE ("entering focus_cb");
-
- clear_focus_timeout();
-
- clientSetFocus (focus_info.screen_info, focus_info.c, focus_info.timestamp, NO_FOCUS_FLAG);
-
- return (TRUE);
-}
-
-static void
moveRequest (Client * c, XEvent * ev)
{
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_MOVE)
@@ -952,8 +879,7 @@
}
if (screen_info->params->raise_on_click)
{
- /* Clear timeout */
- clear_timeout ();
+ clientClearDelayedRaise ();
clientRaise (c, None);
}
clientButtonPress (c, win, ev);
@@ -990,8 +916,7 @@
}
if (screen_info->params->raise_on_click)
{
- /* Clear timeout */
- clear_timeout ();
+ clientClearDelayedRaise ();
clientRaise (c, None);
}
ev->window = ev->root;
@@ -1052,8 +977,7 @@
if ((screen_info->params->raise_on_click) ||
!FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_BORDER))
{
- /* Clear timeout */
- clear_timeout ();
+ clientClearDelayedRaise ();
clientRaise (c, None);
}
}
@@ -1533,14 +1457,8 @@
{
if(screen_info->params->focus_delay)
{
- clear_focus_timeout();
- focus_info.screen_info = c->screen_info;
- focus_info.c = c;
- focus_info.timestamp = ev->time;
- focus_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT,
- screen_info->params->focus_delay,
- (GtkFunction) focus_cb,
- NULL, NULL);
+ clientClearDelayedFocus ();
+ clientAddDelayedFocus (c, ev->time);
}
else
{
@@ -1549,7 +1467,7 @@
}
else
{
- clear_focus_timeout();
+ clientClearDelayedFocus ();
}
}
@@ -1789,7 +1707,7 @@
if (screen_info->params->raise_on_focus)
{
- reset_timeout (screen_info);
+ clientResetDelayedRaise (screen_info);
}
}
}
@@ -1847,8 +1765,7 @@
TRACE ("focus lost from \"%s\" (0x%lx)", c->name, c->window);
clientPassGrabMouseButton (NULL);
clientUpdateFocus (c->screen_info, NULL, NO_FOCUS_FLAG);
- /* Clear timeout */
- clear_timeout ();
+ clientClearDelayedRaise ();
}
}
}
Modified: xfwm4/trunk/src/focus.c
===================================================================
--- xfwm4/trunk/src/focus.c 2007-03-08 17:48:11 UTC (rev 25136)
+++ xfwm4/trunk/src/focus.c 2007-03-08 21:46:34 UTC (rev 25137)
@@ -57,6 +57,7 @@
static Client *pending_focus = NULL;
static Client *user_focus = NULL;
static Client *last_ungrab = NULL;
+static guint focus_timeout = 0;
static ClientPair
clientGetTopMostFocusable (ScreenInfo *screen_info, int layer, Client * exclude)
@@ -479,12 +480,12 @@
XChangeProperty (display_info->dpy, screen_info->xroot,
display_info->atoms[NET_ACTIVE_WINDOW], XA_WINDOW, 32,
PropModeReplace, (unsigned char *) data, 2);
-
+ clientClearDelayedFocus ();
clientUpdateOpacity (screen_info, c);
}
void
-clientSetFocus (ScreenInfo *screen_info, Client * c, Time timestamp, unsigned short flags)
+clientSetFocus (ScreenInfo *screen_info, Client *c, Time timestamp, unsigned short flags)
{
DisplayInfo *display_info;
Client *c2;
@@ -571,6 +572,7 @@
XChangeProperty (myScreenGetXDisplay (screen_info), screen_info->xroot, display_info->atoms[NET_ACTIVE_WINDOW], XA_WINDOW, 32,
PropModeReplace, (unsigned char *) data, 2);
XSetInputFocus (myScreenGetXDisplay (screen_info), screen_info->xfwm4_win, RevertToPointerRoot, timestamp);
+ clientClearDelayedFocus ();
clientUpdateOpacity (screen_info, c);
}
}
@@ -757,3 +759,51 @@
{
last_ungrab = NULL;
}
+
+static gboolean
+delayed_focus_cb (gpointer data)
+{
+ ScreenInfo *screen_info;
+ Window dr, window;
+ unsigned int mask;
+ int rx, ry, wx, wy;
+ Client *c;
+
+ TRACE ("entering delayed_focus_cb");
+
+ screen_info = (ScreenInfo *) data;
+ if (XQueryPointer (myScreenGetXDisplay (screen_info), screen_info->xroot, &dr, &window, &rx, &ry, &wx, &wy, &mask))
+ {
+ c = clientAtPosition (screen_info, rx, ry, NULL);
+ if (c)
+ {
+ clientSetFocus (screen_info, c, myDisplayGetCurrentTime (screen_info->display_info), NO_FOCUS_FLAG);
+ }
+ }
+ focus_timeout = 0;
+
+ return (FALSE);
+}
+
+void
+clientClearDelayedFocus (void)
+{
+ if(focus_timeout)
+ {
+ g_source_remove (focus_timeout);
+ focus_timeout = 0;
+ }
+}
+
+void
+clientAddDelayedFocus (Client *c, Time timestamp)
+{
+ ScreenInfo *screen_info;
+
+ screen_info = c->screen_info;
+ focus_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT,
+ screen_info->params->focus_delay,
+ (GSourceFunc) delayed_focus_cb,
+ screen_info, NULL);
+}
+
Modified: xfwm4/trunk/src/focus.h
===================================================================
--- xfwm4/trunk/src/focus.h 2007-03-08 17:48:11 UTC (rev 25136)
+++ xfwm4/trunk/src/focus.h 2007-03-08 21:46:34 UTC (rev 25137)
@@ -73,6 +73,10 @@
void clientPassGrabMouseButton (Client *);
Client *clientGetLastUngrab (void);
void clientClearLastUngrab (void);
+void clientClearDelayedFocus (void);
+void clientAddDelayedFocus (Client *,
+ Time);
+
#endif /* INC_FOCUS_H */
Modified: xfwm4/trunk/src/stacking.c
===================================================================
--- xfwm4/trunk/src/stacking.c 2007-03-08 17:48:11 UTC (rev 25136)
+++ xfwm4/trunk/src/stacking.c 2007-03-08 21:46:34 UTC (rev 25137)
@@ -34,6 +34,8 @@
#include "frame.h"
#include "focus.h"
+static guint raise_timeout = 0;
+
void
clientApplyStackList (ScreenInfo *screen_info)
{
@@ -681,3 +683,44 @@
g_return_if_fail (screen_info);
screen_info->last_raise = NULL;
}
+
+static gboolean
+delayed_raise_cb (gpointer data)
+{
+ Client *c;
+
+ TRACE ("entering delayed_raise_cb");
+
+ clientClearDelayedRaise ();
+ c = clientGetFocus ();
+
+ if (c)
+ {
+ clientRaise (c, None);
+ }
+ return (TRUE);
+}
+
+void
+clientClearDelayedRaise (void)
+{
+ if (raise_timeout)
+ {
+ g_source_remove (raise_timeout);
+ raise_timeout = 0;
+ }
+}
+
+void
+clientResetDelayedRaise (ScreenInfo *screen_info)
+{
+ if (raise_timeout)
+ {
+ g_source_remove (raise_timeout);
+ }
+ raise_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT,
+ screen_info->params->raise_delay,
+ (GSourceFunc) delayed_raise_cb,
+ NULL, NULL);
+}
+
Modified: xfwm4/trunk/src/stacking.h
===================================================================
--- xfwm4/trunk/src/stacking.h 2007-03-08 17:48:11 UTC (rev 25136)
+++ xfwm4/trunk/src/stacking.h 2007-03-08 21:46:34 UTC (rev 25137)
@@ -56,5 +56,8 @@
void clientSetLastRaise (Client *);
Client *clientGetLastRaise (ScreenInfo *);
void clientClearLastRaise (ScreenInfo *);
+void clientClearDelayedRaise (void);
+void clientResetDelayedRaise (ScreenInfo *);
+
#endif /* INC_STACKING_H */
More information about the Xfce4-commits
mailing list