Fix the issues found while reviewing the Wayland backend

Report the errors the display read loop can fail with instead of
dispatching events on a dead connection, and release exactly the keys the
user really holds: BaseInput::pressedKeys is never erased, so the previous
list sent key releases for keys that were never pressed.

The bar is the only owner of the pointer edges now, the fullscreen state
comes from the compositor, and the decorations are enabled once, with the
window geometry published again. The initialization failure paths destroy
their resources exactly once, the screen state is reset on teardown, the
clipboard write does not block the frame loop on a slow reader, and the
gsettings fallback is not retried after it failed.

The stretch blit of the last frame is gone: composeFrame() already paints
the cached content.
This commit is contained in:
alexei-zebra 2026-10-11 20:06:03 +03:00
parent 4d1b4a1638
commit c635549892
No known key found for this signature in database
GPG key ID: D19D450AC3D9A80E
9 changed files with 206 additions and 137 deletions

View file

@ -1,5 +1,6 @@
#include "window/wayland/WaylandCommon.hpp"
#include <cerrno>
#include <cstring>
#include <poll.h>
@ -20,7 +21,6 @@ double waylandNow() {
).count();
}
GlStateGuard::GlStateGuard() {
glGetIntegerv(GL_CURRENT_PROGRAM, &values[0]);
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &values[1]);
@ -37,6 +37,7 @@ GlStateGuard::GlStateGuard() {
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &values[12]);
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &values[13]);
glGetIntegerv(GL_DEPTH_WRITEMASK, &values[14]);
glGetIntegerv(GL_PACK_ALIGNMENT, &values[15]);
glGetIntegerv(GL_VIEWPORT, viewport);
glGetIntegerv(GL_COLOR_WRITEMASK, colorMask);
for (int i = 0; i < 3; i++) {
@ -52,11 +53,13 @@ GlStateGuard::GlStateGuard() {
);
glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &attribs[i][3]);
glGetVertexAttribiv(
i, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &attribs[i][5]
i, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &attribs[i][4]
);
void* pointer = nullptr;
glGetVertexAttribPointerv(i, GL_VERTEX_ATTRIB_ARRAY_POINTER, &pointer);
attribs[i][6] = static_cast<GLint>(reinterpret_cast<intptr_t>(pointer));
attribs[i][5] = static_cast<GLint>(
reinterpret_cast<intptr_t>(pointer)
);
}
flags[0] = glIsEnabled(GL_BLEND);
flags[1] = glIsEnabled(GL_DEPTH_TEST);
@ -70,6 +73,7 @@ GlStateGuard::~GlStateGuard() {
glActiveTexture(values[2]);
glBindTexture(GL_TEXTURE_2D, values[3]);
glPixelStorei(GL_UNPACK_ALIGNMENT, values[4]);
glPixelStorei(GL_PACK_ALIGNMENT, values[15]);
glBlendFuncSeparate(values[5], values[6], values[7], values[8]);
glBlendEquationSeparate(values[9], values[10]);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, values[12]);
@ -86,11 +90,11 @@ GlStateGuard::~GlStateGuard() {
}
}
for (int i = 0; i < 3; i++) {
glBindBuffer(GL_ARRAY_BUFFER, static_cast<GLuint>(attribs[i][5]));
glBindBuffer(GL_ARRAY_BUFFER, static_cast<GLuint>(attribs[i][4]));
glVertexAttribPointer(
i, attribs[i][0], static_cast<GLenum>(attribs[i][1]),
attribs[i][2], attribs[i][3],
reinterpret_cast<void*>(static_cast<intptr_t>(attribs[i][6]))
reinterpret_cast<void*>(static_cast<intptr_t>(attribs[i][5]))
);
if (attribFlags[i]) {
glEnableVertexAttribArray(i);
@ -125,8 +129,6 @@ class WaylandWindow;
WaylandInput* input = nullptr;
WaylandWindow* window = nullptr;
bool serverDecorations = false;
int keycode_from_keysym(xkb_keysym_t sym) {
switch (sym) {
case XKB_KEY_Escape: return GLFW_KEY_ESCAPE;
@ -203,21 +205,43 @@ int keycode_from_keysym(xkb_keysym_t sym) {
}
void dispatch_events(int timeoutMs) {
wl_display_flush(state.display);
if (state.display == nullptr) {
return;
}
if (wl_display_get_error(state.display) != 0) {
on_display_error();
return;
}
if (wl_display_flush(state.display) == -1 && errno != EAGAIN) {
on_display_error();
return;
}
while (wl_display_prepare_read(state.display) != 0) {
wl_display_dispatch_pending(state.display);
wl_display_flush(state.display);
if (wl_display_get_error(state.display) != 0) {
on_display_error();
return;
}
if (wl_display_dispatch_pending(state.display) == -1 ||
wl_display_get_error(state.display) != 0) {
on_display_error();
return;
}
if (wl_display_flush(state.display) == -1 && errno != EAGAIN) {
on_display_error();
return;
}
}
pollfd descriptor {wl_display_get_fd(state.display), POLLIN, 0};
if (poll(&descriptor, 1, timeoutMs) > 0) {
if (wl_display_read_events(state.display) == -1) {
wl_display_cancel_read(state.display);
on_display_error();
return;
}
} else {
wl_display_cancel_read(state.display);
}
wl_display_dispatch_pending(state.display);
if (wl_display_get_error(state.display) != 0) {
if (wl_display_dispatch_pending(state.display) == -1 ||
wl_display_get_error(state.display) != 0) {
on_display_error();
}
}

View file

@ -26,17 +26,16 @@
#include <memory>
#include <optional>
#include <poll.h>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
struct GlStateGuard {
GLint values[16] {};
GLint attribs[3][7] {};
GLint attribs[3][6] {};
GLint viewport[4] {};
GLint colorMask[4] {};
GLboolean flags[6] {};
GLboolean flags[4] {};
GLboolean attribFlags[3] {};
GlStateGuard();
~GlStateGuard();
@ -100,8 +99,6 @@ void ignore_event(Args...) {
void dispatch_events(int timeoutMs);
int keycode_from_keysym(xkb_keysym_t sym);
extern bool serverDecorations;
void zxdg_decoration_configure(
void*, zxdg_toplevel_decoration_v1*, uint32_t mode
);

View file

@ -55,22 +55,27 @@ namespace {
}
}
bool layoutUnavailable = false;
bool read_button_layout(
std::vector<DecorationButton>& left,
std::vector<DecorationButton>& right
) {
FILE* pipe = popen(
"gsettings get org.gnome.desktop.wm.preferences button-layout"
" 2>/dev/null",
"r"
);
if (layoutUnavailable) {
return false;
}
const std::string command = std::string("gsettings get ") +
LAYOUT_SCHEMA + " " + LAYOUT_KEY + " 2>/dev/null";
FILE* pipe = popen(command.c_str(), "r");
if (pipe == nullptr) {
layoutUnavailable = true;
return false;
}
char buffer[256] {};
const char* line = fgets(buffer, sizeof(buffer), pipe);
const int status = pclose(pipe);
if (line == nullptr || status != 0) {
layoutUnavailable = true;
return false;
}
split_layout(std::string(buffer), left, right);
@ -190,7 +195,11 @@ int WaylandWindow::getDecorationHoveredButton() const {
}
void WaylandWindow::enableOwnDecorations() {
if (barEnabled) {
return;
}
barEnabled = true;
resize(size.x, size.y);
setShouldRefresh();
}
@ -222,10 +231,13 @@ int WaylandWindow::barButtonAt(double x, double y) const {
}
uint32_t WaylandWindow::barEdgeAt(double x, double y) const {
if (!barVisible()) {
return 0;
}
if (barButtonAt(x, y) >= 0) {
return 0;
}
const bool inBar = barVisible() && y >= 0.0 && y < barHeight();
const bool inBar = y >= 0.0 && y < barHeight();
uint32_t edges = 0;
if (y < BAR_EDGE) {
edges |= XDG_TOPLEVEL_RESIZE_EDGE_TOP;
@ -276,6 +288,9 @@ CursorShape WaylandWindow::edgeCursor(uint32_t edges) {
}
uint32_t WaylandWindow::pointerEdges() const {
if (!barVisible()) {
return 0;
}
const int margin = marginSize();
uint32_t edges = 0;
if (margin > 0) {
@ -399,9 +414,11 @@ bool WaylandWindow::handleBarButton(uint32_t serial, int button, bool pressed) {
}
bool WaylandWindow::handleBarScroll() const {
if (!barVisible()) {
return false;
}
const double y = contentY(pointerY);
return (barVisible() && y >= 0.0 && y < barHeight()) ||
pointerEdges() != 0;
return (y >= 0.0 && y < barHeight()) || pointerEdges() != 0;
}
void WaylandWindow::onPointerLeave() {

View file

@ -6,18 +6,42 @@
#include "graphics/core/Texture.hpp"
#include <EGL/eglext.h>
WaylandInput::~WaylandInput() {
if (clipboardFd >= 0) {
close(clipboardFd);
clipboardFd = -1;
}
if (state.xkbContext) {
xkb_context_unref(state.xkbContext);
state.xkbContext = nullptr;
}
if (input == this) {
input = nullptr;
}
}
std::tuple<std::unique_ptr<Window>, std::unique_ptr<Input>>
wayland_window_initialize(DisplaySettings* settings, std::string title) {
state.display = wl_display_connect(nullptr);
if (state.display == nullptr) {
waylandLogger.error() << "could not connect to the Wayland display";
std::unique_ptr<WaylandInput> inputPtr;
std::unique_ptr<WaylandWindow> windowPtr;
const auto fail = [&] (
const std::string& message
) -> std::tuple<std::unique_ptr<Window>, std::unique_ptr<Input>> {
waylandLogger.error() << message;
window = nullptr;
input = nullptr;
windowPtr.reset();
inputPtr.reset();
if (state.display != nullptr) {
wl_display_disconnect(state.display);
state.display = nullptr;
}
return {nullptr, nullptr};
};
state.display = wl_display_connect(nullptr);
if (state.display == nullptr) {
return fail("could not connect to the Wayland display");
}
state.registry = wl_display_get_registry(state.display);
static const wl_registry_listener registryListener = [] {
@ -30,23 +54,14 @@ wayland_window_initialize(DisplaySettings* settings, std::string title) {
wl_registry_add_listener(state.registry, &registryListener, nullptr);
wl_display_roundtrip(state.display);
if (state.compositor == nullptr || state.wmBase == nullptr) {
waylandLogger.error() << "the compositor does not provide xdg-shell";
wl_display_disconnect(state.display);
state.display = nullptr;
window = nullptr;
input = nullptr;
if (state.display != nullptr) {
wl_display_disconnect(state.display);
state.display = nullptr;
}
return {nullptr, nullptr};
return fail("the compositor does not provide xdg-shell");
}
state.surface = wl_compositor_create_surface(state.compositor);
auto inputPtr = std::make_unique<WaylandInput>();
inputPtr = std::make_unique<WaylandInput>();
input = inputPtr.get();
auto windowPtr = std::make_unique<WaylandWindow>(
windowPtr = std::make_unique<WaylandWindow>(
*inputPtr, settings, settings->width.get(), settings->height.get()
);
window = windowPtr.get();
@ -66,7 +81,7 @@ wayland_window_initialize(DisplaySettings* settings, std::string title) {
return value;
}();
wl_data_device_add_listener(state.dataDevice, &deviceListener, nullptr);
wl_data_device_add_listener(state.dataDevice, &deviceListener, nullptr);
}
{
@ -116,14 +131,7 @@ wayland_window_initialize(DisplaySettings* settings, std::string title) {
while (!window->configured) {
if (wl_display_dispatch(state.display) == -1) {
waylandLogger.error() << "the Wayland connection was lost";
window = nullptr;
input = nullptr;
if (state.display != nullptr) {
wl_display_disconnect(state.display);
state.display = nullptr;
}
return {nullptr, nullptr};
return fail("the Wayland connection was lost");
}
}
@ -132,14 +140,7 @@ wayland_window_initialize(DisplaySettings* settings, std::string title) {
);
if (window->eglDisplay == EGL_NO_DISPLAY ||
eglInitialize(window->eglDisplay, nullptr, nullptr) == EGL_FALSE) {
waylandLogger.error() << "could not initialize EGL";
window = nullptr;
input = nullptr;
if (state.display != nullptr) {
wl_display_disconnect(state.display);
state.display = nullptr;
}
return {nullptr, nullptr};
return fail("could not initialize EGL");
}
eglBindAPI(EGL_OPENGL_API);
@ -179,14 +180,7 @@ wayland_window_initialize(DisplaySettings* settings, std::string title) {
waylandLogger.warning()
<< "no EGL config with alpha, the drop shadow is off";
if (!chooseConfig(0, requestedSamples) && !chooseConfig(0, 0)) {
waylandLogger.error() << "no suitable EGL config";
window = nullptr;
input = nullptr;
if (state.display != nullptr) {
wl_display_disconnect(state.display);
state.display = nullptr;
}
return {nullptr, nullptr};
return fail("no suitable EGL config");
}
window->shadowEnabled = false;
}
@ -214,29 +208,17 @@ wayland_window_initialize(DisplaySettings* settings, std::string title) {
window->eglDisplay, window->eglSurface, window->eglSurface,
window->eglContext
) == EGL_FALSE) {
waylandLogger.error() << "could not create the OpenGL context";
window = nullptr;
input = nullptr;
if (state.display != nullptr) {
wl_display_disconnect(state.display);
state.display = nullptr;
}
return {nullptr, nullptr};
return fail("could not create the OpenGL context");
}
eglSwapInterval(window->eglDisplay, 0);
glewExperimental = GL_TRUE;
GLenum glewError = glewInit();
if (glewError != GLEW_OK && glewError != GLEW_ERROR_NO_GLX_DISPLAY) {
waylandLogger.error() << "failed to initialize GLEW:\n"
<< glewGetErrorString(glewError);
window = nullptr;
input = nullptr;
if (state.display != nullptr) {
wl_display_disconnect(state.display);
state.display = nullptr;
}
return {nullptr, nullptr};
return fail(
std::string("failed to initialize GLEW:\n") +
reinterpret_cast<const char*>(glewGetErrorString(glewError))
);
}
window->initStretchRenderer();
@ -259,6 +241,10 @@ wayland_window_initialize(DisplaySettings* settings, std::string title) {
<< reinterpret_cast<const char*>(glGetString(GL_RENDERER));
waylandLogger.info() << "windowing platform: Wayland (native)";
// The first configure may arrive with a zero size, so the geometry is
// published once the surface exists.
window->updateWindowGeometry();
return {std::move(windowPtr), std::move(inputPtr)};
}

View file

@ -10,10 +10,12 @@
#include <poll.h>
#include <unistd.h>
#include <cerrno>
#include <chrono>
#include <optional>
#include <string>
#include <thread>
#include <unordered_set>
#include <vector>
/// @brief Offset between the evdev keycode and the xkb one
@ -21,6 +23,8 @@ static constexpr uint32_t XKB_KEYCODE_OFFSET = 8;
class WaylandInput : public BaseInput {
public:
~WaylandInput() override;
void pollEvents(bool waitForRefresh) override;
const char* getClipboardText() const override {
@ -161,7 +165,8 @@ public:
/// @brief Release every pressed key, e.g. when the keyboard focus is lost
void releasePressedKeys() {
const auto keys = pressedKeys;
const auto keys = heldKeys;
heldKeys.clear();
for (auto key : keys) {
onKeyCallback(static_cast<int>(key), false);
}
@ -190,6 +195,11 @@ public:
int keycode = keycode_from_keysym(syms[0]);
if (keycode != 0) {
onKeyCallback(keycode, pressed);
if (pressed) {
heldKeys.insert(static_cast<uint32_t>(keycode));
} else {
heldKeys.erase(static_cast<uint32_t>(keycode));
}
}
if (pressed) {
repeatKeycode = code;
@ -344,13 +354,45 @@ private:
listener.send = [] (
void*, wl_data_source*, const char*, int32_t fd
) {
if (input) {
const std::string& text = input->sourceText;
if (!text.empty() &&
write(fd, text.data(), text.size()) < 0) {
waylandLogger.warning()
<< "could not write to the clipboard";
if (input == nullptr) {
close(fd);
return;
}
const std::string& text = input->sourceText;
const int flags = fcntl(fd, F_GETFL, 0);
if (flags != -1) {
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
}
// The reader may be slow, so the frame loop is not allowed to
// block on the pipe: partial writes and EAGAIN are retried
// only for a bounded time.
const double deadline = waylandNow() + 0.1;
size_t offset = 0;
while (offset < text.size()) {
const ssize_t written = write(
fd, text.data() + offset, text.size() - offset
);
if (written > 0) {
offset += static_cast<size_t>(written);
continue;
}
if (written < 0 && errno == EINTR) {
continue;
}
if (written < 0 &&
(errno == EAGAIN || errno == EWOULDBLOCK)) {
if (waylandNow() < deadline) {
pollfd descriptor {fd, POLLOUT, 0};
if (poll(&descriptor, 1, 10) > 0) {
continue;
}
}
}
break;
}
if (offset < text.size()) {
waylandLogger.warning()
<< "could not write to the clipboard";
}
close(fd);
};
@ -386,6 +428,8 @@ private:
CursorShape cursor = CursorShape::ARROW;
std::optional<CursorShape> overrideCursor;
// the keys really held: BaseInput::pressedKeys is never erased
std::unordered_set<uint32_t> heldKeys;
xkb_keycode_t repeatKeycode = 0;
double repeatTime = 0.0;
double lastRepeat = 0.0;

View file

@ -38,6 +38,7 @@ static void pointer_motion(
const double x = wl_fixed_to_double(sx);
const double y = wl_fixed_to_double(sy);
if (window && window->handleBarMotion(x, y)) {
window->setShouldRefresh();
return;
}
if (input) {
@ -371,7 +372,8 @@ void registry_global_remove(void*, wl_registry*, uint32_t) {
void zxdg_decoration_configure(
void*, zxdg_toplevel_decoration_v1*, uint32_t mode
) {
serverDecorations = mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
const bool serverDecorations =
mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
if (window != nullptr) {
if (serverDecorations) {
window->disableOwnDecorations();

View file

@ -44,6 +44,7 @@ namespace {
struct SettingsWatcher::Impl {
#ifdef VOXELCORE_SDBUS
sd_bus* bus = nullptr;
std::string changedSchema;
std::string changedKey;
std::string changedValue;
bool changed = false;
@ -58,7 +59,8 @@ struct SettingsWatcher::Impl {
return 0;
}
const std::string value = readVariant(message);
if (key != nullptr && !value.empty()) {
if (schema != nullptr && key != nullptr && !value.empty()) {
self->changedSchema = schema;
self->changedKey = key;
self->changedValue = value;
self->changed = true;
@ -86,10 +88,14 @@ bool SettingsWatcher::open() {
impl->bus = nullptr;
return false;
}
sd_bus_match_signal(
impl->bus, nullptr, nullptr, PORTAL_PATH, PORTAL_INTERFACE,
"SettingChanged", &Impl::onSettingChanged, impl
);
if (sd_bus_match_signal(
impl->bus, nullptr, nullptr, PORTAL_PATH, PORTAL_INTERFACE,
"SettingChanged", &Impl::onSettingChanged, impl
) < 0) {
sd_bus_flush_close_unref(impl->bus);
impl->bus = nullptr;
return false;
}
return true;
#else
return false;
@ -163,10 +169,17 @@ bool SettingsWatcher::poll(
message = nullptr;
}
}
if (!impl->changed || impl->changedKey != key) {
if (result < 0) {
close();
return false;
}
if (!impl->changed) {
return false;
}
impl->changed = false;
if (impl->changedSchema != schema || impl->changedKey != key) {
return false;
}
value = impl->changedValue;
return true;
#else

View file

@ -1,7 +1,6 @@
#include "window/wayland/WaylandWindow.hpp"
#include "settings.hpp"
#include "graphics/core/Texture.hpp"
#include "util/platform.hpp"
WaylandWindow::WaylandWindow(
@ -100,6 +99,14 @@ WaylandWindow::~WaylandWindow() {
xkb_keymap_unref(state.xkbKeymap);
state.xkbKeymap = nullptr;
}
if (state.xkbContext) {
xkb_context_unref(state.xkbContext);
state.xkbContext = nullptr;
}
if (state.display) {
wl_display_disconnect(state.display);
}
state = WaylandState {};
}
double WaylandWindow::time() {
@ -118,13 +125,11 @@ void WaylandWindow::swapBuffers() {
cacheContent();
}
} else if (resizing) {
// While the pointer drags the window border the content is only
// redrawn when the engine asked for it, otherwise the last frame is
// stretched into the new size.
// While the pointer drags the window border the content is redrawn
// only when the engine asked for it, otherwise composeFrame() reuses
// the cached frame.
if (renderPending) {
cacheContent();
} else if (marginSize() == 0) {
drawStretched();
}
} else if (frameRendered) {
cacheContent();
@ -291,7 +296,7 @@ int WaylandWindow::marginSize() const {
}
bool WaylandWindow::compactBar() const {
return settings != nullptr && settings->compactWindowBar.get();
return settings->compactWindowBar.get();
}
int WaylandWindow::barHeight() const {
@ -299,13 +304,10 @@ int WaylandWindow::barHeight() const {
}
bool WaylandWindow::liveResizeEnabled() const {
return settings == nullptr || settings->liveResize.get();
return settings->liveResize.get();
}
void WaylandWindow::updateSettings() {
if (settings == nullptr) {
return;
}
const bool compactBar = settings->compactWindowBar.get();
if (compactBar != compactBarSetting) {
compactBarSetting = compactBar;
@ -342,8 +344,8 @@ void WaylandWindow::resize(int width, int height) {
if (eglWindow) {
const auto surface = surfaceSize();
wl_egl_window_resize(eglWindow, surface.x, surface.y, 0, 0);
glViewport(0, 0, width, height);
}
glViewport(0, 0, width, height);
updateWindowGeometry();
if (Window::mode == WindowMode::WINDOWED && !maximized) {
settings->width.set(width);
@ -359,6 +361,7 @@ void WaylandWindow::onConfigure(
pendingWidth = width;
pendingHeight = height;
stateMaximized = false;
stateFullscreen = false;
stateSuspended = false;
stateActivated = false;
const auto* values = static_cast<const uint32_t*>(states->data);
@ -367,6 +370,9 @@ void WaylandWindow::onConfigure(
case XDG_TOPLEVEL_STATE_MAXIMIZED:
stateMaximized = true;
break;
case XDG_TOPLEVEL_STATE_FULLSCREEN:
stateFullscreen = true;
break;
case XDG_TOPLEVEL_STATE_SUSPENDED:
stateSuspended = true;
break;
@ -379,6 +385,7 @@ void WaylandWindow::onConfigure(
void WaylandWindow::applyConfigure() {
maximized = stateMaximized;
fullscreen = stateFullscreen;
suspended = stateSuspended;
if (pendingWidth > 0 && pendingHeight > 0) {
if (!initialSizeApplied && Window::mode == WindowMode::WINDOWED &&
@ -531,7 +538,6 @@ void WaylandWindow::initShadowRenderer() {
for (int i = 0; names[i] != nullptr; i++) {
shadowUniforms[i] = glGetUniformLocation(shadowProgram, names[i]);
}
}
namespace {
@ -680,29 +686,6 @@ void WaylandWindow::cacheContent() {
lastCacheTime = now();
}
void WaylandWindow::drawStretched() {
GlStateGuard state;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, size.x, size.y);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glDisable(GL_CULL_FACE);
glDisable(GL_SCISSOR_TEST);
if (stretchProgram == 0 || cacheWidth == 0) {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
return;
}
glUseProgram(stretchProgram);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, cacheTexture);
glUniform1i(stretchTextureUniform, 0);
glBindVertexArray(stretchVao);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);
glUseProgram(0);
}
void WaylandWindow::onFrameDone() {
frameCallback = nullptr;
frameDone = true;

View file

@ -15,7 +15,7 @@
#include <vector>
class WaylandWindow : public Window {
public:
public:
WaylandInput& input;
DisplaySettings* settings;
EGLDisplay eglDisplay = EGL_NO_DISPLAY;
@ -25,6 +25,7 @@ class WaylandWindow : public Window {
int32_t pendingWidth = 0;
int32_t pendingHeight = 0;
bool stateMaximized = false;
bool stateFullscreen = false;
bool stateSuspended = false;
bool stateActivated = true;
bool configured = false;
@ -70,6 +71,10 @@ class WaylandWindow : public Window {
double frameCost = 0.0;
double cacheTimeout = 0.5;
bool resizing = false;
// renderPending asks the engine for a new frame after a resize pause,
// presentPending marks a buffer the compositor has not taken yet and
// frameDone a frame callback that already fired. frameOnCallback says
// that pacing follows those callbacks rather than the wall clock.
bool renderPending = true;
bool presentPending = true;
double lastPresent = 0.0;
@ -173,7 +178,6 @@ class WaylandWindow : public Window {
void makeContentOpaque(int x, int y, int width, int height);
const std::vector<DecorationButtonLayout>& getDecorationButtons() const
override;
@ -197,11 +201,10 @@ class WaylandWindow : public Window {
void initStretchRenderer();
void resizeCache(int width, int height);
void cacheContent();
void drawStretched();
void enableOwnDecorations();
void disableOwnDecorations();
bool barVisible() const;
int barButtonAt(double x, double y) const;
int barButtonAt(double x, double y) const;
uint32_t barEdgeAt(double x, double y) const;
static CursorShape edgeCursor(uint32_t edges);
uint32_t pointerEdges() const;