mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
And add a viewport object to accompany the surface (to be used when scaling the surface). Also rename the wl_surf_subsurf struct to wayl_sub_surface, and add a wayl_surface object to it, rather than a plain wl_surface pointer (to also get the viewport pointer).
93 lines
1.9 KiB
C
93 lines
1.9 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"
|
|
#include "util.h"
|
|
|
|
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->csd_mode != 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.surface[i].sub);
|
|
}
|
|
|
|
void
|
|
quirk_weston_csd_off(struct terminal *term)
|
|
{
|
|
if (term->window->csd_mode != 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.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.surf, 0, 0, INT32_MAX, INT32_MAX);
|
|
}
|