Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for mutter 3.3x #260

Merged
merged 3 commits into from
Nov 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions vapi/libmutter-3.deps
1 change: 1 addition & 0 deletions vapi/libmutter-3.vapi
1 change: 1 addition & 0 deletions vapi/libmutter-4.deps
1 change: 1 addition & 0 deletions vapi/libmutter-4.vapi
1 change: 1 addition & 0 deletions vapi/libmutter-5.deps
1 change: 1 addition & 0 deletions vapi/libmutter-5.vapi
1 change: 1 addition & 0 deletions vapi/libmutter-6.deps
1 change: 1 addition & 0 deletions vapi/libmutter-6.vapi
480 changes: 471 additions & 9 deletions vapi/libmutter.vapi

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions vapi/mutter-clutter-3.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
atk
cairo
pango
json-glib-1.0
mutter-cogl-3
1 change: 1 addition & 0 deletions vapi/mutter-clutter-3.vapi
5 changes: 5 additions & 0 deletions vapi/mutter-clutter-4.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
atk
cairo
pango
json-glib-1.0
mutter-cogl-4
1 change: 1 addition & 0 deletions vapi/mutter-clutter-4.vapi
5 changes: 5 additions & 0 deletions vapi/mutter-clutter-5.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
atk
cairo
pango
json-glib-1.0
mutter-cogl-5
1 change: 1 addition & 0 deletions vapi/mutter-clutter-5.vapi
5 changes: 5 additions & 0 deletions vapi/mutter-clutter-6.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
atk
cairo
pango
json-glib-1.0
mutter-cogl-6
1 change: 1 addition & 0 deletions vapi/mutter-clutter-6.vapi
1 change: 1 addition & 0 deletions vapi/mutter-cogl-3.deps
1 change: 1 addition & 0 deletions vapi/mutter-cogl-3.vapi
1 change: 1 addition & 0 deletions vapi/mutter-cogl-4.deps
1 change: 1 addition & 0 deletions vapi/mutter-cogl-4.vapi
1 change: 1 addition & 0 deletions vapi/mutter-cogl-5.deps
1 change: 1 addition & 0 deletions vapi/mutter-cogl-5.vapi
1 change: 1 addition & 0 deletions vapi/mutter-cogl-6.deps
1 change: 1 addition & 0 deletions vapi/mutter-cogl-6.vapi
Empty file added vapi/mutter-cogl-pango-3.vapi
Empty file.
Empty file added vapi/mutter-cogl-pango-4.vapi
Empty file.
Empty file added vapi/mutter-cogl-pango-5.vapi
Empty file.
Empty file added vapi/mutter-cogl-pango-6.vapi
Empty file.
Empty file added vapi/mutter-cogl-path-3.vapi
Empty file.
Empty file added vapi/mutter-cogl-path-4.vapi
Empty file.
Empty file added vapi/mutter-cogl-path-5.vapi
Empty file.
Empty file added vapi/mutter-cogl-path-6.vapi
Empty file.
12 changes: 12 additions & 0 deletions wingpanel-interface/BackgroundManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ public class WingpanelInterface.BackgroundManager : Object {
}

private void connect_signals () {
#if HAS_MUTTER330
unowned Meta.WorkspaceManager manager = Main.display.get_workspace_manager ();
manager.workspace_switched.connect (() => {
update_current_workspace ();
});
#else
Main.screen.workspace_switched.connect (() => {
update_current_workspace ();
});
#endif

var signal_id = GLib.Signal.lookup ("changed", Main.wm.background_group.get_type ());

Expand All @@ -84,7 +91,12 @@ public class WingpanelInterface.BackgroundManager : Object {
}

private void update_current_workspace () {
#if HAS_MUTTER330
unowned Meta.WorkspaceManager manager = Main.display.get_workspace_manager ();
var workspace = manager.get_workspace_by_index (manager.get_active_workspace_index ());
#else
var workspace = Main.screen.get_workspace_by_index (Main.screen.get_active_workspace_index ());
#endif

if (workspace == null) {
warning ("Cannot get active workspace");
Expand Down
36 changes: 36 additions & 0 deletions wingpanel-interface/FocusManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ public class WingpanelInterface.FocusManager : Object {
private Meta.Window? last_focused_dialog_window = null;

public FocusManager () {
#if HAS_MUTTER330
unowned Meta.WorkspaceManager manager = Main.display.get_workspace_manager ();
manager.workspace_switched.connect (() => {
update_current_workspace ();
});
#else
Main.screen.workspace_switched.connect (() => {
update_current_workspace ();
});
#endif

update_current_workspace ();
}
Expand All @@ -41,11 +48,19 @@ public class WingpanelInterface.FocusManager : Object {
}
}

#if HAS_MUTTER330
Main.display.window_created.connect (window_created);
#else
Main.screen.get_display ().window_created.connect (window_created);
#endif
}

public void restore_focused_window () {
#if HAS_MUTTER330
var display = Main.display;
#else
var display = Main.screen.get_display ();
#endif
// when a dialog was opened give it focus
if (last_focused_dialog_window != null) {
last_focused_dialog_window.focus (display.get_current_time ());
Expand All @@ -64,7 +79,11 @@ public class WingpanelInterface.FocusManager : Object {
window.unmanaged.disconnect (window_unmanaged);
}

#if HAS_MUTTER330
Main.display.window_created.disconnect (window_created);
#else
Main.screen.get_display ().window_created.disconnect (window_created);
#endif
}

void window_created (Meta.Window window) {
Expand All @@ -87,10 +106,18 @@ public class WingpanelInterface.FocusManager : Object {
}

public bool begin_grab_focused_window (int x, int y, int button, uint time, uint state) {
#if HAS_MUTTER330
var display = Main.display;
#else
var display = Main.screen.get_display ();
#endif
var window = display.get_focus_window ();
if (window == null || !get_can_grab_window (window, x, y)) {
#if HAS_MUTTER330
unowned Meta.Workspace workspace = display.get_workspace_manager ().get_active_workspace ();
#else
unowned Meta.Workspace workspace = Main.screen.get_active_workspace ();
#endif
List<unowned Meta.Window>? windows = workspace.list_windows ();
if (windows == null) {
return false;
Expand All @@ -111,7 +138,11 @@ public class WingpanelInterface.FocusManager : Object {
}

if (window != null) {
#if HAS_MUTTER330
display.begin_grab_op (window, Meta.GrabOp.MOVING, false, true, button, state, time, x, y);
#else
display.begin_grab_op (Main.screen, window, Meta.GrabOp.MOVING, false, true, button, state, time, x, y);
#endif
return true;
}

Expand All @@ -124,7 +155,12 @@ public class WingpanelInterface.FocusManager : Object {
}

private void update_current_workspace () {
#if HAS_MUTTER330
unowned Meta.WorkspaceManager manager = Main.display.get_workspace_manager ();
var workspace = manager.get_workspace_by_index (manager.get_active_workspace_index ());
#else
var workspace = Main.screen.get_workspace_by_index (Main.screen.get_active_workspace_index ());
#endif

if (workspace == null) {
warning ("Cannot get active workspace");
Expand Down
8 changes: 8 additions & 0 deletions wingpanel-interface/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public class WingpanelInterface.Main : Gala.Plugin {
private const string DBUS_PATH = "/org/pantheon/gala/WingpanelInterface";

public static Gala.WindowManager wm;
#if HAS_MUTTER330
public static Meta.Display display;
#else
public static Meta.Screen screen;
#endif

private DBusConnection? dbus_connection = null;

Expand All @@ -37,7 +41,11 @@ public class WingpanelInterface.Main : Gala.Plugin {
}

wm = _wm;
#if HAS_MUTTER330
display = wm.get_display ();
#else
screen = wm.get_screen ();
#endif

Bus.own_name (BusType.SESSION,
DBUS_NAME,
Expand Down
44 changes: 40 additions & 4 deletions wingpanel-interface/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,54 @@ if mutter328_dep.found()
'-DCOGL_ENABLE_EXPERIMENTAL_API', '-DCOGL_ENABLE_EXPERIMENTAL_2_0_API']
endif

mutter330_dep = dependency('libmutter-2', version: ['>= 3.29.2', '< 3.31'], required: false)
mutter330_dep = dependency('libmutter-3', version: ['>= 3.29.2', '< 3.31'], required: false)
if mutter330_dep.found()
libmutter_dep = dependency('libmutter-2', version: '>= 3.29.2')
libmutter_dep = dependency('libmutter-3', version: '>= 3.29.2')
mutter_dep = [
dependency('mutter-cogl-2'), dependency('mutter-cogl-pango-2'),
dependency('mutter-cogl-path-2'), dependency('mutter-clutter-2')
dependency('mutter-cogl-3'), dependency('mutter-cogl-pango-3'),
dependency('mutter-cogl-path-3'), dependency('mutter-clutter-3')
]
vala_flags += ['--define', 'HAS_MUTTER320', '--define', 'HAS_MUTTER322', '--define', 'HAS_MUTTER324', '--define', 'HAS_MUTTER326', '--define', 'HAS_MUTTER328', '--define', 'HAS_MUTTER330']
c_flags = ['-DCLUTTER_ENABLE_COMPOSITOR_API', '-DCLUTTER_ENABLE_EXPERIMENTAL_API',
'-DCOGL_ENABLE_EXPERIMENTAL_API', '-DCOGL_ENABLE_EXPERIMENTAL_2_0_API']
endif

mutter332_dep = dependency('libmutter-4', version: ['>= 3.31.2', '< 3.34'], required: false)
if mutter332_dep.found()
libmutter_dep = dependency('libmutter-4', version: '>= 3.31.2')
mutter_dep = [
dependency('mutter-cogl-4'), dependency('mutter-cogl-pango-4'),
dependency('mutter-cogl-path-4'), dependency('mutter-clutter-4')
]
vala_flags += ['--define', 'HAS_MUTTER320', '--define', 'HAS_MUTTER322', '--define', 'HAS_MUTTER324', '--define', 'HAS_MUTTER326', '--define', 'HAS_MUTTER328', '--define', 'HAS_MUTTER330', '--define', 'HAS_MUTTER332']
c_flags = ['-DCLUTTER_ENABLE_COMPOSITOR_API', '-DCLUTTER_ENABLE_EXPERIMENTAL_API',
'-DCOGL_ENABLE_EXPERIMENTAL_API', '-DCOGL_ENABLE_EXPERIMENTAL_2_0_API']
endif

mutter334_dep = dependency('libmutter-5', version: ['>= 3.34', '< 3.35.1'], required: false)
if mutter334_dep.found()
libmutter_dep = dependency('libmutter-5', version: '>= 3.34')
mutter_dep = [
dependency('mutter-cogl-5'), dependency('mutter-cogl-pango-5'),
dependency('mutter-cogl-path-5'), dependency('mutter-clutter-5')
]
vala_flags += ['--define', 'HAS_MUTTER320', '--define', 'HAS_MUTTER322', '--define', 'HAS_MUTTER324', '--define', 'HAS_MUTTER326', '--define', 'HAS_MUTTER328', '--define', 'HAS_MUTTER330', '--define', 'HAS_MUTTER332', '--define', 'HAS_MUTTER334']
c_flags = ['-DCLUTTER_ENABLE_COMPOSITOR_API', '-DCLUTTER_ENABLE_EXPERIMENTAL_API',
'-DCOGL_ENABLE_EXPERIMENTAL_API', '-DCOGL_ENABLE_EXPERIMENTAL_2_0_API']
endif

mutter336_dep = dependency('libmutter-6', version: ['>= 3.35.1', '< 3.38'], required: false)
if mutter336_dep.found()
libmutter_dep = dependency('libmutter-6', version: '>= 3.35.1')
mutter_dep = [
dependency('mutter-cogl-6'), dependency('mutter-cogl-pango-6'),
dependency('mutter-cogl-path-6'), dependency('mutter-clutter-6')
]
vala_flags += ['--define', 'HAS_MUTTER320', '--define', 'HAS_MUTTER322', '--define', 'HAS_MUTTER324', '--define', 'HAS_MUTTER326', '--define', 'HAS_MUTTER328', '--define', 'HAS_MUTTER330', '--define', 'HAS_MUTTER332', '--define', 'HAS_MUTTER334', '--define', 'HAS_MUTTER336']
c_flags = ['-DCLUTTER_ENABLE_COMPOSITOR_API', '-DCLUTTER_ENABLE_EXPERIMENTAL_API',
'-DCOGL_ENABLE_EXPERIMENTAL_API', '-DCOGL_ENABLE_EXPERIMENTAL_2_0_API']
endif

if mutter_dep.length() == 0
error ('No supported mutter library found!')
endif
Expand Down