Skip to content

Commit e5dd87f

Browse files
resolve: resolve requested changes
1 parent 9befcaf commit e5dd87f

File tree

8 files changed

+67
-67
lines changed

8 files changed

+67
-67
lines changed

dunstrc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,14 @@
323323
# * close_all: Close all notifications.
324324
# * context: Open context menu for the notification.
325325
# * context_all: Open context menu for all notifications.
326-
# * forward_script: Script on rules section script_mouse_forward will be executed.
327-
# * back_script: Script on rules section script_mouse_back will be executed.
326+
# * mouse_scroll_script: Run script on rule section based on button pressed
328327
# These values can be strung together for each mouse event, and
329328
# will be executed in sequence.
330329
mouse_left_click = close_current
331330
mouse_middle_click = do_action, close_current
332331
mouse_right_click = close_all
333-
mouse_scroll_forward = forward_script
334-
mouse_scroll_backward = back_script
332+
mouse_scroll_up = mouse_scroll_script
333+
mouse_scroll_down = mouse_scroll_script
335334

336335
# Experimental features that may or may not work correctly. Do not expect them
337336
# to have a consistent behaviour across releases.
@@ -405,8 +404,8 @@
405404
# alignment
406405
# hide_text
407406
# override_pause_level
408-
# script_mouse_back
409-
# script_mouse_back
407+
# script_scroll_up
408+
# script_scroll_down
410409
#
411410
# Shell-like globbing will get expanded.
412411
#
@@ -501,6 +500,6 @@
501500
#
502501
#[volume-changer]
503502
# appname = "some_volume_notifiers"
504-
# script_mouse_forward = some_volum_change_up_script
505-
# script_mouse_back = some_volum_change_down_script
503+
# script_scroll_up = some_volum_change_up_script
504+
# script_scroll_down = some_volum_change_down_script
506505
# vim: ft=cfg

src/input.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,22 @@ void input_handle_click(unsigned int button, bool button_down, int mouse_x, int
105105
continue;
106106
}
107107

108-
if (act == MOUSE_DO_ACTION || act == MOUSE_CLOSE_CURRENT || act == MOUSE_CONTEXT || act == MOUSE_OPEN_URL || act== MOUSE_BACKWARD_SCRIPT || act == MOUSE_FORWARD_SCRIPT) {
108+
if (act == MOUSE_DO_ACTION || act == MOUSE_CLOSE_CURRENT || act == MOUSE_CONTEXT || act == MOUSE_OPEN_URL || act== MOUSE_SCROLL_SCRIPT) {
109109
struct notification *n = get_notification_at(mouse_y);
110-
111110
if (n) {
112111
if (act == MOUSE_CLOSE_CURRENT) {
113112
n->marked_for_closure = REASON_USER;
114113
} else if (act == MOUSE_DO_ACTION) {
115114
notification_do_action(n);
116115
} else if (act == MOUSE_OPEN_URL) {
117116
notification_open_url(n);
118-
} else if (act == MOUSE_FORWARD_SCRIPT){
119-
notification_invoke_script_rule(n,MAT_FORWARD);
120-
} else if (act == MOUSE_BACKWARD_SCRIPT){
121-
notification_invoke_script_rule(n,MAT_BACK);
117+
} else if (act == MOUSE_SCROLL_SCRIPT){
118+
if(button==BTN_FORWARD){
119+
notification_invoke_script_rule(n,MOUSE_ACTION_SCROLL_UP);
120+
}
121+
else if(button==BTN_BACK){
122+
notification_invoke_script_rule(n,MOUSE_ACTION_SCROLL_DOWN);
123+
}
122124
} else {
123125
notification_open_context_menu(n);
124126
}

src/notification.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,19 @@ void notification_print(const struct notification *n)
108108
}
109109
printf("\n");
110110
}
111-
printf("\tscript_mouse_forward_count: %d\n", n->script_mouse_forward_count);
112-
if (n->script_mouse_forward_count > 0) {
111+
printf("\tscript_mouse_forward_count: %d\n", n->script_scroll_up_count);
112+
if (n->script_scroll_up_count > 0) {
113113
printf("\tscripts_mf: ");
114-
for (int i = 0; i < n->script_mouse_forward_count; i++) {
115-
printf("'%s' ", STR_NN(n->scripts_mf[i]));
114+
for (int i = 0; i < n->script_scroll_up_count; i++) {
115+
printf("'%s' ", STR_NN(n->script_scroll_up[i]));
116116
}
117117
printf("\n");
118118
}
119-
printf("\tscript_mouse_back_count: %d\n", n->script_mouse_back_count);
120-
if (n->script_mouse_back_count > 0) {
119+
printf("\tscript_mouse_back_count: %d\n", n->script_scroll_down_count);
120+
if (n->script_scroll_down_count > 0) {
121121
printf("\tscripts_mb: ");
122-
for (int i = 0; i < n->script_mouse_back_count; i++) {
123-
printf("'%s' ", STR_NN(n->scripts_mb[i]));
122+
for (int i = 0; i < n->script_scroll_down_count; i++) {
123+
printf("'%s' ", STR_NN(n->script_scroll_down[i]));
124124
}
125125
printf("\n");
126126
}
@@ -145,11 +145,11 @@ void notification_run_script(struct notification *n)
145145
const char *urgency = notification_urgency_to_string(n->urgency);
146146
int script_count = 0;
147147
switch(n->script_choice){
148-
case MAT_FORWARD:
149-
script_count = n->script_mouse_forward_count;
148+
case MOUSE_ACTION_SCROLL_UP:
149+
script_count = n->script_scroll_up_count;
150150
break;
151-
case MAT_BACK:
152-
script_count = n->script_mouse_back_count;
151+
case MOUSE_ACTION_SCROLL_DOWN:
152+
script_count = n->script_scroll_down_count;
153153
break;
154154
default:
155155
script_count = n->script_count;
@@ -160,11 +160,11 @@ void notification_run_script(struct notification *n)
160160

161161
const char *script;
162162
switch(n->script_choice){
163-
case MAT_FORWARD:
164-
script = n->scripts_mf[i];
163+
case MOUSE_ACTION_SCROLL_UP:
164+
script = n->script_scroll_up[i];
165165
break;
166-
case MAT_BACK:
167-
script = n->scripts_mb[i];
166+
case MOUSE_ACTION_SCROLL_DOWN:
167+
script = n->script_scroll_down[i];
168168
break;
169169
default:
170170
script = n->scripts[i];
@@ -567,7 +567,7 @@ void notification_init(struct notification *n)
567567
n->colors.highlight = gradient_acquire(defcolors.highlight);
568568
}
569569
/*Script setup*/
570-
n->script_choice = MAT_OTHERS;
570+
n->script_choice = MOUSE_ACTION_OTHERS;
571571

572572
/* Sanitize misc hints */
573573
if (n->progress < 0)

src/notification.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ enum icon_position {
1919
};
2020

2121
enum mouse_action_type{
22-
MAT_OTHERS=0,
23-
MAT_FORWARD,
24-
MAT_BACK,
22+
MOUSE_ACTION_OTHERS=0,
23+
MOUSE_ACTION_SCROLL_UP,
24+
MOUSE_ACTION_SCROLL_DOWN,
2525
};
2626

2727
enum behavior_fullscreen {
@@ -96,11 +96,11 @@ struct notification {
9696
char **scripts;
9797
int script_count;
9898

99-
char **scripts_mf;
100-
int script_mouse_forward_count;
99+
char **script_scroll_up;
100+
int script_scroll_up_count;
101101

102-
char **scripts_mb;
103-
int script_mouse_back_count;
102+
char **script_scroll_down;
103+
int script_scroll_down_count;
104104

105105
struct notification_colors colors;
106106

src/rules.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,27 +133,27 @@ void rule_apply(struct rule *r, struct notification *n, bool save)
133133
n->scripts[n->script_count + 1] = NULL;
134134
n->script_count++;
135135
}
136-
if (r->script_mouse_forward) {
137-
if (save && n->original->script_mouse_forward == NULL)
138-
n->original->script_mouse_forward = n->script_mouse_forward_count > 0
139-
? g_strdup(n->scripts_mf[0])
136+
if (r->script_scroll_up) {
137+
if (save && n->original->script_scroll_up == NULL)
138+
n->original->script_scroll_up = n->script_scroll_up_count > 0
139+
? g_strdup(n->script_scroll_up[0])
140140
: g_strdup(r->script);
141141

142-
n->scripts_mf = g_renew(char *, n->scripts_mf, n->script_mouse_forward_count + 2);
143-
n->scripts_mf[n->script_mouse_forward_count] = g_strdup(r->script_mouse_forward);
144-
n->scripts_mf[n->script_mouse_forward_count + 1] = NULL;
145-
n->script_mouse_forward_count++;
142+
n->script_scroll_up = g_renew(char *, n->script_scroll_up, n->script_scroll_up_count + 2);
143+
n->script_scroll_up[n->script_scroll_up_count] = g_strdup(r->script_scroll_up);
144+
n->script_scroll_up[n->script_scroll_up_count + 1] = NULL;
145+
n->script_scroll_up_count++;
146146
}
147-
if (r->script_mouse_back) {
148-
if (save && n->original->script_mouse_back == NULL)
149-
n->original->script_mouse_back = n->script_mouse_back_count > 0
150-
? g_strdup(n->scripts_mb[0])
147+
if (r->script_scroll_down) {
148+
if (save && n->original->script_scroll_down == NULL)
149+
n->original->script_scroll_down = n->script_scroll_down_count > 0
150+
? g_strdup(n->script_scroll_down[0])
151151
: g_strdup(r->script);
152152

153-
n->scripts_mb = g_renew(char *, n->scripts_mb, n->script_mouse_back_count + 2);
154-
n->scripts_mb[n->script_mouse_back_count] = g_strdup(r->script_mouse_back);
155-
n->scripts_mb[n->script_mouse_back_count + 1] = NULL;
156-
n->script_mouse_back_count++;
153+
n->script_scroll_down = g_renew(char *, n->script_scroll_down, n->script_scroll_down_count + 2);
154+
n->script_scroll_down[n->script_scroll_down_count] = g_strdup(r->script_scroll_down);
155+
n->script_scroll_down[n->script_scroll_down_count + 1] = NULL;
156+
n->script_scroll_down_count++;
157157
}
158158
}
159159

@@ -207,8 +207,8 @@ void rule_print(const struct rule *r)
207207
if (r->set_category != NULL) printf("\tset_category: '%s'\n", r->set_category);
208208
if (r->format != NULL) printf("\tformat: '%s'\n", r->format);
209209
if (r->script != NULL) printf("\tscript: '%s'\n", r->script);
210-
if (r->script_mouse_forward != NULL) printf("\tscript_mouse_forward: '%s'\n", r->script_mouse_forward);
211-
if (r->script_mouse_back != NULL) printf("\tscript_mouse_back: '%s'\n", r->script_mouse_back);
210+
if (r->script_scroll_up != NULL) printf("\tscript_scroll_up: '%s'\n", r->script_scroll_up);
211+
if (r->script_scroll_down != NULL) printf("\tscript_scroll_down: '%s'\n", r->script_scroll_down);
212212
if (r->fullscreen != FS_NULL) printf("\tfullscreen: %s\n", enum_to_string_fullscreen(r->fullscreen));
213213
if (r->progress_bar_alignment != -1) printf("\tprogress_bar_alignment: %d\n", r->progress_bar_alignment);
214214
if (r->set_stack_tag != NULL) printf("\tset_stack_tag: %s\n", r->set_stack_tag);

src/rules.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ struct rule {
5555
char *set_category;
5656
char *format;
5757
char *script;
58-
char *script_mouse_forward;
59-
char *script_mouse_back;
58+
char *script_scroll_up;
59+
char *script_scroll_down;
6060
enum behavior_fullscreen fullscreen;
6161
bool enabled;
6262
int progress_bar_alignment;

src/settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ enum separator_color { SEP_FOREGROUND, SEP_AUTO, SEP_FRAME, SEP_CUSTOM };
3535
enum follow_mode { FOLLOW_NONE, FOLLOW_MOUSE, FOLLOW_KEYBOARD };
3636
enum mouse_action { MOUSE_NONE, MOUSE_DO_ACTION, MOUSE_CLOSE_CURRENT,
3737
MOUSE_CLOSE_ALL, MOUSE_CONTEXT, MOUSE_CONTEXT_ALL, MOUSE_OPEN_URL,
38-
MOUSE_FORWARD_SCRIPT,MOUSE_BACKWARD_SCRIPT,
38+
MOUSE_SCROLL_SCRIPT,
3939
MOUSE_ACTION_END = LIST_END /* indicates the end of a list of mouse actions */};
4040
#ifndef ZWLR_LAYER_SHELL_V1_LAYER_ENUM
4141
#define ZWLR_LAYER_SHELL_V1_LAYER_ENUM

src/settings_data.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ static const struct string_to_enum_def mouse_action_enum_data[] = {
312312
{"context", MOUSE_CONTEXT },
313313
{"context_all", MOUSE_CONTEXT_ALL },
314314
{"open_url", MOUSE_OPEN_URL },
315-
{"forward_script", MOUSE_FORWARD_SCRIPT },
316-
{"back_script", MOUSE_BACKWARD_SCRIPT },
315+
{"mouse_scroll_script", MOUSE_SCROLL_SCRIPT },
317316
ENUM_END,
318317
};
319318

@@ -522,26 +521,26 @@ static const struct setting allowed_settings[] = {
522521
.rule_offset = offsetof(struct rule, script),
523522
},
524523
{
525-
.name = "script_mouse_forward",
524+
.name = "script_scroll_up",
526525
.section = "*",
527526
.description = "script for mouse scroll up",
528527
.type = TYPE_PATH,
529528
.default_value = "*",
530529
.value = NULL,
531530
.parser = NULL,
532531
.parser_data = NULL,
533-
.rule_offset = offsetof(struct rule, script_mouse_forward),
532+
.rule_offset = offsetof(struct rule, script_scroll_up),
534533
},
535534
{
536-
.name = "script_mouse_back",
535+
.name = "script_scroll_down",
537536
.section = "*",
538537
.description = "script for mouse scroll down",
539538
.type = TYPE_PATH,
540539
.default_value = "*",
541540
.value = NULL,
542541
.parser = NULL,
543542
.parser_data = NULL,
544-
.rule_offset = offsetof(struct rule, script_mouse_back),
543+
.rule_offset = offsetof(struct rule, script_scroll_down),
545544
},
546545
{
547546
.name = "background",
@@ -1350,7 +1349,7 @@ static const struct setting allowed_settings[] = {
13501349
.section = "global",
13511350
.description = "Action of right click event",
13521351
.type = TYPE_LIST,
1353-
.default_value = "forward_script",
1352+
.default_value = "mouse_scroll_script",
13541353
.value = &settings.mouse_scroll_up,
13551354
.parser = NULL,
13561355
.parser_data = GINT_TO_POINTER(MOUSE_LIST),
@@ -1360,7 +1359,7 @@ static const struct setting allowed_settings[] = {
13601359
.section = "global",
13611360
.description = "Action of right click event",
13621361
.type = TYPE_LIST,
1363-
.default_value = "back_script",
1362+
.default_value = "mouse_scroll_script",
13641363
.value = &settings.mouse_scroll_down,
13651364
.parser = NULL,
13661365
.parser_data = GINT_TO_POINTER(MOUSE_LIST),

0 commit comments

Comments
 (0)