From 2a23666e009b352ff14c40e5ace80f7b62845a1f Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Thu, 1 Jun 2017 00:02:57 +0800 Subject: [PATCH] X11/wl/mir: Introduce new block scopes to hold variables. This makes the project compile successfully when -Wdeclaration-after-statement is enabled. --- src/mir_monitor.c | 45 +++++---- src/mir_window.c | 43 +++++---- src/wl_window.c | 22 +++-- src/x11_init.c | 93 ++++++++++--------- src/x11_monitor.c | 55 ++++++----- src/x11_window.c | 228 ++++++++++++++++++++++++++-------------------- 6 files changed, 271 insertions(+), 215 deletions(-) diff --git a/src/mir_monitor.c b/src/mir_monitor.c index 268485064..a94d741be 100644 --- a/src/mir_monitor.c +++ b/src/mir_monitor.c @@ -138,33 +138,38 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) if (id != monitor->mir.outputId) continue; - MirOutputConnectionState state = mir_output_get_connection_state(output); - bool enabled = mir_output_is_enabled(output); - - // We must have been disconnected - if (!enabled || state != mir_output_connection_state_connected) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Mir: Monitor no longer connected"); - return NULL; + MirOutputConnectionState state = mir_output_get_connection_state(output); + bool enabled = mir_output_is_enabled(output); + + // We must have been disconnected + if (!enabled || state != mir_output_connection_state_connected) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Mir: Monitor no longer connected"); + return NULL; + } } - int numModes = mir_output_get_num_modes(output); - modes = calloc(numModes, sizeof(GLFWvidmode)); - for (*found = 0; *found < numModes; (*found)++) { - const MirOutputMode* mode = mir_output_get_mode(output, *found); - int width = mir_output_mode_get_width(mode); - int height = mir_output_mode_get_height(mode); - double refreshRate = mir_output_mode_get_refresh_rate(mode); - MirPixelFormat currentFormat = mir_output_get_current_pixel_format(output); + int numModes = mir_output_get_num_modes(output); + modes = calloc(numModes, sizeof(GLFWvidmode)); - modes[*found].width = width; - modes[*found].height = height; - modes[*found].refreshRate = refreshRate; + for (*found = 0; *found < numModes; (*found)++) + { + const MirOutputMode* mode = mir_output_get_mode(output, *found); + int width = mir_output_mode_get_width(mode); + int height = mir_output_mode_get_height(mode); + double refreshRate = mir_output_mode_get_refresh_rate(mode); + MirPixelFormat currentFormat = mir_output_get_current_pixel_format(output); - FillInRGBBitsFromPixelFormat(&modes[*found], currentFormat); + modes[*found].width = width; + modes[*found].height = height; + modes[*found].refreshRate = refreshRate; + + FillInRGBBitsFromPixelFormat(&modes[*found], currentFormat); + } } break; diff --git a/src/mir_window.c b/src/mir_window.c index 566f571c1..bc66e9e2b 100644 --- a/src/mir_window.c +++ b/src/mir_window.c @@ -205,13 +205,15 @@ static void handlePointerMotion(_GLFWwindow* window, { if (_glfw.mir.disabledCursorWindow != window) return; + else + { + int dx = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_relative_x); + int dy = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_relative_y); + int current_x = window->virtualCursorPosX; + int current_y = window->virtualCursorPosY; - const int dx = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_relative_x); - const int dy = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_relative_y); - const int current_x = window->virtualCursorPosX; - const int current_y = window->virtualCursorPosY; - - _glfwInputCursorPos(window, dx + current_x, dy + current_y); + _glfwInputCursorPos(window, dx + current_x, dy + current_y); + } } else { @@ -701,20 +703,23 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, cursor->mir.conf = mir_cursor_configuration_from_buffer_stream(stream, xhot, yhot); - MirGraphicsRegion region; - mir_buffer_stream_get_graphics_region(stream, ®ion); - - unsigned char* pixels = image->pixels; - char* dest = region.vaddr; - int i; - - for (i = 0; i < i_w * i_h; i++, pixels += 4) { - unsigned int alpha = pixels[3]; - *dest++ = (char)(pixels[2] * alpha / 255); - *dest++ = (char)(pixels[1] * alpha / 255); - *dest++ = (char)(pixels[0] * alpha / 255); - *dest++ = (char)alpha; + MirGraphicsRegion region; + unsigned char* pixels = image->pixels; + char* dest; + int i; + + mir_buffer_stream_get_graphics_region(stream, ®ion); + dest = region.vaddr; + + for (i = 0; i < i_w * i_h; i++, pixels += 4) + { + unsigned int alpha = pixels[3]; + *dest++ = (char)(pixels[2] * alpha / 255); + *dest++ = (char)(pixels[1] * alpha / 255); + *dest++ = (char)(pixels[0] * alpha / 255); + *dest++ = (char)alpha; + } } mir_buffer_stream_swap_buffers_sync(stream); diff --git a/src/wl_window.c b/src/wl_window.c index e9c817d50..45c54ece8 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -763,16 +763,20 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, pool = wl_shm_create_pool(_glfw.wl.shm, fd, length); close(fd); - unsigned char* source = (unsigned char*) image->pixels; - unsigned char* target = data; - for (i = 0; i < image->width * image->height; i++, source += 4) - { - unsigned int alpha = source[3]; - *target++ = (unsigned char) ((source[2] * alpha) / 255); - *target++ = (unsigned char) ((source[1] * alpha) / 255); - *target++ = (unsigned char) ((source[0] * alpha) / 255); - *target++ = (unsigned char) alpha; + { + unsigned char* source = (unsigned char*) image->pixels; + unsigned char* target = data; + + for (i = 0; i < image->width * image->height; i++, source += 4) + { + unsigned int alpha = source[3]; + + *target++ = (unsigned char) ((source[2] * alpha) / 255); + *target++ = (unsigned char) ((source[1] * alpha) / 255); + *target++ = (unsigned char) ((source[0] * alpha) / 255); + *target++ = (unsigned char) alpha; + } } cursor->wl.buffer = diff --git a/src/x11_init.c b/src/x11_init.c index a52216f07..0da8de528 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -416,45 +416,46 @@ static void detectEWMH(void) XFree(windowFromChild); // We are now fairly sure that an EWMH-compliant window manager is running + { + Atom* supportedAtoms; + unsigned long atomCount; - Atom* supportedAtoms; - unsigned long atomCount; + // Now we need to check the _NET_SUPPORTED property of the root window + // It should be a list of supported WM protocol and state atoms + atomCount = _glfwGetWindowPropertyX11(_glfw.x11.root, + wmSupported, + XA_ATOM, + (unsigned char**) &supportedAtoms); - // Now we need to check the _NET_SUPPORTED property of the root window - // It should be a list of supported WM protocol and state atoms - atomCount = _glfwGetWindowPropertyX11(_glfw.x11.root, - wmSupported, - XA_ATOM, - (unsigned char**) &supportedAtoms); + // See which of the atoms we support that are supported by the WM + _glfw.x11.NET_WM_STATE = + getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE"); + _glfw.x11.NET_WM_STATE_ABOVE = + getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE"); + _glfw.x11.NET_WM_STATE_FULLSCREEN = + getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN"); + _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT = + getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT"); + _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ = + getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ"); + _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION = + getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION"); + _glfw.x11.NET_WM_FULLSCREEN_MONITORS = + getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS"); + _glfw.x11.NET_WM_WINDOW_TYPE = + getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE"); + _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL = + getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL"); + _glfw.x11.NET_ACTIVE_WINDOW = + getSupportedAtom(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW"); + _glfw.x11.NET_FRAME_EXTENTS = + getSupportedAtom(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS"); + _glfw.x11.NET_REQUEST_FRAME_EXTENTS = + getSupportedAtom(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS"); - // See which of the atoms we support that are supported by the WM - _glfw.x11.NET_WM_STATE = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE"); - _glfw.x11.NET_WM_STATE_ABOVE = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE"); - _glfw.x11.NET_WM_STATE_FULLSCREEN = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN"); - _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT"); - _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ"); - _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION"); - _glfw.x11.NET_WM_FULLSCREEN_MONITORS = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS"); - _glfw.x11.NET_WM_WINDOW_TYPE = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE"); - _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL"); - _glfw.x11.NET_ACTIVE_WINDOW = - getSupportedAtom(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW"); - _glfw.x11.NET_FRAME_EXTENTS = - getSupportedAtom(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS"); - _glfw.x11.NET_REQUEST_FRAME_EXTENTS = - getSupportedAtom(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS"); - - if (supportedAtoms) - XFree(supportedAtoms); + if (supportedAtoms) + XFree(supportedAtoms); + } } // Look for and initialize supported X11 extensions @@ -736,17 +737,19 @@ Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot) native->xhot = xhot; native->yhot = yhot; - unsigned char* source = (unsigned char*) image->pixels; - XcursorPixel* target = native->pixels; - - for (i = 0; i < image->width * image->height; i++, target++, source += 4) { - unsigned int alpha = source[3]; + unsigned char* source = (unsigned char*) image->pixels; + XcursorPixel* target = native->pixels; - *target = (alpha << 24) | - ((unsigned char) ((source[0] * alpha) / 255) << 16) | - ((unsigned char) ((source[1] * alpha) / 255) << 8) | - ((unsigned char) ((source[2] * alpha) / 255) << 0); + for (i = 0; i < image->width * image->height; i++, target++, source += 4) + { + unsigned int alpha = source[3]; + + *target = (alpha << 24) | + ((unsigned char) ((source[0] * alpha) / 255) << 16) | + ((unsigned char) ((source[1] * alpha) / 255) << 8) | + ((unsigned char) ((source[2] * alpha) / 255) << 0); + } } cursor = XcursorImageLoadCursor(_glfw.x11.display, native); diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 5c0516e67..755f32cfa 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -241,14 +241,17 @@ GLFWbool _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired) for (i = 0; i < oi->nmode; i++) { const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]); + if (!modeIsGood(mi)) continue; - const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci); - if (_glfwCompareVideoModes(best, &mode) == 0) { - native = mi->id; - break; + GLFWvidmode mode = vidmodeFromModeInfo(mi, ci); + if (_glfwCompareVideoModes(best, &mode) == 0) + { + native = mi->id; + break; + } } } @@ -360,23 +363,26 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) for (i = 0; i < oi->nmode; i++) { const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]); + if (!modeIsGood(mi)) continue; - const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci); - - for (j = 0; j < *count; j++) { - if (_glfwCompareVideoModes(result + j, &mode) == 0) - break; + GLFWvidmode mode = vidmodeFromModeInfo(mi, ci); + + for (j = 0; j < *count; j++) + { + if (_glfwCompareVideoModes(result + j, &mode) == 0) + break; + } + + // Skip duplicate modes + if (j < *count) + continue; + + (*count)++; + result[*count - 1] = mode; } - - // Skip duplicate modes - if (j < *count) - continue; - - (*count)++; - result[*count - 1] = mode; } XRRFreeOutputInfo(oi); @@ -453,21 +459,24 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken) { + if (XRRGetCrtcGammaSize(_glfw.x11.display, monitor->x11.crtc) != ramp->size) { _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Gamma ramp size must match current ramp size"); return; } + else + { + XRRCrtcGamma* gamma = XRRAllocGamma(ramp->size); - XRRCrtcGamma* gamma = XRRAllocGamma(ramp->size); + memcpy(gamma->red, ramp->red, ramp->size * sizeof(unsigned short)); + memcpy(gamma->green, ramp->green, ramp->size * sizeof(unsigned short)); + memcpy(gamma->blue, ramp->blue, ramp->size * sizeof(unsigned short)); - memcpy(gamma->red, ramp->red, ramp->size * sizeof(unsigned short)); - memcpy(gamma->green, ramp->green, ramp->size * sizeof(unsigned short)); - memcpy(gamma->blue, ramp->blue, ramp->size * sizeof(unsigned short)); - - XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma); - XRRFreeGamma(gamma); + XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma); + XRRFreeGamma(gamma); + } } else if (_glfw.x11.vidmode.available) { diff --git a/src/x11_window.c b/src/x11_window.c index ed5a0f297..c98489739 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -426,23 +426,25 @@ static char** parseUriList(char* text, int* count) (*count)++; - char* path = calloc(strlen(line) + 1, 1); - paths = realloc(paths, *count * sizeof(char*)); - paths[*count - 1] = path; - - while (*line) { - if (line[0] == '%' && line[1] && line[2]) - { - const char digits[3] = { line[1], line[2], '\0' }; - *path = strtol(digits, NULL, 16); - line += 2; - } - else - *path = *line; + char* path = calloc(strlen(line) + 1, 1); + paths = realloc(paths, *count * sizeof(char*)); + paths[*count - 1] = path; - path++; - line++; + while (*line) + { + if (line[0] == '%' && line[1] && line[2]) + { + const char digits[3] = { line[1], line[2], '\0' }; + *path = strtol(digits, NULL, 16); + line += 2; + } + else + *path = *line; + + path++; + line++; + } } } @@ -1096,13 +1098,16 @@ static void processEvent(XEvent *event) else { KeySym keysym; + XLookupString(&event->xkey, NULL, 0, &keysym, NULL); _glfwInputKey(window, key, keycode, GLFW_PRESS, mods); - const long character = _glfwKeySym2Unicode(keysym); - if (character != -1) - _glfwInputChar(window, character, mods, plain); + { + long character = _glfwKeySym2Unicode(keysym); + if (character != -1) + _glfwInputChar(window, character, mods, plain); + } } return; @@ -1249,17 +1254,20 @@ static void processEvent(XEvent *event) if (window->cursorMode == GLFW_CURSOR_DISABLED) { + if (_glfw.x11.disabledCursorWindow != window) return; if (_glfw.x11.xi.available) return; - const int dx = x - window->x11.lastCursorPosX; - const int dy = y - window->x11.lastCursorPosY; + { + int dx = x - window->x11.lastCursorPosX; + int dy = y - window->x11.lastCursorPosY; - _glfwInputCursorPos(window, - window->virtualCursorPosX + dx, - window->virtualCursorPosY + dy); + _glfwInputCursorPos(window, + window->virtualCursorPosX + dx, + window->virtualCursorPosY + dy); + } } else _glfwInputCursorPos(window, x, y); @@ -1438,28 +1446,30 @@ static void processEvent(XEvent *event) _glfwInputCursorPos(window, xpos, ypos); - XEvent reply; - memset(&reply, 0, sizeof(reply)); - - reply.type = ClientMessage; - reply.xclient.window = _glfw.x11.xdnd.source; - reply.xclient.message_type = _glfw.x11.XdndStatus; - reply.xclient.format = 32; - reply.xclient.data.l[0] = window->x11.handle; - reply.xclient.data.l[2] = 0; // Specify an empty rectangle - reply.xclient.data.l[3] = 0; - - if (_glfw.x11.xdnd.format) { - // Reply that we are ready to copy the dragged data - reply.xclient.data.l[1] = 1; // Accept with no rectangle - if (_glfw.x11.xdnd.version >= 2) - reply.xclient.data.l[4] = _glfw.x11.XdndActionCopy; - } + XEvent reply; + memset(&reply, 0, sizeof(reply)); - XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source, - False, NoEventMask, &reply); - XFlush(_glfw.x11.display); + reply.type = ClientMessage; + reply.xclient.window = _glfw.x11.xdnd.source; + reply.xclient.message_type = _glfw.x11.XdndStatus; + reply.xclient.format = 32; + reply.xclient.data.l[0] = window->x11.handle; + reply.xclient.data.l[2] = 0; // Specify an empty rectangle + reply.xclient.data.l[3] = 0; + + if (_glfw.x11.xdnd.format) + { + // Reply that we are ready to copy the dragged data + reply.xclient.data.l[1] = 1; // Accept with no rectangle + if (_glfw.x11.xdnd.version >= 2) + reply.xclient.data.l[4] = _glfw.x11.XdndActionCopy; + } + + XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source, + False, NoEventMask, &reply); + XFlush(_glfw.x11.display); + } } return; @@ -1571,22 +1581,25 @@ static void processEvent(XEvent *event) if (event->xproperty.atom == _glfw.x11.WM_STATE) { const int state = getWindowState(window); + if (state != IconicState && state != NormalState) return; - const GLFWbool iconified = (state == IconicState); - if (window->x11.iconified != iconified) { - if (window->monitor) + GLFWbool iconified = (state == IconicState); + if (window->x11.iconified != iconified) { - if (iconified) - releaseMonitor(window); - else - acquireMonitor(window); - } + if (window->monitor) + { + if (iconified) + releaseMonitor(window); + else + acquireMonitor(window); + } - window->x11.iconified = iconified; - _glfwInputWindowIconify(window, iconified); + window->x11.iconified = iconified; + _glfwInputWindowIconify(window, iconified); + } } } else if (event->xproperty.atom == _glfw.x11.NET_WM_STATE) @@ -1842,31 +1855,33 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window, for (i = 0; i < count; i++) longCount += 2 + images[i].width * images[i].height; - long* icon = calloc(longCount, sizeof(long)); - long* target = icon; - - for (i = 0; i < count; i++) { - *target++ = images[i].width; - *target++ = images[i].height; + long* icon = calloc(longCount, sizeof(long)); + long* target = icon; - for (j = 0; j < images[i].width * images[i].height; j++) + for (i = 0; i < count; i++) { - *target++ = (images[i].pixels[j * 4 + 0] << 16) | - (images[i].pixels[j * 4 + 1] << 8) | - (images[i].pixels[j * 4 + 2] << 0) | - (images[i].pixels[j * 4 + 3] << 24); + *target++ = images[i].width; + *target++ = images[i].height; + + for (j = 0; j < images[i].width * images[i].height; j++) + { + *target++ = (images[i].pixels[j * 4 + 0] << 16) | + (images[i].pixels[j * 4 + 1] << 8) | + (images[i].pixels[j * 4 + 2] << 0) | + (images[i].pixels[j * 4 + 3] << 24); + } } + + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.NET_WM_ICON, + XA_CARDINAL, 32, + PropModeReplace, + (unsigned char*) icon, + longCount); + + free(icon); } - - XChangeProperty(_glfw.x11.display, window->x11.handle, - _glfw.x11.NET_WM_ICON, - XA_CARDINAL, 32, - PropModeReplace, - (unsigned char*) icon, - longCount); - - free(icon); } else { @@ -2333,12 +2348,15 @@ void _glfwPlatformPollEvents(void) #if defined(__linux__) _glfwDetectJoystickConnectionLinux(); #endif - int count = XPending(_glfw.x11.display); - while (count--) + { - XEvent event; - XNextEvent(_glfw.x11.display, &event); - processEvent(&event); + int count = XPending(_glfw.x11.display); + while (count--) + { + XEvent event; + XNextEvent(_glfw.x11.display, &event); + processEvent(&event); + } } window = _glfw.x11.disabledCursorWindow; @@ -2476,6 +2494,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) const char* _glfwPlatformGetKeyName(int key, int scancode) { + if (!_glfw.x11.xkb.available) return NULL; @@ -2485,19 +2504,28 @@ const char* _glfwPlatformGetKeyName(int key, int scancode) if (!_glfwIsPrintable(_glfw.x11.keycodes[scancode])) return NULL; - const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0); - if (keysym == NoSymbol) - return NULL; + { + long ch; - const long ch = _glfwKeySym2Unicode(keysym); - if (ch == -1) - return NULL; + { + KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0); + if (keysym == NoSymbol) + return NULL; - const size_t count = encodeUTF8(_glfw.x11.keyName, (unsigned int) ch); - if (count == 0) - return NULL; + ch = _glfwKeySym2Unicode(keysym); + if (ch == -1) + return NULL; + } + + { + size_t count = encodeUTF8(_glfw.x11.keyName, (unsigned int) ch); + if (count == 0) + return NULL; + + _glfw.x11.keyName[count] = '\0'; + } + } - _glfw.x11.keyName[count] = '\0'; return _glfw.x11.keyName; } @@ -2664,6 +2692,7 @@ int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle) { + PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR) vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR"); @@ -2674,19 +2703,20 @@ int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, return GLFW_FALSE; } - xcb_connection_t* connection = - _glfw.x11.x11xcb.XGetXCBConnection(_glfw.x11.display); - if (!connection) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "X11: Failed to retrieve XCB connection"); - return GLFW_FALSE; - } + xcb_connection_t* connection = _glfw.x11.x11xcb.XGetXCBConnection(_glfw.x11.display); + if (!connection) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "X11: Failed to retrieve XCB connection"); + return GLFW_FALSE; + } - return vkGetPhysicalDeviceXcbPresentationSupportKHR(device, - queuefamily, - connection, - visualID); + return vkGetPhysicalDeviceXcbPresentationSupportKHR(device, + queuefamily, + connection, + visualID); + } } else {