Most of the x_* functions don't need session_t

Replace session_t parameter with xcb_connection_t if that's the only
thing needed.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2019-02-03 15:59:31 +00:00
parent ad3dc5d233
commit 17c8517abc
8 changed files with 175 additions and 184 deletions

View File

@ -3,8 +3,8 @@
#include <xcb/render.h>
#include <xcb/xcb_renderutil.h>
#include "backend.h"
#include "backend_common.h"
#include "backend/backend.h"
#include "backend/backend_common.h"
#include "kernel.h"
#include "common.h"
#include "log.h"
@ -21,13 +21,13 @@ solid_picture(session_t *ps, bool argb, double a, double r, double g, double b)
xcb_render_color_t col;
xcb_rectangle_t rect;
pixmap = x_create_pixmap(ps, argb ? 32 : 8, ps->root, 1, 1);
pixmap = x_create_pixmap(ps->c, argb ? 32 : 8, ps->root, 1, 1);
if (!pixmap)
return XCB_NONE;
pa.repeat = 1;
picture = x_create_picture_with_standard_and_pixmap(
ps, argb ? XCB_PICT_STANDARD_ARGB_32 : XCB_PICT_STANDARD_A_8, pixmap,
ps->c, argb ? XCB_PICT_STANDARD_ARGB_32 : XCB_PICT_STANDARD_A_8, pixmap,
XCB_RENDER_CP_REPEAT, &pa);
if (!picture) {
@ -194,9 +194,9 @@ bool build_shadow(session_t *ps, double opacity, const int width, const int heig
}
shadow_pixmap =
x_create_pixmap(ps, 8, ps->root, shadow_image->width, shadow_image->height);
x_create_pixmap(ps->c, 8, ps->root, shadow_image->width, shadow_image->height);
shadow_pixmap_argb =
x_create_pixmap(ps, 32, ps->root, shadow_image->width, shadow_image->height);
x_create_pixmap(ps->c, 32, ps->root, shadow_image->width, shadow_image->height);
if (!shadow_pixmap || !shadow_pixmap_argb) {
log_error("Failed to create shadow pixmaps");
@ -204,9 +204,9 @@ bool build_shadow(session_t *ps, double opacity, const int width, const int heig
}
shadow_picture = x_create_picture_with_standard_and_pixmap(
ps, XCB_PICT_STANDARD_A_8, shadow_pixmap, 0, NULL);
ps->c, XCB_PICT_STANDARD_A_8, shadow_pixmap, 0, NULL);
shadow_picture_argb = x_create_picture_with_standard_and_pixmap(
ps, XCB_PICT_STANDARD_ARGB_32, shadow_pixmap_argb, 0, NULL);
ps->c, XCB_PICT_STANDARD_ARGB_32, shadow_pixmap_argb, 0, NULL);
if (!shadow_picture || !shadow_picture_argb)
goto shadow_picture_err;

View File

@ -10,7 +10,7 @@
#include <xcb/composite.h>
#include "backend/backend.h"
#include "backend_common.h"
#include "backend/backend_common.h"
#include "common.h"
#include "config.h"
#include "log.h"
@ -135,7 +135,7 @@ static void compose(void *backend_data, session_t *ps, win *w, void *win_data, i
// Detect if the region is empty before painting
if (pixman_region32_not_empty(&reg_tmp)) {
x_set_picture_clip_region(ps, xd->back, 0, 0, &reg_tmp);
x_set_picture_clip_region(ps->c, xd->back, 0, 0, &reg_tmp);
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_OVER,
wd->shadow_pict, alpha_pict, xd->back, 0, 0, 0,
0, dst_x + w->shadow_dx, dst_y + w->shadow_dy,
@ -147,9 +147,9 @@ static void compose(void *backend_data, session_t *ps, win *w, void *win_data, i
// Clip region of rendered_pict might be set during rendering, clear it to make
// sure we get everything into the buffer
x_clear_picture_clip_region(ps, wd->rendered_pict);
x_clear_picture_clip_region(ps->c, wd->rendered_pict);
x_set_picture_clip_region(ps, xd->back, 0, 0, reg_paint);
x_set_picture_clip_region(ps->c, xd->back, 0, 0, reg_paint);
xcb_render_composite(ps->c, op, wd->rendered_pict, alpha_pict, xd->back, 0, 0, 0,
0, dst_x, dst_y, w->widthb, w->heightb);
}
@ -184,8 +184,8 @@ static bool blur(void *backend_data, session_t *ps, double opacity, const region
return false;
}
x_set_picture_clip_region(ps, tmp_picture[0], 0, 0, &clip);
x_set_picture_clip_region(ps, tmp_picture[1], 0, 0, &clip);
x_set_picture_clip_region(ps->c, tmp_picture[0], 0, 0, &clip);
x_set_picture_clip_region(ps->c, tmp_picture[1], 0, 0, &clip);
// The multipass blur implemented here is not correct, but this is what old
// compton did anyway. XXX
@ -269,14 +269,14 @@ render_win(void *backend_data, session_t *ps, win *w, void *win_data, const regi
}
// Copy the content of the window over to the buffer
x_clear_picture_clip_region(ps, wd->buffer);
x_clear_picture_clip_region(ps->c, wd->buffer);
wd->rendered_pict = wd->buffer;
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC, wd->pict, XCB_NONE,
wd->rendered_pict, 0, 0, 0, 0, 0, 0, w->widthb, w->heightb);
if (w->invert_color) {
// Handle invert color
x_set_picture_clip_region(ps, wd->rendered_pict, 0, 0, &reg_paint_local);
x_set_picture_clip_region(ps->c, wd->rendered_pict, 0, 0, &reg_paint_local);
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_DIFFERENCE, xd->white_pixel, XCB_NONE,
wd->rendered_pict, 0, 0, 0, 0, 0, 0, w->widthb, w->heightb);
@ -302,7 +302,7 @@ render_win(void *backend_data, session_t *ps, win *w, void *win_data, const regi
// Draw the frame with frame opacity
xcb_render_picture_t alpha_pict =
xd->alpha_pict[(int)(w->frame_opacity * dopacity * 255)];
x_set_picture_clip_region(ps, wd->rendered_pict, 0, 0, &frame_reg);
x_set_picture_clip_region(ps->c, wd->rendered_pict, 0, 0, &frame_reg);
// Step 2: multiply alpha value
// XXX test
@ -328,7 +328,7 @@ render_win(void *backend_data, session_t *ps, win *w, void *win_data, const regi
.height = w->heightb,
};
x_clear_picture_clip_region(ps, wd->rendered_pict);
x_clear_picture_clip_region(ps->c, wd->rendered_pict);
xcb_render_fill_rectangles(ps->c, XCB_RENDER_PICT_OP_OVER,
wd->rendered_pict, color, 1, &rect);
}
@ -350,7 +350,7 @@ static void *prepare_win(void *backend_data, session_t *ps, win *w) {
draw = w->id;
log_trace("%s %x", w->name, wd->pixmap);
wd->pict = x_create_picture_with_pictfmt_and_pixmap(ps, w->pictfmt, draw, 0, NULL);
wd->pict = x_create_picture_with_pictfmt_and_pixmap(ps->c, w->pictfmt, draw, 0, NULL);
wd->buffer = XCB_NONE;
// XXX delay allocating shadow pict until compose() will dramatical
@ -395,33 +395,33 @@ static void *init(session_t *ps) {
if (ps->overlay != XCB_NONE) {
xd->target =
x_create_picture_with_visual_and_pixmap(ps, ps->vis, ps->overlay, 0, NULL);
x_create_picture_with_visual_and_pixmap(ps->c, ps->vis, ps->overlay, 0, NULL);
xd->target_win = ps->overlay;
} else {
xcb_render_create_picture_value_list_t pa = {
.subwindowmode = XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS,
};
xd->target = x_create_picture_with_visual_and_pixmap(
ps, ps->vis, ps->root, XCB_RENDER_CP_SUBWINDOW_MODE, &pa);
ps->c, ps->vis, ps->root, XCB_RENDER_CP_SUBWINDOW_MODE, &pa);
xd->target_win = ps->root;
}
auto pictfmt = x_get_pictform_for_visual(ps, ps->vis);
auto pictfmt = x_get_pictform_for_visual(ps->c, ps->vis);
if (!pictfmt) {
log_fatal("Default visual is invalid");
abort();
}
xd->back_pixmap =
x_create_pixmap(ps, pictfmt->depth, ps->root, ps->root_width, ps->root_height);
xd->back = x_create_picture_with_pictfmt_and_pixmap(ps, pictfmt, xd->back_pixmap, 0, NULL);
x_create_pixmap(ps->c, pictfmt->depth, ps->root, ps->root_width, ps->root_height);
xd->back = x_create_picture_with_pictfmt_and_pixmap(ps->c, pictfmt, xd->back_pixmap, 0, NULL);
xcb_pixmap_t root_pixmap = x_get_root_back_pixmap(ps);
if (root_pixmap == XCB_NONE) {
xd->root_pict = solid_picture(ps, false, 1, 0.5, 0.5, 0.5);
} else {
xd->root_pict =
x_create_picture_with_visual_and_pixmap(ps, ps->vis, root_pixmap, 0, NULL);
x_create_picture_with_visual_and_pixmap(ps->c, ps->vis, root_pixmap, 0, NULL);
}
if (ps->present_exists) {
@ -462,7 +462,7 @@ static void prepare(void *backend_data, session_t *ps, const region_t *reg_paint
// Paint the root pixmap (i.e. wallpaper)
// Limit the paint area
x_set_picture_clip_region(ps, xd->back, 0, 0, reg_paint);
x_set_picture_clip_region(ps->c, xd->back, 0, 0, reg_paint);
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC, xd->root_pict, XCB_NONE,
xd->back, 0, 0, 0, 0, 0, 0, ps->root_width, ps->root_height);
@ -481,7 +481,7 @@ static void present(void *backend_data, session_t *ps) {
} else {
// compose() sets clip region, so clear it first to make
// sure we update the whole screen.
x_clear_picture_clip_region(ps, xd->back);
x_clear_picture_clip_region(ps->c, xd->back);
// TODO buffer-age-like optimization might be possible here.
// but that will require a different backend API