-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ac4342
commit 661f826
Showing
19 changed files
with
585 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright (C) 2023 rewine <[email protected]>. | ||
// SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | ||
|
||
|
||
#include "foreigntoplevelhandlev1.h" | ||
#include "foreign_toplevel_manager_impl.h" | ||
|
||
#include <QHash> | ||
|
||
#include <qwoutput.h> | ||
#include <qwsignalconnector.h> | ||
#include <qwglobal.h> | ||
|
||
QW_USE_NAMESPACE | ||
|
||
class TreeLandDockPreviewContextV1Private : public QWObjectPrivate | ||
{ | ||
public: | ||
TreeLandDockPreviewContextV1Private(treeland_dock_preview_context_v1 *handle, bool isOwner, TreeLandDockPreviewContextV1 *qq) | ||
: QWObjectPrivate(handle, isOwner, qq) | ||
{ | ||
Q_ASSERT(!map.contains(handle)); | ||
map.insert(handle, qq); | ||
sc.connect(&handle->events.destroy, this, &TreeLandDockPreviewContextV1Private::on_destroy); | ||
sc.connect(&handle->events.request_show, this, &TreeLandDockPreviewContextV1Private::on_request_show); | ||
} | ||
~TreeLandDockPreviewContextV1Private() { | ||
if (!m_handle) | ||
return; | ||
destroy(); | ||
if (isHandleOwner) | ||
treeland_dock_preview_context_v1_destroy(q_func()->handle()); | ||
} | ||
|
||
inline void destroy() { | ||
Q_ASSERT(m_handle); | ||
Q_ASSERT(map.contains(m_handle)); | ||
Q_EMIT q_func()->beforeDestroy(q_func()); | ||
map.remove(m_handle); | ||
sc.invalidate(); | ||
} | ||
|
||
void on_destroy(void *); | ||
void on_request_show(void *); | ||
|
||
static QHash<void*, TreeLandDockPreviewContextV1*> map; | ||
QW_DECLARE_PUBLIC(TreeLandDockPreviewContextV1) | ||
QWSignalConnector sc; | ||
}; | ||
QHash<void*, TreeLandDockPreviewContextV1*> TreeLandDockPreviewContextV1Private::map; | ||
|
||
void TreeLandDockPreviewContextV1Private::on_destroy(void *) | ||
{ | ||
destroy(); | ||
m_handle = nullptr; | ||
delete q_func(); | ||
} | ||
|
||
void TreeLandDockPreviewContextV1Private::on_request_show(void *data) | ||
{ | ||
Q_EMIT q_func()->requestShow(static_cast<treeland_dock_preview_context_v1_preview_event*>(data)); | ||
} | ||
|
||
TreeLandDockPreviewContextV1::TreeLandDockPreviewContextV1(treeland_dock_preview_context_v1 *handle, bool isOwner) | ||
: QObject(nullptr) | ||
, QWObject(*new TreeLandDockPreviewContextV1Private(handle, isOwner, this)) | ||
{ | ||
|
||
} | ||
|
||
TreeLandDockPreviewContextV1 *TreeLandDockPreviewContextV1::get(treeland_dock_preview_context_v1 *handle) | ||
{ | ||
return TreeLandDockPreviewContextV1Private::map.value(handle); | ||
} | ||
|
||
TreeLandDockPreviewContextV1 *TreeLandDockPreviewContextV1::from(treeland_dock_preview_context_v1 *handle) | ||
{ | ||
if (auto o = get(handle)) | ||
return o; | ||
return new TreeLandDockPreviewContextV1(handle, false); | ||
} | ||
|
||
void TreeLandDockPreviewContextV1::enter() | ||
{ | ||
treeland_dock_preview_context_v1_enter(handle()); | ||
} | ||
|
||
void TreeLandDockPreviewContextV1::leave() | ||
{ | ||
treeland_dock_preview_context_v1_leave(handle()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.