From c6f43e81bf4d46dfd8624ce4d74a503b4e17cc71 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 21 Apr 2020 15:30:11 +0100 Subject: [PATCH] If no valid display has been fetched on linux, return no input supported --- renderdoc/os/posix/linux/linux_stringio.cpp | 45 ++++++++++++++++----- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/renderdoc/os/posix/linux/linux_stringio.cpp b/renderdoc/os/posix/linux/linux_stringio.cpp index 63f5d896b..b5102d678 100644 --- a/renderdoc/os/posix/linux/linux_stringio.cpp +++ b/renderdoc/os/posix/linux/linux_stringio.cpp @@ -70,15 +70,6 @@ void Init() { } -bool PlatformHasKeyInput() -{ -#if ENABLED(RDOC_XCB) || ENABLED(RDOC_XLIB) || ENABLED(RDOC_WAYLAND) - return true; -#else - return false; -#endif -} - #if ENABLED(RDOC_XLIB) Display *CurrentXDisplay = NULL; @@ -91,6 +82,11 @@ void UseXlibDisplay(Display *dpy) CurrentXDisplay = XOpenDisplay(XDisplayString(dpy)); } +bool HasXlibInput() +{ + return CurrentXDisplay != NULL; +} + bool GetXlibKeyState(int key) { if(CurrentXDisplay == NULL) @@ -158,6 +154,11 @@ void UseXlibDisplay(Display *dpy) { } +bool HasXlibInput() +{ + return false; +} + bool GetXlibKeyState(int key) { return false; @@ -176,6 +177,11 @@ void UseXcbConnection(xcb_connection_t *conn) symbols = xcb_key_symbols_alloc(conn); } +bool HasXCBInput() +{ + return symbols != NULL; +} + bool GetXCBKeyState(int key) { if(symbols == NULL) @@ -259,6 +265,11 @@ bool GetXCBKeyState(int key) return false; } +bool HasXCBInput() +{ + return false; +} + #endif #if ENABLED(RDOC_WAYLAND) @@ -480,6 +491,12 @@ void RemoveWaylandInputWindow(wl_surface *wnd) surfaces.erase(wnd); } +bool HasWaylandInput() +{ + SCOPED_LOCK(waylandLock); + return !displays.empty(); +} + bool GetWaylandKeyState(int key) { SCOPED_LOCK(waylandLock); @@ -500,6 +517,11 @@ void RemoveWaylandInputWindow(wl_surface *wnd) { } +bool HasWaylandInput() +{ + return false; +} + bool GetWaylandKeyState(int key) { return false; @@ -553,6 +575,11 @@ void RemoveInputWindow(WindowingSystem windowSystem, void *wnd) } } +bool PlatformHasKeyInput() +{ + return HasXCBInput() || HasXlibInput() || HasWaylandInput(); +} + bool GetKeyState(int key) { return GetXCBKeyState(key) || GetXlibKeyState(key) || GetWaylandKeyState(key);