Skip to content

Commit

Permalink
Add support for Mutter47
Browse files Browse the repository at this point in the history
  • Loading branch information
tintou committed Oct 15, 2024
1 parent 4c11882 commit bdffe25
Show file tree
Hide file tree
Showing 32 changed files with 1,442 additions and 760 deletions.
4 changes: 2 additions & 2 deletions lib/App.vala
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ public class Gala.App : GLib.Object {
return windows.data;
}

public GLib.SList<Posix.pid_t?> get_pids () {
var results = new GLib.SList<Posix.pid_t?> ();
public GLib.SList<pid_t?> get_pids () {
var results = new GLib.SList<pid_t?> ();
foreach (unowned var window in windows) {
var pid = window.get_pid ();
if (pid < 1) {
Expand Down
11 changes: 11 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ if mutter46_dep.found()
vala_flags = ['--define', 'HAS_MUTTER43', '--define', 'HAS_MUTTER44', '--define', 'HAS_MUTTER45', '--define', 'HAS_MUTTER46']
endif

mutter47_dep = dependency('libmutter-15', version: ['>= 47', '< 48'], required: false)
if mutter47_dep.found()
libmutter_dep = dependency('libmutter-15', version: '>= 47')
mutter_dep = [
libmutter_dep,
dependency('mutter-mtk-15'), dependency('mutter-cogl-15'),
dependency('mutter-cogl-pango-15'), dependency('mutter-clutter-15')
]
vala_flags = ['--define', 'HAS_MUTTER43', '--define', 'HAS_MUTTER44', '--define', 'HAS_MUTTER45', '--define', 'HAS_MUTTER46', '--define', 'HAS_MUTTER47']
endif

if mutter_dep.length() == 0
error ('No supported mutter library found!')
endif
Expand Down
23 changes: 23 additions & 0 deletions src/Background/Background.vala
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,38 @@ namespace Gala {
var settings = background_source.gnome_background_settings;

color_string = settings.get_string ("primary-color");
#if HAS_MUTTER47
var color = Cogl.Color.from_string (color_string);
#else
var color = Clutter.Color.from_string (color_string);
#endif
if (color == null) {
#if HAS_MUTTER47
color = Cogl.Color.from_string ("black");
#else
color = Clutter.Color.from_string ("black");
#endif
}

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

if (shading_type == GDesktop.BackgroundShading.SOLID) {
background.set_color (color);
} else {
color_string = settings.get_string ("secondary-color");
#if HAS_MUTTER47
var second_color = Cogl.Color.from_string (color_string);
#else
var second_color = Clutter.Color.from_string (color_string);
#endif
if (second_color == null) {
#if HAS_MUTTER47
second_color = Cogl.Color.from_string ("black");
#else
second_color = Clutter.Color.from_string ("black");
#endif
}

background.set_gradient ((GDesktop.BackgroundShading) shading_type, color, second_color);
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/Background/BackgroundContainer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ namespace Gala {
}

public void set_black_background (bool black) {
#if HAS_MUTTER47
set_background_color (black ? Cogl.Color.from_string ("Black") : null);
#else
set_background_color (black ? Clutter.Color.from_string ("Black") : null);
#endif
}

private void update () {
Expand Down
4 changes: 4 additions & 0 deletions src/InternalUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ namespace Gala {
}

unowned Meta.X11Display x11display = display.get_x11_display ();
#if HAS_MUTTER47
x11display.set_stage_input_region (rects);
#else
var xregion = X.Fixes.create_region (x11display.get_xdisplay (), rects);
x11display.set_stage_input_region (xregion);
#endif
}

/**
Expand Down
8 changes: 7 additions & 1 deletion src/ScreenshotManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ namespace Gala {
var flash_actor = new Clutter.Actor ();
flash_actor.set_size (width, height);
flash_actor.set_position (x, y);
#if HAS_MUTTER46
#if HAS_MUTTER47
flash_actor.set_background_color (Cogl.Color.from_string ("white"));
#elif HAS_MUTTER46
flash_actor.set_background_color (Clutter.Color.from_pixel (0xffffffffu));
#else
flash_actor.set_background_color (Clutter.Color.get_static (Clutter.StaticColor.WHITE));
Expand Down Expand Up @@ -151,8 +153,12 @@ namespace Gala {
window_actor.get_position (out actor_x, out actor_y);

var rect = window.get_frame_rect ();
#if HAS_MUTTER45
if (!include_frame) {
#if else
if ((include_frame && window.is_client_decorated ()) ||
(!include_frame && !window.is_client_decorated ())) {
#endif
rect = window.frame_rect_to_client_rect (rect);
}

Expand Down
4 changes: 4 additions & 0 deletions src/Widgets/IconGroup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ namespace Gala {
var height = InternalUtils.scale_to_int (WorkspaceClone.BOTTOM_OFFSET, scale_factor);
var backdrop_opacity_int = (uint8) (BACKDROP_ABSOLUTE_OPACITY * backdrop_opacity);

#if HAS_MUTTER47
//FIXME: TODO!
#else
Cogl.VertexP2T2C4 vertices[4];
vertices[0] = { x, y + height, 0, 1, backdrop_opacity_int, backdrop_opacity_int, backdrop_opacity_int, backdrop_opacity_int };
vertices[1] = { x, y, 0, 0, 0, 0, 0, 0 };
Expand All @@ -123,6 +126,7 @@ namespace Gala {
var primitive = new Cogl.Primitive.p2t2c4 (context.get_framebuffer ().get_context (), Cogl.VerticesMode.TRIANGLE_STRIP, vertices);
var pipeline = new Cogl.Pipeline (context.get_framebuffer ().get_context ());
primitive.draw (context.get_framebuffer (), pipeline);
#endif
base.paint (context);
}

Expand Down
4 changes: 4 additions & 0 deletions src/Widgets/ScreenShield.vala
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ namespace Gala {
return Clutter.EVENT_STOP;
});

#if HAS_MUTTER47
background_color = Cogl.Color.from_string ("black");
#else
background_color = Clutter.Color.from_string ("black");
#endif

expand_to_screen_size ();

Expand Down
4 changes: 4 additions & 0 deletions src/Widgets/Tooltip.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public class Gala.Tooltip : CanvasActor {
construct {
max_width = 200;

#if HAS_MUTTER47
Cogl.Color text_color = {
#else
Clutter.Color text_color = {
#endif
(uint8) Drawing.Color.TOOLTIP_TEXT_COLOR.red * uint8.MAX,
(uint8) Drawing.Color.TOOLTIP_TEXT_COLOR.green * uint8.MAX,
(uint8) Drawing.Color.TOOLTIP_TEXT_COLOR.blue * uint8.MAX,
Expand Down
4 changes: 4 additions & 0 deletions src/Widgets/WindowSwitcher/WindowSwitcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ public class Gala.WindowSwitcher : CanvasActor {

var stroke_width = scaling_factor;

#if HAS_MUTTER47
caption.color = Cogl.Color.from_string (caption_color);
#else
caption.color = Clutter.Color.from_string (caption_color);
#endif

ctx.save ();
ctx.set_operator (Cairo.Operator.CLEAR);
Expand Down
4 changes: 4 additions & 0 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ 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");
#if HAS_MUTTER47
stage.background_color = Cogl.Color.from_string (color);
#else
stage.background_color = Clutter.Color.from_string (color);
#endif

unowned var laters = display.get_compositor ().get_laters ();
laters.add (Meta.LaterType.BEFORE_REDRAW, () => {
Expand Down
2 changes: 1 addition & 1 deletion src/WindowTracker.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class Gala.WindowTracker : GLib.Object {
return get_app_from_id (id);
}

private static unowned Gala.App? get_app_from_pid (Posix.pid_t pid) {
private static unowned Gala.App? get_app_from_pid (pid_t pid) {
var running_apps = Gala.AppSystem.get_default ().get_running_apps ();
foreach (unowned Gala.App app in running_apps) {
var app_pids = app.get_pids ();
Expand Down
30 changes: 30 additions & 0 deletions vapi/Clutter-15-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 {
}
}
139 changes: 139 additions & 0 deletions vapi/Clutter-15.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// Non mini-object
ActorBox struct
Margin struct
PaintVolume struct
Perspective struct

*.ref unowned

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

// ???
Actor.has_pointer#method name="get_has_pointer"

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

// Nullable return values
Actor
.get_parent 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
Text
.activate#method name="try_activate"
.insert_text#signal skip
TextBuffer.get_text#virtual_method name="get_text_with_length"

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

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

// Variadic arguments
Backend
.get_cogl_context 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

// Skipped upstream for unknown reasons
Interval.register_progress_func 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
Margin
.new skip

// Upstream
Event
.get_position.position out

TransferFunction.get_default_luminances
.min_lum_out out
.max_lum_out out
.ref_lum_out out

FrameListenerIface skip
FrameClock.new skip

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

StageView.layout skip

Stage
.paint_view.redraw_clip type="Cairo.Region"

// *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"
PadButtonEvent struct=false base_type="Clutter.Event"
PadRingEvent struct=false base_type="Clutter.Event"
PadStripEvent struct=false base_type="Clutter.Event"
ProximityEvent struct=false base_type="Clutter.Event"
ScrollEvent struct=false base_type="Clutter.Event"
TouchEvent struct=false base_type="Clutter.Event"
TouchpadHoldEvent struct=false base_type="Clutter.Event"
TouchpadPinchEvent struct=false base_type="Clutter.Event"
TouchpadSwipeEvent struct=false base_type="Clutter.Event"

// Keysyms used to be CLUTTER_X instead of CLUTTER_KEY_X
*#constant skip
CURRENT_TIME 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"

// There is no way to know sealed classes before GLib 2.70
ColorState sealed
FrameClock sealed
TextureContent sealed

TextureContent.new_from_texture symbol_type="constructor"

// Possibly keep
KEY_* skip=false name="KEY_(.+)" type="uint" parent="Clutter.Key"
BUTTON_* skip=false name="BUTTON_(.+)" type="uint32" parent="Clutter.Button"
EVENT_STOP skip=false type="bool"
EVENT_PROPAGATE skip=false type="bool"
Loading

0 comments on commit bdffe25

Please sign in to comment.