mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 04:45:58 +01:00
backend/x11: take wl_event_loop instead of wl_display
This commit is contained in:
parent
ed0bba581b
commit
b62ac611c8
5 changed files with 14 additions and 16 deletions
|
@ -211,7 +211,8 @@ static struct wlr_backend *attempt_wl_backend(struct wl_display *display) {
|
|||
static struct wlr_backend *attempt_x11_backend(struct wl_display *display,
|
||||
const char *x11_display) {
|
||||
#if WLR_HAS_X11_BACKEND
|
||||
struct wlr_backend *backend = wlr_x11_backend_create(display, x11_display);
|
||||
struct wl_event_loop *loop = wl_display_get_event_loop(display);
|
||||
struct wlr_backend *backend = wlr_x11_backend_create(loop, x11_display);
|
||||
if (backend == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ static void backend_destroy(struct wlr_backend *backend) {
|
|||
if (x11->event_source) {
|
||||
wl_event_source_remove(x11->event_source);
|
||||
}
|
||||
wl_list_remove(&x11->display_destroy.link);
|
||||
wl_list_remove(&x11->event_loop_destroy.link);
|
||||
|
||||
wlr_drm_format_set_finish(&x11->primary_dri3_formats);
|
||||
wlr_drm_format_set_finish(&x11->primary_shm_formats);
|
||||
|
@ -230,9 +230,8 @@ bool wlr_backend_is_x11(struct wlr_backend *backend) {
|
|||
return backend->impl == &backend_impl;
|
||||
}
|
||||
|
||||
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||
struct wlr_x11_backend *x11 =
|
||||
wl_container_of(listener, x11, display_destroy);
|
||||
static void handle_event_loop_destroy(struct wl_listener *listener, void *data) {
|
||||
struct wlr_x11_backend *x11 = wl_container_of(listener, x11, event_loop_destroy);
|
||||
backend_destroy(&x11->backend);
|
||||
}
|
||||
|
||||
|
@ -391,7 +390,7 @@ static void x11_get_argb32(struct wlr_x11_backend *x11) {
|
|||
free(reply);
|
||||
}
|
||||
|
||||
struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
||||
struct wlr_backend *wlr_x11_backend_create(struct wl_event_loop *loop,
|
||||
const char *x11_display) {
|
||||
wlr_log(WLR_INFO, "Creating X11 backend");
|
||||
|
||||
|
@ -401,7 +400,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
|||
}
|
||||
|
||||
wlr_backend_init(&x11->backend, &backend_impl);
|
||||
x11->wl_display = display;
|
||||
x11->event_loop = loop;
|
||||
wl_list_init(&x11->outputs);
|
||||
|
||||
x11->xcb = xcb_connect(x11_display, NULL);
|
||||
|
@ -561,9 +560,8 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
|||
free(xi_reply);
|
||||
|
||||
int fd = xcb_get_file_descriptor(x11->xcb);
|
||||
struct wl_event_loop *ev = wl_display_get_event_loop(display);
|
||||
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(loop, fd, events, x11_event, x11);
|
||||
if (!x11->event_source) {
|
||||
wlr_log(WLR_ERROR, "Could not create event source");
|
||||
goto error_display;
|
||||
|
@ -644,8 +642,8 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
|||
wlr_keyboard_init(&x11->keyboard, &x11_keyboard_impl,
|
||||
x11_keyboard_impl.name);
|
||||
|
||||
x11->display_destroy.notify = handle_display_destroy;
|
||||
wl_display_add_destroy_listener(display, &x11->display_destroy);
|
||||
x11->event_loop_destroy.notify = handle_event_loop_destroy;
|
||||
wl_event_loop_add_destroy_listener(loop, &x11->event_loop_destroy);
|
||||
|
||||
// Create an empty pixmap to be used as the cursor. The
|
||||
// default GC foreground is 0, and that is what it will be
|
||||
|
|
|
@ -575,8 +575,7 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
|||
wlr_output_state_init(&state);
|
||||
wlr_output_state_set_custom_mode(&state, 1024, 768, 0);
|
||||
|
||||
wlr_output_init(wlr_output, &x11->backend, &output_impl,
|
||||
wl_display_get_event_loop(x11->wl_display), &state);
|
||||
wlr_output_init(wlr_output, &x11->backend, &output_impl, x11->event_loop, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
||||
size_t output_num = ++last_output_num;
|
||||
|
|
|
@ -62,7 +62,7 @@ struct wlr_x11_touchpoint {
|
|||
|
||||
struct wlr_x11_backend {
|
||||
struct wlr_backend backend;
|
||||
struct wl_display *wl_display;
|
||||
struct wl_event_loop *event_loop;
|
||||
bool started;
|
||||
|
||||
xcb_connection_t *xcb;
|
||||
|
@ -108,7 +108,7 @@ struct wlr_x11_backend {
|
|||
uint8_t present_opcode;
|
||||
uint8_t xinput_opcode;
|
||||
|
||||
struct wl_listener display_destroy;
|
||||
struct wl_listener event_loop_destroy;
|
||||
};
|
||||
|
||||
struct wlr_x11_buffer {
|
||||
|
|
|
@ -17,7 +17,7 @@ struct wlr_input_device;
|
|||
* The `x11_display` argument is the name of the X Display socket. Set
|
||||
* to NULL for the default behaviour of XOpenDisplay().
|
||||
*/
|
||||
struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
||||
struct wlr_backend *wlr_x11_backend_create(struct wl_event_loop *loop,
|
||||
const char *x11_display);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue