mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
Add deco parts top, right and bottom
This commit is contained in:
parent
a6ac2a0439
commit
c07acc9ee6
7 changed files with 104 additions and 22 deletions
|
|
@ -10,6 +10,11 @@ This software is in early development.
|
|||
- wayland-protocols
|
||||
- xwayland
|
||||
|
||||
Will soon depend on
|
||||
|
||||
- libxml2
|
||||
- cairo, pango, glib
|
||||
|
||||
## Aim
|
||||
|
||||
- [x] Support xwayland
|
||||
|
|
|
|||
|
|
@ -93,8 +93,15 @@ struct output {
|
|||
|
||||
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;
|
||||
|
|
|
|||
28
src/cursor.c
28
src/cursor.c
|
|
@ -84,10 +84,22 @@ static void process_cursor_motion(struct server *server, uint32_t time)
|
|||
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);
|
||||
|
|
@ -186,9 +198,21 @@ void cursor_button(struct wl_listener *listener, void *data)
|
|||
/* 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);
|
||||
|
|
|
|||
25
src/deco.c
25
src/deco.c
|
|
@ -18,18 +18,37 @@ struct wlr_box deco_box(struct view *view, enum deco_part deco_part)
|
|||
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;
|
||||
|
|
|
|||
43
src/output.c
43
src/output.c
|
|
@ -1,12 +1,19 @@
|
|||
#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)
|
||||
|
|
@ -34,20 +41,28 @@ static void render_decorations(struct wlr_output *output, struct view *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)
|
||||
{
|
||||
|
|
|
|||
12
src/view.c
12
src/view.c
|
|
@ -207,10 +207,22 @@ struct view *view_at(struct server *server, double lx, double ly,
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ static void position(struct view *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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue