[PATCH mako] Add double click config option
Export this patch
From: Sofia/Nep <nepnep91@child.pizza>
---
config.c | 5 +++++
contrib/completions/bash/mako | 3 ++ -
contrib/completions/fish/mako.fish | 2 + -
contrib/completions/zsh/_mako | 1 +
doc/mako.5.scd | 3 +++
include/config.h | 2 ++
include/notification.h | 2 ++
main.c | 1 +
notification.c | 8 ++++++++
9 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/config.c b/config.c
index 70be717..6a8de65 100644
--- a/config.c
+++ b/config.c
@@ -56,6 +56,8 @@ void init_default_config(struct mako_config *config) {
config->max_history = 5;
config->sort_criteria = MAKO_SORT_CRITERIA_TIME;
config->sort_asc = 0;
+
+ config->double_click = false;
}
void finish_config(struct mako_config *config) {
@@ -529,6 +531,8 @@ static bool apply_config_option(struct mako_config *config, const char *name,
} else if (strcmp(name, "include") == 0) {
char *path = expand_config_path(value);
return path && load_config_file(config, path) == 0;
+ } else if (strcmp(name, "double-click") == 0) {
+ return parse_boolean(value, &config->double_click);
}
return false;
@@ -886,6 +890,7 @@ int parse_config_arguments(struct mako_config *config, int argc, char **argv) {
{"on-button-right", required_argument, 0, 0},
{"on-button-middle", required_argument, 0, 0},
{"on-touch", required_argument, 0, 0},
+ {"double-click", required_argument, 0, 0},
{0},
};
diff --git a/contrib/completions/bash/mako b/contrib/completions/bash/mako
index 60d8b70..6ef63b4 100644
--- a/contrib/completions/bash/mako
+++ b/contrib/completions/bash/mako
@@ -36,6 +36,7 @@ _mako()
'--output'
'--layer'
'--anchor'
+ '--double-click'
)
case $prev in
@@ -43,7 +44,7 @@ _mako()
COMPREPLY=($(compgen -f -- "$cur"))
return
;;
- --icons|--markup|--actions|--history|--ignore-timeout)
+ --icons|--markup|--actions|--history|--ignore-timeout|--double-click)
COMPREPLY=($(compgen -W "0 1" -- "$cur"))
return
;;
diff --git a/contrib/completions/fish/mako.fish b/contrib/completions/fish/mako.fish
index abf2625..4b2a77e 100644
--- a/contrib/completions/fish/mako.fish
+++ b/contrib/completions/fish/mako.fish
@@ -35,4 +35,4 @@ complete -c mako -l ignore-timeout -d 'Enable notification timeout or not' -xa "
complete -c mako -l output -d 'Show notifications on this output' -xa '(complete_outputs)'
complete -c mako -l layer -d 'Show notifications on this layer' -x
complete -c mako -l anchor -d 'Position on output to put notifications' -x
-
+ complete -c mako -l double-click -d 'Require two clicks to invoke the application action' -xa "1 0"
diff --git a/contrib/completions/zsh/_mako b/contrib/completions/zsh/_mako
index 401268f..b920f76 100644
--- a/contrib/completions/zsh/_mako
+++ b/contrib/completions/zsh/_mako
@@ -29,3 +29,4 @@ _arguments \
'--layer[Arrange notifications at this layer.]:layer:(background bottom top overlay)' \
'--anchor[Position on output to put notifications.]:position:(top-right bottom-right bottom-center bottom-left top-left top-center center-right center-left center)' \
'--sort[Sort incoming notifications by time and/or priority in ascending(+) or descending(-) order.]:sort pattern:'
+ '--double-click[Require two clicks to invoke the application action.]:Require double click:(0 1)'
diff --git a/doc/mako.5.scd b/doc/mako.5.scd
index 91378ba..a050202 100644
--- a/doc/mako.5.scd
+++ b/doc/mako.5.scd
@@ -305,6 +305,9 @@ Default when grouped: (%g) <b>%s</b>\\n%b
_bottom-left_, _center-right_, _center-left_ and _center_.
Default: top-right
+ *double-click*=_0|1_
+ Require two clicks to invoke the application action.
+ Default: 0
# CRITERIA
diff --git a/include/config.h b/include/config.h
index 013923a..0e9cfa8 100644
--- a/include/config.h
+++ b/include/config.h
@@ -109,6 +109,8 @@ struct mako_config {
int32_t max_history;
struct mako_style superstyle;
+
+ bool double_click;
};
#define DEFAULT_ACTION_KEY "default"
diff --git a/include/notification.h b/include/notification.h
index 9a395ba..e5e0159 100644
--- a/include/notification.h
+++ b/include/notification.h
@@ -48,6 +48,8 @@ struct mako_notification {
struct mako_hotspot hotspot;
struct mako_timer *timer;
+
+ bool clicked;
};
struct mako_action {
diff --git a/main.c b/main.c
index d235cef..aa9b9d3 100644
--- a/main.c
+++ b/main.c
@@ -53,6 +53,7 @@ static const char usage[] =
" --output <name> Show notifications on this output.\n"
" --layer <layer> Arrange notifications at this layer.\n"
" --anchor <position> Position on output to put notifications.\n"
+ " --double-click <0|1> Require two clicks to invoke the application action.\n"
"\n"
"Colors can be specified with the format #RRGGBB or #RRGGBBAA.\n";
diff --git a/notification.c b/notification.c
index 8c0c8a7..8ef12fd 100644
--- a/notification.c
+++ b/notification.c
@@ -66,6 +66,8 @@ void reset_notification(struct mako_notification *notif) {
destroy_icon(notif->icon);
notif->icon = NULL;
+
+ notif->clicked = false;
}
struct mako_notification *create_notification(struct mako_state *state) {
@@ -356,6 +358,12 @@ static const struct mako_binding *get_button_binding(struct mako_style *style,
static void try_invoke_action(struct mako_notification *notif,
const char *target_action,
const struct mako_binding_context *ctx) {
+ if (!notif->clicked && notif->state->config.double_click) {
+ notif->clicked = true;
+ return;
+ }
+ notif->clicked = false;
+
struct mako_action *action;
wl_list_for_each(action, ¬if->actions, link) {
if (strcmp(action->key, target_action) == 0) {
--
2.47.0
[PATCH mako 2/x] Resetting the clicked flag is unnecessary as the notification is closed at the end of the function, so do not
Export this patch
From: Sofia/Nep <nepnep91@child.pizza>
---
notification.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/notification.c b/notification.c
index 8ef12fd..6b67393 100644
--- a/notification.c
+++ b/notification.c
@@ -362,7 +362,6 @@ static void try_invoke_action(struct mako_notification *notif,
notif->clicked = true;
return;
}
- notif->clicked = false;
struct mako_action *action;
wl_list_for_each(action, ¬if->actions, link) {
--
2.47.0