aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
Diffstat (limited to 'rootston')
-rw-r--r--rootston/layer_shell.c32
-rw-r--r--rootston/output.c27
2 files changed, 50 insertions, 9 deletions
diff --git a/rootston/layer_shell.c b/rootston/layer_shell.c
index 25e683fe..73addb7a 100644
--- a/rootston/layer_shell.c
+++ b/rootston/layer_shell.c
@@ -114,12 +114,32 @@ static void arrange_layers(struct wlr_output *_output) {
}
}
+static void unmap(struct wlr_layer_surface *layer_surface) {
+ struct roots_layer_surface *layer = layer_surface->data;
+ wl_list_remove(&layer->link);
+
+ struct wlr_output *wlr_output = layer_surface->output;
+ struct roots_output *output = wlr_output->data;
+ wlr_output_damage_add_box(output->damage, &layer->geo);
+}
+
static void handle_destroy(struct wl_listener *listener, void *data) {
- // TODO
+ struct roots_layer_surface *layer = wl_container_of(
+ listener, layer, destroy);
+ if (layer->layer_surface->mapped) {
+ unmap(layer->layer_surface);
+ }
+ free(layer);
}
static void handle_surface_commit(struct wl_listener *listener, void *data) {
- // TODO
+ struct roots_layer_surface *layer =
+ wl_container_of(listener, layer, surface_commit);
+ struct wlr_layer_surface *layer_surface = layer->layer_surface;
+ struct wlr_output *wlr_output = layer_surface->output;
+ struct roots_output *output = wlr_output->data;
+ output_damage_from_local_surface(output, layer_surface->surface,
+ layer->geo.x, layer->geo.y, 0);
}
static void handle_map(struct wl_listener *listener, void *data) {
@@ -127,13 +147,13 @@ static void handle_map(struct wl_listener *listener, void *data) {
struct roots_layer_surface *layer = layer_surface->data;
struct wlr_output *wlr_output = layer_surface->output;
struct roots_output *output = wlr_output->data;
- // TODO: This doesn't play right with output layouts and is also stupid
- output_damage_whole_surface(layer_surface->surface, layer->geo.x,
- layer->geo.y, 0, output);
+ wlr_output_damage_add_box(output->damage, &layer->geo);
}
static void handle_unmap(struct wl_listener *listener, void *data) {
- // TODO
+ struct roots_layer_surface *layer = wl_container_of(
+ listener, layer, unmap);
+ unmap(layer->layer_surface);
}
void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
diff --git a/rootston/output.c b/rootston/output.c
index 71497608..7c2c6d44 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -433,6 +433,18 @@ static void render_layer(
}
}
+static void layers_send_done(
+ struct roots_output *output, struct timespec *when) {
+ size_t len = sizeof(output->layers) / sizeof(output->layers[0]);
+ for (size_t i = 0; i < len; ++i) {
+ struct roots_layer_surface *roots_surface;
+ wl_list_for_each(roots_surface, &output->layers[i], link) {
+ struct wlr_layer_surface *layer = roots_surface->layer_surface;
+ wlr_surface_send_frame_done(layer->surface, when);
+ }
+ }
+}
+
static void render_output(struct roots_output *output) {
struct wlr_output *wlr_output = output->wlr_output;
struct roots_desktop *desktop = output->desktop;
@@ -595,6 +607,7 @@ damage_finish:
drag_icons_for_each_surface(server->input, surface_send_frame_done,
&data);
}
+ layers_send_done(output, data.when);
}
void output_damage_whole(struct roots_output *output) {
@@ -628,7 +641,7 @@ static bool view_accept_damage(struct roots_output *output,
return false;
}
-void output_damage_whole_surface(struct wlr_surface *surface,
+static void damage_whole_surface(struct wlr_surface *surface,
double lx, double ly, float rotation, void *data) {
struct roots_output *output = data;
@@ -672,13 +685,13 @@ void output_damage_whole_view(struct roots_output *output,
}
damage_whole_decoration(view, output);
- view_for_each_surface(view, output_damage_whole_surface, output);
+ view_for_each_surface(view, damage_whole_surface, output);
}
void output_damage_whole_drag_icon(struct roots_output *output,
struct roots_drag_icon *icon) {
surface_for_each_surface(icon->wlr_drag_icon->surface, icon->x, icon->y, 0,
- output_damage_whole_surface, output);
+ damage_whole_surface, output);
}
static void damage_from_surface(struct wlr_surface *surface,
@@ -716,6 +729,14 @@ static void damage_from_surface(struct wlr_surface *surface,
pixman_region32_fini(&damage);
}
+void output_damage_from_local_surface(struct roots_output *output,
+ struct wlr_surface *surface, double ox, double oy, float rotation) {
+ struct wlr_output_layout_output *layout = wlr_output_layout_get(
+ output->desktop->layout, output->wlr_output);
+ damage_from_surface(surface, ox + layout->x, oy + layout->y,
+ rotation, output);
+}
+
void output_damage_from_view(struct roots_output *output,
struct roots_view *view) {
if (!view_accept_damage(output, view)) {