Remove colors field from xctx
The xctx color field is a full duplicate of the settings logic. Only logic included in xctx color fields, are the frame colors, which fall back to the global frame setting. So, this required to handle it directly in settings.c
This commit is contained in:
parent
3e205ff159
commit
7e81506226
@ -22,7 +22,6 @@
|
|||||||
#include "rules.h"
|
#include "rules.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "x11/x.h"
|
|
||||||
|
|
||||||
static void notification_extract_urls(struct notification *n);
|
static void notification_extract_urls(struct notification *n);
|
||||||
static void notification_format_message(struct notification *n);
|
static void notification_format_message(struct notification *n);
|
||||||
@ -348,12 +347,26 @@ void notification_init(struct notification *n)
|
|||||||
n->icon = g_strdup(settings.icons[n->urgency]);
|
n->icon = g_strdup(settings.icons[n->urgency]);
|
||||||
|
|
||||||
/* Color hints */
|
/* Color hints */
|
||||||
|
struct notification_colors defcolors;
|
||||||
|
switch (n->urgency) {
|
||||||
|
case URG_LOW:
|
||||||
|
defcolors = settings.colors_low;
|
||||||
|
break;
|
||||||
|
case URG_NORM:
|
||||||
|
defcolors = settings.colors_norm;
|
||||||
|
break;
|
||||||
|
case URG_CRIT:
|
||||||
|
defcolors = settings.colors_crit;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_error("Unhandled urgency type: %d", n->urgency);
|
||||||
|
}
|
||||||
if (!n->colors.fg)
|
if (!n->colors.fg)
|
||||||
n->colors.fg = g_strdup(xctx.colors[ColFG][n->urgency]);
|
n->colors.fg = g_strdup(defcolors.fg);
|
||||||
if (!n->colors.bg)
|
if (!n->colors.bg)
|
||||||
n->colors.bg = g_strdup(xctx.colors[ColBG][n->urgency]);
|
n->colors.bg = g_strdup(defcolors.bg);
|
||||||
if (!n->colors.frame)
|
if (!n->colors.frame)
|
||||||
n->colors.frame = g_strdup(xctx.colors[ColFrame][n->urgency]);
|
n->colors.frame = g_strdup(defcolors.frame);
|
||||||
|
|
||||||
/* Sanitize misc hints */
|
/* Sanitize misc hints */
|
||||||
if (n->progress < 0)
|
if (n->progress < 0)
|
||||||
|
@ -635,7 +635,7 @@ void load_settings(char *cmdline_config_path)
|
|||||||
|
|
||||||
settings.colors_low.frame = option_get_string(
|
settings.colors_low.frame = option_get_string(
|
||||||
"urgency_low",
|
"urgency_low",
|
||||||
"frame_color", "-lfr", NULL,
|
"frame_color", "-lfr", settings.frame_color ? settings.frame_color : defaults.colors_low.frame,
|
||||||
"Frame color for notifications with low urgency"
|
"Frame color for notifications with low urgency"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -665,7 +665,7 @@ void load_settings(char *cmdline_config_path)
|
|||||||
|
|
||||||
settings.colors_norm.frame = option_get_string(
|
settings.colors_norm.frame = option_get_string(
|
||||||
"urgency_normal",
|
"urgency_normal",
|
||||||
"frame_color", "-nfr", NULL,
|
"frame_color", "-nfr", settings.frame_color ? settings.frame_color : defaults.colors_norm.frame,
|
||||||
"Frame color for notifications with normal urgency"
|
"Frame color for notifications with normal urgency"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -695,7 +695,7 @@ void load_settings(char *cmdline_config_path)
|
|||||||
|
|
||||||
settings.colors_crit.frame = option_get_string(
|
settings.colors_crit.frame = option_get_string(
|
||||||
"urgency_critical",
|
"urgency_critical",
|
||||||
"frame_color", "-cfr", NULL,
|
"frame_color", "-cfr", settings.frame_color ? settings.frame_color : defaults.colors_crit.frame,
|
||||||
"Frame color for notifications with critical urgency"
|
"Frame color for notifications with critical urgency"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
21
src/x11/x.c
21
src/x11/x.c
@ -464,27 +464,6 @@ void x_setup(void)
|
|||||||
x_shortcut_grab(&settings.context_ks);
|
x_shortcut_grab(&settings.context_ks);
|
||||||
x_shortcut_ungrab(&settings.context_ks);
|
x_shortcut_ungrab(&settings.context_ks);
|
||||||
|
|
||||||
xctx.colors[ColFG][URG_LOW] = settings.colors_low.fg;
|
|
||||||
xctx.colors[ColFG][URG_NORM] = settings.colors_norm.fg;
|
|
||||||
xctx.colors[ColFG][URG_CRIT] = settings.colors_crit.fg;
|
|
||||||
|
|
||||||
xctx.colors[ColBG][URG_LOW] = settings.colors_low.bg;
|
|
||||||
xctx.colors[ColBG][URG_NORM] = settings.colors_norm.bg;
|
|
||||||
xctx.colors[ColBG][URG_CRIT] = settings.colors_crit.bg;
|
|
||||||
|
|
||||||
if (settings.colors_low.frame)
|
|
||||||
xctx.colors[ColFrame][URG_LOW] = settings.colors_low.frame;
|
|
||||||
else
|
|
||||||
xctx.colors[ColFrame][URG_LOW] = settings.frame_color;
|
|
||||||
if (settings.colors_norm.frame)
|
|
||||||
xctx.colors[ColFrame][URG_NORM] = settings.colors_norm.frame;
|
|
||||||
else
|
|
||||||
xctx.colors[ColFrame][URG_NORM] = settings.frame_color;
|
|
||||||
if (settings.colors_crit.frame)
|
|
||||||
xctx.colors[ColFrame][URG_CRIT] = settings.colors_crit.frame;
|
|
||||||
else
|
|
||||||
xctx.colors[ColFrame][URG_CRIT] = settings.frame_color;
|
|
||||||
|
|
||||||
xctx.screensaver_info = XScreenSaverAllocInfo();
|
xctx.screensaver_info = XScreenSaverAllocInfo();
|
||||||
|
|
||||||
init_screens();
|
init_screens();
|
||||||
|
@ -37,7 +37,6 @@ struct dimensions {
|
|||||||
|
|
||||||
struct x_context {
|
struct x_context {
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
const char *colors[3][3];
|
|
||||||
XScreenSaverInfo *screensaver_info;
|
XScreenSaverInfo *screensaver_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user