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

Add foreground blurring (Privacy and Focus modes) #765

Open
wants to merge 12 commits into
base: next
Choose a base branch
from

Conversation

dshoreman
Copy link

@dshoreman dshoreman commented Jan 23, 2022

Continuation/revival of #490 by @rajansaini691; see that PR for more background.

Differences in this PR:

  • Dropped merge commit, squashed formatting fixes
  • Rebased onto latest next branch, resolved conflicts
  • Added --inactive-blur-include option (see below)
  • Added --inactive-blur-opacity
  • Utilised the blur_foreground property (added but unused in original PR)
  • Avoids blurring background and foreground of the same window to boost speed

Option Rationale

Comments in the original PR called for an exclusion list to be added, but I couldn't see how that would be useful so opted for the inverse.
Doing it this way allows for two different behaviours - either "privacy" or "focus" mode.

  1. Focus Mode
    The easiest option, this will blur all inactive windows:

    inactive-blur = true;
  2. Privacy Mode
    Combining both options will only blur windows defined in --inactive-blur-list.
    This can be useful for hiding sensitive data, eg communication or banking apps:

    inactive-blur = true;
    inactive-blur-include = [
        "class_g = 'discord'",
        "name *= '- Gmail -'",
        "class_g = 'Signal'",
        "class_g = 'TelegramDesktop'",
    ];

Closes #489

@codecov
Copy link

codecov bot commented Jan 23, 2022

Codecov Report

Merging #765 (cda8ca4) into next (05ef18d) will increase coverage by 1.28%.
The diff coverage is 36.00%.

❗ Current head cda8ca4 differs from pull request most recent head 45dc995. Consider uploading reports for the commit 45dc995 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             next     #765      +/-   ##
==========================================
+ Coverage   37.74%   39.02%   +1.28%     
==========================================
  Files          48       46       -2     
  Lines       10869     9681    -1188     
==========================================
- Hits         4102     3778     -324     
+ Misses       6767     5903     -864     
Impacted Files Coverage Δ
src/config.c 42.74% <ø> (-8.53%) ⬇️
src/config.h 23.52% <ø> (ø)
src/options.c 21.09% <0.00%> (+1.89%) ⬆️
src/render.c 4.08% <0.00%> (+2.77%) ⬆️
src/win.h 78.12% <ø> (ø)
src/config_libconfig.c 58.09% <25.00%> (+0.53%) ⬆️
src/backend/backend.c 62.27% <33.33%> (+2.59%) ⬆️
src/win.c 68.15% <80.00%> (+1.01%) ⬆️
src/picom.c 67.80% <100.00%> (+1.91%) ⬆️

... and 27 files with indirect coverage changes

Copy link
Owner

@yshui yshui left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! This is great work, I like how small the changes are for what it does.

Just a couple of concerns

src/win.c Outdated Show resolved Hide resolved
src/backend/backend.c Outdated Show resolved Hide resolved
src/config_libconfig.c Outdated Show resolved Hide resolved
@dshoreman
Copy link
Author

dshoreman commented Feb 10, 2022

Thanks for the PR! This is great work, I like how small the changes are for what it does.

Thanks! I can't take all the credit though.
Much of the work is by @rajansaini691—I simply rebased and made some minor behavioural changes ;)

Sorry it took so long to fix the style issue, a few things came up all at once IRL. I'll see what I can do to resolve any issues later.
It'd be nice to add a test or two as well but so far I haven't even looked inside the tests dir, so we'll see

@schrottkatze
Copy link

Hi, looking for an update on this, does this PR have a future? I'm looking for this feature for quite a while and it's kind of disheartening to see this PR and its predecessor be practically dead.

@rajansaini691
Copy link

rajansaini691 commented Sep 19, 2022 via email

@schrottkatze
Copy link

Hello, thanks for the response!
I'm both lacking the time and C skills to implement it sadly, but I use my laptop in public a lot so I hope that someone will integrate them soon.

@dshoreman
Copy link
Author

@obsidianical Apologies, things came up after my first rebase in July and I forgot to push. I rebased again yesterday (only one new commit) and pushed just now after making sure it still works.

Most conflicts were from new window-shadow-fg and window-shadow-fg-rule options added in 654772b. I'm unsure if it adds similar (or underlying) functionality that could replace or support this PR. It could be something else entirely...


I plan to throw a test config together later today after some sleep to try the plain next branch. If the functionality of this PR isn't already added by 654772b then I have no problem getting back to work resolving some of the original review issues.

Rajan Saini and others added 9 commits April 16, 2023 02:18
Adds an option to specify which windows will be blurred when inactive.
If --inactive-blur-include isn't specified, but --inactive-blur *is*,
then the sensible default would be to blur all inactive windows.

This commit does exactly that.
The property was already added in the first commit on this branch, but
it wasn't defined so it would've had no effect. With this, the long
conditional is easier to read and *should* update automatically.
Moves the setting of `blur_foreground` to a new method which then calls
a second to actually set the value and apply damage if it's different,
similar to how the blur_background value/damage is handled.
Rather than overriding the background blur method, this will only use
blur_method when it's already defined, otherwise creating a whole new
blur context using the 'box' blur method with default size of 3. This
fixes an issue where background blur would be forced even if unwanted.

By placing the fgcontext code in picom.c rather than config_libconfig.c,
this also fixes a segfault when passing `--inactive-blur` on the command
line without having a blur method set either in an option or in config.
@dshoreman
Copy link
Author

image

Finally(!) found enough time to get back to work on this again 🎉

@yshui I'm pretty sure everything's done now, but would you mind reviewing again in case I've missed anything? Thanks!

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.

Blur foreground?
4 participants