summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2010-05-17 20:10:06 -0400
committerDana Jansens <danakj@orodu.net>2010-05-17 20:10:31 -0400
commit9a826d8c3d61150ddd72c621aab870d4bfe4594f (patch)
tree45a50d72d37cce90b353ae94c7caa6565d769b9a /openbox
parentab7673c8167d94bdb93bd9905d6265dd3bf727b3 (diff)
fix focus when starting up, especially when replacing another instance of openbox
adds a function event_reset_time() that forces event_time() to look for a new (future) timestamp
Diffstat (limited to 'openbox')
-rw-r--r--openbox/event.c28
-rw-r--r--openbox/event.h5
-rw-r--r--openbox/openbox.c6
3 files changed, 27 insertions, 12 deletions
diff --git a/openbox/event.c b/openbox/event.c
index 8a5720a5..8daa4281 100644
--- a/openbox/event.c
+++ b/openbox/event.c
@@ -98,13 +98,13 @@ static gboolean focus_delay_func(gpointer data);
static gboolean unfocus_delay_func(gpointer data);
static void focus_delay_client_dest(ObClient *client, gpointer data);
-Time event_last_user_time;
+Time event_last_user_time = CurrentTime;
/*! The time of the current X event (if it had a timestamp) */
-static Time event_curtime;
+static Time event_curtime = CurrentTime;
/*! The source time that started the current X event (user-provided, so not
to be trusted) */
-static Time event_sourcetime;
+static Time event_sourcetime = CurrentTime;
/*! The serial of the current X event */
static gulong event_curserial;
@@ -146,10 +146,6 @@ void event_startup(gboolean reconfig)
#endif
client_add_destroy_notify(focus_delay_client_dest, NULL);
-
- event_curtime = CurrentTime;
- event_sourcetime = CurrentTime;
- event_last_user_time = CurrentTime;
}
void event_shutdown(gboolean reconfig)
@@ -2210,7 +2206,7 @@ gboolean event_time_after(guint32 t1, guint32 t2)
gboolean find_timestamp(XEvent *e, gpointer data)
{
const Time t = event_get_timestamp(e);
- if (t != CurrentTime) {
+ if (t > event_curtime) {
event_curtime = t;
return TRUE;
}
@@ -2218,10 +2214,8 @@ gboolean find_timestamp(XEvent *e, gpointer data)
return FALSE;
}
-Time event_time(void)
+static Time next_time(void)
{
- if (event_curtime) return event_curtime;
-
/* Some events don't come with timestamps :(
...but we can get one anyways >:) */
@@ -2240,7 +2234,19 @@ Time event_time(void)
return event_curtime;
}
+Time event_time(void)
+{
+ if (event_curtime) return event_curtime;
+
+ return next_time();
+}
+
Time event_source_time(void)
{
return event_sourcetime;
}
+
+void event_reset_time(void)
+{
+ next_time();
+}
diff --git a/openbox/event.h b/openbox/event.h
index 8a2a4cbc..f0e2d397 100644
--- a/openbox/event.h
+++ b/openbox/event.h
@@ -68,6 +68,11 @@ gboolean event_time_after(guint32 t1, guint32 t2);
is a time at or after it, but at or before any other events we will process
*/
Time event_time(void);
+
+/*! Force event_time() to skip the current timestamp and look for the next
+ one. */
+void event_reset_time(void);
+
/*! A time at which an event happened that caused this current event to be
generated. This is a user-provided time and not to be trusted.
Returns CurrentTime if there was no source time provided.
diff --git a/openbox/openbox.c b/openbox/openbox.c
index 4703d7d6..fb43b978 100644
--- a/openbox/openbox.c
+++ b/openbox/openbox.c
@@ -213,6 +213,11 @@ gint main(gint argc, gchar **argv)
XC_top_left_corner);
if (screen_annex()) { /* it will be ours! */
+
+ /* get a timestamp from after taking over as the WM. if we use the
+ old timestamp to set focus it can fail when replacing another WM. */
+ event_reset_time();
+
do {
ObPrompt *xmlprompt = NULL;
@@ -317,7 +322,6 @@ gint main(gint argc, gchar **argv)
/* get all the existing windows */
window_manage_all();
- focus_nothing();
/* focus what was focused if a wm was already running */
if (OBT_PROP_GET32(obt_root(ob_screen),