Add rounded corners (#9)

This commit is contained in:
William McKinnon 2022-08-21 17:12:54 -04:00 committed by GitHub
parent c5d08f6085
commit 5c0086b944
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 454 additions and 244 deletions

View file

@ -17,9 +17,9 @@ struct cmd_handler {
* Indicates the result of a command's execution. * Indicates the result of a command's execution.
*/ */
enum cmd_status { enum cmd_status {
CMD_SUCCESS, /**< The command was successful */ CMD_SUCCESS, /**< The command was successful */
CMD_FAILURE, /**< The command resulted in an error */ CMD_FAILURE, /**< The command resulted in an error */
CMD_INVALID, /**< Unknown command or parser error */ CMD_INVALID, /**< Unknown command or parser error */
CMD_DEFER, /**< Command execution deferred */ CMD_DEFER, /**< Command execution deferred */
CMD_BLOCK, CMD_BLOCK,
CMD_BLOCK_COMMANDS, CMD_BLOCK_COMMANDS,
@ -118,6 +118,7 @@ sway_cmd cmd_client_urgent;
sway_cmd cmd_client_placeholder; sway_cmd cmd_client_placeholder;
sway_cmd cmd_client_background; sway_cmd cmd_client_background;
sway_cmd cmd_commands; sway_cmd cmd_commands;
sway_cmd cmd_corner_radius;
sway_cmd cmd_create_output; sway_cmd cmd_create_output;
sway_cmd cmd_default_border; sway_cmd cmd_default_border;
sway_cmd cmd_default_floating_border; sway_cmd cmd_default_floating_border;

View file

@ -466,6 +466,9 @@ enum xwayland_mode {
* The configuration struct. The result of loading a config file. * The configuration struct. The result of loading a config file.
*/ */
struct sway_config { struct sway_config {
// SwayFX config options
int corner_radius;
char *swaynag_command; char *swaynag_command;
struct swaynag_instance swaynag_config_errors; struct swaynag_instance swaynag_config_errors;
list_t *symbols; list_t *symbols;

View file

@ -8,6 +8,7 @@ struct gles2_tex_shader {
GLint proj; GLint proj;
GLint tex; GLint tex;
GLint alpha; GLint alpha;
GLint discardOpaque;
GLint pos_attrib; GLint pos_attrib;
GLint tex_attrib; GLint tex_attrib;
}; };
@ -43,10 +44,10 @@ void fx_renderer_scissor(struct wlr_box *box);
bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer, bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer,
struct wlr_texture *wlr_texture, const struct wlr_fbox *box, struct wlr_texture *wlr_texture, const struct wlr_fbox *box,
const float matrix[static 9], float alpha); const float matrix[static 9], float alpha, int radius);
bool fx_render_texture_with_matrix(struct fx_renderer *renderer, bool fx_render_texture_with_matrix(struct fx_renderer *renderer,
struct wlr_texture *wlr_texture, const float matrix[static 9], float alpha); struct wlr_texture *wlr_texture, const float matrix[static 9], float alpha, int radius);
void fx_render_rect(struct fx_renderer *renderer, const struct wlr_box *box, const float color[static 4], const float projection[static 9]); void fx_render_rect(struct fx_renderer *renderer, const struct wlr_box *box, const float color[static 4], const float projection[static 9]);

View file

@ -55,6 +55,7 @@ static const struct cmd_handler handlers[] = {
{ "client.placeholder", cmd_client_noop }, { "client.placeholder", cmd_client_noop },
{ "client.unfocused", cmd_client_unfocused }, { "client.unfocused", cmd_client_unfocused },
{ "client.urgent", cmd_client_urgent }, { "client.urgent", cmd_client_urgent },
{ "corner_radius", cmd_corner_radius },
{ "default_border", cmd_default_border }, { "default_border", cmd_default_border },
{ "default_floating_border", cmd_default_floating_border }, { "default_floating_border", cmd_default_floating_border },
{ "exec", cmd_exec }, { "exec", cmd_exec },

View file

@ -0,0 +1,23 @@
#include <string.h>
#include "sway/commands.h"
#include "sway/config.h"
#include "log.h"
struct cmd_results *cmd_corner_radius(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "corner_radius", EXPECTED_EQUAL_TO, 1))) {
return error;
}
char *inv;
int value = strtol(argv[0], &inv, 10);
if (*inv != '\0' || value < 0 || value > 99) {
return cmd_results_new(CMD_FAILURE, "Invalid size specified");
}
config->corner_radius = value;
// TODO: rerender windows (see opacity cmd)
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -325,6 +325,9 @@ static void config_defaults(struct sway_config *config) {
color_to_rgba(config->border_colors.background, 0xFFFFFFFF); color_to_rgba(config->border_colors.background, 0xFFFFFFFF);
// SwayFX defaults
config->corner_radius = 0;
// The keysym to keycode translation // The keysym to keycode translation
struct xkb_rule_names rules = {0}; struct xkb_rule_names rules = {0};
config->keysym_translation_state = config->keysym_translation_state =

View file

@ -4,6 +4,8 @@
- https://github.com/vaxerski/Hyprland/blob/main/src/render/OpenGL.cpp - https://github.com/vaxerski/Hyprland/blob/main/src/render/OpenGL.cpp
*/ */
// TODO: add push / pop_gles2_debug(renderer)?
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#include <assert.h> #include <assert.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
@ -64,8 +66,57 @@ const GLchar tex_fragment_src_rgba[] =
"uniform sampler2D tex;\n" "uniform sampler2D tex;\n"
"uniform float alpha;\n" "uniform float alpha;\n"
"\n" "\n"
"uniform vec2 topLeft;\n"
"uniform vec2 bottomRight;\n"
"uniform vec2 fullSize;\n"
"uniform float radius;\n"
"\n"
"uniform int discardOpaque;\n"
"\n"
"void main() {\n" "void main() {\n"
" gl_FragColor = texture2D(tex, v_texcoord) * alpha;\n" " vec4 pixColor = texture2D(tex, v_texcoord);\n"
"\n"
" if (discardOpaque == 1 && pixColor[3] * alpha == 1.0) {\n"
" discard;\n"
" return;\n"
" }\n"
"\n"
" vec2 pixCoord = fullSize * v_texcoord;\n"
"\n"
" if (pixCoord[0] < topLeft[0]) {\n"
" // we're close left\n"
" if (pixCoord[1] < topLeft[1]) {\n"
// top
" if (distance(topLeft, pixCoord) > radius) {\n"
" discard;\n"
" return;\n"
" }\n"
" } else if (pixCoord[1] > bottomRight[1]) {\n"
// bottom
" if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord) > radius) {\n"
" discard;\n"
" return;\n"
" }\n"
" }\n"
" }\n"
" else if (pixCoord[0] > bottomRight[0]) {\n"
// we're close right
" if (pixCoord[1] < topLeft[1]) {\n"
// top
" if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord) > radius) {\n"
" discard;\n"
" return;\n"
" }\n"
" } else if (pixCoord[1] > bottomRight[1]) {\n"
// bottom
" if (distance(bottomRight, pixCoord) > radius) {\n"
" discard;\n"
" return;\n"
" }\n"
" }\n"
" }\n"
"\n"
" gl_FragColor = pixColor * alpha;\n"
"}\n"; "}\n";
const GLchar tex_fragment_src_rgbx[] = const GLchar tex_fragment_src_rgbx[] =
@ -74,7 +125,55 @@ const GLchar tex_fragment_src_rgbx[] =
"uniform sampler2D tex;\n" "uniform sampler2D tex;\n"
"uniform float alpha;\n" "uniform float alpha;\n"
"\n" "\n"
"uniform vec2 topLeft;\n"
"uniform vec2 bottomRight;\n"
"uniform vec2 fullSize;\n"
"uniform float radius;\n"
"\n"
"uniform int discardOpaque;\n"
"\n"
"void main() {\n" "void main() {\n"
"\n"
" if (discardOpaque == 1 && alpha == 1.0) {\n"
" discard;\n"
" return;\n"
" }\n"
"\n"
" vec2 pixCoord = fullSize * v_texcoord;\n"
"\n"
" if (pixCoord[0] < topLeft[0]) {\n"
// we're close left
" if (pixCoord[1] < topLeft[1]) {\n"
// top
" if (distance(topLeft, pixCoord) > radius) {\n"
" discard;\n"
" return;\n"
" }\n"
" } else if (pixCoord[1] > bottomRight[1]) {\n"
// bottom
" if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord) > radius) {\n"
" discard;\n"
" return;\n"
" }\n"
" }\n"
" }\n"
" else if (pixCoord[0] > bottomRight[0]) {\n"
// we're close right
" if (pixCoord[1] < topLeft[1]) {\n"
// top
" if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord) > radius) {\n"
" discard;\n"
" return;\n"
" }\n"
" } else if (pixCoord[1] > bottomRight[1]) {\n"
// bottom
" if (distance(bottomRight, pixCoord) > radius) {\n"
" discard;\n"
" return;\n"
" }\n"
" }\n"
" }\n"
"\n"
" gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n" " gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n"
"}\n"; "}\n";
@ -85,8 +184,58 @@ const GLchar tex_fragment_src_external[] =
"uniform samplerExternalOES texture0;\n" "uniform samplerExternalOES texture0;\n"
"uniform float alpha;\n" "uniform float alpha;\n"
"\n" "\n"
"uniform vec2 topLeft;\n"
"uniform vec2 bottomRight;\n"
"uniform vec2 fullSize;\n"
"uniform float radius;\n"
"\n"
"uniform int discardOpaque;\n"
"\n"
"void main() {\n" "void main() {\n"
" gl_FragColor = texture2D(texture0, v_texcoord) * alpha;\n" "\n"
" vec4 pixColor = texture2D(texture0, v_texcoord);\n"
"\n"
" if (discardOpaque == 1 && pixColor[3] * alpha == 1.0) {\n"
" discard;\n"
" return;\n"
" }\n"
"\n"
" vec2 pixCoord = fullSize * v_texcoord;\n"
"\n"
" if (pixCoord[0] < topLeft[0]) {\n"
// we're close left
" if (pixCoord[1] < topLeft[1]) {\n"
// top
" if (distance(topLeft, pixCoord) > radius) {\n"
" discard;\n"
" return;\n"
" }\n"
" } else if (pixCoord[1] > bottomRight[1]) {\n"
// bottom
" if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord) > radius) {\n"
" discard;\n"
" return;\n"
" }\n"
" }\n"
" }\n"
" else if (pixCoord[0] > bottomRight[0]) {\n"
// we're close right
" if (pixCoord[1] < topLeft[1]) {\n"
// top
" if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord) > radius) {\n"
" discard;\n"
" return;\n"
" }\n"
" } else if (pixCoord[1] > bottomRight[1]) {\n"
// bottom
" if (distance(bottomRight, pixCoord) > radius) {\n"
" discard;\n"
" return;\n"
" }\n"
" }\n"
" }\n"
"\n"
" gl_FragColor = pixColor * alpha;\n"
"}\n"; "}\n";
/************************ /************************
@ -207,6 +356,7 @@ struct fx_renderer *fx_renderer_create(struct wlr_egl *egl) {
renderer->shaders.tex_rgba.alpha = glGetUniformLocation(prog, "alpha"); renderer->shaders.tex_rgba.alpha = glGetUniformLocation(prog, "alpha");
renderer->shaders.tex_rgba.pos_attrib = glGetAttribLocation(prog, "pos"); renderer->shaders.tex_rgba.pos_attrib = glGetAttribLocation(prog, "pos");
renderer->shaders.tex_rgba.tex_attrib = glGetAttribLocation(prog, "texcoord"); renderer->shaders.tex_rgba.tex_attrib = glGetAttribLocation(prog, "texcoord");
renderer->shaders.tex_rgba.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
prog = link_program(tex_vertex_src, tex_fragment_src_rgbx); prog = link_program(tex_vertex_src, tex_fragment_src_rgbx);
renderer->shaders.tex_rgbx.program = prog; renderer->shaders.tex_rgbx.program = prog;
@ -218,6 +368,7 @@ struct fx_renderer *fx_renderer_create(struct wlr_egl *egl) {
renderer->shaders.tex_rgbx.alpha = glGetUniformLocation(prog, "alpha"); renderer->shaders.tex_rgbx.alpha = glGetUniformLocation(prog, "alpha");
renderer->shaders.tex_rgbx.pos_attrib = glGetAttribLocation(prog, "pos"); renderer->shaders.tex_rgbx.pos_attrib = glGetAttribLocation(prog, "pos");
renderer->shaders.tex_rgbx.tex_attrib = glGetAttribLocation(prog, "texcoord"); renderer->shaders.tex_rgbx.tex_attrib = glGetAttribLocation(prog, "texcoord");
renderer->shaders.tex_rgbx.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
prog = link_program(tex_vertex_src, tex_fragment_src_external); prog = link_program(tex_vertex_src, tex_fragment_src_external);
renderer->shaders.tex_ext.program = prog; renderer->shaders.tex_ext.program = prog;
@ -229,8 +380,8 @@ struct fx_renderer *fx_renderer_create(struct wlr_egl *egl) {
renderer->shaders.tex_ext.alpha = glGetUniformLocation(prog, "alpha"); renderer->shaders.tex_ext.alpha = glGetUniformLocation(prog, "alpha");
renderer->shaders.tex_ext.pos_attrib = glGetAttribLocation(prog, "pos"); renderer->shaders.tex_ext.pos_attrib = glGetAttribLocation(prog, "pos");
renderer->shaders.tex_ext.tex_attrib = glGetAttribLocation(prog, "texcoord"); renderer->shaders.tex_ext.tex_attrib = glGetAttribLocation(prog, "texcoord");
renderer->shaders.tex_ext.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
// TODO: if remove renderer->egl, replace below with r->egl
wlr_egl_unset_current(renderer->egl); wlr_egl_unset_current(renderer->egl);
sway_log(SWAY_INFO, "GLES2 RENDERER: Shaders Initialized Successfully"); sway_log(SWAY_INFO, "GLES2 RENDERER: Shaders Initialized Successfully");
@ -262,7 +413,7 @@ void fx_renderer_begin(struct fx_renderer *renderer, uint32_t width, uint32_t he
} }
void fx_renderer_end() { void fx_renderer_end() {
// TODO
} }
void fx_renderer_clear(const float color[static 4]) { void fx_renderer_clear(const float color[static 4]) {
@ -285,7 +436,7 @@ void fx_renderer_scissor(struct wlr_box *box) {
bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer, bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer,
struct wlr_texture *wlr_texture, const struct wlr_fbox *box, struct wlr_texture *wlr_texture, const struct wlr_fbox *box,
const float matrix[static 9], float alpha) { const float matrix[static 9], float alpha, int radius) {
assert(wlr_texture_is_gles2(wlr_texture)); assert(wlr_texture_is_gles2(wlr_texture));
struct wlr_gles2_texture_attribs texture_attrs; struct wlr_gles2_texture_attribs texture_attrs;
@ -341,6 +492,7 @@ bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer,
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, gl_matrix); glUniformMatrix3fv(shader->proj, 1, GL_FALSE, gl_matrix);
glUniform1i(shader->tex, 0); glUniform1i(shader->tex, 0);
glUniform1f(shader->alpha, alpha); glUniform1f(shader->alpha, alpha);
glUniform1i(shader->discardOpaque, 0); // TODO
const GLfloat x1 = box->x / wlr_texture->width; const GLfloat x1 = box->x / wlr_texture->width;
const GLfloat y1 = box->y / wlr_texture->height; const GLfloat y1 = box->y / wlr_texture->height;
@ -353,6 +505,23 @@ bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer,
x1, y2, // bottom left x1, y2, // bottom left
}; };
glUniform2f(
glGetUniformLocation(shader->program, "topLeft"),
radius,
radius
);
glUniform2f(
glGetUniformLocation(shader->program, "bottomRight"),
wlr_texture->width - radius,
wlr_texture->height - radius
);
glUniform2f(
glGetUniformLocation(shader->program, "fullSize"),
wlr_texture->width,
wlr_texture->height
);
glUniform1f(glGetUniformLocation(shader->program, "radius"), radius);
glVertexAttribPointer(shader->pos_attrib, 2, GL_FLOAT, GL_FALSE, 0, verts); glVertexAttribPointer(shader->pos_attrib, 2, GL_FLOAT, GL_FALSE, 0, verts);
glVertexAttribPointer(shader->tex_attrib, 2, GL_FLOAT, GL_FALSE, 0, texcoord); glVertexAttribPointer(shader->tex_attrib, 2, GL_FLOAT, GL_FALSE, 0, texcoord);
@ -370,14 +539,14 @@ bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer,
} }
bool fx_render_texture_with_matrix(struct fx_renderer *renderer, bool fx_render_texture_with_matrix(struct fx_renderer *renderer,
struct wlr_texture *wlr_texture, const float matrix[static 9], float alpha) { struct wlr_texture *wlr_texture, const float matrix[static 9], float alpha, int radius) {
struct wlr_fbox box = { struct wlr_fbox box = {
.x = 0, .x = 0,
.y = 0, .y = 0,
.width = wlr_texture->width, .width = wlr_texture->width,
.height = wlr_texture->height, .height = wlr_texture->height,
}; };
return fx_render_subtexture_with_matrix(renderer, wlr_texture, &box, matrix, alpha); return fx_render_subtexture_with_matrix(renderer, wlr_texture, &box, matrix, alpha, radius);
} }
void fx_render_rect(struct fx_renderer *renderer, const struct wlr_box *box, const float color[static 4], const float projection[static 9]) { void fx_render_rect(struct fx_renderer *renderer, const struct wlr_box *box, const float color[static 4], const float projection[static 9]) {

View file

@ -32,6 +32,7 @@
struct render_data { struct render_data {
pixman_region32_t *damage; pixman_region32_t *damage;
float alpha; float alpha;
int corner_radius;
struct wlr_box *clip_box; struct wlr_box *clip_box;
}; };
@ -101,7 +102,7 @@ static void set_scale_filter(struct wlr_output *wlr_output,
static void render_texture(struct wlr_output *wlr_output, static void render_texture(struct wlr_output *wlr_output,
pixman_region32_t *output_damage, struct wlr_texture *texture, pixman_region32_t *output_damage, struct wlr_texture *texture,
const struct wlr_fbox *src_box, const struct wlr_box *dst_box, const struct wlr_fbox *src_box, const struct wlr_box *dst_box,
const float matrix[static 9], float alpha) { const float matrix[static 9], float alpha, int corner_radius) {
struct sway_output *output = wlr_output->data; struct sway_output *output = wlr_output->data;
struct fx_renderer *renderer = output->server->renderer; struct fx_renderer *renderer = output->server->renderer;
@ -121,9 +122,9 @@ static void render_texture(struct wlr_output *wlr_output,
scissor_output(wlr_output, &rects[i]); scissor_output(wlr_output, &rects[i]);
set_scale_filter(wlr_output, texture, output->scale_filter); set_scale_filter(wlr_output, texture, output->scale_filter);
if (src_box != NULL) { if (src_box != NULL) {
fx_render_subtexture_with_matrix(renderer, texture, src_box, matrix, alpha); fx_render_subtexture_with_matrix(renderer, texture, src_box, matrix, alpha, corner_radius);
} else { } else {
fx_render_texture_with_matrix(renderer, texture, matrix, alpha); fx_render_texture_with_matrix(renderer, texture, matrix, alpha, corner_radius);
} }
} }
@ -138,6 +139,7 @@ static void render_surface_iterator(struct sway_output *output,
struct wlr_output *wlr_output = output->wlr_output; struct wlr_output *wlr_output = output->wlr_output;
pixman_region32_t *output_damage = data->damage; pixman_region32_t *output_damage = data->damage;
float alpha = data->alpha; float alpha = data->alpha;
int corner_radius = data->corner_radius;
struct wlr_texture *texture = wlr_surface_get_texture(surface); struct wlr_texture *texture = wlr_surface_get_texture(surface);
if (!texture) { if (!texture) {
@ -164,7 +166,7 @@ static void render_surface_iterator(struct sway_output *output,
} }
scale_box(&dst_box, wlr_output->scale); scale_box(&dst_box, wlr_output->scale);
render_texture(wlr_output, output_damage, texture, &src_box, &dst_box, matrix, alpha); render_texture(wlr_output, output_damage, texture, &src_box, &dst_box, matrix, alpha, corner_radius);
wlr_presentation_surface_sampled_on_output(server.presentation, surface, wlr_presentation_surface_sampled_on_output(server.presentation, surface,
wlr_output); wlr_output);
@ -175,6 +177,7 @@ static void render_layer_toplevel(struct sway_output *output,
struct render_data data = { struct render_data data = {
.damage = damage, .damage = damage,
.alpha = 1.0f, .alpha = 1.0f,
.corner_radius = 0,
}; };
output_layer_for_each_toplevel_surface(output, layer_surfaces, output_layer_for_each_toplevel_surface(output, layer_surfaces,
render_surface_iterator, &data); render_surface_iterator, &data);
@ -185,6 +188,7 @@ static void render_layer_popups(struct sway_output *output,
struct render_data data = { struct render_data data = {
.damage = damage, .damage = damage,
.alpha = 1.0f, .alpha = 1.0f,
.corner_radius = 0,
}; };
output_layer_for_each_popup_surface(output, layer_surfaces, output_layer_for_each_popup_surface(output, layer_surfaces,
render_surface_iterator, &data); render_surface_iterator, &data);
@ -196,6 +200,7 @@ static void render_unmanaged(struct sway_output *output,
struct render_data data = { struct render_data data = {
.damage = damage, .damage = damage,
.alpha = 1.0f, .alpha = 1.0f,
.corner_radius = 0,
}; };
output_unmanaged_for_each_surface(output, unmanaged, output_unmanaged_for_each_surface(output, unmanaged,
render_surface_iterator, &data); render_surface_iterator, &data);
@ -207,6 +212,7 @@ static void render_drag_icons(struct sway_output *output,
struct render_data data = { struct render_data data = {
.damage = damage, .damage = damage,
.alpha = 1.0f, .alpha = 1.0f,
.corner_radius = 0,
}; };
output_drag_icons_for_each_surface(output, drag_icons, output_drag_icons_for_each_surface(output, drag_icons,
render_surface_iterator, &data); render_surface_iterator, &data);
@ -255,10 +261,11 @@ void premultiply_alpha(float color[4], float opacity) {
} }
static void render_view_toplevels(struct sway_view *view, static void render_view_toplevels(struct sway_view *view,
struct sway_output *output, pixman_region32_t *damage, float alpha) { struct sway_output *output, pixman_region32_t *damage, float alpha, int corner_radius) {
struct render_data data = { struct render_data data = {
.damage = damage, .damage = damage,
.alpha = alpha, .alpha = alpha,
.corner_radius = corner_radius,
}; };
struct wlr_box clip_box; struct wlr_box clip_box;
if (!container_is_current_floating(view->container)) { if (!container_is_current_floating(view->container)) {
@ -282,13 +289,14 @@ static void render_view_popups(struct sway_view *view,
struct render_data data = { struct render_data data = {
.damage = damage, .damage = damage,
.alpha = alpha, .alpha = alpha,
.corner_radius = config->corner_radius,
}; };
output_view_for_each_popup_surface(output, view, output_view_for_each_popup_surface(output, view,
render_surface_iterator, &data); render_surface_iterator, &data);
} }
static void render_saved_view(struct sway_view *view, static void render_saved_view(struct sway_view *view,
struct sway_output *output, pixman_region32_t *damage, float alpha) { struct sway_output *output, pixman_region32_t *damage, float alpha, int corner_radius) {
struct wlr_output *wlr_output = output->wlr_output; struct wlr_output *wlr_output = output->wlr_output;
if (wl_list_empty(&view->saved_buffers)) { if (wl_list_empty(&view->saved_buffers)) {
@ -340,7 +348,7 @@ static void render_saved_view(struct sway_view *view,
scale_box(&dst_box, wlr_output->scale); scale_box(&dst_box, wlr_output->scale);
render_texture(wlr_output, damage, saved_buf->buffer->texture, render_texture(wlr_output, damage, saved_buf->buffer->texture,
&saved_buf->source_box, &dst_box, matrix, alpha); &saved_buf->source_box, &dst_box, matrix, alpha, corner_radius);
} }
// FIXME: we should set the surface that this saved buffer originates from // FIXME: we should set the surface that this saved buffer originates from
@ -355,9 +363,9 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
struct sway_container *con, struct border_colors *colors) { struct sway_container *con, struct border_colors *colors) {
struct sway_view *view = con->view; struct sway_view *view = con->view;
if (!wl_list_empty(&view->saved_buffers)) { if (!wl_list_empty(&view->saved_buffers)) {
render_saved_view(view, output, damage, view->container->alpha); render_saved_view(view, output, damage, view->container->alpha, config->corner_radius);
} else if (view->surface) { } else if (view->surface) {
render_view_toplevels(view, output, damage, view->container->alpha); render_view_toplevels(view, output, damage, view->container->alpha, config->corner_radius);
} }
if (con->current.border == B_NONE || con->current.border == B_CSD) { if (con->current.border == B_NONE || con->current.border == B_CSD) {
@ -521,7 +529,7 @@ static void render_titlebar(struct sway_output *output,
texture_box.width = ob_inner_width; texture_box.width = ob_inner_width;
} }
render_texture(output->wlr_output, output_damage, marks_texture, render_texture(output->wlr_output, output_damage, marks_texture,
NULL, &texture_box, matrix, con->alpha); NULL, &texture_box, matrix, con->alpha, 0);
// Padding above // Padding above
memcpy(&color, colors->background, sizeof(float) * 4); memcpy(&color, colors->background, sizeof(float) * 4);
@ -597,7 +605,7 @@ static void render_titlebar(struct sway_output *output,
} }
render_texture(output->wlr_output, output_damage, title_texture, render_texture(output->wlr_output, output_damage, title_texture,
NULL, &texture_box, matrix, con->alpha); NULL, &texture_box, matrix, con->alpha, 0);
// Padding above // Padding above
memcpy(&color, colors->background, sizeof(float) * 4); memcpy(&color, colors->background, sizeof(float) * 4);
@ -1073,10 +1081,10 @@ void output_render(struct sway_output *output, struct timespec *when,
if (fullscreen_con->view) { if (fullscreen_con->view) {
if (!wl_list_empty(&fullscreen_con->view->saved_buffers)) { if (!wl_list_empty(&fullscreen_con->view->saved_buffers)) {
render_saved_view(fullscreen_con->view, output, damage, 1.0f); render_saved_view(fullscreen_con->view, output, damage, 1.0f, 0);
} else if (fullscreen_con->view->surface) { } else if (fullscreen_con->view->surface) {
render_view_toplevels(fullscreen_con->view, render_view_toplevels(fullscreen_con->view,
output, damage, 1.0f); output, damage, 1.0f, 0);
} }
} else { } else {
render_container(output, damage, fullscreen_con, render_container(output, damage, fullscreen_con,

View file

@ -1,238 +1,239 @@
sway_sources = files( sway_sources = files(
'commands.c', 'commands.c',
'config.c', 'config.c',
'criteria.c', 'criteria.c',
'decoration.c', 'decoration.c',
'ipc-json.c', 'ipc-json.c',
'ipc-server.c', 'ipc-server.c',
'main.c', 'main.c',
'server.c', 'server.c',
'swaynag.c', 'swaynag.c',
'xdg_activation_v1.c', 'xdg_activation_v1.c',
'xdg_decoration.c', 'xdg_decoration.c',
'desktop/desktop.c', 'desktop/desktop.c',
'desktop/fx_renderer.c', 'desktop/fx_renderer.c',
'desktop/idle_inhibit_v1.c', 'desktop/idle_inhibit_v1.c',
'desktop/layer_shell.c', 'desktop/layer_shell.c',
'desktop/output.c', 'desktop/output.c',
'desktop/render.c', 'desktop/render.c',
'desktop/surface.c', 'desktop/surface.c',
'desktop/transaction.c', 'desktop/transaction.c',
'desktop/xdg_shell.c', 'desktop/xdg_shell.c',
'input/input-manager.c', 'input/input-manager.c',
'input/cursor.c', 'input/cursor.c',
'input/keyboard.c', 'input/keyboard.c',
'input/libinput.c', 'input/libinput.c',
'input/seat.c', 'input/seat.c',
'input/seatop_default.c', 'input/seatop_default.c',
'input/seatop_down.c', 'input/seatop_down.c',
'input/seatop_move_floating.c', 'input/seatop_move_floating.c',
'input/seatop_move_tiling.c', 'input/seatop_move_tiling.c',
'input/seatop_resize_floating.c', 'input/seatop_resize_floating.c',
'input/seatop_resize_tiling.c', 'input/seatop_resize_tiling.c',
'input/switch.c', 'input/switch.c',
'input/tablet.c', 'input/tablet.c',
'input/text_input.c', 'input/text_input.c',
'config/bar.c', 'config/bar.c',
'config/output.c', 'config/output.c',
'config/seat.c', 'config/seat.c',
'config/input.c', 'config/input.c',
'commands/assign.c', 'commands/assign.c',
'commands/bar.c', 'commands/bar.c',
'commands/bind.c', 'commands/bind.c',
'commands/border.c', 'commands/border.c',
'commands/client.c', 'commands/client.c',
'commands/create_output.c', 'commands/corner_radius.c',
'commands/default_border.c', 'commands/create_output.c',
'commands/default_floating_border.c', 'commands/default_border.c',
'commands/default_orientation.c', 'commands/default_floating_border.c',
'commands/exit.c', 'commands/default_orientation.c',
'commands/exec.c', 'commands/exit.c',
'commands/exec_always.c', 'commands/exec.c',
'commands/floating.c', 'commands/exec_always.c',
'commands/floating_minmax_size.c', 'commands/floating.c',
'commands/floating_modifier.c', 'commands/floating_minmax_size.c',
'commands/focus.c', 'commands/floating_modifier.c',
'commands/focus_follows_mouse.c', 'commands/focus.c',
'commands/focus_on_window_activation.c', 'commands/focus_follows_mouse.c',
'commands/focus_wrapping.c', 'commands/focus_on_window_activation.c',
'commands/font.c', 'commands/focus_wrapping.c',
'commands/for_window.c', 'commands/font.c',
'commands/force_display_urgency_hint.c', 'commands/for_window.c',
'commands/force_focus_wrapping.c', 'commands/force_display_urgency_hint.c',
'commands/fullscreen.c', 'commands/force_focus_wrapping.c',
'commands/gaps.c', 'commands/fullscreen.c',
'commands/hide_edge_borders.c', 'commands/gaps.c',
'commands/inhibit_idle.c', 'commands/hide_edge_borders.c',
'commands/kill.c', 'commands/inhibit_idle.c',
'commands/mark.c', 'commands/kill.c',
'commands/max_render_time.c', 'commands/mark.c',
'commands/opacity.c', 'commands/max_render_time.c',
'commands/include.c', 'commands/opacity.c',
'commands/input.c', 'commands/include.c',
'commands/layout.c', 'commands/input.c',
'commands/mode.c', 'commands/layout.c',
'commands/mouse_warping.c', 'commands/mode.c',
'commands/move.c', 'commands/mouse_warping.c',
'commands/new_float.c', 'commands/move.c',
'commands/new_window.c', 'commands/new_float.c',
'commands/no_focus.c', 'commands/new_window.c',
'commands/nop.c', 'commands/no_focus.c',
'commands/output.c', 'commands/nop.c',
'commands/popup_during_fullscreen.c', 'commands/output.c',
'commands/reload.c', 'commands/popup_during_fullscreen.c',
'commands/rename.c', 'commands/reload.c',
'commands/resize.c', 'commands/rename.c',
'commands/scratchpad.c', 'commands/resize.c',
'commands/seat.c', 'commands/scratchpad.c',
'commands/seat/attach.c', 'commands/seat.c',
'commands/seat/cursor.c', 'commands/seat/attach.c',
'commands/seat/fallback.c', 'commands/seat/cursor.c',
'commands/seat/hide_cursor.c', 'commands/seat/fallback.c',
'commands/seat/idle.c', 'commands/seat/hide_cursor.c',
'commands/seat/keyboard_grouping.c', 'commands/seat/idle.c',
'commands/seat/pointer_constraint.c', 'commands/seat/keyboard_grouping.c',
'commands/seat/shortcuts_inhibitor.c', 'commands/seat/pointer_constraint.c',
'commands/seat/xcursor_theme.c', 'commands/seat/shortcuts_inhibitor.c',
'commands/set.c', 'commands/seat/xcursor_theme.c',
'commands/show_marks.c', 'commands/set.c',
'commands/shortcuts_inhibitor.c', 'commands/show_marks.c',
'commands/smart_borders.c', 'commands/shortcuts_inhibitor.c',
'commands/smart_gaps.c', 'commands/smart_borders.c',
'commands/split.c', 'commands/smart_gaps.c',
'commands/sticky.c', 'commands/split.c',
'commands/swaybg_command.c', 'commands/sticky.c',
'commands/swaynag_command.c', 'commands/swaybg_command.c',
'commands/swap.c', 'commands/swaynag_command.c',
'commands/tiling_drag.c', 'commands/swap.c',
'commands/tiling_drag_threshold.c', 'commands/tiling_drag.c',
'commands/title_align.c', 'commands/tiling_drag_threshold.c',
'commands/title_format.c', 'commands/title_align.c',
'commands/titlebar_border_thickness.c', 'commands/title_format.c',
'commands/titlebar_padding.c', 'commands/titlebar_border_thickness.c',
'commands/unmark.c', 'commands/titlebar_padding.c',
'commands/urgent.c', 'commands/unmark.c',
'commands/workspace.c', 'commands/urgent.c',
'commands/workspace_layout.c', 'commands/workspace.c',
'commands/ws_auto_back_and_forth.c', 'commands/workspace_layout.c',
'commands/xwayland.c', 'commands/ws_auto_back_and_forth.c',
'commands/xwayland.c',
'commands/bar/bind.c', 'commands/bar/bind.c',
'commands/bar/binding_mode_indicator.c', 'commands/bar/binding_mode_indicator.c',
'commands/bar/colors.c', 'commands/bar/colors.c',
'commands/bar/font.c', 'commands/bar/font.c',
'commands/bar/gaps.c', 'commands/bar/gaps.c',
'commands/bar/height.c', 'commands/bar/height.c',
'commands/bar/hidden_state.c', 'commands/bar/hidden_state.c',
'commands/bar/icon_theme.c', 'commands/bar/icon_theme.c',
'commands/bar/id.c', 'commands/bar/id.c',
'commands/bar/mode.c', 'commands/bar/mode.c',
'commands/bar/modifier.c', 'commands/bar/modifier.c',
'commands/bar/output.c', 'commands/bar/output.c',
'commands/bar/pango_markup.c', 'commands/bar/pango_markup.c',
'commands/bar/position.c', 'commands/bar/position.c',
'commands/bar/separator_symbol.c', 'commands/bar/separator_symbol.c',
'commands/bar/status_command.c', 'commands/bar/status_command.c',
'commands/bar/status_edge_padding.c', 'commands/bar/status_edge_padding.c',
'commands/bar/status_padding.c', 'commands/bar/status_padding.c',
'commands/bar/strip_workspace_numbers.c', 'commands/bar/strip_workspace_numbers.c',
'commands/bar/strip_workspace_name.c', 'commands/bar/strip_workspace_name.c',
'commands/bar/swaybar_command.c', 'commands/bar/swaybar_command.c',
'commands/bar/tray_bind.c', 'commands/bar/tray_bind.c',
'commands/bar/tray_output.c', 'commands/bar/tray_output.c',
'commands/bar/tray_padding.c', 'commands/bar/tray_padding.c',
'commands/bar/workspace_buttons.c', 'commands/bar/workspace_buttons.c',
'commands/bar/workspace_min_width.c', 'commands/bar/workspace_min_width.c',
'commands/bar/wrap_scroll.c', 'commands/bar/wrap_scroll.c',
'commands/input/accel_profile.c', 'commands/input/accel_profile.c',
'commands/input/calibration_matrix.c', 'commands/input/calibration_matrix.c',
'commands/input/click_method.c', 'commands/input/click_method.c',
'commands/input/drag.c', 'commands/input/drag.c',
'commands/input/drag_lock.c', 'commands/input/drag_lock.c',
'commands/input/dwt.c', 'commands/input/dwt.c',
'commands/input/events.c', 'commands/input/events.c',
'commands/input/left_handed.c', 'commands/input/left_handed.c',
'commands/input/map_from_region.c', 'commands/input/map_from_region.c',
'commands/input/map_to_output.c', 'commands/input/map_to_output.c',
'commands/input/map_to_region.c', 'commands/input/map_to_region.c',
'commands/input/middle_emulation.c', 'commands/input/middle_emulation.c',
'commands/input/natural_scroll.c', 'commands/input/natural_scroll.c',
'commands/input/pointer_accel.c', 'commands/input/pointer_accel.c',
'commands/input/repeat_delay.c', 'commands/input/repeat_delay.c',
'commands/input/repeat_rate.c', 'commands/input/repeat_rate.c',
'commands/input/scroll_button.c', 'commands/input/scroll_button.c',
'commands/input/scroll_factor.c', 'commands/input/scroll_factor.c',
'commands/input/scroll_method.c', 'commands/input/scroll_method.c',
'commands/input/tap.c', 'commands/input/tap.c',
'commands/input/tap_button_map.c', 'commands/input/tap_button_map.c',
'commands/input/tool_mode.c', 'commands/input/tool_mode.c',
'commands/input/xkb_capslock.c', 'commands/input/xkb_capslock.c',
'commands/input/xkb_file.c', 'commands/input/xkb_file.c',
'commands/input/xkb_layout.c', 'commands/input/xkb_layout.c',
'commands/input/xkb_model.c', 'commands/input/xkb_model.c',
'commands/input/xkb_numlock.c', 'commands/input/xkb_numlock.c',
'commands/input/xkb_options.c', 'commands/input/xkb_options.c',
'commands/input/xkb_rules.c', 'commands/input/xkb_rules.c',
'commands/input/xkb_switch_layout.c', 'commands/input/xkb_switch_layout.c',
'commands/input/xkb_variant.c', 'commands/input/xkb_variant.c',
'commands/output/adaptive_sync.c', 'commands/output/adaptive_sync.c',
'commands/output/background.c', 'commands/output/background.c',
'commands/output/disable.c', 'commands/output/disable.c',
'commands/output/dpms.c', 'commands/output/dpms.c',
'commands/output/enable.c', 'commands/output/enable.c',
'commands/output/max_render_time.c', 'commands/output/max_render_time.c',
'commands/output/mode.c', 'commands/output/mode.c',
'commands/output/position.c', 'commands/output/position.c',
'commands/output/render_bit_depth.c', 'commands/output/render_bit_depth.c',
'commands/output/scale.c', 'commands/output/scale.c',
'commands/output/scale_filter.c', 'commands/output/scale_filter.c',
'commands/output/subpixel.c', 'commands/output/subpixel.c',
'commands/output/toggle.c', 'commands/output/toggle.c',
'commands/output/transform.c', 'commands/output/transform.c',
'tree/arrange.c', 'tree/arrange.c',
'tree/container.c', 'tree/container.c',
'tree/node.c', 'tree/node.c',
'tree/root.c', 'tree/root.c',
'tree/view.c', 'tree/view.c',
'tree/workspace.c', 'tree/workspace.c',
'tree/output.c', 'tree/output.c',
) )
sway_deps = [ sway_deps = [
cairo, cairo,
drm, drm,
jsonc, jsonc,
libevdev, libevdev,
libinput, libinput,
libudev, libudev,
math, math,
pango, pango,
pcre, pcre,
glesv2, glesv2,
pixman, pixman,
server_protos, server_protos,
wayland_server, wayland_server,
wlroots, wlroots,
xkbcommon, xkbcommon,
] ]
if have_xwayland if have_xwayland
sway_sources += 'desktop/xwayland.c' sway_sources += 'desktop/xwayland.c'
sway_deps += xcb sway_deps += xcb
endif endif
executable( executable(
'sway', 'sway',
sway_sources, sway_sources,
include_directories: [sway_inc], include_directories: [sway_inc],
dependencies: sway_deps, dependencies: sway_deps,
link_with: [lib_sway_common], link_with: [lib_sway_common],
install: true install: true
) )