From 22327ef300a60294e8a1bc847aac4d4576d3f6c6 Mon Sep 17 00:00:00 2001 From: RAR27 Date: Fri, 2 Jun 2023 18:46:39 -0400 Subject: [PATCH 1/7] fix: crash when splitting inside tabbed container (#180) --- sway/desktop/render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 3472e12f..b9de2025 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -1454,7 +1454,7 @@ static void render_containers_tabbed(struct sway_output *output, struct decoration_data deco_data = { .alpha = current->alpha, - .dim_color = view_is_urgent(current->view) + .dim_color = current->view && view_is_urgent(current->view) ? config->dim_inactive_colors.urgent : config->dim_inactive_colors.unfocused, .dim = current->current.focused || parent->focused ? 0.0f : current->dim, From 212c51f62cc06885606879fe2deca207d6fd6a60 Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Sat, 3 Jun 2023 00:53:41 +0200 Subject: [PATCH 2/7] fix: update stencil if the output size changes (#178) --- .../sway/desktop/fx_renderer/fx_framebuffer.h | 6 +-- .../desktop/fx_renderer/fx_stencilbuffer.h | 18 +++++++ include/sway/desktop/fx_renderer/fx_texture.h | 6 ++- sway/desktop/fx_renderer/fx_framebuffer.c | 48 +++++++++---------- sway/desktop/fx_renderer/fx_stencilbuffer.c | 21 ++++++++ sway/desktop/fx_renderer/fx_texture.c | 20 +++++++- sway/meson.build | 1 + 7 files changed, 91 insertions(+), 29 deletions(-) create mode 100644 include/sway/desktop/fx_renderer/fx_stencilbuffer.h create mode 100644 sway/desktop/fx_renderer/fx_stencilbuffer.c diff --git a/include/sway/desktop/fx_renderer/fx_framebuffer.h b/include/sway/desktop/fx_renderer/fx_framebuffer.h index 39eeb257..3372cd00 100644 --- a/include/sway/desktop/fx_renderer/fx_framebuffer.h +++ b/include/sway/desktop/fx_renderer/fx_framebuffer.h @@ -5,12 +5,13 @@ #include #include +#include "sway/desktop/fx_renderer/fx_stencilbuffer.h" #include "sway/desktop/fx_renderer/fx_texture.h" struct fx_framebuffer { - struct fx_texture texture; GLuint fb; - GLuint stencil_buffer; + struct fx_stencilbuffer stencil_buffer; + struct fx_texture texture; }; struct fx_framebuffer fx_framebuffer_create(); @@ -23,5 +24,4 @@ void fx_framebuffer_add_stencil_buffer(struct fx_framebuffer *buffer, int width, void fx_framebuffer_release(struct fx_framebuffer *buffer); - #endif diff --git a/include/sway/desktop/fx_renderer/fx_stencilbuffer.h b/include/sway/desktop/fx_renderer/fx_stencilbuffer.h new file mode 100644 index 00000000..157c0282 --- /dev/null +++ b/include/sway/desktop/fx_renderer/fx_stencilbuffer.h @@ -0,0 +1,18 @@ +#ifndef FX_STENCILBUFFER_H +#define FX_STENCILBUFFER_H + +#include +#include +#include + +struct fx_stencilbuffer { + GLuint rb; + int width; + int height; +}; + +struct fx_stencilbuffer fx_stencilbuffer_create(); + +void fx_stencilbuffer_release(struct fx_stencilbuffer *stencil_buffer); + +#endif diff --git a/include/sway/desktop/fx_renderer/fx_texture.h b/include/sway/desktop/fx_renderer/fx_texture.h index 0c375913..62e635e6 100644 --- a/include/sway/desktop/fx_renderer/fx_texture.h +++ b/include/sway/desktop/fx_renderer/fx_texture.h @@ -13,6 +13,10 @@ struct fx_texture { int height; }; -struct fx_texture fx_texture_from_wlr_texture(struct wlr_texture* tex); +struct fx_texture fx_texture_create(); + +struct fx_texture fx_texture_from_wlr_texture(struct wlr_texture *tex); + +void fx_texture_release(struct fx_texture *texture); #endif diff --git a/sway/desktop/fx_renderer/fx_framebuffer.c b/sway/desktop/fx_renderer/fx_framebuffer.c index 14bc454e..3ef3129a 100644 --- a/sway/desktop/fx_renderer/fx_framebuffer.c +++ b/sway/desktop/fx_renderer/fx_framebuffer.c @@ -1,14 +1,13 @@ #include "log.h" #include "sway/desktop/fx_renderer/fx_framebuffer.h" +#include "sway/desktop/fx_renderer/fx_stencilbuffer.h" +#include "sway/desktop/fx_renderer/fx_texture.h" struct fx_framebuffer fx_framebuffer_create() { return (struct fx_framebuffer) { .fb = -1, - .stencil_buffer = -1, - .texture.id = 0, - .texture.target = 0, - .texture.width = -1, - .texture.height = -1, + .stencil_buffer = fx_stencilbuffer_create(), + .texture = fx_texture_create(), }; } @@ -17,15 +16,15 @@ void fx_framebuffer_bind(struct fx_framebuffer *buffer) { } void fx_framebuffer_update(struct fx_framebuffer *buffer, int width, int height) { - bool firstAlloc = false; + bool first_alloc = false; if (buffer->fb == (uint32_t) -1) { glGenFramebuffers(1, &buffer->fb); - firstAlloc = true; + first_alloc = true; } if (buffer->texture.id == 0) { - firstAlloc = true; + first_alloc = true; glGenTextures(1, &buffer->texture.id); glBindTexture(GL_TEXTURE_2D, buffer->texture.id); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -34,7 +33,7 @@ void fx_framebuffer_update(struct fx_framebuffer *buffer, int width, int height) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } - if (firstAlloc || buffer->texture.width != width || buffer->texture.height != height) { + if (first_alloc || buffer->texture.width != width || buffer->texture.height != height) { glBindTexture(GL_TEXTURE_2D, buffer->texture.id); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); @@ -58,11 +57,20 @@ void fx_framebuffer_update(struct fx_framebuffer *buffer, int width, int height) } void fx_framebuffer_add_stencil_buffer(struct fx_framebuffer *buffer, int width, int height) { - if (buffer->stencil_buffer == (uint32_t) -1) { - glGenRenderbuffers(1, &buffer->stencil_buffer); - glBindRenderbuffer(GL_RENDERBUFFER, buffer->stencil_buffer); + bool first_alloc = false; + + if (buffer->stencil_buffer.rb == (uint32_t) -1) { + glGenRenderbuffers(1, &buffer->stencil_buffer.rb); + first_alloc = true; + } + + if (first_alloc || buffer->stencil_buffer.width != width || buffer->stencil_buffer.height != height) { + glBindRenderbuffer(GL_RENDERBUFFER, buffer->stencil_buffer.rb); glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, buffer->stencil_buffer); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, buffer->stencil_buffer.rb); + buffer->stencil_buffer.width = width; + buffer->stencil_buffer.height = height; + GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { sway_log(SWAY_ERROR, "Stencil buffer incomplete, couldn't create! (FB status: %i)", status); @@ -77,19 +85,11 @@ void fx_framebuffer_release(struct fx_framebuffer *buffer) { if (buffer->fb != (uint32_t) -1 && buffer->fb) { glDeleteFramebuffers(1, &buffer->fb); } - buffer->fb= -1; + buffer->fb = -1; // Release the stencil buffer - if (buffer->stencil_buffer != (uint32_t)-1 && buffer->stencil_buffer) { - glDeleteRenderbuffers(1, &buffer->stencil_buffer); - } - buffer->stencil_buffer = -1; + fx_stencilbuffer_release(&buffer->stencil_buffer); // Release the texture - if (buffer->texture.id) { - glDeleteTextures(1, &buffer->texture.id); - } - buffer->texture.id = 0; - buffer->texture.width = -1; - buffer->texture.height = -1; + fx_texture_release(&buffer->texture); } diff --git a/sway/desktop/fx_renderer/fx_stencilbuffer.c b/sway/desktop/fx_renderer/fx_stencilbuffer.c new file mode 100644 index 00000000..5b99ff79 --- /dev/null +++ b/sway/desktop/fx_renderer/fx_stencilbuffer.c @@ -0,0 +1,21 @@ +#include +#include + +#include "sway/desktop/fx_renderer/fx_stencilbuffer.h" + +struct fx_stencilbuffer fx_stencilbuffer_create() { + return (struct fx_stencilbuffer) { + .rb = -1, + .width = -1, + .height = -1, + }; +} + +void fx_stencilbuffer_release(struct fx_stencilbuffer *stencil_buffer) { + if (stencil_buffer->rb != (uint32_t) -1 && stencil_buffer->rb) { + glDeleteRenderbuffers(1, &stencil_buffer->rb); + } + stencil_buffer->rb = -1; + stencil_buffer->width = -1; + stencil_buffer->height = -1; +} diff --git a/sway/desktop/fx_renderer/fx_texture.c b/sway/desktop/fx_renderer/fx_texture.c index 60aa9a26..cc5d14c8 100644 --- a/sway/desktop/fx_renderer/fx_texture.c +++ b/sway/desktop/fx_renderer/fx_texture.c @@ -3,7 +3,16 @@ #include "sway/desktop/fx_renderer/fx_texture.h" -struct fx_texture fx_texture_from_wlr_texture(struct wlr_texture* texture) { +struct fx_texture fx_texture_create() { + return (struct fx_texture) { + .id = 0, + .target = 0, + .width = -1, + .height = -1, + }; +} + +struct fx_texture fx_texture_from_wlr_texture(struct wlr_texture *texture) { assert(wlr_texture_is_gles2(texture)); struct wlr_gles2_texture_attribs texture_attrs; @@ -17,3 +26,12 @@ struct fx_texture fx_texture_from_wlr_texture(struct wlr_texture* texture) { .height = texture->height, }; } + +void fx_texture_release(struct fx_texture *texture) { + if (texture->id) { + glDeleteTextures(1, &texture->id); + } + texture->id = 0; + texture->width = -1; + texture->height = -1; +} diff --git a/sway/meson.build b/sway/meson.build index 2e1c5d20..528cdd99 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -17,6 +17,7 @@ sway_sources = files( 'desktop/desktop.c', 'desktop/fx_renderer/fx_framebuffer.c', 'desktop/fx_renderer/fx_renderer.c', + 'desktop/fx_renderer/fx_stencilbuffer.c', 'desktop/fx_renderer/fx_texture.c', 'desktop/fx_renderer/matrix.c', 'desktop/idle_inhibit_v1.c', From 588fca381ed4eaa6053a44108d6a4891ec7e05bb Mon Sep 17 00:00:00 2001 From: William McKinnon Date: Fri, 2 Jun 2023 18:56:24 -0400 Subject: [PATCH 3/7] default scratchpad_minimize to false and add warning --- README.md | 3 +-- config.in | 2 +- sway/config.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ff227bd5..9556f92a 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Sway is an incredible window manager, and certainly one of the most well establi - `dim_inactive_colors.urgent ex, #900000FF` + Application saturation: `for_window [CRITERIA HERE] saturation 2.0>` + Keep/remove separator border between titlebar and content: `titlebar_separator enable|disable` -+ Treat Scratchpad as minimized: `scratchpad_minimize enable|disable` ++ Treat Scratchpad as minimized: `scratchpad_minimize enable|disable`: **we recommend keeping this setting off, as there are many kinks to iron out here** ## Roadmap @@ -113,4 +113,3 @@ Here's a quick outline of where most of our changes lie vs the main sway reposit + `sway/desktop/render.c`: the file that handles calling `fx_renderer` to render to the screen, handles damage tracking and scaling + `sway/desktop/fx_renderer.c`: the meat and potatoes of this project, structured as similarly to wlr_renderer as possible + `sway/desktop/shaders`: where all of the shaders that fx_renderer uses live - diff --git a/config.in b/config.in index 15727bbe..05b461db 100644 --- a/config.in +++ b/config.in @@ -41,7 +41,7 @@ dim_inactive_colors.unfocused #000000FF dim_inactive_colors.urgent #900000FF # Move minimized windows into Scratchpad (enable|disable) -scratchpad_minimize enable +scratchpad_minimize disable ### Output configuration # diff --git a/sway/config.c b/sway/config.c index fbcf94a4..82085d03 100644 --- a/sway/config.c +++ b/sway/config.c @@ -359,7 +359,7 @@ static void config_defaults(struct sway_config *config) { config->blur_params.radius = 5; config->titlebar_separator = true; - config->scratchpad_minimize = true; + config->scratchpad_minimize = false; if (!(config->layer_criteria = create_list())) goto cleanup; From 11451465ad1b170c453242121a6ff18ec813027a Mon Sep 17 00:00:00 2001 From: William McKinnon Date: Fri, 2 Jun 2023 18:58:16 -0400 Subject: [PATCH 4/7] added layer namespace information --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9556f92a..a1646e7b 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,9 @@ Sway is an incredible window manager, and certainly one of the most well establi - `shadows_on_csd enable|disable` (**Note**: The shadow might not fit some windows) - `shadow_blur_radius ` - `shadow_color ex, #0000007F` -+ LayerShell effects (to blur panels / notifications etc) : ++ LayerShell effects (to blur panels / notifications etc): - `layer_effects ` + - The current layer namespaces can be shown with `swaymsg -r -t get_outputs | jq '.[0].layer_shell_surfaces | .[] | .namespace'` - Example: `layer_effects "waybar" blur enable; shadows enable; corner_radius 6` - Note: If an application uses gtk, its namespace is likely to be "gtk-layer-shell" - SwayIPC Example: `swaymsg "layer_effects 'waybar' 'blur enable; shadows enable; corner_radius 6'"` From 15bf6ae835f43a4b2cc870dafc525735dfedc54a Mon Sep 17 00:00:00 2001 From: William McKinnon Date: Fri, 2 Jun 2023 19:21:26 -0400 Subject: [PATCH 5/7] ver: bump to 0.3.1 --- build-scripts/aur/PKGBUILD | 2 +- build-scripts/swayfx.rpkg.spec | 2 +- meson.build | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build-scripts/aur/PKGBUILD b/build-scripts/aur/PKGBUILD index 7adf4094..a3f39349 100644 --- a/build-scripts/aur/PKGBUILD +++ b/build-scripts/aur/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: Erik Reider _pkgname=swayfx pkgname="$_pkgname" -pkgver=0.3 +pkgver=0.3.1 pkgrel=1 license=("MIT") pkgdesc="SwayFX: Sway, but with eye candy!" diff --git a/build-scripts/swayfx.rpkg.spec b/build-scripts/swayfx.rpkg.spec index 6ea9acd4..418db3b9 100644 --- a/build-scripts/swayfx.rpkg.spec +++ b/build-scripts/swayfx.rpkg.spec @@ -4,7 +4,7 @@ # Change to current Sway base version! %global SwayBaseVersion 1.8.1 # Change to current SwayFX tag! -%global Tag 0.3 +%global Tag 0.3.1 Name: {{{ git_dir_name }}} Version: %{Tag} diff --git a/meson.build b/meson.build index f13c1eb0..3332128a 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'sway', 'c', - version: '0.3', + version: '0.3.1', license: 'MIT', meson_version: '>=0.60.0', default_options: [ From 6a6cf2841c4bb83f45015067d5bd503be1ab0188 Mon Sep 17 00:00:00 2001 From: RAR27 Date: Fri, 2 Jun 2023 20:19:25 -0400 Subject: [PATCH 6/7] fix: crash when moving tabbed container to scratchpad (#182) when `scratchpad_minimize` enabled --- sway/tree/root.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sway/tree/root.c b/sway/tree/root.c index 636a3b75..2c1b96b8 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c @@ -57,12 +57,15 @@ void root_destroy(struct sway_root *root) { /* Set minimized state from scratchpad container `show` state */ static void root_scratchpad_set_minimize(struct sway_container *con, bool minimize) { - struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel = con->view->foreign_toplevel; - if (wlr_surface_is_xwayland_surface(con->view->surface)) { - struct wlr_xwayland_surface *xsurface = wlr_xwayland_surface_from_wlr_surface(con->view->surface); - wlr_xwayland_surface_set_minimized(xsurface, minimize); - } else if (foreign_toplevel) { - wlr_foreign_toplevel_handle_v1_set_minimized(foreign_toplevel, minimize); + if (con->view) { + struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel = con->view->foreign_toplevel; + + if (wlr_surface_is_xwayland_surface(con->view->surface)) { + struct wlr_xwayland_surface *xsurface = wlr_xwayland_surface_from_wlr_surface(con->view->surface); + wlr_xwayland_surface_set_minimized(xsurface, minimize); + } else if (foreign_toplevel) { + wlr_foreign_toplevel_handle_v1_set_minimized(foreign_toplevel, minimize); + } } } From 3e6626d6c3c876cd043c8589a59c448016bff377 Mon Sep 17 00:00:00 2001 From: rti Date: Sun, 4 Jun 2023 21:48:19 +0200 Subject: [PATCH 7/7] fix: consider dim introduced transparency for blur (#184) The blur rendering logic includes the optimization to render blur only for transparent surfaces. This patch considers surfaces as transparent also when the transparency is only introduced by the dim color. We can now have windows, that are opaque by default become transparent with blurred background as soon as they loose focus. Example configuration: ``` blur on blur_passes 3 blur_radius 5 default_dim_inactive 0.15 dim_inactive_colors.unfocused #00000000 ``` --- sway/desktop/render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/desktop/render.c b/sway/desktop/render.c index b9de2025..47449bb6 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -441,7 +441,7 @@ static void render_surface_iterator(struct sway_output *output, pixman_region32_init(&opaque_region); bool has_alpha = false; - if (deco_data.alpha < 1.0) { + if (deco_data.alpha < 1.0 || deco_data.dim_color[3] < 1.0) { has_alpha = true; pixman_region32_union_rect(&opaque_region, &opaque_region, 0, 0, 0, 0); } else {