diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-05-03 08:50:19 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-05-03 08:50:19 +0200 |
| commit | a94fed77e4c6f6b4528eb79ef01edf370de62d13 (patch) | |
| tree | 683e24b83dc6254486147cb950008dc078cda321 | |
| parent | 9ffeef76975579e0d838ea781a64ec66b92c9851 (diff) | |
Wayland: clearer procedure to complete initialisation of screen data
| -rw-r--r-- | documentation/src/wayland.dox | 1 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Screen_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 10 |
3 files changed, 11 insertions, 1 deletions
diff --git a/documentation/src/wayland.dox b/documentation/src/wayland.dox index 353509e45..6e65a6924 100644 --- a/documentation/src/wayland.dox +++ b/documentation/src/wayland.dox @@ -922,6 +922,7 @@ struct Fl_Wayland_Screen_Driver::output { // one record for each display struct wl_output *wl_output; // the Wayland object for this display int wld_scale; // Wayland scale factor float gui_scale; // FLTK scale factor + bool done; // true means record members have been initialized struct wl_list link; // links these records together }; </pre> diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H index aeacf033d..c20477dba 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H @@ -73,6 +73,7 @@ public: struct wl_output *wl_output; int wld_scale; // Wayland scale factor float gui_scale; // FLTK scale factor + bool done; struct wl_list link; }; diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index ed9ae1313..3c08492a8 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -977,6 +977,7 @@ static void output_done(void *data, struct wl_output *wl_output) } xp = xp->next; } + output->done = true; Fl_Wayland_Screen_Driver *scr_driver = (Fl_Wayland_Screen_Driver*)Fl::screen_driver(); if (scr_driver->seat) try_update_cursor(scr_driver->seat); @@ -1082,7 +1083,6 @@ static void registry_handle_global(void *user_data, struct wl_registry *wl_regis wl_output_add_listener(output->wl_output, &output_listener, output); wl_list_insert(&(scr_driver->outputs), &output->link); scr_driver->screen_count_set( wl_list_length(&(scr_driver->outputs)) ); - wl_display_roundtrip(scr_driver->wl_display); // important //fprintf(stderr, "wl_output: id=%d wl_output=%p screen_count()=%d\n", id, output->wl_output, Fl::screen_count()); } else if (strcmp(interface, xdg_wm_base_interface.name) == 0) { @@ -1107,6 +1107,7 @@ static void registry_handle_global(void *user_data, struct wl_registry *wl_regis output->wld_scale = 1; output->gui_scale = 1.f; output->width = 1440; output->height = 900; + output->done = true; wl_list_insert(&(scr_driver->outputs), &output->link); scr_driver->screen_count_set(1); } @@ -1172,8 +1173,15 @@ Fl_Wayland_Screen_Driver::Fl_Wayland_Screen_Driver() : Fl_Unix_Screen_Driver() { static void sync_done(void *data, struct wl_callback *cb, uint32_t time) { + // runs after all calls to registry_handle_global() *(struct wl_callback **)data = NULL; wl_callback_destroy(cb); + // keep processing until output_done() has run for each screen + Fl_Wayland_Screen_Driver *scr_driver = (Fl_Wayland_Screen_Driver*)Fl::screen_driver(); + Fl_Wayland_Screen_Driver::output *output; + wl_list_for_each(output, &scr_driver->outputs, link) { // each screen of the system + while (!output->done) wl_display_dispatch(scr_driver->wl_display); + } } |
