aboutsummaryrefslogtreecommitdiff
path: root/rootston/wl_shell.c
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-10-10 10:00:09 -0400
committerTony Crisci <tony@dubstepdish.com>2017-10-10 10:00:09 -0400
commitfe3c6c929be467b3e1ec860c94c9524a6686bd61 (patch)
tree610d71e6274bf1dbd75ee9321b554b9389df1279 /rootston/wl_shell.c
parentd4c065e59b1d0275d91dac83bed8cfa54d2e57b5 (diff)
wl-shell: popup input handling
Diffstat (limited to 'rootston/wl_shell.c')
-rw-r--r--rootston/wl_shell.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c
index 34f53c7a..a629575b 100644
--- a/rootston/wl_shell.c
+++ b/rootston/wl_shell.c
@@ -138,3 +138,40 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
roots_surface->view = view;
list_add(desktop->views, view);
}
+
+struct wlr_wl_shell_surface *wlr_wl_shell_surface_popup_at(
+ struct wlr_wl_shell_surface *surface, double sx, double sy,
+ double *popup_sx, double *popup_sy) {
+ struct wlr_wl_shell_surface *popup;
+ wl_list_for_each(popup, &surface->children, child_link) {
+ double _popup_sx = popup->transient_state->x;
+ double _popup_sy = popup->transient_state->y;
+ int popup_width =
+ popup->surface->current->buffer_width;
+ int popup_height =
+ popup->surface->current->buffer_height;
+
+ struct wlr_wl_shell_surface *_popup =
+ wlr_wl_shell_surface_popup_at(popup,
+ popup->transient_state->x,
+ popup->transient_state->y,
+ popup_sx, popup_sy);
+ if (_popup) {
+ *popup_sx = sx + _popup_sx;
+ *popup_sy = sy + _popup_sy;
+ return _popup;
+ }
+
+ if ((sx > _popup_sx && sx < _popup_sx + popup_width) &&
+ (sy > _popup_sy && sy < _popup_sy + popup_height)) {
+ if (pixman_region32_contains_point(&popup->surface->current->input,
+ sx - _popup_sx, sy - _popup_sy, NULL)) {
+ *popup_sx = _popup_sx;
+ *popup_sy = _popup_sy;
+ return popup;
+ }
+ }
+ }
+
+ return NULL;
+}