aboutsummaryrefslogtreecommitdiff
path: root/rootston/desktop.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-09-30 14:31:57 -0400
committerGitHub <noreply@github.com>2017-09-30 14:31:57 -0400
commitbfb6914cdf725d9a614e5ae7f6b3f189aa3bd89e (patch)
tree0f4b9f20187792d4859830048b7ab44df0709185 /rootston/desktop.c
parente3438233f19a813731c049b8b5eae19220e4e87f (diff)
parent8f41c497a71ab0ca7fec96957d109b3b0adb702e (diff)
Merge pull request #160 from acrisci/feature/subcompositor
Subcompositor
Diffstat (limited to 'rootston/desktop.c')
-rw-r--r--rootston/desktop.c58
1 files changed, 52 insertions, 6 deletions
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 3d307ee4..fcfc0ccf 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -31,8 +31,8 @@ void view_get_size(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;
+ box->width = view->wlr_surface->current->width;
+ box->height = view->wlr_surface->current->height;
}
void view_get_input_bounds(struct roots_view *view, struct wlr_box *box) {
@@ -41,8 +41,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;
+ box->width = view->wlr_surface->current->width;
+ box->height = view->wlr_surface->current->height;
}
void view_activate(struct roots_view *view, bool activate) {
@@ -57,14 +57,60 @@ void view_resize(struct roots_view *view, uint32_t width, uint32_t height) {
}
}
-struct roots_view *view_at(struct roots_desktop *desktop, int x, int y) {
+static struct wlr_subsurface *subsurface_at(struct wlr_surface *surface,
+ double sx, double sy, double *sub_x, double *sub_y) {
+ struct wlr_subsurface *subsurface;
+ wl_list_for_each(subsurface, &surface->subsurface_list, parent_link) {
+ double _sub_x = subsurface->surface->current->subsurface_position.x;
+ double _sub_y = subsurface->surface->current->subsurface_position.y;
+ struct wlr_subsurface *sub =
+ subsurface_at(subsurface->surface, _sub_x + sx, _sub_y + sy,
+ sub_x, sub_y);
+ if (sub) {
+ // TODO: convert sub_x and sub_y to the parent coordinate system
+ return sub;
+ }
+
+ int sub_width = subsurface->surface->current->buffer_width;
+ int sub_height = subsurface->surface->current->buffer_height;
+ if ((sx > _sub_x && sx < _sub_x + sub_width) &&
+ (sy > _sub_y && sub_y < sub_y + sub_height)) {
+ *sub_x = _sub_x;
+ *sub_y = _sub_y;
+ return subsurface;
+ }
+ }
+
+ return NULL;
+}
+
+struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
+ struct wlr_surface **surface, double *sx, double *sy) {
for (size_t i = 0; i < desktop->views->length; ++i) {
struct roots_view *view = desktop->views->items[i];
+
+ double view_sx = lx - view->x;
+ double view_sy = ly - view->y;
+
+ double sub_x, sub_y;
+ struct wlr_subsurface *subsurface =
+ subsurface_at(view->wlr_surface, view_sx, view_sy, &sub_x, &sub_y);
+
+ if (subsurface) {
+ *sx = view_sx - sub_x;
+ *sy = view_sy - sub_y;
+ *surface = subsurface->surface;
+ return view;
+ }
+
struct wlr_box box;
view_get_input_bounds(view, &box);
box.x += view->x;
box.y += view->y;
- if (wlr_box_contains_point(&box, x, y)) {
+ if (wlr_box_contains_point(&box, lx, ly)) {
+ *sx = view_sx;
+ *sy = view_sy;
+ *surface = view->wlr_surface;
return view;
}
}