From 95e282d5a0f20939b73dd436a8cfcb2601fdaf25 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 1 Oct 2017 01:38:00 +0100 Subject: [PATCH 1/5] Wayland: Add transparency support Closes #788. --- src/wl_platform.h | 1 + src/wl_window.c | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index c543d82c4..656f0ef1f 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -76,6 +76,7 @@ typedef struct _GLFWwindowWayland int width, height; GLFWbool visible; GLFWbool maximized; + GLFWbool transparent; struct wl_surface* surface; struct wl_egl_window* native; struct wl_shell_surface* shellSurface; diff --git a/src/wl_window.c b/src/wl_window.c index caa51d3a9..32d5f4040 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -212,8 +212,8 @@ static GLFWbool createSurface(_GLFWwindow* window, window->wl.height = wndconfig->height; window->wl.scale = 1; - // TODO: make this optional once issue #197 is fixed. - setOpaqueRegion(window); + if (!window->wl.transparent) + setOpaqueRegion(window); return GLFW_TRUE; } @@ -390,6 +390,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { + window->wl.transparent = fbconfig->transparent; + if (!createSurface(window, wndconfig)) return GLFW_FALSE; @@ -514,7 +516,8 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) window->wl.width = width; window->wl.height = height; wl_egl_window_resize(window->wl.native, scaledWidth, scaledHeight, 0, 0); - setOpaqueRegion(window); + if (!window->wl.transparent) + setOpaqueRegion(window); _glfwInputFramebufferSize(window, scaledWidth, scaledHeight); } @@ -656,9 +659,7 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window) int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Framebuffer transparency attribute not implemented yet"); - return GLFW_FALSE; + return window->wl.transparent; } void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) From 6d463d36fade96c1a455a6a1549b49f31d6527af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 2 Oct 2017 17:31:39 +0200 Subject: [PATCH 2/5] Cleanup --- src/init.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/init.c b/src/init.c index 7d3678fac..19a13e0df 100644 --- a/src/init.c +++ b/src/init.c @@ -152,15 +152,13 @@ void _glfwInputError(int code, const char* format, ...) if (format) { - int count; va_list vl; va_start(vl, format); - count = vsnprintf(description, sizeof(description), format, vl); + vsnprintf(description, sizeof(description), format, vl); va_end(vl); - if (count < 0) - description[sizeof(description) - 1] = '\0'; + description[sizeof(description) - 1] = '\0'; } else strcpy(description, getErrorString(code)); From 07cc6e00da51ade97a240cf8cc1768be4046f1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 2 Oct 2017 17:32:21 +0200 Subject: [PATCH 3/5] Add gamepad name to joysticks test --- tests/joysticks.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/joysticks.c b/tests/joysticks.c index 88489d4e6..d039a761c 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -269,7 +269,9 @@ int main(void) "LT", "RT", }; - nk_label(nk, "Gamepad state", NK_TEXT_LEFT); + nk_labelf(nk, NK_TEXT_LEFT, + "Gamepad state: %s", + glfwGetGamepadName(joysticks[i])); nk_layout_row_dynamic(nk, 30, 2); From 94ee10e655cf0f1c82882ec2efe30f4195a5cf50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 3 Oct 2017 00:41:19 +0200 Subject: [PATCH 4/5] Remove trailing else --- src/linux_joystick.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 3283d1eaf..d73961fb6 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -306,7 +306,6 @@ GLFWbool _glfwInitJoysticksLinux(void) closedir(dir); } - else // Continue with no joysticks if enumeration fails From 56ecd62f58f0c988c017050a75c46953a30a7512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 3 Oct 2017 00:41:55 +0200 Subject: [PATCH 5/5] Fix joystick test hat drawing --- tests/joysticks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/joysticks.c b/tests/joysticks.c index d039a761c..d2be6475d 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -98,7 +98,7 @@ static void hat_widget(struct nk_context* nk, unsigned char state) struct nk_rect area; struct nk_vec2 center; - if (nk_widget(&area, nk) != NK_WIDGET_VALID) + if (nk_widget(&area, nk) == NK_WIDGET_INVALID) return; center = nk_vec2(area.x + area.w / 2.f, area.y + area.h / 2.f);