mirror of https://github.com/AxioDL/boo.git
Merge branch 'master' of https://github.com/AxioDL/boo
This commit is contained in:
commit
04ff1692d8
|
@ -10,7 +10,7 @@ DBusConnection* RegisterDBus(const char* appName, bool& isFirst);
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
||||||
|
|
||||||
IWindow* _WindowWaylandNew(const std::string& title);
|
std::shared_ptr<IWindow> _WindowWaylandNew(const std::string& title);
|
||||||
|
|
||||||
class ApplicationWayland final : public IApplication
|
class ApplicationWayland final : public IApplication
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ public:
|
||||||
return m_args;
|
return m_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
IWindow* newWindow(const std::string& title, uint32_t drawSamples)
|
std::shared_ptr<IWindow> newWindow(const std::string& title, uint32_t drawSamples)
|
||||||
{
|
{
|
||||||
return _WindowWaylandNew(title);
|
return _WindowWaylandNew(title);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,10 +114,10 @@ static Window GetWindowOfEvent(XEvent* event, bool& windowEvent)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IWindow* _WindowXlibNew(const std::string& title,
|
std::shared_ptr<IWindow> _WindowXlibNew(const std::string& title,
|
||||||
Display* display, void* xcbConn,
|
Display* display, void* xcbConn,
|
||||||
int defaultScreen, XIM xIM, XIMStyle bestInputStyle, XFontSet fontset,
|
int defaultScreen, XIM xIM, XIMStyle bestInputStyle, XFontSet fontset,
|
||||||
GLXContext lastCtx, void* vulkanHandle, uint32_t drawSamples);
|
GLXContext lastCtx, void* vulkanHandle, uint32_t drawSamples);
|
||||||
|
|
||||||
static XIMStyle ChooseBetterStyle(XIMStyle style1, XIMStyle style2)
|
static XIMStyle ChooseBetterStyle(XIMStyle style1, XIMStyle style2)
|
||||||
{
|
{
|
||||||
|
@ -168,7 +168,7 @@ class ApplicationXlib final : public IApplication
|
||||||
DBusConnection* m_dbus = nullptr;
|
DBusConnection* m_dbus = nullptr;
|
||||||
|
|
||||||
/* All windows */
|
/* All windows */
|
||||||
std::unordered_map<Window, IWindow*> m_windows;
|
std::unordered_map<Window, std::weak_ptr<IWindow>> m_windows;
|
||||||
|
|
||||||
Display* m_xDisp = nullptr;
|
Display* m_xDisp = nullptr;
|
||||||
XIM m_xIM = nullptr;
|
XIM m_xIM = nullptr;
|
||||||
|
@ -467,7 +467,8 @@ public:
|
||||||
{
|
{
|
||||||
auto window = m_windows.find(evWindow);
|
auto window = m_windows.find(evWindow);
|
||||||
if (window != m_windows.end())
|
if (window != m_windows.end())
|
||||||
window->second->_incomingEvent(&event);
|
if (std::shared_ptr<IWindow> w = window->second.lock())
|
||||||
|
w->_incomingEvent(&event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XUnlockDisplay(m_xDisp);
|
XUnlockDisplay(m_xDisp);
|
||||||
|
@ -525,14 +526,14 @@ public:
|
||||||
return m_args;
|
return m_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
IWindow* newWindow(const std::string& title, uint32_t drawSamples)
|
std::shared_ptr<IWindow> newWindow(const std::string& title, uint32_t drawSamples)
|
||||||
{
|
{
|
||||||
#if BOO_HAS_VULKAN
|
#if BOO_HAS_VULKAN
|
||||||
IWindow* newWindow = _WindowXlibNew(title, m_xDisp, m_xcbConn, m_xDefaultScreen, m_xIM,
|
std::shared_ptr<IWindow> newWindow = _WindowXlibNew(title, m_xDisp, m_xcbConn, m_xDefaultScreen, m_xIM,
|
||||||
m_bestStyle, m_fontset, m_lastGlxCtx, (void*)m_getVkProc, drawSamples);
|
m_bestStyle, m_fontset, m_lastGlxCtx, (void*)m_getVkProc, drawSamples);
|
||||||
#else
|
#else
|
||||||
IWindow* newWindow = _WindowXlibNew(title, m_xDisp, nullptr, m_xDefaultScreen, m_xIM,
|
std::shared_ptr<IWindow> newWindow = _WindowXlibNew(title, m_xDisp, nullptr, m_xDefaultScreen, m_xIM,
|
||||||
m_bestStyle, m_fontset, m_lastGlxCtx, nullptr, drawSamples);
|
m_bestStyle, m_fontset, m_lastGlxCtx, nullptr, drawSamples);
|
||||||
#endif
|
#endif
|
||||||
m_windows[(Window)newWindow->getPlatformHandle()] = newWindow;
|
m_windows[(Window)newWindow->getPlatformHandle()] = newWindow;
|
||||||
return newWindow;
|
return newWindow;
|
||||||
|
|
|
@ -110,6 +110,11 @@ struct WindowWayland : IWindow
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void closeWindow()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void showWindow()
|
void showWindow()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -239,9 +244,9 @@ struct WindowWayland : IWindow
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IWindow* _WindowWaylandNew(const std::string& title)
|
std::shared_ptr<IWindow> _WindowWaylandNew(const std::string& title)
|
||||||
{
|
{
|
||||||
return new WindowWayland(title);
|
return std::make_shared<WindowWayland>(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1071,6 +1071,14 @@ public:
|
||||||
m_callback = cb;
|
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()
|
void showWindow()
|
||||||
{
|
{
|
||||||
XLockDisplay(m_xDisp);
|
XLockDisplay(m_xDisp);
|
||||||
|
@ -1980,14 +1988,15 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IWindow* _WindowXlibNew(const std::string& title,
|
std::shared_ptr<IWindow> _WindowXlibNew(const std::string& title,
|
||||||
Display* display, void* xcbConn,
|
Display* display, void* xcbConn,
|
||||||
int defaultScreen, XIM xIM, XIMStyle bestInputStyle, XFontSet fontset,
|
int defaultScreen, XIM xIM, XIMStyle bestInputStyle, XFontSet fontset,
|
||||||
GLXContext lastCtx, void* vulkanHandle, uint32_t drawSamples)
|
GLXContext lastCtx, void* vulkanHandle, uint32_t drawSamples)
|
||||||
{
|
{
|
||||||
XLockDisplay(display);
|
XLockDisplay(display);
|
||||||
IWindow* ret = new WindowXlib(title, display, xcbConn, defaultScreen, xIM,
|
std::shared_ptr<IWindow> ret = std::make_shared<WindowXlib>(title, display, xcbConn,
|
||||||
bestInputStyle, fontset, lastCtx, vulkanHandle, drawSamples);
|
defaultScreen, xIM, bestInputStyle, fontset, lastCtx,
|
||||||
|
vulkanHandle, drawSamples);
|
||||||
XUnlockDisplay(display);
|
XUnlockDisplay(display);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue