这是indexloc提供的服务,不要输入任何密码
Skip to content

Add an on-closed event #578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ void finish_style(struct mako_style *style) {
finish_binding(&style->button_bindings.right);
finish_binding(&style->touch_binding);
finish_binding(&style->notify_binding);
finish_binding(&style->closed_binding);
free(style->icon_path);
free(style->font);
free(style->format);
Expand Down Expand Up @@ -400,6 +401,11 @@ bool apply_style(struct mako_style *target, const struct mako_style *style) {
target->spec.notify_binding = true;
}

if (style->spec.closed_binding) {
copy_binding(&target->closed_binding, &style->closed_binding);
target->spec.closed_binding = true;
}

return true;
}

Expand Down Expand Up @@ -719,6 +725,9 @@ static bool apply_style_option(struct mako_style *style, const char *name,
} else if (strcmp(name, "on-notify") == 0) {
copy_binding(&style->notify_binding, &binding);
style->spec.notify_binding = true;
} else if (strcmp(name, "on-closed") == 0) {
copy_binding(&style->closed_binding, &binding);
style->spec.closed_binding = true;
} else {
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions dbus/xdg.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ void notify_notification_closed(struct mako_notification *notif,

sd_bus_emit_signal(state->bus, service_path, service_interface,
"NotificationClosed", "uu", notif->id, reason);

notification_execute_binding(notif, &notif->style.closed_binding, NULL);
}

void notify_action_invoked(struct mako_action *action,
Expand Down
5 changes: 5 additions & 0 deletions doc/mako.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ Supported options:

Default: none

*on-closed*=_action_
Performs the action when the notification is closed.

Default: none

Supported actions:

*none*
Expand Down
4 changes: 2 additions & 2 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct mako_style_spec {
struct {
bool left, right, middle;
} button_bindings;
bool touch_binding, notify_binding;
bool touch_binding, notify_binding, closed_binding;
};


Expand Down Expand Up @@ -99,7 +99,7 @@ struct mako_style {
struct {
struct mako_binding left, right, middle;
} button_bindings;
struct mako_binding touch_binding, notify_binding;
struct mako_binding touch_binding, notify_binding, closed_binding;
};

struct mako_config {
Expand Down