aboutsummaryrefslogtreecommitdiff
path: root/rootston/desktop.c
diff options
context:
space:
mode:
Diffstat (limited to 'rootston/desktop.c')
-rw-r--r--rootston/desktop.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 4bb1de5f..b2d586f4 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -19,6 +19,7 @@
#include "rootston/server.h"
#include "rootston/seat.h"
#include "rootston/xcursor.h"
+#include "rootston/view.h"
void view_get_box(const struct roots_view *view, struct wlr_box *box) {
box->x = view->x;
@@ -26,11 +27,66 @@ void view_get_box(const struct roots_view *view, struct wlr_box *box) {
if (view->get_size) {
view->get_size(view, box);
} else {
+ if (view->wlr_surface == NULL) {
+ // View is unmapped
+ box->width = box->height = 0;
+ return;
+ }
+
box->width = view->wlr_surface->current->width;
box->height = view->wlr_surface->current->height;
}
}
+void view_get_deco_box(const struct roots_view *view, struct wlr_box *box) {
+ view_get_box(view, box);
+ if (!view->decorated) {
+ return;
+ }
+
+ box->x -= view->border_width;
+ box->y -= (view->border_width + view->titlebar_height);
+ box->width += view->border_width * 2;
+ box->height += (view->border_width * 2 + view->titlebar_height);
+}
+
+enum roots_deco_part view_get_deco_part(struct roots_view *view, double sx, double sy) {
+ if (!view->decorated) {
+ return ROOTS_DECO_PART_NONE;
+ }
+
+ int sw = view->wlr_surface->current->width;
+ int sh = view->wlr_surface->current->height;
+ int bw = view->border_width;
+ int titlebar_h = view->titlebar_height;
+
+ if (sx > 0 && sx < sw && sy < 0 && sy > -view->titlebar_height) {
+ return ROOTS_DECO_PART_TITLEBAR;
+ }
+
+ enum roots_deco_part parts = 0;
+ if (sy >= -(titlebar_h + bw) &&
+ sy <= sh + bw) {
+ if (sx < 0 && sx > -bw) {
+ parts |= ROOTS_DECO_PART_LEFT_BORDER;
+ } else if (sx > sw && sx < sw + bw) {
+ parts |= ROOTS_DECO_PART_RIGHT_BORDER;
+ }
+ }
+
+ if (sx >= -bw && sx <= sw + bw) {
+ if (sy > sh && sy <= sh + bw) {
+ parts |= ROOTS_DECO_PART_BOTTOM_BORDER;
+ } else if (sy >= -(titlebar_h + bw) && sy < 0) {
+ parts |= ROOTS_DECO_PART_TOP_BORDER;
+ }
+ }
+
+ // TODO corners
+
+ return parts;
+}
+
static void view_update_output(const struct roots_view *view,
const struct wlr_box *before) {
struct roots_desktop *desktop = view->desktop;
@@ -468,6 +524,13 @@ static bool view_at(struct roots_view *view, double lx, double ly,
return true;
}
+ if (view_get_deco_part(view, view_sx, view_sy)) {
+ *sx = view_sx;
+ *sy = view_sy;
+ *surface = NULL;
+ return true;
+ }
+
if (wlr_box_contains_point(&box, view_sx, view_sy) &&
pixman_region32_contains_point(&view->wlr_surface->current->input,
view_sx, view_sy, NULL)) {