Skip to content
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

dbus server accepts parsing blur strength and added dbus example #16

Open
wants to merge 1 commit into
base: dual_kawase
Choose a base branch
from

Conversation

mvrozanti
Copy link

This one doesn't bloat stuff up and solves #14

I'm still wondering though, can we omit the parse_blur_strength call?

@tryone144
Copy link
Owner

Thanks for re-implementing in the dbus interface.

But I'm not quite shure how you want to change the parameters without a call to parse_blur_strength? Currently, the blur strength is tracked globally and directly set by said function.

@mvrozanti
Copy link
Author

mvrozanti commented Jun 22, 2019

Yeah I don't know why I mentioned that actually

Copy link
Owner

@tryone144 tryone144 left a comment

Choose a reason for hiding this comment

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

As blur-strength is kept in the global state and applied to all windows, this would be a better fit in the opts_set category, don't you think? 😉

src/common.h Outdated Show resolved Hide resolved
dbus-examples/dbus-strength.sh Outdated Show resolved Hide resolved
src/compton.c Outdated Show resolved Hide resolved
src/dbus.c Outdated Show resolved Hide resolved
src/dbus.c Outdated Show resolved Hide resolved
@mvrozanti
Copy link
Author

mvrozanti commented Jun 22, 2019

Oops

I forgot to rename that. I was not sure if it had had conflicts with ps->o.blur_strength somehow

I'm also not sure how to add this to opts_set, I'm gonna try and find out

@tryone144
Copy link
Owner

I'm also not sure how to add this to opts_set, I'm gonna try and find out

There should be a generic handler:

cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {

@mvrozanti
Copy link
Author

mvrozanti commented Jun 22, 2019

Is that last commit right..?

I also wanted to have the possibility to increment/decrement by a factor.

@tryone144
Copy link
Owner

Is that last commit right..?

Looks like you forgot to actually change the copied handler to update the blur-strength like the other one did...
The old win_set handler is misleading and should be removed, I think.

I also wanted to have the possibility to increment/decrement by a factor though.

This is a bit more difficult, as there is currently no way to read the numeric blur-strength value back. But this could be stored in the ps->o.blur_strength item as well. Just update the corresponding struct definition and the parse method to include the numeric value as well like here:

compton/src/common.h

Lines 554 to 559 in 0f86353

typedef struct {
int level;
int iterations;
float offset;
int expand;
} blur_strength_t;

compton/src/common.h

Lines 1709 to 1744 in 0f86353

/**
* Parse a blur_strength option argument.
*/
static inline bool
parse_blur_strength(session_t *ps, const int level) {
static const blur_strength_t values[20] = {
{ .level = 1, .iterations = 1, .offset = 1.5 , .expand = 10 }, // 1
{ .level = 2, .iterations = 1, .offset = 2.0 , .expand = 10 }, // 2
{ .level = 3, .iterations = 2, .offset = 2.5 , .expand = 20 }, // 3
{ .level = 4, .iterations = 2, .offset = 3.0 , .expand = 20 }, // 4
{ .level = 5, .iterations = 3, .offset = 2.75 , .expand = 50 }, // 5
{ .level = 6, .iterations = 3, .offset = 3.5 , .expand = 50 }, // 6
{ .level = 7, .iterations = 3, .offset = 4.25 , .expand = 50 }, // 7
{ .level = 8, .iterations = 3, .offset = 5.0 , .expand = 50 }, // 8
{ .level = 9, .iterations = 4, .offset = 3.71429, .expand = 150 }, // 9
{ .level = 10, .iterations = 4, .offset = 4.42857, .expand = 150 }, // 10
{ .level = 11, .iterations = 4, .offset = 5.14286, .expand = 150 }, // 11
{ .level = 12, .iterations = 4, .offset = 5.85714, .expand = 150 }, // 12
{ .level = 13, .iterations = 4, .offset = 6.57143, .expand = 150 }, // 13
{ .level = 14, .iterations = 4, .offset = 7.28571, .expand = 150 }, // 14
{ .level = 15, .iterations = 4, .offset = 8.0 , .expand = 150 }, // 15
{ .level = 16, .iterations = 5, .offset = 6.0 , .expand = 400 }, // 16
{ .level = 17, .iterations = 5, .offset = 7.0 , .expand = 400 }, // 17
{ .level = 18, .iterations = 5, .offset = 8.0 , .expand = 400 }, // 18
{ .level = 19, .iterations = 5, .offset = 9.0 , .expand = 400 }, // 19
{ .level = 20, .iterations = 5, .offset = 10.0 , .expand = 400 }, // 20
};
if (level < 1 || level > 20) {
printf_errf("(\"%d\"): Invalid blur_strength argument. Needs to be a number between 1 and 20.", level);
return false;
}
ps->o.blur_strength = values[level - 1];
return true;
}

This value should be accessible via a new dbus handler in opts_get. Increment and decrement should then be possible via the dbus interface.

@mvrozanti mvrozanti force-pushed the dbus-str branch 2 times, most recently from 043732d to 05b5f30 Compare June 22, 2019 23:28
@mvrozanti
Copy link
Author

Does this look right? this dbus thing is kinda weird

@tryone144
Copy link
Owner

I guess it works... 😄
I'll take a look at it later.

@mvrozanti
Copy link
Author

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.

2 participants