+void plugin_setup_config()
+{
+ ConfigValue val;
+
+ config_def_set(config_def_new("focus.followMouse", Config_Bool,
+ "Focus Follows Mouse",
+ "Focus windows when the mouse pointer "
+ "enters them."));
+ val.bool = TRUE;
+ config_set("focus.followMouse", Config_Bool, val);
+ config_def_set(config_def_new("focus.focusNew", Config_Bool,
+ "Focus New Windows",
+ "Focus windows when they first appear."));
+ val.bool = TRUE;
+ config_set("focus.focusNew", Config_Bool, val);
+/*
+ config_def_set(config_def_new("focus.warpOnDeskSwitch", Config_Bool,
+ "Warp Pointer On Desktop Switch",
+ "Warps the pointer to the focused window "
+ "when switching desktops."));
+ config_set("focus.warpOnDeskSwitch", Config_Bool, FALSE);
+*/
+}
+
+/*static int skip_enter = 0;*/
+
+static gboolean focus_under_pointer()
+{
+ Window w;
+ int i, x, y;
+ guint u;
+ GList *it;
+
+ if (XQueryPointer(ob_display, ob_root, &w, &w, &x, &y, &i, &i, &u))
+ {
+ for (it = stacking_list; it != NULL; it = it->next) {
+ Client *c = it->data;
+ if (c->desktop == screen_desktop &&
+ RECT_CONTAINS(c->frame->area, x, y))
+ break;
+ }
+ if (it != NULL) {
+ return client_normal(it->data) && client_focus(it->data);
+ }
+ }
+ return FALSE;
+}
+
+static void chew_enter_events()
+{
+ XEvent e;
+
+ /* XXX... not anymore
+ skip the next enter event from the desktop switch so focus
+ doesn't skip briefly to what was under the pointer */
+
+ /* kill all enter events from prior to the desktop switch, we
+ aren't interested in them if we have found our own target
+ to focus.
+ XXX this is rude to other plugins...can this be done
+ better? count the events in the queue? */
+ while (XCheckTypedEvent(ob_display, EnterNotify, &e));
+/*
+ {
+ XPutBackEvent(ob_display, &e);
+ g_message("skip");
+ ++skip_enter;
+ }
+*/
+}
+
+static void focus_fallback(gboolean switching_desks)
+{
+ GList *it;
+
+ for (it = focus_order[screen_desktop]; it != NULL; it = it->next)
+ if (client_normal(it->data) && client_focus(it->data)) {
+ if (switching_desks) {
+ Client *c = it->data;