search: enable/disable weston sub-surface desync quirk when rendering search box

This commit is contained in:
Daniel Eklöf 2020-03-01 13:06:00 +01:00
parent a29427a185
commit b6f8a2e422
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 26 additions and 6 deletions

View file

@ -112,6 +112,7 @@ executable(
'main.c',
'misc.c', 'misc.h',
'osc.c', 'osc.h',
'quirks.c', 'quirks.h',
'render.c', 'render.h',
'search.c', 'search.h',
'selection.c', 'selection.h',

View file

@ -3,8 +3,8 @@
#include <stdlib.h>
#include <stdbool.h>
void
quirk_weston_subsurface_desync(struct wl_subsurface *sub)
static bool
is_weston(void)
{
/*
* On weston (8.0), synchronized subsurfaces aren't updated
@ -19,7 +19,6 @@ quirk_weston_subsurface_desync(struct wl_subsurface *sub)
* since it would defeat the purpose of having the subsurface
* synchronized in the first place).
*/
static bool is_weston = false;
static bool initialized = false;
@ -28,8 +27,23 @@ quirk_weston_subsurface_desync(struct wl_subsurface *sub)
is_weston = getenv("WESTON_CONFIG_FILE") != NULL;
}
if (!is_weston)
return is_weston;
}
void
quirk_weston_subsurface_desync_on(struct wl_subsurface *sub)
{
if (!is_weston())
return;
wl_subsurface_set_desync(sub);
}
void
quirk_weston_subsurface_desync_off(struct wl_subsurface *sub)
{
if (!is_weston())
return;
wl_subsurface_set_sync(sub);
}

View file

@ -2,4 +2,5 @@
#include <wayland-client.h>
void quirk_weston_subsurface_desync(struct wl_subsurface *sub);
void quirk_weston_subsurface_desync_on(struct wl_subsurface *sub);
void quirk_weston_subsurface_desync_off(struct wl_subsurface *sub);

View file

@ -18,6 +18,7 @@
#include "log.h"
#include "config.h"
#include "grid.h"
#include "quirks.h"
#include "selection.h"
#include "shm.h"
@ -1211,6 +1212,8 @@ render_search_box(struct terminal *term)
if (term->search.cursor >= term->search.len)
draw_bar(term, buf->pix, font, &fg, x, y);
quirk_weston_subsurface_desync_on(term->window->search_sub_surface);
/* TODO: this is only necessary on a window resize */
wl_subsurface_set_position(
term->window->search_sub_surface,
@ -1229,6 +1232,7 @@ render_search_box(struct terminal *term)
}
wl_surface_commit(term->window->search_surface);
quirk_weston_subsurface_desync_off(term->window->search_sub_surface);
}
/* Move to terminal.c? */

View file

@ -79,12 +79,12 @@ search_begin(struct terminal *term)
win->search_sub_surface = wl_subcompositor_get_subsurface(
wayl->sub_compositor, win->search_surface, win->surface);
wl_subsurface_set_desync(win->search_sub_surface);
struct wl_region *region = wl_compositor_create_region(term->wl->compositor);
wl_region_add(region, 0, 0, INT32_MAX, INT32_MAX);
wl_surface_set_opaque_region(win->search_surface, region);
wl_region_destroy(region);
wl_subsurface_set_sync(win->search_sub_surface);
term->search.original_view = term->grid->view;
term->search.view_followed_offset = term->grid->view == term->grid->offset;