mirror of
https://github.com/swaywm/sway.git
synced 2026-04-26 06:46:26 -04:00
Add border texture class usage
This commit is contained in:
parent
de5609ad55
commit
c329a40f91
3 changed files with 42 additions and 8 deletions
|
|
@ -260,6 +260,8 @@ void container_floating_move_to_center(struct sway_container *con);
|
||||||
|
|
||||||
bool container_has_urgent_child(struct sway_container *container);
|
bool container_has_urgent_child(struct sway_container *container);
|
||||||
|
|
||||||
|
bool container_has_focused_child(struct sway_container *container);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the container is involved in a drag or resize operation via a mouse, this
|
* If the container is involved in a drag or resize operation via a mouse, this
|
||||||
* ends the operation.
|
* ends the operation.
|
||||||
|
|
|
||||||
|
|
@ -818,6 +818,30 @@ struct output_and_damage {
|
||||||
pixman_region32_t *damage;
|
pixman_region32_t *damage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines which border texture class to render for a given container.
|
||||||
|
*/
|
||||||
|
struct border_textures *get_border_textures_for_container(
|
||||||
|
struct sway_container *con) {
|
||||||
|
if (container_has_urgent_child(con)) {
|
||||||
|
return &config->border_textures.urgent;
|
||||||
|
}
|
||||||
|
if (container_has_focused_child(con) || con->current.focused) {
|
||||||
|
return &config->border_textures.focused;
|
||||||
|
}
|
||||||
|
if (!con->children) {
|
||||||
|
return &config->border_textures.unfocused;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < con->children->length; ++i) {
|
||||||
|
struct sway_container *child = con->children->items[i];
|
||||||
|
if (child == con->current.focused_inactive_child) {
|
||||||
|
return &config->border_textures.focused_inactive;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &config->border_textures.unfocused;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render all of the border textures for a container.
|
* Render all of the border textures for a container.
|
||||||
*/
|
*/
|
||||||
|
|
@ -842,18 +866,19 @@ static void render_border_textures_for_container(struct sway_container *con,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct border_textures *textures;
|
|
||||||
bypass_border_checks:
|
|
||||||
// TODO: Use the appropriate border_texture based on children
|
|
||||||
textures = &config->border_textures.focused;
|
|
||||||
|
|
||||||
struct sway_container_state *state = &con->current;
|
struct border_textures *textures;
|
||||||
|
struct sway_container_state *state;
|
||||||
struct wlr_box box;
|
struct wlr_box box;
|
||||||
|
struct output_and_damage *oad;
|
||||||
|
bypass_border_checks:
|
||||||
|
state = &con->current;
|
||||||
box.x = state->x;
|
box.x = state->x;
|
||||||
box.y = state->y;
|
box.y = state->y;
|
||||||
box.width = state->width;
|
box.width = state->width;
|
||||||
box.height = state->height;
|
box.height = state->height;
|
||||||
struct output_and_damage *oad = (struct output_and_damage *) data;
|
oad = (struct output_and_damage *) data;
|
||||||
|
textures = get_border_textures_for_container(con);
|
||||||
render_border_textures(oad->output, oad->damage, &box, textures->texture, con->alpha);
|
render_border_textures(oad->output, oad->damage, &box, textures->texture, con->alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -868,9 +893,8 @@ static void render_border_textures_for_workspace(struct sway_output *output,
|
||||||
struct wlr_box box;
|
struct wlr_box box;
|
||||||
workspace_get_box(ws, &box);
|
workspace_get_box(ws, &box);
|
||||||
|
|
||||||
// TODO: Use the appropriate border_texture based on children
|
|
||||||
struct border_textures *textures = &config->border_textures.focused;
|
|
||||||
struct sway_container *con = ws->tiling->items[0];
|
struct sway_container *con = ws->tiling->items[0];
|
||||||
|
struct border_textures *textures = get_border_textures_for_container(con);
|
||||||
render_border_textures(output, damage, &box, textures->texture, con->alpha);
|
render_border_textures(output, damage, &box, textures->texture, con->alpha);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -965,6 +965,14 @@ bool container_has_urgent_child(struct sway_container *container) {
|
||||||
return container_find_child(container, find_urgent_iterator, NULL);
|
return container_find_child(container, find_urgent_iterator, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool find_focused_iterator(struct sway_container *con, void *data) {
|
||||||
|
return con->current.focused;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool container_has_focused_child(struct sway_container *container) {
|
||||||
|
return container_find_child(container, find_focused_iterator, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void container_end_mouse_operation(struct sway_container *container) {
|
void container_end_mouse_operation(struct sway_container *container) {
|
||||||
struct sway_seat *seat;
|
struct sway_seat *seat;
|
||||||
wl_list_for_each(seat, &server.input->seats, link) {
|
wl_list_for_each(seat, &server.input->seats, link) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue