-
Notifications
You must be signed in to change notification settings - Fork 2
/
xdg_surface_handle.h
59 lines (51 loc) · 1.8 KB
/
xdg_surface_handle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef XDG_SURFACE_HANDLER_H
#define XDG_SURFACE_HANDLER_H
#include "config.h"
#include "egl.h"
#include "log.h"
#include "surface_colors.h"
#include <EGL/egl.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <wayland-client.h>
#include <wayland-egl.h>
static void xdg_surface_configure(void* data, struct xdg_surface* xdg_surface, uint32_t serial)
{
struct client_state* state = data;
xdg_surface_ack_configure(xdg_surface, serial);
// Ensure EGL and Wayland surface setup is ready before binding the context
if (state->egl_display && state->egl_surface && state->egl_context)
{
// Check if the current EGL context and surface match the ones we're trying to use
if (eglGetCurrentContext() != state->egl_context ||
eglGetCurrentSurface(EGL_DRAW) != state->egl_surface)
{
if (!eglMakeCurrent(state->egl_display, state->egl_surface, state->egl_surface,
state->egl_context))
{
log_message(LOG_LEVEL_ERROR, "Failed to make EGL context current");
return;
}
}
// Render the lock screen (if not done in another function) and commit
render_lock_screen(state); // Assuming render_lock_screen calls eglSwapBuffers
state->session_lock.surface_dirty = true;
// Surface commit to ensure Wayland knows of the new state
wl_surface_commit(state->wl_surface);
if (!eglSwapBuffers(state->egl_display, state->egl_surface))
{
log_message(LOG_LEVEL_ERROR, "Failed to swap EGL buffers");
}
}
else
{
// If EGL resources are not ready, defer processing
log_message(LOG_LEVEL_WARN,
"EGL display or surfaces not ready in xdg_surface_configure... Waiting ...");
}
}
static const struct xdg_surface_listener xdg_surface_listener = {
.configure = xdg_surface_configure,
};
#endif