Use smart pointers for Xlib windows

This commit is contained in:
Jack Andersen
2017-07-16 17:58:18 -10:00
parent b97c82469a
commit 023d129a75
4 changed files with 36 additions and 21 deletions

View File

@@ -1070,6 +1070,14 @@ public:
{
m_callback = cb;
}
void closeWindow()
{
// TODO: Free window resources and prevent further access
XLockDisplay(m_xDisp);
XUnmapWindow(m_xDisp, m_windowId);
XUnlockDisplay(m_xDisp);
}
void showWindow()
{
@@ -1980,14 +1988,15 @@ public:
}
};
IWindow* _WindowXlibNew(const std::string& title,
Display* display, void* xcbConn,
int defaultScreen, XIM xIM, XIMStyle bestInputStyle, XFontSet fontset,
GLXContext lastCtx, void* vulkanHandle, uint32_t drawSamples)
std::shared_ptr<IWindow> _WindowXlibNew(const std::string& title,
Display* display, void* xcbConn,
int defaultScreen, XIM xIM, XIMStyle bestInputStyle, XFontSet fontset,
GLXContext lastCtx, void* vulkanHandle, uint32_t drawSamples)
{
XLockDisplay(display);
IWindow* ret = new WindowXlib(title, display, xcbConn, defaultScreen, xIM,
bestInputStyle, fontset, lastCtx, vulkanHandle, drawSamples);
std::shared_ptr<IWindow> ret = std::make_shared<WindowXlib>(title, display, xcbConn,
defaultScreen, xIM, bestInputStyle, fontset, lastCtx,
vulkanHandle, drawSamples);
XUnlockDisplay(display);
return ret;
}