diff options
Diffstat (limited to 'xwayland/xwm.c')
-rw-r--r-- | xwayland/xwm.c | 92 |
1 files changed, 59 insertions, 33 deletions
diff --git a/xwayland/xwm.c b/xwayland/xwm.c index b0a24ff2..a93f3525 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -8,6 +8,7 @@ #include <xcb/xcb_image.h> #include <xcb/render.h> #include "wlr/util/log.h" +#include "wlr/util/edges.h" #include "wlr/types/wlr_surface.h" #include "wlr/xwayland.h" #include "wlr/xcursor.h" @@ -598,7 +599,7 @@ static void xwm_handle_configure_request(struct wlr_xwm *xwm, if (xsurface->surface == NULL) { // Surface has not been mapped yet - wlr_xwayland_surface_configure(xwm->xwayland, xsurface, ev->x, ev->y, + wlr_xwayland_surface_configure(xsurface, ev->x, ev->y, ev->width, ev->height); } else { struct wlr_xwayland_surface_configure_event *wlr_event = @@ -750,14 +751,43 @@ static void xwm_handle_surface_id_message(struct wlr_xwm *xwm, #define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 // move via keyboard #define _NET_WM_MOVERESIZE_CANCEL 11 // cancel operation +static enum wlr_edges net_wm_edges_to_wlr(uint32_t net_wm_edges) { + enum wlr_edges edges = WLR_EDGE_NONE; + + switch(net_wm_edges) { + case _NET_WM_MOVERESIZE_SIZE_TOPLEFT: + edges = WLR_EDGE_TOP | WLR_EDGE_LEFT; + break; + case _NET_WM_MOVERESIZE_SIZE_TOP: + edges = WLR_EDGE_TOP; + break; + case _NET_WM_MOVERESIZE_SIZE_TOPRIGHT: + edges = WLR_EDGE_TOP | WLR_EDGE_RIGHT; + break; + case _NET_WM_MOVERESIZE_SIZE_RIGHT: + edges = WLR_EDGE_RIGHT; + break; + case _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT: + edges = WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT; + break; + case _NET_WM_MOVERESIZE_SIZE_BOTTOM: + edges = WLR_EDGE_BOTTOM; + break; + case _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT: + edges = WLR_EDGE_BOTTOM | WLR_EDGE_LEFT; + break; + case _NET_WM_MOVERESIZE_SIZE_LEFT: + edges = WLR_EDGE_LEFT; + break; + default: + break; + } + + return edges; +} + static void xwm_handle_net_wm_moveresize_message(struct wlr_xwm *xwm, xcb_client_message_event_t *ev) { - // same as xdg-toplevel-v6 - // TODO need a common enum for this - static const int map[] = { - 5, 1, 9, 8, 10, 2, 6, 4 - }; - struct wlr_xwayland_surface *xsurface = lookup_surface(xwm, ev->window); if (!xsurface) { return; @@ -783,7 +813,7 @@ static void xwm_handle_net_wm_moveresize_message(struct wlr_xwm *xwm, case _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT: case _NET_WM_MOVERESIZE_SIZE_LEFT: resize_event.surface = xsurface; - resize_event.edges = map[detail]; + resize_event.edges = net_wm_edges_to_wlr(detail); wl_signal_emit(&xsurface->events.request_resize, &resize_event); break; case _NET_WM_MOVERESIZE_CANCEL: @@ -995,25 +1025,24 @@ static void handle_compositor_surface_create(struct wl_listener *listener, } } -void wlr_xwayland_surface_activate(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *xsurface, bool activated) { - struct wlr_xwayland_surface *focused = wlr_xwayland->xwm->focus_surface; +void wlr_xwayland_surface_activate(struct wlr_xwayland_surface *xsurface, + bool activated) { + struct wlr_xwayland_surface *focused = xsurface->xwm->focus_surface; if (activated) { - xwm_surface_activate(wlr_xwayland->xwm, xsurface); + xwm_surface_activate(xsurface->xwm, xsurface); } else if (focused == xsurface) { - xwm_surface_activate(wlr_xwayland->xwm, NULL); + xwm_surface_activate(xsurface->xwm, NULL); } } -void wlr_xwayland_surface_configure(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *xsurface, int16_t x, int16_t y, - uint16_t width, uint16_t height) { +void wlr_xwayland_surface_configure(struct wlr_xwayland_surface *xsurface, + int16_t x, int16_t y, uint16_t width, uint16_t height) { xsurface->x = x; xsurface->y = y; xsurface->width = width; xsurface->height = height; - struct wlr_xwm *xwm = wlr_xwayland->xwm; + struct wlr_xwm *xwm = xsurface->xwm; uint32_t mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH; @@ -1022,9 +1051,8 @@ void wlr_xwayland_surface_configure(struct wlr_xwayland *wlr_xwayland, xcb_flush(xwm->xcb_conn); } -void wlr_xwayland_surface_close(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *xsurface) { - struct wlr_xwm *xwm = wlr_xwayland->xwm; +void wlr_xwayland_surface_close(struct wlr_xwayland_surface *xsurface) { + struct wlr_xwm *xwm = xsurface->xwm; bool supports_delete = false; for (size_t i = 0; i < xsurface->protocols_len; i++) { @@ -1359,19 +1387,17 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { return xwm; } -void wlr_xwayland_surface_set_maximized(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *surface, bool maximized) { - if (xsurface_is_maximized(surface) != maximized) { - surface->maximized_horz = maximized; - surface->maximized_vert = maximized; - xsurface_set_net_wm_state(surface); - } +void wlr_xwayland_surface_set_maximized(struct wlr_xwayland_surface *surface, + bool maximized) { + surface->maximized_horz = maximized; + surface->maximized_vert = maximized; + xsurface_set_net_wm_state(surface); + xcb_flush(surface->xwm->xcb_conn); } -void wlr_xwayland_surface_set_fullscreen(struct wlr_xwayland *wlr_xwayland, - struct wlr_xwayland_surface *surface, bool fullscreen) { - if (surface->fullscreen != fullscreen) { - surface->fullscreen = fullscreen; - xsurface_set_net_wm_state(surface); - } +void wlr_xwayland_surface_set_fullscreen(struct wlr_xwayland_surface *surface, + bool fullscreen) { + surface->fullscreen = fullscreen; + xsurface_set_net_wm_state(surface); + xcb_flush(surface->xwm->xcb_conn); } |