Put code in src/ and include/

This commit is contained in:
Johan Malm 2020-05-27 14:29:05 +01:00
parent d9a083960b
commit d28465dfc3
12 changed files with 39 additions and 49 deletions

49
src/deco.c Normal file
View file

@ -0,0 +1,49 @@
#include "labwc.h"
struct wlr_box deco_max_extents(struct view *view)
{
struct wlr_box box = {
.x = view->x - XWL_WINDOW_BORDER,
.y = view->y - XWL_TITLEBAR_HEIGHT - XWL_WINDOW_BORDER,
.width = view->surface->current.width + 2 * XWL_WINDOW_BORDER,
.height = view->surface->current.height + XWL_TITLEBAR_HEIGHT +
2 * XWL_WINDOW_BORDER,
};
return box;
}
struct wlr_box deco_box(struct view *view, enum deco_part deco_part)
{
struct wlr_box box = { .x = 0, .y = 0, .width = 0, .height = 0 };
if (!view || !view->surface)
return box;
switch (deco_part) {
case LAB_DECO_PART_TOP:
box.x = view->x - XWL_WINDOW_BORDER;
box.y = view->y - XWL_TITLEBAR_HEIGHT - XWL_WINDOW_BORDER;
box.width =
view->surface->current.width + 2 * XWL_WINDOW_BORDER;
box.height = XWL_TITLEBAR_HEIGHT + XWL_WINDOW_BORDER;
break;
case LAB_DECO_PART_LEFT:
box.x = view->x - XWL_WINDOW_BORDER;
box.y = view->y;
box.width = XWL_WINDOW_BORDER;
box.height = view->surface->current.height;
break;
default:
break;
}
return box;
}
enum deco_part deco_at(struct view *view, double lx, double ly)
{
enum deco_part deco_part;
for (deco_part = 0; deco_part < LAB_DECO_NONE; ++deco_part) {
struct wlr_box box = deco_box(view, deco_part);
if (wlr_box_contains_point(&box, lx, ly))
return deco_part;
}
return LAB_DECO_NONE;
}