Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
rootston: refactor rendering
Browse files Browse the repository at this point in the history
This implements rootston surface iterators to ease rendering, sending
frame/presentation events and accumulating damage.
  • Loading branch information
emersion committed Feb 25, 2019
1 parent 0b33643 commit 591efc2
Show file tree
Hide file tree
Showing 8 changed files with 337 additions and 347 deletions.
22 changes: 20 additions & 2 deletions include/rootston/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,27 @@ struct roots_output {
struct wl_listener damage_destroy;
};

typedef void (*roots_surface_iterator_func_t)(struct roots_output *output,
struct wlr_surface *surface, struct wlr_box *box, float rotation,
void *user_data);

void rotate_child_position(double *sx, double *sy, double sw, double sh,
double pw, double ph, float rotation);

struct roots_input;

void output_surface_for_each_surface(struct roots_output *output,
struct wlr_surface *surface, double ox, double oy,
roots_surface_iterator_func_t iterator, void *user_data);
void output_view_for_each_surface(struct roots_output *output,
struct roots_view *view, roots_surface_iterator_func_t iterator,
void *user_data);
void output_drag_icons_for_each_surface(struct roots_output *output,
struct roots_input *input, roots_surface_iterator_func_t iterator,
void *user_data);
void output_for_each_surface(struct roots_output *output,
roots_surface_iterator_func_t iterator, void *user_data);

void handle_new_output(struct wl_listener *listener, void *data);

struct roots_view;
Expand All @@ -45,8 +63,8 @@ void output_damage_from_view(struct roots_output *output,
void output_damage_whole_drag_icon(struct roots_output *output,
struct roots_drag_icon *icon);
void output_damage_from_local_surface(struct roots_output *output,
struct wlr_surface *surface, double ox, double oy, float rotation);
struct wlr_surface *surface, double ox, double oy);
void output_damage_whole_local_surface(struct roots_output *output,
struct wlr_surface *surface, double ox, double oy, float rotation);
struct wlr_surface *surface, double ox, double oy);

#endif
4 changes: 4 additions & 0 deletions include/rootston/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct roots_view_interface {
void (*maximize)(struct roots_view *view, bool maximized);
void (*set_fullscreen)(struct roots_view *view, bool fullscreen);
void (*close)(struct roots_view *view);
void (*for_each_surface)(struct roots_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
void (*destroy)(struct roots_view *view);
};

Expand Down Expand Up @@ -251,6 +253,8 @@ void view_set_title(struct roots_view *view, const char *title);
void view_set_app_id(struct roots_view *view, const char *app_id);
void view_create_foreign_toplevel_handle(struct roots_view *view);
void view_get_deco_box(const struct roots_view *view, struct wlr_box *box);
void view_for_each_surface(struct roots_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);

struct roots_wl_shell_surface *roots_wl_shell_surface_from_view(
struct roots_view *view);
Expand Down
16 changes: 8 additions & 8 deletions rootston/layer_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,12 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {

if (memcmp(&old_geo, &layer->geo, sizeof(struct wlr_box)) != 0) {
output_damage_whole_local_surface(output, layer_surface->surface,
old_geo.x, old_geo.y, 0);
old_geo.x, old_geo.y);
output_damage_whole_local_surface(output, layer_surface->surface,
layer->geo.x, layer->geo.y, 0);
layer->geo.x, layer->geo.y);
} else {
output_damage_from_local_surface(output, layer_surface->surface,
layer->geo.x, layer->geo.y, 0);
layer->geo.x, layer->geo.y);
}
}
}
Expand All @@ -314,7 +314,7 @@ static void unmap(struct wlr_layer_surface_v1 *layer_surface) {
if (wlr_output != NULL) {
struct roots_output *output = wlr_output->data;
output_damage_whole_local_surface(output, layer_surface->surface,
layer->geo.x, layer->geo.y, 0);
layer->geo.x, layer->geo.y);
}
}

Expand Down Expand Up @@ -342,7 +342,7 @@ static void handle_map(struct wl_listener *listener, void *data) {
struct wlr_output *wlr_output = layer_surface->output;
struct roots_output *output = wlr_output->data;
output_damage_whole_local_surface(output, layer_surface->surface,
layer->geo.x, layer->geo.y, 0);
layer->geo.x, layer->geo.y);
wlr_surface_send_enter(layer_surface->surface, wlr_output);
}

Expand All @@ -363,7 +363,7 @@ static void popup_handle_map(struct wl_listener *listener, void *data) {
int ox = popup->wlr_popup->geometry.x + layer->geo.x;
int oy = popup->wlr_popup->geometry.y + layer->geo.y;
output_damage_whole_local_surface(output, popup->wlr_popup->base->surface,
ox, oy, 0);
ox, oy);
input_update_cursor_focus(output->desktop->server->input);
}

Expand All @@ -375,7 +375,7 @@ static void popup_handle_unmap(struct wl_listener *listener, void *data) {
int ox = popup->wlr_popup->geometry.x + layer->geo.x;
int oy = popup->wlr_popup->geometry.y + layer->geo.y;
output_damage_whole_local_surface(output, popup->wlr_popup->base->surface,
ox, oy, 0);
ox, oy);
}

static void popup_handle_commit(struct wl_listener *listener, void *data) {
Expand All @@ -386,7 +386,7 @@ static void popup_handle_commit(struct wl_listener *listener, void *data) {
int ox = popup->wlr_popup->geometry.x + layer->geo.x;
int oy = popup->wlr_popup->geometry.y + layer->geo.y;
output_damage_from_local_surface(output, popup->wlr_popup->base->surface,
ox, oy, 0);
ox, oy);
}

static void popup_handle_destroy(struct wl_listener *listener, void *data) {
Expand Down
Loading

0 comments on commit 591efc2

Please sign in to comment.