Backport Wayland fixes with Wayland-by-default from upstream
Resolves: rhbz#2051963 Signed-off-by: Neal Gompa <ngompa@centosproject.org>
This commit is contained in:
parent
ac51f1967f
commit
737aec8a5b
72
0001-video-Prefer-Wayland-over-X11.patch
Normal file
72
0001-video-Prefer-Wayland-over-X11.patch
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
From 8ceba27d6291f1195e13608033ec439aec621fc6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ethan Lee <flibitijibibo@gmail.com>
|
||||||
|
Date: Sat, 17 Apr 2021 12:07:38 -0400
|
||||||
|
Subject: [PATCH] video: Prefer Wayland over X11
|
||||||
|
|
||||||
|
---
|
||||||
|
src/video/SDL_video.c | 24 ++++++++++++------------
|
||||||
|
1 file changed, 12 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
|
||||||
|
index dac8d1cc9..d3fe65502 100644
|
||||||
|
--- a/src/video/SDL_video.c
|
||||||
|
+++ b/src/video/SDL_video.c
|
||||||
|
@@ -61,12 +61,12 @@ static VideoBootStrap *bootstrap[] = {
|
||||||
|
#if SDL_VIDEO_DRIVER_COCOA
|
||||||
|
&COCOA_bootstrap,
|
||||||
|
#endif
|
||||||
|
-#if SDL_VIDEO_DRIVER_X11
|
||||||
|
- &X11_bootstrap,
|
||||||
|
-#endif
|
||||||
|
#if SDL_VIDEO_DRIVER_WAYLAND
|
||||||
|
&Wayland_bootstrap,
|
||||||
|
#endif
|
||||||
|
+#if SDL_VIDEO_DRIVER_X11
|
||||||
|
+ &X11_bootstrap,
|
||||||
|
+#endif
|
||||||
|
#if SDL_VIDEO_DRIVER_VIVANTE
|
||||||
|
&VIVANTE_bootstrap,
|
||||||
|
#endif
|
||||||
|
@@ -4249,12 +4249,12 @@ SDL_IsScreenKeyboardShown(SDL_Window *window)
|
||||||
|
#if SDL_VIDEO_DRIVER_UIKIT
|
||||||
|
#include "uikit/SDL_uikitmessagebox.h"
|
||||||
|
#endif
|
||||||
|
-#if SDL_VIDEO_DRIVER_X11
|
||||||
|
-#include "x11/SDL_x11messagebox.h"
|
||||||
|
-#endif
|
||||||
|
#if SDL_VIDEO_DRIVER_WAYLAND
|
||||||
|
#include "wayland/SDL_waylandmessagebox.h"
|
||||||
|
#endif
|
||||||
|
+#if SDL_VIDEO_DRIVER_X11
|
||||||
|
+#include "x11/SDL_x11messagebox.h"
|
||||||
|
+#endif
|
||||||
|
#if SDL_VIDEO_DRIVER_HAIKU
|
||||||
|
#include "haiku/SDL_bmessagebox.h"
|
||||||
|
#endif
|
||||||
|
@@ -4362,17 +4362,17 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||||
|
retval = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
-#if SDL_VIDEO_DRIVER_X11
|
||||||
|
+#if SDL_VIDEO_DRIVER_WAYLAND
|
||||||
|
if (retval == -1 &&
|
||||||
|
- SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_X11) &&
|
||||||
|
- X11_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||||
|
+ SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WAYLAND) &&
|
||||||
|
+ Wayland_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||||
|
retval = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
-#if SDL_VIDEO_DRIVER_WAYLAND
|
||||||
|
+#if SDL_VIDEO_DRIVER_X11
|
||||||
|
if (retval == -1 &&
|
||||||
|
- SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WAYLAND) &&
|
||||||
|
- Wayland_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||||
|
+ SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_X11) &&
|
||||||
|
+ X11_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||||
|
retval = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
182
0001-wayland-Convert-URI-to-local-path-for-DropFile.patch
Normal file
182
0001-wayland-Convert-URI-to-local-path-for-DropFile.patch
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
From 9a2bbd8acbebcde56dd2f89ebca3b196c2b38914 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ethan Lee <flibitijibibo@gmail.com>
|
||||||
|
Date: Wed, 12 Jan 2022 13:01:05 -0500
|
||||||
|
Subject: [PATCH 01/11] wayland: Convert URI to local path for DropFile
|
||||||
|
|
||||||
|
---
|
||||||
|
src/video/wayland/SDL_waylandevents.c | 149 ++++++++++++++++++++++----
|
||||||
|
1 file changed, 129 insertions(+), 20 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
|
||||||
|
index dfa62ec69..bf2aeea5b 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandevents.c
|
||||||
|
+++ b/src/video/wayland/SDL_waylandevents.c
|
||||||
|
@@ -1312,36 +1312,145 @@ data_device_handle_motion(void *data, struct wl_data_device *wl_data_device,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* Decodes URI escape sequences in string buf of len bytes
|
||||||
|
+ (excluding the terminating NULL byte) in-place. Since
|
||||||
|
+ URI-encoded characters take three times the space of
|
||||||
|
+ normal characters, this should not be an issue.
|
||||||
|
+
|
||||||
|
+ Returns the number of decoded bytes that wound up in
|
||||||
|
+ the buffer, excluding the terminating NULL byte.
|
||||||
|
+
|
||||||
|
+ The buffer is guaranteed to be NULL-terminated but
|
||||||
|
+ may contain embedded NULL bytes.
|
||||||
|
+
|
||||||
|
+ On error, -1 is returned.
|
||||||
|
+
|
||||||
|
+ FIXME: This was shamelessly copied from SDL_x11events.c
|
||||||
|
+ */
|
||||||
|
+static int Wayland_URIDecode(char *buf, int len) {
|
||||||
|
+ int ri, wi, di;
|
||||||
|
+ char decode = '\0';
|
||||||
|
+ if (buf == NULL || len < 0) {
|
||||||
|
+ errno = EINVAL;
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+ if (len == 0) {
|
||||||
|
+ len = SDL_strlen(buf);
|
||||||
|
+ }
|
||||||
|
+ for (ri = 0, wi = 0, di = 0; ri < len && wi < len; ri += 1) {
|
||||||
|
+ if (di == 0) {
|
||||||
|
+ /* start decoding */
|
||||||
|
+ if (buf[ri] == '%') {
|
||||||
|
+ decode = '\0';
|
||||||
|
+ di += 1;
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ /* normal write */
|
||||||
|
+ buf[wi] = buf[ri];
|
||||||
|
+ wi += 1;
|
||||||
|
+ continue;
|
||||||
|
+ } else if (di == 1 || di == 2) {
|
||||||
|
+ char off = '\0';
|
||||||
|
+ char isa = buf[ri] >= 'a' && buf[ri] <= 'f';
|
||||||
|
+ char isA = buf[ri] >= 'A' && buf[ri] <= 'F';
|
||||||
|
+ char isn = buf[ri] >= '0' && buf[ri] <= '9';
|
||||||
|
+ if (!(isa || isA || isn)) {
|
||||||
|
+ /* not a hexadecimal */
|
||||||
|
+ int sri;
|
||||||
|
+ for (sri = ri - di; sri <= ri; sri += 1) {
|
||||||
|
+ buf[wi] = buf[sri];
|
||||||
|
+ wi += 1;
|
||||||
|
+ }
|
||||||
|
+ di = 0;
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ /* itsy bitsy magicsy */
|
||||||
|
+ if (isn) {
|
||||||
|
+ off = 0 - '0';
|
||||||
|
+ } else if (isa) {
|
||||||
|
+ off = 10 - 'a';
|
||||||
|
+ } else if (isA) {
|
||||||
|
+ off = 10 - 'A';
|
||||||
|
+ }
|
||||||
|
+ decode |= (buf[ri] + off) << (2 - di) * 4;
|
||||||
|
+ if (di == 2) {
|
||||||
|
+ buf[wi] = decode;
|
||||||
|
+ wi += 1;
|
||||||
|
+ di = 0;
|
||||||
|
+ } else {
|
||||||
|
+ di += 1;
|
||||||
|
+ }
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ buf[wi] = '\0';
|
||||||
|
+ return wi;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/* Convert URI to local filename
|
||||||
|
+ return filename if possible, else NULL
|
||||||
|
+
|
||||||
|
+ FIXME: This was shamelessly copied from SDL_x11events.c
|
||||||
|
+*/
|
||||||
|
+static char* Wayland_URIToLocal(char* uri) {
|
||||||
|
+ char *file = NULL;
|
||||||
|
+ SDL_bool local;
|
||||||
|
+
|
||||||
|
+ if (SDL_memcmp(uri,"file:/",6) == 0) uri += 6; /* local file? */
|
||||||
|
+ else if (SDL_strstr(uri,":/") != NULL) return file; /* wrong scheme */
|
||||||
|
+
|
||||||
|
+ local = uri[0] != '/' || (uri[0] != '\0' && uri[1] == '/');
|
||||||
|
+
|
||||||
|
+ /* got a hostname? */
|
||||||
|
+ if (!local && uri[0] == '/' && uri[2] != '/') {
|
||||||
|
+ char* hostname_end = SDL_strchr(uri+1, '/');
|
||||||
|
+ if (hostname_end != NULL) {
|
||||||
|
+ char hostname[ 257 ];
|
||||||
|
+ if (gethostname(hostname, 255) == 0) {
|
||||||
|
+ hostname[ 256 ] = '\0';
|
||||||
|
+ if (SDL_memcmp(uri+1, hostname, hostname_end - (uri+1)) == 0) {
|
||||||
|
+ uri = hostname_end + 1;
|
||||||
|
+ local = SDL_TRUE;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ if (local) {
|
||||||
|
+ file = uri;
|
||||||
|
+ /* Convert URI escape sequences to real characters */
|
||||||
|
+ Wayland_URIDecode(file, 0);
|
||||||
|
+ if (uri[1] == '/') {
|
||||||
|
+ file++;
|
||||||
|
+ } else {
|
||||||
|
+ file--;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return file;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void
|
||||||
|
data_device_handle_drop(void *data, struct wl_data_device *wl_data_device)
|
||||||
|
{
|
||||||
|
SDL_WaylandDataDevice *data_device = data;
|
||||||
|
- void *buffer = NULL;
|
||||||
|
- size_t length = 0;
|
||||||
|
-
|
||||||
|
- const char *current_uri = NULL;
|
||||||
|
- const char *last_char = NULL;
|
||||||
|
- char *current_char = NULL;
|
||||||
|
|
||||||
|
if (data_device->drag_offer != NULL) {
|
||||||
|
/* TODO: SDL Support more mime types */
|
||||||
|
- buffer = Wayland_data_offer_receive(data_device->drag_offer,
|
||||||
|
- &length, FILE_MIME, SDL_FALSE);
|
||||||
|
-
|
||||||
|
- /* uri-list */
|
||||||
|
- current_uri = (const char *)buffer;
|
||||||
|
- last_char = (const char *)buffer + length;
|
||||||
|
- for (current_char = buffer; current_char < last_char; ++current_char) {
|
||||||
|
- if (*current_char == '\n' || *current_char == 0) {
|
||||||
|
- if (*current_uri != 0 && *current_uri != '#') {
|
||||||
|
- *current_char = 0;
|
||||||
|
- SDL_SendDropFile(NULL, current_uri);
|
||||||
|
+ size_t length;
|
||||||
|
+ void *buffer = Wayland_data_offer_receive(data_device->drag_offer,
|
||||||
|
+ &length, FILE_MIME, SDL_FALSE);
|
||||||
|
+ if (buffer) {
|
||||||
|
+ char *saveptr = NULL;
|
||||||
|
+ char *token = SDL_strtokr((char *) buffer, "\r\n", &saveptr);
|
||||||
|
+ while (token != NULL) {
|
||||||
|
+ char *fn = Wayland_URIToLocal(token);
|
||||||
|
+ if (fn) {
|
||||||
|
+ SDL_SendDropFile(NULL, fn); /* FIXME: Window? */
|
||||||
|
}
|
||||||
|
- current_uri = (const char *)current_char + 1;
|
||||||
|
+ token = SDL_strtokr(NULL, "\r\n", &saveptr);
|
||||||
|
}
|
||||||
|
+ SDL_SendDropComplete(NULL); /* FIXME: Window? */
|
||||||
|
+ SDL_free(buffer);
|
||||||
|
}
|
||||||
|
-
|
||||||
|
- SDL_free(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
133
0002-wayland-Avoid-spurious-resize-events.patch
Normal file
133
0002-wayland-Avoid-spurious-resize-events.patch
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
From d3952a8a2c8a32d4f6f521402427052a4b756f9f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Cameron Gutman <aicommander@gmail.com>
|
||||||
|
Date: Sun, 16 Jan 2022 15:14:33 -0600
|
||||||
|
Subject: [PATCH 02/11] wayland: Avoid spurious resize events
|
||||||
|
|
||||||
|
---
|
||||||
|
src/video/wayland/SDL_waylandwindow.c | 42 +++++++++++++++++----------
|
||||||
|
src/video/wayland/SDL_waylandwindow.h | 1 +
|
||||||
|
2 files changed, 28 insertions(+), 15 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
index 3eae22bf7..a4b5933eb 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
+++ b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
@@ -224,14 +224,16 @@ handle_configure_xdg_toplevel(void *data,
|
||||||
|
* us a completely stateless, sizeless configure, with which we have
|
||||||
|
* to enforce our own state anyway.
|
||||||
|
*/
|
||||||
|
- if (width != 0 && height != 0) {
|
||||||
|
+ if (width != 0 && height != 0 && (window->w != width || window->h != height)) {
|
||||||
|
window->w = width;
|
||||||
|
window->h = height;
|
||||||
|
+ wind->needs_resize_event = SDL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This part is good though. */
|
||||||
|
- if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||||
|
+ if ((window->flags & SDL_WINDOW_ALLOW_HIGHDPI) && wind->scale_factor != driverdata->scale_factor) {
|
||||||
|
wind->scale_factor = driverdata->scale_factor;
|
||||||
|
+ wind->needs_resize_event = SDL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
@@ -284,8 +286,11 @@ handle_configure_xdg_toplevel(void *data,
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Store this now so the xdg_surface configure knows what to resize to */
|
||||||
|
- window->w = width;
|
||||||
|
- window->h = height;
|
||||||
|
+ if (window->w != width || window->h != height) {
|
||||||
|
+ window->w = width;
|
||||||
|
+ window->h = height;
|
||||||
|
+ wind->needs_resize_event = SDL_TRUE;
|
||||||
|
+ }
|
||||||
|
} else {
|
||||||
|
/* For fullscreen, foolishly do what the compositor says. If it's wrong,
|
||||||
|
* don't blame us, we were explicitly instructed to do this.
|
||||||
|
@@ -293,14 +298,16 @@ handle_configure_xdg_toplevel(void *data,
|
||||||
|
* UPDATE: Nope, sure enough a compositor sends 0,0. This is a known bug:
|
||||||
|
* https://bugs.kde.org/show_bug.cgi?id=444962
|
||||||
|
*/
|
||||||
|
- if (width != 0 && height != 0) {
|
||||||
|
+ if (width != 0 && height != 0 && (window->w != width || window->h != height)) {
|
||||||
|
window->w = width;
|
||||||
|
window->h = height;
|
||||||
|
+ wind->needs_resize_event = SDL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This part is good though. */
|
||||||
|
- if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||||
|
+ if ((window->flags & SDL_WINDOW_ALLOW_HIGHDPI) && wind->scale_factor != driverdata->scale_factor) {
|
||||||
|
wind->scale_factor = driverdata->scale_factor;
|
||||||
|
+ wind->needs_resize_event = SDL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -330,6 +337,7 @@ decoration_frame_configure(struct libdecor_frame *frame,
|
||||||
|
|
||||||
|
enum libdecor_window_state window_state;
|
||||||
|
int width, height;
|
||||||
|
+ float scale_factor = wind->scale_factor;
|
||||||
|
|
||||||
|
SDL_bool focused = SDL_FALSE;
|
||||||
|
SDL_bool fullscreen = SDL_FALSE;
|
||||||
|
@@ -399,7 +407,7 @@ decoration_frame_configure(struct libdecor_frame *frame,
|
||||||
|
|
||||||
|
/* This part is good though. */
|
||||||
|
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||||
|
- wind->scale_factor = driverdata->scale_factor;
|
||||||
|
+ scale_factor = driverdata->scale_factor;
|
||||||
|
}
|
||||||
|
} else if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
|
||||||
|
width = window->windowed.w;
|
||||||
|
@@ -427,7 +435,7 @@ decoration_frame_configure(struct libdecor_frame *frame,
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do the resize on the SDL side (this will set window->w/h)... */
|
||||||
|
- Wayland_HandleResize(window, width, height, wind->scale_factor);
|
||||||
|
+ Wayland_HandleResize(window, width, height, scale_factor);
|
||||||
|
wind->shell_surface.libdecor.initial_configure_seen = SDL_TRUE;
|
||||||
|
|
||||||
|
/* ... then commit the changes on the libdecor side. */
|
||||||
|
@@ -1341,14 +1349,18 @@ Wayland_HandleResize(SDL_Window *window, int width, int height, float scale)
|
||||||
|
{
|
||||||
|
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||||
|
SDL_VideoData *viddata = data->waylandData;
|
||||||
|
-
|
||||||
|
struct wl_region *region;
|
||||||
|
- window->w = 0;
|
||||||
|
- window->h = 0;
|
||||||
|
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, width, height);
|
||||||
|
- window->w = width;
|
||||||
|
- window->h = height;
|
||||||
|
- data->scale_factor = scale;
|
||||||
|
+
|
||||||
|
+ if (data->needs_resize_event || window->w != width || window->h != height || data->scale_factor != scale) {
|
||||||
|
+ /* We may have already updated window w/h (or only adjusted scale factor),
|
||||||
|
+ * so we must override the deduplication logic in the video core */
|
||||||
|
+ window->w = 0;
|
||||||
|
+ window->h = 0;
|
||||||
|
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, width, height);
|
||||||
|
+ window->w = width;
|
||||||
|
+ window->h = height;
|
||||||
|
+ data->needs_resize_event = SDL_FALSE;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
wl_surface_set_buffer_scale(data->surface, data->scale_factor);
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h
|
||||||
|
index 8ca090f0c..bce1d1855 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandwindow.h
|
||||||
|
+++ b/src/video/wayland/SDL_waylandwindow.h
|
||||||
|
@@ -84,6 +84,7 @@ typedef struct {
|
||||||
|
int num_outputs;
|
||||||
|
|
||||||
|
float scale_factor;
|
||||||
|
+ SDL_bool needs_resize_event;
|
||||||
|
} SDL_WindowData;
|
||||||
|
|
||||||
|
extern void Wayland_ShowWindow(_THIS, SDL_Window *window);
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
96
0003-wayland-Fix-building-with-SDL_OPENGL-OFF.patch
Normal file
96
0003-wayland-Fix-building-with-SDL_OPENGL-OFF.patch
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
From ed3442d7a5a79b3a7357c5bdf54b47ab985ca7f7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ethan Lee <flibitijibibo@gmail.com>
|
||||||
|
Date: Wed, 19 Jan 2022 15:47:52 -0500
|
||||||
|
Subject: [PATCH 03/11] wayland: Fix building with SDL_OPENGL=OFF
|
||||||
|
|
||||||
|
---
|
||||||
|
src/video/wayland/SDL_waylandvideo.c | 2 ++
|
||||||
|
src/video/wayland/SDL_waylandwindow.c | 8 ++++++--
|
||||||
|
src/video/wayland/SDL_waylandwindow.h | 2 ++
|
||||||
|
3 files changed, 10 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
|
||||||
|
index f009fb7c6..60d7403c7 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandvideo.c
|
||||||
|
+++ b/src/video/wayland/SDL_waylandvideo.c
|
||||||
|
@@ -230,6 +230,7 @@ Wayland_CreateDevice(int devindex)
|
||||||
|
device->WaitEventTimeout = Wayland_WaitEventTimeout;
|
||||||
|
device->SendWakeupEvent = Wayland_SendWakeupEvent;
|
||||||
|
|
||||||
|
+#if SDL_VIDEO_OPENGL_EGL
|
||||||
|
device->GL_SwapWindow = Wayland_GLES_SwapWindow;
|
||||||
|
device->GL_GetSwapInterval = Wayland_GLES_GetSwapInterval;
|
||||||
|
device->GL_SetSwapInterval = Wayland_GLES_SetSwapInterval;
|
||||||
|
@@ -240,6 +241,7 @@ Wayland_CreateDevice(int devindex)
|
||||||
|
device->GL_UnloadLibrary = Wayland_GLES_UnloadLibrary;
|
||||||
|
device->GL_GetProcAddress = Wayland_GLES_GetProcAddress;
|
||||||
|
device->GL_DeleteContext = Wayland_GLES_DeleteContext;
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
device->CreateSDLWindow = Wayland_CreateWindow;
|
||||||
|
device->ShowWindow = Wayland_ShowWindow;
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
index a4b5933eb..80bb66878 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
+++ b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
@@ -21,7 +21,7 @@
|
||||||
|
|
||||||
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
|
-#if SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL
|
||||||
|
+#if SDL_VIDEO_DRIVER_WAYLAND
|
||||||
|
|
||||||
|
#include "../SDL_sysvideo.h"
|
||||||
|
#include "../../events/SDL_windowevents_c.h"
|
||||||
|
@@ -1309,12 +1309,14 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
|
||||||
|
data->egl_window = WAYLAND_wl_egl_window_create(data->surface,
|
||||||
|
window->w * data->scale_factor, window->h * data->scale_factor);
|
||||||
|
|
||||||
|
+#if SDL_VIDEO_OPENGL_EGL
|
||||||
|
/* Create the GLES window surface */
|
||||||
|
data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->egl_window);
|
||||||
|
|
||||||
|
if (data->egl_surface == EGL_NO_SURFACE) {
|
||||||
|
return SDL_SetError("failed to create an EGL window surface");
|
||||||
|
}
|
||||||
|
+#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||||
|
@@ -1517,9 +1519,11 @@ void Wayland_DestroyWindow(_THIS, SDL_Window *window)
|
||||||
|
SDL_WindowData *wind = window->driverdata;
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
+#if SDL_VIDEO_OPENGL_EGL
|
||||||
|
if (wind->egl_surface) {
|
||||||
|
SDL_EGL_DestroySurface(_this, wind->egl_surface);
|
||||||
|
}
|
||||||
|
+#endif
|
||||||
|
if (wind->egl_window) {
|
||||||
|
WAYLAND_wl_egl_window_destroy(wind->egl_window);
|
||||||
|
}
|
||||||
|
@@ -1555,6 +1559,6 @@ void Wayland_DestroyWindow(_THIS, SDL_Window *window)
|
||||||
|
window->driverdata = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
-#endif /* SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL */
|
||||||
|
+#endif /* SDL_VIDEO_DRIVER_WAYLAND */
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h
|
||||||
|
index bce1d1855..e8d7d6299 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandwindow.h
|
||||||
|
+++ b/src/video/wayland/SDL_waylandwindow.h
|
||||||
|
@@ -63,7 +63,9 @@ typedef struct {
|
||||||
|
} shell_surface;
|
||||||
|
struct wl_egl_window *egl_window;
|
||||||
|
struct SDL_WaylandInput *keyboard_device;
|
||||||
|
+#if SDL_VIDEO_OPENGL_EGL
|
||||||
|
EGLSurface egl_surface;
|
||||||
|
+#endif
|
||||||
|
struct zwp_locked_pointer_v1 *locked_pointer;
|
||||||
|
struct zwp_confined_pointer_v1 *confined_pointer;
|
||||||
|
struct zxdg_toplevel_decoration_v1 *server_decoration;
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
@ -0,0 +1,54 @@
|
|||||||
|
From e1b4761c621e9883c3f02971ea74cef14b1d6b87 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ethan Lee <flibitijibibo@gmail.com>
|
||||||
|
Date: Thu, 20 Jan 2022 14:10:56 -0500
|
||||||
|
Subject: [PATCH 04/11] wayland: Avoid calling SetFullscreen in libdecor
|
||||||
|
ShowWindow.
|
||||||
|
|
||||||
|
This caused some weird stuff to happen in the libdecor path, probably because
|
||||||
|
the window hasn't actually been mapped yet. It ends up calling stuff that
|
||||||
|
should not yet apply, and so fullscreen in particular would have a really
|
||||||
|
messed up titlebar.
|
||||||
|
|
||||||
|
The good news is, libdecor is good about tracking fullscreen state, so we can
|
||||||
|
let the callback do this for us. Keep this for xdg_shell because we actually
|
||||||
|
map the window ourselves, so we know this call is valid for that path.
|
||||||
|
---
|
||||||
|
src/video/wayland/SDL_waylandwindow.c | 8 ++++++--
|
||||||
|
1 file changed, 6 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
index 80bb66878..3b21af7be 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
+++ b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
@@ -724,7 +724,6 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||||
|
{
|
||||||
|
SDL_VideoData *c = _this->driverdata;
|
||||||
|
SDL_WindowData *data = window->driverdata;
|
||||||
|
- SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||||
|
|
||||||
|
/* Detach any previous buffers before resetting everything, otherwise when
|
||||||
|
* calling this a second time you'll get an annoying protocol error
|
||||||
|
@@ -766,7 +765,6 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||||
|
if (window->flags & SDL_WINDOW_MINIMIZED) {
|
||||||
|
Wayland_MinimizeWindow(_this, window);
|
||||||
|
}
|
||||||
|
- Wayland_SetWindowFullscreen(_this, window, display, (window->flags & SDL_WINDOW_FULLSCREEN) != 0);
|
||||||
|
|
||||||
|
/* We have to wait until the surface gets a "configure" event, or use of
|
||||||
|
* this surface will fail. This is a new rule for xdg_shell.
|
||||||
|
@@ -782,6 +780,12 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
if (c->shell.xdg) {
|
||||||
|
+ /* Unlike libdecor we need to call this explicitly to prevent a deadlock.
|
||||||
|
+ * libdecor will call this as part of their configure event!
|
||||||
|
+ * -flibit
|
||||||
|
+ */
|
||||||
|
+ Wayland_SetWindowFullscreen(_this, window, SDL_GetDisplayForWindow(window),
|
||||||
|
+ (window->flags & SDL_WINDOW_FULLSCREEN) != 0);
|
||||||
|
if (data->shell_surface.xdg.surface) {
|
||||||
|
while (!data->shell_surface.xdg.initial_configure_seen) {
|
||||||
|
WAYLAND_wl_display_flush(c->display);
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
@ -0,0 +1,41 @@
|
|||||||
|
From e2d74bcbe524960c17c852466130a6e0a30674a3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ethan Lee <flibitijibibo@gmail.com>
|
||||||
|
Date: Tue, 25 Jan 2022 11:16:09 -0500
|
||||||
|
Subject: [PATCH 05/11] wayland: Detach hidden surfaces in HideWindow, not
|
||||||
|
ShowWindow
|
||||||
|
|
||||||
|
---
|
||||||
|
src/video/wayland/SDL_waylandwindow.c | 10 ++++------
|
||||||
|
1 file changed, 4 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
index 3b21af7be..2bf500a91 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
+++ b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
@@ -725,12 +725,6 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||||
|
SDL_VideoData *c = _this->driverdata;
|
||||||
|
SDL_WindowData *data = window->driverdata;
|
||||||
|
|
||||||
|
- /* Detach any previous buffers before resetting everything, otherwise when
|
||||||
|
- * calling this a second time you'll get an annoying protocol error
|
||||||
|
- */
|
||||||
|
- wl_surface_attach(data->surface, NULL, 0, 0);
|
||||||
|
- wl_surface_commit(data->surface);
|
||||||
|
-
|
||||||
|
/* Create the shell surface and map the toplevel */
|
||||||
|
#ifdef HAVE_LIBDECOR_H
|
||||||
|
if (c->shell.libdecor) {
|
||||||
|
@@ -862,6 +856,10 @@ void Wayland_HideWindow(_THIS, SDL_Window *window)
|
||||||
|
wind->shell_surface.xdg.surface = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ /* Be sure to detach after this is done, otherwise ShowWindow crashes! */
|
||||||
|
+ wl_surface_attach(wind->surface, NULL, 0, 0);
|
||||||
|
+ wl_surface_commit(wind->surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
28
0006-wayland-Call-SetFullscreen-directly-in-ShowWindow.patch
Normal file
28
0006-wayland-Call-SetFullscreen-directly-in-ShowWindow.patch
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
From f0e768da43173cf62732fc20d1f80eb777d6d5c8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ethan Lee <flibitijibibo@gmail.com>
|
||||||
|
Date: Tue, 25 Jan 2022 13:07:00 -0500
|
||||||
|
Subject: [PATCH 06/11] wayland: Call SetFullscreen directly in ShowWindow.
|
||||||
|
|
||||||
|
This cuts out an extra flush when getting the first configure event.
|
||||||
|
---
|
||||||
|
src/video/wayland/SDL_waylandwindow.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
index 2bf500a91..d4b89de7a 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
+++ b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
@@ -778,8 +778,8 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||||
|
* libdecor will call this as part of their configure event!
|
||||||
|
* -flibit
|
||||||
|
*/
|
||||||
|
- Wayland_SetWindowFullscreen(_this, window, SDL_GetDisplayForWindow(window),
|
||||||
|
- (window->flags & SDL_WINDOW_FULLSCREEN) != 0);
|
||||||
|
+ SDL_WaylandOutputData *odata = SDL_GetDisplayForWindow(window)->driverdata;
|
||||||
|
+ SetFullscreen(window, (window->flags & SDL_WINDOW_FULLSCREEN) ? odata->output : NULL);
|
||||||
|
if (data->shell_surface.xdg.surface) {
|
||||||
|
while (!data->shell_surface.xdg.initial_configure_seen) {
|
||||||
|
WAYLAND_wl_display_flush(c->display);
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
142
0007-wayland-Try-to-avoid-committing-before-the-window-is.patch
Normal file
142
0007-wayland-Try-to-avoid-committing-before-the-window-is.patch
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
From 68a71f91c6cbb1458dc95e2d994d4522afd92c5e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ethan Lee <flibitijibibo@gmail.com>
|
||||||
|
Date: Tue, 25 Jan 2022 11:18:04 -0500
|
||||||
|
Subject: [PATCH 07/11] wayland: Try to avoid committing before the window is
|
||||||
|
shown
|
||||||
|
|
||||||
|
---
|
||||||
|
src/video/wayland/SDL_waylandwindow.c | 32 +++++++++++++++++----------
|
||||||
|
1 file changed, 20 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
index d4b89de7a..4c3c60aac 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
+++ b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
@@ -42,7 +42,7 @@
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
-CommitMinMaxDimensions(SDL_Window *window)
|
||||||
|
+SetMinMaxDimensions(SDL_Window *window, SDL_bool commit)
|
||||||
|
{
|
||||||
|
SDL_WindowData *wind = window->driverdata;
|
||||||
|
SDL_VideoData *viddata = wind->waylandData;
|
||||||
|
@@ -88,12 +88,14 @@ CommitMinMaxDimensions(SDL_Window *window)
|
||||||
|
xdg_toplevel_set_max_size(wind->shell_surface.xdg.roleobj.toplevel,
|
||||||
|
max_width,
|
||||||
|
max_height);
|
||||||
|
- wl_surface_commit(wind->surface);
|
||||||
|
+ if (commit) {
|
||||||
|
+ wl_surface_commit(wind->surface);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
-SetFullscreen(SDL_Window *window, struct wl_output *output)
|
||||||
|
+SetFullscreen(SDL_Window *window, struct wl_output *output, SDL_bool commit)
|
||||||
|
{
|
||||||
|
SDL_WindowData *wind = window->driverdata;
|
||||||
|
SDL_VideoData *viddata = wind->waylandData;
|
||||||
|
@@ -101,7 +103,7 @@ SetFullscreen(SDL_Window *window, struct wl_output *output)
|
||||||
|
/* The desktop may try to enforce min/max sizes here, so turn them off for
|
||||||
|
* fullscreen and on (if applicable) for windowed
|
||||||
|
*/
|
||||||
|
- CommitMinMaxDimensions(window);
|
||||||
|
+ SetMinMaxDimensions(window, SDL_FALSE);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBDECOR_H
|
||||||
|
if (viddata->shell.libdecor) {
|
||||||
|
@@ -134,6 +136,9 @@ SetFullscreen(SDL_Window *window, struct wl_output *output)
|
||||||
|
} else {
|
||||||
|
xdg_toplevel_unset_fullscreen(wind->shell_surface.xdg.roleobj.toplevel);
|
||||||
|
}
|
||||||
|
+ if (commit) {
|
||||||
|
+ wl_surface_commit(wind->surface);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -215,7 +220,7 @@ handle_configure_xdg_toplevel(void *data,
|
||||||
|
if (!fullscreen) {
|
||||||
|
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||||
|
/* We might need to re-enter fullscreen after being restored from minimized */
|
||||||
|
- SetFullscreen(window, driverdata->output);
|
||||||
|
+ SetFullscreen(window, driverdata->output, SDL_FALSE);
|
||||||
|
|
||||||
|
/* Foolishly do what the compositor says here. If it's wrong, don't
|
||||||
|
* blame us, we were explicitly instructed to do this.
|
||||||
|
@@ -364,7 +369,7 @@ decoration_frame_configure(struct libdecor_frame *frame,
|
||||||
|
if (!fullscreen) {
|
||||||
|
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||||
|
/* We might need to re-enter fullscreen after being restored from minimized */
|
||||||
|
- SetFullscreen(window, driverdata->output);
|
||||||
|
+ SetFullscreen(window, driverdata->output, SDL_FALSE);
|
||||||
|
fullscreen = SDL_TRUE;
|
||||||
|
floating = SDL_FALSE;
|
||||||
|
}
|
||||||
|
@@ -779,7 +784,7 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||||
|
* -flibit
|
||||||
|
*/
|
||||||
|
SDL_WaylandOutputData *odata = SDL_GetDisplayForWindow(window)->driverdata;
|
||||||
|
- SetFullscreen(window, (window->flags & SDL_WINDOW_FULLSCREEN) ? odata->output : NULL);
|
||||||
|
+ SetFullscreen(window, (window->flags & SDL_WINDOW_FULLSCREEN) ? odata->output : NULL, SDL_TRUE);
|
||||||
|
if (data->shell_surface.xdg.surface) {
|
||||||
|
while (!data->shell_surface.xdg.initial_configure_seen) {
|
||||||
|
WAYLAND_wl_display_flush(c->display);
|
||||||
|
@@ -791,6 +796,9 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||||
|
if (data->shell_surface.xdg.roleobj.toplevel && c->decoration_manager) {
|
||||||
|
data->server_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(c->decoration_manager, data->shell_surface.xdg.roleobj.toplevel);
|
||||||
|
}
|
||||||
|
+ } else {
|
||||||
|
+ /* Nothing to see here, just commit. */
|
||||||
|
+ wl_surface_commit(data->surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlike the rest of window state we have to set this _after_ flushing the
|
||||||
|
@@ -1053,7 +1061,7 @@ Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
|
||||||
|
{
|
||||||
|
struct wl_output *output = ((SDL_WaylandOutputData*) _display->driverdata)->output;
|
||||||
|
SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata;
|
||||||
|
- SetFullscreen(window, fullscreen ? output : NULL);
|
||||||
|
+ SetFullscreen(window, fullscreen ? output : NULL, SDL_TRUE);
|
||||||
|
|
||||||
|
WAYLAND_wl_display_flush(viddata->display);
|
||||||
|
}
|
||||||
|
@@ -1125,7 +1133,7 @@ Wayland_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
- CommitMinMaxDimensions(window);
|
||||||
|
+ SetMinMaxDimensions(window, SDL_TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1338,7 +1346,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
|
||||||
|
Wayland_input_lock_pointer(c->input);
|
||||||
|
}
|
||||||
|
|
||||||
|
- wl_surface_commit(data->surface);
|
||||||
|
+ /* Moved this call to ShowWindow: wl_surface_commit(data->surface); */
|
||||||
|
WAYLAND_wl_display_flush(c->display);
|
||||||
|
|
||||||
|
/* We may need to create an idle inhibitor for this new window */
|
||||||
|
@@ -1393,13 +1401,13 @@ Wayland_HandleResize(SDL_Window *window, int width, int height, float scale)
|
||||||
|
void
|
||||||
|
Wayland_SetWindowMinimumSize(_THIS, SDL_Window * window)
|
||||||
|
{
|
||||||
|
- CommitMinMaxDimensions(window);
|
||||||
|
+ SetMinMaxDimensions(window, SDL_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Wayland_SetWindowMaximumSize(_THIS, SDL_Window * window)
|
||||||
|
{
|
||||||
|
- CommitMinMaxDimensions(window);
|
||||||
|
+ SetMinMaxDimensions(window, SDL_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Wayland_SetWindowSize(_THIS, SDL_Window * window)
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
@ -0,0 +1,57 @@
|
|||||||
|
From 77a9ca6ba0ae1973d7bc255a4d785e7f1ba3d111 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Cameron Gutman <aicommander@gmail.com>
|
||||||
|
Date: Wed, 26 Jan 2022 18:26:07 -0600
|
||||||
|
Subject: [PATCH 08/11] wayland: Fix SDL_SetWindowSize() being dropped right
|
||||||
|
after exiting fullscreen
|
||||||
|
|
||||||
|
If we get a SDL_SetWindowSize() call right after SDL_SetWindowFullscreen() but
|
||||||
|
before we've gotten a new configure event from the compositor, the attempt to
|
||||||
|
set our window size will silently fail (when libdecor is enabled).
|
||||||
|
|
||||||
|
Fix this by remembering that we need to commit a new size, so we can do that
|
||||||
|
in decoration_frame_configure().
|
||||||
|
---
|
||||||
|
src/video/wayland/SDL_waylandwindow.c | 5 ++++-
|
||||||
|
src/video/wayland/SDL_waylandwindow.h | 1 +
|
||||||
|
2 files changed, 5 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
index 4c3c60aac..635546af4 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
+++ b/src/video/wayland/SDL_waylandwindow.c
|
||||||
|
@@ -414,9 +414,10 @@ decoration_frame_configure(struct libdecor_frame *frame,
|
||||||
|
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||||
|
scale_factor = driverdata->scale_factor;
|
||||||
|
}
|
||||||
|
- } else if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
|
||||||
|
+ } else if (!(window->flags & SDL_WINDOW_RESIZABLE) || (floating && wind->floating_resize_pending)) {
|
||||||
|
width = window->windowed.w;
|
||||||
|
height = window->windowed.h;
|
||||||
|
+ wind->floating_resize_pending = SDL_FALSE;
|
||||||
|
} else {
|
||||||
|
/* This will never set 0 for width/height unless the function returns false */
|
||||||
|
if (!libdecor_configuration_get_content_size(configuration, frame, &width, &height)) {
|
||||||
|
@@ -1424,6 +1425,8 @@ void Wayland_SetWindowSize(_THIS, SDL_Window * window)
|
||||||
|
if (data->shell.libdecor &&
|
||||||
|
wind->shell_surface.libdecor.frame &&
|
||||||
|
!libdecor_frame_is_floating(wind->shell_surface.libdecor.frame)) {
|
||||||
|
+ /* Commit the resize when we re-enter floating state */
|
||||||
|
+ wind->floating_resize_pending = SDL_TRUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h
|
||||||
|
index e8d7d6299..90e4d8cf6 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandwindow.h
|
||||||
|
+++ b/src/video/wayland/SDL_waylandwindow.h
|
||||||
|
@@ -87,6 +87,7 @@ typedef struct {
|
||||||
|
|
||||||
|
float scale_factor;
|
||||||
|
SDL_bool needs_resize_event;
|
||||||
|
+ SDL_bool floating_resize_pending;
|
||||||
|
} SDL_WindowData;
|
||||||
|
|
||||||
|
extern void Wayland_ShowWindow(_THIS, SDL_Window *window);
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
@ -0,0 +1,36 @@
|
|||||||
|
From cc40f732f9482eb45a1938a23d4f34265e78a729 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Cameron Gutman <aicommander@gmail.com>
|
||||||
|
Date: Wed, 26 Jan 2022 21:09:39 -0600
|
||||||
|
Subject: [PATCH 09/11] wayland: Round the refresh rate rather than truncating
|
||||||
|
it
|
||||||
|
|
||||||
|
A 59999 mHz monitor should be reported as 60 Hz, not 59 Hz.
|
||||||
|
---
|
||||||
|
src/video/wayland/SDL_waylandvideo.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
|
||||||
|
index 60d7403c7..61940cca4 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandvideo.c
|
||||||
|
+++ b/src/video/wayland/SDL_waylandvideo.c
|
||||||
|
@@ -393,7 +393,7 @@ display_handle_mode(void *data,
|
||||||
|
mode.w = width;
|
||||||
|
mode.h = height;
|
||||||
|
}
|
||||||
|
- mode.refresh_rate = refresh / 1000; /* mHz to Hz */
|
||||||
|
+ mode.refresh_rate = (int)SDL_round(refresh / 1000.0); /* mHz to Hz */
|
||||||
|
mode.driverdata = driverdata->output;
|
||||||
|
if (driverdata->index > -1) {
|
||||||
|
SDL_AddDisplayMode(SDL_GetDisplay(driverdata->index), &mode);
|
||||||
|
@@ -446,7 +446,7 @@ display_handle_done(void *data,
|
||||||
|
((float) driverdata->physical_width) / 25.4f,
|
||||||
|
((float) driverdata->physical_height) / 25.4f);
|
||||||
|
}
|
||||||
|
- mode.refresh_rate = driverdata->refresh / 1000; /* mHz to Hz */
|
||||||
|
+ mode.refresh_rate = (int)SDL_round(driverdata->refresh / 1000.0); /* mHz to Hz */
|
||||||
|
mode.driverdata = driverdata->output;
|
||||||
|
|
||||||
|
if (driverdata->index > -1) {
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
54
0010-Fix-text_input_v3-preedit-string.patch
Normal file
54
0010-Fix-text_input_v3-preedit-string.patch
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
From a90a2e7582a73f7b69b14437287aa15945bf5989 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Weng Xuetian <wengxt@gmail.com>
|
||||||
|
Date: Sun, 30 Jan 2022 16:44:44 -0800
|
||||||
|
Subject: [PATCH 10/11] Fix text_input_v3 preedit string
|
||||||
|
|
||||||
|
For every batch of text_input_v3 updates, if there is no preedit in this
|
||||||
|
batch, preedit should be cleared.
|
||||||
|
---
|
||||||
|
src/video/wayland/SDL_waylandevents.c | 8 +++++++-
|
||||||
|
src/video/wayland/SDL_waylandkeyboard.h | 1 +
|
||||||
|
2 files changed, 8 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
|
||||||
|
index bf2aeea5b..85d4edfc8 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandevents.c
|
||||||
|
+++ b/src/video/wayland/SDL_waylandevents.c
|
||||||
|
@@ -1505,7 +1505,9 @@ text_input_preedit_string(void *data,
|
||||||
|
int32_t cursor_begin,
|
||||||
|
int32_t cursor_end)
|
||||||
|
{
|
||||||
|
+ SDL_WaylandTextInput *text_input = data;
|
||||||
|
char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
|
||||||
|
+ text_input->has_preedit = SDL_TRUE;
|
||||||
|
if (text) {
|
||||||
|
size_t text_bytes = SDL_strlen(text), i = 0;
|
||||||
|
size_t cursor = 0;
|
||||||
|
@@ -1557,7 +1559,11 @@ text_input_done(void *data,
|
||||||
|
struct zwp_text_input_v3 *zwp_text_input_v3,
|
||||||
|
uint32_t serial)
|
||||||
|
{
|
||||||
|
- /* No-op */
|
||||||
|
+ SDL_WaylandTextInput *text_input = data;
|
||||||
|
+ if (!text_input->has_preedit) {
|
||||||
|
+ SDL_SendEditingText("", 0, 0);
|
||||||
|
+ }
|
||||||
|
+ text_input->has_preedit = SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct zwp_text_input_v3_listener text_input_listener = {
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandkeyboard.h b/src/video/wayland/SDL_waylandkeyboard.h
|
||||||
|
index dd8c146e6..604e0f37f 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandkeyboard.h
|
||||||
|
+++ b/src/video/wayland/SDL_waylandkeyboard.h
|
||||||
|
@@ -27,6 +27,7 @@ typedef struct SDL_WaylandTextInput
|
||||||
|
{
|
||||||
|
struct zwp_text_input_v3 *text_input;
|
||||||
|
SDL_Rect cursor_rect;
|
||||||
|
+ SDL_bool has_preedit;
|
||||||
|
} SDL_WaylandTextInput;
|
||||||
|
|
||||||
|
extern int Wayland_InitKeyboard(_THIS);
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
@ -0,0 +1,42 @@
|
|||||||
|
From b11dfd761181ab5005fe3f5527faa4faf6b56112 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Weng Xuetian <wengxt@gmail.com>
|
||||||
|
Date: Tue, 1 Feb 2022 14:43:26 -0800
|
||||||
|
Subject: [PATCH 11/11] Only generate key repetition for keys that should
|
||||||
|
repeat on wayland.
|
||||||
|
|
||||||
|
This fix repetition on modifier keys, e.g. Control.
|
||||||
|
---
|
||||||
|
src/video/wayland/SDL_waylandevents.c | 4 +++-
|
||||||
|
src/video/wayland/SDL_waylandsym.h | 1 +
|
||||||
|
2 files changed, 4 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
|
||||||
|
index 85d4edfc8..55893201b 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandevents.c
|
||||||
|
+++ b/src/video/wayland/SDL_waylandevents.c
|
||||||
|
@@ -987,7 +987,9 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
|
||||||
|
SDL_SendKeyboardText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- keyboard_repeat_set(&input->keyboard_repeat, time, scancode, has_text, text);
|
||||||
|
+ if (input->xkb.keymap && WAYLAND_xkb_keymap_key_repeats(input->xkb.keymap, key + 8)) {
|
||||||
|
+ keyboard_repeat_set(&input->keyboard_repeat, time, scancode, has_text, text);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/video/wayland/SDL_waylandsym.h b/src/video/wayland/SDL_waylandsym.h
|
||||||
|
index 366ce9e94..fa29bedb1 100644
|
||||||
|
--- a/src/video/wayland/SDL_waylandsym.h
|
||||||
|
+++ b/src/video/wayland/SDL_waylandsym.h
|
||||||
|
@@ -122,6 +122,7 @@ SDL_WAYLAND_SYM(int, xkb_state_key_get_syms, (struct xkb_state *, xkb_keycode_t,
|
||||||
|
SDL_WAYLAND_SYM(int, xkb_keysym_to_utf8, (xkb_keysym_t, char *, size_t) )
|
||||||
|
SDL_WAYLAND_SYM(struct xkb_keymap *, xkb_keymap_new_from_string, (struct xkb_context *, const char *, enum xkb_keymap_format, enum xkb_keymap_compile_flags))
|
||||||
|
SDL_WAYLAND_SYM(struct xkb_state *, xkb_state_new, (struct xkb_keymap *) )
|
||||||
|
+SDL_WAYLAND_SYM(int, xkb_keymap_key_repeats, (struct xkb_keymap *keymap, xkb_keycode_t key) );
|
||||||
|
SDL_WAYLAND_SYM(void, xkb_keymap_unref, (struct xkb_keymap *) )
|
||||||
|
SDL_WAYLAND_SYM(void, xkb_state_unref, (struct xkb_state *) )
|
||||||
|
SDL_WAYLAND_SYM(void, xkb_context_unref, (struct xkb_context *) )
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
23
SDL2.spec
23
SDL2.spec
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
Name: SDL2
|
Name: SDL2
|
||||||
Version: 2.0.20
|
Version: 2.0.20
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
Summary: Cross-platform multimedia library
|
Summary: Cross-platform multimedia library
|
||||||
License: zlib and MIT
|
License: zlib and MIT
|
||||||
URL: http://www.libsdl.org/
|
URL: http://www.libsdl.org/
|
||||||
@ -22,6 +22,23 @@ Patch0: multilib.patch
|
|||||||
# ptrdiff_t is not the same as khronos defines on 32bit arches
|
# ptrdiff_t is not the same as khronos defines on 32bit arches
|
||||||
Patch1: SDL2-2.0.9-khrplatform.patch
|
Patch1: SDL2-2.0.9-khrplatform.patch
|
||||||
|
|
||||||
|
# Wayland backports
|
||||||
|
# From git format-patch release-2.0.20..68dd84f1de159b2e6ae1d5a23f842ee87f8a175a src/video/wayland/
|
||||||
|
Patch0101: 0001-wayland-Convert-URI-to-local-path-for-DropFile.patch
|
||||||
|
Patch0102: 0002-wayland-Avoid-spurious-resize-events.patch
|
||||||
|
Patch0103: 0003-wayland-Fix-building-with-SDL_OPENGL-OFF.patch
|
||||||
|
Patch0104: 0004-wayland-Avoid-calling-SetFullscreen-in-libdecor-Show.patch
|
||||||
|
Patch0105: 0005-wayland-Detach-hidden-surfaces-in-HideWindow-not-Sho.patch
|
||||||
|
Patch0106: 0006-wayland-Call-SetFullscreen-directly-in-ShowWindow.patch
|
||||||
|
Patch0107: 0007-wayland-Try-to-avoid-committing-before-the-window-is.patch
|
||||||
|
Patch0108: 0008-wayland-Fix-SDL_SetWindowSize-being-dropped-right-af.patch
|
||||||
|
Patch0109: 0009-wayland-Round-the-refresh-rate-rather-than-truncatin.patch
|
||||||
|
Patch0110: 0010-Fix-text_input_v3-preedit-string.patch
|
||||||
|
Patch0111: 0011-Only-generate-key-repetition-for-keys-that-should-re.patch
|
||||||
|
|
||||||
|
# From: https://github.com/libsdl-org/SDL/commit/8ceba27d6291f1195e13608033ec439aec621fc6
|
||||||
|
Patch0199: 0001-video-Prefer-Wayland-over-X11.patch
|
||||||
|
|
||||||
BuildRequires: git-core
|
BuildRequires: git-core
|
||||||
BuildRequires: cmake
|
BuildRequires: cmake
|
||||||
BuildRequires: make
|
BuildRequires: make
|
||||||
@ -167,6 +184,10 @@ install -p -m 644 %{SOURCE2} %{buildroot}%{_includedir}/SDL2/SDL_revision.h
|
|||||||
%{_libdir}/cmake/SDL2/SDL2staticTargets*.cmake
|
%{_libdir}/cmake/SDL2/SDL2staticTargets*.cmake
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Feb 08 2022 Neal Gompa <ngompa@centosproject.org> - 2.0.20-2
|
||||||
|
- Backport Wayland fixes with Wayland-by-default from upstream
|
||||||
|
Resolves: rhbz#2051963
|
||||||
|
|
||||||
* Tue Jan 11 2022 Neal Gompa <ngompa@centosproject.org> - 2.0.20-1
|
* Tue Jan 11 2022 Neal Gompa <ngompa@centosproject.org> - 2.0.20-1
|
||||||
- Update to 2.0.20
|
- Update to 2.0.20
|
||||||
Resolves: rhbz#2039137
|
Resolves: rhbz#2039137
|
||||||
|
Loading…
Reference in New Issue
Block a user