Create struct wl_callback_listener *Fl_Wayland_Graphics_Driver::p_surface_frame_listener

This commit is contained in:
ManoloFLTK 2024-01-18 08:51:31 +01:00
parent b7fba465ce
commit 01f2f760b6
4 changed files with 15 additions and 25 deletions

View File

@ -609,11 +609,9 @@ If it's not NULL, the exact content of function \c surface_frame_done() :
static void surface_frame_done(void *data, struct wl_callback *cb, uint32_t time) {
struct wld_window *window = (struct wld_window *)data;
wl_callback_destroy(cb);
if (window->buffer) {
window->frame_cb = NULL;
if (window->buffer->draw_buffer_needs_commit) {
Fl_Wayland_Graphics_Driver::buffer_commit(window);
}
window->frame_cb = NULL;
if (window->buffer && window->buffer->draw_buffer_needs_commit) {
Fl_Wayland_Graphics_Driver::buffer_commit(window);
}
}
\endcode

View File

@ -397,18 +397,6 @@ static void delayed_scissor(Fl_Wayland_Gl_Window_Driver *dr) {
}*/
static void surface_frame_done(void *data, struct wl_callback *cb, uint32_t time) {
struct wld_window *xid = (struct wld_window *)data;
wl_callback_destroy(cb);
xid->frame_cb = NULL;
}
static const struct wl_callback_listener surface_frame_listener = {
.done = surface_frame_done,
};
void Fl_Wayland_Gl_Window_Driver::resize(int is_a_resize, int W, int H) {
if (!egl_window) return;
float f = Fl::screen_scale(pWindow->screen_num());
@ -421,7 +409,8 @@ void Fl_Wayland_Gl_Window_Driver::resize(int is_a_resize, int W, int H) {
struct wld_window *xid = fl_wl_xid(pWindow);
if (xid->kind == Fl_Wayland_Window_Driver::DECORATED && !xid->frame_cb) {
xid->frame_cb = wl_surface_frame(xid->wl_surface);
wl_callback_add_listener(xid->frame_cb, &surface_frame_listener, xid);
wl_callback_add_listener(xid->frame_cb,
Fl_Wayland_Graphics_Driver::p_surface_frame_listener, xid);
}
wl_egl_window_resize(egl_window, W, H, 0, 0);
}

View File

@ -53,6 +53,7 @@ public:
};
static const uint32_t wld_format;
static struct wl_shm_pool *current_pool;
static FL_EXPORT const struct wl_callback_listener *p_surface_frame_listener;
void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen osrc,
int srcx, int srcy) FL_OVERRIDE;
void cache_size(Fl_Image *img, int &width, int &height) FL_OVERRIDE;

View File

@ -118,15 +118,13 @@ struct Fl_Wayland_Graphics_Driver::wld_buffer *
}
// used to support both normal and progressive drawing
// used to support both normal and progressive drawing and for top-level GL windows
static void surface_frame_done(void *data, struct wl_callback *cb, uint32_t time) {
struct wld_window *window = (struct wld_window *)data;
wl_callback_destroy(cb);
if (window->buffer) { // fix for issue #712
window->frame_cb = NULL;
if (window->buffer->draw_buffer_needs_commit) {
Fl_Wayland_Graphics_Driver::buffer_commit(window);
}
window->frame_cb = NULL;
if (window->buffer && window->buffer->draw_buffer_needs_commit) {
Fl_Wayland_Graphics_Driver::buffer_commit(window);
}
}
@ -136,6 +134,10 @@ static const struct wl_callback_listener surface_frame_listener = {
};
const struct wl_callback_listener *Fl_Wayland_Graphics_Driver::p_surface_frame_listener =
&surface_frame_listener;
// copy pixels in region r from the Cairo surface to the Wayland buffer
static void copy_region(struct wld_window *window, struct flCairoRegion *r) {
struct Fl_Wayland_Graphics_Driver::wld_buffer *buffer = window->buffer;
@ -178,7 +180,7 @@ void Fl_Wayland_Graphics_Driver::buffer_commit(struct wld_window *window, struct
Fl_Wayland_Window_Driver::driver(window->fl_win)->wld_scale() );
if (!window->covered) { // see issue #878
window->frame_cb = wl_surface_frame(window->wl_surface);
wl_callback_add_listener(window->frame_cb, &surface_frame_listener, window);
wl_callback_add_listener(window->frame_cb, p_surface_frame_listener, window);
}
wl_surface_commit(window->wl_surface);
window->buffer->draw_buffer_needs_commit = false;