[Xfce4-commits] r23600 - xfwm4/trunk/src
Olivier Fourdan
olivier at xfce.org
Thu Nov 2 22:18:32 CET 2006
Author: olivier
Date: 2006-11-02 21:18:29 +0000 (Thu, 02 Nov 2006)
New Revision: 23600
Modified:
xfwm4/trunk/src/client.c
xfwm4/trunk/src/client.h
xfwm4/trunk/src/events.c
Log:
Add timeout to avoid blocking on broken apps that claim XSync compliance but don't implement the protocol properly.
Modified: xfwm4/trunk/src/client.c
===================================================================
--- xfwm4/trunk/src/client.c 2006-11-02 14:21:26 UTC (rev 23599)
+++ xfwm4/trunk/src/client.c 2006-11-02 21:18:29 UTC (rev 23600)
@@ -313,8 +313,10 @@
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_VISIBLE))
{
c->blink_timeout_id =
- g_timeout_add_full (0, 500, (GtkFunction) urgent_cb,
- (gpointer) c, NULL);
+ g_timeout_add_full (G_PRIORITY_DEFAULT,
+ CLIENT_BLINK_TIMEOUT,
+ (GtkFunction) urgent_cb,
+ (gpointer) c, NULL);
}
}
if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_SEEN_ACTIVE)
@@ -1073,19 +1075,21 @@
g_return_if_fail (c != NULL);
g_return_if_fail (c->xsync_counter != None);
+ TRACE ("entering clientIncrementXSyncValue");
+
XSyncIntToValue (&add, 1);
XSyncValueAdd (&c->xsync_value, c->xsync_value, add, &overflow);
}
-static void
+static gboolean
clientCreateXSyncAlarm (Client *c)
{
ScreenInfo *screen_info;
DisplayInfo *display_info;
XSyncAlarmAttributes values;
- g_return_if_fail (c != NULL);
- g_return_if_fail (c->xsync_counter != None);
+ g_return_val_if_fail (c != NULL, FALSE);
+ g_return_val_if_fail (c->xsync_counter != None, FALSE);
TRACE ("entering clientCreateXSyncAlarm");
@@ -1110,6 +1114,7 @@
XSyncCAValue |
XSyncCAValueType,
&values);
+ return (c->xsync_alarm != None);
}
static void
@@ -1130,21 +1135,76 @@
c->xsync_alarm = None;
}
+static void
+clientXSyncClearTimeout (Client * c)
+{
+ g_return_if_fail (c != NULL);
+
+ TRACE ("entering clientXSyncClearTimeout");
+
+ if (c->xsync_timeout_id)
+ {
+ g_source_remove (c->xsync_timeout_id);
+ c->xsync_timeout_id = 0;
+ }
+}
+
+static gboolean
+clientXSyncTimeout (gpointer data)
+{
+ Client *c;
+ XWindowChanges wc;
+
+ TRACE ("entering clientXSyncTimeout");
+
+ c = (Client *) data;
+ if (c)
+ {
+ g_warning ("XSync timeout for client \"%s\" (0x%lx)", c->name, c->window);
+ clientXSyncClearTimeout (c);
+ c->xsync_waiting = FALSE;
+ c->xsync_enabled = FALSE;
+
+ wc.x = c->x;
+ wc.y = c->y;
+ wc.width = c->width;
+ wc.height = c->height;
+ clientConfigure (c, &wc, CWX | CWY | CWWidth | CWHeight, NO_CFG_FLAG);
+ }
+ return (TRUE);
+}
+
+static void
+clientXSyncResetTimeout (Client * c)
+{
+ g_return_if_fail (c != NULL);
+
+ TRACE ("entering clientXSyncResetTimeout");
+
+ clientXSyncClearTimeout (c);
+ c->xsync_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT,
+ CLIENT_XSYNC_TIMEOUT,
+ (GtkFunction) clientXSyncTimeout,
+ (gpointer) c, NULL);
+}
+
void
clientXSyncRequest (Client * c)
{
ScreenInfo *screen_info;
DisplayInfo *display_info;
- TRACE ("entering clientXSyncRequest");
g_return_if_fail (c != NULL);
g_return_if_fail (c->window != None);
+ TRACE ("entering clientXSyncRequest");
+
screen_info = c->screen_info;
display_info = screen_info->display_info;
clientIncrementXSyncValue (c);
sendXSyncRequest (display_info, c->window, c->xsync_value);
+ clientXSyncResetTimeout (c);
c->xsync_waiting = TRUE;
}
#endif /* HAVE_XSYNC */
@@ -1182,6 +1242,10 @@
{
clientDestroyXSyncAlarm (c);
}
+ if (c->xsync_timeout_id)
+ {
+ g_source_remove (c->xsync_timeout_id);
+ }
#endif /* HAVE_XSYNC */
#ifdef HAVE_LIBSTARTUP_NOTIFICATION
if (c->startup_id)
@@ -1564,12 +1628,17 @@
#ifdef HAVE_XSYNC
c->xsync_waiting = FALSE;
+ c->xsync_enabled = FALSE;
c->xsync_counter = None;
- getXSyncCounter (display_info, c->window, &c->xsync_counter);
c->xsync_alarm = None;
- if (c->xsync_counter)
+ c->xsync_timeout_id = 0;
+ if (display_info->have_xsync)
{
- clientCreateXSyncAlarm (c);
+ getXSyncCounter (display_info, c->window, &c->xsync_counter);
+ if ((c->xsync_counter) && clientCreateXSyncAlarm (c))
+ {
+ c->xsync_enabled = TRUE;
+ }
}
#endif /* HAVE_XSYNC */
@@ -3886,9 +3955,14 @@
static void
clientResizeConfigure (Client *c, int px, int py, int pw, int ph)
{
+ ScreenInfo *screen_info;
+ DisplayInfo *display_info;
XWindowChanges wc;
unsigned long value_mask;
+ screen_info = c->screen_info;
+ display_info = screen_info->display_info;
+
value_mask = 0L;
if (c->x != px)
{
@@ -3914,7 +3988,8 @@
#ifdef HAVE_XSYNC
if (!c->xsync_waiting)
{
- if ((c->xsync_counter) && (value_mask & (CWWidth | CWHeight)))
+ if ((display_info->have_xsync) && (c->xsync_enabled) && (c->xsync_counter)
+ && (value_mask & (CWWidth | CWHeight)))
{
clientXSyncRequest (c);
}
Modified: xfwm4/trunk/src/client.h
===================================================================
--- xfwm4/trunk/src/client.h 2006-11-02 14:21:26 UTC (rev 23599)
+++ xfwm4/trunk/src/client.h 2006-11-02 21:18:29 UTC (rev 23600)
@@ -83,6 +83,14 @@
#define CLIENT_MIN_VISIBLE 15
#endif
+#ifndef CLIENT_XSYNC_TIMEOUT
+#define CLIENT_XSYNC_TIMEOUT 1000 /* ms */
+#endif
+
+#ifndef CLIENT_BLINK_TIMEOUT
+#define CLIENT_BLINK_TIMEOUT 500 /* ms */
+#endif
+
#define XFWM_FLAG_HAS_BORDER (1L<<0)
#define XFWM_FLAG_HAS_MENU (1L<<1)
#define XFWM_FLAG_HAS_MAXIMIZE (1L<<2)
@@ -277,7 +285,9 @@
XSyncAlarm xsync_alarm;
XSyncCounter xsync_counter;
XSyncValue xsync_value;
+ guint xsync_timeout_id;
gboolean xsync_waiting;
+ gboolean xsync_enabled;
#endif /* HAVE_XSYNC */
};
Modified: xfwm4/trunk/src/events.c
===================================================================
--- xfwm4/trunk/src/events.c 2006-11-02 14:21:26 UTC (rev 23599)
+++ xfwm4/trunk/src/events.c 2006-11-02 21:18:29 UTC (rev 23600)
@@ -235,9 +235,10 @@
passdata.ycurrent = passdata.y;
passdata.clicks = 1;
passdata.allow_double_click = allow_double_click;
- passdata.timeout = g_timeout_add_full (0, display_info->dbl_click_time,
- (GtkFunction) typeOfClick_break,
- (gpointer) &passdata, NULL);
+ passdata.timeout = g_timeout_add_full (G_PRIORITY_DEFAULT,
+ display_info->dbl_click_time,
+ (GtkFunction) typeOfClick_break,
+ (gpointer) &passdata, NULL);
TRACE ("entering typeOfClick loop");
eventFilterPush (display_info->xfilter, typeOfClick_event_filter, &passdata);
@@ -300,7 +301,10 @@
{
g_source_remove (raise_timeout);
}
- raise_timeout = g_timeout_add_full (0, screen_info->params->raise_delay, (GtkFunction) raise_cb, NULL, NULL);
+ raise_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT,
+ screen_info->params->raise_delay,
+ (GtkFunction) raise_cb,
+ NULL, NULL);
}
static void
@@ -2235,16 +2239,24 @@
TRACE ("entering handleXSyncAlarmNotify");
+ if (!display_info->have_xsync)
+ {
+ return;
+ }
+
c = myDisplayGetClientFromXSyncAlarm (display_info, ev->alarm);
if (c)
{
c->xsync_waiting = FALSE;
- c->xsync_value = ev->counter_value;
- wc.x = c->x;
- wc.y = c->y;
- wc.width = c->width;
- wc.height = c->height;
- clientConfigure (c, &wc, CWX | CWY | CWWidth | CWHeight, NO_CFG_FLAG);
+ if (c->xsync_enabled)
+ {
+ c->xsync_value = ev->counter_value;
+ wc.x = c->x;
+ wc.y = c->y;
+ wc.width = c->width;
+ wc.height = c->height;
+ clientConfigure (c, &wc, CWX | CWY | CWWidth | CWHeight, NO_CFG_FLAG);
+ }
}
}
#endif /* HAVE_XSYNC */
More information about the Xfce4-commits
mailing list