diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-10-10 13:21:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-10 13:21:18 -0400 |
commit | 2af261fe404839ebd4b81879f36448068a026a15 (patch) | |
tree | ab59377961c4e2941945c4a799c6fe0d2284e571 /rootston | |
parent | fbddc81b59bdc7ce392fa0ed3ec3733067c8bafe (diff) | |
parent | 0a6f54384ceca7f639bcaa3dc27c2c407e3e5843 (diff) |
Merge pull request #246 from acrisci/feature/wl-shell-fixes
wl-shell fixes (QT support)
Diffstat (limited to 'rootston')
-rw-r--r-- | rootston/desktop.c | 21 | ||||
-rw-r--r-- | rootston/output.c | 32 | ||||
-rw-r--r-- | rootston/wl_shell.c | 23 |
3 files changed, 72 insertions, 4 deletions
diff --git a/rootston/desktop.c b/rootston/desktop.c index bef0fad4..d5cac575 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -103,6 +103,12 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, for (int i = desktop->views->length - 1; i >= 0; --i) { struct roots_view *view = desktop->views->items[i]; + if (view->type == ROOTS_WL_SHELL_VIEW && + view->wl_shell_surface->state == + WLR_WL_SHELL_SURFACE_STATE_POPUP) { + continue; + } + double view_sx = lx - view->x; double view_sy = ly - view->y; @@ -138,6 +144,21 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, } } + if (view->type == ROOTS_WL_SHELL_VIEW) { + // TODO: test if this works with rotated views + double popup_sx, popup_sy; + struct wlr_wl_shell_surface *popup = + wlr_wl_shell_surface_popup_at(view->wl_shell_surface, + view_sx, view_sy, &popup_sx, &popup_sy); + + if (popup) { + *sx = view_sx - popup_sx; + *sy = view_sy - popup_sy; + *surface = popup->surface; + return view; + } + } + double sub_x, sub_y; struct wlr_subsurface *subsurface = wlr_surface_subsurface_at(view->wlr_surface, diff --git a/rootston/output.c b/rootston/output.c index d1b2c7de..2c061739 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -97,13 +97,39 @@ static void render_xdg_v6_popups(struct wlr_xdg_surface_v6 *surface, } } +static void render_wl_shell_surface(struct wlr_wl_shell_surface *surface, struct roots_desktop *desktop, + struct wlr_output *wlr_output, struct timespec *when, double lx, + double ly, float rotation, bool is_child) { + if (is_child || surface->state != WLR_WL_SHELL_SURFACE_STATE_POPUP) { + render_surface(surface->surface, desktop, wlr_output, when, + lx, ly, rotation); + struct wlr_wl_shell_surface *popup; + wl_list_for_each(popup, &surface->popups, popup_link) { + render_wl_shell_surface(popup, desktop, wlr_output, when, + lx + popup->transient_state->x, + ly + popup->transient_state->y, + rotation, true); + } + } +} + static void render_view(struct roots_view *view, struct roots_desktop *desktop, struct wlr_output *wlr_output, struct timespec *when) { - render_surface(view->wlr_surface, desktop, wlr_output, when, - view->x, view->y, view->rotation); - if (view->type == ROOTS_XDG_SHELL_V6_VIEW) { + switch (view->type) { + case ROOTS_XDG_SHELL_V6_VIEW: + render_surface(view->wlr_surface, desktop, wlr_output, when, + view->x, view->y, view->rotation); render_xdg_v6_popups(view->xdg_surface_v6, desktop, wlr_output, when, view->x, view->y, view->rotation); + break; + case ROOTS_WL_SHELL_VIEW: + render_wl_shell_surface(view->wl_shell_surface, desktop, wlr_output, + when, view->x, view->y, view->rotation, false); + break; + case ROOTS_XWAYLAND_VIEW: + render_surface(view->wlr_surface, desktop, wlr_output, when, + view->x, view->y, view->rotation); + break; } } diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index 009a8c06..34f53c7a 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -73,6 +73,14 @@ static void handle_destroy(struct wl_listener *listener, void *data) { free(roots_surface); } +static int shell_surface_compare_equals(const void *item, const void *cmp_to) { + const struct roots_view *view = item; + if (view->type == ROOTS_WL_SHELL_VIEW && view->wl_shell_surface == cmp_to) { + return 0; + } + return -1; +} + void handle_wl_shell_surface(struct wl_listener *listener, void *data) { struct roots_desktop *desktop = wl_container_of(listener, desktop, wl_shell_surface); @@ -107,7 +115,20 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { struct roots_view *view = calloc(1, sizeof(struct roots_view)); view->type = ROOTS_WL_SHELL_VIEW; - view->x = view->y = 200; + + if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) { + // we need to map it relative to the parent + int i = + list_seq_find(desktop->views, + shell_surface_compare_equals, surface->parent); + if (i != -1) { + struct roots_view *parent = desktop->views->items[i]; + view->x = parent->x + surface->transient_state->x; + view->y = parent->y + surface->transient_state->y; + } + } else { + view->x = view->y = 200; + } view->wl_shell_surface = surface; view->roots_wl_shell_surface = roots_surface; view->wlr_surface = surface->surface; |