Skip to content

Commit

Permalink
Merge branch 'master' into lenemter/idk-what-im-doing
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Oct 26, 2023
2 parents d33054d + 11c3125 commit faac336
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 126 deletions.
1 change: 1 addition & 0 deletions data/gala.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@
<enum id="GestureSwipeHorizontal">
<value nick="none" value="0" />
<value nick="switch-to-workspace" value="1" />
<value nick="move-to-workspace" value="2" />
</enum>
<enum id="GestureSwipeUp">
<value nick="none" value="0" />
Expand Down
1 change: 1 addition & 0 deletions data/gala.metainfo.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
</description>
<issues>
<issue url="https://github.com/elementary/notifications/issues/218">Notifications appear in the middle of the screen</issue>
<issue url="https://github.com/elementary/gala/issues/1774">Scheduled switch to dark style does not dim the wallpaper after cold reboot on elementary OS 7.1</issue>
<issue url="https://github.com/elementary/gala/issues/1261">Alt + Shift unnecessarily blocked when there is only one keyboard layout</issue>
</issues>
</release>
Expand Down
7 changes: 7 additions & 0 deletions plugins/pip/PopupWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,15 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
}

private Clutter.Actor on_move_begin () {
wm.get_display ().set_cursor (Meta.Cursor.DND_IN_DRAG);

return this;
}

private void on_move_end () {
reactive = true;
update_screen_position ();
wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);
}

#if HAS_MUTTER45
Expand All @@ -245,6 +248,8 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
grab = resize_button.get_stage ().grab (resize_button);
resize_button.event.connect (on_resize_event);

wm.get_display ().set_cursor (Meta.Cursor.SE_RESIZE);

return Clutter.EVENT_PROPAGATE;
}

Expand Down Expand Up @@ -303,6 +308,8 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
resizing = false;

update_screen_position ();

wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);
}

private void on_allocation_changed () {
Expand Down
6 changes: 3 additions & 3 deletions src/Background/Background.vala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Gala {
var cache = BackgroundCache.get_default ();

foreach (var watch in file_watches.values) {
SignalHandler.disconnect (cache, watch);
cache.disconnect (watch);
}

background_source.changed.disconnect (settings_changed);
Expand Down Expand Up @@ -179,7 +179,7 @@ namespace Gala {
} else {
ulong handler = 0;
handler = image.loaded.connect (() => {
SignalHandler.disconnect (image, handler);
image.disconnect (handler);
if (--num_pending_images == 0) {
finish_animation (files);
}
Expand Down Expand Up @@ -237,7 +237,7 @@ namespace Gala {
ulong handler = 0;
handler = image.loaded.connect (() => {
set_loaded ();
SignalHandler.disconnect (image, handler);
image.disconnect (handler);
});
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/Background/BackgroundContainer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ namespace Gala {
public signal void changed ();
public signal void show_background_menu (int x, int y);

public Meta.Display display { get; construct; }
public WindowManager wm { get; construct; }

public BackgroundContainer (Meta.Display display) {
Object (display: display);
public BackgroundContainer (WindowManager wm) {
Object (wm: wm);
}

construct {
unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
unowned var monitor_manager = wm.get_display ().get_context ().get_backend ().get_monitor_manager ();
monitor_manager.monitors_changed.connect (update);

reactive = true;
Expand All @@ -43,7 +43,7 @@ namespace Gala {
}

~BackgroundContainer () {
unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
unowned var monitor_manager = wm.get_display ().get_context ().get_backend ().get_monitor_manager ();
monitor_manager.monitors_changed.disconnect (update);
}

Expand All @@ -54,8 +54,8 @@ namespace Gala {

destroy_all_children ();

for (var i = 0; i < display.get_n_monitors (); i++) {
var background = new BackgroundManager (display, i);
for (var i = 0; i < wm.get_display ().get_n_monitors (); i++) {
var background = new BackgroundManager (wm, i);

add_child (background);

Expand Down
100 changes: 20 additions & 80 deletions src/Background/BackgroundManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,25 @@

namespace Gala {
public class BackgroundManager : Meta.BackgroundGroup {
private const string GALA_BACKGROUND_SCHEMA = "io.elementary.desktop.background";
private const string DIM_WALLPAPER_KEY = "dim-wallpaper-in-dark-style";
private const double DIM_OPACITY = 0.55;
private const int FADE_ANIMATION_TIME = 1000;

public signal void changed ();

public Meta.Display display { get; construct; }
public WindowManager wm { get; construct; }
public int monitor_index { get; construct; }
public bool control_position { get; construct; }

private BackgroundSource background_source;
private Meta.BackgroundActor background_actor;
private Meta.BackgroundActor? new_background_actor = null;

private Clutter.PropertyTransition? last_dim_transition = null;

private static Settings gala_background_settings;

public BackgroundManager (Meta.Display display, int monitor_index, bool control_position = true) {
Object (display: display, monitor_index: monitor_index, control_position: control_position);
}

static construct {
gala_background_settings = new Settings (GALA_BACKGROUND_SCHEMA);
public BackgroundManager (WindowManager wm, int monitor_index, bool control_position = true) {
Object (wm: wm, monitor_index: monitor_index, control_position: control_position);
}

construct {
background_source = BackgroundCache.get_default ().get_background_source (display);
background_source = BackgroundCache.get_default ().get_background_source (wm.get_display ());
background_actor = create_background_actor ();

destroy.connect (on_destroy);
Expand Down Expand Up @@ -76,7 +66,7 @@ namespace Gala {
if (old_background_actor == null)
return;

if (animate) {
if (animate && wm.enable_animations) {
var transition = new Clutter.PropertyTransition ("opacity");
transition.set_from_value (255);
transition.set_to_value (0);
Expand Down Expand Up @@ -120,7 +110,7 @@ namespace Gala {

ulong handler = 0;
handler = background.loaded.connect (() => {
SignalHandler.disconnect (background, handler);
background.disconnect (handler);
background.set_data<ulong> ("background-loaded-handler", 0);

swap_background_actor (animate);
Expand All @@ -135,20 +125,23 @@ namespace Gala {
}

private Meta.BackgroundActor create_background_actor () {
unowned var display = wm.get_display ();

var background = background_source.get_background (monitor_index);
var background_actor = new Meta.BackgroundActor (display, monitor_index);

((Meta.BackgroundContent)background_actor.content).background = background.background;
((Meta.BackgroundContent)background_actor.content).vignette = true;
unowned var content = (Meta.BackgroundContent) background_actor.content;
content.background = background.background;

// Don't play dim animation when launching gala or switching wallpaper
if (should_dim ()) {
((Meta.BackgroundContent)background_actor.content).brightness = DIM_OPACITY;
if (background_source.should_dim) {
// It doesn't work without Idle :(
Idle.add (() => {
content.vignette = true;
content.brightness = DIM_OPACITY;
return Source.REMOVE;
});
}

Granite.Settings.get_default ().notify["prefers-color-scheme"].connect (update_dim_wallpaper);
gala_background_settings.changed[DIM_WALLPAPER_KEY].connect (update_dim_wallpaper);

insert_child_below (background_actor, null);

var monitor = display.get_monitor_geometry (monitor_index);
Expand All @@ -160,78 +153,25 @@ namespace Gala {

ulong changed_handler = 0;
changed_handler = background.changed.connect (() => {
SignalHandler.disconnect (background, changed_handler);
background.disconnect (changed_handler);
changed_handler = 0;
update_background_actor ();
});

background_actor.destroy.connect (() => {
if (changed_handler != 0) {
SignalHandler.disconnect (background, changed_handler);
background.disconnect (changed_handler);
changed_handler = 0;
}

var loaded_handler = background.get_data<ulong> ("background-loaded-handler");
if (loaded_handler != 0) {
SignalHandler.disconnect (background, loaded_handler);
background.disconnect (loaded_handler);
background.set_data<ulong> ("background-loaded-handler", 0);
}
});

return background_actor;
}

private bool should_dim () {
return (
Granite.Settings.get_default ().prefers_color_scheme == Granite.Settings.ColorScheme.DARK &&
gala_background_settings.get_boolean (DIM_WALLPAPER_KEY)
);
}

// OpacityDimActor is used for transitioning background actor's vignette brightness
// In mutter 3.38+ vignette's properties are contained in Meta.BackgroundContent
// which doesn't support transitions
// so we bind OpacityDimActor.opacity to ((Meta.BackgroundContent) background_actor.content).brightness
// and then create transition for OpacityDimActor.opacity

private class OpacityDimActor : Clutter.Actor {
public new double opacity { get; set; }
}

private void update_dim_wallpaper () {
if (last_dim_transition != null) {
last_dim_transition.stop ();
}

var dim_actor = new OpacityDimActor ();
background_actor.add_child (dim_actor);
var binding = dim_actor.bind_property (
"opacity",
(Meta.BackgroundContent) background_actor.content,
"brightness",
BindingFlags.DEFAULT
);

var transition = new Clutter.PropertyTransition ("opacity");
transition.set_from_value (
((Meta.BackgroundContent) background_actor.content).brightness
);
transition.set_to_value (should_dim () ? DIM_OPACITY : 1.0);
transition.duration = FADE_ANIMATION_TIME;
transition.progress_mode = Clutter.AnimationMode.EASE_OUT_QUAD;
transition.remove_on_complete = true;
transition.completed.connect (() => {
binding.unbind ();

background_actor.remove_child (dim_actor);
dim_actor.destroy ();

changed ();
});

dim_actor.add_transition ("wallpaper-dim", transition);

last_dim_transition = transition;
}
}
}
23 changes: 17 additions & 6 deletions src/Background/BackgroundSource.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace Gala {
// list of keys that are actually relevant for us
private const string[] OPTIONS = {
"color-shading-type",
"picture-opacity",
"picture-options",
"picture-uri",
"picture-uri-dark",
Expand All @@ -31,13 +30,23 @@ namespace Gala {
public signal void changed ();

public Meta.Display display { get; construct; }
public GLib.Settings gnome_background_settings { get; construct; }
public GLib.Settings gnome_background_settings { get; private set; }

internal int use_count { get; set; default = 0; }

private GLib.HashTable<int, Background> backgrounds;
private uint[] hash_cache;
private Meta.MonitorManager? monitor_manager;
private GLib.Settings gala_background_settings;

public bool should_dim {
get {
return (
Granite.Settings.get_default ().prefers_color_scheme == DARK &&
gala_background_settings.get_boolean ("dim-wallpaper-in-dark-style")
);
}
}

public BackgroundSource (Meta.Display display) {
Object (display: display);
Expand All @@ -50,7 +59,12 @@ namespace Gala {
monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
monitor_manager.monitors_changed.connect (monitors_changed);

gnome_background_settings = new Settings ("org.gnome.desktop.background");
gala_background_settings = new GLib.Settings ("io.elementary.desktop.background");
gala_background_settings.changed["dim-wallpaper-in-dark-style"].connect (() => changed ());

Granite.Settings.get_default ().notify["prefers-color-scheme"].connect (() => changed ());

gnome_background_settings = new GLib.Settings ("org.gnome.desktop.background");

// unfortunately the settings sometimes tend to fire random changes even though
// nothing actually happened. The code below is used to prevent us from spamming
Expand All @@ -71,9 +85,6 @@ namespace Gala {
}
}
});

unowned var granite_settings = Granite.Settings.get_default ();
granite_settings.notify["prefers-color-scheme"].connect (() => changed ());
}

private void monitors_changed () {
Expand Down
6 changes: 6 additions & 0 deletions src/Widgets/IconGroup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ namespace Gala {
// disable reactivity so that workspace thumbs can get events
reactive = false;

wm.get_display ().set_cursor (Meta.Cursor.DND_IN_DRAG);

return this;
}

Expand All @@ -534,11 +536,15 @@ namespace Gala {
} else {
drag_canceled ();
}

wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);
}

private void drag_canceled () {
get_parent ().remove_child (this);
restore_group ();

wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);
}

private void restore_group () {
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/MonitorClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Gala {
construct {
reactive = true;

background = new BackgroundManager (display, monitor, false);
background = new BackgroundManager (wm, monitor, false);

var scale = display.get_monitor_scale (monitor);

Expand Down
Loading

0 comments on commit faac336

Please sign in to comment.