From 2118c691b13c20d7100abfa02f9e274667501aef Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 8 Nov 2017 23:03:07 +0100 Subject: Add maximize support for xwayland in rootston --- rootston/xwayland.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'rootston/xwayland.c') diff --git a/rootston/xwayland.c b/rootston/xwayland.c index e3fc1c84..431586ba 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -85,6 +85,13 @@ static void close(struct roots_view *view) { wlr_xwayland_surface_close(view->desktop->xwayland, view->xwayland_surface); } +static void maximize(struct roots_view *view, bool maximized) { + assert(view->type == ROOTS_XWAYLAND_VIEW); + + wlr_xwayland_surface_set_maximized(view->desktop->xwayland, + view->xwayland_surface, maximized); +} + static void handle_destroy(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = wl_container_of(listener, roots_surface, destroy); @@ -161,6 +168,17 @@ static void handle_request_resize(struct wl_listener *listener, void *data) { view_begin_resize(input, cursor, view, e->edges); } +static void handle_request_maximize(struct wl_listener *listener, void *data) { + struct roots_xwayland_surface *roots_surface = + wl_container_of(listener, roots_surface, request_resize); + struct roots_view *view = roots_surface->view; + struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; + + bool maximized = xwayland_surface->maximized_vert && + xwayland_surface->maximized_horz; + view_maximize(view, maximized); +} + static void handle_map_notify(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = wl_container_of(listener, roots_surface, map_notify); @@ -202,24 +220,24 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { if (roots_surface == NULL) { return; } + roots_surface->destroy.notify = handle_destroy; wl_signal_add(&surface->events.destroy, &roots_surface->destroy); - roots_surface->request_configure.notify = handle_request_configure; wl_signal_add(&surface->events.request_configure, &roots_surface->request_configure); - roots_surface->map_notify.notify = handle_map_notify; wl_signal_add(&surface->events.map_notify, &roots_surface->map_notify); - roots_surface->unmap_notify.notify = handle_unmap_notify; wl_signal_add(&surface->events.unmap_notify, &roots_surface->unmap_notify); - roots_surface->request_move.notify = handle_request_move; wl_signal_add(&surface->events.request_move, &roots_surface->request_move); - roots_surface->request_resize.notify = handle_request_resize; - wl_signal_add(&surface->events.request_resize, &roots_surface->request_resize); + wl_signal_add(&surface->events.request_resize, + &roots_surface->request_resize); + roots_surface->request_maximize.notify = handle_request_maximize; + wl_signal_add(&surface->events.request_maximize, + &roots_surface->request_maximize); struct roots_view *view = calloc(1, sizeof(struct roots_view)); if (view == NULL) { @@ -237,6 +255,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { view->resize = resize; view->move = move; view->move_resize = move_resize; + view->maximize = maximize; view->close = close; roots_surface->view = view; wlr_list_add(desktop->views, view); -- cgit v1.2.3 From 758514fe5d67d226290694208a34f90d1a857d8e Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 9 Nov 2017 11:21:55 +0100 Subject: Fix xwayland _NET_WM_STATE handling --- rootston/xwayland.c | 2 +- xwayland/xwm.c | 52 ++++++++++++++++++++++++++++++---------------------- 2 files changed, 31 insertions(+), 23 deletions(-) (limited to 'rootston/xwayland.c') diff --git a/rootston/xwayland.c b/rootston/xwayland.c index 431586ba..1da61ec3 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -170,7 +170,7 @@ static void handle_request_resize(struct wl_listener *listener, void *data) { static void handle_request_maximize(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = - wl_container_of(listener, roots_surface, request_resize); + wl_container_of(listener, roots_surface, request_maximize); struct roots_view *view = roots_surface->view; struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; diff --git a/xwayland/xwm.c b/xwayland/xwm.c index f011587e..e5806d5b 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -823,41 +823,49 @@ static void xwm_handle_net_wm_state_message(struct wlr_xwm *xwm, if (!xsurface) { return; } + if (client_message->format != 32) { + return; + } - int maximized = xsurface_is_maximized(xsurface); + bool fullscreen = xsurface->fullscreen; + bool maximized = xsurface_is_maximized(xsurface); uint32_t action = client_message->data.data32[0]; - uint32_t property = client_message->data.data32[1]; + for (size_t i = 0; i < 2; ++i) { + uint32_t property = client_message->data.data32[1 + i]; - if (property == xwm->atoms[_NET_WM_STATE_FULLSCREEN] && - update_state(action, &xsurface->fullscreen)) { - xsurface_set_net_wm_state(xsurface); + if (property == xwm->atoms[_NET_WM_STATE_FULLSCREEN] && + update_state(action, &xsurface->fullscreen)) { + xsurface_set_net_wm_state(xsurface); + } else if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT] && + update_state(action, &xsurface->maximized_vert)) { + wlr_log(L_DEBUG, "cc sava"); + xsurface_set_net_wm_state(xsurface); + } else if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ] && + update_state(action, &xsurface->maximized_horz)) { + wlr_log(L_DEBUG, "mwa sava"); + xsurface_set_net_wm_state(xsurface); + } + } + // client_message->data.data32[3] is the source indication + // all other values are set to 0 + if (fullscreen != xsurface->fullscreen) { if (xsurface->fullscreen) { xsurface->saved_width = xsurface->width; xsurface->saved_height = xsurface->height; } wl_signal_emit(&xsurface->events.request_fullscreen, xsurface); - } else { - if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT] && - update_state(action, &xsurface->maximized_vert)) { - xsurface_set_net_wm_state(xsurface); - } + } - if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ] && - update_state(action, &xsurface->maximized_horz)) { - xsurface_set_net_wm_state(xsurface); + if (maximized != xsurface_is_maximized(xsurface)) { + if (xsurface_is_maximized(xsurface)) { + xsurface->saved_width = xsurface->width; + xsurface->saved_height = xsurface->height; } - if (maximized != xsurface_is_maximized(xsurface)) { - if (xsurface_is_maximized(xsurface)) { - xsurface->saved_width = xsurface->width; - xsurface->saved_height = xsurface->height; - } - - wl_signal_emit(&xsurface->events.request_maximize, xsurface); - } + wl_signal_emit(&xsurface->events.request_maximize, xsurface); } } @@ -1310,8 +1318,8 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { xwm->atoms[_NET_ACTIVE_WINDOW], xwm->atoms[_NET_WM_MOVERESIZE], xwm->atoms[_NET_WM_STATE_FULLSCREEN], - xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ], xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT], + xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ], }; xcb_change_property(xwm->xcb_conn, XCB_PROP_MODE_REPLACE, -- cgit v1.2.3 From 0204f811b44a0a999666bc7601c9b38f7c5c1adb Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 9 Nov 2017 20:08:43 +0100 Subject: Remove xwayland view listeners on destroy --- rootston/xwayland.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'rootston/xwayland.c') diff --git a/rootston/xwayland.c b/rootston/xwayland.c index 1da61ec3..b608b143 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -97,6 +97,10 @@ static void handle_destroy(struct wl_listener *listener, void *data) { wl_container_of(listener, roots_surface, destroy); view_teardown(roots_surface->view); wl_list_remove(&roots_surface->destroy.link); + wl_list_remove(&roots_surface->request_configure.link); + wl_list_remove(&roots_surface->request_move.link); + wl_list_remove(&roots_surface->request_resize.link); + wl_list_remove(&roots_surface->request_maximize.link); wl_list_remove(&roots_surface->map_notify.link); wl_list_remove(&roots_surface->unmap_notify.link); view_destroy(roots_surface->view); -- cgit v1.2.3