- wayland-protocols
- xwayland
+Will soon depend on
+
+- libxml2
+- cairo, pango, glib
+
## Aim
- [x] Support xwayland
enum view_type { LAB_XDG_SHELL_VIEW, LAB_XWAYLAND_VIEW };
-/* Keep LAB_DECO_NONE last for the purpose of iterating */
-enum deco_part { LAB_DECO_PART_TOP = 0, LAB_DECO_PART_LEFT, LAB_DECO_NONE };
+enum deco_part {
+ LAB_DECO_PART_TITLE = 0,
+ LAB_DECO_PART_TOP,
+ LAB_DECO_PART_RIGHT,
+ LAB_DECO_PART_BOTTOM,
+ LAB_DECO_PART_LEFT,
+ LAB_DECO_NONE
+ /* Keep LAB_DECO_NONE last as iteration end-marker */
+};
struct view {
enum view_type type;
server->cursor_mgr, XCURSOR_DEFAULT, server->cursor);
}
switch (view_area) {
- case LAB_DECO_PART_TOP:
+ case LAB_DECO_PART_TITLE:
wlr_xcursor_manager_set_cursor_image(
server->cursor_mgr, XCURSOR_DEFAULT, server->cursor);
break;
+ case LAB_DECO_PART_TOP:
+ wlr_xcursor_manager_set_cursor_image(
+ server->cursor_mgr, "top_side", server->cursor);
+ break;
+ case LAB_DECO_PART_RIGHT:
+ wlr_xcursor_manager_set_cursor_image(
+ server->cursor_mgr, "right_side", server->cursor);
+ break;
+ case LAB_DECO_PART_BOTTOM:
+ wlr_xcursor_manager_set_cursor_image(
+ server->cursor_mgr, "bottom_side", server->cursor);
+ break;
case LAB_DECO_PART_LEFT:
wlr_xcursor_manager_set_cursor_image(
server->cursor_mgr, "left_side", server->cursor);
/* Focus that client if the button was _pressed_ */
view_focus(view);
switch (view_area) {
- case LAB_DECO_PART_TOP:
+ case LAB_DECO_PART_TITLE:
interactive_begin(view, LAB_CURSOR_MOVE, 0);
break;
+ case LAB_DECO_PART_TOP:
+ interactive_begin(view, LAB_CURSOR_RESIZE,
+ WLR_EDGE_TOP);
+ break;
+ case LAB_DECO_PART_RIGHT:
+ interactive_begin(view, LAB_CURSOR_RESIZE,
+ WLR_EDGE_RIGHT);
+ break;
+ case LAB_DECO_PART_BOTTOM:
+ interactive_begin(view, LAB_CURSOR_RESIZE,
+ WLR_EDGE_BOTTOM);
+ break;
case LAB_DECO_PART_LEFT:
interactive_begin(view, LAB_CURSOR_RESIZE,
WLR_EDGE_LEFT);
if (!view || !view->surface)
return box;
switch (deco_part) {
+ case LAB_DECO_PART_TITLE:
+ box.x = view->x;
+ box.y = view->y - XWL_TITLEBAR_HEIGHT;
+ box.width = view->surface->current.width;
+ box.height = XWL_TITLEBAR_HEIGHT;
+ break;
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;
+ box.height = + XWL_WINDOW_BORDER;
+ break;
+ case LAB_DECO_PART_RIGHT:
+ box.x = view->x + view->surface->current.width;
+ box.y = view->y - XWL_TITLEBAR_HEIGHT;
+ box.width = XWL_WINDOW_BORDER;
+ box.height = view->surface->current.height + XWL_TITLEBAR_HEIGHT;
+ break;
+ case LAB_DECO_PART_BOTTOM:
+ box.x = view->x - XWL_WINDOW_BORDER;
+ box.y = view->y + view->surface->current.height;
+ box.width =
+ view->surface->current.width + 2 * XWL_WINDOW_BORDER;
+ box.height = + XWL_WINDOW_BORDER;
break;
case LAB_DECO_PART_LEFT:
box.x = view->x - XWL_WINDOW_BORDER;
- box.y = view->y;
+ box.y = view->y - XWL_TITLEBAR_HEIGHT;
box.width = XWL_WINDOW_BORDER;
- box.height = view->surface->current.height;
+ box.height = view->surface->current.height + XWL_TITLEBAR_HEIGHT;
break;
default:
break;
#include "labwc.h"
-struct render_data {
- struct wlr_output *output;
+static float window_active_title_bg[] = { 0.29, 0.55, 0.78, 1.0 };
+static float window_active_handle_bg[] = { 0.21, 0.49, 0.71, 1.0 };
+
+struct draw_data {
struct wlr_renderer *renderer;
- struct view *view;
- struct timespec *when;
+ float *transform_matrix;
+ float *rgba;
};
+static void draw_rect(struct draw_data *d, struct wlr_box box)
+{
+ wlr_render_rect(d->renderer, &box, d->rgba, d->transform_matrix);
+}
+
static void render_cycle_box(struct output *output)
{
if (!output->server->cycle_view)
{
if (!view_want_deco(view))
return;
+ struct draw_data ddata = {
+ .renderer = view->server->renderer,
+ .transform_matrix = output->transform_matrix,
+ };
- struct wlr_box box = deco_max_extents(view);
- float matrix[9];
- wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0,
- output->transform_matrix);
- float color[] = { 0.2, 0.2, 0.7, 0.9 };
- wlr_render_quad_with_matrix(view->server->renderer, color, matrix);
+ ddata.rgba = window_active_handle_bg;
+ draw_rect(&ddata, deco_box(view, LAB_DECO_PART_TOP));
+ draw_rect(&ddata, deco_box(view, LAB_DECO_PART_RIGHT));
+ draw_rect(&ddata, deco_box(view, LAB_DECO_PART_BOTTOM));
+ draw_rect(&ddata, deco_box(view, LAB_DECO_PART_LEFT));
- box = deco_box(view, LAB_DECO_PART_TOP);
- float color2[] = { 0.7, 0.2, 0.2, 0.9 };
- wlr_render_rect(view->server->renderer, &box, color2,
- output->transform_matrix);
+ ddata.rgba = window_active_title_bg;
+ draw_rect(&ddata, deco_box(view, LAB_DECO_PART_TITLE));
}
+struct render_data {
+ struct wlr_output *output;
+ struct wlr_renderer *renderer;
+ struct view *view;
+ struct timespec *when;
+};
+
static void render_surface(struct wlr_surface *surface, int sx, int sy,
void *data)
{
return view;
if (!view_want_deco(view))
continue;
+ if (deco_at(view, lx, ly) == LAB_DECO_PART_TITLE) {
+ *view_area = LAB_DECO_PART_TITLE;
+ return view;
+ }
if (deco_at(view, lx, ly) == LAB_DECO_PART_TOP) {
*view_area = LAB_DECO_PART_TOP;
return view;
}
+ if (deco_at(view, lx, ly) == LAB_DECO_PART_RIGHT) {
+ *view_area = LAB_DECO_PART_RIGHT;
+ return view;
+ }
+ if (deco_at(view, lx, ly) == LAB_DECO_PART_BOTTOM) {
+ *view_area = LAB_DECO_PART_BOTTOM;
+ return view;
+ }
if (deco_at(view, lx, ly) == LAB_DECO_PART_LEFT) {
*view_area = LAB_DECO_PART_LEFT;
return view;
return;
if (view->x || view->y)
return;
- box = deco_box(view, LAB_DECO_PART_TOP);
+ box = deco_box(view, LAB_DECO_PART_TITLE);
view->y = box.height;
box = deco_box(view, LAB_DECO_PART_LEFT);
view->x = box.width;