Merge pull request #530 from zijung/feature-mouse_event
Add options to specify mouse event
This commit is contained in:
commit
c0eef2da2f
6
config.h
6
config.h
@ -102,6 +102,12 @@ settings_t defaults = {
|
|||||||
.code = 0,.sym = NoSymbol,.is_valid = false
|
.code = 0,.sym = NoSymbol,.is_valid = false
|
||||||
}, /* ignore this */
|
}, /* ignore this */
|
||||||
|
|
||||||
|
.mouse_left_click = MOUSE_CLOSE_CURRENT,
|
||||||
|
|
||||||
|
.mouse_middle_click = MOUSE_DO_ACTION,
|
||||||
|
|
||||||
|
.mouse_right_click = MOUSE_CLOSE_ALL,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
rule_t default_rules[] = {
|
rule_t default_rules[] = {
|
||||||
|
@ -472,6 +472,30 @@ single notification.
|
|||||||
To avoid the corners clipping the icon or text the corner radius will be
|
To avoid the corners clipping the icon or text the corner radius will be
|
||||||
automatically lowered to half of the notification height if it exceeds it.
|
automatically lowered to half of the notification height if it exceeds it.
|
||||||
|
|
||||||
|
=item B<mouse_left/middle/right_click> (values: [none/do_action/close_current/close_all])
|
||||||
|
|
||||||
|
Defines action of mouse click.
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item B<none>
|
||||||
|
|
||||||
|
Don't do anything.
|
||||||
|
|
||||||
|
=item B<do_action> (default for mouse_middle_click)
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
=item B<close_current> (default for mouse_left_click)
|
||||||
|
|
||||||
|
Close current notification.
|
||||||
|
|
||||||
|
=item B<close_all> (default for mouse_right_click)
|
||||||
|
|
||||||
|
Close all notifications.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head2 Shortcut section
|
=head2 Shortcut section
|
||||||
|
13
dunstrc
13
dunstrc
@ -226,6 +226,19 @@
|
|||||||
# layout changes.
|
# layout changes.
|
||||||
force_xinerama = false
|
force_xinerama = false
|
||||||
|
|
||||||
|
### mouse
|
||||||
|
|
||||||
|
# Defines action of mouse event
|
||||||
|
# Possible values are:
|
||||||
|
# * none: Don't do anything.
|
||||||
|
# * 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.
|
||||||
|
# * close_all: Close all notifications.
|
||||||
|
mouse_left_click = close_current
|
||||||
|
mouse_middle_click = do_action
|
||||||
|
mouse_right_click = close_all
|
||||||
|
|
||||||
# Experimental features that may or may not work correctly. Do not expect them
|
# Experimental features that may or may not work correctly. Do not expect them
|
||||||
# to have a consistent behaviour across releases.
|
# to have a consistent behaviour across releases.
|
||||||
[experimental]
|
[experimental]
|
||||||
|
@ -49,6 +49,23 @@ static enum markup_mode parse_markup_mode(const char *mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum mouse_action parse_mouse_action(const char *action)
|
||||||
|
{
|
||||||
|
if (strcmp(action, "none") == 0)
|
||||||
|
return MOUSE_NONE;
|
||||||
|
else if (strcmp(action, "do_action") == 0)
|
||||||
|
return MOUSE_DO_ACTION;
|
||||||
|
else if (strcmp(action, "close_current") == 0)
|
||||||
|
return MOUSE_CLOSE_CURRENT;
|
||||||
|
else if (strcmp(action, "close_all") == 0)
|
||||||
|
return MOUSE_CLOSE_ALL;
|
||||||
|
else {
|
||||||
|
LOG_W("Unknown mouse action: '%s'", action);
|
||||||
|
return MOUSE_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static enum urgency ini_get_urgency(const char *section, const char *key, const int def)
|
static enum urgency ini_get_urgency(const char *section, const char *key, const int def)
|
||||||
{
|
{
|
||||||
int ret = def;
|
int ret = def;
|
||||||
@ -516,6 +533,55 @@ void load_settings(char *cmdline_config_path)
|
|||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char *c = option_get_string(
|
||||||
|
"global",
|
||||||
|
"mouse_left_click", "-left_click", NULL,
|
||||||
|
"Action of Left click event"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (c) {
|
||||||
|
settings.mouse_left_click = parse_mouse_action(c);
|
||||||
|
} else {
|
||||||
|
settings.mouse_left_click = defaults.mouse_left_click;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char *c = option_get_string(
|
||||||
|
"global",
|
||||||
|
"mouse_middle_click", "-mouse_middle_click", NULL,
|
||||||
|
"Action of middle click event"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (c) {
|
||||||
|
settings.mouse_middle_click = parse_mouse_action(c);
|
||||||
|
} else {
|
||||||
|
settings.mouse_middle_click = defaults.mouse_middle_click;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char *c = option_get_string(
|
||||||
|
"global",
|
||||||
|
"mouse_right_click", "-mouse_right_click", NULL,
|
||||||
|
"Action of right click event"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (c) {
|
||||||
|
settings.mouse_right_click = parse_mouse_action(c);
|
||||||
|
} else {
|
||||||
|
settings.mouse_right_click = defaults.mouse_right_click;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(c);
|
||||||
|
}
|
||||||
|
|
||||||
settings.lowbgcolor = option_get_string(
|
settings.lowbgcolor = option_get_string(
|
||||||
"urgency_low",
|
"urgency_low",
|
||||||
"background", "-lb", defaults.lowbgcolor,
|
"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 separator_color { SEP_FOREGROUND, SEP_AUTO, SEP_FRAME, SEP_CUSTOM };
|
||||||
enum follow_mode { FOLLOW_NONE, FOLLOW_MOUSE, FOLLOW_KEYBOARD };
|
enum follow_mode { FOLLOW_NONE, FOLLOW_MOUSE, FOLLOW_KEYBOARD };
|
||||||
enum markup_mode { MARKUP_NULL, MARKUP_NO, MARKUP_STRIP, MARKUP_FULL };
|
enum markup_mode { MARKUP_NULL, MARKUP_NO, MARKUP_STRIP, MARKUP_FULL };
|
||||||
|
enum mouse_action { MOUSE_NONE, MOUSE_DO_ACTION, MOUSE_CLOSE_CURRENT, MOUSE_CLOSE_ALL };
|
||||||
|
|
||||||
struct geometry {
|
struct geometry {
|
||||||
int x;
|
int x;
|
||||||
@ -85,6 +86,9 @@ typedef struct _settings {
|
|||||||
keyboard_shortcut context_ks;
|
keyboard_shortcut context_ks;
|
||||||
bool force_xinerama;
|
bool force_xinerama;
|
||||||
int corner_radius;
|
int corner_radius;
|
||||||
|
enum mouse_action mouse_left_click;
|
||||||
|
enum mouse_action mouse_middle_click;
|
||||||
|
enum mouse_action mouse_right_click;
|
||||||
} settings_t;
|
} settings_t;
|
||||||
|
|
||||||
extern settings_t settings;
|
extern settings_t settings;
|
||||||
|
23
src/x11/x.c
23
src/x11/x.c
@ -386,13 +386,30 @@ bool x_is_idle(void)
|
|||||||
*/
|
*/
|
||||||
static void x_handle_click(XEvent ev)
|
static void x_handle_click(XEvent ev)
|
||||||
{
|
{
|
||||||
if (ev.xbutton.button == Button3) {
|
enum mouse_action act;
|
||||||
|
|
||||||
|
switch (ev.xbutton.button) {
|
||||||
|
case Button1:
|
||||||
|
act = settings.mouse_left_click;
|
||||||
|
break;
|
||||||
|
case Button2:
|
||||||
|
act = settings.mouse_middle_click;
|
||||||
|
break;
|
||||||
|
case Button3:
|
||||||
|
act = settings.mouse_right_click;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOG_W("Unsupported mouse button: '%d'", ev.xbutton.button);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (act == MOUSE_CLOSE_ALL) {
|
||||||
queues_history_push_all();
|
queues_history_push_all();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ev.xbutton.button == Button1 || ev.xbutton.button == Button2) {
|
if (act == MOUSE_DO_ACTION || act == MOUSE_CLOSE_CURRENT) {
|
||||||
int y = settings.separator_height;
|
int y = settings.separator_height;
|
||||||
notification *n = NULL;
|
notification *n = NULL;
|
||||||
int first = true;
|
int first = true;
|
||||||
@ -408,7 +425,7 @@ static void x_handle_click(XEvent ev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (n) {
|
if (n) {
|
||||||
if (ev.xbutton.button == Button1)
|
if (act == MOUSE_CLOSE_CURRENT)
|
||||||
queues_notification_close(n, REASON_USER);
|
queues_notification_close(n, REASON_USER);
|
||||||
else
|
else
|
||||||
notification_do_action(n);
|
notification_do_action(n);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user