Skip to content

Commit

Permalink
Merge pull request #27 from yshui/next
Browse files Browse the repository at this point in the history
Merged with picom upstream
  • Loading branch information
FT-Labs authored Sep 19, 2023
2 parents 367643e + fbc803b commit 2b74392
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 82 deletions.
3 changes: 0 additions & 3 deletions picom.sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@ dithered-present = false;
# Enable/disable VSync.
# vsync = true

# Enable remote control via D-Bus. See the *D-BUS API* section below for more details.
# dbus = false

# Try to detect WM windows (a non-override-redirect window with no
# child that has 'WM_STATE') and mark them as active.
#
Expand Down
17 changes: 6 additions & 11 deletions src/backend/xrender/xrender.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,12 +896,6 @@ static backend_t *backend_xrender_init(session_t *ps) {
&ps->c, ps->c.screen_info->root_visual, xd->target_win,
XCB_RENDER_CP_SUBWINDOW_MODE, &pa);

auto pictfmt = x_get_pictform_for_visual(&ps->c, ps->c.screen_info->root_visual);
if (!pictfmt) {
log_fatal("Default visual is invalid");
abort();
}

xd->vsync = ps->o.vsync;
if (ps->present_exists) {
auto eid = x_new_id(&ps->c);
Expand Down Expand Up @@ -930,14 +924,15 @@ static backend_t *backend_xrender_init(session_t *ps) {
// double buffering.
int first_buffer_index = xd->vsync ? 0 : 2;
for (int i = first_buffer_index; i < 3; i++) {
xd->back_pixmap[i] =
x_create_pixmap(&ps->c, pictfmt->depth, to_u16_checked(ps->root_width),
to_u16_checked(ps->root_height));
xd->back_pixmap[i] = x_create_pixmap(&ps->c, ps->c.screen_info->root_depth,
to_u16_checked(ps->root_width),
to_u16_checked(ps->root_height));
const uint32_t pic_attrs_mask = XCB_RENDER_CP_REPEAT;
const xcb_render_create_picture_value_list_t pic_attrs = {
.repeat = XCB_RENDER_REPEAT_PAD};
xd->back[i] = x_create_picture_with_pictfmt_and_pixmap(
&ps->c, pictfmt, xd->back_pixmap[i], pic_attrs_mask, &pic_attrs);
xd->back[i] = x_create_picture_with_visual_and_pixmap(
&ps->c, ps->c.screen_info->root_visual, xd->back_pixmap[i],
pic_attrs_mask, &pic_attrs);
xd->buffer_age[i] = -1;
if (xd->back_pixmap[i] == XCB_NONE || xd->back[i] == XCB_NONE) {
log_error("Cannot create pixmap for rendering");
Expand Down
15 changes: 9 additions & 6 deletions src/c2.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,16 @@ static inline long winprop_get_int(winprop_t prop, size_t index) {
*/
static inline int strcmp_wd(const char *needle, const char *src) {
int ret = mstrncmp(needle, src);
if (ret)
if (ret) {
return ret;
}

char c = src[strlen(needle)];
if (isalnum((unsigned char)c) || '_' == c)
if (isalnum((unsigned char)c) || '_' == c) {
return 1;
else
return 0;
}

return 0;
}

/**
Expand All @@ -254,8 +256,9 @@ static inline attr_unused bool c2_ptr_isempty(const c2_ptr_t p) {
* Reset a c2_ptr_t.
*/
static inline void c2_ptr_reset(c2_ptr_t *pp) {
if (pp)
if (pp) {
memcpy(pp, &C2_PTR_NULL, sizeof(c2_ptr_t));
}
}

/**
Expand Down Expand Up @@ -988,7 +991,7 @@ static int c2_parse_legacy(const char *pattern, int offset, c2_ptr_t *presult) {

// Determine the pattern target
#define TGTFILL(pdefid) \
(pleaf->predef = pdefid, pleaf->type = C2_PREDEFS[pdefid].type, \
(pleaf->predef = (pdefid), pleaf->type = C2_PREDEFS[pdefid].type, \
pleaf->format = C2_PREDEFS[pdefid].format)
switch (pattern[offset]) {
case 'n': TGTFILL(C2_L_PNAME); break;
Expand Down
23 changes: 11 additions & 12 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,19 @@ const char *parse_readnum(const char *src, double *dest) {
}

enum blur_method parse_blur_method(const char *src) {
if (strcmp(src, "kernel") == 0) {
return BLUR_METHOD_KERNEL;
} else if (strcmp(src, "box") == 0) {
if (strcmp(src, "box") == 0) {
return BLUR_METHOD_BOX;
} else if (strcmp(src, "gaussian") == 0) {
return BLUR_METHOD_GAUSSIAN;
} else if (strcmp(src, "dual_kawase") == 0) {
return BLUR_METHOD_DUAL_KAWASE;
} else if (strcmp(src, "kawase") == 0) {
log_warn("Blur method 'kawase' has been renamed to 'dual_kawase'. "
"Interpreted as 'dual_kawase', but this will stop working "
"soon.");
}
if (strcmp(src, "dual_kawase") == 0) {
return BLUR_METHOD_DUAL_KAWASE;
} else if (strcmp(src, "none") == 0) {
}
if (strcmp(src, "gaussian") == 0) {
return BLUR_METHOD_GAUSSIAN;
}
if (strcmp(src, "kernel") == 0) {
return BLUR_METHOD_KERNEL;
}
if (strcmp(src, "none") == 0) {
return BLUR_METHOD_NONE;
}
return BLUR_METHOD_INVALID;
Expand Down
23 changes: 15 additions & 8 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,21 @@ static attr_const const char *log_level_to_string(enum log_level level) {
}

enum log_level string_to_log_level(const char *str) {
if (strcasecmp(str, "TRACE") == 0)
if (strcasecmp(str, "TRACE") == 0) {
return LOG_LEVEL_TRACE;
else if (strcasecmp(str, "DEBUG") == 0)
}
if (strcasecmp(str, "DEBUG") == 0) {
return LOG_LEVEL_DEBUG;
else if (strcasecmp(str, "INFO") == 0)
}
if (strcasecmp(str, "INFO") == 0) {
return LOG_LEVEL_INFO;
else if (strcasecmp(str, "WARN") == 0)
}
if (strcasecmp(str, "WARN") == 0) {
return LOG_LEVEL_WARN;
else if (strcasecmp(str, "ERROR") == 0)
}
if (strcasecmp(str, "ERROR") == 0) {
return LOG_LEVEL_ERROR;
}
return LOG_LEVEL_INVALID;
}

Expand Down Expand Up @@ -143,8 +148,9 @@ enum log_level log_get_level(const struct log *l) {
attr_printf(4, 5) void log_printf(struct log *l, int level, const char *func,
const char *fmt, ...) {
assert(level <= LOG_LEVEL_FATAL && level >= 0);
if (level < l->log_level)
if (level < l->log_level) {
return;
}

char *buf = NULL;
va_list args;
Expand Down Expand Up @@ -340,7 +346,7 @@ static void
gl_string_marker_logger_write(struct log_target *tgt, const char *str, size_t len) {
auto g = (struct gl_string_marker_logger *)tgt;
// strip newlines at the end of the string
while (len > 0 && str[len-1] == '\n') {
while (len > 0 && str[len - 1] == '\n') {
len--;
}
g->gl_string_marker((GLsizei)len, str);
Expand All @@ -358,8 +364,9 @@ struct log_target *gl_string_marker_logger_new(void) {
}

void *fnptr = glXGetProcAddress((GLubyte *)"glStringMarkerGREMEDY");
if (!fnptr)
if (!fnptr) {
return NULL;
}

auto ret = cmalloc(struct gl_string_marker_logger);
ret->tgt.ops = &gl_string_marker_logger_ops;
Expand Down
Loading

0 comments on commit 2b74392

Please sign in to comment.