| | |
| | | return [nsview window]; |
| | | } |
| | | |
| | | static inline void cleanupProxy() { |
| | | if (g_proxyList()->isEmpty()) { |
| | | return; |
| | | } |
| | | const auto &data = *g_proxyList(); |
| | | qDeleteAll(data); |
| | | g_proxyList()->clear(); |
| | | } |
| | | |
| | | static inline NSWindowProxy *ensureWindowProxy(const WId windowId) { |
| | | auto it = g_proxyList()->find(windowId); |
| | | if (it == g_proxyList()->end()) { |
| | |
| | | const auto proxy = new NSWindowProxy(nswindow); |
| | | it = g_proxyList()->insert(windowId, proxy); |
| | | } |
| | | static bool cleanerInstalled = false; |
| | | if (!cleanerInstalled) { |
| | | cleanerInstalled = true; |
| | | qAddPostRoutine(cleanupProxy); |
| | | } |
| | | return it.value(); |
| | | } |
| | | |
| | | static inline void releaseWindowProxy(const WId windowId) { |
| | | if (const auto proxy = g_proxyList()->take(windowId)) { |
| | | delete proxy; |
| | | } |
| | | } |
| | | |
| | | class CocoaWindowEventFilter : public QObject { |
| | |
| | | } |
| | | |
| | | CocoaWindowContext::~CocoaWindowContext() { |
| | | // TODO: deref something? |
| | | releaseWindowProxy(windowId); |
| | | } |
| | | |
| | | QString CocoaWindowContext::key() const { |
| | |
| | | AbstractWindowContext::virtual_hook(id, data); |
| | | } |
| | | |
| | | bool CocoaWindowContext::winIdChanged(QWindow *oldWindow) { |
| | | void CocoaWindowContext::winIdChanged(QWindow *oldWindow) { |
| | | releaseWindowProxy(windowId); |
| | | if (!m_windowHandle) { |
| | | return; |
| | | } |
| | | |
| | | windowId = m_windowHandle->winId(); |
| | | ensureWindowProxy(windowId)->setSystemTitleBarVisible(false); |
| | | std::ignore = new CocoaWindowEventFilter(this, this); |
| | | return true; |
| | | cocoaWindowEventFilter = std::make_unique<CocoaWindowEventFilter>(this, this); |
| | | } |
| | | |
| | | } |