Skip to content

Conversation

@zsien
Copy link

@zsien zsien commented Jul 12, 2018


Edit (@bebehei): Fixes #246

Copy link
Member

@tsipinakis tsipinakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found some small nitpicks but other than that looks good, thanks for working on this!

(For reference relevant issue: #246)

EDIT: Can you also update the manpage with the new settings?

dunstrc Outdated
# * 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.
# * push_all: Push all waiting and displayed notifications to history.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close_all would be a more consistent name for this IMO.

dunstrc Outdated
# invoke it. If there are multiple and no default, open the context menu.
# * close_current: Close current notification.
# * push_all: Push all waiting and displayed notifications to history.
[mouse]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer it if this was in the global section as well as mouse_left_click, mouse_middle_click etc. I think sections are best reserved for rules/more customization down the line rather than setting groups.

src/settings.h Outdated
enum separator_color { SEP_FOREGROUND, SEP_AUTO, SEP_FRAME, SEP_CUSTOM };
enum follow_mode { FOLLOW_NONE, FOLLOW_MOUSE, FOLLOW_KEYBOARD };
enum markup_mode { MARKUP_NULL, MARKUP_NO, MARKUP_STRIP, MARKUP_FULL };
enum mouse_action { do_action, close_current, push_all };
Copy link
Member

@tsipinakis tsipinakis Jul 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please match the enum value style as above, all caps and prefixed with a relevant string e.g. MOUSE_DO_ACTION

src/x11/x.c Outdated
break;
}

if (act == push_all) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some undefined behaviour here since act is uninitialized by default - are there any other mouse button events? Not sure, but it's best to handle it in any case. (probably ignore the event in the default case)

src/settings.c Outdated
{
char *c = option_get_string(
"mouse",
"middle_click", "-middel_click", "do_action",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-middel_click Typo :)

src/settings.c Outdated
else if (strcmp(c, "push_all") == 0)
settings.right_click = push_all;
else {
LOG_W("Unknown right_click position: '%s'", c);
Copy link
Member

@tsipinakis tsipinakis Jul 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message should be Unknown right_click action and similarly for the other errors.

src/settings.c Outdated
);

if (strlen(c) > 0) {
if (strcmp(c, "do_action") == 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of copy-paste code, it'll be easier to split this into a function (see the parse functions at the top of the file as an example)

  * Move mouse_left/middle/right_click to global section
  * Match the enum value style
  * Ignore unknow mouse event
  * Split copy-paste code into a function
  * Fix typo
@zsien
Copy link
Author

zsien commented Jul 13, 2018

Thank you for correcting me. I just uploaded my new code.

Copy link
Member

@bebehei bebehei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks mergeable.Thank you for implementing this! And also thanks to @tsipinakis giving already a very good review!

src/settings.c Outdated
{
char *c = option_get_string(
"global",
"mouse_left_click", "-left_click", "close_current",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, the only thing, which is still against current consistency: Please put the default value in the defaults struct in the file config.h. There is a full settings_t allocated and you can specify the default value there.

Use

char *c = option_get_string(
                        "global",
                        "mouse_left_click", "-left_click", NULL,

And then do it similarly to markup_mode:

dunst/src/settings.c

Lines 160 to 167 in 6d0e20e

//Use markup if set
//Use default if settings.markup not set yet
// (=>c empty&&!allow_markup)
if (c) {
settings.markup = parse_markup_mode(c);
} else if (!settings.markup) {
settings.markup = defaults.markup;
}

@zsien
Copy link
Author

zsien commented Jul 13, 2018

Done~

@tsipinakis
Copy link
Member

Thanks again, merged!

@tsipinakis tsipinakis merged commit c0eef2d into dunst-project:master Jul 15, 2018
@ForsakenHarmony
Copy link

when are you gonna release this?

@zsien zsien deleted the feature-mouse_event branch August 18, 2018 14:02
@bebehei
Copy link
Member

bebehei commented Aug 18, 2018

@ForsakenHarmony We'll release this with 1.4.0. The milestone is linked here: https://github.com/dunst-project/dunst/milestone/6

@var314 var314 mentioned this pull request Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants