Skip to content

Commit

Permalink
Fix mutter 3.3x crashes (#635)
Browse files Browse the repository at this point in the history
* Make gala build against Mutter 3.32

* Add schemas override for Mutter 3.3x

* Fix Gala.WorkspaceManager.workspace_removed callback that cause a SIGABRT

* Fix Gala.WorkspaceManager.cleanup method which causes SIGABRT by trying to get non-existing workspaces

* Fix Gala.WorkspaceManager.cleanup method which deletes all workspace instead of keeping at least the last workspace

* Fix Multitasking-View remove_workspace callback which has an incorrect algorithm to remove destroyed workspaces

* Add missing manager.workspace_reordered callback for Mutter 3.34
  • Loading branch information
Tireg authored and Corentin Noël committed Nov 13, 2019
1 parent 8540e84 commit 70cfe7e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 22 deletions.
6 changes: 6 additions & 0 deletions data/20_elementary.pantheon.wm.gschema.override
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[org.gnome.mutter:Pantheon]
dynamic-workspaces = true
attach-modal-dialogs = false
button-layout = 'close:maximize'
edge-tiling = true
enable-animations = true
1 change: 1 addition & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ i18n.merge_file(
install_dir: join_paths(data_dir, 'applications')
)
install_data(['gala.desktop', 'gala-daemon.desktop', 'gala-wayland.desktop'], install_dir: join_paths(data_dir, 'applications'))
install_data(files('20_elementary.pantheon.wm.gschema.override'), install_dir: join_paths(data_dir, 'glib-2.0', 'schemas'))

icons_dir = join_paths(get_option('datadir'), 'icons', 'hicolor')
install_data('icons/32x32/multitasking-view.svg', install_dir: join_paths(icons_dir, '32x32', 'apps'))
Expand Down
10 changes: 5 additions & 5 deletions src/Background/SystemBackground.vala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Gala
{
#if HAS_MUTTER334
#if HAS_MUTTER332
public class SystemBackground : GLib.Object
#else
public class SystemBackground : Meta.BackgroundActor
Expand All @@ -26,7 +26,7 @@ namespace Gala
const Clutter.Color DEFAULT_BACKGROUND_COLOR = { 0x2e, 0x34, 0x36, 0xff };

static Meta.Background? system_background = null;
#if HAS_MUTTER334
#if HAS_MUTTER332
public Meta.BackgroundActor background_actor { get; construct; }
#endif

Expand All @@ -35,7 +35,7 @@ namespace Gala
#if HAS_MUTTER330
public SystemBackground (Meta.Display display)
{
#if HAS_MUTTER334
#if HAS_MUTTER332
Object (background_actor: new Meta.BackgroundActor (display, 0));
#else
Object (meta_display: display, monitor: 0);
Expand All @@ -57,7 +57,7 @@ namespace Gala
}

if (system_background == null) {
#if HAS_MUTTER334
#if HAS_MUTTER332
system_background = new Meta.Background (background_actor.meta_display);
#elif HAS_MUTTER330
system_background = new Meta.Background (meta_display);
Expand All @@ -68,7 +68,7 @@ namespace Gala
system_background.set_file (background_file, GDesktop.BackgroundStyle.WALLPAPER);
}

#if HAS_MUTTER334
#if HAS_MUTTER332
background_actor.background = system_background;
#else
background = system_background;
Expand Down
20 changes: 7 additions & 13 deletions src/Widgets/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ namespace Gala

manager.workspace_added.connect (add_workspace);
manager.workspace_removed.connect (remove_workspace);
#if HAS_MUTTER334
manager.workspaces_reordered.connect (() => update_positions (false));
#endif
manager.workspace_switched.connect_after ((from, to, direction) => {
update_positions (opened);
});
Expand Down Expand Up @@ -389,29 +392,20 @@ namespace Gala
// FIXME is there a better way to get the removed workspace?
#if HAS_MUTTER330
unowned Meta.WorkspaceManager manager = display.get_workspace_manager ();
List<Workspace> existing_workspaces = null;
for (int i = 0; i < manager.get_n_workspaces (); i++) {
existing_workspaces.append (manager.get_workspace_by_index (i));
}
#else
unowned List<Meta.Workspace> existing_workspaces = screen.get_workspaces ();
#endif

foreach (var child in workspaces.get_children ()) {
unowned WorkspaceClone clone = (WorkspaceClone) child;
#if HAS_MUTTER330
for (int i = 0; i < manager.get_n_workspaces (); i++) {
if (manager.get_workspace_by_index (i) == clone.workspace) {
workspace = clone;
break;
}
}

if (workspace != null) {
break;
}
#else
if (existing_workspaces.index (clone.workspace) < 0) {
workspace = clone;
break;
}
#endif
}

if (workspace == null)
Expand Down
2 changes: 1 addition & 1 deletion src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ namespace Gala
var system_background = new SystemBackground (screen);
#endif

#if HAS_MUTTER334
#if HAS_MUTTER332
system_background.background_actor.add_constraint (new Clutter.BindConstraint (stage,
Clutter.BindCoordinate.ALL, 0));
stage.insert_child_below (system_background.background_actor, null);
Expand Down
16 changes: 13 additions & 3 deletions src/WorkspaceManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,16 @@ namespace Gala

void workspace_removed (Meta.WorkspaceManager manager, int index)
{
List<Workspace> existing_workspaces = null;
for (int i = 0; i < manager.get_n_workspaces (); i++) {
existing_workspaces.append (manager.get_workspace_by_index (i));
}

var it = workspaces_marked_removed.iterator ();
while (it.next ()) {
var workspace = it.@get ();
if (workspace.index () < 0)

if (existing_workspaces.index (workspace) < 0)
it.remove ();
}
}
Expand Down Expand Up @@ -389,9 +395,13 @@ namespace Gala
#if HAS_MUTTER330
unowned Meta.Display display = wm.get_display ();
unowned Meta.WorkspaceManager manager = display.get_workspace_manager ();
var last_index = manager.get_n_workspaces () - 1;
List<Meta.Workspace> workspaces = null;
for (int i = 0; i < manager.get_n_workspaces (); i++) {
unowned Meta.Workspace workspace = manager.get_workspace_by_index (i);
workspaces.append (manager.get_workspace_by_index (i));
}

foreach (var workspace in workspaces) {
var last_index = manager.get_n_workspaces () - 1;
if (Utils.get_n_windows (workspace) < 1
&& workspace.index () != last_index) {
remove_workspace (workspace);
Expand Down

0 comments on commit 70cfe7e

Please sign in to comment.