decorate xwayland views

This commit is contained in:
Tony Crisci 2018-01-16 07:50:40 -05:00
parent dc701b72fc
commit 3751a17321
5 changed files with 47 additions and 1 deletions

View file

@ -31,6 +31,18 @@ void view_get_box(const struct roots_view *view, struct wlr_box *box) {
}
}
void view_get_deco_box(const struct roots_view *view, struct wlr_box *box) {
view_get_box(view, box);
if (!view->decorated) {
return;
}
box->x -= view->border_width;
box->y -= (view->border_width + view->titlebar_height);
box->width += view->border_width * 2;
box->height += (view->border_width * 2 + view->titlebar_height);
}
static void view_update_output(const struct roots_view *view,
const struct wlr_box *before) {
struct roots_desktop *desktop = view->desktop;

View file

@ -144,8 +144,32 @@ static void render_xwayland_children(struct wlr_xwayland_surface *surface,
}
}
static void render_decorations(struct roots_view *view,
struct roots_desktop *desktop, struct wlr_output *output) {
if (!view->decorated) {
return;
}
struct wlr_box deco_box;
view_get_deco_box(view, &deco_box);
double ox = deco_box.x;
double oy = deco_box.y;
wlr_output_layout_output_coords(desktop->layout, output, &ox, &oy);
ox *= output->scale;
oy *= output->scale;
float matrix[16];
wlr_output_get_box_matrix(output, ox, oy, deco_box.width,
deco_box.height, WL_OUTPUT_TRANSFORM_NORMAL, view->rotation,
&matrix);
float color[4] = { 0.2, 0.2, 0.2, 1 };
wlr_render_colored_quad(desktop->server->renderer, &color, &matrix);
}
static void render_view(struct roots_view *view, struct roots_desktop *desktop,
struct wlr_output *wlr_output, struct timespec *when) {
render_decorations(view, desktop, wlr_output);
switch (view->type) {
case ROOTS_XDG_SHELL_V6_VIEW:
render_surface(view->wlr_surface, desktop, wlr_output, when,

View file

@ -296,6 +296,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
view->type = ROOTS_XWAYLAND_VIEW;
view->x = (double)surface->x;
view->y = (double)surface->y;
view->xwayland_surface = surface;
view->roots_xwayland_surface = roots_surface;
view->wlr_surface = surface->surface;
@ -311,6 +312,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
wl_list_insert(&desktop->views, &view->link);
if (!surface->override_redirect) {
view->decorated = true;
view->border_width = 4;
view->titlebar_height = 12;
view_setup(view);
}
}