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 initial support for Mutter 41 #1228

Merged
merged 3 commits into from
Aug 30, 2021
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
16 changes: 14 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ granite_dep = dependency('granite', version: '>= 5.4.0')
gnome_desktop_dep = dependency('gnome-desktop-3.0')
gsd_dep = dependency('gnome-settings-daemon', version: '>= @0@'.format(gsd_version_required))
m_dep = cc.find_library('m', required: false)
posix_dep = vala.find_library('posix', required: false)
gexiv2_dep = dependency('gexiv2')

mutter_dep = []
Expand Down Expand Up @@ -137,11 +138,22 @@ if mutter40_dep.found()
dependency('mutter-cogl-8'), dependency('mutter-cogl-pango-8'),
dependency('mutter-clutter-8')
]
vala_flags = ['--define', 'HAS_MUTTER330', '--define', 'HAS_MUTTER332', '--define', 'HAS_MUTTER334', '--define', 'HAS_MUTTER336', '--define', 'HAS_MUTTER338', '--define', 'HAS_MUTTER40']
vala_flags = ['--define', 'HAS_MUTTER338', '--define', 'HAS_MUTTER40']
add_project_arguments(['-DCLUTTER_ENABLE_COMPOSITOR_API', '-DCLUTTER_ENABLE_EXPERIMENTAL_API',
'-DCOGL_ENABLE_EXPERIMENTAL_API', '-DCOGL_ENABLE_EXPERIMENTAL_2_0_API'], language: 'c')
endif

mutter41_dep = dependency('libmutter-9', version: ['>= 41', '< 42'], required: false)
if mutter41_dep.found()
libmutter_dep = dependency('libmutter-9', version: '>= 41')
mutter_dep = [
libmutter_dep,
dependency('mutter-cogl-9'), dependency('mutter-cogl-pango-9'),
dependency('mutter-clutter-9')
]
vala_flags = ['--define', 'HAS_MUTTER338', '--define', 'HAS_MUTTER40', '--define', 'HAS_MUTTER41']
endif

if mutter_dep.length() == 0
error ('No supported mutter library found!')
endif
Expand All @@ -151,7 +163,7 @@ mutter_typelib_dir = libmutter_dep.get_pkgconfig_variable('typelibdir')
add_project_arguments(vala_flags, language: 'vala')
add_project_link_arguments(['-Wl,-rpath,@0@'.format(mutter_typelib_dir)], language: 'c')

gala_base_dep = [canberra_dep, glib_dep, gobject_dep, gio_dep, gmodule_dep, gee_dep, gtk_dep, plank_dep, mutter_dep, granite_dep, gnome_desktop_dep, m_dep, gexiv2_dep, config_dep]
gala_base_dep = [canberra_dep, glib_dep, gobject_dep, gio_dep, gmodule_dep, gee_dep, gtk_dep, plank_dep, mutter_dep, granite_dep, gnome_desktop_dep, m_dep, posix_dep, gexiv2_dep, config_dep]

subdir('data')
subdir('lib')
Expand Down
6 changes: 4 additions & 2 deletions src/Background/Background.vala
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ namespace Gala {
var settings = background_source.settings;

color_string = settings.get_string ("primary-color");
var color = Clutter.Color.from_string (color_string);
var color = Clutter.Color ();
color.from_string (color_string);

color_string = settings.get_string ("secondary-color");
var second_color = Clutter.Color.from_string (color_string);
var second_color = Clutter.Color ();
second_color.from_string (color_string);

var shading_type = settings.get_enum ("color-shading-type");

Expand Down
42 changes: 41 additions & 1 deletion src/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ namespace Gala {
GLib.Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
GLib.Intl.textdomain (Config.GETTEXT_PACKAGE);

#if HAS_MUTTER41
var ctx = new Meta.Context ("Mutter(Gala)");
ctx.add_option_entries (Gala.OPTIONS, Config.GETTEXT_PACKAGE);
try {
ctx.configure (ref args);
} catch (Error e) {
stderr.printf ("Error initializing: %s\n", e.message);
return Posix.EXIT_FAILURE;
}

ctx.set_plugin_gtype (typeof (WindowManagerGala));
#else
unowned OptionContext ctx = Meta.get_option_context ();
ctx.add_main_entries (Gala.OPTIONS, null);
try {
Expand All @@ -44,7 +56,16 @@ namespace Gala {
Meta.Plugin.manager_set_plugin_type (typeof (WindowManagerGala));

Meta.Util.set_wm_name ("Mutter(Gala)");
#endif

#if HAS_MUTTER41
try {
ctx.setup ();
} catch (Error e) {
stderr.printf ("Failed to setup: %s\n", e.message);
return Posix.EXIT_FAILURE;
}
#else
/**
* Prevent Meta.init () from causing gtk to load gail and at-bridge
* Taken from Gnome-Shell main.c
Expand All @@ -54,13 +75,32 @@ namespace Gala {
Meta.init ();
GLib.Environment.unset_variable ("NO_GAIL");
GLib.Environment.unset_variable ("NO_AT_BRIDGE");
#endif

Plank.Paths.initialize ("plank", Config.DATADIR + "/plank");

// Force initialization of static fields in Utils class
// https://bugzilla.gnome.org/show_bug.cgi?id=543189
// https://gitlab.gnome.org/GNOME/vala/-/issues/11
typeof (Gala.Utils).class_ref ();

#if HAS_MUTTER41
try {
ctx.start ();
} catch (Error e) {
stderr.printf ("Failed to start: %s\n", e.message);
return Posix.EXIT_FAILURE;
}

try {
ctx.run_main_loop ();
} catch (Error e) {
stderr.printf ("Gala terminated with a failure: %s\n", e.message);
return Posix.EXIT_FAILURE;
}

return Posix.EXIT_SUCCESS;
#else
return Meta.run ();
#endif
}
}
2 changes: 1 addition & 1 deletion src/Widgets/ScreenShield.vala
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ namespace Gala {
on_user_became_active ();
});

background_color = Clutter.Color.from_string ("black");
background_color.from_string ("black");

expand_to_screen_size ();

Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/Tooltip.vala
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class Gala.Tooltip : Clutter.Actor {

padding = tooltip_style_context.get_padding (Gtk.StateFlags.NORMAL);

text_color = Clutter.Color.from_string ("#ffffff");
text_color.from_string ("#ffffff");
}

construct {
Expand Down
13 changes: 8 additions & 5 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ namespace Gala {
stage = display.get_stage () as Clutter.Stage;
var background_settings = new GLib.Settings ("org.gnome.desktop.background");
var color = background_settings.get_string ("primary-color");
stage.background_color = Clutter.Color.from_string (color);
stage.background_color.from_string (color);

Meta.Util.later_add (Meta.LaterType.BEFORE_REDRAW, () => {
WorkspaceManager.init (this);
Expand Down Expand Up @@ -348,12 +348,15 @@ namespace Gala {

stage.show ();

// let the session manager move to the next phase
Meta.register_with_session ();

Idle.add (() => {
// let the session manager move to the next phase
#if HAS_MUTTER41
display.get_context ().notify_ready ();
#else
Meta.register_with_session ();
#endif
plugin_manager.load_waiting_plugins ();
return false;
return GLib.Source.REMOVE;
});

return false;
Expand Down
30 changes: 30 additions & 0 deletions vapi/Clutter-9-custom.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace Clutter {
public interface Container : GLib.Object {
public void add (params Clutter.Actor[] actors);
[CCode (cname = "clutter_container_class_find_child_property")]
public class unowned GLib.ParamSpec find_child_property (string property_name);
[CCode (cname = "clutter_container_class_list_child_properties")]
public class unowned GLib.ParamSpec[] list_child_properties ();
}

public struct Units {
[CCode (cname = "clutter_units_from_cm")]
public Units.from_cm (float cm);
[CCode (cname = "clutter_units_from_em")]
public Units.from_em (float em);
[CCode (cname = "clutter_units_from_em_for_font")]
public Units.from_em_for_font (string font_name, float em);
[CCode (cname = "clutter_units_from_mm")]
public Units.from_mm (float mm);
[CCode (cname = "clutter_units_from_pixels")]
public Units.from_pixels (int px);
[CCode (cname = "clutter_units_from_pt")]
public Units.from_pt (float pt);
[CCode (cname = "clutter_units_from_string")]
public Units.from_string (string str);
}

[CCode (cheader_filename = "clutter/clutter.h", has_copy_function = false, has_destroy_function = false, has_type_id = false)]
public struct Capture {
}
}
187 changes: 187 additions & 0 deletions vapi/Clutter-9.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
// Non mini-object
ActorBox struct
Color struct
Knot struct
Margin struct
PaintVolume struct
PathNode struct
Perspective struct
Units struct

*.ref unowned

init.argv unowned
Actor
.apply_transform.matrix ref
.get_abs_allocation_vertices.verts out=false
Canvas
.new symbol_type="constructor"
Event.type#method name="get_type"
Image
.new symbol_type="constructor"

// ???
Actor.has_pointer#method name="get_has_pointer"
InitError errordomain=false
ScriptError errordomain
ImageError errordomain

// Not all backing symbols are deprecated
Actor.pick deprecated=false

// Nullable return values
Actor
.get_parent nullable
value_get_color nullable

// method/virtual-method/signal don't match
Actor
.event#method name="emit_event"
.get_paint_volume#virtual_method name="get_paint_volume_vfunc"
.get_paint_volume#virtual_method.volume out
Container
.add_actor skip=false
.class_* skip
Text
.activate#method name="try_activate"
.insert_text#signal skip
TextBuffer.get_text#virtual_method name="get_text_with_length"

// virtual/abstract distinction
Container
.lower virtual
.raise virtual
.*_child_meta#virtual_method virtual

// Default values
Container
.lower.sibling nullable default=null
.raise.sibling nullable default=null
Stage.read_pixels
.width default=-1
.height default=-1
Stage.paint_to_buffer
.data type="uint8[]"
Text
.position_to_coords.line_height default=null

// Reparented funcs methods can't be instance methods
feature_available skip
feature_get_all skip

// Skipped by g-i for unknown reasons
LayoutManager
.create_child_meta skip=false

// Variadic arguments
Backend
.get_cogl_context skip=false
Container
.child_get skip=false
.child_set skip=false
.remove skip=false
Interval
.new skip=false
.get_interval skip=false
.set_final skip=false
.set_initial skip=false
.set_interval skip=false
LayoutManager
.child_get skip=false
.child_set skip=false
Script
.get_objects skip=false

// Skipped upstream for unknown reasons
Interval.register_progress_func skip=false
get_option_group skip=false
get_option_group_without_init skip=false
threads_add_idle skip=false
threads_add_idle_full skip=false
threads_add_timeout skip=false
threads_add_timeout_full skip=false

// struct/class confusion
ActorBox
.new skip
.from_vertices skip
Units.from_* skip
Color
.new skip
Margin
.new skip

// Class methods
container_class_find_child_property skip
container_class_list_child_properties skip

// Move symbols
color_from_* skip
units_from_* skip

// Struct return values
color_get_static nullable

// Upstream
Event
.get_position.position out

FrameListenerIface skip
FrameClock.new skip

// Remove for clutter-2.0
/////////////////////////

StageView.layout skip

Stage
.event name="emit_event"
.paint_view.redraw_clip type="Cairo.Region"

Capture
.image type="Cairo.ImageSurface"

// *Event should be compact classes derived from Clutter.Event
Event.type skip=false
AnyEvent struct=false base_type="Clutter.Event"
ButtonEvent struct=false base_type="Clutter.Event"
CrossingEvent struct=false base_type="Clutter.Event"
DeviceEvent struct=false base_type="Clutter.Event"
IMEvent struct=false base_type="Clutter.Event"
KeyEvent struct=false base_type="Clutter.Event"
MotionEvent struct=false base_type="Clutter.Event"
ScrollEvent struct=false base_type="Clutter.Event"
TouchEvent struct=false base_type="Clutter.Event"
TouchpadPinchEvent struct=false base_type="Clutter.Event"
TouchpadSwipeEvent struct=false base_type="Clutter.Event"
ProximityEvent struct=false base_type="Clutter.Event"
PadButtonEvent struct=false base_type="Clutter.Event"
PadRingEvent struct=false base_type="Clutter.Event"
PadStripEvent struct=false base_type="Clutter.Event"

// Keysyms used to be CLUTTER_X instead of CLUTTER_KEY_X
*#constant skip
COGL skip=false
CURRENT_TIME skip=false
FLAVOUR skip=false
PATH_RELATIVE skip=false
PRIORITY_REDRAW skip=false

// Clutter devs don't like us creating nested namespaces
value_* name="value_(.+)" parent="Clutter.Value"
threads_* name="threads_(.+)" parent="Clutter.Threads"
threads_add_idle name="add" parent="Clutter.Threads.Idle"
threads_add_idle_full name="add_full" parent="Clutter.Threads.Idle"
threads_add_timeout name="add" parent="Clutter.Threads.Timeout"
threads_add_timeout_full name="add_full" parent="Clutter.Threads.Timeout"

// Backwards compatibility
Color.alloc symbol_type="function"

BinAlignment deprecated=false deprecated_since=null
BinAlignment.* deprecated
BinAlignment.start deprecated=false
BinLayout.new.*_align default=Clutter.BinAlignment.START

// Possibly keep
KEY_* skip=false name="KEY_(.+)" type="uint" parent="Clutter.Key"
Loading