Wayland: account for memorised keyboard surface before wl_surface_destroy()

This commit is contained in:
ManoloFLTK 2023-04-17 08:19:59 +02:00
parent ac76239db7
commit 256e368368
2 changed files with 7 additions and 5 deletions

View File

@ -553,6 +553,7 @@ static void wl_keyboard_enter(void *data, struct wl_keyboard *wl_keyboard,
{
struct Fl_Wayland_Screen_Driver::seat *seat = (struct Fl_Wayland_Screen_Driver::seat*)data;
//fprintf(stderr, "keyboard enter fl_win=%p; keys pressed are: ", Fl_Wayland_Window_Driver::surface_to_window(surface));
key_vector.size(0);
// Replace wl_array_for_each(p, keys) rejected by C++
for (uint32_t *p = (uint32_t *)(keys)->data;
(const char *) p < ((const char *) (keys)->data + (keys)->size);

View File

@ -421,8 +421,9 @@ static void delayed_delete_Fl_X(Fl_X *i) {
static void destroy_surface_caution_pointer_focus(struct wl_surface *surface,
Fl_Wayland_Screen_Driver *scr_driver) {
if (scr_driver->seat->pointer_focus == surface) scr_driver->seat->pointer_focus = NULL;
struct Fl_Wayland_Screen_Driver::seat *seat) {
if (seat->pointer_focus == surface) seat->pointer_focus = NULL;
if (seat->keyboard_surface == surface) seat->keyboard_surface = NULL;
wl_surface_destroy(surface);
}
@ -463,7 +464,7 @@ void Fl_Wayland_Window_Driver::hide() {
}
if (wld_win->wl_surface) {
Fl_Wayland_Screen_Driver *scr_driver = (Fl_Wayland_Screen_Driver*)Fl::screen_driver();
destroy_surface_caution_pointer_focus(wld_win->wl_surface, scr_driver);
destroy_surface_caution_pointer_focus(wld_win->wl_surface, scr_driver->seat);
wld_win->wl_surface = NULL;
}
if (wld_win->custom_cursor) delete_cursor_(wld_win);
@ -1272,7 +1273,7 @@ void Fl_Wayland_Window_Driver::makeWindow()
// a tall menuwindow with a menutitle: don't create the menutitle at all
// and undo what has been created/allocated before
struct wld_window *xid = fl_wl_xid(previous_floatingtitle);
destroy_surface_caution_pointer_focus(xid->wl_surface, scr_driver);
destroy_surface_caution_pointer_focus(xid->wl_surface, scr_driver->seat);
free(xid);
Fl_Window_Driver::driver(previous_floatingtitle)->hide_common();
previous_floatingtitle = NULL;
@ -1765,7 +1766,7 @@ void Fl_Wayland_Window_Driver::reposition_menu_window(int x, int y) {
xdg_popup_destroy(old_popup);
delete old_win_pos;
xdg_surface_destroy(old_xdg);
destroy_surface_caution_pointer_focus(old_surface, scr_driver);
destroy_surface_caution_pointer_focus(old_surface, scr_driver->seat);
this->y(y);
}