Skip to content

Commit

Permalink
Added layer-shell-cover-screen option to fix animations in Hyprland (#…
Browse files Browse the repository at this point in the history
…520)

* Added layer-shell-cover-screen option to fix animations in Hyprland

* Fixed linting issue
  • Loading branch information
ErikReider authored Mar 2, 2025
1 parent dc7cd1a commit 86a7b5b
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/config.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"layer": "overlay",
"control-center-layer": "top",
"layer-shell": true,
"layer-shell-cover-screen": true,
"cssPriority": "application",
"control-center-margin-top": 0,
"control-center-margin-bottom": 0,
Expand Down
6 changes: 6 additions & 0 deletions src/configModel/configModel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ namespace SwayNotificationCenter {
*/
public bool layer_shell { get; set; default = true; }

/**
* Wether or not the windows should cover the whole screen when
* layer-shell is used.
*/
public bool layer_shell_cover_screen { get; set; default = true; }

/** The CSS loading priority */
public CssPriority cssPriority { // vala-lint=naming-convention
get; set; default = CssPriority.APPLICATION;
Expand Down
5 changes: 5 additions & 0 deletions src/configSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"description": "Wether or not the windows should be opened as layer-shell surfaces. Note: Requires swaync restart to apply",
"default": true
},
"layer-shell-cover-screen": {
"type": "boolean",
"description": "Wether or not the windows should cover the whole screen when layer-shell is used. Fixes animations in compositors like Hyprland.",
"default": true
},
"cssPriority": {
"type": "string",
"description": "Which GTK priority to use when loading the default and user CSS files. Pick \"user\" to override XDG_CONFIG_HOME/gtk-3.0/gtk.css",
Expand Down
44 changes: 40 additions & 4 deletions src/controlCenter/controlCenter.vala
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ namespace SwayNotificationCenter {

/** Resets the UI positions */
private void set_anchor () {
PositionX pos_x = ConfigModel.instance.control_center_positionX;
if (pos_x == PositionX.NONE) pos_x = ConfigModel.instance.positionX;
PositionY pos_y = ConfigModel.instance.control_center_positionY;
if (pos_y == PositionY.NONE) pos_y = ConfigModel.instance.positionY;

if (swaync_daemon.use_layer_shell) {
// Set the exlusive zone
int exclusive_zone = ConfigModel.instance.control_center_exclusive_zone ? 0 : 100;
Expand Down Expand Up @@ -423,6 +428,41 @@ namespace SwayNotificationCenter {
break;
}
GtkLayerShell.set_layer (this, layer);

// Set whether the control center should cover the whole screen or not
bool cover_screen = ConfigModel.instance.layer_shell_cover_screen;
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.TOP, cover_screen);
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.LEFT, cover_screen);
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.RIGHT, cover_screen);
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.BOTTOM, cover_screen);
if (!ConfigModel.instance.layer_shell_cover_screen) {
switch (pos_x) {
case PositionX.LEFT:
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.LEFT, true);
break;
case PositionX.CENTER:
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.LEFT, true);
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.RIGHT, true);
break;
default:
case PositionX.RIGHT:
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.RIGHT, true);
break;
}
switch (pos_y) {
default:
case PositionY.TOP:
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.TOP, true);
break;
case PositionY.CENTER:
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.TOP, true);
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.BOTTOM, true);
break;
case PositionY.BOTTOM:
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.BOTTOM, true);
break;
}
}
}

// Set the box margins
Expand All @@ -433,8 +473,6 @@ namespace SwayNotificationCenter {

// Anchor box to north/south edges as needed
Gtk.Align align_x = Gtk.Align.END;
PositionX pos_x = ConfigModel.instance.control_center_positionX;
if (pos_x == PositionX.NONE) pos_x = ConfigModel.instance.positionX;
switch (pos_x) {
case PositionX.LEFT:
align_x = Gtk.Align.START;
Expand All @@ -448,8 +486,6 @@ namespace SwayNotificationCenter {
break;
}
Gtk.Align align_y = Gtk.Align.START;
PositionY pos_y = ConfigModel.instance.control_center_positionY;
if (pos_y == PositionY.NONE) pos_y = ConfigModel.instance.positionY;
switch (pos_y) {
default:
case PositionY.TOP:
Expand Down
4 changes: 3 additions & 1 deletion src/swayncDaemon/swayncDaemon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ namespace SwayNotificationCenter {

[DBus (visible = false)]
public void show_blank_windows (Gdk.Monitor ? monitor) {
if (!use_layer_shell) return;
if (!use_layer_shell || !ConfigModel.instance.layer_shell_cover_screen) {
return;
}
foreach (unowned BlankWindow win in blank_windows.data) {
if (win.monitor != monitor) win.show ();
}
Expand Down

0 comments on commit 86a7b5b

Please sign in to comment.