This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch up/7-output
in repository enlightenment.

View the commit online.

commit 8ae5d6d39815559a9ce7ba2cd8dcc65cb60a9052
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 22 16:18:45 2026 -0600

    e_comp_wl - raise wl_output to version 4
    
    Firefox skips its wl_output bind below version 3 rather than clamping,
    so against E it has no monitor list at all: no DPI and no per-monitor
    surface tracking. Chromium binds up to 4 and uses the name.
    
    Version 3 adds release, version 4 adds name and description. The
    protocol allows the name once per object, and a monitor change sends
    the rest of the state again, so name and description only go out on
    bind.
    
    A randr id is "<connector>/<edid>". The name is the connector part,
    which is what people know the output by. Backends without randr pass
    no id and get the WL-n form other compositors use.
    
    E never destroys the global of an output that is disabled, so a monitor
    disabled and enabled again is advertised twice, now under one name.
    That is an existing problem with the output's lifetime and is left to
    its own change.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/bin/e_comp_wl.c                | 110 ++++++++++++++-------
 src/bin/e_comp_wl.h                |   1 +
 src/tests/wayland/globals.expected |   2 +-
 src/tests/wayland/meson.build      |   1 +
 src/tests/wayland/test_output.c    | 196 +++++++++++++++++++++++++++++++++++++
 5 files changed, 274 insertions(+), 36 deletions(-)

diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
index a512cb75e..65b5eff91 100644
--- a/src/bin/e_comp_wl.c
+++ b/src/bin/e_comp_wl.c
@@ -3197,6 +3197,37 @@ _e_comp_wl_cb_output_unbind(struct wl_resource *resource)
    output->resources = eina_list_remove(output->resources, resource);
 }
 
+static void
+_e_comp_wl_output_cb_release(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
+{
+   wl_resource_destroy(resource);
+}
+
+static const struct wl_output_interface _e_comp_wl_output_interface =
+{
+   _e_comp_wl_output_cb_release
+};
+
+static void
+_e_comp_wl_output_state_send(E_Comp_Wl_Output *output, struct wl_resource *resource)
+{
+   uint32_t version = wl_resource_get_version(resource);
+
+   wl_output_send_geometry(resource, output->x, output->y,
+                           output->phys_width, output->phys_height,
+                           output->subpixel, output->make ?: "",
+                           output->model ?: "", output->transform);
+
+   if (version >= WL_OUTPUT_SCALE_SINCE_VERSION)
+     wl_output_send_scale(resource, output->scale);
+
+   /* 3 == preferred + current */
+   wl_output_send_mode(resource, 3, output->w, output->h, output->refresh);
+
+   if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
+     wl_output_send_done(resource);
+}
+
 static void
 _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
 {
@@ -3218,23 +3249,17 @@ _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version
 
    output->resources = eina_list_append(output->resources, resource);
 
-   wl_resource_set_implementation(resource, NULL, output,
-                                  _e_comp_wl_cb_output_unbind);
-   wl_resource_set_user_data(resource, output);
+   wl_resource_set_implementation(resource, &_e_comp_wl_output_interface,
+                                  output, _e_comp_wl_cb_output_unbind);
 
-   wl_output_send_geometry(resource, output->x, output->y,
-                           output->phys_width, output->phys_height,
-                           output->subpixel, output->make ?: "",
-                           output->model ?: "", output->transform);
-
-   if (version >= WL_OUTPUT_SCALE_SINCE_VERSION)
-     wl_output_send_scale(resource, output->scale);
-
-   /* 3 == preferred + current */
-   wl_output_send_mode(resource, 3, output->w, output->h, output->refresh);
-
-   if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
-     wl_output_send_done(resource);
+   /* wl_output.name goes out once per object, so never from the state
+    * that a reconfigure sends again. */
+   if (version >= WL_OUTPUT_NAME_SINCE_VERSION)
+     {
+        wl_output_send_name(resource, output->name);
+        wl_output_send_description(resource, output->description);
+     }
+   _e_comp_wl_output_state_send(output, resource);
 }
 
 static Eina_Bool
@@ -3548,6 +3573,8 @@ e_comp_wl_shutdown(void)
         if (output->id) eina_stringshare_del(output->id);
         if (output->make) eina_stringshare_del(output->make);
         if (output->model) eina_stringshare_del(output->model);
+        eina_stringshare_del(output->name);
+        eina_stringshare_del(output->description);
         free(output);
      }
 
@@ -3744,6 +3771,34 @@ _e_comp_wl_output_get(Eina_List *outputs, const char *id)
    return NULL;
 }
 
+/* wl_output.name is unique among outputs. A randr id is
+ * "<connector>/<edid>", and only the connector is what a user knows the
+ * output by. Backends with no randr pass no id. */
+static const char *
+_e_comp_wl_output_name_new(const char *id)
+{
+   static unsigned int unnamed = 0;
+   const char *slash;
+   char buf[32];
+
+   if (!id)
+     {
+        snprintf(buf, sizeof(buf), "WL-%u", ++unnamed);
+        return eina_stringshare_add(buf);
+     }
+   slash = strchr(id, '/');
+   if (slash) return eina_stringshare_add_length(id, slash - id);
+   return eina_stringshare_add(id);
+}
+
+static const char *
+_e_comp_wl_output_description_new(const E_Comp_Wl_Output *output)
+{
+   if (output->make && output->model)
+     return eina_stringshare_printf("%s %s", output->make, output->model);
+   return eina_stringshare_add(output->model ?: output->name);
+}
+
 /**
  * Initializes information about one display output.
  *
@@ -3790,12 +3845,14 @@ e_comp_wl_output_init(const char *id, const char *make, const char *model,
         if (id) output->id = eina_stringshare_add(id);
         if (make) output->make = eina_stringshare_add(make);
         if (model) output->model = eina_stringshare_add(model);
+        output->name = _e_comp_wl_output_name_new(id);
+        output->description = _e_comp_wl_output_description_new(output);
 
         e_comp_wl->outputs = eina_list_append(e_comp_wl->outputs, output);
 
         output->global =
           wl_global_create(e_comp_wl->wl.disp, &wl_output_interface,
-                           2, output, _e_comp_wl_cb_output_bind);
+                           4, output, _e_comp_wl_cb_output_bind);
 
         output->resources = NULL;
         /* Not e_scale: wl_surface.set_buffer_scale is not honoured, so a
@@ -3822,24 +3879,7 @@ e_comp_wl_output_init(const char *id, const char *make, const char *model,
 
    /* if we have bound resources, send updates */
    EINA_LIST_FOREACH(output->resources, l2, resource)
-     {
-        wl_output_send_geometry(resource,
-                                output->x, output->y,
-                                output->phys_width,
-                                output->phys_height,
-                                output->subpixel,
-                                output->make ?: "", output->model ?: "",
-                                output->transform);
-
-        if (wl_resource_get_version(resource) >= WL_OUTPUT_SCALE_SINCE_VERSION)
-          wl_output_send_scale(resource, output->scale);
-
-        /* 3 == preferred + current */
-        wl_output_send_mode(resource, 3, output->w, output->h, output->refresh);
-
-        if (wl_resource_get_version(resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
-          wl_output_send_done(resource);
-     }
+     _e_comp_wl_output_state_send(output, resource);
 
    return EINA_TRUE;
 }
diff --git a/src/bin/e_comp_wl.h b/src/bin/e_comp_wl.h
index 8a5b515d5..09a552da4 100644
--- a/src/bin/e_comp_wl.h
+++ b/src/bin/e_comp_wl.h
@@ -390,6 +390,7 @@ struct _E_Comp_Wl_Output
    struct wl_global *global;
    Eina_List *resources;
    const char *id, *make, *model;
+   const char *name, *description;
    int x, y, w, h;
    int phys_width, phys_height;
    unsigned int refresh;
diff --git a/src/tests/wayland/globals.expected b/src/tests/wayland/globals.expected
index c8c2a4b64..624f9f417 100644
--- a/src/tests/wayland/globals.expected
+++ b/src/tests/wayland/globals.expected
@@ -2,7 +2,7 @@ action_route	1
 efl_aux_hints	1
 wl_compositor	4
 wl_data_device_manager	3
-wl_output	2
+wl_output	4
 wl_seat	8
 wl_shell	1
 wl_shm	>=1
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index 3c28733fa..bec2e287b 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -70,6 +70,7 @@ wl_protocol_tests = [
   ['maximize-restore', 'test_maximize_restore.c'],
   ['xdg-decoration', 'test_xdg_decoration.c'],
   ['shm-truncate', 'test_shm_truncate.c'],
+  ['output', 'test_output.c'],
   ['client-iconify', 'test_client_iconify.c',
    {'ELM_TRANSITION_DURATION_FACTOR': '4'}],
 ]
diff --git a/src/tests/wayland/test_output.c b/src/tests/wayland/test_output.c
new file mode 100644
index 000000000..cc0d18977
--- /dev/null
+++ b/src/tests/wayland/test_output.c
@@ -0,0 +1,196 @@
+/* What a client is told about an output: when it binds, and when the output
+ * changes after that. */
+#include <stdio.h>
+#include <string.h>
+#include "e_wl_testkit.h"
+
+#define MAX_OUTPUTS 4
+
+typedef struct
+{
+   struct wl_output *output;
+   uint32_t global;
+   char name[64];
+   char description[128];
+   int x, y, w, h;
+   int names, descriptions, dones;
+   int name_after_done, description_after_done;
+} Output;
+
+static Tk *tk;
+static Output outputs[MAX_OUTPUTS];
+static int output_count = 0;
+static Output old_client;
+
+static void
+_geometry(void *data, struct wl_output *o __attribute__((unused)), int32_t x, int32_t y,
+          int32_t pw __attribute__((unused)), int32_t ph __attribute__((unused)),
+          int32_t subpixel __attribute__((unused)), const char *make __attribute__((unused)),
+          const char *model __attribute__((unused)), int32_t transform __attribute__((unused)))
+{
+   Output *out = data;
+
+   out->x = x;
+   out->y = y;
+}
+
+static void
+_mode(void *data, struct wl_output *o __attribute__((unused)),
+      uint32_t flags __attribute__((unused)), int32_t w, int32_t h,
+      int32_t refresh __attribute__((unused)))
+{
+   Output *out = data;
+
+   out->w = w;
+   out->h = h;
+}
+
+static void
+_done(void *data, struct wl_output *o __attribute__((unused)))
+{
+   Output *out = data;
+
+   out->dones++;
+}
+
+static void
+_scale(void *data __attribute__((unused)), struct wl_output *o __attribute__((unused)),
+       int32_t factor __attribute__((unused)))
+{
+}
+
+static void
+_name(void *data, struct wl_output *o __attribute__((unused)), const char *name)
+{
+   Output *out = data;
+
+   snprintf(out->name, sizeof(out->name), "%s", name);
+   out->names++;
+   if (out->dones) out->name_after_done = 1;
+}
+
+static void
+_description(void *data, struct wl_output *o __attribute__((unused)), const char *description)
+{
+   Output *out = data;
+
+   snprintf(out->description, sizeof(out->description), "%s", description);
+   out->descriptions++;
+   if (out->dones) out->description_after_done = 1;
+}
+
+static const struct wl_output_listener _output_listener =
+{
+   _geometry, _mode, _done, _scale, _name, _description
+};
+
+static void
+_global(void *data __attribute__((unused)), struct wl_registry *reg, uint32_t id,
+        const char *iface, uint32_t version)
+{
+   Output *out;
+
+   if (strcmp(iface, "wl_output")) return;
+   if (version != 4) tk_fail(tk, "wl_output is at version %u, not 4", version);
+   if (output_count == MAX_OUTPUTS) tk_fail(tk, "too many outputs");
+
+   out = &outputs[output_count++];
+   out->global = id;
+   out->output = wl_registry_bind(reg, id, &wl_output_interface, 4);
+   wl_output_add_listener(out->output, &_output_listener, out);
+}
+
+static void
+_global_remove(void *data __attribute__((unused)), struct wl_registry *reg __attribute__((unused)),
+               uint32_t id __attribute__((unused)))
+{
+}
+
+static const struct wl_registry_listener _registry_listener =
+{
+   _global, _global_remove
+};
+
+static void
+_settle(void)
+{
+   tk_sync(tk);
+   wl_display_roundtrip(tk_display(tk));
+}
+
+static void
+_check_bound(const Output *out)
+{
+   if (out->names != 1) tk_fail(tk, "%d name events on bind", out->names);
+   if (out->descriptions != 1)
+     tk_fail(tk, "%d description events on bind", out->descriptions);
+   if (!out->name[0]) tk_fail(tk, "empty output name");
+   if (!out->description[0]) tk_fail(tk, "empty output description");
+   if (out->name_after_done || out->description_after_done)
+     tk_fail(tk, "%s: name or description came after done", out->name);
+   if (out->dones != 1) tk_fail(tk, "%d done events on bind", out->dones);
+}
+
+int
+main(void)
+{
+   struct wl_registry *reg;
+   struct wl_test *tester;
+   int dones;
+
+   tk = tk_connect("test-output");
+   tester = tk_bind(tk, &wl_test_interface, 5);
+   if (!tester) tk_fail(tk, "no wl_test version 5");
+
+   reg = wl_display_get_registry(tk_display(tk));
+   wl_registry_add_listener(reg, &_registry_listener, NULL);
+   _settle();
+   if (output_count != 1) tk_fail(tk, "%d outputs, expected 1", output_count);
+
+   wl_test_zone_add(tester, 1024, 0, 800, 600);
+   _settle();
+   _settle();
+   if (output_count != 2) tk_fail(tk, "zone_add made no new output");
+
+   _check_bound(&outputs[0]);
+   _check_bound(&outputs[1]);
+   if (!strcmp(outputs[0].name, outputs[1].name))
+     tk_fail(tk, "two outputs are both named %s", outputs[0].name);
+
+   old_client.global = outputs[1].global;
+   old_client.output = wl_registry_bind(reg, old_client.global,
+                                        &wl_output_interface, 2);
+   wl_output_add_listener(old_client.output, &_output_listener, &old_client);
+   _settle();
+   if (old_client.names || old_client.descriptions)
+     tk_fail(tk, "a version 2 object was sent name or description");
+   if (old_client.dones != 1) tk_fail(tk, "version 2 object got no done");
+
+   dones = outputs[1].dones;
+   wl_test_output_configure(tester, 1, 1100, 20, 640, 480);
+   _settle();
+
+   if (outputs[1].dones != (dones + 1))
+     tk_fail(tk, "reconfigure sent %d done events", outputs[1].dones - dones);
+   if ((outputs[1].x != 1100) || (outputs[1].y != 20) ||
+       (outputs[1].w != 640) || (outputs[1].h != 480))
+     tk_fail(tk, "output is %d,%d %dx%d after reconfigure",
+             outputs[1].x, outputs[1].y, outputs[1].w, outputs[1].h);
+   if (outputs[1].names != 1)
+     tk_fail(tk, "name sent %d times: the protocol allows once",
+             outputs[1].names);
+   if (outputs[1].descriptions != 1)
+     tk_fail(tk, "unchanged description sent %d times",
+             outputs[1].descriptions);
+   if (old_client.w != 640) tk_fail(tk, "version 2 object missed the change");
+   if (old_client.names) tk_fail(tk, "version 2 object was sent a name");
+
+   wl_output_release(outputs[0].output);
+   wl_output_release(outputs[1].output);
+   _settle();
+
+   wl_registry_destroy(reg);
+   wl_test_destroy(tester);
+   tk_disconnect(tk);
+   return 0;
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to