- /* put the events back */
- for (it = saved; it; it = g_slist_next(it)) {
- XPutBackEvent(ob_display, it->data);
- g_free(it->data);
+ return False; /* don't disrupt the queue order, just count them */
+}
+
+void event_ignore_all_queued_enters()
+{
+ event_ignore_enters_leaving_window(NULL);
+}
+
+void event_ignore_enters_leaving_window(ObClient *c)
+{
+ struct ObLookForEnters lfe;
+ XEvent e;
+
+ XSync(ob_display, FALSE);
+
+ /* count the events without disrupting them */
+ ignore_enter_focus = 0;
+ lfe.c = c;
+ lfe.looking_for_enter = 0;
+ XCheckIfEvent(ob_display, &e, event_look_for_enters, (XPointer)&lfe);
+
+}
+
+static gboolean is_enter_focus_event_ignored(XEvent *e)
+{
+ g_assert(e->type == EnterNotify);
+
+ if (ignore_enter_focus) {
+ gint i;
+
+ --ignore_enter_focus;
+
+ /* remove the serial */
+ for (i = 0; ignore_enter_serials[i] != 0; ++i) {
+ if (ignore_enter_serials[i] == e->xany.serial) {
+ for (; ignore_enter_serials[i+1] != 0; ++i)
+ ignore_enter_serials[i] = ignore_enter_serials[i+1];
+ ignore_enter_serials[i] = 0;
+ }
+ }
+ return TRUE;