mirror of
https://github.com/fltk/fltk.git
synced 2026-03-23 15:35:11 +08:00
Cont'd "New Wayland subwindow code creates issues with resizes of opengl windows…" (#1311)
This commit is contained in:
@@ -300,7 +300,6 @@ void Fl_Gl_Window::resize(int X,int Y,int W,int H) {
|
||||
if (is_a_resize) valid(0);
|
||||
pGlWindowDriver->resize(is_a_resize, W, H);
|
||||
Fl_Window::resize(X,Y,W,H);
|
||||
if (is_a_resize) pGlWindowDriver->after_resize();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,7 +67,6 @@ public:
|
||||
virtual void make_current_after() {}
|
||||
virtual void swap_buffers() {}
|
||||
virtual void resize(int /*is_a_resize*/, int /*w*/, int /*h*/) {}
|
||||
virtual void after_resize() {}
|
||||
virtual char swap_type();
|
||||
virtual void swap_interval(int) { }
|
||||
virtual int swap_interval() const { return -1; }
|
||||
|
||||
@@ -32,13 +32,13 @@ private:
|
||||
static EGLDisplay egl_display;
|
||||
struct wl_egl_window *egl_window;
|
||||
EGLSurface egl_surface;
|
||||
bool need_swap;
|
||||
Fl_Wayland_Gl_Window_Driver(Fl_Gl_Window *win);
|
||||
float pixels_per_unit() FL_OVERRIDE;
|
||||
void make_current_before() FL_OVERRIDE;
|
||||
int mode_(int m, const int *a) FL_OVERRIDE;
|
||||
void swap_buffers() FL_OVERRIDE;
|
||||
void resize(int is_a_resize, int w, int h) FL_OVERRIDE;
|
||||
void after_resize() FL_OVERRIDE;
|
||||
char swap_type() FL_OVERRIDE;
|
||||
void swap_interval(int) FL_OVERRIDE;
|
||||
int swap_interval() const FL_OVERRIDE;
|
||||
@@ -52,6 +52,7 @@ private:
|
||||
void gl_visual(Fl_Gl_Choice *c) FL_OVERRIDE;
|
||||
void init();
|
||||
public:
|
||||
static void surface_frame_done(void *data, struct wl_callback *cb, uint32_t time);
|
||||
//virtual bool need_scissor() { return true; } // CONTROL_LEAKING_SUB_GL_WINDOWS
|
||||
//void apply_scissor(); // CONTROL_LEAKING_SUB_GL_WINDOWS
|
||||
};
|
||||
|
||||
@@ -76,6 +76,7 @@ Fl_Wayland_Gl_Window_Driver::Fl_Wayland_Gl_Window_Driver(Fl_Gl_Window *win) :
|
||||
if (egl_display == EGL_NO_DISPLAY) init();
|
||||
egl_window = NULL;
|
||||
egl_surface = NULL;
|
||||
need_swap = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -300,6 +301,23 @@ int Fl_Wayland_Gl_Window_Driver::mode_(int m, const int *a) {
|
||||
}
|
||||
|
||||
|
||||
void Fl_Wayland_Gl_Window_Driver::surface_frame_done(void *data, struct wl_callback *cb, uint32_t time) {
|
||||
Fl_Wayland_Gl_Window_Driver *gl_dr = (Fl_Wayland_Gl_Window_Driver *)data;
|
||||
wl_callback_destroy(cb);
|
||||
struct wld_window *window = fl_wl_xid(gl_dr->pWindow);
|
||||
window->frame_cb = NULL;
|
||||
if (gl_dr->need_swap) {
|
||||
eglSwapBuffers(Fl_Wayland_Gl_Window_Driver::egl_display, gl_dr->egl_surface);
|
||||
gl_dr->need_swap = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const struct wl_callback_listener surface_frame_listener = {
|
||||
.done = Fl_Wayland_Gl_Window_Driver::surface_frame_done,
|
||||
};
|
||||
|
||||
|
||||
void Fl_Wayland_Gl_Window_Driver::swap_buffers() {
|
||||
if (overlay()) {
|
||||
static bool overlay_buffer = true;
|
||||
@@ -333,14 +351,21 @@ void Fl_Wayland_Gl_Window_Driver::swap_buffers() {
|
||||
}
|
||||
|
||||
if (egl_surface) {
|
||||
if (pWindow->parent()) { // issue #967
|
||||
Fl_Window *parent = pWindow->parent() ? pWindow->window() : NULL;
|
||||
struct wld_window *parent_xid = parent ? fl_wl_xid(parent) : NULL;
|
||||
if (parent_xid) { // issue #967
|
||||
struct wld_window *xid = fl_wl_xid(pWindow);
|
||||
if (xid->frame_cb) return;
|
||||
xid->frame_cb = wl_surface_frame(xid->wl_surface);
|
||||
wl_callback_add_listener(xid->frame_cb, Fl_Wayland_Graphics_Driver::p_surface_frame_listener,
|
||||
xid);
|
||||
if (xid->frame_cb) {
|
||||
need_swap = true;
|
||||
return;
|
||||
}
|
||||
if (!parent_xid->frame_cb) {
|
||||
xid->frame_cb = wl_surface_frame(xid->wl_surface);
|
||||
wl_callback_add_listener(xid->frame_cb, &surface_frame_listener, this);
|
||||
}
|
||||
}
|
||||
eglSwapBuffers(Fl_Wayland_Gl_Window_Driver::egl_display, egl_surface);
|
||||
need_swap = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,13 +431,6 @@ void Fl_Wayland_Gl_Window_Driver::resize(int is_a_resize, int W, int H) {
|
||||
}*/
|
||||
}
|
||||
|
||||
void Fl_Wayland_Gl_Window_Driver::after_resize() {
|
||||
Fl_Window *parent = (pWindow->parent() ? pWindow->window() : NULL);
|
||||
struct wld_window *xid = (parent ? fl_wl_xid(parent) : NULL);
|
||||
if (xid && !xid->frame_cb) {
|
||||
eglSwapBuffers(Fl_Wayland_Gl_Window_Driver::egl_display, egl_surface);
|
||||
}
|
||||
}
|
||||
|
||||
char Fl_Wayland_Gl_Window_Driver::swap_type() {
|
||||
return copy;
|
||||
|
||||
@@ -1517,7 +1517,6 @@ void Fl_Wayland_Window_Driver::makeWindow()
|
||||
wait_for_expose_value = 0;
|
||||
pWindow->border(0);
|
||||
checkSubwindowFrame(); // make sure subwindow doesn't leak outside parent
|
||||
if (can_expand_outside_parent_) parent->covered = true; // for #1307
|
||||
|
||||
} else { // a window without decoration
|
||||
new_window->kind = UNFRAMED;
|
||||
@@ -1926,6 +1925,7 @@ void Fl_Wayland_Window_Driver::resize(int X, int Y, int W, int H) {
|
||||
if (fl_win->subsurface) wl_subsurface_set_position(fl_win->subsurface, X * f, Y * f);
|
||||
if (!parent_xid->buffer->wl_buffer || parent_xid->buffer->draw_buffer_needs_commit) {
|
||||
if (!parent_xid->frame_cb) Fl_Wayland_Graphics_Driver::buffer_commit(parent_xid);
|
||||
else wl_surface_commit(parent_xid->wl_surface);
|
||||
} else {
|
||||
if (!parent_xid->frame_cb) {
|
||||
// Use the frame callback mechanism applied to the object's parent window
|
||||
|
||||
Reference in New Issue
Block a user