mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-02 03:45:58 +01:00
backend/x11: Rename xcb_conn to xcb
When the Xlib connection is removed, this _conn suffix is going to be pointless. I'm removing this preemtively for that.
This commit is contained in:
parent
4aff85cc8e
commit
51a283cbe4
4 changed files with 34 additions and 34 deletions
|
@ -81,7 +81,7 @@ static int x11_event(int fd, uint32_t mask, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_generic_event_t *e;
|
xcb_generic_event_t *e;
|
||||||
while ((e = xcb_poll_for_event(x11->xcb_conn))) {
|
while ((e = xcb_poll_for_event(x11->xcb))) {
|
||||||
handle_x11_event(x11, e);
|
handle_x11_event(x11, e);
|
||||||
free(e);
|
free(e);
|
||||||
}
|
}
|
||||||
|
@ -123,13 +123,13 @@ static bool backend_start(struct wlr_backend *backend) {
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(atom) / sizeof(atom[0]); ++i) {
|
for (size_t i = 0; i < sizeof(atom) / sizeof(atom[0]); ++i) {
|
||||||
atom[i].cookie = xcb_intern_atom(x11->xcb_conn,
|
atom[i].cookie = xcb_intern_atom(x11->xcb,
|
||||||
true, strlen(atom[i].name), atom[i].name);
|
true, strlen(atom[i].name), atom[i].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(atom) / sizeof(atom[0]); ++i) {
|
for (size_t i = 0; i < sizeof(atom) / sizeof(atom[0]); ++i) {
|
||||||
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(
|
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(
|
||||||
x11->xcb_conn, atom[i].cookie, NULL);
|
x11->xcb, atom[i].cookie, NULL);
|
||||||
|
|
||||||
if (reply) {
|
if (reply) {
|
||||||
*atom[i].atom = reply->atom;
|
*atom[i].atom = reply->atom;
|
||||||
|
@ -140,29 +140,29 @@ static bool backend_start(struct wlr_backend *backend) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a blank cursor
|
// create a blank cursor
|
||||||
xcb_pixmap_t pix = xcb_generate_id(x11->xcb_conn);
|
xcb_pixmap_t pix = xcb_generate_id(x11->xcb);
|
||||||
xcb_create_pixmap(x11->xcb_conn, 1, pix, x11->screen->root, 1, 1);
|
xcb_create_pixmap(x11->xcb, 1, pix, x11->screen->root, 1, 1);
|
||||||
|
|
||||||
x11->cursor = xcb_generate_id(x11->xcb_conn);
|
x11->cursor = xcb_generate_id(x11->xcb);
|
||||||
xcb_create_cursor(x11->xcb_conn, x11->cursor, pix, pix, 0, 0, 0, 0, 0, 0,
|
xcb_create_cursor(x11->xcb, x11->cursor, pix, pix, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0);
|
0, 0);
|
||||||
xcb_free_pixmap(x11->xcb_conn, pix);
|
xcb_free_pixmap(x11->xcb, pix);
|
||||||
|
|
||||||
#if WLR_HAS_XCB_XKB
|
#if WLR_HAS_XCB_XKB
|
||||||
const xcb_query_extension_reply_t *reply =
|
const xcb_query_extension_reply_t *reply =
|
||||||
xcb_get_extension_data(x11->xcb_conn, &xcb_xkb_id);
|
xcb_get_extension_data(x11->xcb, &xcb_xkb_id);
|
||||||
if (reply != NULL && reply->present) {
|
if (reply != NULL && reply->present) {
|
||||||
x11->xkb_base_event = reply->first_event;
|
x11->xkb_base_event = reply->first_event;
|
||||||
x11->xkb_base_error = reply->first_error;
|
x11->xkb_base_error = reply->first_error;
|
||||||
|
|
||||||
xcb_xkb_use_extension_cookie_t cookie = xcb_xkb_use_extension(
|
xcb_xkb_use_extension_cookie_t cookie = xcb_xkb_use_extension(
|
||||||
x11->xcb_conn, XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION);
|
x11->xcb, XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION);
|
||||||
xcb_xkb_use_extension_reply_t *reply =
|
xcb_xkb_use_extension_reply_t *reply =
|
||||||
xcb_xkb_use_extension_reply(x11->xcb_conn, cookie, NULL);
|
xcb_xkb_use_extension_reply(x11->xcb, cookie, NULL);
|
||||||
if (reply != NULL && reply->supported) {
|
if (reply != NULL && reply->supported) {
|
||||||
x11->xkb_supported = true;
|
x11->xkb_supported = true;
|
||||||
|
|
||||||
xcb_xkb_select_events(x11->xcb_conn,
|
xcb_xkb_select_events(x11->xcb,
|
||||||
XCB_XKB_ID_USE_CORE_KBD,
|
XCB_XKB_ID_USE_CORE_KBD,
|
||||||
XCB_XKB_EVENT_TYPE_STATE_NOTIFY,
|
XCB_XKB_EVENT_TYPE_STATE_NOTIFY,
|
||||||
0,
|
0,
|
||||||
|
@ -210,7 +210,7 @@ static void backend_destroy(struct wlr_backend *backend) {
|
||||||
wlr_egl_finish(&x11->egl);
|
wlr_egl_finish(&x11->egl);
|
||||||
|
|
||||||
if (x11->cursor) {
|
if (x11->cursor) {
|
||||||
xcb_free_cursor(x11->xcb_conn, x11->cursor);
|
xcb_free_cursor(x11->xcb, x11->cursor);
|
||||||
}
|
}
|
||||||
if (x11->xlib_conn) {
|
if (x11->xlib_conn) {
|
||||||
XCloseDisplay(x11->xlib_conn);
|
XCloseDisplay(x11->xlib_conn);
|
||||||
|
@ -258,15 +258,15 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
||||||
goto error_x11;
|
goto error_x11;
|
||||||
}
|
}
|
||||||
|
|
||||||
x11->xcb_conn = XGetXCBConnection(x11->xlib_conn);
|
x11->xcb = XGetXCBConnection(x11->xlib_conn);
|
||||||
if (!x11->xcb_conn || xcb_connection_has_error(x11->xcb_conn)) {
|
if (!x11->xcb || xcb_connection_has_error(x11->xcb)) {
|
||||||
wlr_log(WLR_ERROR, "Failed to open xcb connection");
|
wlr_log(WLR_ERROR, "Failed to open xcb connection");
|
||||||
goto error_display;
|
goto error_display;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSetEventQueueOwner(x11->xlib_conn, XCBOwnsEventQueue);
|
XSetEventQueueOwner(x11->xlib_conn, XCBOwnsEventQueue);
|
||||||
|
|
||||||
int fd = xcb_get_file_descriptor(x11->xcb_conn);
|
int fd = xcb_get_file_descriptor(x11->xcb);
|
||||||
struct wl_event_loop *ev = wl_display_get_event_loop(display);
|
struct wl_event_loop *ev = wl_display_get_event_loop(display);
|
||||||
uint32_t events = WL_EVENT_READABLE | WL_EVENT_ERROR | WL_EVENT_HANGUP;
|
uint32_t events = WL_EVENT_READABLE | WL_EVENT_ERROR | WL_EVENT_HANGUP;
|
||||||
x11->event_source = wl_event_loop_add_fd(ev, fd, events, x11_event, x11);
|
x11->event_source = wl_event_loop_add_fd(ev, fd, events, x11_event, x11);
|
||||||
|
@ -276,7 +276,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
||||||
}
|
}
|
||||||
wl_event_source_check(x11->event_source);
|
wl_event_source_check(x11->event_source);
|
||||||
|
|
||||||
x11->screen = xcb_setup_roots_iterator(xcb_get_setup(x11->xcb_conn)).data;
|
x11->screen = xcb_setup_roots_iterator(xcb_get_setup(x11->xcb)).data;
|
||||||
|
|
||||||
if (!create_renderer_func) {
|
if (!create_renderer_func) {
|
||||||
create_renderer_func = wlr_renderer_autocreate;
|
create_renderer_func = wlr_renderer_autocreate;
|
||||||
|
|
|
@ -166,9 +166,9 @@ void update_x11_pointer_position(struct wlr_x11_output *output,
|
||||||
struct wlr_x11_backend *x11 = output->x11;
|
struct wlr_x11_backend *x11 = output->x11;
|
||||||
|
|
||||||
xcb_query_pointer_cookie_t cookie =
|
xcb_query_pointer_cookie_t cookie =
|
||||||
xcb_query_pointer(x11->xcb_conn, output->win);
|
xcb_query_pointer(x11->xcb, output->win);
|
||||||
xcb_query_pointer_reply_t *reply =
|
xcb_query_pointer_reply_t *reply =
|
||||||
xcb_query_pointer_reply(x11->xcb_conn, cookie, NULL);
|
xcb_query_pointer_reply(x11->xcb, cookie, NULL);
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@ static int signal_frame(void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_xcb_setup(struct wlr_output *output,
|
static void parse_xcb_setup(struct wlr_output *output,
|
||||||
xcb_connection_t *xcb_conn) {
|
xcb_connection_t *xcb) {
|
||||||
const xcb_setup_t *xcb_setup = xcb_get_setup(xcb_conn);
|
const xcb_setup_t *xcb_setup = xcb_get_setup(xcb);
|
||||||
|
|
||||||
snprintf(output->make, sizeof(output->make), "%.*s",
|
snprintf(output->make, sizeof(output->make), "%.*s",
|
||||||
xcb_setup_vendor_length(xcb_setup),
|
xcb_setup_vendor_length(xcb_setup),
|
||||||
|
@ -55,11 +55,11 @@ static bool output_set_custom_mode(struct wlr_output *wlr_output,
|
||||||
|
|
||||||
const uint32_t values[] = { width, height };
|
const uint32_t values[] = { width, height };
|
||||||
xcb_void_cookie_t cookie = xcb_configure_window_checked(
|
xcb_void_cookie_t cookie = xcb_configure_window_checked(
|
||||||
x11->xcb_conn, output->win,
|
x11->xcb, output->win,
|
||||||
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
|
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
|
||||||
|
|
||||||
xcb_generic_error_t *error;
|
xcb_generic_error_t *error;
|
||||||
if ((error = xcb_request_check(x11->xcb_conn, cookie))) {
|
if ((error = xcb_request_check(x11->xcb, cookie))) {
|
||||||
wlr_log(WLR_ERROR, "Could not set window size to %dx%d\n",
|
wlr_log(WLR_ERROR, "Could not set window size to %dx%d\n",
|
||||||
width, height);
|
width, height);
|
||||||
free(error);
|
free(error);
|
||||||
|
@ -84,8 +84,8 @@ static void output_destroy(struct wlr_output *wlr_output) {
|
||||||
wl_list_remove(&output->link);
|
wl_list_remove(&output->link);
|
||||||
wl_event_source_remove(output->frame_timer);
|
wl_event_source_remove(output->frame_timer);
|
||||||
wlr_egl_destroy_surface(&x11->egl, output->surf);
|
wlr_egl_destroy_surface(&x11->egl, output->surf);
|
||||||
xcb_destroy_window(x11->xcb_conn, output->win);
|
xcb_destroy_window(x11->xcb, output->win);
|
||||||
xcb_flush(x11->xcb_conn);
|
xcb_flush(x11->xcb);
|
||||||
free(output);
|
free(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
||||||
|
|
||||||
snprintf(wlr_output->name, sizeof(wlr_output->name), "X11-%d",
|
snprintf(wlr_output->name, sizeof(wlr_output->name), "X11-%d",
|
||||||
wl_list_length(&x11->outputs) + 1);
|
wl_list_length(&x11->outputs) + 1);
|
||||||
parse_xcb_setup(wlr_output, x11->xcb_conn);
|
parse_xcb_setup(wlr_output, x11->xcb);
|
||||||
|
|
||||||
uint32_t mask = XCB_CW_EVENT_MASK;
|
uint32_t mask = XCB_CW_EVENT_MASK;
|
||||||
uint32_t values[] = {
|
uint32_t values[] = {
|
||||||
|
@ -152,8 +152,8 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
||||||
XCB_EVENT_MASK_POINTER_MOTION |
|
XCB_EVENT_MASK_POINTER_MOTION |
|
||||||
XCB_EVENT_MASK_STRUCTURE_NOTIFY
|
XCB_EVENT_MASK_STRUCTURE_NOTIFY
|
||||||
};
|
};
|
||||||
output->win = xcb_generate_id(x11->xcb_conn);
|
output->win = xcb_generate_id(x11->xcb);
|
||||||
xcb_create_window(x11->xcb_conn, XCB_COPY_FROM_PARENT, output->win,
|
xcb_create_window(x11->xcb, XCB_COPY_FROM_PARENT, output->win,
|
||||||
x11->screen->root, 0, 0, wlr_output->width, wlr_output->height, 1,
|
x11->screen->root, 0, 0, wlr_output->width, wlr_output->height, 1,
|
||||||
XCB_WINDOW_CLASS_INPUT_OUTPUT, x11->screen->root_visual, mask, values);
|
XCB_WINDOW_CLASS_INPUT_OUTPUT, x11->screen->root_visual, mask, values);
|
||||||
|
|
||||||
|
@ -164,23 +164,23 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_change_property(x11->xcb_conn, XCB_PROP_MODE_REPLACE, output->win,
|
xcb_change_property(x11->xcb, XCB_PROP_MODE_REPLACE, output->win,
|
||||||
x11->atoms.wm_protocols, XCB_ATOM_ATOM, 32, 1,
|
x11->atoms.wm_protocols, XCB_ATOM_ATOM, 32, 1,
|
||||||
&x11->atoms.wm_delete_window);
|
&x11->atoms.wm_delete_window);
|
||||||
|
|
||||||
char title[32];
|
char title[32];
|
||||||
if (snprintf(title, sizeof(title), "wlroots - %s", wlr_output->name)) {
|
if (snprintf(title, sizeof(title), "wlroots - %s", wlr_output->name)) {
|
||||||
xcb_change_property(x11->xcb_conn, XCB_PROP_MODE_REPLACE, output->win,
|
xcb_change_property(x11->xcb, XCB_PROP_MODE_REPLACE, output->win,
|
||||||
x11->atoms.net_wm_name, x11->atoms.utf8_string, 8,
|
x11->atoms.net_wm_name, x11->atoms.utf8_string, 8,
|
||||||
strlen(title), title);
|
strlen(title), title);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t cursor_values[] = { x11->cursor };
|
uint32_t cursor_values[] = { x11->cursor };
|
||||||
xcb_change_window_attributes(x11->xcb_conn, output->win, XCB_CW_CURSOR,
|
xcb_change_window_attributes(x11->xcb, output->win, XCB_CW_CURSOR,
|
||||||
cursor_values);
|
cursor_values);
|
||||||
|
|
||||||
xcb_map_window(x11->xcb_conn, output->win);
|
xcb_map_window(x11->xcb, output->win);
|
||||||
xcb_flush(x11->xcb_conn);
|
xcb_flush(x11->xcb);
|
||||||
|
|
||||||
struct wl_event_loop *ev = wl_display_get_event_loop(x11->wl_display);
|
struct wl_event_loop *ev = wl_display_get_event_loop(x11->wl_display);
|
||||||
output->frame_timer = wl_event_loop_add_timer(ev, signal_frame, output);
|
output->frame_timer = wl_event_loop_add_timer(ev, signal_frame, output);
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct wlr_x11_backend {
|
||||||
bool started;
|
bool started;
|
||||||
|
|
||||||
Display *xlib_conn;
|
Display *xlib_conn;
|
||||||
xcb_connection_t *xcb_conn;
|
xcb_connection_t *xcb;
|
||||||
xcb_screen_t *screen;
|
xcb_screen_t *screen;
|
||||||
|
|
||||||
size_t requested_outputs;
|
size_t requested_outputs;
|
||||||
|
|
Loading…
Reference in a new issue