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:
parent
60dd9bacb0
commit
090646b61a
17 changed files with 137 additions and 201 deletions
|
|
@ -1,38 +1,24 @@
|
|||
|
||||
#include <Spectre/System/Log.h>
|
||||
|
||||
#include "X11EventQueue.h"
|
||||
#include "X11SharedDisplay.h"
|
||||
#include "Xlib.h"
|
||||
#include "X11Keyboard.h"
|
||||
#include "X11Mouse.h"
|
||||
#include "X11WindowEventHandler.h"
|
||||
|
||||
namespace sp {
|
||||
|
||||
X11EventQueue::X11EventQueue()
|
||||
{
|
||||
m_disp = XGetDisplay();
|
||||
}
|
||||
|
||||
X11EventQueue::~X11EventQueue()
|
||||
{
|
||||
if (m_disp) {
|
||||
XReleaseDisplay(m_disp);
|
||||
}
|
||||
}
|
||||
|
||||
bool X11EventQueue::poll(Event& event)
|
||||
{
|
||||
Atom del_win = getAtom("WM_DELETE_WINDOW");
|
||||
Atom wm_proto = getAtom("WM_PROTOCOLS");
|
||||
::Display* disp = Xlib::getDisplay();
|
||||
Atom del_win = Xlib::getAtom("WM_DELETE_WINDOW");
|
||||
Atom wm_proto = Xlib::getAtom("WM_PROTOCOLS");
|
||||
|
||||
if (m_disp == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (XPending(m_disp)) {
|
||||
if (XPending(disp)) {
|
||||
XEvent xevent;
|
||||
|
||||
XNextEvent(m_disp, &xevent);
|
||||
XNextEvent(disp, &xevent);
|
||||
|
||||
switch(xevent.type) {
|
||||
case ClientMessage:
|
||||
|
|
@ -64,7 +50,7 @@ bool X11EventQueue::poll(Event& event)
|
|||
default:
|
||||
// Pass to window.
|
||||
Log::info("X11: Window Event");
|
||||
X11WindowEventHandler::process(m_disp, xevent);
|
||||
X11WindowEventHandler::process(disp, xevent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue