+ /* Assemble the list of windows that could overlap with @c in the user's
+ current view. */
+ GSList* potential_overlap_clients = NULL;
+ gint n_client_rects = config_dock_hide ? 0 : 1;
+
+ /* if we're "showing desktop", ignore all existing windows */
+ if (!screen_showing_desktop) {
+ GList* it;
+ for (it = client_list; it != NULL; it = g_list_next(it)) {
+ ObClient* maybe_client = (ObClient*)it->data;
+ if (maybe_client == c)
+ continue;
+ if (maybe_client->iconic)
+ continue;
+ if (!client_occupies_space(maybe_client))
+ continue;
+ if (c->desktop != DESKTOP_ALL) {
+ if (maybe_client->desktop != c->desktop &&
+ maybe_client->desktop != DESKTOP_ALL)
+ continue;
+ } else {
+ if (maybe_client->desktop != screen_desktop &&
+ maybe_client->desktop != DESKTOP_ALL)
+ continue;
+ }
+
+ potential_overlap_clients = g_slist_prepend(
+ potential_overlap_clients, maybe_client);
+ n_client_rects += 1;
+ }
+ }
+ Rect client_rects[n_client_rects];
+
+ GSList* it;
+ guint i = 0;
+ if (!config_dock_hide)
+ dock_get_area(&client_rects[i++]);
+ for (it = potential_overlap_clients; it != NULL; it = g_slist_next(it)) {
+ ObClient* potential_overlap_client = (ObClient*)it->data;
+ client_rects[i] = potential_overlap_client->frame->area;
+ i += 1;
+ }
+ g_slist_free(potential_overlap_clients);
+
+ Point result;
+ place_overlap_find_least_placement(client_rects, n_client_rects, head,
+ &frame_size, &result);
+ *x = result.x;
+ *y = result.y;
+
+ return TRUE;
+}
+
+static gboolean should_set_client_position(ObClient *client,
+ ObAppSettings *settings)
+{
+ gboolean has_position = settings && settings->pos_given;
+ gboolean has_forced_position = has_position && settings->pos_force;
+
+ gboolean user_positioned = client->positioned & USPosition;
+ if (user_positioned && !has_forced_position)