Partially fix Jacob's SM bugs.

2002-06-22  Havoc Pennington  <hp@pobox.com>

	Partially fix Jacob's SM bugs.

	* src/window.c (meta_window_apply_session_info): restore the extra
	stuff we're saving, except stack position I didn't figure out yet.

	* src/session.c: save stack position, minimized, maximized,
	in the session file.
This commit is contained in:
Havoc Pennington 2002-06-23 00:21:20 +00:00 committed by Havoc Pennington
parent 5eca441b1c
commit 97b629ad5b
4 changed files with 103 additions and 5 deletions

View File

@ -1,3 +1,13 @@
2002-06-22 Havoc Pennington <hp@pobox.com>
Partially fix Jacob's SM bugs.
* src/window.c (meta_window_apply_session_info): restore the extra
stuff we're saving, except stack position I didn't figure out yet.
* src/session.c: save stack position, minimized, maximized,
in the session file.
2002-06-22 Havoc Pennington <hp@pobox.com> 2002-06-22 Havoc Pennington <hp@pobox.com>
* src/workspace.c (set_number_of_spaces_hint): do nothing if * src/workspace.c (set_number_of_spaces_hint): do nothing if

View File

@ -826,6 +826,24 @@ decode_text_from_utf8 (const char *text)
return g_string_free (str, FALSE); return g_string_free (str, FALSE);
} }
static int
stack_cmp (const void *a,
const void *b)
{
MetaWindow *aw = (void*) a;
MetaWindow *bw = (void*) b;
if (aw->screen == bw->screen)
return meta_stack_windows_cmp (aw->screen->stack, aw, bw);
/* Then assume screens are stacked by number */
else if (aw->screen->number < bw->screen->number)
return -1;
else if (aw->screen->number > bw->screen->number)
return 1;
else
return 0; /* not reached in theory, if windows on same display */
}
static void static void
save_state (void) save_state (void)
{ {
@ -872,10 +890,10 @@ save_state (void)
/* The file format is: /* The file format is:
* <metacity_session id="foo"> * <metacity_session id="foo">
* <window id="bar" class="XTerm" name="xterm" title="/foo/bar" role="blah" type="normal"> * <window id="bar" class="XTerm" name="xterm" title="/foo/bar" role="blah" type="normal" stacking="5">
* <workspace index="2"/> * <workspace index="2"/>
* <workspace index="4"/> * <workspace index="4"/>
* <sticky/> * <sticky/> <minimized/> <maximized/>
* <geometry x="100" y="100" width="200" height="200" gravity="northwest"/> * <geometry x="100" y="100" width="200" height="200" gravity="northwest"/>
* </window> * </window>
* </metacity_session> * </metacity_session>
@ -895,8 +913,12 @@ save_state (void)
{ {
GSList *windows; GSList *windows;
GSList *tmp; GSList *tmp;
int stack_position;
windows = meta_display_list_windows (display_iter->data); windows = meta_display_list_windows (display_iter->data);
windows = g_slist_sort (windows, stack_cmp);
stack_position = 0;
tmp = windows; tmp = windows;
while (tmp != NULL) while (tmp != NULL)
{ {
@ -928,13 +950,14 @@ save_state (void)
window->desc, window->sm_client_id); window->desc, window->sm_client_id);
fprintf (outfile, fprintf (outfile,
" <window id=\"%s\" class=\"%s\" name=\"%s\" title=\"%s\" role=\"%s\" type=\"%s\">\n", " <window id=\"%s\" class=\"%s\" name=\"%s\" title=\"%s\" role=\"%s\" type=\"%s\" stacking=\"%d\">\n",
sm_client_id, sm_client_id,
res_class ? res_class : "", res_class ? res_class : "",
res_name ? res_name : "", res_name ? res_name : "",
window->title ? window->title : "", window->title ? window->title : "",
role ? role : "", role ? role : "",
window_type_to_string (window->type)); window_type_to_string (window->type),
stack_position);
g_free (sm_client_id); g_free (sm_client_id);
g_free (res_class); g_free (res_class);
@ -945,6 +968,14 @@ save_state (void)
if (window->on_all_workspaces) if (window->on_all_workspaces)
fputs (" <sticky/>\n", outfile); fputs (" <sticky/>\n", outfile);
/* Minimized */
if (window->minimized)
fputs (" <minimized/>\n", outfile);
/* Maximized */
if (window->maximized)
fputs (" <maximized/>\n", outfile);
/* Workspaces we're on */ /* Workspaces we're on */
{ {
GList *w; GList *w;
@ -980,6 +1011,7 @@ save_state (void)
} }
tmp = tmp->next; tmp = tmp->next;
++stack_position;
} }
g_slist_free (windows); g_slist_free (windows);
@ -1016,6 +1048,8 @@ typedef enum
WINDOW_TAG_NONE, WINDOW_TAG_NONE,
WINDOW_TAG_DESKTOP, WINDOW_TAG_DESKTOP,
WINDOW_TAG_STICKY, WINDOW_TAG_STICKY,
WINDOW_TAG_MINIMIZED,
WINDOW_TAG_MAXIMIZED,
WINDOW_TAG_GEOMETRY WINDOW_TAG_GEOMETRY
} WindowTag; } WindowTag;
@ -1234,6 +1268,14 @@ start_element_handler (GMarkupParseContext *context,
if (*val) if (*val)
pd->info->type = window_type_from_string (val); pd->info->type = window_type_from_string (val);
} }
else if (strcmp (name, "stacking") == 0)
{
if (*val)
{
pd->info->stack_position = atoi (val);
pd->info->stack_position_set = TRUE;
}
}
else else
{ {
g_set_error (error, g_set_error (error,
@ -1286,6 +1328,16 @@ start_element_handler (GMarkupParseContext *context,
pd->info->on_all_workspaces = TRUE; pd->info->on_all_workspaces = TRUE;
pd->info->on_all_workspaces_set = TRUE; pd->info->on_all_workspaces_set = TRUE;
} }
else if (strcmp (element_name, "minimized") == 0)
{
pd->info->minimized = TRUE;
pd->info->minimized_set = TRUE;
}
else if (strcmp (element_name, "maximized") == 0)
{
pd->info->maximized = TRUE;
pd->info->maximized_set = TRUE;
}
else if (strcmp (element_name, "geometry") == 0) else if (strcmp (element_name, "geometry") == 0)
{ {
int i; int i;

View File

@ -41,6 +41,8 @@ struct _MetaWindowSessionInfo
GSList *workspace_indices; GSList *workspace_indices;
int stack_position;
/* width/height should be multiplied by resize inc and /* width/height should be multiplied by resize inc and
* added to base size; position should be interpreted in * added to base size; position should be interpreted in
* light of gravity. This preserves semantics of the * light of gravity. This preserves semantics of the
@ -49,9 +51,14 @@ struct _MetaWindowSessionInfo
int gravity; int gravity;
MetaRectangle rect; MetaRectangle rect;
guint on_all_workspaces : 1; guint on_all_workspaces : 1;
guint minimized : 1;
guint maximized : 1;
guint stack_position_set : 1;
guint geometry_set : 1; guint geometry_set : 1;
guint on_all_workspaces_set : 1; guint on_all_workspaces_set : 1;
guint minimized_set : 1;
guint maximized_set : 1;
}; };
/* If lookup_saved_state returns something, it should be used, /* If lookup_saved_state returns something, it should be used,

View File

@ -628,6 +628,35 @@ static void
meta_window_apply_session_info (MetaWindow *window, meta_window_apply_session_info (MetaWindow *window,
const MetaWindowSessionInfo *info) const MetaWindowSessionInfo *info)
{ {
if (info->stack_position_set)
{
meta_topic (META_DEBUG_SM,
"Restoring stack position %d for window %s\n",
info->stack_position, window->desc);
/* FIXME well, I'm not sure how to do this. */
}
if (info->minimized_set)
{
meta_topic (META_DEBUG_SM,
"Restoring minimized state %d for window %s\n",
info->minimized, window->desc);
if (window->has_minimize_func && info->minimized)
meta_window_minimize (window);
}
if (info->maximized_set)
{
meta_topic (META_DEBUG_SM,
"Restoring maximized state %d for window %s\n",
info->maximized, window->desc);
if (window->has_maximize_func && info->maximized)
meta_window_maximize (window);
}
if (info->on_all_workspaces_set) if (info->on_all_workspaces_set)
{ {
window->on_all_workspaces = info->on_all_workspaces; window->on_all_workspaces = info->on_all_workspaces;