From 8210f89b127a7c085ec38ba4342602da6b298244 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 11 Oct 2016 02:40:16 +0100 Subject: [PATCH] Wayland: Set a proper name for outputs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit glfwGetMonitorName()’s documentation says “this function returns a human-readable name”, which “typically reflects the make and model of the monitor”. We get these two strings in the geometry event, so we only set the name at this point. --- src/wl_monitor.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 7a830513..73567a5b 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -50,11 +50,21 @@ static void geometry(void* data, int32_t transform) { struct _GLFWmonitor *monitor = data; + char* name; + size_t nameLength; monitor->wl.x = x; monitor->wl.y = y; monitor->widthMM = physicalWidth; monitor->heightMM = physicalHeight; + + nameLength = strlen(make) + 1 + strlen(model) + 1; + name = realloc(monitor->name, nameLength); + if (name) + { + sprintf(name, "%s %s", make, model); + monitor->name = name; + } } static void mode(void* data, @@ -118,10 +128,6 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version) { _GLFWmonitor *monitor; struct wl_output *output; - char nameStr[80]; - - memset(nameStr, 0, sizeof(nameStr)); - snprintf(nameStr, 79, "wl_output@%u", name); if (version < 2) { @@ -130,7 +136,8 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version) return; } - monitor = _glfwAllocMonitor(nameStr, 0, 0); + // The actual name of this output will be set in the geometry handler. + monitor = _glfwAllocMonitor(NULL, 0, 0); output = wl_registry_bind(_glfw.wl.registry, name,