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