فهرست منبع

wayland: Use xdg-output to get connector names when older versions of libwayland are in use

Connector names prior to v4 were sent via xdg-output, so use that if an older version of libwayland is present.

Additionally, ensure the output names are actually allocated before comparing the strings.
Frank Praznik 1 سال پیش
والد
کامیت
f6edc2f603
1فایلهای تغییر یافته به همراه15 افزوده شده و 6 حذف شده
  1. 15 6
      src/video/wayland/SDL_waylandvideo.c

+ 15 - 6
src/video/wayland/SDL_waylandvideo.c

@@ -255,12 +255,14 @@ static void Wayland_SortOutputs(SDL_VideoData *vid)
         /* Sort the outputs by connector name. */
         WAYLAND_wl_list_init(&sorted_list);
         wl_list_for_each (c, &vid->output_order, link) {
-            wl_list_for_each (d, &vid->output_list, link) {
-                if (SDL_strcmp(c->wl_output_name, d->wl_output_name) == 0) {
-                    /* Remove from the current list and Append the next node to the end of the new list. */
-                    WAYLAND_wl_list_remove(&d->link);
-                    WAYLAND_wl_list_insert(sorted_list.prev, &d->link);
-                    break;
+            if (c->wl_output_name) {
+                wl_list_for_each (d, &vid->output_list, link) {
+                    if (d->wl_output_name && SDL_strcmp(c->wl_output_name, d->wl_output_name) == 0) {
+                        /* Remove from the current list and Append the next node to the end of the new list. */
+                        WAYLAND_wl_list_remove(&d->link);
+                        WAYLAND_wl_list_insert(sorted_list.prev, &d->link);
+                        break;
+                    }
                 }
             }
         }
@@ -565,7 +567,14 @@ static void xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output
 static void xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output,
                                    const char *name)
 {
+    SDL_DisplayData *driverdata = (SDL_DisplayData *)data;
+
     /* Deprecated as of wl_output v4. */
+    if (wl_output_get_version(driverdata->output) < WL_OUTPUT_NAME_SINCE_VERSION &&
+        driverdata->display == 0) {
+        SDL_free(driverdata->wl_output_name);
+        driverdata->wl_output_name = SDL_strdup(name);
+    }
 }
 
 static void xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output,