- 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;
- int l, r, t, b;
- for (it = client->group->members; it; it = it->next) {
- 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));
- }
+ gint l, r, t, b;
+ gint px, py;
+ Rect *area;
+
+ area = pick_pointer_head(client);
+ screen_pointer_pos(&px, &py);
+
+ l = area->x;
+ t = area->y;
+ r = area->x + area->width - client->frame->area.width;
+ b = area->y + area->height - client->frame->area.height;
+
+ *x = px - client->area.width / 2 - client->frame->size.left;
+ *x = MIN(MAX(*x, l), r);
+ *y = py - client->area.height / 2 - client->frame->size.top;
+ *y = MIN(MAX(*y, t), b);
+
+ return TRUE;
+}
+
+static gboolean place_per_app_setting(ObClient *client, gint *x, gint *y,
+ ObAppSettings *settings)
+{
+ Rect *screen = NULL;
+
+ if (!settings || (settings && !settings->pos_given))
+ return FALSE;
+
+ /* Find which head the pointer is on */
+ if (settings->monitor == 0)
+ screen = pick_pointer_head(client);
+ else if (settings->monitor > 0 &&
+ (guint)settings->monitor <= screen_num_monitors)
+ screen = screen_area_monitor(client->desktop,
+ (guint)settings->monitor - 1);
+ else {
+ Rect **all = NULL;
+ all = pick_head(client);
+ screen = all[0];
+ g_free(all); /* the areas themselves don't need to be freed */
+ }
+
+ if (settings->center_x)
+ *x = screen->x + screen->width / 2 - client->area.width / 2;
+ else if (settings->opposite_x)
+ *x = screen->x + screen->width - client->frame->area.width -
+ settings->position.x;
+ else
+ *x = screen->x + settings->position.x;
+
+ if (settings->center_y)
+ *y = screen->y + screen->height / 2 - client->area.height / 2;
+ else if (settings->opposite_y)
+ *y = screen->y + screen->height - client->frame->area.height -
+ settings->position.y;
+ else
+ *y = screen->y + settings->position.y;
+
+ 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));