Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 1 addition & 4 deletions lib/CloseButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ public class Gala.CloseButton : Clutter.Actor {
var pixbuf = get_close_button_pixbuf (scale);
if (pixbuf != null) {
try {
var image = new Clutter.Image ();
Cogl.PixelFormat pixel_format = (pixbuf.get_has_alpha () ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888);
image.set_data (pixbuf.get_pixels (), pixel_format, pixbuf.width, pixbuf.height, pixbuf.rowstride);

var image = new Gala.Image.from_pixbuf (pixbuf);
pixbuf_actor.set_content (image);
pixbuf_actor.set_size (pixbuf.width, pixbuf.height);
set_size (pixbuf.width, pixbuf.height);
Expand Down
4 changes: 4 additions & 0 deletions lib/DragDropAction.vala
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ namespace Gala {
event.get_coords (out x, out y);

if (!dragging && clicked) {
#if HAS_MUTTER47
var drag_threshold = actor.context.get_settings ().dnd_drag_threshold;
#else
var drag_threshold = Clutter.Settings.get_default ().dnd_drag_threshold;
#endif
if (Math.fabsf (last_x - x) > drag_threshold || Math.fabsf (last_y - y) > drag_threshold) {
handle = drag_begin (last_x, last_y);
if (handle == null) {
Expand Down
75 changes: 75 additions & 0 deletions lib/Image.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright 2015 Corentin Noël
* Copyright 2025 elementary, Inc. <https://elementary.io>
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#if !HAS_MUTTER48
public class Gala.Image : Clutter.Image {
public Image.from_pixbuf (Gdk.Pixbuf pixbuf) {
Object ();

Cogl.PixelFormat pixel_format = (pixbuf.get_has_alpha () ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888);
try {
set_data (pixbuf.get_pixels (), pixel_format, pixbuf.width, pixbuf.height, pixbuf.rowstride);
} catch (Error e) {}
}
}
#else
public class Gala.Image : GLib.Object, Clutter.Content {
Gdk.Pixbuf? pixbuf;
Cogl.Texture? texture;
uint width;
uint height;

public Image.from_pixbuf (Gdk.Pixbuf pixbuf) {
this.pixbuf = pixbuf;
width = pixbuf.width;
height = pixbuf.height;
invalidate ();
}

public bool get_preferred_size (out float width, out float height) {
if (texture == null) {
width = 0;
height = 0;
return false;
}

width = texture.get_width ();
height = texture.get_height ();
return true;
}

public void paint_content (Clutter.Actor actor, Clutter.PaintNode node, Clutter.PaintContext paint_context) {
if (pixbuf != null && texture == null) {
var cogl_context = actor.context.get_backend ().get_cogl_context ();
Cogl.PixelFormat pixel_format = (pixbuf.get_has_alpha () ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888);
try {
texture = new Cogl.Texture2D.from_data (cogl_context, pixbuf.width, pixbuf.height, pixel_format, pixbuf.rowstride, pixbuf.get_pixels ());
if (width != texture.get_width () || height != texture.get_height ()) {
width = texture.get_width ();
height = texture.get_height ();
invalidate_size ();
}
} catch (Error e) {
critical (e.message);
}
}

if (texture == null)
return;

var content_node = actor.create_texture_paint_node (texture);
content_node.set_static_name ("Image Content");
node.add_child (content_node);
}

public void invalidate () {
texture = null;
}

public void invalidate_size () {
}
}
#endif
10 changes: 3 additions & 7 deletions lib/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,9 @@ namespace Gala {
texture.reactive = true;

if (pixbuf != null) {
try {
var image = new Clutter.Image ();
Cogl.PixelFormat pixel_format = (pixbuf.get_has_alpha () ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888);
image.set_data (pixbuf.get_pixels (), pixel_format, pixbuf.width, pixbuf.height, pixbuf.rowstride);
texture.set_content (image);
texture.set_size (pixbuf.width, pixbuf.height);
} catch (Error e) {}
var image = new Gala.Image.from_pixbuf (pixbuf);
texture.set_content (image);
texture.set_size (pixbuf.width, pixbuf.height);
} else {
// we'll just make this red so there's at least something as an
// indicator that loading failed. Should never happen and this
Expand Down
8 changes: 2 additions & 6 deletions lib/WindowIcon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ public class Gala.WindowIcon : Clutter.Actor {
height = icon_size * scale;

var pixbuf = Gala.Utils.get_icon_for_window (window, icon_size, scale);
try {
var image = new Clutter.Image ();
Cogl.PixelFormat pixel_format = (pixbuf.get_has_alpha () ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888);
image.set_data (pixbuf.get_pixels (), pixel_format, pixbuf.width, pixbuf.height, pixbuf.rowstride);
set_content (image);
} catch (Error e) {}
var image = new Gala.Image.from_pixbuf (pixbuf);
set_content (image);
}
}
1 change: 1 addition & 0 deletions lib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ gala_lib_sources = files(
'Drawing/Color.vala',
'Drawing/StyleManager.vala',
'Drawing/Utilities.vala',
'Image.vala',
'Plugin.vala',
'ShadowEffect.vala',
'Utils.vala',
Expand Down
11 changes: 11 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ if mutter47_dep.found()
vala_flags = ['--define', 'HAS_MUTTER43', '--define', 'HAS_MUTTER44', '--define', 'HAS_MUTTER45', '--define', 'HAS_MUTTER46', '--define', 'HAS_MUTTER47']
endif

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

if mutter_dep.length() == 0
error ('No supported mutter library found!')
endif
Expand Down
8 changes: 8 additions & 0 deletions plugins/pip/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ public class Gala.Plugins.PIP.Plugin : Gala.Plugin {

private Meta.WindowActor? get_window_actor_at (int x, int y) {
unowned Meta.Display display = wm.get_display ();
#if HAS_MUTTER48
unowned List<Meta.WindowActor> actors = display.get_compositor ().get_window_actors ();
#else
unowned List<Meta.WindowActor> actors = display.get_window_actors ();
#endif

var copy = actors.copy ();
copy.reverse ();
Expand All @@ -161,7 +165,11 @@ public class Gala.Plugins.PIP.Plugin : Gala.Plugin {

private Meta.WindowActor? get_active_window_actor () {
unowned Meta.Display display = wm.get_display ();
#if HAS_MUTTER48
unowned List<Meta.WindowActor> actors = display.get_compositor ().get_window_actors ();
#else
unowned List<Meta.WindowActor> actors = display.get_window_actors ();
#endif

var copy = actors.copy ();
copy.reverse ();
Expand Down
8 changes: 8 additions & 0 deletions plugins/pip/PopupWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
}

private Clutter.Actor on_move_begin () {
#if HAS_MUTTER48
display.set_cursor (Meta.Cursor.MOVE);
#else
display.set_cursor (Meta.Cursor.DND_IN_DRAG);
#endif

return this;
}
Expand Down Expand Up @@ -304,7 +308,11 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
opacity = 0;
restore_easing_state ();

#if HAS_MUTTER48
GLib.Timeout.add (duration, () => {
#else
Clutter.Threads.Timeout.add (duration, () => {
#endif
closed ();
return Source.REMOVE;
});
Expand Down
4 changes: 4 additions & 0 deletions src/ColorFilters/ColorblindnessCorrectionEffect.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ public class Gala.ColorblindnessCorrectionEffect : Clutter.ShaderEffect {

public ColorblindnessCorrectionEffect (int mode, double strength) {
Object (
#if HAS_MUTTER48
shader_type: Cogl.ShaderType.FRAGMENT,
#else
shader_type: Clutter.ShaderType.FRAGMENT_SHADER,
#endif
mode: mode,
strength: strength
);
Expand Down
4 changes: 4 additions & 0 deletions src/ColorFilters/MonochromeEffect.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public class Gala.MonochromeEffect : Clutter.ShaderEffect {

public MonochromeEffect (double strength) {
Object (
#if HAS_MUTTER48
shader_type: Cogl.ShaderType.FRAGMENT,
#else
shader_type: Clutter.ShaderType.FRAGMENT_SHADER,
#endif
strength: strength
);

Expand Down
8 changes: 8 additions & 0 deletions src/DesktopIntegration.vala
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,18 @@ public class Gala.DesktopIntegration : GLib.Object {

transition.stopped.connect (() => {
notifying = false;
#if HAS_MUTTER48
wm.get_display ().get_compositor ().enable_unredirect ();
#else
wm.get_display ().enable_unredirect ();
#endif
});

#if HAS_MUTTER48
wm.get_display ().get_compositor ().disable_unredirect ();
#else
wm.get_display ().disable_unredirect ();
#endif

((Meta.WindowActor) window.get_compositor_private ()).add_transition ("notify-already-focused", transition);
}
Expand Down
8 changes: 7 additions & 1 deletion src/InternalUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ namespace Gala {

new_window.change_workspace_by_index (index, false);

#if HAS_MUTTER48
unowned List<Meta.WindowActor> actors = new_window.get_display ().get_compositor ().get_window_actors ();
#else
unowned List<Meta.WindowActor> actors = new_window.get_display ().get_window_actors ();
#endif
foreach (unowned Meta.WindowActor actor in actors) {
if (actor.is_destroyed ())
continue;
Expand Down Expand Up @@ -338,7 +342,9 @@ namespace Gala {
}

public static void bell_notify (Meta.Display display) {
#if HAS_MUTTER47
#if HAS_MUTTER48
display.get_compositor ().get_stage ().context.get_backend ().get_default_seat ().bell_notify ();
#elif HAS_MUTTER47
display.get_stage ().context.get_backend ().get_default_seat ().bell_notify ();
#else
Clutter.get_default_backend ().get_default_seat ().bell_notify ();
Expand Down
6 changes: 5 additions & 1 deletion src/ScreenshotManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,11 @@ public class Gala.ScreenshotManager : Object {
}

private Cairo.ImageSurface composite_stage_cursor (Cairo.ImageSurface image, Cairo.RectangleInt image_rect) {
unowned Meta.CursorTracker cursor_tracker = wm.get_display ().get_cursor_tracker ();
#if HAS_MUTTER48
unowned var cursor_tracker = wm.get_display ().get_compositor ().get_backend ().get_cursor_tracker ();
#else
unowned var cursor_tracker = wm.get_display ().get_cursor_tracker ();
#endif
Graphene.Point coords = {};
cursor_tracker.get_pointer (out coords, null);

Expand Down
10 changes: 9 additions & 1 deletion src/ShellClients/HideTracker.vala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ public class Gala.HideTracker : Object {
window.unmanaged.connect (schedule_update);
});

var cursor_tracker = display.get_cursor_tracker ();
#if HAS_MUTTER48
unowned var cursor_tracker = display.get_compositor ().get_backend ().get_cursor_tracker ();
#else
unowned var cursor_tracker = display.get_cursor_tracker ();
#endif
cursor_tracker.position_invalidated.connect (() => {
var has_pointer = panel.window.has_pointer ();

Expand All @@ -80,7 +84,11 @@ public class Gala.HideTracker : Object {
pan_action.gesture_begin.connect (check_valid_gesture);
pan_action.pan.connect (on_pan);

#if HAS_MUTTER48
display.get_compositor ().get_stage ().add_action_full ("panel-swipe-gesture", CAPTURE, pan_action);
#else
display.get_stage ().add_action_full ("panel-swipe-gesture", CAPTURE, pan_action);
#endif

panel.notify["anchor"].connect (setup_barrier);

Expand Down
4 changes: 4 additions & 0 deletions src/Widgets/DwellClickTimer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ public class Gala.DwellClickTimer : Clutter.Actor, Clutter.Animatable {
var scale = display.get_monitor_scale (display.get_current_monitor ());
update_cursor_size (scale);

#if HAS_MUTTER48
unowned var tracker = display.get_compositor ().get_backend ().get_cursor_tracker ();
#else
unowned var tracker = display.get_cursor_tracker ();
#endif
Graphene.Point coords = {};
tracker.get_pointer (out coords, null);

Expand Down
4 changes: 4 additions & 0 deletions src/Widgets/MultitaskingView/IconGroup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,11 @@ public class Gala.IconGroup : CanvasActor {
// disable reactivity so that workspace thumbs can get events
reactive = false;

#if HAS_MUTTER48
display.set_cursor (Meta.Cursor.MOVE);
#else
display.set_cursor (Meta.Cursor.DND_IN_DRAG);
#endif

return this;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Widgets/MultitaskingView/MonitorClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public class Gala.MonitorClone : ActorTarget {
display.window_entered_monitor.connect (window_entered);
display.window_left_monitor.connect (window_left);

#if HAS_MUTTER48
unowned GLib.List<Meta.WindowActor> window_actors = display.get_compositor ().get_window_actors ();
#else
unowned GLib.List<Meta.WindowActor> window_actors = display.get_window_actors ();
#endif
foreach (unowned Meta.WindowActor window_actor in window_actors) {
if (window_actor.is_destroyed ())
continue;
Expand Down
8 changes: 8 additions & 0 deletions src/Widgets/MultitaskingView/WindowClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,11 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
close_button.opacity = 0;
window_title.opacity = 0;

#if HAS_MUTTER48
wm.get_display ().set_cursor (Meta.Cursor.MOVE);
#else
wm.get_display ().set_cursor (Meta.Cursor.DND_IN_DRAG);
#endif

return this;
}
Expand Down Expand Up @@ -551,7 +555,11 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
}
}

#if HAS_MUTTER48
wm.get_display ().set_cursor (hovered ? Meta.Cursor.MOVE: Meta.Cursor.NO_DROP);
#else
wm.get_display ().set_cursor (hovered ? Meta.Cursor.DND_MOVE: Meta.Cursor.DND_IN_DRAG);
#endif
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/Widgets/PointerLocator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ public class Gala.PointerLocator : Clutter.Actor, Clutter.Animatable {
stroke_color = new Cairo.Pattern.rgb (rgba.red, rgba.green, rgba.blue);
fill_color = new Cairo.Pattern.rgba (rgba.red, rgba.green, rgba.blue, BACKGROUND_OPACITY);

#if HAS_MUTTER48
unowned var tracker = display.get_compositor ().get_backend ().get_cursor_tracker ();
#else
unowned var tracker = display.get_cursor_tracker ();
#endif
Graphene.Point coords = {};
tracker.get_pointer (out coords, null);

Expand Down
Loading