Only send display events for hotplugged displays, not the initial state

main
Sam Lantinga 2021-11-23 20:14:18 +00:00
parent a3c05d2f34
commit 57366285d8
2 changed files with 11 additions and 5 deletions

View File

@ -202,6 +202,7 @@ Wayland_CreateDevice(int devindex)
return NULL;
}
data->initializing = SDL_TRUE;
data->display = display;
/* Initialize all variables that we clean on shutdown */
@ -449,15 +450,15 @@ display_handle_done(void *data,
if (driverdata->index == -1) {
/* First time getting display info, create the VideoDisplay */
SDL_bool send_event = driverdata->videodata->initializing ? SDL_FALSE : SDL_TRUE;
driverdata->placeholder.orientation = driverdata->orientation;
driverdata->placeholder.driverdata = driverdata;
driverdata->index = SDL_AddVideoDisplay(&driverdata->placeholder, SDL_TRUE);
driverdata->index = SDL_AddVideoDisplay(&driverdata->placeholder, send_event);
SDL_free(driverdata->placeholder.name);
SDL_zero(driverdata->placeholder);
dpy = SDL_GetDisplay(driverdata->index);
} else {
SDL_SendDisplayEvent(dpy, SDL_DISPLAYEVENT_ORIENTATION, driverdata->orientation);
}
SDL_SendDisplayEvent(dpy, SDL_DISPLAYEVENT_ORIENTATION, driverdata->orientation);
}
static void
@ -489,6 +490,7 @@ Wayland_add_display(SDL_VideoData *d, uint32_t id)
}
data = SDL_malloc(sizeof *data);
SDL_zerop(data);
data->videodata = d;
data->output = output;
data->registry_id = id;
data->scale_factor = 1.0;
@ -679,6 +681,8 @@ Wayland_VideoInit(_THIS)
Wayland_InitKeyboard(_this);
data->initializing = SDL_FALSE;
return 0;
}

View File

@ -47,6 +47,7 @@ typedef struct {
} SDL_WaylandCursorTheme;
typedef struct {
SDL_bool initializing;
struct wl_display *display;
int display_disconnected;
struct wl_registry *registry;
@ -89,6 +90,7 @@ typedef struct {
} SDL_VideoData;
typedef struct {
SDL_VideoData *videodata;
struct wl_output *output;
uint32_t registry_id;
float scale_factor;