Today was the predicted day and it happened just as expected. I was
wrong since it happens on May 19 at 9:06am in the local time, not 7:06am
UTC as I previously said. So some people will just have experienced it
and some may just run into it after I send this.
Now that I've confirmed the periodicity I'm going to run a patched
WindowMaker. As promised, here's the enhanced patch. Next predicted time
is July 8 at 2:09am. I'll report back in that date.
This patch relies on ANSI C standard compliance regarding arithmetic
operations. It will reject past events for 1 minute (as denoted by the
number 60000, which is 1 minute expressed in milliseconds). If a focus
request comes to the X Window server with a timestamp which is more than
1 minute in the past, it will be accepted. Hopefully that will not cause
problems. Even if X is run over a network the 1 minute lapse is probably
enough as to not cause race conditions anyway.
But relying on X Window timestamps for that purpose has the drawback of
the possibility of integer overflow. With this patch applied, there'll
be no more problems unless a very unlikely condition happens.
This condition is: if you click a window to focus it, and then you don't
click any other window for between 49 days, 17 hours, 1 min and 49 days,
17 hours, 2 mins in a row, then you try to focus another window, you'll
be unable to do that for about a minute. (If you click after 49 days 17
hours 2 mins, you'll not notice anything wrong anyway.)
Safe enough, I think, and much better than what is happening now. And
better than with the previous patch too.
-- Pedro Gimeno
diff -ru wmaker-0.92.0-orig/src/actions.c wmaker-0.92.0/src/actions.c
--- wmaker-0.92.0-orig/src/actions.c 2008-05-19 13:54:03.000000000 +0200
+++ wmaker-0.92.0/src/actions.c 2008-05-19 14:44:27.000000000 +0200
@@ -78,6 +78,15 @@
#define SHADE_STEPS shadePars[(int)wPreferences.shade_speed].steps
#define SHADE_DELAY shadePars[(int)wPreferences.shade_speed].delay
+static int
+compareTimes(Time t1, Time t2)
+{
+ Time diff;
+ if (t1 == t2)
+ return 0;
+ diff = t1 - t2;
+ return (diff < 60000) ? 1 : -1;
+}
/*
*----------------------------------------------------------------------
@@ -99,11 +108,11 @@
WWindow *old_focused;
WWindow *focused=scr->focused_window;
- int timestamp=LastTimestamp;
+ Time timestamp=LastTimestamp;
WApplication *oapp=NULL, *napp=NULL;
int wasfocused;
- if (scr->flags.ignore_focus_events || LastFocusChange > timestamp)
+ if (scr->flags.ignore_focus_events || compareTimes(LastFocusChange, timestamp) > 0)
return;
if (!old_scr)