aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2023-04-25 19:33:45 +0000
committerDaniel Eklöf <daniel@ekloef.se>2023-05-12 12:51:05 +0000
commit3b41379be43a21a00a776d0d136c5d1b2fe4007e (patch)
tree13454ab49cc74a3fd6a2f8f840a25facfac2b08d
parentterm: reset: switch modifyOtherKeys back to level 1 (diff)
quirks: sway does not damage surface beneath sub-surface, when unmapped
When unmapping a sub-surface, Sway <= 1.8 does not damage the surface beneath the sub-surface. https://github.com/swaywm/sway/issues/6960 The workaround is to manually damage the main surface. Previously, this was done when exiting scrollback search, and after the ‘flash’ OSC. But other sub-surfaces, that may also be unmapped, did not. This patch adds a quirk handler that does this, and calls it when: * Exiting scrollback search * Ending the ‘flash’ OSC * Exiting unicode input mode * Clearing URL labels * Removing the scrollback position indicator Closes #1335
-rw-r--r--quirks.c25
-rw-r--r--quirks.h2
-rw-r--r--render.c11
-rw-r--r--search.c6
-rw-r--r--terminal.c5
-rw-r--r--url-mode.c5
6 files changed, 43 insertions, 11 deletions
diff --git a/quirks.c b/quirks.c
index e4fe4a1f..bf9bc7fb 100644
--- a/quirks.c
+++ b/quirks.c
@@ -66,3 +66,28 @@ quirk_weston_csd_off(struct terminal *term)
for (int i = 0; i < ALEN(term->window->csd.surface); i++)
quirk_weston_subsurface_desync_off(term->window->csd.surface[i].sub);
}
+
+static bool
+is_sway(void)
+{
+ static bool is_sway = false;
+ static bool initialized = false;
+
+ if (!initialized) {
+ initialized = true;
+ is_sway = getenv("SWAYSOCK") != NULL;
+ if (is_sway)
+ LOG_WARN("applying wl_surface_damage_buffer() workaround for Sway");
+ }
+
+ return is_sway;
+}
+
+void
+quirk_sway_subsurface_unmap(struct terminal *term)
+{
+ if (!is_sway())
+ return;
+
+ wl_surface_damage_buffer(term->window->surface, 0, 0, INT32_MAX, INT32_MAX);
+}
diff --git a/quirks.h b/quirks.h
index e762bb3e..0e840667 100644
--- a/quirks.h
+++ b/quirks.h
@@ -21,3 +21,5 @@ void quirk_weston_subsurface_desync_off(struct wl_subsurface *sub);
/* Shortcuts to call desync_{on,off} on all CSD subsurfaces */
void quirk_weston_csd_on(struct terminal *term);
void quirk_weston_csd_off(struct terminal *term);
+
+void quirk_sway_subsurface_unmap(struct terminal *term);
diff --git a/render.c b/render.c
index 521c8b7f..f1e80392 100644
--- a/render.c
+++ b/render.c
@@ -1527,6 +1527,10 @@ render_overlay(struct terminal *term)
wl_surface_commit(overlay->surf);
term->render.last_overlay_style = OVERLAY_NONE;
term->render.last_overlay_buf = NULL;
+
+ /* Work around Sway bug - unmapping a sub-surface does not
+ * damage the underlying surface */
+ quirk_sway_subsurface_unmap(term);
}
return;
}
@@ -2374,8 +2378,13 @@ render_scrollback_position(struct terminal *term)
struct wl_window *win = term->window;
if (term->grid->view == term->grid->offset) {
- if (win->scrollback_indicator.surf != NULL)
+ if (win->scrollback_indicator.surf != NULL) {
wayl_win_subsurface_destroy(&win->scrollback_indicator);
+
+ /* Work around Sway bug - unmapping a sub-surface does not damage
+ * the underlying surface */
+ quirk_sway_subsurface_unmap(term);
+ }
return;
}
diff --git a/search.c b/search.c
index 59765c2e..b4bec057 100644
--- a/search.c
+++ b/search.c
@@ -15,6 +15,7 @@
#include "input.h"
#include "key-binding.h"
#include "misc.h"
+#include "quirks.h"
#include "render.h"
#include "selection.h"
#include "shm.h"
@@ -117,11 +118,6 @@ search_cancel_keep_selection(struct terminal *term)
term_xcursor_update(term);
render_refresh(term);
-
- /* Work around Sway bug - unmapping a sub-surface does not damage
- * the underlying surface */
- term_damage_margins(term);
- term_damage_view(term);
}
void
diff --git a/terminal.c b/terminal.c
index 39d9b406..ddc24cb3 100644
--- a/terminal.c
+++ b/terminal.c
@@ -406,11 +406,6 @@ fdm_flash(struct fdm *fdm, int fd, int events, void *data)
term->flash.active = false;
render_refresh(term);
-
- /* Work around Sway bug - unmapping a sub-surface does not damage
- * the underlying surface */
- term_damage_margins(term);
- term_damage_view(term);
return true;
}
diff --git a/url-mode.c b/url-mode.c
index 7d7ffd81..bd9b5157 100644
--- a/url-mode.c
+++ b/url-mode.c
@@ -14,6 +14,7 @@
#include "char32.h"
#include "grid.h"
#include "key-binding.h"
+#include "quirks.h"
#include "render.h"
#include "selection.h"
#include "spawn.h"
@@ -859,6 +860,10 @@ urls_reset(struct terminal *term)
tll_foreach(term->window->urls, it) {
wayl_win_subsurface_destroy(&it->item.surf);
tll_remove(term->window->urls, it);
+
+ /* Work around Sway bug - unmapping a sub-surface does not
+ * damage the underlying surface */
+ quirk_sway_subsurface_unmap(term);
}
}