output: render an overlay when dialogs are open

Fixes #6.
This commit is contained in:
Jente Hidskes 2019-01-04 18:33:59 +01:00
parent c848bafaed
commit 8faf7a2f59
No known key found for this signature in database
GPG key ID: 04BE5A29F32D91EA
3 changed files with 17 additions and 1 deletions

View file

@ -26,6 +26,15 @@
#include "server.h"
#include "view.h"
static void
render_overlay(struct wlr_renderer *renderer, struct wlr_output *output, int width, int height)
{
struct wlr_box box = { .width = width, .height = height };
float color[4] = { 0.0, 0.0, 0.0, 0.3 };
wlr_render_rect(renderer, &box, color, output->transform_matrix);
}
/* Used to move all of the data necessary to render a surface from the
* top-level frame handler to the per-surface render function. */
struct render_data {
@ -102,6 +111,12 @@ handle_output_frame(struct wl_listener *listener, void *data)
wl_list_for_each_reverse(view, &output->server->views, link) {
rdata.view = view;
view_for_each_surface(view, render_surface, &rdata);
/* If we have dialogs open and this view is not the
top of the stack, draw an overlay. */
if (have_dialogs_open(output->server) &&
view->link.prev != &output->server->views) {
render_overlay(renderer, output->wlr_output, width, height);
}
}
wlr_renderer_end(renderer);

2
seat.c
View file

@ -26,7 +26,7 @@
#include "server.h"
#include "view.h"
static inline bool
bool
have_dialogs_open(struct cg_server *server)
{
/* We only need to test if there is more than a single

1
seat.h
View file

@ -70,5 +70,6 @@ struct cg_seat *cg_seat_create(struct cg_server *server);
void cg_seat_destroy(struct cg_seat *seat);
struct cg_view *seat_get_focus(struct cg_seat *seat);
void seat_set_focus(struct cg_seat *seat, struct cg_view *view);
bool have_dialogs_open(struct cg_server *server);
#endif