diff --git a/config.c b/config.c index 1a37f50..2372f45 100644 --- a/config.c +++ b/config.c @@ -644,6 +644,8 @@ static bool apply_style_option(struct mako_style *style, const char *name, binding.action = MAKO_BINDING_NONE; } else if (strcmp(value, "dismiss") == 0) { binding.action = MAKO_BINDING_DISMISS; + } else if (strcmp(value, "dismiss --no-history") == 0) { + binding.action = MAKO_BINDING_DISMISS_NO_HISTORY; } else if (strcmp(value, "dismiss-all") == 0) { binding.action = MAKO_BINDING_DISMISS_ALL; } else if (strcmp(value, "dismiss-group") == 0) { diff --git a/dbus/mako.c b/dbus/mako.c index 6f091b5..b2d1491 100644 --- a/dbus/mako.c +++ b/dbus/mako.c @@ -58,7 +58,7 @@ static int handle_dismiss_last_notification(sd_bus_message *msg, void *data, struct mako_notification *notif = wl_container_of(state->notifications.next, notif, link); - close_notification(notif, MAKO_NOTIFICATION_CLOSE_DISMISSED); + close_notification(notif, MAKO_NOTIFICATION_CLOSE_DISMISSED, true); set_dirty(notif->surface); done: @@ -82,7 +82,7 @@ static int handle_dismiss_notification(sd_bus_message *msg, void *data, if (dismiss_group) { close_group_notifications(notif, MAKO_NOTIFICATION_CLOSE_DISMISSED); } else { - close_notification(notif, MAKO_NOTIFICATION_CLOSE_DISMISSED); + close_notification(notif, MAKO_NOTIFICATION_CLOSE_DISMISSED, true); } set_dirty(notif->surface); break; diff --git a/dbus/xdg.c b/dbus/xdg.c index f183110..b772f57 100644 --- a/dbus/xdg.c +++ b/dbus/xdg.c @@ -87,7 +87,7 @@ static void handle_notification_timer(void *data) { struct mako_surface *surface = notif->surface; notif->timer = NULL; - close_notification(notif, MAKO_NOTIFICATION_CLOSE_EXPIRED); + close_notification(notif, MAKO_NOTIFICATION_CLOSE_EXPIRED, true); set_dirty(surface); } @@ -449,7 +449,7 @@ static int handle_close_notification(sd_bus_message *msg, void *data, struct mako_notification *notif = get_notification(state, id); if (notif) { struct mako_surface *surface = notif->surface; - close_notification(notif, MAKO_NOTIFICATION_CLOSE_REQUEST); + close_notification(notif, MAKO_NOTIFICATION_CLOSE_REQUEST, true); set_dirty(surface); } diff --git a/include/config.h b/include/config.h index d099e3f..013923a 100644 --- a/include/config.h +++ b/include/config.h @@ -10,6 +10,7 @@ enum mako_binding_action { MAKO_BINDING_NONE, MAKO_BINDING_DISMISS, + MAKO_BINDING_DISMISS_NO_HISTORY, MAKO_BINDING_DISMISS_GROUP, MAKO_BINDING_DISMISS_ALL, MAKO_BINDING_INVOKE_ACTION, diff --git a/include/notification.h b/include/notification.h index 43e4ff4..9a395ba 100644 --- a/include/notification.h +++ b/include/notification.h @@ -85,7 +85,8 @@ struct mako_notification *create_notification(struct mako_state *state); void destroy_notification(struct mako_notification *notif); void close_notification(struct mako_notification *notif, - enum mako_notification_close_reason reason); + enum mako_notification_close_reason reason, + bool add_to_history); void close_group_notifications(struct mako_notification *notif, enum mako_notification_close_reason reason); void close_all_notifications(struct mako_state *state, diff --git a/mako.5.scd b/mako.5.scd index 6938b8d..557bc16 100644 --- a/mako.5.scd +++ b/mako.5.scd @@ -65,8 +65,9 @@ Supported actions: *none* Do nothing. -*dismiss* - Dismiss the current notification. +*dismiss [--no-history]* + Dismiss the current notification. If *--no-history* is passed, the notification + won't be added to history. *dismiss-all* Dismiss all notifications. diff --git a/notification.c b/notification.c index a9f7d7c..b82279f 100644 --- a/notification.c +++ b/notification.c @@ -108,7 +108,8 @@ void destroy_notification(struct mako_notification *notif) { } void close_notification(struct mako_notification *notif, - enum mako_notification_close_reason reason) { + enum mako_notification_close_reason reason, + bool add_to_history) { notify_notification_closed(notif, reason); wl_list_remove(¬if->link); // Remove so regrouping works... wl_list_init(¬if->link); // ...but destroy will remove again. @@ -129,12 +130,16 @@ void close_notification(struct mako_notification *notif, destroy_timer(notif->timer); notif->timer = NULL; - wl_list_insert(¬if->state->history, ¬if->link); - while (wl_list_length(¬if->state->history) > - notif->state->config.max_history) { - struct mako_notification *n = - wl_container_of(notif->state->history.prev, n, link); - destroy_notification(n); + if (add_to_history) { + wl_list_insert(¬if->state->history, ¬if->link); + while (wl_list_length(¬if->state->history) > + notif->state->config.max_history) { + struct mako_notification *n = + wl_container_of(notif->state->history.prev, n, link); + destroy_notification(n); + } + } else { + destroy_notification(notif); } } @@ -168,7 +173,7 @@ void close_group_notifications(struct mako_notification *top_notif, if (top_notif->style.group_criteria_spec.none) { // No grouping, just close the notification - close_notification(top_notif, reason); + close_notification(top_notif, reason, true); return; } @@ -178,7 +183,7 @@ void close_group_notifications(struct mako_notification *top_notif, struct mako_notification *notif, *tmp; wl_list_for_each_safe(notif, tmp, &state->notifications, link) { if (match_criteria(notif_criteria, notif)) { - close_notification(notif, reason); + close_notification(notif, reason, true); } } @@ -189,7 +194,7 @@ void close_all_notifications(struct mako_state *state, enum mako_notification_close_reason reason) { struct mako_notification *notif, *tmp; wl_list_for_each_safe(notif, tmp, &state->notifications, link) { - close_notification(notif, reason); + close_notification(notif, reason, true); } } @@ -365,7 +370,7 @@ static void try_invoke_action(struct mako_notification *notif, break; } } - close_notification(notif, MAKO_NOTIFICATION_CLOSE_DISMISSED); + close_notification(notif, MAKO_NOTIFICATION_CLOSE_DISMISSED, true); } void notification_execute_binding(struct mako_notification *notif, @@ -375,7 +380,10 @@ void notification_execute_binding(struct mako_notification *notif, case MAKO_BINDING_NONE: break; case MAKO_BINDING_DISMISS: - close_notification(notif, MAKO_NOTIFICATION_CLOSE_DISMISSED); + close_notification(notif, MAKO_NOTIFICATION_CLOSE_DISMISSED, true); + break; + case MAKO_BINDING_DISMISS_NO_HISTORY: + close_notification(notif, MAKO_NOTIFICATION_CLOSE_DISMISSED, false); break; case MAKO_BINDING_DISMISS_GROUP: close_group_notifications(notif, MAKO_NOTIFICATION_CLOSE_DISMISSED);