mirror of
https://github.com/elementary/gala.git
synced 2024-12-29 04:04:29 +03:00
Fix crash resulting from missing removal of workspaces when their number changes
This commit is contained in:
parent
813ab28e25
commit
374a254a00
@ -256,7 +256,7 @@ namespace Gala
|
|||||||
{
|
{
|
||||||
check_last_workspace ();
|
check_last_workspace ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_windows ()
|
void update_windows ()
|
||||||
{
|
{
|
||||||
windows.remove_all_children ();
|
windows.remove_all_children ();
|
||||||
@ -451,14 +451,14 @@ namespace Gala
|
|||||||
if (workspace == null)
|
if (workspace == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (!Prefs.get_dynamic_workspaces ())
|
||||||
|
return false;
|
||||||
|
|
||||||
if (workspace.index () == screen.n_workspaces - 1) {
|
if (workspace.index () == screen.n_workspaces - 1) {
|
||||||
wallpaper.animate (AnimationMode.EASE_OUT_QUAD, 300, opacity : 210);
|
wallpaper.animate (AnimationMode.EASE_OUT_QUAD, 300, opacity : 210);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Prefs.get_dynamic_workspaces ())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//dont allow closing the tab if it's the last one used
|
//dont allow closing the tab if it's the last one used
|
||||||
if (workspace.index () == 0 && screen.n_workspaces == 2)
|
if (workspace.index () == 0 && screen.n_workspaces == 2)
|
||||||
return false;
|
return false;
|
||||||
|
@ -79,13 +79,30 @@ namespace Gala
|
|||||||
|
|
||||||
add_child (thumbnails);
|
add_child (thumbnails);
|
||||||
add_child (scroll);
|
add_child (scroll);
|
||||||
|
|
||||||
screen.workareas_changed.connect (initial_configuration);
|
screen.workareas_changed.connect (initial_configuration);
|
||||||
|
|
||||||
//place it somewhere low, so it won't slide down on first open
|
//place it somewhere low, so it won't slide down on first open
|
||||||
int swidth, sheight;
|
int swidth, sheight;
|
||||||
screen.get_size (out swidth, out sheight);
|
screen.get_size (out swidth, out sheight);
|
||||||
y = sheight;
|
y = sheight;
|
||||||
|
|
||||||
|
screen.workspace_added.connect ((obj) => {
|
||||||
|
create_workspace_thumb (screen.get_workspace_by_index (obj));
|
||||||
|
});
|
||||||
|
|
||||||
|
Prefs.add_listener ((pref) => {
|
||||||
|
if (!Prefs.get_dynamic_workspaces () && pref == Preference.NUM_WORKSPACES) {
|
||||||
|
// only need to listen for the case when workspaces were removed.
|
||||||
|
// Any other case will be caught by the workspace_added signal.
|
||||||
|
// For some reason workspace_removed is not emitted, when changing the workspace number
|
||||||
|
if (Prefs.get_num_workspaces () < thumbnails.get_n_children ()) {
|
||||||
|
for (int i = Prefs.get_num_workspaces () - 1; i < thumbnails.get_n_children (); i++) {
|
||||||
|
(thumbnails.get_child_at_index (i) as WorkspaceThumb).closed ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//method that waits for the workspaces to be configured on first run
|
//method that waits for the workspaces to be configured on first run
|
||||||
@ -172,17 +189,21 @@ namespace Gala
|
|||||||
|
|
||||||
void add_workspace ()
|
void add_workspace ()
|
||||||
{
|
{
|
||||||
var screen = plugin.get_screen ();
|
|
||||||
var wp = screen.append_new_workspace (false, screen.get_display ().get_current_time ());
|
var wp = screen.append_new_workspace (false, screen.get_display ().get_current_time ());
|
||||||
if (wp == null)
|
if (wp == null)
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void create_workspace_thumb (Meta.Workspace workspace)
|
||||||
|
{
|
||||||
|
var screen = plugin.get_screen ();
|
||||||
|
|
||||||
var thumb = new WorkspaceThumb (wp);
|
var thumb = new WorkspaceThumb (workspace);
|
||||||
thumb.clicked.connect (hide);
|
thumb.clicked.connect (hide);
|
||||||
thumb.closed.connect (remove_workspace);
|
thumb.closed.connect (remove_workspace);
|
||||||
thumb.window_on_last.connect (add_workspace);
|
thumb.window_on_last.connect (add_workspace);
|
||||||
|
|
||||||
thumbnails.add_child (thumb);
|
thumbnails.insert_child_at_index (thumb, workspace.index ());
|
||||||
|
|
||||||
thumb.show ();
|
thumb.show ();
|
||||||
|
|
||||||
@ -202,7 +223,8 @@ namespace Gala
|
|||||||
|
|
||||||
var workspace = thumb.workspace;
|
var workspace = thumb.workspace;
|
||||||
|
|
||||||
if (workspace != null && workspace.index () > -1) { //dont remove non existing workspaces
|
//dont remove non existing workspaces
|
||||||
|
if (workspace != null && workspace.index () > -1) {
|
||||||
var screen = workspace.get_screen ();
|
var screen = workspace.get_screen ();
|
||||||
screen.remove_workspace (workspace, screen.get_display ().get_current_time ());
|
screen.remove_workspace (workspace, screen.get_display ().get_current_time ());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user