diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2017-08-20 14:18:29 +0200 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2017-08-23 22:03:49 +0200 |
commit | 1458a95e65248fede646051d2607c4553e8dcb0c (patch) | |
tree | 2905b0e6b183fec41e9ada40d78bebdf9c679776 | |
parent | f912316d9b1ed39352efb07e773128b6e4f554aa (diff) |
example compositor: loop through xwayland surfaces
-rw-r--r-- | examples/compositor.c | 10 | ||||
-rw-r--r-- | include/wlr/xwayland.h | 22 | ||||
-rw-r--r-- | xwayland/xwayland.c | 1 | ||||
-rw-r--r-- | xwayland/xwm.c | 13 | ||||
-rw-r--r-- | xwayland/xwm.h | 14 |
5 files changed, 32 insertions, 28 deletions
diff --git a/examples/compositor.c b/examples/compositor.c index e0bafe60..024324cd 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -36,7 +36,7 @@ struct sample_state { struct wlr_data_device_manager *data_device_manager; struct wl_resource *focus; struct wl_listener keyboard_bound; - struct wlr_xwayland *wlr_xwayland; + struct wlr_xwayland *xwayland; int keymap_fd; size_t keymap_size; uint32_t serial; @@ -85,6 +85,10 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts wl_list_for_each(xdg_surface, &sample->xdg_shell->surfaces, link) { output_frame_handle_surface(sample, wlr_output, ts, xdg_surface->surface); } + struct wlr_x11_window *x11_window; + wl_list_for_each(x11_window, &sample->xwayland->displayable_windows, link) { + output_frame_handle_surface(sample, wlr_output, ts, x11_window->surface); + } wlr_renderer_end(sample->renderer); wlr_output_swap_buffers(wlr_output); @@ -178,13 +182,13 @@ int main() { free(keymap); break; } - state.wlr_xwayland = wlr_xwayland_create(compositor.display, state.wlr_compositor); + state.xwayland = wlr_xwayland_create(compositor.display, state.wlr_compositor); compositor.keyboard_key_cb = handle_keyboard_key; wl_display_run(compositor.display); - wlr_xwayland_destroy(state.wlr_xwayland); + wlr_xwayland_destroy(state.xwayland); close(state.keymap_fd); wlr_seat_destroy(state.wl_seat); wlr_data_device_manager_destroy(state.data_device_manager); diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index 61386700..4d1a726d 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -4,20 +4,34 @@ #include <sys/types.h> #include <stdbool.h> #include <wlr/types/wlr_compositor.h> +#include <xcb/xcb.h> struct wlr_xwm; struct wlr_xwayland { - pid_t pid; - int display; - int x_fd[2], wl_fd[2], wm_fd[2]; - struct wl_client *client; + pid_t pid; + int display; + int x_fd[2], wl_fd[2], wm_fd[2]; + struct wl_client *client; struct wl_display *wl_display; struct wlr_compositor *compositor; time_t server_start; struct wl_event_source *sigusr1_source; struct wlr_xwm *xwm; + struct wl_list displayable_windows; +}; + +struct wlr_x11_window { + xcb_window_t window_id; + uint32_t surface_id; + struct wl_list link; + + struct wl_resource *surface; + struct wl_listener surface_destroy_listener; + int16_t x, y; + uint16_t width, height; + bool override_redirect; }; void wlr_xwayland_destroy(struct wlr_xwayland *wlr_xwayland); diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index 764c0135..aa1c3f96 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -161,6 +161,7 @@ static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, wlr_xwayland->x_fd[0] = wlr_xwayland->x_fd[1] = -1; wlr_xwayland->wl_fd[0] = wlr_xwayland->wl_fd[1] = -1; wlr_xwayland->wm_fd[0] = wlr_xwayland->wm_fd[1] = -1; + wl_list_init(&wlr_xwayland->displayable_windows); wlr_xwayland->display = open_display_sockets(wlr_xwayland->x_fd); if (wlr_xwayland->display < 0) { diff --git a/xwayland/xwm.c b/xwayland/xwm.c index b9653f14..bcc5ea05 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -19,7 +19,7 @@ static struct wlr_x11_window *lookup_window(struct wl_list *list, xcb_window_t w } static struct wlr_x11_window *lookup_window_any(struct wlr_xwm *xwm, xcb_window_t window_id) { struct wlr_x11_window *window; - if ((window = lookup_window(&xwm->paired_windows, window_id)) || + if ((window = lookup_window(&xwm->xwayland->displayable_windows, window_id)) || (window = lookup_window(&xwm->unpaired_windows, window_id)) || (window = lookup_window(&xwm->new_windows, window_id))) { return window; @@ -71,10 +71,10 @@ static void map_shell_surface(struct wlr_xwm *xwm, struct wlr_x11_window *window struct wlr_surface *surface) { // get xcb geometry for depth = alpha channel - // TODO link to compositor somehow + window->surface = surface->resource; wl_list_remove(&window->link); - wl_list_insert(&xwm->paired_windows, &window->link); + wl_list_insert(&xwm->xwayland->displayable_windows, &window->link); } /* xcb event handlers */ @@ -96,7 +96,7 @@ static void handle_destroy_notify(struct wlr_xwm *xwm, xcb_destroy_notify_event_ static void handle_configure_request(struct wlr_xwm *xwm, xcb_configure_request_event_t *ev) { struct wlr_x11_window *window; wlr_log(L_DEBUG, "XCB_CONFIGURE_REQUEST (%u) [%ux%u+%d,%d]", ev->window, - ev->width, ev->height, ev->x, ev->y); + ev->width, ev->height, ev->x, ev->y); if (!(window = lookup_window_any(xwm, ev->window))) { return; } @@ -211,7 +211,7 @@ static int x11_event_handler(int fd, uint32_t mask, void *data) { static void create_surface_handler(struct wl_listener *listener, void *data) { struct wlr_surface *surface = data; - struct wlr_xwm *xwm = wl_container_of(listener, xwm, surface_create_listener); + struct wlr_xwm *xwm = wl_container_of(listener, xwm, surface_create_listener); struct wlr_x11_window *window; uint32_t surface_id; @@ -308,7 +308,6 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { xwm->xwayland = wlr_xwayland; wl_list_init(&xwm->new_windows); wl_list_init(&xwm->unpaired_windows); - wl_list_init(&xwm->paired_windows); xwm->xcb_conn = xcb_connect_to_fd(wlr_xwayland->wm_fd[0], NULL); if ((rc = xcb_connection_has_error(xwm->xcb_conn))) { @@ -317,7 +316,7 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { return NULL; } - struct wl_event_loop *event_loop = wl_display_get_event_loop(wlr_xwayland->wl_display); + struct wl_event_loop *event_loop = wl_display_get_event_loop(wlr_xwayland->wl_display); xwm->event_source = wl_event_loop_add_fd(event_loop, wlr_xwayland->wm_fd[0], WL_EVENT_READABLE, x11_event_handler, xwm); // probably not needed diff --git a/xwayland/xwm.h b/xwayland/xwm.h index 51d60395..235145b9 100644 --- a/xwayland/xwm.h +++ b/xwayland/xwm.h @@ -1,6 +1,5 @@ #ifndef XWAYLAND_INTERNALS_H #define XWAYLAND_INTERNALS_H -#include <xcb/xcb.h> #include <wayland-server-core.h> #include <wlr/xwayland.h> @@ -65,18 +64,6 @@ static const char * const atom_map[ATOM_LAST] = { "_NET_WM_STATE", }; -struct wlr_x11_window { - xcb_window_t window_id; - uint32_t surface_id; - struct wl_list link; - - struct wl_resource *surface; - struct wl_listener surface_destroy_listener; - int16_t x, y; - uint16_t width, height; - bool override_redirect; -}; - struct wlr_xwm { struct wlr_xwayland *xwayland; struct wl_event_source *event_source; @@ -89,7 +76,6 @@ struct wlr_xwm { struct wl_list new_windows; struct wl_list unpaired_windows; - struct wl_list paired_windows; }; void xwm_destroy(struct wlr_xwm *xwm); |