mirror of
https://github.com/swaywm/sway.git
synced 2026-05-03 06:46:26 -04:00
update tabbed layout for damage tracking and focus parent
This commit is contained in:
commit
7bf11139cf
15 changed files with 363 additions and 220 deletions
|
|
@ -37,8 +37,8 @@ void output_damage_whole(struct sway_output *output);
|
|||
void output_damage_surface(struct sway_output *output, double ox, double oy,
|
||||
struct wlr_surface *surface, bool whole);
|
||||
|
||||
void output_damage_view(struct sway_output *output, struct sway_view *view,
|
||||
bool whole);
|
||||
void output_damage_from_view(struct sway_output *output,
|
||||
struct sway_view *view);
|
||||
|
||||
void output_damage_whole_container(struct sway_output *output,
|
||||
struct sway_container *con);
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ void view_set_fullscreen(struct sway_view *view, bool fullscreen);
|
|||
|
||||
void view_close(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,
|
||||
wlr_surface_iterator_func_t iterator, void *user_data);
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ struct cmd_results *cmd_default_border(int argc, char **argv) {
|
|||
config->border = B_NORMAL;
|
||||
} else if (strcmp(argv[0], "pixel") == 0) {
|
||||
config->border = B_PIXEL;
|
||||
if (argc == 2) {
|
||||
config->border_thickness = atoi(argv[1]);
|
||||
}
|
||||
} else {
|
||||
return cmd_results_new(CMD_INVALID, "default_border",
|
||||
"Expected 'default_border <none|normal|pixel>' or 'default_border pixel <px>'");
|
||||
"Expected 'default_border <none|normal|pixel>' or 'default_border <normal|pixel> <px>'");
|
||||
}
|
||||
if (argc == 2) {
|
||||
config->border_thickness = atoi(argv[1]);
|
||||
}
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
|
|
|
|||
|
|
@ -90,12 +90,14 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
|
|||
}
|
||||
free(ws_name);
|
||||
struct sway_container *old_parent = current->parent;
|
||||
struct sway_container *focus = seat_get_focus_inactive(
|
||||
struct sway_container *destination = seat_get_focus_inactive(
|
||||
config->handler_context.seat, ws);
|
||||
container_move_to(current, focus);
|
||||
seat_set_focus(config->handler_context.seat, old_parent);
|
||||
container_move_to(current, destination);
|
||||
struct sway_container *focus = seat_get_focus_inactive(
|
||||
config->handler_context.seat, old_parent);
|
||||
seat_set_focus(config->handler_context.seat, focus);
|
||||
container_reap_empty(old_parent);
|
||||
container_reap_empty(focus->parent);
|
||||
container_reap_empty(destination->parent);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
} else if (strcasecmp(argv[1], "to") == 0
|
||||
&& strcasecmp(argv[2], "output") == 0) {
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ static void config_defaults(struct sway_config *config) {
|
|||
config->default_layout = L_NONE;
|
||||
config->default_orientation = L_NONE;
|
||||
if (!(config->font = strdup("monospace 10"))) goto cleanup;
|
||||
config->font_height = 0;
|
||||
config->font_height = 17; // height of monospace 10
|
||||
|
||||
// floating view
|
||||
config->floating_maximum_width = 0;
|
||||
|
|
|
|||
|
|
@ -180,9 +180,6 @@ void arrange_layers(struct sway_output *output) {
|
|||
}
|
||||
|
||||
// Arrange non-exlusive surfaces from top->bottom
|
||||
usable_area.x = usable_area.y = 0;
|
||||
wlr_output_effective_resolution(output->wlr_output,
|
||||
&usable_area.width, &usable_area.height);
|
||||
arrange_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
|
||||
&usable_area, false);
|
||||
arrange_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
|
||||
|
|
|
|||
|
|
@ -163,14 +163,65 @@ static void scale_box(struct wlr_box *box, float scale) {
|
|||
struct render_data {
|
||||
struct root_geometry root_geo;
|
||||
struct sway_output *output;
|
||||
pixman_region32_t *damage;
|
||||
float alpha;
|
||||
};
|
||||
|
||||
static void scissor_output(struct wlr_output *wlr_output,
|
||||
pixman_box32_t *rect) {
|
||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
|
||||
assert(renderer);
|
||||
|
||||
struct wlr_box box = {
|
||||
.x = rect->x1,
|
||||
.y = rect->y1,
|
||||
.width = rect->x2 - rect->x1,
|
||||
.height = rect->y2 - rect->y1,
|
||||
};
|
||||
|
||||
int ow, oh;
|
||||
wlr_output_transformed_resolution(wlr_output, &ow, &oh);
|
||||
|
||||
enum wl_output_transform transform =
|
||||
wlr_output_transform_invert(wlr_output->transform);
|
||||
wlr_box_transform(&box, transform, ow, oh, &box);
|
||||
|
||||
wlr_renderer_scissor(renderer, &box);
|
||||
}
|
||||
|
||||
static void render_texture(struct wlr_output *wlr_output,
|
||||
pixman_region32_t *output_damage, struct wlr_texture *texture,
|
||||
const struct wlr_box *box, const float matrix[static 9], float alpha) {
|
||||
struct wlr_renderer *renderer =
|
||||
wlr_backend_get_renderer(wlr_output->backend);
|
||||
|
||||
pixman_region32_t damage;
|
||||
pixman_region32_init(&damage);
|
||||
pixman_region32_union_rect(&damage, &damage, box->x, box->y,
|
||||
box->width, box->height);
|
||||
pixman_region32_intersect(&damage, &damage, output_damage);
|
||||
bool damaged = pixman_region32_not_empty(&damage);
|
||||
if (!damaged) {
|
||||
goto damage_finish;
|
||||
}
|
||||
|
||||
int nrects;
|
||||
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
|
||||
for (int i = 0; i < nrects; ++i) {
|
||||
scissor_output(wlr_output, &rects[i]);
|
||||
wlr_render_texture_with_matrix(renderer, texture, matrix, alpha);
|
||||
}
|
||||
|
||||
damage_finish:
|
||||
pixman_region32_fini(&damage);
|
||||
}
|
||||
|
||||
static void render_surface_iterator(struct wlr_surface *surface, int sx, int sy,
|
||||
void *_data) {
|
||||
struct render_data *data = _data;
|
||||
struct wlr_output *wlr_output = data->output->wlr_output;
|
||||
float rotation = data->root_geo.rotation;
|
||||
pixman_region32_t *output_damage = data->damage;
|
||||
float alpha = data->alpha;
|
||||
|
||||
if (!wlr_surface_has_buffer(surface)) {
|
||||
|
|
@ -184,13 +235,6 @@ static void render_surface_iterator(struct wlr_surface *surface, int sx, int sy,
|
|||
return;
|
||||
}
|
||||
|
||||
struct wlr_renderer *renderer =
|
||||
wlr_backend_get_renderer(wlr_output->backend);
|
||||
if (!sway_assert(renderer != NULL,
|
||||
"expected the output backend to have a renderer")) {
|
||||
return;
|
||||
}
|
||||
|
||||
scale_box(&box, wlr_output->scale);
|
||||
|
||||
float matrix[9];
|
||||
|
|
@ -199,38 +243,81 @@ static void render_surface_iterator(struct wlr_surface *surface, int sx, int sy,
|
|||
wlr_matrix_project_box(matrix, &box, transform, rotation,
|
||||
wlr_output->transform_matrix);
|
||||
|
||||
wlr_render_texture_with_matrix(renderer, surface->texture,
|
||||
matrix, alpha);
|
||||
render_texture(wlr_output, output_damage, surface->texture, &box, matrix,
|
||||
alpha);
|
||||
}
|
||||
|
||||
static void render_layer(struct sway_output *output,
|
||||
struct wl_list *layer_surfaces) {
|
||||
struct render_data data = { .output = output, .alpha = 1.0f };
|
||||
pixman_region32_t *damage, struct wl_list *layer_surfaces) {
|
||||
struct render_data data = {
|
||||
.output = output,
|
||||
.damage = damage,
|
||||
.alpha = 1.0f,
|
||||
};
|
||||
layer_for_each_surface(layer_surfaces, &data.root_geo,
|
||||
render_surface_iterator, &data);
|
||||
}
|
||||
|
||||
static void render_unmanaged(struct sway_output *output,
|
||||
struct wl_list *unmanaged) {
|
||||
struct render_data data = { .output = output, .alpha = 1.0f };
|
||||
pixman_region32_t *damage, struct wl_list *unmanaged) {
|
||||
struct render_data data = {
|
||||
.output = output,
|
||||
.damage = damage,
|
||||
.alpha = 1.0f,
|
||||
};
|
||||
unmanaged_for_each_surface(unmanaged, output, &data.root_geo,
|
||||
render_surface_iterator, &data);
|
||||
}
|
||||
|
||||
static void render_view(struct sway_view *view, struct sway_output *output) {
|
||||
struct render_data data = { .output = output, .alpha = view->swayc->alpha };
|
||||
static void render_view(struct sway_view *view, struct sway_output *output,
|
||||
pixman_region32_t *damage) {
|
||||
struct render_data data = {
|
||||
.output = output,
|
||||
.damage = damage,
|
||||
.alpha = view->swayc->alpha,
|
||||
};
|
||||
output_view_for_each_surface(
|
||||
view, &data.root_geo, render_surface_iterator, &data);
|
||||
}
|
||||
|
||||
static void render_rect(struct wlr_output *wlr_output,
|
||||
pixman_region32_t *output_damage, const struct wlr_box *_box,
|
||||
float color[static 4]) {
|
||||
struct wlr_renderer *renderer =
|
||||
wlr_backend_get_renderer(wlr_output->backend);
|
||||
|
||||
struct wlr_box box = *_box;
|
||||
scale_box(&box, wlr_output->scale);
|
||||
|
||||
pixman_region32_t damage;
|
||||
pixman_region32_init(&damage);
|
||||
pixman_region32_union_rect(&damage, &damage, box.x, box.y,
|
||||
box.width, box.height);
|
||||
pixman_region32_intersect(&damage, &damage, output_damage);
|
||||
bool damaged = pixman_region32_not_empty(&damage);
|
||||
if (!damaged) {
|
||||
goto damage_finish;
|
||||
}
|
||||
|
||||
int nrects;
|
||||
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
|
||||
for (int i = 0; i < nrects; ++i) {
|
||||
scissor_output(wlr_output, &rects[i]);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
wlr_output->transform_matrix);
|
||||
}
|
||||
|
||||
damage_finish:
|
||||
pixman_region32_fini(&damage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render decorations for a view with "border normal".
|
||||
*/
|
||||
static void render_container_simple_border_normal(struct sway_output *output,
|
||||
pixman_region32_t *output_damage,
|
||||
struct sway_container *con, struct border_colors *colors,
|
||||
struct wlr_texture *title_texture) {
|
||||
struct wlr_renderer *renderer =
|
||||
wlr_backend_get_renderer(output->wlr_output->backend);
|
||||
struct wlr_box box;
|
||||
float color[4];
|
||||
|
||||
|
|
@ -241,9 +328,7 @@ static void render_container_simple_border_normal(struct sway_output *output,
|
|||
box.y = con->y + 1;
|
||||
box.width = con->sway_view->border_thickness;
|
||||
box.height = con->height - 1;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Child border - right edge
|
||||
if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) {
|
||||
|
|
@ -256,9 +341,7 @@ static void render_container_simple_border_normal(struct sway_output *output,
|
|||
box.y = con->y + 1;
|
||||
box.width = con->sway_view->border_thickness;
|
||||
box.height = con->height - 1;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Child border - bottom edge
|
||||
if (con->parent->children->length == 1 && con->parent->layout == L_VERT) {
|
||||
|
|
@ -271,9 +354,7 @@ static void render_container_simple_border_normal(struct sway_output *output,
|
|||
box.y = con->y + con->height - con->sway_view->border_thickness;
|
||||
box.width = con->width;
|
||||
box.height = con->sway_view->border_thickness;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Single pixel bar above title
|
||||
memcpy(&color, colors->border, sizeof(float) * 4);
|
||||
|
|
@ -282,18 +363,14 @@ static void render_container_simple_border_normal(struct sway_output *output,
|
|||
box.y = con->y;
|
||||
box.width = con->width;
|
||||
box.height = 1;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Single pixel bar below title
|
||||
box.x = con->x + con->sway_view->border_thickness;
|
||||
box.y = con->sway_view->y - 1;
|
||||
box.width = con->width - con->sway_view->border_thickness * 2;
|
||||
box.height = 1;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Title background
|
||||
memcpy(&color, colors->background, sizeof(float) * 4);
|
||||
|
|
@ -302,16 +379,24 @@ static void render_container_simple_border_normal(struct sway_output *output,
|
|||
box.y = con->y + 1;
|
||||
box.width = con->width - con->sway_view->border_thickness * 2;
|
||||
box.height = con->sway_view->y - con->y - 2;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Title text
|
||||
if (title_texture) {
|
||||
wlr_renderer_scissor(renderer, &box);
|
||||
wlr_render_texture(renderer, title_texture,
|
||||
output->wlr_output->transform_matrix, box.x, box.y, 1);
|
||||
wlr_renderer_scissor(renderer, NULL);
|
||||
float output_scale = output->wlr_output->scale;
|
||||
struct wlr_box texture_box = {
|
||||
.x = box.x * output_scale,
|
||||
.y = box.y * output_scale,
|
||||
};
|
||||
wlr_texture_get_size(title_texture,
|
||||
&texture_box.width, &texture_box.height);
|
||||
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, &texture_box, WL_OUTPUT_TRANSFORM_NORMAL,
|
||||
0.0, output->wlr_output->transform_matrix);
|
||||
|
||||
render_texture(output->wlr_output, output_damage, title_texture,
|
||||
&texture_box, matrix, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -319,9 +404,8 @@ static void render_container_simple_border_normal(struct sway_output *output,
|
|||
* Render decorations for a view with "border pixel".
|
||||
*/
|
||||
static void render_container_simple_border_pixel(struct sway_output *output,
|
||||
struct sway_container *con, struct border_colors *colors) {
|
||||
struct wlr_renderer *renderer =
|
||||
wlr_backend_get_renderer(output->wlr_output->backend);
|
||||
pixman_region32_t *output_damage, struct sway_container *con,
|
||||
struct border_colors *colors) {
|
||||
struct wlr_box box;
|
||||
float color[4];
|
||||
|
||||
|
|
@ -332,9 +416,7 @@ static void render_container_simple_border_pixel(struct sway_output *output,
|
|||
box.y = con->y;
|
||||
box.width = con->sway_view->border_thickness;
|
||||
box.height = con->height;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Child border - right edge
|
||||
if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) {
|
||||
|
|
@ -347,18 +429,14 @@ static void render_container_simple_border_pixel(struct sway_output *output,
|
|||
box.y = con->y;
|
||||
box.width = con->sway_view->border_thickness;
|
||||
box.height = con->height;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Child border - top edge
|
||||
box.x = con->x;
|
||||
box.y = con->y;
|
||||
box.width = con->width;
|
||||
box.height = con->sway_view->border_thickness;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Child border - bottom edge
|
||||
if (con->parent->children->length == 1 && con->parent->layout == L_VERT) {
|
||||
|
|
@ -371,18 +449,15 @@ static void render_container_simple_border_pixel(struct sway_output *output,
|
|||
box.y = con->y + con->height - con->sway_view->border_thickness;
|
||||
box.width = con->width;
|
||||
box.height = con->sway_view->border_thickness;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render decorations for the left, right, and bottom edge of a view with "border normal".
|
||||
*/
|
||||
static void render_container_border_outline_normal(struct sway_output *output,
|
||||
struct sway_container *con, struct border_colors *colors) {
|
||||
struct wlr_renderer *renderer =
|
||||
wlr_backend_get_renderer(output->wlr_output->backend);
|
||||
pixman_region32_t *output_damage, struct sway_container *con,
|
||||
struct border_colors *colors) {
|
||||
struct wlr_box box;
|
||||
float color[4];
|
||||
|
||||
|
|
@ -393,9 +468,7 @@ static void render_container_border_outline_normal(struct sway_output *output,
|
|||
box.y = con->y + (con->sway_view->y - con->y);
|
||||
box.width = con->sway_view->border_thickness;
|
||||
box.height = con->height;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Child border - right edge
|
||||
if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) {
|
||||
|
|
@ -408,9 +481,7 @@ static void render_container_border_outline_normal(struct sway_output *output,
|
|||
box.y = con->y + (con->sway_view->y - con->y);
|
||||
box.width = con->sway_view->border_thickness;
|
||||
box.height = con->height;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Child border - bottom edge
|
||||
if (con->parent->children->length == 1 && con->parent->layout == L_VERT) {
|
||||
|
|
@ -423,20 +494,16 @@ static void render_container_border_outline_normal(struct sway_output *output,
|
|||
box.y = con->y + con->height - con->sway_view->border_thickness;
|
||||
box.width = con->width;
|
||||
box.height = con->sway_view->border_thickness;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render decorations for the top border for tabbed view with "border normal".
|
||||
*/
|
||||
static void render_container_top_tabbed_border_normal(struct sway_output *output,
|
||||
struct sway_container *con, struct border_colors *colors,
|
||||
struct wlr_texture *title_texture, size_t depth) {
|
||||
|
||||
struct wlr_renderer *renderer =
|
||||
wlr_backend_get_renderer(output->wlr_output->backend);
|
||||
pixman_region32_t *output_damage, struct sway_container *con,
|
||||
struct border_colors *colors, struct wlr_texture *title_texture,
|
||||
size_t depth) {
|
||||
struct wlr_box box;
|
||||
float color[4];
|
||||
double num_tabs = con->parent->children->length;
|
||||
|
|
@ -449,9 +516,7 @@ static void render_container_top_tabbed_border_normal(struct sway_output *output
|
|||
box.y = con->y;
|
||||
box.width = ceil(con->width / num_tabs);
|
||||
box.height = 1;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Single pixel bar below title
|
||||
box.x = floor(con->x + depth*tab_width);
|
||||
|
|
@ -459,8 +524,7 @@ static void render_container_top_tabbed_border_normal(struct sway_output *output
|
|||
box.width = ceil(con->width / num_tabs);
|
||||
box.height = 1;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Tab separator on the left
|
||||
box.x = floor(con->x + depth * tab_width);
|
||||
|
|
@ -468,8 +532,7 @@ static void render_container_top_tabbed_border_normal(struct sway_output *output
|
|||
box.width = ceil(con->sway_view->border_thickness);
|
||||
box.height = con->sway_view->y - con->y - 2;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Tab separator on the right
|
||||
box.x = floor(con->x + (depth + 1) * tab_width - con->sway_view->border_thickness);
|
||||
|
|
@ -477,8 +540,7 @@ static void render_container_top_tabbed_border_normal(struct sway_output *output
|
|||
box.width = ceil(con->sway_view->border_thickness);
|
||||
box.height = con->sway_view->y - con->y - 2;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Title background
|
||||
memcpy(&color, colors->background, sizeof(float) * 4);
|
||||
|
|
@ -488,20 +550,29 @@ static void render_container_top_tabbed_border_normal(struct sway_output *output
|
|||
box.width = ceil(con->width / num_tabs - con->sway_view->border_thickness * 2);
|
||||
box.height = con->sway_view->y - con->y - 2;
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
wlr_render_rect(renderer, &box, color,
|
||||
output->wlr_output->transform_matrix);
|
||||
render_rect(output->wlr_output, output_damage, &box, color);
|
||||
|
||||
// Title text
|
||||
if (title_texture) {
|
||||
wlr_renderer_scissor(renderer, &box);
|
||||
wlr_render_texture(renderer, title_texture,
|
||||
output->wlr_output->transform_matrix, box.x, box.y, 1);
|
||||
wlr_renderer_scissor(renderer, NULL);
|
||||
float output_scale = output->wlr_output->scale;
|
||||
struct wlr_box texture_box = {
|
||||
.x = box.x * output_scale,
|
||||
.y = box.y * output_scale,
|
||||
};
|
||||
wlr_texture_get_size(title_texture,
|
||||
&texture_box.width, &texture_box.height);
|
||||
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, &texture_box, WL_OUTPUT_TRANSFORM_NORMAL,
|
||||
0.0, output->wlr_output->transform_matrix);
|
||||
|
||||
render_texture(output->wlr_output, output_damage, title_texture,
|
||||
&texture_box, matrix, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
static void render_container(struct sway_output *output,
|
||||
struct sway_container *con);
|
||||
pixman_region32_t *damage, struct sway_container *con, bool parent_focused);
|
||||
|
||||
/**
|
||||
* Render a container's children using a L_HORIZ or L_VERT layout.
|
||||
|
|
@ -510,7 +581,8 @@ static void render_container(struct sway_output *output,
|
|||
* they'll apply their own borders to their children.
|
||||
*/
|
||||
static void render_container_simple(struct sway_output *output,
|
||||
struct sway_container *con) {
|
||||
pixman_region32_t *damage, struct sway_container *con,
|
||||
bool parent_focused) {
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_container *focus = seat_get_focus(seat);
|
||||
|
||||
|
|
@ -521,7 +593,7 @@ static void render_container_simple(struct sway_output *output,
|
|||
if (child->sway_view->border != B_NONE) {
|
||||
struct border_colors *colors;
|
||||
struct wlr_texture *title_texture;
|
||||
if (focus == child) {
|
||||
if (focus == child || parent_focused) {
|
||||
colors = &config->border_colors.focused;
|
||||
title_texture = child->title_focused;
|
||||
} else if (seat_get_focus_inactive(seat, con) == child) {
|
||||
|
|
@ -533,15 +605,17 @@ static void render_container_simple(struct sway_output *output,
|
|||
}
|
||||
|
||||
if (child->sway_view->border == B_NORMAL) {
|
||||
render_container_simple_border_normal(output, child,
|
||||
colors, title_texture);
|
||||
render_container_simple_border_normal(output, damage,
|
||||
child, colors, title_texture);
|
||||
} else {
|
||||
render_container_simple_border_pixel(output, child, colors);
|
||||
render_container_simple_border_pixel(output, damage, child,
|
||||
colors);
|
||||
}
|
||||
}
|
||||
render_view(child->sway_view, output);
|
||||
render_view(child->sway_view, output, damage);
|
||||
} else {
|
||||
render_container(output, child);
|
||||
render_container(output, damage, child,
|
||||
parent_focused || focus == child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -549,8 +623,9 @@ static void render_container_simple(struct sway_output *output,
|
|||
/**
|
||||
* Render a container's children using the L_TABBED layout.
|
||||
*/
|
||||
static void render_container_tabbed(struct sway_output *output,
|
||||
struct sway_container *con) {
|
||||
static void render_container_tabbed(struct sway_output *output,
|
||||
pixman_region32_t *damage, struct sway_container *con,
|
||||
bool parent_focused) {
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_container *focus = seat_get_focus(seat);
|
||||
|
||||
|
|
@ -562,7 +637,7 @@ static void render_container_tabbed(struct sway_output *output,
|
|||
if (child->type == C_VIEW) {
|
||||
struct border_colors *colors;
|
||||
struct wlr_texture *title_texture;
|
||||
if (focus == child) {
|
||||
if (focus == child || parent_focused) {
|
||||
colors = &config->border_colors.focused;
|
||||
title_texture = child->title_focused;
|
||||
active_child = child;
|
||||
|
|
@ -576,16 +651,18 @@ static void render_container_tabbed(struct sway_output *output,
|
|||
}
|
||||
|
||||
if (child->sway_view->border != B_NONE) {
|
||||
render_container_top_tabbed_border_normal(output, child, colors,
|
||||
title_texture, i);
|
||||
render_container_top_tabbed_border_normal(output, damage,
|
||||
child, colors, title_texture, i);
|
||||
}
|
||||
} else {
|
||||
render_container(output, child);
|
||||
render_container(output, damage, child,
|
||||
parent_focused || focus == child);
|
||||
}
|
||||
}
|
||||
if (active_child) {
|
||||
render_container_border_outline_normal(output, active_child, focused_colors);
|
||||
render_view(active_child->sway_view, output);
|
||||
render_container_border_outline_normal(output, damage, active_child,
|
||||
focused_colors);
|
||||
render_view(active_child->sway_view, output, damage);
|
||||
} else {
|
||||
wlr_log(L_INFO, "tabbed layout has no active child");
|
||||
}
|
||||
|
|
@ -595,23 +672,24 @@ static void render_container_tabbed(struct sway_output *output,
|
|||
* Render a container's children using the L_STACKED layout.
|
||||
*/
|
||||
static void render_container_stacked(struct sway_output *output,
|
||||
struct sway_container *con) {
|
||||
pixman_region32_t *damage, struct sway_container *con) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
static void render_container(struct sway_output *output,
|
||||
struct sway_container *con) {
|
||||
pixman_region32_t *damage, struct sway_container *con,
|
||||
bool parent_focused) {
|
||||
switch (con->layout) {
|
||||
case L_NONE:
|
||||
case L_HORIZ:
|
||||
case L_VERT:
|
||||
render_container_simple(output, con);
|
||||
render_container_simple(output, damage, con, parent_focused);
|
||||
break;
|
||||
case L_STACKED:
|
||||
render_container_stacked(output, con);
|
||||
render_container_stacked(output, damage, con);
|
||||
break;
|
||||
case L_TABBED:
|
||||
render_container_tabbed(output, con);
|
||||
render_container_tabbed(output, damage, con, parent_focused);
|
||||
break;
|
||||
case L_FLOATING:
|
||||
// TODO
|
||||
|
|
@ -653,37 +731,53 @@ static void render_output(struct sway_output *output, struct timespec *when,
|
|||
goto renderer_end;
|
||||
}
|
||||
|
||||
// TODO: don't damage the whole output
|
||||
int width, height;
|
||||
wlr_output_transformed_resolution(wlr_output, &width, &height);
|
||||
pixman_region32_union_rect(damage, damage, 0, 0, width, height);
|
||||
//wlr_renderer_clear(renderer, (float[]){1, 1, 0, 1});
|
||||
|
||||
struct sway_container *workspace = output_get_active_workspace(output);
|
||||
|
||||
if (workspace->sway_workspace->fullscreen) {
|
||||
float clear_color[] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
wlr_renderer_clear(renderer, clear_color);
|
||||
|
||||
int nrects;
|
||||
pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects);
|
||||
for (int i = 0; i < nrects; ++i) {
|
||||
scissor_output(wlr_output, &rects[i]);
|
||||
wlr_renderer_clear(renderer, clear_color);
|
||||
}
|
||||
|
||||
// TODO: handle views smaller than the output
|
||||
render_view(workspace->sway_workspace->fullscreen, output);
|
||||
render_view(workspace->sway_workspace->fullscreen, output, damage);
|
||||
|
||||
if (workspace->sway_workspace->fullscreen->type == SWAY_VIEW_XWAYLAND) {
|
||||
render_unmanaged(output,
|
||||
&root_container.sway_root->xwayland_unmanaged);
|
||||
render_unmanaged(output, damage,
|
||||
&root_container.sway_root->xwayland_unmanaged);
|
||||
}
|
||||
} else {
|
||||
float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
|
||||
wlr_renderer_clear(renderer, clear_color);
|
||||
|
||||
render_layer(output,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]);
|
||||
render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]);
|
||||
int nrects;
|
||||
pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects);
|
||||
for (int i = 0; i < nrects; ++i) {
|
||||
scissor_output(wlr_output, &rects[i]);
|
||||
wlr_renderer_clear(renderer, clear_color);
|
||||
}
|
||||
|
||||
render_container(output, workspace);
|
||||
render_layer(output, damage,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]);
|
||||
render_layer(output, damage,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]);
|
||||
|
||||
render_unmanaged(output, &root_container.sway_root->xwayland_unmanaged);
|
||||
render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
struct sway_container *focus = seat_get_focus(seat);
|
||||
render_container(output, damage, workspace, focus == workspace);
|
||||
|
||||
render_unmanaged(output, damage,
|
||||
&root_container.sway_root->xwayland_unmanaged);
|
||||
render_layer(output, damage,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
|
||||
}
|
||||
render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
|
||||
render_layer(output, damage,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
|
||||
|
||||
renderer_end:
|
||||
if (root_container.sway_root->debug_tree) {
|
||||
|
|
@ -691,6 +785,7 @@ renderer_end:
|
|||
wlr_output->transform_matrix, 0, 0, 1);
|
||||
}
|
||||
|
||||
wlr_renderer_scissor(renderer, NULL);
|
||||
wlr_renderer_end(renderer);
|
||||
if (!wlr_output_damage_swap_buffers(output->damage, when, damage)) {
|
||||
return;
|
||||
|
|
@ -820,28 +915,28 @@ static void damage_surface_iterator(struct wlr_surface *surface, int sx, int sy,
|
|||
|
||||
scale_box(&box, output->wlr_output->scale);
|
||||
|
||||
int center_x = box.x + box.width/2;
|
||||
int center_y = box.y + box.height/2;
|
||||
|
||||
pixman_region32_t damage;
|
||||
pixman_region32_init(&damage);
|
||||
pixman_region32_copy(&damage, &surface->current->surface_damage);
|
||||
wlr_region_scale(&damage, &damage, output->wlr_output->scale);
|
||||
if (ceil(output->wlr_output->scale) > surface->current->scale) {
|
||||
// When scaling up a surface, it'll become blurry so we need to
|
||||
// expand the damage region
|
||||
wlr_region_expand(&damage, &damage,
|
||||
ceil(output->wlr_output->scale) - surface->current->scale);
|
||||
}
|
||||
pixman_region32_translate(&damage, box.x, box.y);
|
||||
wlr_region_rotated_bounds(&damage, &damage, rotation,
|
||||
center_x, center_y);
|
||||
wlr_output_damage_add(output->damage, &damage);
|
||||
pixman_region32_fini(&damage);
|
||||
|
||||
if (whole) {
|
||||
wlr_box_rotated_bounds(&box, rotation, &box);
|
||||
wlr_output_damage_add_box(output->damage, &box);
|
||||
} else {
|
||||
int center_x = box.x + box.width/2;
|
||||
int center_y = box.y + box.height/2;
|
||||
|
||||
pixman_region32_t damage;
|
||||
pixman_region32_init(&damage);
|
||||
pixman_region32_copy(&damage, &surface->current->surface_damage);
|
||||
wlr_region_scale(&damage, &damage, output->wlr_output->scale);
|
||||
if (ceil(output->wlr_output->scale) > surface->current->scale) {
|
||||
// When scaling up a surface, it'll become blurry so we need to
|
||||
// expand the damage region
|
||||
wlr_region_expand(&damage, &damage,
|
||||
ceil(output->wlr_output->scale) - surface->current->scale);
|
||||
}
|
||||
pixman_region32_translate(&damage, box.x, box.y);
|
||||
wlr_region_rotated_bounds(&damage, &damage, rotation,
|
||||
center_x, center_y);
|
||||
wlr_output_damage_add(output->damage, &damage);
|
||||
pixman_region32_fini(&damage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -856,8 +951,8 @@ void output_damage_surface(struct sway_output *output, double ox, double oy,
|
|||
damage_surface_iterator, &data);
|
||||
}
|
||||
|
||||
void output_damage_view(struct sway_output *output, struct sway_view *view,
|
||||
bool whole) {
|
||||
static void output_damage_view(struct sway_output *output,
|
||||
struct sway_view *view, bool whole) {
|
||||
if (!sway_assert(view->swayc != NULL, "expected a view in the tree")) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -877,6 +972,11 @@ void output_damage_view(struct sway_output *output, struct sway_view *view,
|
|||
damage_surface_iterator, &data);
|
||||
}
|
||||
|
||||
void output_damage_from_view(struct sway_output *output,
|
||||
struct sway_view *view) {
|
||||
output_damage_view(output, view, false);
|
||||
}
|
||||
|
||||
static void output_damage_whole_container_iterator(struct sway_container *con,
|
||||
void *data) {
|
||||
struct sway_output *output = data;
|
||||
|
|
@ -899,8 +999,12 @@ void output_damage_whole_container(struct sway_output *output,
|
|||
};
|
||||
wlr_output_damage_add_box(output->damage, &box);
|
||||
|
||||
container_descendants(con, C_VIEW, output_damage_whole_container_iterator,
|
||||
output);
|
||||
if (con->type == C_VIEW) {
|
||||
output_damage_whole_container_iterator(con, output);
|
||||
} else {
|
||||
container_descendants(con, C_VIEW,
|
||||
output_damage_whole_container_iterator, output);
|
||||
}
|
||||
}
|
||||
|
||||
static void damage_handle_destroy(struct wl_listener *listener, void *data) {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
|||
// TODO: Let floating views do whatever
|
||||
view_update_size(view, wl_shell_view->pending_width,
|
||||
wl_shell_view->pending_height);
|
||||
view_damage(view, false);
|
||||
view_damage_from(view);
|
||||
}
|
||||
|
||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
|||
view_update_size(view, xdg_shell_v6_view->pending_width,
|
||||
xdg_shell_v6_view->pending_height);
|
||||
view_update_title(view, false);
|
||||
view_damage(view, false);
|
||||
view_damage_from(view);
|
||||
}
|
||||
|
||||
static void handle_new_popup(struct wl_listener *listener, void *data) {
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
|||
// TODO: Let floating views do whatever
|
||||
view_update_size(view, xwayland_view->pending_width,
|
||||
xwayland_view->pending_height);
|
||||
view_damage(view, false);
|
||||
view_damage_from(view);
|
||||
view_update_title(view, false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,27 +65,49 @@ static void seat_container_destroy(struct sway_seat_container *seat_con) {
|
|||
free(seat_con);
|
||||
}
|
||||
|
||||
static void seat_send_focus(struct sway_seat *seat,
|
||||
struct sway_container *con) {
|
||||
if (con->type != C_VIEW) {
|
||||
return;
|
||||
}
|
||||
struct sway_view *view = con->sway_view;
|
||||
if (view->type == SWAY_VIEW_XWAYLAND) {
|
||||
struct wlr_xwayland *xwayland =
|
||||
seat->input->server->xwayland;
|
||||
wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
|
||||
}
|
||||
view_set_activated(view, true);
|
||||
struct wlr_keyboard *keyboard =
|
||||
wlr_seat_get_keyboard(seat->wlr_seat);
|
||||
if (keyboard) {
|
||||
wlr_seat_keyboard_notify_enter(seat->wlr_seat,
|
||||
view->surface, keyboard->keycodes,
|
||||
keyboard->num_keycodes, &keyboard->modifiers);
|
||||
/**
|
||||
* Activate all views within this container recursively.
|
||||
*/
|
||||
static void seat_send_activate(struct sway_container *con,
|
||||
struct sway_seat *seat) {
|
||||
if (con->type == C_VIEW) {
|
||||
if (!seat_is_input_allowed(seat, con->sway_view->surface)) {
|
||||
wlr_log(L_DEBUG, "Refusing to set focus, input is inhibited");
|
||||
return;
|
||||
}
|
||||
view_set_activated(con->sway_view, true);
|
||||
} else {
|
||||
wlr_seat_keyboard_notify_enter(
|
||||
seat->wlr_seat, view->surface, NULL, 0, NULL);
|
||||
for (int i = 0; i < con->children->length; ++i) {
|
||||
struct sway_container *child = con->children->items[i];
|
||||
seat_send_activate(child, seat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If con is a view, set it as active and enable keyboard input.
|
||||
* If con is a container, set all child views as active and don't enable
|
||||
* keyboard input on any.
|
||||
*/
|
||||
static void seat_send_focus(struct sway_container *con,
|
||||
struct sway_seat *seat) {
|
||||
seat_send_activate(con, seat);
|
||||
|
||||
if (con->type == C_VIEW
|
||||
&& seat_is_input_allowed(seat, con->sway_view->surface)) {
|
||||
if (con->sway_view->type == SWAY_VIEW_XWAYLAND) {
|
||||
struct wlr_xwayland *xwayland = seat->input->server->xwayland;
|
||||
wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
|
||||
}
|
||||
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat);
|
||||
if (keyboard) {
|
||||
wlr_seat_keyboard_notify_enter(seat->wlr_seat,
|
||||
con->sway_view->surface, keyboard->keycodes,
|
||||
keyboard->num_keycodes, &keyboard->modifiers);
|
||||
} else {
|
||||
wlr_seat_keyboard_notify_enter(
|
||||
seat->wlr_seat, con->sway_view->surface, NULL, 0, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +182,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener,
|
|||
// the structure change might have caused it to move up to the top of
|
||||
// the focus stack without sending focus notifications to the view
|
||||
if (seat_get_focus(seat) == next_focus) {
|
||||
seat_send_focus(seat, next_focus);
|
||||
seat_send_focus(next_focus, seat);
|
||||
} else {
|
||||
seat_set_focus(seat, next_focus);
|
||||
}
|
||||
|
|
@ -457,6 +479,20 @@ bool seat_is_input_allowed(struct sway_seat *seat,
|
|||
return !seat->exclusive_client || seat->exclusive_client == client;
|
||||
}
|
||||
|
||||
// Unfocus the container and any children (eg. when leaving `focus parent`)
|
||||
static void seat_send_unfocus(struct sway_container *container,
|
||||
struct sway_seat *seat) {
|
||||
if (container->type == C_VIEW) {
|
||||
wlr_seat_keyboard_clear_focus(seat->wlr_seat);
|
||||
view_set_activated(container->sway_view, false);
|
||||
} else {
|
||||
for (int i = 0; i < container->children->length; ++i) {
|
||||
struct sway_container *child = container->children->items[i];
|
||||
seat_send_unfocus(child, seat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void seat_set_focus_warp(struct sway_seat *seat,
|
||||
struct sway_container *container, bool warp) {
|
||||
if (seat->focused_layer) {
|
||||
|
|
@ -521,15 +557,12 @@ void seat_set_focus_warp(struct sway_seat *seat,
|
|||
wl_list_remove(&seat_con->link);
|
||||
wl_list_insert(&seat->focus_stack, &seat_con->link);
|
||||
|
||||
if (container->type == C_VIEW && !seat_is_input_allowed(
|
||||
seat, container->sway_view->surface)) {
|
||||
wlr_log(L_DEBUG, "Refusing to set focus, input is inhibited");
|
||||
return;
|
||||
if (last_focus) {
|
||||
seat_send_unfocus(last_focus, seat);
|
||||
}
|
||||
|
||||
if (container->type == C_VIEW) {
|
||||
seat_send_focus(seat, container);
|
||||
}
|
||||
seat_send_focus(container, seat);
|
||||
container_damage_whole(container);
|
||||
}
|
||||
|
||||
// clean up unfocused empty workspace on new output
|
||||
|
|
@ -575,10 +608,8 @@ void seat_set_focus_warp(struct sway_seat *seat,
|
|||
}
|
||||
}
|
||||
|
||||
if (last_focus && last_focus->type == C_VIEW &&
|
||||
!input_manager_has_focus(seat->input, last_focus)) {
|
||||
struct sway_view *view = last_focus->sway_view;
|
||||
view_set_activated(view, false);
|
||||
if (last_focus) {
|
||||
container_damage_whole(last_focus);
|
||||
}
|
||||
|
||||
if (last_workspace && last_workspace != new_workspace) {
|
||||
|
|
@ -602,10 +633,7 @@ void seat_set_focus_surface(struct sway_seat *seat,
|
|||
}
|
||||
if (seat->has_focus) {
|
||||
struct sway_container *focus = seat_get_focus(seat);
|
||||
if (focus->type == C_VIEW) {
|
||||
wlr_seat_keyboard_clear_focus(seat->wlr_seat);
|
||||
view_set_activated(focus->sway_view, false);
|
||||
}
|
||||
seat_send_unfocus(focus, seat);
|
||||
seat->has_focus = false;
|
||||
}
|
||||
struct wlr_keyboard *keyboard =
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@ bool server_init(struct sway_server *server) {
|
|||
server->wl_event_loop = wl_display_get_event_loop(server->wl_display);
|
||||
server->backend = wlr_backend_autocreate(server->wl_display);
|
||||
|
||||
if (!server->backend) {
|
||||
wlr_log(L_ERROR, "Unable to create backend");
|
||||
return false;
|
||||
}
|
||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(server->backend);
|
||||
assert(renderer);
|
||||
|
||||
|
|
|
|||
|
|
@ -582,12 +582,13 @@ bool container_has_child(struct sway_container *con,
|
|||
return container_find(con, find_child_func, child);
|
||||
}
|
||||
|
||||
void container_damage_whole(struct sway_container *con) {
|
||||
struct sway_container *output = con;
|
||||
if (output->type != C_OUTPUT) {
|
||||
output = container_parent(output, C_OUTPUT);
|
||||
void container_damage_whole(struct sway_container *container) {
|
||||
for (int i = 0; i < root_container.children->length; ++i) {
|
||||
struct sway_container *cont = root_container.children->items[i];
|
||||
if (cont->type == C_OUTPUT) {
|
||||
output_damage_whole_container(cont->sway_output, container);
|
||||
}
|
||||
}
|
||||
output_damage_whole_container(output->sway_output, con);
|
||||
}
|
||||
|
||||
static void update_title_texture(struct sway_container *con,
|
||||
|
|
@ -655,6 +656,7 @@ void container_update_title_textures(struct sway_container *container) {
|
|||
&config->border_colors.unfocused);
|
||||
update_title_texture(container, &container->title_urgent,
|
||||
&config->border_colors.urgent);
|
||||
container_damage_whole(container);
|
||||
}
|
||||
|
||||
void container_calculate_title_height(struct sway_container *container) {
|
||||
|
|
|
|||
|
|
@ -199,11 +199,11 @@ void view_close(struct sway_view *view) {
|
|||
}
|
||||
}
|
||||
|
||||
void view_damage(struct sway_view *view, bool whole) {
|
||||
void view_damage_from(struct sway_view *view) {
|
||||
for (int i = 0; i < root_container.children->length; ++i) {
|
||||
struct sway_container *cont = root_container.children->items[i];
|
||||
if (cont->type == C_OUTPUT) {
|
||||
output_damage_view(cont->sway_output, view, whole);
|
||||
output_damage_from_view(cont->sway_output, view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -333,7 +333,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
|
|||
arrange_children_of(cont->parent);
|
||||
input_manager_set_focus(input_manager, cont);
|
||||
|
||||
view_damage(view, true);
|
||||
container_damage_whole(cont);
|
||||
view_handle_container_reparent(&view->container_reparent, NULL);
|
||||
|
||||
view_execute_criteria(view);
|
||||
|
|
@ -351,7 +351,7 @@ void view_unmap(struct sway_view *view) {
|
|||
ws->sway_workspace->fullscreen = NULL;
|
||||
}
|
||||
|
||||
view_damage(view, true);
|
||||
container_damage_whole(view->swayc);
|
||||
|
||||
wl_list_remove(&view->surface_new_subsurface.link);
|
||||
wl_list_remove(&view->container_reparent.link);
|
||||
|
|
@ -380,10 +380,10 @@ void view_update_position(struct sway_view *view, double ox, double oy) {
|
|||
|
||||
// TODO: Only allow this if the view is floating (this function will only be
|
||||
// called in response to wayland clients wanting to reposition themselves).
|
||||
view_damage(view, true);
|
||||
container_damage_whole(view->swayc);
|
||||
view->swayc->x = ox;
|
||||
view->swayc->y = oy;
|
||||
view_damage(view, true);
|
||||
container_damage_whole(view->swayc);
|
||||
}
|
||||
|
||||
void view_update_size(struct sway_view *view, int width, int height) {
|
||||
|
|
@ -391,11 +391,11 @@ void view_update_size(struct sway_view *view, int width, int height) {
|
|||
return;
|
||||
}
|
||||
|
||||
view_damage(view, true);
|
||||
container_damage_whole(view->swayc);
|
||||
// Should we update the swayc width/height here too?
|
||||
view->width = width;
|
||||
view->height = height;
|
||||
view_damage(view, true);
|
||||
container_damage_whole(view->swayc);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -414,7 +414,7 @@ static void view_child_handle_surface_commit(struct wl_listener *listener,
|
|||
struct sway_view_child *child =
|
||||
wl_container_of(listener, child, surface_commit);
|
||||
// TODO: only accumulate damage from the child
|
||||
view_damage(child->view, false);
|
||||
view_damage_from(child->view);
|
||||
}
|
||||
|
||||
static void view_child_handle_surface_new_subsurface(
|
||||
|
|
@ -476,12 +476,16 @@ void view_child_init(struct sway_view_child *child,
|
|||
view_init_subsurfaces(child->view, surface);
|
||||
|
||||
// TODO: only damage the whole child
|
||||
view_damage(child->view, true);
|
||||
if (child->view->swayc) {
|
||||
container_damage_whole(child->view->swayc);
|
||||
}
|
||||
}
|
||||
|
||||
void view_child_destroy(struct sway_view_child *child) {
|
||||
// TODO: only damage the whole child
|
||||
view_damage(child->view, true);
|
||||
if (child->view->swayc) {
|
||||
container_damage_whole(child->view->swayc);
|
||||
}
|
||||
|
||||
wl_list_remove(&child->surface_commit.link);
|
||||
wl_list_remove(&child->surface_destroy.link);
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo,
|
|||
|
||||
int text_width, text_height;
|
||||
get_text_size(cairo, config->font, &text_width, &text_height,
|
||||
output->scale, true, "%s", mode);
|
||||
output->scale, config->pango_markup, "%s", mode);
|
||||
|
||||
int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale;
|
||||
int ws_horizontal_padding = WS_HORIZONTAL_PADDING * output->scale;
|
||||
|
|
@ -329,7 +329,8 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo,
|
|||
double text_y = height / 2.0 - text_height / 2.0;
|
||||
cairo_set_source_u32(cairo, config->colors.binding_mode.text);
|
||||
cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y));
|
||||
pango_printf(cairo, config->font, output->scale, true, "%s", mode);
|
||||
pango_printf(cairo, config->font, output->scale, config->pango_markup,
|
||||
"%s", mode);
|
||||
return surface_height;
|
||||
}
|
||||
|
||||
|
|
@ -374,7 +375,7 @@ static uint32_t render_workspace_button(cairo_t *cairo,
|
|||
|
||||
int text_width, text_height;
|
||||
get_text_size(cairo, config->font, &text_width, &text_height,
|
||||
output->scale, true, "%s", name);
|
||||
output->scale, config->pango_markup, "%s", name);
|
||||
|
||||
int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale;
|
||||
int ws_horizontal_padding = WS_HORIZONTAL_PADDING * output->scale;
|
||||
|
|
@ -406,7 +407,8 @@ static uint32_t render_workspace_button(cairo_t *cairo,
|
|||
double text_y = height / 2.0 - text_height / 2.0;
|
||||
cairo_set_source_u32(cairo, box_colors.text);
|
||||
cairo_move_to(cairo, *x + width / 2 - text_width / 2, (int)floor(text_y));
|
||||
pango_printf(cairo, config->font, output->scale, true, "%s", name);
|
||||
pango_printf(cairo, config->font, output->scale, config->pango_markup,
|
||||
"%s", name);
|
||||
|
||||
struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot));
|
||||
hotspot->x = *x;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue