|
|
@ -19,6 +19,7 @@
|
|
|
|
#include "rootston/server.h"
|
|
|
|
#include "rootston/server.h"
|
|
|
|
#include "rootston/seat.h"
|
|
|
|
#include "rootston/seat.h"
|
|
|
|
#include "rootston/xcursor.h"
|
|
|
|
#include "rootston/xcursor.h"
|
|
|
|
|
|
|
|
#include "rootston/view.h"
|
|
|
|
|
|
|
|
|
|
|
|
void view_get_box(const struct roots_view *view, struct wlr_box *box) {
|
|
|
|
void view_get_box(const struct roots_view *view, struct wlr_box *box) {
|
|
|
|
box->x = view->x;
|
|
|
|
box->x = view->x;
|
|
|
@ -43,6 +44,43 @@ void view_get_deco_box(const struct roots_view *view, struct wlr_box *box) {
|
|
|
|
box->height += (view->border_width * 2 + view->titlebar_height);
|
|
|
|
box->height += (view->border_width * 2 + view->titlebar_height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum wlr_deco_part view_get_deco_part(struct roots_view *view, double sx, double sy) {
|
|
|
|
|
|
|
|
if (!view->decorated) {
|
|
|
|
|
|
|
|
return WLR_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 WLR_DECO_PART_TITLEBAR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum wlr_deco_part parts = 0;
|
|
|
|
|
|
|
|
if (sy >= -(titlebar_h + bw) &&
|
|
|
|
|
|
|
|
sy <= sh + bw) {
|
|
|
|
|
|
|
|
if (sx < 0 && sx > -bw) {
|
|
|
|
|
|
|
|
parts |= WLR_DECO_PART_LEFT_BORDER;
|
|
|
|
|
|
|
|
} else if (sx > sw && sx < sw + bw) {
|
|
|
|
|
|
|
|
parts |= WLR_DECO_PART_RIGHT_BORDER;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sx >= -bw && sx <= sw + bw) {
|
|
|
|
|
|
|
|
if (sy > sh && sy <= sh + bw) {
|
|
|
|
|
|
|
|
parts |= WLR_DECO_PART_BOTTOM_BORDER;
|
|
|
|
|
|
|
|
} else if (sy >= -(titlebar_h + bw) && sy < 0) {
|
|
|
|
|
|
|
|
parts |= WLR_DECO_PART_TOP_BORDER;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO corners
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return parts;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void view_update_output(const struct roots_view *view,
|
|
|
|
static void view_update_output(const struct roots_view *view,
|
|
|
|
const struct wlr_box *before) {
|
|
|
|
const struct wlr_box *before) {
|
|
|
|
struct roots_desktop *desktop = view->desktop;
|
|
|
|
struct roots_desktop *desktop = view->desktop;
|
|
|
@ -359,6 +397,12 @@ static bool view_at(struct roots_view *view, double lx, double ly,
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (view_get_deco_part(view, view_sx, view_sy)) {
|
|
|
|
|
|
|
|
*sx = view_sx;
|
|
|
|
|
|
|
|
*sy = view_sy;
|
|
|
|
|
|
|
|
return view;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (wlr_box_contains_point(&box, view_sx, view_sy) &&
|
|
|
|
if (wlr_box_contains_point(&box, view_sx, view_sy) &&
|
|
|
|
pixman_region32_contains_point(&view->wlr_surface->current->input,
|
|
|
|
pixman_region32_contains_point(&view->wlr_surface->current->input,
|
|
|
|
view_sx, view_sy, NULL)) {
|
|
|
|
view_sx, view_sy, NULL)) {
|
|
|
@ -392,14 +436,6 @@ struct roots_view *desktop_view_at(struct roots_desktop *desktop, double lx,
|
|
|
|
if (view_at(view, lx, ly, surface, sx, sy)) {
|
|
|
|
if (view_at(view, lx, ly, surface, sx, sy)) {
|
|
|
|
return view;
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (view->decorated) {
|
|
|
|
|
|
|
|
struct wlr_box deco_box;
|
|
|
|
|
|
|
|
view_get_deco_box(view, &deco_box);
|
|
|
|
|
|
|
|
if (wlr_box_contains_point(&deco_box, lx, ly)) {
|
|
|
|
|
|
|
|
return view;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|