If no valid display has been fetched on linux, return no input supported

This commit is contained in:
baldurk
2020-04-21 15:30:11 +01:00
parent f57709366a
commit c6f43e81bf
+36 -9
View File
@@ -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);