xwm: create colormap and visual depth detection

master
Tony Crisci 7 years ago
parent be297d9d14
commit 325def3841

@ -102,6 +102,8 @@ struct wlr_xwayland_surface {
bool maximized_vert; bool maximized_vert;
bool maximized_horz; bool maximized_horz;
bool has_alpha;
struct { struct {
struct wl_signal destroy; struct wl_signal destroy;
struct wl_signal request_configure; struct wl_signal request_configure;

@ -64,6 +64,9 @@ static struct wlr_xwayland_surface *wlr_xwayland_surface_create(
return NULL; return NULL;
} }
xcb_get_geometry_cookie_t geometry_cookie =
xcb_get_geometry(xwm->xcb_conn, window_id);
uint32_t values[1]; uint32_t values[1];
values[0] = values[0] =
XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_FOCUS_CHANGE |
@ -92,6 +95,16 @@ static struct wlr_xwayland_surface *wlr_xwayland_surface_create(
wl_signal_init(&surface->events.set_parent); wl_signal_init(&surface->events.set_parent);
wl_signal_init(&surface->events.set_pid); wl_signal_init(&surface->events.set_pid);
wl_signal_init(&surface->events.set_window_type); wl_signal_init(&surface->events.set_window_type);
xcb_get_geometry_reply_t *geometry_reply =
xcb_get_geometry_reply(xwm->xcb_conn, geometry_cookie, NULL);
if (geometry_reply != NULL) {
surface->has_alpha = geometry_reply->depth == 32;
}
free(geometry_reply);
return surface; return surface;
} }
@ -193,10 +206,6 @@ static void wlr_xwayland_surface_destroy(struct wlr_xwayland_surface *surface) {
wl_list_remove(&surface->unpaired_link); wl_list_remove(&surface->unpaired_link);
} }
for (size_t i = 0; i < surface->state->length; i++) {
free(surface->state->items[i]);
}
if (surface->surface) { if (surface->surface) {
wl_list_remove(&surface->surface_destroy.link); wl_list_remove(&surface->surface_destroy.link);
wl_list_remove(&surface->surface_commit.link); wl_list_remove(&surface->surface_commit.link);
@ -1140,6 +1149,35 @@ static void xwm_create_wm_window(struct wlr_xwm *xwm) {
XCB_CURRENT_TIME); XCB_CURRENT_TIME);
} }
// TODO use me to support 32 bit color somehow
static void xwm_get_visual_and_colormap(struct wlr_xwm *xwm) {
xcb_depth_iterator_t d_iter;
xcb_visualtype_iterator_t vt_iter;
xcb_visualtype_t *visualtype;
d_iter = xcb_screen_allowed_depths_iterator(xwm->screen);
visualtype = NULL;
while (d_iter.rem > 0) {
if (d_iter.data->depth == 32) {
vt_iter = xcb_depth_visuals_iterator(d_iter.data);
visualtype = vt_iter.data;
break;
}
xcb_depth_next(&d_iter);
}
if (visualtype == NULL) {
wlr_log(L_DEBUG, "no 32 bit visualtype\n");
return;
}
xwm->visual_id = visualtype->visual_id;
xwm->colormap = xcb_generate_id(xwm->xcb_conn);
xcb_create_colormap_checked(xwm->xcb_conn, XCB_COLORMAP_ALLOC_NONE,
xwm->colormap, xwm->screen->root, xwm->visual_id);
}
struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) {
struct wlr_xwm *xwm = calloc(1, sizeof(struct wlr_xwm)); struct wlr_xwm *xwm = calloc(1, sizeof(struct wlr_xwm));
if (xwm == NULL) { if (xwm == NULL) {
@ -1175,6 +1213,7 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) {
wl_event_source_check(xwm->event_source); wl_event_source_check(xwm->event_source);
xwm_get_resources(xwm); xwm_get_resources(xwm);
xwm_get_visual_and_colormap(xwm);
uint32_t values[1]; uint32_t values[1];
values[0] = values[0] =

@ -47,6 +47,8 @@ struct wlr_xwm {
xcb_connection_t *xcb_conn; xcb_connection_t *xcb_conn;
xcb_screen_t *screen; xcb_screen_t *screen;
xcb_window_t window; xcb_window_t window;
xcb_visualid_t visual_id;
xcb_colormap_t colormap;
struct wlr_xwayland_surface *focus_surface; struct wlr_xwayland_surface *focus_surface;

Loading…
Cancel
Save