summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-08-25 07:48:28 +0000
committerDana Jansens <danakj@orodu.net>2003-08-25 07:48:28 +0000
commit0964b804a135243968de22695b953f19f9e8b9d1 (patch)
tree67183e6c176a3d8972b90076bc3f256211466f14
parent486c189d0b606b6dce28ff84a472979c67d5dc9c (diff)
restore the stacking order of a saved session
-rw-r--r--openbox/client.c62
-rw-r--r--openbox/client.h5
2 files changed, 50 insertions, 17 deletions
diff --git a/openbox/client.c b/openbox/client.c
index a1deded5..961c6bbf 100644
--- a/openbox/client.c
+++ b/openbox/client.c
@@ -47,6 +47,7 @@ static void client_change_allowed_actions(ObClient *self);
static void client_change_state(ObClient *self);
static void client_apply_startup_state(ObClient *self);
static void client_restore_session_state(ObClient *self);
+static void client_restore_session_stacking(ObClient *self);
void client_startup()
{
@@ -261,6 +262,7 @@ void client_manage(Window window)
focus_order_add_new(self);
stacking_add(CLIENT_AS_WINDOW(self));
+ client_restore_session_stacking(self);
/* focus the new window? */
if (ob_state() != OB_STATE_STARTING && config_focus_new &&
@@ -472,30 +474,55 @@ void client_unmanage(ObClient *self)
static void client_restore_session_state(ObClient *self)
{
- ObSessionState *s;
+ GList *it;
+
+ if (!(it = session_state_find(self)))
+ return;
- s = session_state_find(self);
- if (!(s)) return;
+ self->session = it->data;
- RECT_SET(self->area, s->x, s->y, s->w, s->h);
+ RECT_SET(self->area, self->session->x, self->session->y,
+ self->session->w, self->session->h);
self->positioned = TRUE;
- XResizeWindow(ob_display, self->window, s->w, s->h);
+ XResizeWindow(ob_display, self->window,
+ self->session->w, self->session->h);
- self->desktop = s->desktop == DESKTOP_ALL ? s->desktop :
- MIN(screen_num_desktops - 1, s->desktop);
+ 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 = s->shaded;
- self->iconic = s->iconic;
- self->skip_pager = s->skip_pager;
- self->skip_taskbar = s->skip_taskbar;
- self->fullscreen = s->fullscreen;
- self->above = s->above;
- self->below = s->below;
- self->max_horz = s->max_horz;
- self->max_vert = s->max_vert;
+ 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;
+}
+
+static void client_restore_session_stacking(ObClient *self)
+{
+ GList *it;
+
+ if (!self->session) return;
+
+ it = g_list_find(session_saved_state, self->session);
+ for (it = g_list_previous(it); it; it = g_list_previous(it)) {
+ GList *cit;
- session_state_free(s);
+ for (cit = client_list; cit; cit = g_list_next(cit))
+ if (session_state_cmp(it->data, cit->data))
+ break;
+ if (cit) {
+ client_calc_layer(self);
+ stacking_below(CLIENT_AS_WINDOW(self),
+ CLIENT_AS_WINDOW(cit->data));
+ break;
+ }
+ }
}
void client_move_onscreen(ObClient *self, gboolean rude)
@@ -630,6 +657,7 @@ static void client_get_all(ObClient *self)
/* defaults */
self->frame = NULL;
+ self->session = NULL;
self->title = self->icon_title = NULL;
self->title_count = 1;
self->name = self->class = self->role = NULL;
diff --git a/openbox/client.h b/openbox/client.h
index 080225cf..eec1b754 100644
--- a/openbox/client.h
+++ b/openbox/client.h
@@ -12,6 +12,7 @@
struct _ObFrame;
struct _ObGroup;
+struct _ObSessionState;
typedef struct _ObClient ObClient;
typedef struct _ObClientIcon ObClientIcon;
@@ -67,6 +68,10 @@ struct _ObClient
/*! The id of the group the window belongs to */
struct _ObGroup *group;
+
+ /*! Saved session data to apply to this client */
+ struct _ObSessionState *session;
+
/*! Whether or not the client is a transient window. This is guaranteed to
be TRUE if transient_for != NULL, but not guaranteed to be FALSE if
transient_for == NULL. */