mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
Update _NET_CURRENT_DESKTOP on workspace removal
When we delete a workspace before the active workspace, we need to upate the _NET_CURRENT_DESKTOP since the active workspace index changes. To do this workspace.c:set_active_space_hint() is moved to screen.c:meta_screen_set_active_workspace_hint() so that it can be shared. https://bugzilla.gnome.org/show_bug.cgi?id=640581
This commit is contained in:
parent
ad707be01e
commit
4c4c720dc1
@ -255,4 +255,6 @@ void meta_screen_workspace_switched (MetaScreen *screen,
|
||||
int to,
|
||||
MetaMotionDirection direction);
|
||||
|
||||
void meta_screen_set_active_workspace_hint (MetaScreen *screen);
|
||||
|
||||
#endif
|
||||
|
@ -1283,6 +1283,7 @@ meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace,
|
||||
MetaWorkspace *neighbour = NULL;
|
||||
GList *next = NULL;
|
||||
int index;
|
||||
gboolean active_index_changed;
|
||||
int new_num;
|
||||
|
||||
l = screen->workspaces;
|
||||
@ -1321,6 +1322,7 @@ meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace,
|
||||
|
||||
/* To emit the signal after removing the workspace */
|
||||
index = meta_workspace_index (workspace);
|
||||
active_index_changed = index < meta_screen_get_active_workspace_index (screen);
|
||||
|
||||
/* This also removes the workspace from the screens list */
|
||||
meta_workspace_remove (workspace);
|
||||
@ -1330,6 +1332,11 @@ meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace,
|
||||
set_number_of_spaces_hint (screen, new_num);
|
||||
meta_prefs_set_num_workspaces (new_num);
|
||||
|
||||
/* If deleting a workspace before the current workspace, the active
|
||||
* workspace index changes, so we need to update that hint */
|
||||
if (active_index_changed)
|
||||
meta_screen_set_active_workspace_hint (workspace->screen);
|
||||
|
||||
l = next;
|
||||
while (l)
|
||||
{
|
||||
@ -3345,3 +3352,29 @@ meta_screen_workspace_switched (MetaScreen *screen,
|
||||
from, to, direction);
|
||||
}
|
||||
|
||||
void
|
||||
meta_screen_set_active_workspace_hint (MetaScreen *screen)
|
||||
{
|
||||
unsigned long data[1];
|
||||
|
||||
/* this is because we destroy the spaces in order,
|
||||
* so we always end up setting a current desktop of
|
||||
* 0 when closing a screen, so lose the current desktop
|
||||
* on restart. By doing this we keep the current
|
||||
* desktop on restart.
|
||||
*/
|
||||
if (screen->closing > 0)
|
||||
return;
|
||||
|
||||
data[0] = meta_workspace_index (screen->active_workspace);
|
||||
|
||||
meta_verbose ("Setting _NET_CURRENT_DESKTOP to %lu\n", data[0]);
|
||||
|
||||
meta_error_trap_push (screen->display);
|
||||
XChangeProperty (screen->display->xdisplay, screen->xroot,
|
||||
screen->display->atom__NET_CURRENT_DESKTOP,
|
||||
XA_CARDINAL,
|
||||
32, PropModeReplace, (guchar*) data, 1);
|
||||
meta_error_trap_pop (screen->display);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "screen-private.h"
|
||||
#include "workspace.h"
|
||||
#include "workspace-private.h"
|
||||
#include "boxes-private.h"
|
||||
@ -45,7 +46,6 @@ enum {
|
||||
};
|
||||
|
||||
void meta_workspace_queue_calc_showing (MetaWorkspace *workspace);
|
||||
static void set_active_space_hint (MetaScreen *screen);
|
||||
static void focus_ancestor_or_mru_window (MetaWorkspace *workspace,
|
||||
MetaWindow *not_this_one,
|
||||
guint32 timestamp);
|
||||
@ -557,7 +557,7 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
|
||||
|
||||
workspace->screen->active_workspace = workspace;
|
||||
|
||||
set_active_space_hint (workspace->screen);
|
||||
meta_screen_set_active_workspace_hint (workspace->screen);
|
||||
|
||||
/* If the "show desktop" mode is active for either the old workspace
|
||||
* or the new one *but not both*, then update the
|
||||
@ -752,32 +752,6 @@ meta_workspace_list_windows (MetaWorkspace *workspace)
|
||||
return workspace_windows;
|
||||
}
|
||||
|
||||
static void
|
||||
set_active_space_hint (MetaScreen *screen)
|
||||
{
|
||||
unsigned long data[1];
|
||||
|
||||
/* this is because we destroy the spaces in order,
|
||||
* so we always end up setting a current desktop of
|
||||
* 0 when closing a screen, so lose the current desktop
|
||||
* on restart. By doing this we keep the current
|
||||
* desktop on restart.
|
||||
*/
|
||||
if (screen->closing > 0)
|
||||
return;
|
||||
|
||||
data[0] = meta_workspace_index (screen->active_workspace);
|
||||
|
||||
meta_verbose ("Setting _NET_CURRENT_DESKTOP to %lu\n", data[0]);
|
||||
|
||||
meta_error_trap_push (screen->display);
|
||||
XChangeProperty (screen->display->xdisplay, screen->xroot,
|
||||
screen->display->atom__NET_CURRENT_DESKTOP,
|
||||
XA_CARDINAL,
|
||||
32, PropModeReplace, (guchar*) data, 1);
|
||||
meta_error_trap_pop (screen->display);
|
||||
}
|
||||
|
||||
void
|
||||
meta_workspace_invalidate_work_area (MetaWorkspace *workspace)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user