Skip to content

Instantly share code, notes, and snippets.

@Tireg
Created November 8, 2019 12:01
Show Gist options
  • Save Tireg/f6e13bd66c0234234c94ca4b330bf887 to your computer and use it in GitHub Desktop.
Save Tireg/f6e13bd66c0234234c94ca4b330bf887 to your computer and use it in GitHub Desktop.
Fix gala bugs agains mutter 3.3x (All-In-One patch)
diff --git a/data/20_elementary.pantheon.wm.gschema.override b/data/20_elementary.pantheon.wm.gschema.override
new file mode 100644
index 0000000..ef292ee
--- /dev/null
+++ b/data/20_elementary.pantheon.wm.gschema.override
@@ -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
diff --git a/data/meson.build b/data/meson.build
index b99cfc0..c05d093 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -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'))
diff --git a/src/Background/SystemBackground.vala b/src/Background/SystemBackground.vala
index 4ca70ab..18210be 100644
--- a/src/Background/SystemBackground.vala
+++ b/src/Background/SystemBackground.vala
@@ -17,7 +17,7 @@
namespace Gala
{
-#if HAS_MUTTER334
+#if HAS_MUTTER332
public class SystemBackground : GLib.Object
#else
public class SystemBackground : Meta.BackgroundActor
@@ -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
@@ -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);
@@ -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);
@@ -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;
diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala
index cede706..cdeb779 100644
--- a/src/Widgets/MultitaskingView.vala
+++ b/src/Widgets/MultitaskingView.vala
@@ -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);
});
@@ -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 ();
+ unowned 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)
diff --git a/src/WindowManager.vala b/src/WindowManager.vala
index 5b1e8f8..ae40989 100644
--- a/src/WindowManager.vala
+++ b/src/WindowManager.vala
@@ -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);
diff --git a/src/WorkspaceManager.vala b/src/WorkspaceManager.vala
index dd4a09e..bc6558d 100644
--- a/src/WorkspaceManager.vala
+++ b/src/WorkspaceManager.vala
@@ -132,10 +132,16 @@ namespace Gala
void workspace_removed (Meta.WorkspaceManager manager, int index)
{
+ unowned 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 ();
}
}
@@ -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;
+ unowned 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment