调整壁纸绘制方案
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "app.h"
|
||||
#include "utils.h"
|
||||
#include "window.h"
|
||||
#include "xcb-private.h"
|
||||
|
||||
xcb_connection_t *conn = NULL;
|
||||
@@ -150,6 +151,52 @@ rect_size_t *get_screen_size(void) {
|
||||
return size;
|
||||
}
|
||||
|
||||
bar_cairo_params_t *prepare_wallpaper_surface_params(void) {
|
||||
uint32_t width = screen->width_in_pixels;
|
||||
uint32_t height = screen->height_in_pixels;
|
||||
xcb_window_t root = screen->root;
|
||||
|
||||
visual_t *v = get_xcb_visual(false);
|
||||
|
||||
static xcb_pixmap_t pixmap = XCB_PIXMAP_NONE;
|
||||
if (pixmap != XCB_PIXMAP_NONE) {
|
||||
xcb_kill_client(conn, pixmap);
|
||||
xcb_free_pixmap(conn, pixmap);
|
||||
}
|
||||
|
||||
pixmap = xcb_generate_id(conn);
|
||||
xcb_create_pixmap(conn, v->depth, pixmap, root, width, height);
|
||||
xcb_gcontext_t gc = xcb_generate_id(conn);
|
||||
xcb_create_gc(conn, gc, pixmap, 0, NULL);
|
||||
xcb_change_window_attributes_value_list_t value_list = {
|
||||
.background_pixmap = pixmap,
|
||||
};
|
||||
xcb_change_window_attributes_aux(conn, root, XCB_CW_BACK_PIXMAP, &value_list);
|
||||
|
||||
/* 兼容合成器,不设置若开启合成器壁纸会不显示 */
|
||||
uint8_t mode = XCB_PROP_MODE_REPLACE;
|
||||
xcb_atom_t atom = get_xcb_atom(atom__xrootpmap_id);
|
||||
xcb_change_property(conn, mode, root, atom, XCB_ATOM_PIXMAP, 32, 1, &pixmap);
|
||||
atom = get_xcb_atom(atom_esetroot_pmap_id);
|
||||
xcb_change_property(conn, mode, root, atom, XCB_ATOM_PIXMAP, 32, 1, &pixmap);
|
||||
|
||||
xcb_clear_area(conn, 0, root, 0, 0, width, height);
|
||||
xcb_free_gc(conn, gc);
|
||||
xcb_flush(conn);
|
||||
|
||||
bar_cairo_params_t *p = ecalloc(1, sizeof(bar_cairo_params_t));
|
||||
p->conn = conn;
|
||||
p->visual = v->visual;
|
||||
p->window = pixmap;
|
||||
free(v);
|
||||
return p;
|
||||
}
|
||||
|
||||
void refresh_root_window(void) {
|
||||
xcb_clear_area(conn, 0, screen->root, 0, 0, 0, 0);
|
||||
xcb_flush(conn);
|
||||
}
|
||||
|
||||
void set_wallpaper(uint32_t *wallpaper_data) {
|
||||
uint32_t width = screen->width_in_pixels;
|
||||
uint32_t height = screen->height_in_pixels;
|
||||
|
||||
Reference in New Issue
Block a user