Wayland: fix opening GL top-level window on 2-screen system

This commit is contained in:
ManoloFLTK 2023-05-11 18:42:07 +02:00
parent 4fb18ffbdd
commit 37abac2d8e
3 changed files with 17 additions and 8 deletions

View File

@ -411,7 +411,9 @@ void Fl_Wayland_Gl_Window_Driver::resize(int is_a_resize, int W, int H) {
wl_egl_window_get_attached_size(egl_window, &W2, &H2);
if (W2 != W || H2 != H) {
wl_egl_window_resize(egl_window, W, H, 0, 0);
//fprintf(stderr, "Fl_Wayland_Gl_Window_Driver::resize to %dx%d\n", W, H);
//fprintf(stderr, "Fl_Wayland_Gl_Window_Driver::resize from %dx%d to %dx%d\n",
// W2, H2, W, H);
Fl::wait(0);
}
/* CONTROL_LEAKING_SUB_GL_WINDOWS
if (Fl_Wayland_Window_Driver::driver(pWindow)->subRect()) {
@ -430,9 +432,6 @@ void Fl_Wayland_Gl_Window_Driver::gl_visual(Fl_Gl_Choice *c) {
wld_egl_conf = ((Fl_Wayland_Gl_Choice*)c)->egl_conf;
}
static void delayed_redraw(Fl_Window *win) {
win->redraw();
}
void Fl_Wayland_Gl_Window_Driver::gl_start() {
float f = Fl::screen_scale(Fl_Window::current()->screen_num());
@ -443,7 +442,7 @@ void Fl_Wayland_Gl_Window_Driver::gl_start() {
wl_egl_window_get_attached_size(dr->gl_start_support_->egl_window, &W2, &H2);
if (W2 != W || H2 != H) {
wl_egl_window_resize(dr->gl_start_support_->egl_window, W, H, 0, 0);
Fl::add_timeout(0.01, (Fl_Timeout_Handler)delayed_redraw, Fl_Window::current());
Fl::wait(0);
}
glClearColor(0., 0., 0., 0.);
glClear(GL_COLOR_BUFFER_BIT);

View File

@ -83,7 +83,6 @@ public:
Fl_Wayland_Window_Driver(Fl_Window*);
virtual ~Fl_Wayland_Window_Driver();
static struct wld_window *wld_window;
static void redraw(struct wld_window *window);
static Fl_Window *surface_to_window(struct wl_surface *);
static inline Fl_Wayland_Window_Driver* driver(const Fl_Window *w) {return (Fl_Wayland_Window_Driver*)Fl_Window_Driver::driver(w);}

View File

@ -623,6 +623,12 @@ static struct libdecor_interface libdecor_iface = {
.error = handle_error,
};
static void delayed_redraw(Fl_Window *win) {
win->redraw();
}
static void surface_enter(void *data, struct wl_surface *wl_surface, struct wl_output *wl_output)
{
struct wld_window *window = (struct wld_window*)data;
@ -661,9 +667,14 @@ static void surface_enter(void *data, struct wl_surface *wl_surface, struct wl_o
win_driver->is_a_rescale(true);
window->fl_win->size(window->fl_win->w(), window->fl_win->h());
win_driver->is_a_rescale(false);
if (window->fl_win->as_gl_window() && !window->fl_win->parent() &&
post_scale != pre_scale) { // necessary for glpuzzle on 2-screen system
Fl::add_timeout(0.01, (Fl_Timeout_Handler)delayed_redraw, window->fl_win);
}
} else if (window->buffer) {
if (window->buffer->cb) wl_callback_destroy(window->buffer->cb);
Fl_Wayland_Graphics_Driver::buffer_commit(window);
if (!window->buffer->cb) {
Fl_Wayland_Graphics_Driver::buffer_commit(window);
}
}
if (window->fl_win->as_gl_window())
wl_surface_set_buffer_scale(window->wl_surface, output->wld_scale);