Add options to specify mouse event
This commit is contained in:
parent
6d0e20e40b
commit
fbcc26b5e1
11
dunstrc
11
dunstrc
@ -258,6 +258,17 @@
|
||||
# Context menu.
|
||||
context = ctrl+shift+period
|
||||
|
||||
# Defines action of mouse event
|
||||
# Possible values are:
|
||||
# * do_action: If the notification has exactly one action, or one is marked as default,
|
||||
# invoke it. If there are multiple and no default, open the context menu.
|
||||
# * close_current: Close current notification.
|
||||
# * push_all: Push all waiting and displayed notifications to history.
|
||||
[mouse]
|
||||
left_click = close_current
|
||||
middle_click = do_action
|
||||
right_click = push_all
|
||||
|
||||
[urgency_low]
|
||||
# IMPORTANT: colors have to be defined in quotation marks.
|
||||
# Otherwise the "#" and following would be interpreted as a comment.
|
||||
|
@ -516,6 +516,70 @@ void load_settings(char *cmdline_config_path)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
char *c = option_get_string(
|
||||
"mouse",
|
||||
"left_click", "-left_click", "close_current",
|
||||
"Action of Left click event"
|
||||
);
|
||||
|
||||
if (strlen(c) > 0) {
|
||||
if (strcmp(c, "do_action") == 0)
|
||||
settings.left_click = do_action;
|
||||
else if (strcmp(c, "close_current") == 0)
|
||||
settings.left_click = close_current;
|
||||
else if (strcmp(c, "push_all") == 0)
|
||||
settings.left_click = push_all;
|
||||
else {
|
||||
LOG_W("Unknown left_click position: '%s'", c);
|
||||
}
|
||||
}
|
||||
g_free(c);
|
||||
}
|
||||
|
||||
{
|
||||
char *c = option_get_string(
|
||||
"mouse",
|
||||
"middle_click", "-middel_click", "do_action",
|
||||
"Action of middle click event"
|
||||
);
|
||||
|
||||
if (strlen(c) > 0) {
|
||||
if (strcmp(c, "do_action") == 0)
|
||||
settings.middle_click = do_action;
|
||||
else if (strcmp(c, "close_current") == 0)
|
||||
settings.middle_click = close_current;
|
||||
else if (strcmp(c, "push_all") == 0)
|
||||
settings.middle_click = push_all;
|
||||
else {
|
||||
LOG_W("Unknown middle_click position: '%s'", c);
|
||||
}
|
||||
}
|
||||
g_free(c);
|
||||
}
|
||||
|
||||
{
|
||||
char *c = option_get_string(
|
||||
"mouse",
|
||||
"right_click", "-right_click", "push_all",
|
||||
"Action of right click event"
|
||||
);
|
||||
|
||||
if (strlen(c) > 0) {
|
||||
if (strcmp(c, "do_action") == 0)
|
||||
settings.right_click = do_action;
|
||||
else if (strcmp(c, "close_current") == 0)
|
||||
settings.right_click = close_current;
|
||||
else if (strcmp(c, "push_all") == 0)
|
||||
settings.right_click = push_all;
|
||||
else {
|
||||
LOG_W("Unknown right_click position: '%s'", c);
|
||||
}
|
||||
}
|
||||
g_free(c);
|
||||
}
|
||||
|
||||
settings.lowbgcolor = option_get_string(
|
||||
"urgency_low",
|
||||
"background", "-lb", defaults.lowbgcolor,
|
||||
|
@ -12,6 +12,7 @@ enum icon_position_t { icons_left, icons_right, icons_off };
|
||||
enum separator_color { SEP_FOREGROUND, SEP_AUTO, SEP_FRAME, SEP_CUSTOM };
|
||||
enum follow_mode { FOLLOW_NONE, FOLLOW_MOUSE, FOLLOW_KEYBOARD };
|
||||
enum markup_mode { MARKUP_NULL, MARKUP_NO, MARKUP_STRIP, MARKUP_FULL };
|
||||
enum mouse_action { do_action, close_current, push_all };
|
||||
|
||||
struct geometry {
|
||||
int x;
|
||||
@ -85,6 +86,9 @@ typedef struct _settings {
|
||||
keyboard_shortcut context_ks;
|
||||
bool force_xinerama;
|
||||
int corner_radius;
|
||||
enum mouse_action left_click;
|
||||
enum mouse_action middle_click;
|
||||
enum mouse_action right_click;
|
||||
} settings_t;
|
||||
|
||||
extern settings_t settings;
|
||||
|
20
src/x11/x.c
20
src/x11/x.c
@ -386,13 +386,27 @@ bool x_is_idle(void)
|
||||
*/
|
||||
static void x_handle_click(XEvent ev)
|
||||
{
|
||||
if (ev.xbutton.button == Button3) {
|
||||
enum mouse_action act;
|
||||
|
||||
switch (ev.xbutton.button) {
|
||||
case Button1:
|
||||
act = settings.left_click;
|
||||
break;
|
||||
case Button2:
|
||||
act = settings.middle_click;
|
||||
break;
|
||||
case Button3:
|
||||
act = settings.right_click;
|
||||
break;
|
||||
}
|
||||
|
||||
if (act == push_all) {
|
||||
queues_history_push_all();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev.xbutton.button == Button1 || ev.xbutton.button == Button2) {
|
||||
if (act == do_action || act == close_current) {
|
||||
int y = settings.separator_height;
|
||||
notification *n = NULL;
|
||||
int first = true;
|
||||
@ -408,7 +422,7 @@ static void x_handle_click(XEvent ev)
|
||||
}
|
||||
|
||||
if (n) {
|
||||
if (ev.xbutton.button == Button1)
|
||||
if (act == close_current)
|
||||
queues_notification_close(n, REASON_USER);
|
||||
else
|
||||
notification_do_action(n);
|
||||
|
Loading…
x
Reference in New Issue
Block a user