+ gboolean diffhead = FALSE;
+ guint i;
+ Rect *a;
+
+ for (i = 0; i < screen_num_monitors; ++i) {
+ a = screen_physical_area_monitor(i);
+ if (RECT_CONTAINS(*a, a1->x, a1->y) &&
+ !RECT_CONTAINS(*a, a2->x, a2->y))
+ {
+ diffhead = TRUE;
+ break;
+ }
+ }
+
+ /* has to be more than me in the group */
+ if (diffhead && c->group && c->group->members->next) {
+ guint *num, most;
+ GSList *it;
+
+ /* find how many clients in the group are on each monitor, use the
+ monitor with the most in it */
+ num = g_new0(guint, screen_num_monitors);
+ for (it = c->group->members; it; it = g_slist_next(it))
+ if (it->data != c)
+ ++num[client_monitor(it->data)];
+ most = 0;
+ for (i = 1; i < screen_num_monitors; ++i)
+ if (num[i] > num[most])
+ most = i;
+
+ a = screen_physical_area_monitor(most);
+ if (RECT_CONTAINS(*a, a1->x, a1->y))
+ return -1;
+ if (RECT_CONTAINS(*a, a2->x, a2->y))
+ return 1;
+ }