Partially resolve the conflicting requirements of windows on multiple

2004-12-22  Elijah Newren  <newren@gmail.com>

	Partially resolve the conflicting requirements of windows on
	multiple workspaces and hidden being a global quantity for windows
	(fixes bug 156182; the remainder of the work is bug 87531 and is a
	libwnck issue)

	* src/display.c (event_callback):
	* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
	* src/workspace.c (meta_workspace_add_window,
	meta_workspace_contains_window,
	meta_workspace_queue_calc_showing):
	* src/workspace.h:

	Remove meta_workspace_contains_window, replace with simple
	comparison utilizing window->workspace

	* src/place.c (meta_window_place):
	* src/window.c (meta_window_shares_some_workspace):
	* src/window.h:

	Remove meta_window_shares_some_workspace, replace with a simple
	comparison utilizing window->workspace

	* src/session.c (save_state),
	* src/window.c (meta_window_new_with_attrs,
	meta_window_apply_session_info, meta_window_free,
	window_showing_on_its_workspace,
	meta_window_change_workspace_without_transients,
	meta_window_unstick, meta_window_set_current_workspace_hint,
	meta_window_get_workspaces):
	* src/window.h:
	* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
	meta_workspace_remove_window):

	Only one workspace now
This commit is contained in:
Elijah Newren 2004-12-22 23:52:52 +00:00 committed by Elijah Newren
parent 85d4c396d0
commit f4f8699d84
8 changed files with 93 additions and 152 deletions

View File

@ -1,3 +1,40 @@
2004-12-22 Elijah Newren <newren@gmail.com>
Partially resolve the conflicting requirements of windows on
multiple workspaces and hidden being a global quantity for windows
(fixes bug 156182; the remainder of the work is bug 87531 and is a
libwnck issue)
* src/display.c (event_callback):
* src/window.c (meta_window_visible_on_workspace, meta_window_unstick):
* src/workspace.c (meta_workspace_add_window,
meta_workspace_contains_window,
meta_workspace_queue_calc_showing):
* src/workspace.h:
Remove meta_workspace_contains_window, replace with simple
comparison utilizing window->workspace
* src/place.c (meta_window_place):
* src/window.c (meta_window_shares_some_workspace):
* src/window.h:
Remove meta_window_shares_some_workspace, replace with a simple
comparison utilizing window->workspace
* src/session.c (save_state),
* src/window.c (meta_window_new_with_attrs,
meta_window_apply_session_info, meta_window_free,
window_showing_on_its_workspace,
meta_window_change_workspace_without_transients,
meta_window_unstick, meta_window_set_current_workspace_hint,
meta_window_get_workspaces):
* src/window.h:
* src/workspace.c (meta_workspace_free, meta_workspace_add_window,
meta_workspace_remove_window):
Only one workspace now
2004-12-20 Elijah Newren <newren@gmail.com> 2004-12-20 Elijah Newren <newren@gmail.com>
* configure.in: post-release version bump to 2.9.3 * configure.in: post-release version bump to 2.9.3

View File

@ -1947,8 +1947,7 @@ event_callback (XEvent *event,
if (window->minimized) if (window->minimized)
{ {
meta_window_unminimize (window); meta_window_unminimize (window);
if (!meta_workspace_contains_window (window->screen->active_workspace, if (window->workspace != window->screen->active_workspace)
window))
{ {
meta_verbose ("Changing workspace due to MapRequest mapped = %d minimized = %d\n", meta_verbose ("Changing workspace due to MapRequest mapped = %d minimized = %d\n",
window->mapped, window->minimized); window->mapped, window->minimized);

View File

@ -750,7 +750,7 @@ meta_window_place (MetaWindow *window,
if (!w->minimized && if (!w->minimized &&
w != window && w != window &&
meta_window_shares_some_workspace (window, w)) window->workspace == w->workspace)
windows = g_list_prepend (windows, w); windows = g_list_prepend (windows, w);
tmp = tmp->next; tmp = tmp->next;

View File

@ -1004,18 +1004,11 @@ save_state (void)
} }
/* Workspaces we're on */ /* Workspaces we're on */
{
GList *w;
w = window->workspaces;
while (w != NULL)
{ {
int n; int n;
n = meta_workspace_index (w->data); n = meta_workspace_index (window->workspace);
fprintf (outfile, fprintf (outfile,
" <workspace index=\"%d\"/>\n", n); " <workspace index=\"%d\"/>\n", n);
w = w->next;
}
} }
/* Gravity */ /* Gravity */

View File

@ -368,7 +368,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
* type * type
*/ */
window->display = display; window->display = display;
window->workspaces = NULL; window->workspace = NULL;
#ifdef HAVE_XSYNC #ifdef HAVE_XSYNC
window->sync_request_counter = None; window->sync_request_counter = None;
@ -652,7 +652,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
} }
} }
if (window->workspaces == NULL && if (window->workspace == NULL &&
window->xtransient_for != None) window->xtransient_for != None)
{ {
/* Try putting dialog on parent's workspace */ /* Try putting dialog on parent's workspace */
@ -663,28 +663,20 @@ meta_window_new_with_attrs (MetaDisplay *display,
if (parent) if (parent)
{ {
GList *tmp_list;
meta_topic (META_DEBUG_PLACEMENT, meta_topic (META_DEBUG_PLACEMENT,
"Putting window %s on some workspaces as parent %s\n", "Putting window %s on same workspace as parent %s\n",
window->desc, parent->desc); window->desc, parent->desc);
if (parent->on_all_workspaces) if (parent->on_all_workspaces)
window->on_all_workspaces = TRUE; window->on_all_workspaces = TRUE;
tmp_list = parent->workspaces;
while (tmp_list != NULL)
{
/* this will implicitly add to the appropriate MRU lists /* this will implicitly add to the appropriate MRU lists
*/ */
meta_workspace_add_window (tmp_list->data, window); meta_workspace_add_window (parent->workspace, window);
tmp_list = tmp_list->next;
}
} }
} }
if (window->workspaces == NULL) if (window->workspace == NULL)
{ {
meta_topic (META_DEBUG_PLACEMENT, meta_topic (META_DEBUG_PLACEMENT,
"Putting window %s on active workspace\n", "Putting window %s on active workspace\n",
@ -831,25 +823,19 @@ meta_window_apply_session_info (MetaWindow *window,
* ensured that one of the workspaces from the session was * ensured that one of the workspaces from the session was
* indeed valid, so we know we'll go right back to one. * indeed valid, so we know we'll go right back to one.
*/ */
while (window->workspaces) if (window->workspace)
meta_workspace_remove_window (window->workspaces->data, window); meta_workspace_remove_window (window->workspace, window);
tmp = spaces; /* Only restore to the first workspace if the window
while (tmp != NULL) * happened to be on more than one, since we have replaces
{ * window->workspaces with window->workspace
MetaWorkspace *space; */
meta_workspace_add_window (spaces->data, window);
space = tmp->data;
meta_workspace_add_window (space, window);
meta_topic (META_DEBUG_SM, meta_topic (META_DEBUG_SM,
"Restoring saved window %s to workspace %d\n", "Restoring saved window %s to workspace %d\n",
window->desc, window->desc,
meta_workspace_index (space)); meta_workspace_index (spaces->data));
tmp = tmp->next;
}
g_slist_free (spaces); g_slist_free (spaces);
} }
@ -978,20 +964,10 @@ meta_window_free (MetaWindow *window)
meta_window_unqueue_update_icon (window); meta_window_unqueue_update_icon (window);
meta_window_free_delete_dialog (window); meta_window_free_delete_dialog (window);
tmp = window->workspaces; if (window->workspace)
while (tmp != NULL) meta_workspace_remove_window (window->workspace, window);
{
GList *next;
next = tmp->next; g_assert (window->workspace == NULL);
/* pops front of list */
meta_workspace_remove_window (tmp->data, window);
tmp = next;
}
g_assert (window->workspaces == NULL);
#ifndef G_DISABLE_CHECKS #ifndef G_DISABLE_CHECKS
tmp = window->screen->workspaces; tmp = window->screen->workspaces;
@ -1200,7 +1176,7 @@ meta_window_visible_on_workspace (MetaWindow *window,
MetaWorkspace *workspace) MetaWorkspace *workspace)
{ {
return (window->on_all_workspaces && window->screen == workspace->screen) || return (window->on_all_workspaces && window->screen == workspace->screen) ||
meta_workspace_contains_window (workspace, window); (window->workspace == workspace);
} }
static gboolean static gboolean
@ -1250,20 +1226,12 @@ window_showing_on_its_workspace (MetaWindow *window)
&is_desktop_or_dock); &is_desktop_or_dock);
if (window->on_all_workspaces) if (window->on_all_workspaces)
/* Unless the behavior in bug 87531 is implemented, or else /* Until the behavior in bug 87531 is implemented, this will be
* _NET_WM_STATE_HIDDEN can be made per-workspace instead of * just a hack that only sort of works.
* global, or else we get rid of on_all_workspaces windows
* altogether, then this will be just a hack that only sort of
* works.
*/ */
workspace_of_window = window->screen->active_workspace; workspace_of_window = window->screen->active_workspace;
else if (window->workspaces) else if (window->workspace)
/* This is sort of hacky too; would like to guarantee that workspace_of_window = window->workspace;
* window->workspaces only contains a single workspace. I believe
* that's currently true in Metacity, but it isn't guaranteed to
* remain true in the future.
*/
workspace_of_window = window->workspaces->data;
else /* This only seems to be needed for startup */ else /* This only seems to be needed for startup */
workspace_of_window = NULL; workspace_of_window = NULL;
@ -3369,8 +3337,6 @@ static void
meta_window_change_workspace_without_transients (MetaWindow *window, meta_window_change_workspace_without_transients (MetaWindow *window,
MetaWorkspace *workspace) MetaWorkspace *workspace)
{ {
GList *next;
meta_verbose ("Changing window %s to workspace %d\n", meta_verbose ("Changing window %s to workspace %d\n",
window->desc, meta_workspace_index (workspace)); window->desc, meta_workspace_index (workspace));
@ -3382,24 +3348,11 @@ meta_window_change_workspace_without_transients (MetaWindow *window,
meta_window_unstick (window); meta_window_unstick (window);
/* See if we're already on this space. If not, make sure we are */ /* See if we're already on this space. If not, make sure we are */
if (g_list_find (window->workspaces, workspace) == NULL) if (window->workspace != workspace)
meta_workspace_add_window (workspace, window);
/* Remove from all other spaces */
next = window->workspaces;
while (next != NULL)
{ {
MetaWorkspace *remove; meta_workspace_remove_window (window->workspace, window);
remove = next->data; meta_workspace_add_window (workspace, window);
next = next->next;
if (remove != workspace)
meta_workspace_remove_window (remove, window);
} }
/* list size == 1 */
g_assert (window->workspaces != NULL);
g_assert (window->workspaces->next == NULL);
} }
static gboolean static gboolean
@ -3473,7 +3426,7 @@ meta_window_unstick (MetaWindow *window)
while (tmp) while (tmp)
{ {
workspace = (MetaWorkspace *) tmp->data; workspace = (MetaWorkspace *) tmp->data;
if (!meta_workspace_contains_window (workspace, window)) if (window->workspace != workspace)
workspace->mru_list = g_list_remove (workspace->mru_list, window); workspace->mru_list = g_list_remove (workspace->mru_list, window);
tmp = tmp->next; tmp = tmp->next;
} }
@ -3483,8 +3436,7 @@ meta_window_unstick (MetaWindow *window)
* on more than one workspace this should probably be add_workspace * on more than one workspace this should probably be add_workspace
* not change_workspace. * not change_workspace.
*/ */
if (!meta_workspace_contains_window (window->screen->active_workspace, if (window->screen->active_workspace != window->workspace)
window))
meta_window_change_workspace (window, window->screen->active_workspace); meta_window_change_workspace (window, window->screen->active_workspace);
meta_window_set_current_workspace_hint (window); meta_window_set_current_workspace_hint (window);
@ -3495,11 +3447,10 @@ meta_window_unstick (MetaWindow *window)
unsigned long unsigned long
meta_window_get_net_wm_desktop (MetaWindow *window) meta_window_get_net_wm_desktop (MetaWindow *window)
{ {
if (window->on_all_workspaces || if (window->on_all_workspaces)
g_list_length (window->workspaces) > 1)
return 0xFFFFFFFF; return 0xFFFFFFFF;
else else
return meta_workspace_index (window->workspaces->data); return meta_workspace_index (window->workspace);
} }
static void static void
@ -3540,7 +3491,7 @@ meta_window_set_current_workspace_hint (MetaWindow *window)
*/ */
unsigned long data[1]; unsigned long data[1];
if (window->workspaces == NULL) if (window->workspace == NULL)
{ {
/* this happens when unmanaging windows */ /* this happens when unmanaging windows */
return; return;
@ -5189,7 +5140,7 @@ meta_window_get_workspaces (MetaWindow *window)
if (window->on_all_workspaces) if (window->on_all_workspaces)
return window->screen->workspaces; return window->screen->workspaces;
else else
return window->workspaces; return g_list_prepend (NULL, window->workspace);
} }
static void static void
@ -6591,28 +6542,6 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
} }
} }
gboolean
meta_window_shares_some_workspace (MetaWindow *window,
MetaWindow *with)
{
GList *tmp;
if (window->on_all_workspaces ||
with->on_all_workspaces)
return TRUE;
tmp = window->workspaces;
while (tmp != NULL)
{
if (g_list_find (with->workspaces, tmp->data) != NULL)
return TRUE;
tmp = tmp->next;
}
return FALSE;
}
void void
meta_window_set_gravity (MetaWindow *window, meta_window_set_gravity (MetaWindow *window,
int gravity) int gravity)

View File

@ -64,7 +64,7 @@ struct _MetaWindow
{ {
MetaDisplay *display; MetaDisplay *display;
MetaScreen *screen; MetaScreen *screen;
GList *workspaces; MetaWorkspace *workspace;
Window xwindow; Window xwindow;
/* may be NULL! not all windows get decorated */ /* may be NULL! not all windows get decorated */
MetaFrame *frame; MetaFrame *frame;
@ -458,9 +458,6 @@ void meta_window_show_menu (MetaWindow *window,
int button, int button,
Time timestamp); Time timestamp);
gboolean meta_window_shares_some_workspace (MetaWindow *window,
MetaWindow *with);
void meta_window_set_gravity (MetaWindow *window, void meta_window_set_gravity (MetaWindow *window,
int gravity); int gravity);

View File

@ -94,7 +94,7 @@ meta_workspace_free (MetaWorkspace *workspace)
/* pop front of list we're iterating over */ /* pop front of list we're iterating over */
meta_workspace_remove_window (workspace, window); meta_workspace_remove_window (workspace, window);
g_assert (window->workspaces != NULL); g_assert (window->workspace != NULL);
tmp = next; tmp = next;
} }
@ -125,14 +125,14 @@ void
meta_workspace_add_window (MetaWorkspace *workspace, meta_workspace_add_window (MetaWorkspace *workspace,
MetaWindow *window) MetaWindow *window)
{ {
g_return_if_fail (!meta_workspace_contains_window (workspace, window)); g_return_if_fail (window->workspace == NULL);
/* If the window is on all workspaces, we want to add it to all mru /* If the window is on all workspaces, we want to add it to all mru
* lists, otherwise just add it to this workspaces mru list * lists, otherwise just add it to this workspaces mru list
*/ */
if (window->on_all_workspaces) if (window->on_all_workspaces)
{ {
if (window->workspaces == NULL) if (window->workspace == NULL)
{ {
GList* tmp = window->screen->workspaces; GList* tmp = window->screen->workspaces;
while (tmp) while (tmp)
@ -152,7 +152,7 @@ meta_workspace_add_window (MetaWorkspace *workspace,
} }
workspace->windows = g_list_prepend (workspace->windows, window); workspace->windows = g_list_prepend (workspace->windows, window);
window->workspaces = g_list_prepend (window->workspaces, workspace); window->workspace = workspace;
meta_window_set_current_workspace_hint (window); meta_window_set_current_workspace_hint (window);
@ -175,18 +175,16 @@ void
meta_workspace_remove_window (MetaWorkspace *workspace, meta_workspace_remove_window (MetaWorkspace *workspace,
MetaWindow *window) MetaWindow *window)
{ {
g_return_if_fail (meta_workspace_contains_window (workspace, window)); g_return_if_fail (window->workspace == workspace);
workspace->windows = g_list_remove (workspace->windows, window); workspace->windows = g_list_remove (workspace->windows, window);
window->workspaces = g_list_remove (window->workspaces, workspace); window->workspace = NULL;
/* If the window is on all workspaces, we don't want to remove it /* If the window is on all workspaces, we don't want to remove it
* from the MRU list unless this causes it to be removed from all * from the MRU list unless this causes it to be removed from all
* workspaces * workspaces
*/ */
if (window->on_all_workspaces) if (window->on_all_workspaces)
{
if (window->workspaces == NULL)
{ {
GList* tmp = window->screen->workspaces; GList* tmp = window->screen->workspaces;
while (tmp) while (tmp)
@ -197,7 +195,6 @@ meta_workspace_remove_window (MetaWorkspace *workspace,
tmp = tmp->next; tmp = tmp->next;
} }
} }
}
else else
{ {
workspace->mru_list = g_list_remove (workspace->mru_list, window); workspace->mru_list = g_list_remove (workspace->mru_list, window);
@ -250,13 +247,6 @@ meta_workspace_relocate_windows (MetaWorkspace *workspace,
g_assert (workspace->windows == NULL); g_assert (workspace->windows == NULL);
} }
gboolean
meta_workspace_contains_window (MetaWorkspace *workspace,
MetaWindow *window)
{
return g_list_find (window->workspaces, workspace) != NULL;
}
void void
meta_workspace_queue_calc_showing (MetaWorkspace *workspace) meta_workspace_queue_calc_showing (MetaWorkspace *workspace)
{ {
@ -317,10 +307,9 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
* never gets unmapped and we maintain the button grab * never gets unmapped and we maintain the button grab
* on it. * on it.
*/ */
if (move_window) if (move_window && (move_window->workspace != workspace))
{ {
if (!meta_workspace_contains_window (workspace, meta_workspace_remove_window (workspace, move_window);
move_window))
meta_workspace_add_window (workspace, move_window); meta_workspace_add_window (workspace, move_window);
} }
} }

View File

@ -61,9 +61,6 @@ void meta_workspace_remove_window (MetaWorkspace *workspace,
MetaWindow *window); MetaWindow *window);
void meta_workspace_relocate_windows (MetaWorkspace *workspace, void meta_workspace_relocate_windows (MetaWorkspace *workspace,
MetaWorkspace *new_home); MetaWorkspace *new_home);
/* don't confuse with meta_window_visible_on_workspace() */
gboolean meta_workspace_contains_window (MetaWorkspace *workspace,
MetaWindow *window);
void meta_workspace_activate_with_focus (MetaWorkspace *workspace, void meta_workspace_activate_with_focus (MetaWorkspace *workspace,
MetaWindow *focus_this, MetaWindow *focus_this,
Time timestamp); Time timestamp);