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>
* 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);
}
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
save_state (void)
{
@ -872,10 +890,10 @@ save_state (void)
/* The file format is:
* <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="4"/>
* <sticky/>
* <sticky/> <minimized/> <maximized/>
* <geometry x="100" y="100" width="200" height="200" gravity="northwest"/>
* </window>
* </metacity_session>
@ -895,8 +913,12 @@ save_state (void)
{
GSList *windows;
GSList *tmp;
int stack_position;
windows = meta_display_list_windows (display_iter->data);
windows = g_slist_sort (windows, stack_cmp);
stack_position = 0;
tmp = windows;
while (tmp != NULL)
{
@ -928,13 +950,14 @@ save_state (void)
window->desc, window->sm_client_id);
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,
res_class ? res_class : "",
res_name ? res_name : "",
window->title ? window->title : "",
role ? role : "",
window_type_to_string (window->type));
window_type_to_string (window->type),
stack_position);
g_free (sm_client_id);
g_free (res_class);
@ -945,6 +968,14 @@ save_state (void)
if (window->on_all_workspaces)
fputs (" <sticky/>\n", outfile);
/* Minimized */
if (window->minimized)
fputs (" <minimized/>\n", outfile);
/* Maximized */
if (window->maximized)
fputs (" <maximized/>\n", outfile);
/* Workspaces we're on */
{
GList *w;
@ -980,6 +1011,7 @@ save_state (void)
}
tmp = tmp->next;
++stack_position;
}
g_slist_free (windows);
@ -1016,6 +1048,8 @@ typedef enum
WINDOW_TAG_NONE,
WINDOW_TAG_DESKTOP,
WINDOW_TAG_STICKY,
WINDOW_TAG_MINIMIZED,
WINDOW_TAG_MAXIMIZED,
WINDOW_TAG_GEOMETRY
} WindowTag;
@ -1234,6 +1268,14 @@ start_element_handler (GMarkupParseContext *context,
if (*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
{
g_set_error (error,
@ -1286,6 +1328,16 @@ start_element_handler (GMarkupParseContext *context,
pd->info->on_all_workspaces = 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)
{
int i;

View File

@ -40,6 +40,8 @@ struct _MetaWindowSessionInfo
/* Information we restore */
GSList *workspace_indices;
int stack_position;
/* width/height should be multiplied by resize inc and
* added to base size; position should be interpreted in
@ -49,9 +51,14 @@ struct _MetaWindowSessionInfo
int gravity;
MetaRectangle rect;
guint on_all_workspaces : 1;
guint minimized : 1;
guint maximized : 1;
guint stack_position_set : 1;
guint geometry_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,

View File

@ -628,6 +628,35 @@ static void
meta_window_apply_session_info (MetaWindow *window,
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)
{
window->on_all_workspaces = info->on_all_workspaces;