From 220a6e9bf637471f3f5e392d3c3fb76ae9b7e138 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 28 Sep 2017 09:11:16 -0400 Subject: [PATCH] Add xwayland activate and fix EGL bug --- include/wlr/xwayland.h | 2 ++ render/gles2/texture.c | 4 ++-- rootston/cursor.c | 4 +++- rootston/desktop.c | 2 ++ rootston/xwayland.c | 5 +++++ types/wlr_surface.c | 1 + xwayland/xwm.c | 19 +++++++++++++++++++ xwayland/xwm.h | 3 ++- 8 files changed, 36 insertions(+), 4 deletions(-) diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index e3eadc2d..3c893c72 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -50,5 +50,7 @@ struct wlr_x11_window { void wlr_xwayland_destroy(struct wlr_xwayland *wlr_xwayland); struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display, struct wlr_compositor *compositor); +void wlr_x11_window_activate(struct wlr_xwayland *wlr_xwayland, + struct wlr_x11_window *window); #endif diff --git a/render/gles2/texture.c b/render/gles2/texture.c index f6a9d7eb..98d1a112 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -227,13 +227,13 @@ static void gles2_texture_get_buffer_size(struct wlr_texture *texture, struct return; } if (!wlr_egl_query_buffer(tex->egl, resource, EGL_WIDTH, - (EGLint*)&width)) { + (EGLint*)width)) { wlr_log(L_ERROR, "could not get size of the buffer " "(no buffer found)"); return; }; wlr_egl_query_buffer(tex->egl, resource, EGL_HEIGHT, - (EGLint*)&height); + (EGLint*)height); return; } diff --git a/rootston/cursor.c b/rootston/cursor.c index 226fe412..89f5874e 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -100,7 +100,9 @@ static void do_cursor_button_press(struct roots_input *input, input->input_events_idx = (i + 1) % (sizeof(input->input_events) / sizeof(input->input_events[0])); set_view_focus(input, desktop, view); - wlr_seat_keyboard_enter(input->wl_seat, view->wlr_surface); + if (view) { + wlr_seat_keyboard_enter(input->wl_seat, view->wlr_surface); + } break; } } diff --git a/rootston/desktop.c b/rootston/desktop.c index 0224dd19..697c83df 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -23,6 +23,8 @@ void view_get_input_bounds(struct roots_view *view, struct wlr_box *box) { return; } box->x = box->y = 0; + box->width = view->wlr_surface->current.width; + box->height = view->wlr_surface->current.height; } void view_activate(struct roots_view *view, bool activate) { diff --git a/rootston/xwayland.c b/rootston/xwayland.c index e68af907..f9ad2a22 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -17,6 +17,10 @@ static void handle_destroy(struct wl_listener *listener, void *data) { free(roots_surface); } +static void x11_activate(struct roots_view *view, bool active) { + wlr_x11_window_activate(view->desktop->xwayland, view->x11_window); +} + void handle_xwayland_surface(struct wl_listener *listener, void *data) { struct roots_desktop *desktop = wl_container_of(listener, desktop, xwayland_surface); @@ -38,6 +42,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { view->roots_x11_surface = roots_surface; view->wlr_surface = surface->surface; view->desktop = desktop; + view->activate = x11_activate; roots_surface->view = view; wl_list_insert(&desktop->views, &view->link); } diff --git a/types/wlr_surface.c b/types/wlr_surface.c index a9a54abe..09002d2d 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -117,6 +117,7 @@ static void wlr_surface_update_size(struct wlr_surface *surface) { surface->current.width = _width; surface->current.height = _height; + wlr_log(L_DEBUG, "%dx%d", _width, _height); } static void wlr_surface_to_buffer_region(struct wlr_surface *surface, diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 88be0d99..bda9f882 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -308,6 +308,25 @@ static void xcb_init_wm(struct wlr_xwm *xwm) { xcb_flush(xwm->xcb_conn); } +void wlr_x11_window_activate(struct wlr_xwayland *wlr_xwayland, + struct wlr_x11_window *window) { + struct wlr_xwm *xwm = wlr_xwayland->xwm; + xcb_client_message_event_t m = {0}; + m.response_type = XCB_CLIENT_MESSAGE; + m.format = 32; + m.window = window->window_id; + m.type = xwm->atoms[WM_PROTOCOLS]; + m.data.data32[0] = xwm->atoms[WM_TAKE_FOCUS]; + m.data.data32[1] = XCB_TIME_CURRENT_TIME; + xcb_send_event_checked(xwm->xcb_conn, 0, window->window_id, + XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (char*)&m); + xcb_set_input_focus_checked(xwm->xcb_conn, XCB_INPUT_FOCUS_POINTER_ROOT, + window->window_id, XCB_CURRENT_TIME); + xcb_configure_window_checked(xwm->xcb_conn, window->window_id, + XCB_CONFIG_WINDOW_STACK_MODE, (uint32_t[]){XCB_STACK_MODE_ABOVE}); + xcb_flush(xwm->xcb_conn); +} + void xwm_destroy(struct wlr_xwm *xwm) { if (!xwm) { return; diff --git a/xwayland/xwm.h b/xwayland/xwm.h index 235145b9..679ff128 100644 --- a/xwayland/xwm.h +++ b/xwayland/xwm.h @@ -52,7 +52,8 @@ enum atom_name { NET_SUPPORTED, NET_WM_S0, NET_WM_STATE, - ATOM_LAST + ATOM_LAST, + WM_TAKE_FOCUS, }; static const char * const atom_map[ATOM_LAST] = {