backend: add interfaces for readiness reporting

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-04-27 15:07:23 +01:00
parent f50428a18b
commit be673f93c6
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
5 changed files with 25 additions and 6 deletions

View File

@ -5,8 +5,8 @@
#include <stdbool.h>
#include "driver.h"
#include "compiler.h"
#include "driver.h"
#include "kernel.h"
#include "region.h"
#include "x.h"
@ -14,15 +14,22 @@
typedef struct session session_t;
struct managed_win;
struct ev_loop;
struct backend_operations;
typedef struct backend_base {
struct backend_operations *ops;
xcb_connection_t *c;
xcb_window_t root;
struct ev_loop *loop;
/// Whether the backend can accept new render request at the moment
bool busy;
// ...
} backend_t;
typedef void (*backend_ready_callback_t)(void *);
enum image_operations {
// Invert the color of the entire image, `reg_op` ignored
IMAGE_OP_INVERT_COLOR_ALL,
@ -177,6 +184,9 @@ struct backend_operations {
// =========== Hooks ============
/// Let the backend hook into the event handling queue
void (*set_ready_callback)(backend_t *, backend_ready_callback_t cb);
/// Called right after compton has handled its events.
void (*handle_events)(backend_t *);
// =========== Misc ============
/// Return the driver that is been used by the backend
enum driver (*detect_driver)(backend_t *backend_data);

View File

@ -279,3 +279,11 @@ default_backend_render_shadow(backend_t *backend_data, int width, int height,
xcb_render_free_picture(backend_data->c, pict);
return ret;
}
void init_backend_base(struct backend_base *base, session_t *ps) {
base->c = ps->c;
base->loop = ps->loop;
base->root = ps->root;
base->busy = false;
base->ops = NULL;
}

View File

@ -13,6 +13,7 @@ typedef struct session session_t;
typedef struct win win;
typedef struct conv conv;
typedef struct backend_base backend_t;
struct backend_operations;
bool build_shadow(xcb_connection_t *, xcb_drawable_t, double opacity, int width,
int height, const conv *kernel, xcb_render_picture_t shadow_pixel,
@ -35,3 +36,5 @@ bool default_is_frame_transparent(void *, win *, void *);
void *
default_backend_render_shadow(backend_t *backend_data, int width, int height,
const conv *kernel, double r, double g, double b, double a);
void init_backend_base(struct backend_base *base, session_t *ps);

View File

@ -218,8 +218,8 @@ static backend_t *glx_init(session_t *ps) {
bool success = false;
glxext_init(ps->dpy, ps->scr);
auto gd = ccalloc(1, struct _glx_data);
gd->gl.base.c = ps->c;
gd->gl.base.root = ps->root;
init_backend_base(&gd->gl.base, ps);
gd->display = ps->dpy;
gd->screen = ps->scr;
gd->target_win = ps->overlay != XCB_NONE ? ps->overlay : ps->root;

View File

@ -474,9 +474,7 @@ static void *copy(backend_t *base, const void *image, const region_t *reg) {
backend_t *backend_xrender_init(session_t *ps) {
auto xd = ccalloc(1, struct _xrender_data);
xd->base.c = ps->c;
xd->base.root = ps->root;
init_backend_base(&xd->base, ps);
for (int i = 0; i < 256; ++i) {
double o = (double)i / 255.0;