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

Implementing shadow exclude regions list #582

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/checkupstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Check new upstream commits
Copy link
Owner

Choose a reason for hiding this comment

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

This doesn't seem to be relevant to this PR?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, my bad. I had had to create another branch for this PR. I thought it is abandoned and pushed mechanism informing me about new commits.
Anyway, what do you think about the changes? Worth merging? Without last commit of course :)


on:
repository_dispatch:
types: [check_upstream]

jobs:
sync_with_upstream:
runs-on: ubuntu-latest
name: Sync master with upstream latest

steps:
- name: Checkout master
uses: actions/checkout@v2
with:
ref: next

- name: Fetch upstream changes
id: sync
uses: ivanmilov/upstream_check_new_commits@v1
with:
upstream_repository: yshui/picom
upstream_branch: next
target_branch: next_upstream

- name: Notify if new commits
uses: ivanmilov/telegram_notify_action@v1
with:
api_key: ${{secrets.API_KEY}}
chat_id: ${{secrets.CHAT_ID}}
message: "New commit in upstream repo ${{github.repository}}"
if: ${{ steps.sync.outputs.has_new_commits == 'true' }}
1 change: 1 addition & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable,
.shadow_opacity = .75,
.shadow_blacklist = NULL,
.shadow_ignore_shaped = false,
.shadow_exclude_regions_str = NULL,
.xinerama_shadow_crop = false,

.corner_radius = 0,
Expand Down
7 changes: 7 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ enum blur_method {
BLUR_METHOD_INVALID,
};

typedef struct region_list_str {
char *reg;
struct region_list_str *next;
} region_list_str_t;

typedef struct _c2_lptr c2_lptr_t;

/// Structure representing all options.
Expand Down Expand Up @@ -148,6 +153,8 @@ typedef struct options {
double shadow_opacity;
/// argument string to shadow-exclude-reg option
char *shadow_exclude_reg_str;
/// Shadow exclude region list. A linked list of regions as string.
region_list_str_t *shadow_exclude_regions_str;
/// Shadow blacklist. A linked list of conditions.
c2_lptr_t *shadow_blacklist;
/// Whether bounding-shaped window should be ignored.
Expand Down
43 changes: 43 additions & 0 deletions src/config_libconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,47 @@ void parse_cfg_condlst(const config_t *pcfg, c2_lptr_t **pcondlst, const char *n
}
}

/**
* Parse a region list in configuration file.
*/
void parse_cfg_regions(const config_t *pcfg, region_list_str_t **list, const char *name) {
config_setting_t *setting = config_lookup(pcfg, name);

if (setting) {
// Parse an array of options
if (config_setting_is_array(setting)) {
int i = config_setting_length(setting);
// shadow_exclude_regions
while (i--) {
if (list) {
auto tmp = cmalloc(region_list_str_t);
tmp->next = *list;
const auto str =
config_setting_get_string_elem(setting, i);

tmp->reg = cvalloc(strlen(str));
tmp->reg = memcpy(tmp->reg, str, strlen(str));

*list = tmp;
}
}
}
// Treat it as a single pattern if it's a string
else if (CONFIG_TYPE_STRING == config_setting_type(setting)) {
if (list) {
auto tmp = cmalloc(region_list_str_t);
tmp->next = *list;
const auto str = config_setting_get_string(setting);

tmp->reg = cvalloc(strlen(str));
tmp->reg = memcpy(tmp->reg, str, strlen(str));

*list = tmp;
}
}
}
}

/**
* Parse an opacity rule list in configuration file.
*/
Expand Down Expand Up @@ -430,6 +471,8 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
// --shadow-exclude-reg
if (config_lookup_string(&cfg, "shadow-exclude-reg", &sval))
opt->shadow_exclude_reg_str = strdup(sval);
// --shadow-exclude-reg-list
parse_cfg_regions(&cfg, &opt->shadow_exclude_regions_str, "shadow-exclude-reg-list");
// --inactive-opacity-override
lcfg_lookup_bool(&cfg, "inactive-opacity-override", &opt->inactive_opacity_override);
// --inactive-dim
Expand Down
28 changes: 28 additions & 0 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,22 @@ static void rebuild_shadow_exclude_reg(session_t *ps) {
bool ret = parse_geometry(ps, ps->o.shadow_exclude_reg_str, &ps->shadow_exclude_reg);
if (!ret)
exit(1);

if (ps->o.shadow_exclude_regions_str) {
region_t reg_tmp;
pixman_region32_init(&reg_tmp);

auto regs = ps->o.shadow_exclude_regions_str;
while (regs) {
if (!parse_geometry(ps, regs->reg, &reg_tmp))
exit(1);

pixman_region32_union(&ps->shadow_exclude_reg,
&ps->shadow_exclude_reg, &reg_tmp);
regs = regs->next;
}
pixman_region32_fini(&reg_tmp);
}
}

/// Free up all the images and deinit the backend
Expand Down Expand Up @@ -2297,6 +2313,18 @@ static void session_destroy(session_t *ps) {
free_wincondlst(&ps->o.unredir_if_possible_blacklist);
free_wincondlst(&ps->o.rounded_corners_blacklist);

// Free shadow exclude region list
{
region_list_str_t *next = NULL;
for (region_list_str_t *this = ps->o.shadow_exclude_regions_str; this;
this = next) {
next = this->next;
free(this);
}

ps->o.shadow_exclude_regions_str = NULL;
}

// Free tracked atom list
{
latom_t *next = NULL;
Expand Down