Only send display events for hotplugged displays, not the initial state
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index 1938cd6..f9109f1 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -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;
}
diff --git a/src/video/wayland/SDL_waylandvideo.h b/src/video/wayland/SDL_waylandvideo.h
index 4e1d8b2..e82c7ec 100644
--- a/src/video/wayland/SDL_waylandvideo.h
+++ b/src/video/wayland/SDL_waylandvideo.h
@@ -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;