Added setting for changing layer.
This commit is contained in:
parent
deabe2bacf
commit
ac6093a577
2
config.h
2
config.h
@ -122,6 +122,8 @@ struct settings defaults = {
|
||||
.progress_bar_frame_width = 1,
|
||||
|
||||
.progress_bar = true,
|
||||
|
||||
.layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP,
|
||||
};
|
||||
|
||||
struct rule default_rules[] = {
|
||||
|
@ -264,7 +264,24 @@ Set to 0 to disable.
|
||||
A client can mark a notification as transient to bypass this setting and timeout
|
||||
anyway. Use a rule with 'set_transient = no' to disable this behavior.
|
||||
|
||||
Note: this doesn't work on xwayland yet.
|
||||
Note: this doesn't work on xwayland.
|
||||
|
||||
=item B<layer> (Wayland only)
|
||||
|
||||
One of bottom, top or overlay.
|
||||
|
||||
Place dunst notifications on the selected layer. Using overlay
|
||||
will cause notifications to be displayed above fullscreen windows, though
|
||||
this may also occur at top depending on your compositor.
|
||||
|
||||
The bottom layer is below all windows and above the background.
|
||||
|
||||
Default: top
|
||||
|
||||
=item B<use_xwayland> (values: [true/false], default: false) (Wayland only)
|
||||
|
||||
Force the use of X11 output, even on a wayland compositor. This setting
|
||||
has no effect when not using a Wayland compositor.
|
||||
|
||||
=item B<font> (default: "Monospace 8")
|
||||
|
||||
@ -497,7 +514,7 @@ Do not display log messages, which have lower precedence than specified
|
||||
verbosity. This won't affect printing notifications on the terminal. Use
|
||||
the '-print' option for this.
|
||||
|
||||
=item B<force_xinerama> (values: [true/false], default: false)
|
||||
=item B<force_xinerama> (values: [true/false], default: false) (X11 only)
|
||||
|
||||
Use the Xinerama extension instead of RandR for multi-monitor support. This
|
||||
setting is provided for compatibility with older nVidia drivers that do not
|
||||
@ -774,7 +791,7 @@ Equivalent to the C<format> setting.
|
||||
|
||||
The frame color color of the notification. See COLORS for possible values.
|
||||
|
||||
=item C<fullscreen>
|
||||
=item C<fullscreen> (X11 only)
|
||||
|
||||
One of show, delay, or pushback.
|
||||
|
||||
@ -789,6 +806,10 @@ Or pushback which is equivalent to delay with the difference that already
|
||||
existing notifications are paused and hidden until the focus to the fullscreen
|
||||
window is lost.
|
||||
|
||||
See B<layer> to change fullscreen behavior in Wayland
|
||||
|
||||
Default: show
|
||||
|
||||
=item C<new_icon>
|
||||
|
||||
Updates the icon of the notification, it should be a path to a valid image.
|
||||
|
@ -45,7 +45,7 @@ void input_handle_click(unsigned int button, bool button_down, int mouse_x, int
|
||||
iter = iter->next) {
|
||||
n = iter->data;
|
||||
if (mouse_y > y && mouse_y < y + n->displayed_height) {
|
||||
LOG_W("Mouse X: %i", mouse_x);
|
||||
/* LOG_W("Mouse X: %i", mouse_x); */
|
||||
/* LOG_W("X < width: ", mouse_x < ); */
|
||||
/* n = NULL; */
|
||||
break;
|
||||
|
@ -189,6 +189,18 @@ bool string_parse_urgency(const char *s, enum urgency *ret)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool string_parse_layer(const char *s, enum zwlr_layer_shell_v1_layer *ret)
|
||||
{
|
||||
ASSERT_OR_RET(STR_FULL(s), false);
|
||||
ASSERT_OR_RET(ret, false);
|
||||
|
||||
STRING_PARSE_RET("bottom", ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM);
|
||||
STRING_PARSE_RET("top", ZWLR_LAYER_SHELL_V1_LAYER_TOP);
|
||||
STRING_PARSE_RET("overlay", ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
struct section *new_section(const char *name)
|
||||
{
|
||||
for (int i = 0; i < section_count; i++) {
|
||||
|
@ -20,6 +20,7 @@ bool string_parse_mouse_action(const char *s, enum mouse_action *ret);
|
||||
bool string_parse_mouse_action_list(char **s, enum mouse_action **ret);
|
||||
bool string_parse_sepcolor(const char *s, struct separator_color_data *ret);
|
||||
bool string_parse_urgency(const char *s, enum urgency *ret);
|
||||
bool string_parse_layer(const char *s, enum zwlr_layer_shell_v1_layer *ret);
|
||||
|
||||
int load_ini_file(FILE *);
|
||||
char *ini_get_path(const char *section, const char *key, const char *def);
|
||||
|
@ -486,6 +486,22 @@ void load_settings(char *cmdline_config_path)
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
char *c = option_get_string(
|
||||
"global",
|
||||
"layer", "-layer", "top",
|
||||
"Select the layer where notifications should be placed"
|
||||
);
|
||||
|
||||
if (!string_parse_layer(c, &settings.layer)) {
|
||||
if (c)
|
||||
LOG_W("Unknown layer: '%s'", c);
|
||||
settings.layer = defaults.layer;
|
||||
}
|
||||
g_free(c);
|
||||
|
||||
}
|
||||
|
||||
settings.min_icon_size = option_get_int(
|
||||
"global",
|
||||
"min_icon_size", "-min_icon_size", defaults.min_icon_size,
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "wayland/protocols/wlr-layer-shell-unstable-v1-client-header.h"
|
||||
|
||||
#include "markup.h"
|
||||
#include "notification.h"
|
||||
#include "x11/x.h"
|
||||
@ -97,6 +99,7 @@ struct settings {
|
||||
int progress_bar_max_width;
|
||||
int progress_bar_frame_width;
|
||||
bool progress_bar;
|
||||
enum zwlr_layer_shell_v1_layer layer;
|
||||
};
|
||||
|
||||
extern struct settings settings;
|
||||
|
@ -153,7 +153,7 @@ static const struct wl_output_listener output_listener = {
|
||||
static void create_output( struct wl_output *wl_output, uint32_t global_name) {
|
||||
struct dunst_output *output = g_malloc0(sizeof(struct dunst_output));
|
||||
if (output == NULL) {
|
||||
fprintf(stderr, "allocation failed\n");
|
||||
LOG_E("allocation failed");
|
||||
return;
|
||||
}
|
||||
static int number = 0;
|
||||
@ -255,7 +255,7 @@ static void send_frame();
|
||||
static void layer_surface_handle_configure(void *data,
|
||||
struct zwlr_layer_surface_v1 *surface,
|
||||
uint32_t serial, uint32_t width, uint32_t height) {
|
||||
LOG_W("Surface handle configure %ix%i", width, height);
|
||||
LOG_D("Surface handle configure %ix%i", width, height);
|
||||
ctx.configured = true;
|
||||
ctx.width = width;
|
||||
ctx.height = height;
|
||||
@ -268,7 +268,7 @@ static void layer_surface_handle_configure(void *data,
|
||||
|
||||
static void layer_surface_handle_closed(void *data,
|
||||
struct zwlr_layer_surface_v1 *surface) {
|
||||
LOG_W("Destroying layer");
|
||||
LOG_I("Destroying layer");
|
||||
zwlr_layer_surface_v1_destroy(ctx.layer_surface);
|
||||
ctx.layer_surface = NULL;
|
||||
|
||||
@ -313,6 +313,9 @@ static const struct org_kde_kwin_idle_timeout_listener idle_timeout_listener = {
|
||||
};
|
||||
|
||||
static void add_seat_to_idle_handler(struct wl_seat *seat) {
|
||||
if (!ctx.idle_handler){
|
||||
return;
|
||||
}
|
||||
uint32_t timeout_ms = settings.idle_threshold/1000;
|
||||
struct org_kde_kwin_idle_timeout *idle_timeout = org_kde_kwin_idle_get_idle_timeout(ctx.idle_handler, ctx.seat, timeout_ms);
|
||||
org_kde_kwin_idle_timeout_add_listener(idle_timeout, &idle_timeout_listener, 0);
|
||||
@ -372,7 +375,7 @@ bool init_wayland() {
|
||||
ctx.display = wl_display_connect(NULL);
|
||||
|
||||
if (ctx.display == NULL) {
|
||||
fprintf(stderr, "failed to create display\n");
|
||||
LOG_E("failed to create display");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -381,15 +384,15 @@ bool init_wayland() {
|
||||
wl_display_roundtrip(ctx.display);
|
||||
|
||||
if (ctx.compositor == NULL) {
|
||||
fprintf(stderr, "compositor doesn't support wl_compositor\n");
|
||||
LOG_E("compositor doesn't support wl_compositor");
|
||||
return false;
|
||||
}
|
||||
if (ctx.shm == NULL) {
|
||||
fprintf(stderr, "compositor doesn't support wl_shm\n");
|
||||
LOG_E("compositor doesn't support wl_shm");
|
||||
return false;
|
||||
}
|
||||
if (ctx.layer_shell == NULL) {
|
||||
fprintf(stderr, "compositor doesn't support zwlr_layer_shell_v1\n");
|
||||
LOG_E("compositor doesn't support zwlr_layer_shell_v1");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -402,8 +405,8 @@ bool init_wayland() {
|
||||
}
|
||||
//if (ctx.xdg_output_manager == NULL &&
|
||||
// strcmp(ctx.config.output, "") != 0) {
|
||||
// fprintf(stderr, "warning: configured an output but compositor doesn't "
|
||||
// "support xdg-output-unstable-v1 version 2\n");
|
||||
// LOG_E("warning: configured an output but compositor doesn't "
|
||||
// "support xdg-output-unstable-v1 version 2");
|
||||
//}
|
||||
|
||||
return true;
|
||||
@ -501,9 +504,10 @@ static void send_frame() {
|
||||
ctx.surface = wl_compositor_create_surface(ctx.compositor);
|
||||
wl_surface_add_listener(ctx.surface, &surface_listener, NULL);
|
||||
|
||||
if (settings.frame_color)
|
||||
ctx.layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||
ctx.layer_shell, ctx.surface, wl_output,
|
||||
ZWLR_LAYER_SHELL_V1_LAYER_TOP, "notifications");
|
||||
settings.layer, "notifications");
|
||||
zwlr_layer_surface_v1_add_listener(ctx.layer_surface,
|
||||
&layer_surface_listener, NULL);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user