1
0
Fork 0

Platform/Unix: Rename X11SharedDisplay to Xlib, and remove Display member variable from all classes.

We now initialize/destroy the display in Xlib::init/shutdown that is called in UnixApplication::init/shutdown and
therefore is valid through the whole lifetime. So no need for classes to keep references.
This commit is contained in:
Henrik Hautakoski 2020-12-25 17:17:51 +01:00
parent 60dd9bacb0
commit 090646b61a
17 changed files with 137 additions and 201 deletions

View file

@ -2,7 +2,7 @@
#include <string.h>
#include "X11Keyboard.h"
#include "X11Display.h"
#include "X11SharedDisplay.h"
#include "Xlib.h"
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <Spectre/System/Log.h>
@ -211,14 +211,10 @@ m_win(0)
X11Keyboard::~X11Keyboard()
{
if (m_disp) {
XReleaseDisplay(m_disp);
}
}
void X11Keyboard::init()
{
m_disp = XGetDisplay();
}
bool X11Keyboard::isKeyDown(Keyboard::Key key)
@ -334,7 +330,7 @@ bool X11Keyboard::isKeyDown(Keyboard::Key key)
default : sym = 0; break;
}
KeyCode keycode = ::XKeysymToKeycode(m_disp, sym);
KeyCode keycode = ::XKeysymToKeycode(Xlib::getDisplay(), sym);
if (keycode) {
return m_key_state[keycode / 8] & (1 << (keycode % 8));
@ -365,7 +361,7 @@ void X11Keyboard::update(InputModule *input)
if (m_win) {
// Query keyboard state.
::XQueryKeymap(m_disp, m_key_state);
::XQueryKeymap(Xlib::getDisplay(), m_key_state);
}
}