+ gboolean allow_omni;
+
+ /* only allow omnipresent windows to get focus on desktop change if
+ an omnipresent window is already focused (it'll keep focus probably, but
+ maybe not depending on mouse-focus options) */
+ allow_omni = focus_client && (client_normal(focus_client) &&
+ focus_client->desktop == DESKTOP_ALL);
+
+ /* the client moved there already so don't move focus. prevent flicker
+ on sendtodesktop + follow */
+ if (focus_client && focus_client->desktop == screen_desktop)
+ return;
+
+ /* have to try focus here because when you leave an empty desktop
+ there is no focus out to watch for. also, we have different rules
+ here. we always allow it to look under the mouse pointer if
+ config_focus_last is FALSE
+
+ do this before hiding the windows so if helper windows are coming
+ with us, they don't get hidden
+ */
+ if ((c = focus_fallback(TRUE, !config_focus_last, allow_omni,
+ !allow_omni)))
+ {
+ /* only do the flicker reducing stuff ahead of time if we are going
+ to call xsetinputfocus on the window ourselves. otherwise there is
+ no guarantee the window will actually take focus.. */
+ if (c->can_focus) {
+ /* reduce flicker by hiliting now rather than waiting for the
+ server FocusIn event */
+ frame_adjust_focus(c->frame, TRUE);
+ /* do this here so that if you switch desktops to a window with
+ helper windows then the helper windows won't flash */
+ client_bring_helper_windows(c);
+ }
+ }
+}
+
+void screen_set_desktop(guint num, gboolean dofocus)
+{