Tile root pixmap in the glx backend
In X, background pixmap is tiled (meaning they are repeated to filled the window) by default. So, in the glx backend, we mimic this behavior by binding the background pixmap of the root window (aka, the wallpaper) to texture that repeats. Fixes #107 Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
5fffb6f3f6
commit
edb8b38eef
|
@ -103,8 +103,8 @@ void log_add_target(struct log *l, struct log_target *tgt) {
|
||||||
l->head = tgt;
|
l->head = tgt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove a previously added log target for a log struct. If the log target was never
|
/// Remove a previously added log target for a log struct, and destroy it. If the log
|
||||||
/// added, nothing happens.
|
/// target was never added, nothing happens.
|
||||||
void log_remove_target(struct log *l, struct log_target *tgt) {
|
void log_remove_target(struct log *l, struct log_target *tgt) {
|
||||||
struct log_target *now = l->head, **prev = &l->head;
|
struct log_target *now = l->head, **prev = &l->head;
|
||||||
while (now) {
|
while (now) {
|
||||||
|
|
11
src/opengl.c
11
src/opengl.c
|
@ -496,7 +496,7 @@ glx_load_prog_main(session_t *ps,
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, xcb_pixmap_t pixmap,
|
glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, xcb_pixmap_t pixmap,
|
||||||
unsigned width, unsigned height, const struct glx_fbconfig_info *fbcfg) {
|
unsigned width, unsigned height, bool repeat, const struct glx_fbconfig_info *fbcfg) {
|
||||||
if (ps->o.backend != BKEND_GLX && ps->o.backend != BKEND_XR_GLX_HYBRID)
|
if (ps->o.backend != BKEND_GLX && ps->o.backend != BKEND_XR_GLX_HYBRID)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -604,8 +604,13 @@ glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, xcb_pixmap_t pixmap,
|
||||||
|
|
||||||
glTexParameteri(ptex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(ptex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(ptex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(ptex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(ptex->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
if (repeat) {
|
||||||
glTexParameteri(ptex->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(ptex->target, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
glTexParameteri(ptex->target, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
} else {
|
||||||
|
glTexParameteri(ptex->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(ptex->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
}
|
||||||
|
|
||||||
glBindTexture(ptex->target, 0);
|
glBindTexture(ptex->target, 0);
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ glx_load_prog_main(session_t *ps,
|
||||||
|
|
||||||
bool
|
bool
|
||||||
glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, xcb_pixmap_t pixmap,
|
glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, xcb_pixmap_t pixmap,
|
||||||
unsigned width, unsigned height, const struct glx_fbconfig_info *);
|
unsigned width, unsigned height, bool repeat, const struct glx_fbconfig_info *);
|
||||||
|
|
||||||
void
|
void
|
||||||
glx_release_pixmap(session_t *ps, glx_texture_t *ptex);
|
glx_release_pixmap(session_t *ps, glx_texture_t *ptex);
|
||||||
|
|
19
src/render.c
19
src/render.c
|
@ -35,8 +35,9 @@
|
||||||
/**
|
/**
|
||||||
* Bind texture in paint_t if we are using GLX backend.
|
* Bind texture in paint_t if we are using GLX backend.
|
||||||
*/
|
*/
|
||||||
static inline bool paint_bind_tex(session_t *ps, paint_t *ppaint, unsigned wid, unsigned hei,
|
static inline bool
|
||||||
int depth, xcb_visualid_t visual, bool force) {
|
paint_bind_tex(session_t *ps, paint_t *ppaint, unsigned wid, unsigned hei, bool repeat,
|
||||||
|
int depth, xcb_visualid_t visual, bool force) {
|
||||||
#ifdef CONFIG_OPENGL
|
#ifdef CONFIG_OPENGL
|
||||||
// XXX This is a mess. But this will go away after the backend refactor.
|
// XXX This is a mess. But this will go away after the backend refactor.
|
||||||
static thread_local struct glx_fbconfig_info *argb_fbconfig = NULL;
|
static thread_local struct glx_fbconfig_info *argb_fbconfig = NULL;
|
||||||
|
@ -82,7 +83,8 @@ static inline bool paint_bind_tex(session_t *ps, paint_t *ppaint, unsigned wid,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force || !glx_tex_binded(ppaint->ptex, ppaint->pixmap))
|
if (force || !glx_tex_binded(ppaint->ptex, ppaint->pixmap))
|
||||||
return glx_bind_pixmap(ps, &ppaint->ptex, ppaint->pixmap, wid, hei, fbcfg);
|
return glx_bind_pixmap(ps, &ppaint->ptex, ppaint->pixmap, wid, hei,
|
||||||
|
repeat, fbcfg);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -257,7 +259,7 @@ void paint_one(session_t *ps, win *w, const region_t *reg_paint) {
|
||||||
// Let glx_bind_pixmap() determine pixmap size, because if the user
|
// Let glx_bind_pixmap() determine pixmap size, because if the user
|
||||||
// is resizing windows, the width and height we get may not be up-to-date,
|
// is resizing windows, the width and height we get may not be up-to-date,
|
||||||
// causing the jittering issue M4he reported in #7.
|
// causing the jittering issue M4he reported in #7.
|
||||||
if (!paint_bind_tex(ps, &w->paint, 0, 0, 0, w->a.visual,
|
if (!paint_bind_tex(ps, &w->paint, 0, 0, false, 0, w->a.visual,
|
||||||
(!ps->o.glx_no_rebind_pixmap && w->pixmap_damaged))) {
|
(!ps->o.glx_no_rebind_pixmap && w->pixmap_damaged))) {
|
||||||
log_error("Failed to bind texture for window %#010x.", w->id);
|
log_error("Failed to bind texture for window %#010x.", w->id);
|
||||||
}
|
}
|
||||||
|
@ -474,7 +476,7 @@ static bool get_root_tile(session_t *ps) {
|
||||||
ps->root_tile_paint.pixmap = pixmap;
|
ps->root_tile_paint.pixmap = pixmap;
|
||||||
#ifdef CONFIG_OPENGL
|
#ifdef CONFIG_OPENGL
|
||||||
if (BKEND_GLX == ps->o.backend)
|
if (BKEND_GLX == ps->o.backend)
|
||||||
return paint_bind_tex(ps, &ps->root_tile_paint, 0, 0, 0, ps->vis, false);
|
return paint_bind_tex(ps, &ps->root_tile_paint, 0, 0, true, 0, ps->vis, false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -571,7 +573,7 @@ shadow_picture_err:
|
||||||
*/
|
*/
|
||||||
static inline void win_paint_shadow(session_t *ps, win *w, region_t *reg_paint) {
|
static inline void win_paint_shadow(session_t *ps, win *w, region_t *reg_paint) {
|
||||||
// Bind shadow pixmap to GLX texture if needed
|
// Bind shadow pixmap to GLX texture if needed
|
||||||
paint_bind_tex(ps, &w->shadow_paint, 0, 0, 32, 0, false);
|
paint_bind_tex(ps, &w->shadow_paint, 0, 0, false, 32, 0, false);
|
||||||
|
|
||||||
if (!paint_isvalid(ps, &w->shadow_paint)) {
|
if (!paint_isvalid(ps, &w->shadow_paint)) {
|
||||||
log_error("Window %#010x is missing shadow data.", w->id);
|
log_error("Window %#010x is missing shadow data.", w->id);
|
||||||
|
@ -985,8 +987,7 @@ void paint_all(session_t *ps, win *const t, bool ignore_damage) {
|
||||||
|
|
||||||
// First we create a new picture, and copy content from the buffer
|
// First we create a new picture, and copy content from the buffer
|
||||||
// to it
|
// to it
|
||||||
auto pictfmt =
|
auto pictfmt = x_get_pictform_for_visual(ps->c, ps->vis);
|
||||||
x_get_pictform_for_visual(ps->c, ps->vis);
|
|
||||||
xcb_render_picture_t new_pict = x_create_picture_with_pictfmt(
|
xcb_render_picture_t new_pict = x_create_picture_with_pictfmt(
|
||||||
ps, ps->root_width, ps->root_height, pictfmt, 0, NULL);
|
ps, ps->root_width, ps->root_height, pictfmt, 0, NULL);
|
||||||
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC,
|
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC,
|
||||||
|
@ -1021,7 +1022,7 @@ void paint_all(session_t *ps, win *const t, bool ignore_damage) {
|
||||||
glFlush();
|
glFlush();
|
||||||
glXWaitX();
|
glXWaitX();
|
||||||
assert(ps->tgt_buffer.pixmap);
|
assert(ps->tgt_buffer.pixmap);
|
||||||
paint_bind_tex(ps, &ps->tgt_buffer, ps->root_width, ps->root_height,
|
paint_bind_tex(ps, &ps->tgt_buffer, ps->root_width, ps->root_height, false,
|
||||||
ps->depth, ps->vis, !ps->o.glx_no_rebind_pixmap);
|
ps->depth, ps->vis, !ps->o.glx_no_rebind_pixmap);
|
||||||
if (ps->o.vsync_use_glfinish)
|
if (ps->o.vsync_use_glfinish)
|
||||||
glFinish();
|
glFinish();
|
||||||
|
|
Loading…
Reference in New Issue