- ob_debug("placing window 0x%x at %d, %d with size %d x %d\n",
- self->window, placex, placey,
- self->area.width, self->area.height);
+ /* if the window isn't user-sized, then make it fit inside
+ the visible screen area on its monitor. Use basically the same rules
+ for forcing the window on screen in the client_find_onscreen call.
+
+ do this after place_client, it chooses the monitor! */
+ if (transient ||
+ (!(self->sized & USSize) &&
+ client_normal(self) &&
+ !self->session))
+ {
+ /* make a copy to modify */
+ Rect a = *screen_area_monitor(self->desktop, client_monitor(self));
+
+ /* shrink by the frame's area */
+ a.width -= self->frame->size.left + self->frame->size.right;
+ a.height -= self->frame->size.top + self->frame->size.bottom;
+
+ /* fit the window inside the area */
+ if (placew > a.width || self->area.height > a.height) {
+ placew = MAX(MIN(MIN(self->area.width, a.width),
+ self->max_size.width),
+ self->min_size.width);
+ placeh = MAX(MIN(MIN(self->area.height, a.height),
+ self->max_size.height),
+ self->min_size.height);
+
+ ob_debug("setting window size to %dx%d\n",
+ self->area.width, self->area.height);
+ }
+ }
+
+
+ ob_debug("placing window 0x%x at %d, %d with size %d x %d. "
+ "some restrictions may apply\n",
+ self->window, placex, placey, placew, placeh);