wio

a wayland wm stylised after plan9 rio - forked from git.sr.ht/~srcmpwn/wio
git clone git://src.gearsix.net/wio
Log | Files | Refs | Atom | Submodules | README | LICENSE

commit 5d87979beaba99cc808f430f07659aea0d135dc4
parent 4b184d2769b0207d24773839d2e8c2977bee9e34
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 24 Apr 2019 22:45:10 -0400

Render window borders

Diffstat:
Minclude/colors.h | 2+-
Moutput.c | 38++++++++++++++++++++++++++++++++++++++
Mview.c | 11+++++++++++
3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/include/colors.h b/include/colors.h @@ -6,7 +6,7 @@ static const float background[4] = { }; static const float active_border[4] = { - 0x59 / 255.0f, 0xAB / 255.0f, 0xAB / 255.0f, 1.0f, + 0x50 / 255.0f, 0xA1 / 255.0f, 0xAD / 255.0f, 1.0f, }; static const float inactive_border[4] = { diff --git a/output.c b/output.c @@ -1,5 +1,6 @@ #define _POSIX_C_SOURCE 200112L #include <stdlib.h> +#include <string.h> #include <time.h> #include <wayland-server.h> #include <wlr/types/wlr_matrix.h> @@ -160,6 +161,43 @@ static void output_frame(struct wl_listener *listener, void *data) { .renderer = renderer, .when = &now, }; + const int border = 5; + float color[4]; + if (view->xdg_surface->toplevel->current.activated) { + memcpy(color, active_border, sizeof(color)); + } else { + memcpy(color, inactive_border, sizeof(color)); + } + struct wlr_box borders; + // Top + borders.x = view->x - border; + borders.y = view->y - border; + borders.width = view->xdg_surface->surface->current.width + border * 2; + borders.height = border; + wlr_render_rect(renderer, &borders, color, + output->wlr_output->transform_matrix); + // Right + borders.x = view->x + view->xdg_surface->surface->current.width; + borders.y = view->y - border; + borders.width = border; + borders.height = view->xdg_surface->surface->current.height + border * 2; + wlr_render_rect(renderer, &borders, color, + output->wlr_output->transform_matrix); + // Bottom + borders.x = view->x - border; + borders.y = view->y + view->xdg_surface->surface->current.height; + borders.width = view->xdg_surface->surface->current.width + border * 2; + borders.height = border; + wlr_render_rect(renderer, &borders, color, + output->wlr_output->transform_matrix); + // Left + borders.x = view->x - border; + borders.y = view->y - border; + borders.width = border; + borders.height = view->xdg_surface->surface->current.height + border * 2; + wlr_render_rect(renderer, &borders, color, + output->wlr_output->transform_matrix); + wlr_xdg_surface_for_each_surface(view->xdg_surface, render_surface, &rdata); } diff --git a/view.c b/view.c @@ -7,7 +7,18 @@ static void xdg_surface_map(struct wl_listener *listener, void *data) { struct wio_view *view = wl_container_of(listener, view, map); + struct wio_server *server = view->server; wio_view_focus(view, view->xdg_surface->surface); + + // TODO: move this view to its preallocated space + struct wlr_output *output = wlr_output_layout_output_at( + server->output_layout, server->cursor->x, server->cursor->y); + struct wlr_output_layout_output *layout = wlr_output_layout_get( + server->output_layout, output); + view->x = layout->x + + (output->width / 2 - view->xdg_surface->surface->current.width / 2); + view->y = layout->y + + (output->height / 2 - view->xdg_surface->surface->current.height / 2); } static void xdg_surface_destroy(struct wl_listener *listener, void *data) {