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 46 #1825

Merged
merged 1 commit into from
Jan 13, 2024
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
11 changes: 11 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ if mutter45_dep.found()
vala_flags = ['--define', 'HAS_MUTTER43', '--define', 'HAS_MUTTER44', '--define', 'HAS_MUTTER45']
endif

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

if mutter_dep.length() == 0
error ('No supported mutter library found!')
endif
Expand Down
7 changes: 6 additions & 1 deletion plugins/pip/SelectionArea.vala
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@ public class Gala.Plugins.PIP.SelectionArea : Clutter.Actor {
}

private bool draw_area (Cairo.Context ctx) {
Clutter.cairo_clear (ctx);
ctx.save ();

ctx.set_operator (Cairo.Operator.CLEAR);
ctx.paint ();

ctx.restore ();

if (!dragging) {
return true;
Expand Down
25 changes: 2 additions & 23 deletions src/ScreenshotManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ namespace Gala {
public async void select_area (out int x, out int y, out int width, out int height) throws DBusError, IOError {
var selection_area = new SelectionArea (wm);
selection_area.closed.connect (() => Idle.add (select_area.callback));
wm.ui_group.add (selection_area);
wm.ui_group.add_child (selection_area);
selection_area.start_selection ();

yield;
Expand Down Expand Up @@ -235,7 +235,7 @@ namespace Gala {
public async GLib.HashTable<string, Variant> pick_color () throws DBusError, IOError {
var pixel_picker = new PixelPicker (wm);
pixel_picker.closed.connect (() => Idle.add (pick_color.callback));
wm.ui_group.add (pixel_picker);
wm.ui_group.add_child (pixel_picker);
pixel_picker.start_selection ();

yield;
Expand Down Expand Up @@ -403,27 +403,6 @@ namespace Gala {
return image;
}

private Cairo.ImageSurface composite_capture_images (Clutter.Capture[] captures, int x, int y, int width, int height) {
var image = new Cairo.ImageSurface (captures[0].image.get_format (), width, height);
var cr = new Cairo.Context (image);

foreach (unowned Clutter.Capture capture in captures) {
// Ignore capture regions with scale other than 1 for now; mutter can't
// produce them yet, so there is no way to test them.
double capture_scale = 1.0;
capture.image.get_device_scale (out capture_scale, null);
if (capture_scale != 1.0)
continue;

cr.save ();
cr.translate (capture.rect.x - x, capture.rect.y - y);
cr.set_source_surface (capture.image, 0, 0);
cr.restore ();
}

return image;
}

private Cairo.ImageSurface composite_stage_cursor (Cairo.ImageSurface image, Cairo.RectangleInt image_rect) {
unowned Meta.CursorTracker cursor_tracker = wm.get_display ().get_cursor_tracker ();
Graphene.Point coords = {};
Expand Down
8 changes: 8 additions & 0 deletions src/Widgets/IconGroup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,19 @@ namespace Gala {

resize_canvas ();

#if HAS_MUTTER46
icon_container.child_removed.connect_after (redraw);
#else
icon_container.actor_removed.connect_after (redraw);
#endif
}

~IconGroup () {
#if HAS_MUTTER46
icon_container.child_removed.disconnect (redraw);
#else
icon_container.actor_removed.disconnect (redraw);
#endif
}

private bool resize_canvas () {
Expand Down
7 changes: 6 additions & 1 deletion src/Widgets/SelectionArea.vala
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ namespace Gala {
}

private bool draw_area (Cairo.Context ctx) {
Clutter.cairo_clear (ctx);
ctx.save ();

ctx.set_operator (Cairo.Operator.CLEAR);
ctx.paint ();

ctx.restore ();

if (!dragging) {
return true;
Expand Down
9 changes: 3 additions & 6 deletions src/Widgets/WindowSwitcher/WindowSwitcherIcon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,15 @@ public class Gala.WindowSwitcherIcon : Clutter.Actor {
ctx.reset_clip ();

if (selected) {
// draw rect
var rgba = InternalUtils.get_theme_accent_color ();
Clutter.Color accent_color = {
ctx.set_source_rgba (
(uint8) (rgba.red * 255),
(uint8) (rgba.green * 255),
(uint8) (rgba.blue * 255),
(uint8) (rgba.alpha * 255)
};

);
var rect_radius = InternalUtils.scale_to_int (WRAPPER_BORDER_RADIUS, scale_factor);

// draw rect
Clutter.cairo_set_source_color (ctx, accent_color);
Drawing.Utilities.cairo_rounded_rectangle (ctx, 0, 0, width, height, rect_radius);
ctx.set_operator (Cairo.Operator.SOURCE);
ctx.fill ();
Expand Down
53 changes: 53 additions & 0 deletions vapi/Clutter-14-custom.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
namespace Clutter {
public struct Color {
[CCode (cname = "_vala_clutter_color_from_hls")]
public static Clutter.Color? from_hls (float hue, float luminance, float saturation) {
var color = Clutter.Color.alloc ();
color.init_from_hls (hue, luminance, saturation);
return color;
}
[CCode (cname = "_vala_clutter_color_from_pixel")]
public static Clutter.Color? from_pixel (uint32 pixel) {
var color = Clutter.Color.alloc ();
color.init_from_pixel (pixel);
return color;
}
[CCode (cname = "_vala_clutter_color_from_string")]
public static Clutter.Color? from_string (string str) {
var color = Clutter.Color.alloc ();
color.init_from_string (str);
return color;
}
[CCode (cname = "clutter_color_from_string")]
public bool parse_string (string str);
}

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 {
}
}
160 changes: 160 additions & 0 deletions vapi/Clutter-14.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
// Non mini-object
ActorBox struct
Color struct
Margin struct
PaintVolume struct
Perspective struct

*.ref 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"

// 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
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

// 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
.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"

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

Color.from_hls name="init_from_hls"
Color.from_pixel name="init_from_pixel"
Color.from_string name="init_from_string"

Color.new name="from_rgba" symbol_type="function"
.alpha default=0
.blue default=0
.green default=0
.red default=0

Color.init
.alpha default=0
.blue default=0
.green default=0
.red default=0

// 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