+void client_fake_unmanage(ObClient *self)
+{
+ /* this is all that got allocated to get the decorations */
+
+ frame_free(self->frame);
+ g_free(self);
+}
+
+static ObAppSettings *client_get_settings_state(ObClient *self)
+{
+ ObAppSettings *settings = NULL;
+ GSList *it;
+
+ for (it = config_per_app_settings; it; it = g_slist_next(it)) {
+ ObAppSettings *app = it->data;
+
+ if ((app->name && !app->class && !strcmp(app->name, self->name))
+ || (app->class && !app->name && !strcmp(app->class, self->class))
+ || (app->class && app->name && !strcmp(app->class, self->class)
+ && !strcmp(app->name, self->name)))
+ {
+ /* Match if no role was specified in the per app setting, or if the
+ * string matches the beginning of the role, since apps like to set
+ * the role to things like browser-window-23c4b2f */
+ if (!app->role
+ || !strncmp(app->role, self->role, strlen(app->role)))
+ {
+ ob_debug("Window matching: %s\n", app->name);
+ /* use this one */
+ settings = app;
+ break;
+ }
+ }
+ }
+
+ if (settings) {
+ if (settings->shade != -1)
+ self->shaded = !!settings->shade;
+ if (settings->decor != -1)
+ self->undecorated = !settings->decor;
+ if (settings->iconic != -1)
+ self->iconic = !!settings->iconic;
+ if (settings->skip_pager != -1)
+ self->skip_pager = !!settings->skip_pager;
+ if (settings->skip_taskbar != -1)
+ self->skip_taskbar = !!settings->skip_taskbar;
+
+ if (settings->max_vert != -1)
+ self->max_vert = !!settings->max_vert;
+ if (settings->max_horz != -1)
+ self->max_horz = !!settings->max_horz;
+
+ if (settings->fullscreen != -1)
+ self->fullscreen = !!settings->fullscreen;
+
+ if (settings->desktop) {
+ if (settings->desktop == DESKTOP_ALL)
+ self->desktop = settings->desktop;
+ else if (settings->desktop > 0 &&
+ settings->desktop <= screen_num_desktops)
+ self->desktop = settings->desktop - 1;
+ }
+
+ if (settings->layer == -1) {
+ self->below = TRUE;
+ self->above = FALSE;
+ }
+ else if (settings->layer == 0) {
+ self->below = FALSE;
+ self->above = FALSE;
+ }
+ else if (settings->layer == 1) {
+ self->below = FALSE;
+ self->above = TRUE;
+ }
+ }
+ return settings;
+}
+
+static void client_restore_session_state(ObClient *self)
+{
+ GList *it;
+
+ ob_debug_type(OB_DEBUG_SM,
+ "Restore session for client %s\n", self->title);
+
+ if (!(it = session_state_find(self))) {
+ ob_debug_type(OB_DEBUG_SM,
+ "Session data not found for client %s\n", self->title);
+ return;
+ }
+
+ self->session = it->data;
+
+ ob_debug_type(OB_DEBUG_SM, "Session data loaded for client %s\n",
+ self->title);
+
+ RECT_SET_POINT(self->area, self->session->x, self->session->y);
+ self->positioned = USPosition;
+ if (self->session->w > 0)
+ self->area.width = self->session->w;
+ if (self->session->h > 0)
+ self->area.height = self->session->h;
+ XResizeWindow(ob_display, self->window,
+ self->area.width, self->area.height);
+
+ self->desktop = (self->session->desktop == DESKTOP_ALL ?
+ self->session->desktop :
+ MIN(screen_num_desktops - 1, self->session->desktop));
+ PROP_SET32(self->window, net_wm_desktop, cardinal, self->desktop);
+
+ self->shaded = self->session->shaded;
+ self->iconic = self->session->iconic;
+ self->skip_pager = self->session->skip_pager;
+ self->skip_taskbar = self->session->skip_taskbar;
+ self->fullscreen = self->session->fullscreen;
+ self->above = self->session->above;
+ self->below = self->session->below;
+ self->max_horz = self->session->max_horz;
+ self->max_vert = self->session->max_vert;
+ self->undecorated = self->session->undecorated;
+}
+
+static gboolean client_restore_session_stacking(ObClient *self)
+{
+ GList *it, *mypos;
+
+ if (!self->session) return FALSE;
+
+ mypos = g_list_find(session_saved_state, self->session);
+ if (!mypos) return FALSE;
+
+ /* start above me and look for the first client */
+ for (it = g_list_previous(mypos); it; it = g_list_previous(it)) {
+ GList *cit;
+
+ for (cit = client_list; cit; cit = g_list_next(cit)) {
+ ObClient *c = cit->data;
+ /* found a client that was in the session, so go below it */
+ if (c->session == it->data) {
+ stacking_below(CLIENT_AS_WINDOW(self),
+ CLIENT_AS_WINDOW(cit->data));
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+void client_move_onscreen(ObClient *self, gboolean rude)
+{
+ gint x = self->area.x;
+ gint y = self->area.y;
+ if (client_find_onscreen(self, &x, &y,
+ self->area.width,
+ self->area.height, rude)) {
+ client_move(self, x, y);
+ }
+}
+
+gboolean client_find_onscreen(ObClient *self, gint *x, gint *y, gint w, gint h,
+ gboolean rude)