Simplify damage tracking functions, use them in layer shell

master
emersion 7 years ago
parent d447460c01
commit 516f5454ad
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

@ -1,7 +1,4 @@
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_surface.h>
void desktop_damage_whole_surface(struct wlr_surface *surface, double lx, void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
double ly); bool whole);
void desktop_damage_from_surface(struct wlr_surface *surface, double lx,
double ly);

@ -34,11 +34,11 @@ struct sway_output {
void output_damage_whole(struct sway_output *output); void output_damage_whole(struct sway_output *output);
void output_damage_whole_surface(struct sway_output *output, void output_damage_surface(struct sway_output *output, double ox, double oy,
double ox, double oy, struct wlr_surface *surface); struct wlr_surface *surface, bool whole);
void output_damage_whole_view(struct sway_output *output, void output_damage_view(struct sway_output *output, struct sway_view *view,
struct sway_view *view); bool whole);
void output_damage_whole_container(struct sway_output *output, void output_damage_whole_container(struct sway_output *output,
struct sway_container *con); struct sway_container *con);

@ -157,9 +157,7 @@ void view_set_activated(struct sway_view *view, bool activated);
void view_close(struct sway_view *view); void view_close(struct sway_view *view);
void view_damage_whole(struct sway_view *view); void view_damage(struct sway_view *view, bool whole);
void view_damage_from(struct sway_view *view);
void view_for_each_surface(struct sway_view *view, void view_for_each_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data); wlr_surface_iterator_func_t iterator, void *user_data);

@ -30,10 +30,7 @@ struct cmd_results *cmd_opacity(int argc, char **argv) {
} }
con->alpha = opacity; con->alpha = opacity;
container_damage_whole(con);
if (con->type == C_VIEW) {
view_damage_whole(con->sway_view);
}
return cmd_results_new(CMD_SUCCESS, NULL, NULL); return cmd_results_new(CMD_SUCCESS, NULL, NULL);
} }

@ -2,19 +2,13 @@
#include "sway/desktop.h" #include "sway/desktop.h"
#include "sway/output.h" #include "sway/output.h"
void desktop_damage_whole_surface(struct wlr_surface *surface, double lx, void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
double ly) { bool whole) {
for (int i = 0; i < root_container.children->length; ++i) { for (int i = 0; i < root_container.children->length; ++i) {
struct sway_container *cont = root_container.children->items[i]; struct sway_container *cont = root_container.children->items[i];
if (cont->type == C_OUTPUT) { if (cont->type == C_OUTPUT) {
output_damage_whole_surface(cont->sway_output, output_damage_surface(cont->sway_output, lx - cont->x, ly - cont->y,
lx - cont->x, ly - cont->y, surface); surface, whole);
} }
} }
} }
void desktop_damage_from_surface(struct wlr_surface *surface, double lx,
double ly) {
// TODO
desktop_damage_whole_surface(surface, lx, ly);
}

@ -229,33 +229,39 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
wl_container_of(listener, layer, surface_commit); wl_container_of(listener, layer, surface_commit);
struct wlr_layer_surface *layer_surface = layer->layer_surface; struct wlr_layer_surface *layer_surface = layer->layer_surface;
struct wlr_output *wlr_output = layer_surface->output; struct wlr_output *wlr_output = layer_surface->output;
if (wlr_output != NULL) { if (wlr_output == NULL) {
struct sway_output *output = wlr_output->data; return;
struct wlr_box old_geo = layer->geo; }
arrange_layers(output);
if (memcmp(&old_geo, &layer->geo, sizeof(struct wlr_box)) != 0) { struct sway_output *output = wlr_output->data;
// TODO DAMAGE apply whole surface from previous and new geos struct wlr_box old_geo = layer->geo;
} else { arrange_layers(output);
// TODO DAMAGE from surface damage if (memcmp(&old_geo, &layer->geo, sizeof(struct wlr_box)) != 0) {
} output_damage_surface(output, old_geo.x, old_geo.y,
wlr_output_damage_add_box(output->damage, &old_geo); layer_surface->surface, true);
wlr_output_damage_add_box(output->damage, &layer->geo); output_damage_surface(output, layer->geo.x, layer->geo.y,
layer_surface->surface, true);
} else {
output_damage_surface(output, layer->geo.x, layer->geo.y,
layer_surface->surface, false);
} }
} }
static void unmap(struct sway_layer_surface *sway_layer) { static void unmap(struct sway_layer_surface *sway_layer) {
struct wlr_output *wlr_output = sway_layer->layer_surface->output; struct wlr_output *wlr_output = sway_layer->layer_surface->output;
if (wlr_output != NULL) { if (wlr_output == NULL) {
struct sway_output *output = wlr_output->data; return;
wlr_output_damage_add_box(output->damage, &sway_layer->geo);
} }
struct sway_output *output = wlr_output->data;
output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
sway_layer->layer_surface->surface, true);
} }
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {
struct sway_layer_surface *sway_layer = wl_container_of(listener, struct sway_layer_surface *sway_layer =
sway_layer, destroy); wl_container_of(listener, sway_layer, destroy);
wlr_log(L_DEBUG, "Layer surface destroyed (%s)", wlr_log(L_DEBUG, "Layer surface destroyed (%s)",
sway_layer->layer_surface->namespace); sway_layer->layer_surface->namespace);
if (sway_layer->layer_surface->mapped) { if (sway_layer->layer_surface->mapped) {
unmap(sway_layer); unmap(sway_layer);
} }
@ -277,7 +283,9 @@ static void handle_map(struct wl_listener *listener, void *data) {
struct sway_layer_surface *sway_layer = wl_container_of(listener, struct sway_layer_surface *sway_layer = wl_container_of(listener,
sway_layer, map); sway_layer, map);
struct sway_output *output = sway_layer->layer_surface->output->data; struct sway_output *output = sway_layer->layer_surface->output->data;
wlr_output_damage_add_box(output->damage, &sway_layer->geo); output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
sway_layer->layer_surface->surface, true);
// TODO: send enter to subsurfaces and popups
wlr_surface_send_enter(sway_layer->layer_surface->surface, wlr_surface_send_enter(sway_layer->layer_surface->surface,
sway_layer->layer_surface->output); sway_layer->layer_surface->output);
} }

@ -332,14 +332,14 @@ void output_damage_whole(struct sway_output *output) {
wlr_output_damage_add_whole(output->damage); wlr_output_damage_add_whole(output->damage);
} }
void output_damage_whole_surface(struct sway_output *output, void output_damage_surface(struct sway_output *output, double ox, double oy,
double ox, double oy, struct wlr_surface *surface) { struct wlr_surface *surface, bool whole) {
// TODO // TODO
output_damage_whole(output); output_damage_whole(output);
} }
void output_damage_whole_view(struct sway_output *output, void output_damage_view(struct sway_output *output, struct sway_view *view,
struct sway_view *view) { bool whole) {
// TODO // TODO
output_damage_whole(output); output_damage_whole(output);
} }

@ -79,7 +79,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
// TODO: Let floating views do whatever // TODO: Let floating views do whatever
view_update_size(view, wl_shell_view->pending_width, view_update_size(view, wl_shell_view->pending_width,
wl_shell_view->pending_height); wl_shell_view->pending_height);
view_damage_from(view); view_damage(view, false);
} }
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {

@ -169,7 +169,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
// TODO: Let floating views do whatever // TODO: Let floating views do whatever
view_update_size(view, xdg_shell_v6_view->pending_width, view_update_size(view, xdg_shell_v6_view->pending_width,
xdg_shell_v6_view->pending_height); xdg_shell_v6_view->pending_height);
view_damage_from(view); view_damage(view, false);
} }
static void handle_new_popup(struct wl_listener *listener, void *data) { static void handle_new_popup(struct wl_listener *listener, void *data) {

@ -32,15 +32,15 @@ static void unmanaged_handle_commit(struct wl_listener *listener, void *data) {
if (xsurface->x != surface->lx || xsurface->y != surface->ly) { if (xsurface->x != surface->lx || xsurface->y != surface->ly) {
// Surface has moved // Surface has moved
desktop_damage_whole_surface(xsurface->surface, desktop_damage_surface(xsurface->surface, surface->lx, surface->ly,
surface->lx, surface->ly); true);
surface->lx = xsurface->x; surface->lx = xsurface->x;
surface->ly = xsurface->y; surface->ly = xsurface->y;
desktop_damage_whole_surface(xsurface->surface, desktop_damage_surface(xsurface->surface, surface->lx, surface->ly,
surface->lx, surface->ly); true);
} else { } else {
desktop_damage_from_surface(xsurface->surface, desktop_damage_surface(xsurface->surface, xsurface->x, xsurface->y,
xsurface->x, xsurface->y); false);
} }
} }
@ -57,7 +57,7 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) {
surface->lx = xsurface->x; surface->lx = xsurface->x;
surface->ly = xsurface->y; surface->ly = xsurface->y;
desktop_damage_whole_surface(xsurface->surface, surface->lx, surface->ly); desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true);
// TODO: we don't send surface enter/leave events to xwayland unmanaged // TODO: we don't send surface enter/leave events to xwayland unmanaged
// surfaces, but xwayland doesn't support HiDPI anyway // surfaces, but xwayland doesn't support HiDPI anyway
@ -67,7 +67,7 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
struct sway_xwayland_unmanaged *surface = struct sway_xwayland_unmanaged *surface =
wl_container_of(listener, surface, unmap); wl_container_of(listener, surface, unmap);
struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface;
desktop_damage_whole_surface(xsurface->surface, xsurface->x, xsurface->y); desktop_damage_surface(xsurface->surface, xsurface->x, xsurface->y, true);
wl_list_remove(&surface->link); wl_list_remove(&surface->link);
wl_list_remove(&surface->commit.link); wl_list_remove(&surface->commit.link);
} }
@ -209,7 +209,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
// TODO: Let floating views do whatever // TODO: Let floating views do whatever
view_update_size(view, xwayland_view->pending_width, view_update_size(view, xwayland_view->pending_width,
xwayland_view->pending_height); xwayland_view->pending_height);
view_damage_from(view); view_damage(view, false);
} }
static void handle_unmap(struct wl_listener *listener, void *data) { static void handle_unmap(struct wl_listener *listener, void *data) {

@ -79,20 +79,15 @@ void view_close(struct sway_view *view) {
} }
} }
void view_damage_whole(struct sway_view *view) { void view_damage(struct sway_view *view, bool whole) {
for (int i = 0; i < root_container.children->length; ++i) { for (int i = 0; i < root_container.children->length; ++i) {
struct sway_container *cont = root_container.children->items[i]; struct sway_container *cont = root_container.children->items[i];
if (cont->type == C_OUTPUT) { if (cont->type == C_OUTPUT) {
output_damage_whole_view(cont->sway_output, view); output_damage_view(cont->sway_output, view, whole);
} }
} }
} }
void view_damage_from(struct sway_view *view) {
// TODO
view_damage_whole(view);
}
static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) { static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) {
struct sway_container *output = container_parent(view->swayc, C_OUTPUT); struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
@ -191,7 +186,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
arrange_windows(cont->parent, -1, -1); arrange_windows(cont->parent, -1, -1);
input_manager_set_focus(input_manager, cont); input_manager_set_focus(input_manager, cont);
view_damage_whole(view); view_damage(view, true);
view_handle_container_reparent(&view->container_reparent, NULL); view_handle_container_reparent(&view->container_reparent, NULL);
} }
@ -202,7 +197,7 @@ void view_unmap(struct sway_view *view) {
wl_signal_emit(&view->events.unmap, view); wl_signal_emit(&view->events.unmap, view);
view_damage_whole(view); view_damage(view, true);
wl_list_remove(&view->surface_new_subsurface.link); wl_list_remove(&view->surface_new_subsurface.link);
wl_list_remove(&view->container_reparent.link); wl_list_remove(&view->container_reparent.link);
@ -220,10 +215,10 @@ void view_update_position(struct sway_view *view, double ox, double oy) {
return; return;
} }
view_damage_whole(view); view_damage(view, true);
view->swayc->x = ox; view->swayc->x = ox;
view->swayc->y = oy; view->swayc->y = oy;
view_damage_whole(view); view_damage(view, true);
} }
void view_update_size(struct sway_view *view, int width, int height) { void view_update_size(struct sway_view *view, int width, int height) {
@ -231,10 +226,10 @@ void view_update_size(struct sway_view *view, int width, int height) {
return; return;
} }
view_damage_whole(view); view_damage(view, true);
view->width = width; view->width = width;
view->height = height; view->height = height;
view_damage_whole(view); view_damage(view, true);
} }
@ -253,7 +248,7 @@ static void view_child_handle_surface_commit(struct wl_listener *listener,
struct sway_view_child *child = struct sway_view_child *child =
wl_container_of(listener, child, surface_commit); wl_container_of(listener, child, surface_commit);
// TODO: only accumulate damage from the child // TODO: only accumulate damage from the child
view_damage_from(child->view); view_damage(child->view, false);
} }
static void view_child_handle_surface_new_subsurface( static void view_child_handle_surface_new_subsurface(
@ -315,12 +310,12 @@ void view_child_init(struct sway_view_child *child,
view_init_subsurfaces(child->view, surface); view_init_subsurfaces(child->view, surface);
// TODO: only damage the whole child // TODO: only damage the whole child
view_damage_whole(child->view); view_damage(child->view, true);
} }
void view_child_destroy(struct sway_view_child *child) { void view_child_destroy(struct sway_view_child *child) {
// TODO: only damage the whole child // TODO: only damage the whole child
view_damage_whole(child->view); view_damage(child->view, true);
wl_list_remove(&child->surface_commit.link); wl_list_remove(&child->surface_commit.link);
wl_list_remove(&child->surface_destroy.link); wl_list_remove(&child->surface_destroy.link);

Loading…
Cancel
Save