+gboolean stacking_restack_request(ObClient *client, ObClient *sibling,
+ gint detail)
+{
+ gboolean ret = FALSE;
+
+ if (sibling && ((client->desktop != sibling->desktop &&
+ client->desktop != DESKTOP_ALL &&
+ sibling->desktop != DESKTOP_ALL) ||
+ sibling->iconic))
+ {
+ ob_debug("Setting restack sibling to NULL, they are not on the same "
+ "desktop or it is iconified");
+ sibling = NULL;
+ }
+
+ switch (detail) {
+ case Below:
+ ob_debug("Restack request Below for client %s sibling %s",
+ client->title, sibling ? sibling->title : "(all)");
+ /* just lower it */
+ stacking_lower(CLIENT_AS_WINDOW(client));
+ ret = TRUE;
+ break;
+ case BottomIf:
+ ob_debug("Restack request BottomIf for client %s sibling %s",
+ client->title, sibling ? sibling->title : "(all)");
+ /* if this client occludes sibling (or anything if NULL), then
+ lower it to the bottom */
+ if (stacking_occludes(client, sibling)) {
+ stacking_lower(CLIENT_AS_WINDOW(client));
+ ret = TRUE;
+ }
+ break;
+ case Above:
+ ob_debug("Restack request Above for client %s sibling %s",
+ client->title, sibling ? sibling->title : "(all)");
+ stacking_raise(CLIENT_AS_WINDOW(client));
+ ret = TRUE;
+ break;
+ case TopIf:
+ ob_debug("Restack request TopIf for client %s sibling %s",
+ client->title, sibling ? sibling->title : "(all)");
+ if (stacking_occluded(client, sibling)) {
+ stacking_raise(CLIENT_AS_WINDOW(client));
+ ret = TRUE;
+ }
+ break;
+ case Opposite:
+ ob_debug("Restack request Opposite for client %s sibling %s",
+ client->title, sibling ? sibling->title : "(all)");
+ if (stacking_occluded(client, sibling)) {
+ stacking_raise(CLIENT_AS_WINDOW(client));
+ ret = TRUE;
+ }
+ else if (stacking_occludes(client, sibling)) {
+ stacking_lower(CLIENT_AS_WINDOW(client));
+ ret = TRUE;
+ }
+ break;