Add option to configure control center layer (#175)

This commit is contained in:
Tobias Langendorf
2022-10-21 00:01:00 +02:00
committed by GitHub
parent 1ef364c334
commit 69375cc791
5 changed files with 55 additions and 1 deletions

View File

@@ -21,6 +21,12 @@ config file to be able to detect config errors
values: top, bottom ++
description: Vertical position of control center and notification window
*layer* ++
type: string ++
default: top ++
values: background, bottom, top, overlay ++
description: Layer of control center window relative to normal windows. background is below all windows, overlay is above all windows.
*control-center-margin-top* ++
type: integer ++
default: 0 ++

View File

@@ -2,6 +2,7 @@
"$schema": @JSONPATH@,
"positionX": "right",
"positionY": "top",
"layer": "top",
"control-center-margin-top": 0,
"control-center-margin-bottom": 0,
"control-center-margin-right": 0,

View File

@@ -42,6 +42,25 @@ namespace SwayNotificationCenter {
}
}
public enum Layer {
BACKGROUND, BOTTOM, TOP, OVERLAY;
public string parse () {
switch (this) {
default:
return "top";
case BACKGROUND:
return "background";
case BOTTOM:
return "bottom";
case TOP:
return "top";
case OVERLAY:
return "overlay";
}
}
}
public class Category : Object {
public string ? sound { get; set; default = null; }
public string ? icon { get; set; default = null; }
@@ -284,6 +303,11 @@ namespace SwayNotificationCenter {
get; set; default = PositionY.TOP;
}
/** Layer of control center */
public Layer layer {
get; set; default = Layer.TOP;
}
/** The timeout for notifications with NORMAL priority */
private const int TIMEOUT_DEFAULT = 10;
private int _timeout = TIMEOUT_DEFAULT;

View File

@@ -14,6 +14,12 @@
"default": "right",
"enum": ["right", "left", "center"]
},
"layer": {
"type": "string",
"description": "Layer of control center window",
"default": "top",
"enum": ["background", "bottom", "top", "overlay"]
},
"positionY": {
"type": "string",
"description": "Vertical position of control center and notification window",

View File

@@ -212,7 +212,24 @@ namespace SwayNotificationCenter {
#else
GtkLayerShell.set_keyboard_interactivity (this, keyboard_shortcuts);
#endif
GtkLayerShell.set_layer (this, GtkLayerShell.Layer.TOP);
// Set layer
GtkLayerShell.Layer layer = GtkLayerShell.Layer.TOP;
switch (ConfigModel.instance.layer) {
case Layer.BACKGROUND:
layer = GtkLayerShell.Layer.BACKGROUND;
break;
case Layer.BOTTOM:
layer = GtkLayerShell.Layer.BOTTOM;
break;
case Layer.TOP:
layer = GtkLayerShell.Layer.TOP;
break;
case Layer.OVERLAY:
layer = GtkLayerShell.Layer.OVERLAY;
break;
}
GtkLayerShell.set_layer (this, layer);
// Set the box margins
box.set_margin_top (ConfigModel.instance.control_center_margin_top);