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

This commit is contained in:
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; return NULL;
} }
data->initializing = SDL_TRUE;
data->display = display; data->display = display;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
@ -449,15 +450,15 @@ display_handle_done(void *data,
if (driverdata->index == -1) { if (driverdata->index == -1) {
/* First time getting display info, create the VideoDisplay */ /* 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->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_free(driverdata->placeholder.name);
SDL_zero(driverdata->placeholder); SDL_zero(driverdata->placeholder);
} else {
dpy = SDL_GetDisplay(driverdata->index); SDL_SendDisplayEvent(dpy, SDL_DISPLAYEVENT_ORIENTATION, driverdata->orientation);
} }
SDL_SendDisplayEvent(dpy, SDL_DISPLAYEVENT_ORIENTATION, driverdata->orientation);
} }
static void static void
@ -489,6 +490,7 @@ Wayland_add_display(SDL_VideoData *d, uint32_t id)
} }
data = SDL_malloc(sizeof *data); data = SDL_malloc(sizeof *data);
SDL_zerop(data); SDL_zerop(data);
data->videodata = d;
data->output = output; data->output = output;
data->registry_id = id; data->registry_id = id;
data->scale_factor = 1.0; data->scale_factor = 1.0;
@ -679,6 +681,8 @@ Wayland_VideoInit(_THIS)
Wayland_InitKeyboard(_this); Wayland_InitKeyboard(_this);
data->initializing = SDL_FALSE;
return 0; return 0;
} }

View File

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