summaryrefslogtreecommitdiff
path: root/sway/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/fx_renderer.c6
-rw-r--r--sway/desktop/render.c22
-rw-r--r--sway/desktop/shaders/tex_external.frag9
-rw-r--r--sway/desktop/shaders/tex_rgba.frag9
-rw-r--r--sway/desktop/shaders/tex_rgbx.frag9
5 files changed, 46 insertions, 9 deletions
diff --git a/sway/desktop/fx_renderer.c b/sway/desktop/fx_renderer.c
index a8dfa561..f2436e96 100644
--- a/sway/desktop/fx_renderer.c
+++ b/sway/desktop/fx_renderer.c
@@ -95,6 +95,8 @@ bool init_frag_shader(struct gles2_tex_shader *shader, GLuint prog) {
shader->proj = glGetUniformLocation(prog, "proj");
shader->tex = glGetUniformLocation(prog, "tex");
shader->alpha = glGetUniformLocation(prog, "alpha");
+ shader->dim = glGetUniformLocation(prog, "dim");
+ shader->dim_color = glGetUniformLocation(prog, "dim_color");
shader->pos_attrib = glGetAttribLocation(prog, "pos");
shader->tex_attrib = glGetAttribLocation(prog, "texcoord");
shader->size = glGetUniformLocation(prog, "size");
@@ -345,11 +347,15 @@ bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer, struct wlr_t
glUseProgram(shader->program);
+ float* dim_color = deco_data.dim_color;
+
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, gl_matrix);
glUniform1i(shader->tex, 0);
glUniform2f(shader->size, dst_box->width, dst_box->height);
glUniform2f(shader->position, dst_box->x, dst_box->y);
glUniform1f(shader->alpha, deco_data.alpha);
+ glUniform1f(shader->dim, deco_data.dim);
+ glUniform4f(shader->dim_color, dim_color[0], dim_color[1], dim_color[2], dim_color[3]);
glUniform1f(shader->has_titlebar, deco_data.has_titlebar);
glUniform1f(shader->saturation, deco_data.saturation);
glUniform1f(shader->radius, deco_data.corner_radius);
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 3ee719b6..fd42cbbb 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -39,6 +39,8 @@ struct render_data {
struct decoration_data get_undecorated_decoration_data() {
return (struct decoration_data) {
.alpha = 1.0f,
+ .dim = 0.0f,
+ .dim_color = config->dim_inactive_colors.unfocused,
.corner_radius = 0,
.saturation = 1.0f,
.has_titlebar = false,
@@ -945,6 +947,10 @@ static void render_containers_linear(struct sway_output *output,
bool has_titlebar = state->border == B_NORMAL;
struct decoration_data deco_data = {
.alpha = child->alpha,
+ .dim_color = view_is_urgent(view)
+ ? config->dim_inactive_colors.urgent
+ : config->dim_inactive_colors.unfocused,
+ .dim = child->current.focused ? 0.0f: config->dim_inactive,
// no corner radius if smart gaps are on and only visible view
.corner_radius = config->smart_gaps == SMART_GAPS_ON &&
view_ancestor_is_only_visible(view) ? 0 : child->corner_radius,
@@ -1038,6 +1044,10 @@ static void render_containers_tabbed(struct sway_output *output,
if (current->view) {
struct decoration_data deco_data = {
.alpha = current->alpha,
+ .dim_color = view_is_urgent(current->view)
+ ? config->dim_inactive_colors.urgent
+ : config->dim_inactive_colors.unfocused,
+ .dim = current->current.focused ? 0.0f: config->dim_inactive,
.corner_radius = current->corner_radius,
.saturation = current->saturation,
.has_titlebar = true,
@@ -1107,6 +1117,10 @@ static void render_containers_stacked(struct sway_output *output,
if (current->view) {
struct decoration_data deco_data = {
.alpha = current->alpha,
+ .dim_color = view_is_urgent(current->view)
+ ? config->dim_inactive_colors.urgent
+ : config->dim_inactive_colors.unfocused,
+ .dim = current->current.focused ? 0.0f: config->dim_inactive,
.saturation = current->saturation,
.corner_radius = current->corner_radius,
.has_titlebar = true,
@@ -1203,6 +1217,10 @@ static void render_floating_container(struct sway_output *soutput,
bool has_titlebar = state->border == B_NORMAL;
struct decoration_data deco_data = {
.alpha = con->alpha,
+ .dim_color = view_is_urgent(view)
+ ? config->dim_inactive_colors.urgent
+ : config->dim_inactive_colors.unfocused,
+ .dim = con->current.focused ? 0.0f: config->dim_inactive,
.saturation = con->saturation,
.corner_radius = con->corner_radius,
.has_titlebar = has_titlebar,
@@ -1355,6 +1373,10 @@ void output_render(struct sway_output *output, struct timespec *when,
if (focus && focus->view) {
struct decoration_data deco_data = {
.alpha = focus->alpha,
+ .dim_color = view_is_urgent(focus->view)
+ ? config->dim_inactive_colors.urgent
+ : config->dim_inactive_colors.unfocused,
+ .dim = focus->current.focused ? 0.0f: config->dim_inactive,
.corner_radius = focus->corner_radius,
.saturation = focus->saturation,
.has_titlebar = focus->current.border == B_NORMAL,
diff --git a/sway/desktop/shaders/tex_external.frag b/sway/desktop/shaders/tex_external.frag
index d31cc990..9976eb51 100644
--- a/sway/desktop/shaders/tex_external.frag
+++ b/sway/desktop/shaders/tex_external.frag
@@ -4,6 +4,8 @@ precision mediump float;
varying vec2 v_texcoord;
uniform samplerExternalOES texture0;
uniform float alpha;
+uniform float dim;
+uniform vec4 dim_color;
uniform vec2 size;
uniform vec2 position;
@@ -13,15 +15,16 @@ uniform float saturation;
const vec3 saturation_weight = vec3(0.2125, 0.7154, 0.0721);
void main() {
+ vec4 color = texture2D(texture0, v_texcoord);
// Saturation
if (saturation != 1.0) {
vec4 pixColor = texture2D(texture0, v_texcoord);
vec3 irgb = pixColor.rgb;
vec3 target = vec3(dot(irgb, saturation_weight));
- gl_FragColor = vec4(mix(target, irgb, saturation), pixColor.a) * alpha;
- } else {
- gl_FragColor = texture2D(texture0, v_texcoord) * alpha;
+ color = vec4(mix(target, irgb, saturation), pixColor.a);
}
+ // Dimming
+ gl_FragColor = mix(color, dim_color, dim) * alpha;
if (!has_titlebar || gl_FragCoord.y - position.y > radius) {
vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - gl_FragCoord.xy);
diff --git a/sway/desktop/shaders/tex_rgba.frag b/sway/desktop/shaders/tex_rgba.frag
index 2a9dbccb..b46885b2 100644
--- a/sway/desktop/shaders/tex_rgba.frag
+++ b/sway/desktop/shaders/tex_rgba.frag
@@ -2,6 +2,8 @@ precision mediump float;
varying vec2 v_texcoord;
uniform sampler2D tex;
uniform float alpha;
+uniform float dim;
+uniform vec4 dim_color;
uniform vec2 size;
uniform vec2 position;
@@ -11,15 +13,16 @@ uniform float saturation;
const vec3 saturation_weight = vec3(0.2125, 0.7154, 0.0721);
void main() {
+ vec4 color = texture2D(tex, v_texcoord);
// Saturation
if (saturation != 1.0) {
vec4 pixColor = texture2D(tex, v_texcoord);
vec3 irgb = pixColor.rgb;
vec3 target = vec3(dot(irgb, saturation_weight));
- gl_FragColor = vec4(mix(target, irgb, saturation), pixColor.a) * alpha;
- } else {
- gl_FragColor = texture2D(tex, v_texcoord) * alpha;
+ color = vec4(mix(target, irgb, saturation), pixColor.a);
}
+ // Dimming
+ gl_FragColor = mix(color, dim_color, dim) * alpha;
if (!has_titlebar || gl_FragCoord.y - position.y > radius) {
vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - gl_FragCoord.xy);
diff --git a/sway/desktop/shaders/tex_rgbx.frag b/sway/desktop/shaders/tex_rgbx.frag
index b31c1bfd..283963f2 100644
--- a/sway/desktop/shaders/tex_rgbx.frag
+++ b/sway/desktop/shaders/tex_rgbx.frag
@@ -2,6 +2,8 @@ precision mediump float;
varying vec2 v_texcoord;
uniform sampler2D tex;
uniform float alpha;
+uniform float dim;
+uniform vec4 dim_color;
uniform vec2 size;
uniform vec2 position;
@@ -11,14 +13,15 @@ uniform float saturation;
const vec3 saturation_weight = vec3(0.2125, 0.7154, 0.0721);
void main() {
+ vec4 color = vec4(texture2D(tex, v_texcoord).rgb, 1.0);
// Saturation
if (saturation != 1.0) {
vec3 irgb = texture2D(tex, v_texcoord).rgb;
vec3 target = vec3(dot(irgb, saturation_weight));
- gl_FragColor = vec4(mix(target, irgb, saturation), 1.0) * alpha;
- } else {
- gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;
+ color = vec4(mix(target, irgb, saturation), 1.0);
}
+ // Dimming
+ gl_FragColor = mix(color, dim_color, dim) * alpha;
if (!has_titlebar || gl_FragCoord.y - position.y > radius) {
vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - gl_FragCoord.xy);