Added ability to choose wether layer-shell should be used or not (#261)
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
"positionX": "right",
|
"positionX": "right",
|
||||||
"positionY": "top",
|
"positionY": "top",
|
||||||
"layer": "top",
|
"layer": "top",
|
||||||
|
"layer-shell": true,
|
||||||
"cssPriority": "application",
|
"cssPriority": "application",
|
||||||
"control-center-margin-top": 0,
|
"control-center-margin-top": 0,
|
||||||
"control-center-margin-bottom": 0,
|
"control-center-margin-bottom": 0,
|
||||||
|
@@ -351,6 +351,11 @@ namespace SwayNotificationCenter {
|
|||||||
get; set; default = Layer.TOP;
|
get; set; default = Layer.TOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wether or not the windows should be opened as layer-shell surfaces
|
||||||
|
*/
|
||||||
|
public bool layer_shell { get; set; default = true; }
|
||||||
|
|
||||||
/** The CSS loading priority */
|
/** The CSS loading priority */
|
||||||
public CssPriority cssPriority { // vala-lint=naming-convention
|
public CssPriority cssPriority { // vala-lint=naming-convention
|
||||||
get; set; default = CssPriority.APPLICATION;
|
get; set; default = CssPriority.APPLICATION;
|
||||||
|
@@ -20,6 +20,11 @@
|
|||||||
"default": "top",
|
"default": "top",
|
||||||
"enum": ["background", "bottom", "top", "overlay"]
|
"enum": ["background", "bottom", "top", "overlay"]
|
||||||
},
|
},
|
||||||
|
"layer-shell": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Wether or not the windows should be opened as layer-shell surfaces. Note: Requires swaync restart to apply",
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
"cssPriority": {
|
"cssPriority": {
|
||||||
"type": "string",
|
"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",
|
"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",
|
||||||
|
@@ -38,19 +38,21 @@ namespace SwayNotificationCenter {
|
|||||||
|
|
||||||
this.swaync_daemon.reloading_css.connect (reload_notifications_style);
|
this.swaync_daemon.reloading_css.connect (reload_notifications_style);
|
||||||
|
|
||||||
if (!GtkLayerShell.is_supported ()) {
|
if (swaync_daemon.use_layer_shell) {
|
||||||
stderr.printf ("GTKLAYERSHELL IS NOT SUPPORTED!\n");
|
if (!GtkLayerShell.is_supported ()) {
|
||||||
stderr.printf ("Swaync only works on Wayland!\n");
|
stderr.printf ("GTKLAYERSHELL IS NOT SUPPORTED!\n");
|
||||||
stderr.printf ("If running waylans session, try running:\n");
|
stderr.printf ("Swaync only works on Wayland!\n");
|
||||||
stderr.printf ("\tGDK_BACKEND=wayland swaync\n");
|
stderr.printf ("If running waylans session, try running:\n");
|
||||||
Process.exit (1);
|
stderr.printf ("\tGDK_BACKEND=wayland swaync\n");
|
||||||
|
Process.exit (1);
|
||||||
|
}
|
||||||
|
GtkLayerShell.init_for_window (this);
|
||||||
|
GtkLayerShell.set_namespace (this, "swaync-control-center");
|
||||||
|
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.TOP, true);
|
||||||
|
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.LEFT, true);
|
||||||
|
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.RIGHT, true);
|
||||||
|
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.BOTTOM, true);
|
||||||
}
|
}
|
||||||
GtkLayerShell.init_for_window (this);
|
|
||||||
GtkLayerShell.set_namespace (this, "swaync-control-center");
|
|
||||||
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.TOP, true);
|
|
||||||
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.LEFT, true);
|
|
||||||
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.RIGHT, true);
|
|
||||||
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.BOTTOM, true);
|
|
||||||
|
|
||||||
viewport.size_allocate.connect (size_alloc);
|
viewport.size_allocate.connect (size_alloc);
|
||||||
|
|
||||||
@@ -255,34 +257,36 @@ namespace SwayNotificationCenter {
|
|||||||
|
|
||||||
/** Resets the UI positions */
|
/** Resets the UI positions */
|
||||||
private void set_anchor () {
|
private void set_anchor () {
|
||||||
// Grabs the keyboard input until closed
|
if (swaync_daemon.use_layer_shell) {
|
||||||
bool keyboard_shortcuts = ConfigModel.instance.keyboard_shortcuts;
|
// Grabs the keyboard input until closed
|
||||||
|
bool keyboard_shortcuts = ConfigModel.instance.keyboard_shortcuts;
|
||||||
#if HAVE_LATEST_GTK_LAYER_SHELL
|
#if HAVE_LATEST_GTK_LAYER_SHELL
|
||||||
var mode = keyboard_shortcuts ?
|
var mode = keyboard_shortcuts ?
|
||||||
GtkLayerShell.KeyboardMode.EXCLUSIVE :
|
GtkLayerShell.KeyboardMode.EXCLUSIVE :
|
||||||
GtkLayerShell.KeyboardMode.NONE;
|
GtkLayerShell.KeyboardMode.NONE;
|
||||||
GtkLayerShell.set_keyboard_mode (this, mode);
|
GtkLayerShell.set_keyboard_mode (this, mode);
|
||||||
#else
|
#else
|
||||||
GtkLayerShell.set_keyboard_interactivity (this, keyboard_shortcuts);
|
GtkLayerShell.set_keyboard_interactivity (this, keyboard_shortcuts);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set layer
|
// Set layer
|
||||||
GtkLayerShell.Layer layer = GtkLayerShell.Layer.TOP;
|
GtkLayerShell.Layer layer = GtkLayerShell.Layer.TOP;
|
||||||
switch (ConfigModel.instance.layer) {
|
switch (ConfigModel.instance.layer) {
|
||||||
case Layer.BACKGROUND:
|
case Layer.BACKGROUND:
|
||||||
layer = GtkLayerShell.Layer.BACKGROUND;
|
layer = GtkLayerShell.Layer.BACKGROUND;
|
||||||
break;
|
break;
|
||||||
case Layer.BOTTOM:
|
case Layer.BOTTOM:
|
||||||
layer = GtkLayerShell.Layer.BOTTOM;
|
layer = GtkLayerShell.Layer.BOTTOM;
|
||||||
break;
|
break;
|
||||||
case Layer.TOP:
|
case Layer.TOP:
|
||||||
layer = GtkLayerShell.Layer.TOP;
|
layer = GtkLayerShell.Layer.TOP;
|
||||||
break;
|
break;
|
||||||
case Layer.OVERLAY:
|
case Layer.OVERLAY:
|
||||||
layer = GtkLayerShell.Layer.OVERLAY;
|
layer = GtkLayerShell.Layer.OVERLAY;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
GtkLayerShell.set_layer (this, layer);
|
||||||
}
|
}
|
||||||
GtkLayerShell.set_layer (this, layer);
|
|
||||||
|
|
||||||
// Set the box margins
|
// Set the box margins
|
||||||
box.set_margin_top (ConfigModel.instance.control_center_margin_top);
|
box.set_margin_top (ConfigModel.instance.control_center_margin_top);
|
||||||
|
@@ -43,16 +43,18 @@ namespace SwayNotificationCenter {
|
|||||||
private const int MAX_HEIGHT = 600;
|
private const int MAX_HEIGHT = 600;
|
||||||
|
|
||||||
private NotificationWindow () {
|
private NotificationWindow () {
|
||||||
if (!GtkLayerShell.is_supported ()) {
|
if (swaync_daemon.use_layer_shell) {
|
||||||
stderr.printf ("GTKLAYERSHELL IS NOT SUPPORTED!\n");
|
if (!GtkLayerShell.is_supported ()) {
|
||||||
stderr.printf ("Swaync only works on Wayland!\n");
|
stderr.printf ("GTKLAYERSHELL IS NOT SUPPORTED!\n");
|
||||||
stderr.printf ("If running waylans session, try running:\n");
|
stderr.printf ("Swaync only works on Wayland!\n");
|
||||||
stderr.printf ("\tGDK_BACKEND=wayland swaync\n");
|
stderr.printf ("If running waylans session, try running:\n");
|
||||||
Process.exit (1);
|
stderr.printf ("\tGDK_BACKEND=wayland swaync\n");
|
||||||
|
Process.exit (1);
|
||||||
|
}
|
||||||
|
GtkLayerShell.init_for_window (this);
|
||||||
|
GtkLayerShell.set_namespace (this, "swaync-notification-window");
|
||||||
|
GtkLayerShell.set_layer (this, GtkLayerShell.Layer.OVERLAY);
|
||||||
}
|
}
|
||||||
GtkLayerShell.init_for_window (this);
|
|
||||||
GtkLayerShell.set_namespace (this, "swaync-notification-window");
|
|
||||||
GtkLayerShell.set_layer (this, GtkLayerShell.Layer.OVERLAY);
|
|
||||||
this.set_anchor ();
|
this.set_anchor ();
|
||||||
|
|
||||||
// -1 should set it to the content size unless it exceeds max_height
|
// -1 should set it to the content size unless it exceeds max_height
|
||||||
@@ -68,18 +70,21 @@ namespace SwayNotificationCenter {
|
|||||||
private void set_anchor () {
|
private void set_anchor () {
|
||||||
switch (ConfigModel.instance.positionX) {
|
switch (ConfigModel.instance.positionX) {
|
||||||
case PositionX.LEFT:
|
case PositionX.LEFT:
|
||||||
|
if (!swaync_daemon.use_layer_shell) break;
|
||||||
GtkLayerShell.set_anchor (
|
GtkLayerShell.set_anchor (
|
||||||
this, GtkLayerShell.Edge.RIGHT, false);
|
this, GtkLayerShell.Edge.RIGHT, false);
|
||||||
GtkLayerShell.set_anchor (
|
GtkLayerShell.set_anchor (
|
||||||
this, GtkLayerShell.Edge.LEFT, true);
|
this, GtkLayerShell.Edge.LEFT, true);
|
||||||
break;
|
break;
|
||||||
case PositionX.CENTER:
|
case PositionX.CENTER:
|
||||||
|
if (!swaync_daemon.use_layer_shell) break;
|
||||||
GtkLayerShell.set_anchor (
|
GtkLayerShell.set_anchor (
|
||||||
this, GtkLayerShell.Edge.RIGHT, false);
|
this, GtkLayerShell.Edge.RIGHT, false);
|
||||||
GtkLayerShell.set_anchor (
|
GtkLayerShell.set_anchor (
|
||||||
this, GtkLayerShell.Edge.LEFT, false);
|
this, GtkLayerShell.Edge.LEFT, false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (!swaync_daemon.use_layer_shell) break;
|
||||||
GtkLayerShell.set_anchor (
|
GtkLayerShell.set_anchor (
|
||||||
this, GtkLayerShell.Edge.LEFT, false);
|
this, GtkLayerShell.Edge.LEFT, false);
|
||||||
GtkLayerShell.set_anchor (
|
GtkLayerShell.set_anchor (
|
||||||
@@ -90,6 +95,7 @@ namespace SwayNotificationCenter {
|
|||||||
default:
|
default:
|
||||||
case PositionY.TOP:
|
case PositionY.TOP:
|
||||||
list_reverse = false;
|
list_reverse = false;
|
||||||
|
if (!swaync_daemon.use_layer_shell) break;
|
||||||
GtkLayerShell.set_anchor (
|
GtkLayerShell.set_anchor (
|
||||||
this, GtkLayerShell.Edge.BOTTOM, false);
|
this, GtkLayerShell.Edge.BOTTOM, false);
|
||||||
GtkLayerShell.set_anchor (
|
GtkLayerShell.set_anchor (
|
||||||
@@ -97,17 +103,19 @@ namespace SwayNotificationCenter {
|
|||||||
break;
|
break;
|
||||||
case PositionY.CENTER:
|
case PositionY.CENTER:
|
||||||
list_reverse = false;
|
list_reverse = false;
|
||||||
|
if (!swaync_daemon.use_layer_shell) break;
|
||||||
GtkLayerShell.set_anchor (
|
GtkLayerShell.set_anchor (
|
||||||
this, GtkLayerShell.Edge.BOTTOM, false);
|
this, GtkLayerShell.Edge.BOTTOM, false);
|
||||||
GtkLayerShell.set_anchor (
|
GtkLayerShell.set_anchor (
|
||||||
this, GtkLayerShell.Edge.TOP, false);
|
this, GtkLayerShell.Edge.TOP, false);
|
||||||
break;
|
break;
|
||||||
case PositionY.BOTTOM:
|
case PositionY.BOTTOM:
|
||||||
|
list_reverse = true;
|
||||||
|
if (!swaync_daemon.use_layer_shell) break;
|
||||||
GtkLayerShell.set_anchor (
|
GtkLayerShell.set_anchor (
|
||||||
this, GtkLayerShell.Edge.TOP, false);
|
this, GtkLayerShell.Edge.TOP, false);
|
||||||
GtkLayerShell.set_anchor (
|
GtkLayerShell.set_anchor (
|
||||||
this, GtkLayerShell.Edge.BOTTOM, true);
|
this, GtkLayerShell.Edge.BOTTOM, true);
|
||||||
list_reverse = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,9 +21,14 @@ namespace SwayNotificationCenter {
|
|||||||
[DBus (visible = false)]
|
[DBus (visible = false)]
|
||||||
public signal void reloading_css ();
|
public signal void reloading_css ();
|
||||||
|
|
||||||
|
// Only set on swaync start due to some limitations of GtkLayerShell
|
||||||
|
[DBus (visible = false)]
|
||||||
|
public bool use_layer_shell { get; private set; }
|
||||||
|
|
||||||
public SwayncDaemon () {
|
public SwayncDaemon () {
|
||||||
// Init noti_daemon
|
// Init noti_daemon
|
||||||
this.noti_daemon = new NotiDaemon (this);
|
this.noti_daemon = new NotiDaemon (this);
|
||||||
|
this.use_layer_shell = ConfigModel.instance.layer_shell;
|
||||||
Bus.own_name (BusType.SESSION, "org.freedesktop.Notifications",
|
Bus.own_name (BusType.SESSION, "org.freedesktop.Notifications",
|
||||||
BusNameOwnerFlags.NONE,
|
BusNameOwnerFlags.NONE,
|
||||||
on_noti_bus_aquired,
|
on_noti_bus_aquired,
|
||||||
@@ -122,6 +127,7 @@ namespace SwayNotificationCenter {
|
|||||||
|
|
||||||
[DBus (visible = false)]
|
[DBus (visible = false)]
|
||||||
public void show_blank_windows (Gdk.Monitor ? monitor) {
|
public void show_blank_windows (Gdk.Monitor ? monitor) {
|
||||||
|
if (!use_layer_shell) return;
|
||||||
foreach (unowned BlankWindow win in blank_windows.data) {
|
foreach (unowned BlankWindow win in blank_windows.data) {
|
||||||
if (win.monitor != monitor) win.show ();
|
if (win.monitor != monitor) win.show ();
|
||||||
}
|
}
|
||||||
@@ -129,6 +135,7 @@ namespace SwayNotificationCenter {
|
|||||||
|
|
||||||
[DBus (visible = false)]
|
[DBus (visible = false)]
|
||||||
public void hide_blank_windows () {
|
public void hide_blank_windows () {
|
||||||
|
if (!use_layer_shell) return;
|
||||||
foreach (unowned BlankWindow win in blank_windows.data) {
|
foreach (unowned BlankWindow win in blank_windows.data) {
|
||||||
win.hide ();
|
win.hide ();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user