foot/quirks.c
Daniel Eklöf b42709525c
quirks: add KDE quirk: surface must be damaged *after* being attached
KDE resets all surface damage when a buffer is attached. Add a quirk
that adds a full-buffer damage to the surface. This quirk is intended
to be called after attaching a buffer to a surface.
2020-03-24 17:44:17 +01:00

92 lines
2 KiB
C

#include "quirks.h"
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#define LOG_MODULE "quirks"
#define LOG_ENABLE_DBG 0
#include "log.h"
#define ALEN(v) (sizeof(v) / sizeof(v[0]))
static bool
is_weston(void)
{
static bool is_weston = false;
static bool initialized = false;
if (!initialized) {
initialized = true;
is_weston = getenv("WESTON_CONFIG_FILE") != NULL;
if (is_weston)
LOG_WARN("applying wl_subsurface_set_desync() workaround for 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);
}
void
quirk_weston_csd_on(struct terminal *term)
{
if (term->window->use_csd != CSD_YES)
return;
if (term->window->is_fullscreen)
return;
for (int i = 0; i < ALEN(term->window->csd.surface); i++)
quirk_weston_subsurface_desync_on(term->window->csd.sub_surface[i]);
}
void
quirk_weston_csd_off(struct terminal *term)
{
if (term->window->use_csd != CSD_YES)
return;
if (term->window->is_fullscreen)
return;
for (int i = 0; i < ALEN(term->window->csd.surface); i++)
quirk_weston_subsurface_desync_off(term->window->csd.sub_surface[i]);
}
void
quirk_kde_damage_before_attach(struct wl_surface *surface)
{
static bool is_kde = false;
static bool initialized = false;
if (!initialized) {
initialized = true;
const char *cur_desktop = getenv("XDG_CURRENT_DESKTOP");
if (cur_desktop != NULL)
is_kde = strcasestr(cur_desktop, "kde") != NULL;
if (is_kde)
LOG_WARN("applying wl_surface_damage_buffer() workaround for KDE");
}
if (!is_kde)
return;
wl_surface_damage_buffer(surface, 0, 0, INT32_MAX, INT32_MAX);
}