+ /* adjust the frame to the client's size before showing or placing
+ the window */
+ frame_adjust_area(self->frame, FALSE, TRUE, FALSE);
+ frame_adjust_client_area(self->frame);
+
+ /* where the frame was placed is where the window was originally */
+ placex = self->area.x;
+ placey = self->area.y;
+ placew = self->area.width;
+ placeh = self->area.height;
+
+ /* figure out placement for the window if the window is new */
+ if (ob_state() == OB_STATE_RUNNING) {
+ ob_debug("Positioned: %s @ %d %d\n",
+ (!self->positioned ? "no" :
+ (self->positioned == PPosition ? "program specified" :
+ (self->positioned == USPosition ? "user specified" :
+ (self->positioned == (PPosition | USPosition) ?
+ "program + user specified" :
+ "BADNESS !?")))), placex, placey);
+
+ ob_debug("Sized: %s @ %d %d\n",
+ (!self->sized ? "no" :
+ (self->sized == PSize ? "program specified" :
+ (self->sized == USSize ? "user specified" :
+ (self->sized == (PSize | USSize) ?
+ "program + user specified" :
+ "BADNESS !?")))), placew, placeh);
+
+ /* splash screens are also returned as TRUE for transient,
+ and so will be forced on screen below */
+ transient = place_client(self, &placex, &placey, settings);
+
+ /* make sure the window is visible. */
+ client_find_onscreen(self, &placex, &placey, placew, placeh,
+ /* non-normal clients has less rules, and
+ windows that are being restored from a
+ session do also. we can assume you want
+ it back where you saved it. Clients saying
+ they placed themselves are subjected to
+ harder rules, ones that are placed by
+ place.c or by the user are allowed partially
+ off-screen and on xinerama divides (ie,
+ it is up to the placement routines to avoid
+ the xinerama divides)
+
+ splash screens get "transient" set to TRUE by
+ the place_client call
+ */
+ ob_state() == OB_STATE_RUNNING &&
+ (transient ||
+ (!(self->positioned & USPosition) &&
+ client_normal(self) &&
+ !self->session)));
+ }
+
+ /* 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!
+
+ splash screens get "transient" set to TRUE by
+ the place_client call
+ */
+ if (ob_state() == OB_STATE_RUNNING &&
+ (transient ||
+ (!(self->sized & USSize || self->positioned & USPosition) &&
+ client_normal(self) &&
+ !self->session)))
+ {
+ Rect placer;
+
+ RECT_SET(placer, placex, placey, placew, placeh);
+ frame_rect_to_frame(self->frame, &placer);
+
+ Rect *a = screen_area(self->desktop, SCREEN_AREA_ONE_MONITOR, &placer);
+
+ /* 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 = MIN(self->area.width, a->width);
+ placeh = MIN(self->area.height, a->height);
+
+ ob_debug("setting window size to %dx%d\n",
+ self->area.width, self->area.height);
+ }
+ g_free(a);
+ }
+
+
+ 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);
+ if (self->session)
+ ob_debug(" but session requested %d, %d %d x %d instead, "
+ "overriding\n",
+ self->session->x, self->session->y,
+ self->session->w, self->session->h);
+
+ /* do this after the window is placed, so the premax/prefullscreen numbers
+ won't be all wacko!!
+
+ this also places the window
+ */
+ client_apply_startup_state(self, placex, placey, placew, placeh);
+
+ if (activate) {
+ guint32 last_time = focus_client ?
+ focus_client->user_time : CurrentTime;
+
+ /* This is focus stealing prevention */
+ ob_debug_type(OB_DEBUG_FOCUS,
+ "Want to focus new window 0x%x with time %u "
+ "(last time %u)\n",
+ self->window, self->user_time, last_time);
+
+ /* if it's on another desktop */
+ if (!(self->desktop == screen_desktop || self->desktop == DESKTOP_ALL)
+ && /* the timestamp is from before you changed desktops */
+ self->user_time && screen_desktop_user_time &&
+ !event_time_after(self->user_time, screen_desktop_user_time))
+ {
+ activate = FALSE;
+ ob_debug_type(OB_DEBUG_FOCUS,
+ "Not focusing the window because its on another "
+ "desktop\n");
+ }
+ /* If something is focused, and it's not our relative... */
+ else if (focus_client && client_search_focus_tree_full(self) == NULL &&
+ client_search_focus_group_full(self) == NULL)
+ {
+ /* If time stamp is old, don't steal focus */
+ if (self->user_time && last_time &&
+ !event_time_after(self->user_time, last_time))
+ {
+ activate = FALSE;
+ ob_debug_type(OB_DEBUG_FOCUS,
+ "Not focusing the window because the time is "
+ "too old\n");
+ }
+ /* If its a transient (and parents aren't focused) and the time
+ is ambiguous (either the current focus target doesn't have
+ a timestamp, or they are the same (we probably inherited it
+ from them) */
+ else if (client_has_parent(self) &&
+ (!last_time || self->user_time == last_time))
+ {
+ activate = FALSE;
+ ob_debug_type(OB_DEBUG_FOCUS,
+ "Not focusing the window because it is a "
+ "transient, and the time is very ambiguous\n");