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
34
source/Platform/Unix/Xlib.cpp
Normal file
34
source/Platform/Unix/Xlib.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include "Xlib.h"
|
||||
|
||||
namespace sp { namespace Xlib {
|
||||
|
||||
namespace _priv {
|
||||
// Define a global display (for simplicity, we always connect to local one.)
|
||||
::Display* display = NULL;
|
||||
};
|
||||
|
||||
void init()
|
||||
{
|
||||
_priv::display = XOpenDisplay(NULL);
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
{
|
||||
XCloseDisplay(_priv::display);
|
||||
_priv::display = NULL;
|
||||
}
|
||||
|
||||
::Display* getDisplay()
|
||||
{
|
||||
assert(_priv::display != NULL);
|
||||
return _priv::display;
|
||||
}
|
||||
|
||||
::Atom getAtom(const std::string& name, bool onlyIfExists)
|
||||
{
|
||||
return XInternAtom(getDisplay(), name.c_str(), onlyIfExists);
|
||||
}
|
||||
|
||||
} } // namespace sp::Xlib
|
||||
Loading…
Add table
Add a link
Reference in a new issue