example compositor: loop through xwayland surfaces

This commit is contained in:
Dominique Martinet 2017-08-20 14:18:29 +02:00
parent f912316d9b
commit 1458a95e65
5 changed files with 32 additions and 28 deletions

View File

@ -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);

View File

@ -4,6 +4,7 @@
#include <sys/types.h>
#include <stdbool.h>
#include <wlr/types/wlr_compositor.h>
#include <xcb/xcb.h>
struct wlr_xwm;
@ -18,6 +19,19 @@ struct wlr_xwayland {
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);

View File

@ -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) {

View File

@ -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 */
@ -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))) {

View File

@ -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);