- /* count the events */
- while (TRUE) {
- e = g_new(XEvent, 1);
- if (XCheckTypedEvent(ob_display, EnterNotify, e)) {
- ObWindow *win;
-
- win = g_hash_table_lookup(window_map, &e->xany.window);
- if (win && WINDOW_IS_CLIENT(win))
- ++ignore_enter_focus;
-
- saved = g_slist_append(saved, e);
- } else {
- g_free(e);
- break;
+void event_end_ignore_all_enters(gulong start)
+{
+ ObSerialRange *r;
+
+ g_assert(start != 0);
+ XSync(ob_display, FALSE);
+
+ r = g_new(ObSerialRange, 1);
+ r->start = start;
+ r->end = LastKnownRequestProcessed(ob_display);
+ ignore_serials = g_slist_prepend(ignore_serials, r);
+ ob_debug("ignoring serials %u-%u\n", r->start, r->end);
+
+ /* increment the serial so we don't ignore events we weren't meant to */
+ XSync(ob_display, FALSE);
+ ob_debug("now last serial %u\n", LastKnownRequestProcessed(ob_display));
+}
+
+static gboolean is_enter_focus_event_ignored(XEvent *e)
+{
+ GSList *it, *next;
+
+ g_assert(e->type == EnterNotify &&
+ !(e->xcrossing.mode == NotifyGrab ||
+ e->xcrossing.mode == NotifyUngrab ||
+ e->xcrossing.detail == NotifyInferior));
+
+ ob_debug("checking serial %u\n", e->xany.serial);
+ for (it = ignore_serials; it; it = next) {
+ ObSerialRange *r = it->data;
+
+ next = g_slist_next(it);
+
+ /* XXX wraparound... */
+ ob_debug(" ignore range %u-%u\n", r->start, r->end);
+ if (e->xany.serial > r->end) {
+ ignore_serials = g_slist_delete_link(ignore_serials, it);
+ g_free(r);