From 1e1265334838a59ed41a1529a9ab13f12b066a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 4 Jun 2019 16:59:04 +0200 Subject: [PATCH] X11: Let the language initialize XEvent structs (cherry picked from commit 1f508530f0cda2db78404a82fba1b956372e67aa) --- src/x11_window.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index da39a39d..dc8c1e93 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -215,10 +215,7 @@ static int translateKey(int scancode) static void sendEventToWM(_GLFWwindow* window, Atom type, long a, long b, long c, long d, long e) { - XEvent event; - memset(&event, 0, sizeof(event)); - - event.type = ClientMessage; + XEvent event = { ClientMessage }; event.xclient.window = window->x11.handle; event.xclient.format = 32; // Data is 32-bit longs event.xclient.message_type = type; @@ -946,11 +943,8 @@ static void handleSelectionRequest(XEvent* event) { const XSelectionRequestEvent* request = &event->xselectionrequest; - XEvent reply; - memset(&reply, 0, sizeof(reply)); - + XEvent reply = { SelectionNotify }; reply.xselection.property = writeTargetToProperty(request); - reply.xselection.type = SelectionNotify; reply.xselection.display = request->display; reply.xselection.requestor = request->requestor; reply.xselection.selection = request->selection; @@ -1647,10 +1641,7 @@ static void processEvent(XEvent *event) } else if (_glfw.x11.xdnd.version >= 2) { - XEvent reply; - memset(&reply, 0, sizeof(reply)); - - reply.type = ClientMessage; + XEvent reply = { ClientMessage }; reply.xclient.window = _glfw.x11.xdnd.source; reply.xclient.message_type = _glfw.x11.XdndFinished; reply.xclient.format = 32; @@ -1683,10 +1674,7 @@ static void processEvent(XEvent *event) _glfwInputCursorPos(window, xpos, ypos); - XEvent reply; - memset(&reply, 0, sizeof(reply)); - - reply.type = ClientMessage; + XEvent reply = { ClientMessage }; reply.xclient.window = _glfw.x11.xdnd.source; reply.xclient.message_type = _glfw.x11.XdndStatus; reply.xclient.format = 32; @@ -1739,10 +1727,7 @@ static void processEvent(XEvent *event) if (_glfw.x11.xdnd.version >= 2) { - XEvent reply; - memset(&reply, 0, sizeof(reply)); - - reply.type = ClientMessage; + XEvent reply = { ClientMessage }; reply.xclient.window = _glfw.x11.xdnd.source; reply.xclient.message_type = _glfw.x11.XdndFinished; reply.xclient.format = 32; @@ -2738,10 +2723,7 @@ void _glfwPlatformWaitEventsTimeout(double timeout) void _glfwPlatformPostEmptyEvent(void) { - XEvent event; - - memset(&event, 0, sizeof(event)); - event.type = ClientMessage; + XEvent event = { ClientMessage }; event.xclient.window = _glfw.x11.helperWindowHandle; event.xclient.format = 32; // Data is 32-bit longs event.xclient.message_type = _glfw.x11.NULL_;