mirror of
https://github.com/fltk/fltk.git
synced 2026-05-28 11:25:22 +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);
|
if (is_a_resize) valid(0);
|
||||||
pGlWindowDriver->resize(is_a_resize, W, H);
|
pGlWindowDriver->resize(is_a_resize, W, H);
|
||||||
Fl_Window::resize(X,Y,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 make_current_after() {}
|
||||||
virtual void swap_buffers() {}
|
virtual void swap_buffers() {}
|
||||||
virtual void resize(int /*is_a_resize*/, int /*w*/, int /*h*/) {}
|
virtual void resize(int /*is_a_resize*/, int /*w*/, int /*h*/) {}
|
||||||
virtual void after_resize() {}
|
|
||||||
virtual char swap_type();
|
virtual char swap_type();
|
||||||
virtual void swap_interval(int) { }
|
virtual void swap_interval(int) { }
|
||||||
virtual int swap_interval() const { return -1; }
|
virtual int swap_interval() const { return -1; }
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ private:
|
|||||||
static EGLDisplay egl_display;
|
static EGLDisplay egl_display;
|
||||||
struct wl_egl_window *egl_window;
|
struct wl_egl_window *egl_window;
|
||||||
EGLSurface egl_surface;
|
EGLSurface egl_surface;
|
||||||
|
bool need_swap;
|
||||||
Fl_Wayland_Gl_Window_Driver(Fl_Gl_Window *win);
|
Fl_Wayland_Gl_Window_Driver(Fl_Gl_Window *win);
|
||||||
float pixels_per_unit() FL_OVERRIDE;
|
float pixels_per_unit() FL_OVERRIDE;
|
||||||
void make_current_before() FL_OVERRIDE;
|
void make_current_before() FL_OVERRIDE;
|
||||||
int mode_(int m, const int *a) FL_OVERRIDE;
|
int mode_(int m, const int *a) FL_OVERRIDE;
|
||||||
void swap_buffers() FL_OVERRIDE;
|
void swap_buffers() FL_OVERRIDE;
|
||||||
void resize(int is_a_resize, int w, int h) FL_OVERRIDE;
|
void resize(int is_a_resize, int w, int h) FL_OVERRIDE;
|
||||||
void after_resize() FL_OVERRIDE;
|
|
||||||
char swap_type() FL_OVERRIDE;
|
char swap_type() FL_OVERRIDE;
|
||||||
void swap_interval(int) FL_OVERRIDE;
|
void swap_interval(int) FL_OVERRIDE;
|
||||||
int swap_interval() const FL_OVERRIDE;
|
int swap_interval() const FL_OVERRIDE;
|
||||||
@@ -52,6 +52,7 @@ private:
|
|||||||
void gl_visual(Fl_Gl_Choice *c) FL_OVERRIDE;
|
void gl_visual(Fl_Gl_Choice *c) FL_OVERRIDE;
|
||||||
void init();
|
void init();
|
||||||
public:
|
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
|
//virtual bool need_scissor() { return true; } // CONTROL_LEAKING_SUB_GL_WINDOWS
|
||||||
//void apply_scissor(); // 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();
|
if (egl_display == EGL_NO_DISPLAY) init();
|
||||||
egl_window = NULL;
|
egl_window = NULL;
|
||||||
egl_surface = 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() {
|
void Fl_Wayland_Gl_Window_Driver::swap_buffers() {
|
||||||
if (overlay()) {
|
if (overlay()) {
|
||||||
static bool overlay_buffer = true;
|
static bool overlay_buffer = true;
|
||||||
@@ -333,14 +351,21 @@ void Fl_Wayland_Gl_Window_Driver::swap_buffers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (egl_surface) {
|
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);
|
struct wld_window *xid = fl_wl_xid(pWindow);
|
||||||
if (xid->frame_cb) return;
|
if (xid->frame_cb) {
|
||||||
xid->frame_cb = wl_surface_frame(xid->wl_surface);
|
need_swap = true;
|
||||||
wl_callback_add_listener(xid->frame_cb, Fl_Wayland_Graphics_Driver::p_surface_frame_listener,
|
return;
|
||||||
xid);
|
}
|
||||||
|
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);
|
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() {
|
char Fl_Wayland_Gl_Window_Driver::swap_type() {
|
||||||
return copy;
|
return copy;
|
||||||
|
|||||||
@@ -1517,7 +1517,6 @@ void Fl_Wayland_Window_Driver::makeWindow()
|
|||||||
wait_for_expose_value = 0;
|
wait_for_expose_value = 0;
|
||||||
pWindow->border(0);
|
pWindow->border(0);
|
||||||
checkSubwindowFrame(); // make sure subwindow doesn't leak outside parent
|
checkSubwindowFrame(); // make sure subwindow doesn't leak outside parent
|
||||||
if (can_expand_outside_parent_) parent->covered = true; // for #1307
|
|
||||||
|
|
||||||
} else { // a window without decoration
|
} else { // a window without decoration
|
||||||
new_window->kind = UNFRAMED;
|
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 (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->buffer->wl_buffer || parent_xid->buffer->draw_buffer_needs_commit) {
|
||||||
if (!parent_xid->frame_cb) Fl_Wayland_Graphics_Driver::buffer_commit(parent_xid);
|
if (!parent_xid->frame_cb) Fl_Wayland_Graphics_Driver::buffer_commit(parent_xid);
|
||||||
|
else wl_surface_commit(parent_xid->wl_surface);
|
||||||
} else {
|
} else {
|
||||||
if (!parent_xid->frame_cb) {
|
if (!parent_xid->frame_cb) {
|
||||||
// Use the frame callback mechanism applied to the object's parent window
|
// Use the frame callback mechanism applied to the object's parent window
|
||||||
|
|||||||
Reference in New Issue
Block a user