-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add apply_superset_style to calculate the maximum values for all criteria styles #68
Conversation
This is the only place where we actually need special-case access to the first criteria, so it can do it on its own. I also renamed it root_criteria, which seems slightly more accurate.
config.c
Outdated
@@ -13,10 +13,14 @@ | |||
#include "types.h" | |||
#include "wlr-layer-shell-unstable-v1-client-protocol.h" | |||
|
|||
#define max(a, b) (((a) > (b)) ? (a) : (b)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of macros. This can be just a normal function, which will be automatically inlined by the compiler.
config.c
Outdated
@@ -79,8 +84,12 @@ void init_empty_style(struct mako_style *style) { | |||
} | |||
|
|||
void finish_style(struct mako_style *style) { | |||
free(style->font); | |||
free(style->format); | |||
if (style->spec.font) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for these if
s. free(NULL)
is valid and does nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right, not sure why I suddenly felt the need to add these.
config.c
Outdated
target->spec.format = true; | ||
|
||
if (target->format) { | ||
free(target->format); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for these if
s. free(NULL)
is valid and does nothing.
criteria.c
Outdated
@@ -134,6 +135,9 @@ bool parse_criteria(const char *string, struct mako_criteria *criteria) { | |||
++token_location; | |||
} | |||
break; | |||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I'm not a fan of adding default
cases since most compilers will emit a warning when an enum case isn't handled.
include/types.h
Outdated
@@ -25,6 +25,10 @@ struct mako_directional { | |||
}; | |||
|
|||
bool parse_directional(const char *string, struct mako_directional *out); | |||
|
|||
// List of specifier characters that can appear in a format string. | |||
static const char VALID_FORMAT_SPECIFIERS[] = "%asbht"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like not to introduce static
definitions in headers. Instead we can declare this constant as extern
here and define it in a .c
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks! |
This replaces
global_criteria
as the way to find out about notification styles in the general case, rather than for a specific notification. This is useful for two things that aren't currently possible to do accurately:This doesn't directly fix any issues, but was necessary for #46, #47, and #48, and will improve the fix for #55.
The main behavior change here is that we're now advertising DBus capabilities based on whether any of the criteria are using them, rather than just the default section. This means that you can now, for example, turn off markup globally but reenable it for a specific type of notification. Before, you could only do the opposite.
I've eliminated all but one use of
global_criteria
. It will be able to go away entirely after #66, because the stacking mechanism can be used to make thehidden
criteria no longer a special case (yay!).The one tricky part of this was the "maximum" value for
format
: a collection of all of the specifiers that appear in at least one style. I added format validation to make it a little easier (by knowing what the maximum length of that collection can be).Finally, I took the opportunity of needing to generate the "superstyle" on each reconfig to unify config loading during startup with that of reload_config. The
argc
andargv
are now stored on themako_state
to make that easier.