]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add deco parts top, right and bottom
authorJohan Malm <jgm323@gmail.com>
Sat, 30 May 2020 20:28:17 +0000 (21:28 +0100)
committerJohan Malm <jgm323@gmail.com>
Sat, 30 May 2020 20:28:17 +0000 (21:28 +0100)
README.md
include/labwc.h
src/cursor.c
src/deco.c
src/output.c
src/view.c
src/xwl.c

index 820bb7b06ff8fd43ec44e410e20128d3c644a825..e988473d47d40e98081768ecb3be7f811909af4a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -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
index 872feec230f7eeae35168c9ee078e57a3ece6666..bf591710940905ed3b62e501a4033eb09e2d17d4 100644 (file)
@@ -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;
index 78b466c9103880b2c0adbcffc2cc78dff058e713..bde8183989cc6a8e2da8fccffdbd69caa81b8e29 100644 (file)
@@ -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);
index f50296886c2bed0e7cdf39250b920f55b7b1dfb3..485f6e98e92c55b5dd63e03c3fa9df4ea1fedec1 100644 (file)
@@ -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;
index d89185ac527e12eb29147446145dce965f07adbe..8e577fa60a25b804150f9eaf54cd578510b3bd58 100644 (file)
@@ -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)
 {
index 3dc030705bfd31dd06fe418ed9c331a395c8e6fc..22de34657c6f27497d42794233d7aec154d8d416 100644 (file)
@@ -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;
index c6e7806f49c124af930379a9ce161d284b55f753..459953526a37fcd576889867430889916633808f 100644 (file)
--- a/src/xwl.c
+++ b/src/xwl.c
@@ -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;