+ /* 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 */
+ place = self->area;
+ monitor = screen_physical_area_monitor(screen_find_monitor(&place));
+
+ /* figure out placement for the window if the window is new */
+ if (ob_state() == OB_STATE_RUNNING) {
+ ob_debug("Positioned: %s @ %d %d",
+ (!self->positioned ? "no" :
+ (self->positioned == PPosition ? "program specified" :
+ (self->positioned == USPosition ? "user specified" :
+ (self->positioned == (PPosition | USPosition) ?
+ "program + user specified" :
+ "BADNESS !?")))), place.x, place.y);
+
+ ob_debug("Sized: %s @ %d %d",
+ (!self->sized ? "no" :
+ (self->sized == PSize ? "program specified" :
+ (self->sized == USSize ? "user specified" :
+ (self->sized == (PSize | USSize) ?
+ "program + user specified" :
+ "BADNESS !?")))), place.width, place.height);
+
+ /* splash screens are also returned as TRUE for transient,
+ and so will be forced on screen below */
+ transient = place_client(self, &place.x, &place.y, settings);
+
+ /* make sure the window is visible. */
+ client_find_onscreen(self, &place.x, &place.y,
+ place.width, place.height,
+ /* 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) ||
+ (settings && settings->pos_given)) &&
+ client_normal(self) &&
+ !self->session &&
+ /* don't move oldschool fullscreen windows to
+ fit inside the struts (fixes Acroread, which
+ makes its fullscreen window fit the screen
+ but it is not USSize'd or USPosition'd) */
+ !(self->decorations == 0 &&
+ RECT_EQUAL(place, *monitor)))));
+ }
+
+ /* 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 &&
+ /* don't shrink oldschool fullscreen windows to fit inside the
+ struts (fixes Acroread, which makes its fullscreen window
+ fit the screen but it is not USSize'd or USPosition'd) */
+ !(self->decorations == 0 && RECT_EQUAL(place, *monitor)))))
+ {
+ Rect *a = screen_area(self->desktop, SCREEN_AREA_ONE_MONITOR, &place);
+
+ /* get the size of the frame */
+ place.width += self->frame->size.left + self->frame->size.right;
+ place.height += self->frame->size.top + self->frame->size.bottom;
+
+ /* fit the window inside the area */
+ place.width = MIN(place.width, a->width);
+ place.height = MIN(place.height, a->height);
+
+ ob_debug("setting window size to %dx%d", place.width, place.height);
+
+ /* get the size of the client back */
+ place.width -= self->frame->size.left + self->frame->size.right;
+ place.height -= self->frame->size.top + self->frame->size.bottom;
+
+ g_free(a);
+ }
+
+ ob_debug("placing window 0x%x at %d, %d with size %d x %d. "
+ "some restrictions may apply",
+ self->window, place.x, place.y, place.width, place.height);
+ if (self->session)
+ ob_debug(" but session requested %d, %d %d x %d instead, "
+ "overriding",
+ 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, place.x, place.y,
+ place.width, place.height);
+
+ g_free(monitor);
+ monitor = NULL;
+
+ ob_debug_type(OB_DEBUG_FOCUS, "Going to try activate new window? %s",
+ activate ? "yes" : "no");
+ if (activate) {
+ gboolean raise = FALSE;
+
+ /* This is focus stealing prevention */
+ ob_debug_type(OB_DEBUG_FOCUS,
+ "Want to focus new window 0x%x at time %u "
+ "launched at %u (last user interaction time %u)",
+ self->window, map_time, launch_time,
+ event_last_user_time);
+
+ if (menu_frame_visible || moveresize_in_progress) {
+ activate = FALSE;
+ raise = TRUE;
+ ob_debug_type(OB_DEBUG_FOCUS,
+ "Not focusing the window because the user is inside "
+ "an Openbox menu or is move/resizing a window and "
+ "we don't want to interrupt them");
+ }
+
+ /* if it's on another desktop */
+ else if (!(self->desktop == screen_desktop ||
+ self->desktop == DESKTOP_ALL) &&
+ /* the timestamp is from before you changed desktops */
+ launch_time && screen_desktop_user_time &&
+ !event_time_after(launch_time, screen_desktop_user_time))
+ {
+ activate = FALSE;
+ raise = TRUE;
+ ob_debug_type(OB_DEBUG_FOCUS,
+ "Not focusing the window because its on another "
+ "desktop");
+ }
+ /* 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 the user is working in another window right now, then don't
+ steal focus */
+ if (event_last_user_time && launch_time &&
+ event_time_after(event_last_user_time, launch_time) &&
+ event_last_user_time != launch_time &&
+ event_time_after(event_last_user_time,
+ map_time - OB_EVENT_USER_TIME_DELAY))
+ {
+ activate = FALSE;
+ ob_debug_type(OB_DEBUG_FOCUS,
+ "Not focusing the window because the user is "
+ "working in another window");
+ }
+ /* If its a transient (and its parents aren't focused) */
+ else if (client_has_parent(self)) {
+ activate = FALSE;
+ ob_debug_type(OB_DEBUG_FOCUS,
+ "Not focusing the window because it is a "
+ "transient, and its relatives aren't focused");