Create wl_resource with minimum version 92/283592/2
authorSeunghun Lee <shiin.lee@samsung.com>
Mon, 24 Oct 2022 01:41:57 +0000 (10:41 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 31 Oct 2022 05:05:49 +0000 (05:05 +0000)
The version of wl_resource has to be the minimum among the versions for
which both compositor and client support.

Change-Id: I16e310e8f5aaec570b1dc1a956b05fd115facd58

src/compositor.c
src/data_device/manager.c
src/output.c
src/presentation.c
src/seat/seat.c
src/shell.c
src/subcompositor.c
src/xdg_shell/xdg_shell.c
src/xdg_shell_v6/xdg_shell_v6.c

index 64b9a99..4b90405 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "libds/log.h"
 
+#include "util.h"
 #include "subcompositor.h"
 #include "surface.h"
 #include "region.h"
@@ -120,7 +121,7 @@ static void compositor_bind(struct wl_client *client, void *data,
     struct wl_resource *resource;
 
     resource = wl_resource_create(client, &wl_compositor_interface,
-            version, id);
+            DS_MIN((int)version, COMPOSITOR_VERSION), id);
     if (resource == NULL) {
         wl_client_post_no_memory(client);
         return;
index 79ccc7f..b30d33e 100644 (file)
@@ -2,6 +2,7 @@
 #include <wayland-server.h>
 
 #include "libds/log.h"
+#include "util.h"
 #include "data_device_private.h"
 
 #define DATA_DEVICE_MANAGER_VERSION 3
@@ -102,7 +103,7 @@ data_device_manager_bind(struct wl_client *client, void *data,
     struct wl_resource *resource;
 
     resource = wl_resource_create(client, &wl_data_device_manager_interface,
-            version, id);
+            DS_MIN((int)version, DATA_DEVICE_MANAGER_VERSION), id);
     if (!resource) {
         wl_client_post_no_memory(client);
         return;
index de48b37..8876a3d 100644 (file)
@@ -345,7 +345,8 @@ output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
     struct ds_output *output = data;
     struct wl_resource *resource;
 
-    resource = wl_resource_create(client, &wl_output_interface, version, id);
+    resource = wl_resource_create(client, &wl_output_interface,
+            DS_MIN((int)version, OUTPUT_VERSION), id);
     if (!resource) {
         wl_client_post_no_memory(client);
         return;
index 54d10d9..0e0580e 100644 (file)
@@ -91,7 +91,7 @@ presentation_bind(struct wl_client *client, void *data,
     struct wl_resource *resource;
 
     resource = wl_resource_create(client, &wp_presentation_interface,
-            version, id);
+            DS_MIN((int)version, PRESENTATION_VERSION), id);
     if (!resource) {
         wl_client_post_no_memory(client);
         return;
index ca9c2e9..58ac3ec 100644 (file)
@@ -400,7 +400,8 @@ seat_handle_bind(struct wl_client *wl_client, void *data, uint32_t version,
     struct ds_seat_client *seat_client;
     struct wl_resource *resource;
 
-    resource = wl_resource_create(wl_client, &wl_seat_interface, version, id);
+    resource = wl_resource_create(wl_client, &wl_seat_interface,
+            DS_MIN((int)version, SEAT_VERSION), id);
     if (!resource) {
         wl_client_post_no_memory(wl_client);
         return;
index e9b42b4..a757233 100644 (file)
@@ -5,6 +5,7 @@
 #include "libds/log.h"
 #include "libds/shell.h"
 
+#include "util.h"
 #include "shell.h"
 
 #define WL_SHELL_VERSION 1
@@ -158,8 +159,8 @@ shell_bind(struct wl_client *wl_client, void *data, uint32_t version,
 
     wl_list_init(&client->shell_surfaces);
 
-    client->resource =
-        wl_resource_create(wl_client, &wl_shell_interface, version, id);
+    client->resource = wl_resource_create(wl_client, &wl_shell_interface,
+            DS_MIN((int)version, WL_SHELL_VERSION), id);
     if (client->resource == NULL) {
         free(client);
         wl_client_post_no_memory(wl_client);
index 9e821b3..077a715 100644 (file)
@@ -1,5 +1,6 @@
 #include "libds/log.h"
 
+#include "util.h"
 #include "subcompositor.h"
 #include "surface.h"
 
@@ -90,7 +91,8 @@ subcompositor_bind(struct wl_client *client, void *data,
     struct ds_subcompositor *subcomp = data;
     struct wl_resource *resource;
 
-    resource = wl_resource_create(client, &wl_subcompositor_interface, 1, id);
+    resource = wl_resource_create(client, &wl_subcompositor_interface,
+            DS_MIN((int)version, SUBCOMPOSITOR_VERSION), id);
     if (resource == NULL) {
         wl_client_post_no_memory(client);
         return;
index 57096ea..3d48efb 100644 (file)
@@ -5,6 +5,7 @@
 #include "libds/log.h"
 #include "libds/xdg_shell.h"
 
+#include "util.h"
 #include "xdg_shell.h"
 
 #define XDG_WM_BASE_VERSION 2
@@ -200,8 +201,8 @@ xdg_shell_bind(struct wl_client *wl_client, void *data, uint32_t version,
 
     wl_list_init(&client->surfaces);
 
-    client->resource =
-        wl_resource_create(wl_client, &xdg_wm_base_interface, version, id);
+    client->resource = wl_resource_create(wl_client, &xdg_wm_base_interface,
+            DS_MIN((int)version, XDG_WM_BASE_VERSION), id);
     if (client->resource == NULL) {
         free(client);
         wl_client_post_no_memory(wl_client);
index af8b81c..0f94fae 100644 (file)
@@ -5,6 +5,7 @@
 #include "libds/log.h"
 #include "libds/xdg_shell_v6.h"
 
+#include "util.h"
 #include "xdg_shell_v6.h"
 
 #define XDG_SHELL_V6_BASE_VERSION 1
@@ -200,8 +201,8 @@ xdg_shell_v6_bind(struct wl_client *wl_client, void *data, uint32_t version,
 
     wl_list_init(&client->surfaces);
 
-    client->resource =
-        wl_resource_create(wl_client, &zxdg_shell_v6_interface, version, id);
+    client->resource = wl_resource_create(wl_client, &zxdg_shell_v6_interface,
+            DS_MIN((int)version, XDG_SHELL_V6_BASE_VERSION), id);
     if (client->resource == NULL) {
         free(client);
         wl_client_post_no_memory(wl_client);