- if (client->transient_for) {
- if (client->transient_for != OB_TRAN_GROUP) {
- ObClient *c = client;
- ObClient *p = client->transient_for;
- *x = (p->frame->area.width - c->frame->area.width) / 2 +
- p->frame->area.x;
- *y = (p->frame->area.height - c->frame->area.height) / 2 +
- p->frame->area.y;
- return TRUE;
- } else {
- GSList *it;
- gboolean first = TRUE;
- gint l, r, t, b;
- for (it = client->group->members; it; it = g_slist_next(it)) {
- ObClient *m = it->data;
- if (!(m == client || m->transient_for)) {
- if (first) {
- l = RECT_LEFT(m->frame->area);
- t = RECT_TOP(m->frame->area);
- r = RECT_RIGHT(m->frame->area);
- b = RECT_BOTTOM(m->frame->area);
- first = FALSE;
- } else {
- l = MIN(l, RECT_LEFT(m->frame->area));
- t = MIN(t, RECT_TOP(m->frame->area));
- r = MAX(r, RECT_RIGHT(m->frame->area));
- b = MAX(b, RECT_BOTTOM(m->frame->area));
- }
+ Rect *screen = NULL;
+
+ if (!settings || (settings && !settings->pos_given))
+ return FALSE;
+
+ /* Find which head the pointer is on */
+ if (settings->monitor == 0)
+ /* this can return NULL */
+ screen = pick_pointer_head(client);
+ else if (settings->monitor > 0 &&
+ (guint)settings->monitor <= screen_num_monitors)
+ screen = screen_area(client->desktop, (guint)settings->monitor - 1,
+ NULL);
+
+ /* if we have't found a screen yet.. */
+ if (!screen) {
+ Rect **areas;
+ guint i;
+
+ areas = pick_head(client);
+ screen = areas[0];
+
+ /* don't free the first one, it's being set as "screen" */
+ for (i = 1; i < screen_num_monitors; ++i)
+ g_free(areas[i]);
+ g_free(areas);
+ }
+
+ if (settings->position.x.center)
+ *x = screen->x + screen->width / 2 - client->area.width / 2;
+ else if (settings->position.x.opposite)
+ *x = screen->x + screen->width - client->frame->area.width -
+ settings->position.x.pos;
+ else
+ *x = screen->x + settings->position.x.pos;
+
+ if (settings->position.y.center)
+ *y = screen->y + screen->height / 2 - client->area.height / 2;
+ else if (settings->position.y.opposite)
+ *y = screen->y + screen->height - client->frame->area.height -
+ settings->position.y.pos;
+ else
+ *y = screen->y + settings->position.y.pos;
+
+ g_free(screen);
+ return TRUE;
+}
+
+static gboolean place_transient_splash(ObClient *client, gint *x, gint *y)
+{
+ if (client->type == OB_CLIENT_TYPE_DIALOG) {
+ GSList *it;
+ gboolean first = TRUE;
+ gint l, r, t, b;
+ for (it = client->parents; it; it = g_slist_next(it)) {
+ ObClient *m = it->data;
+ if (!m->iconic) {
+ if (first) {
+ l = RECT_LEFT(m->frame->area);
+ t = RECT_TOP(m->frame->area);
+ r = RECT_RIGHT(m->frame->area);
+ b = RECT_BOTTOM(m->frame->area);
+ first = FALSE;
+ } else {
+ l = MIN(l, RECT_LEFT(m->frame->area));
+ t = MIN(t, RECT_TOP(m->frame->area));
+ r = MAX(r, RECT_RIGHT(m->frame->area));
+ b = MAX(b, RECT_BOTTOM(m->frame->area));