mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-27 01:45:58 +01:00
listener fixes
This commit is contained in:
parent
1455442b9a
commit
98ef43496b
4 changed files with 28 additions and 26 deletions
|
@ -312,7 +312,7 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
||||||
Debug::log(LOG, "Window %x unmapped (class %s)", PWINDOW, g_pXWaylandManager->getAppIDClass(PWINDOW).c_str());
|
Debug::log(LOG, "Window %x unmapped (class %s)", PWINDOW, g_pXWaylandManager->getAppIDClass(PWINDOW).c_str());
|
||||||
|
|
||||||
if (!PWINDOW->m_bIsX11) {
|
if (!PWINDOW->m_bIsX11) {
|
||||||
Debug::log(LOG, "Unregistered late callbacks XDG: %x %x %x %x", &PWINDOW->hyprListener_commitWindow.m_sListener.link, &PWINDOW->hyprListener_setTitleWindow.m_sListener.link, &PWINDOW->hyprListener_fullscreenWindow.m_sListener.link, &PWINDOW->hyprListener_newPopupXDG.m_sListener.link);
|
Debug::log(LOG, "Unregistered late callbacks XDG");
|
||||||
PWINDOW->hyprListener_commitWindow.removeCallback();
|
PWINDOW->hyprListener_commitWindow.removeCallback();
|
||||||
PWINDOW->hyprListener_setTitleWindow.removeCallback();
|
PWINDOW->hyprListener_setTitleWindow.removeCallback();
|
||||||
PWINDOW->hyprListener_fullscreenWindow.removeCallback();
|
PWINDOW->hyprListener_fullscreenWindow.removeCallback();
|
||||||
|
@ -322,7 +322,7 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
||||||
PWINDOW->hyprListener_requestMove.removeCallback();
|
PWINDOW->hyprListener_requestMove.removeCallback();
|
||||||
PWINDOW->hyprListener_requestResize.removeCallback();
|
PWINDOW->hyprListener_requestResize.removeCallback();
|
||||||
} else {
|
} else {
|
||||||
Debug::log(LOG, "Unregistered late callbacks XWL: %x %x %x %x", &PWINDOW->hyprListener_fullscreenWindow.m_sListener.link, &PWINDOW->hyprListener_activateX11.m_sListener.link, &PWINDOW->hyprListener_configureX11.m_sListener.link, &PWINDOW->hyprListener_setTitleWindow.m_sListener.link);
|
Debug::log(LOG, "Unregistered late callbacks XWL");
|
||||||
PWINDOW->hyprListener_fullscreenWindow.removeCallback();
|
PWINDOW->hyprListener_fullscreenWindow.removeCallback();
|
||||||
PWINDOW->hyprListener_activateX11.removeCallback();
|
PWINDOW->hyprListener_activateX11.removeCallback();
|
||||||
PWINDOW->hyprListener_configureX11.removeCallback();
|
PWINDOW->hyprListener_configureX11.removeCallback();
|
||||||
|
|
|
@ -21,9 +21,7 @@ void addSurfaceGlobalOffset(SSurfaceTreeNode* node, int* lx, int* ly) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SSurfaceTreeNode* createTree(wlr_surface* pSurface, CWindow* pWindow) {
|
SSurfaceTreeNode* createTree(wlr_surface* pSurface, CWindow* pWindow) {
|
||||||
SubsurfaceTree::surfaceTreeNodes.push_back(SSurfaceTreeNode());
|
const auto PNODE = &SubsurfaceTree::surfaceTreeNodes.emplace_back();
|
||||||
|
|
||||||
const auto PNODE = &SubsurfaceTree::surfaceTreeNodes.back();
|
|
||||||
|
|
||||||
PNODE->pSurface = pSurface;
|
PNODE->pSurface = pSurface;
|
||||||
PNODE->pWindowOwner = pWindow;
|
PNODE->pWindowOwner = pWindow;
|
||||||
|
@ -128,8 +126,7 @@ void Events::listener_newSubsurfaceNode(void* owner, void* data) {
|
||||||
|
|
||||||
const auto PSUBSURFACE = (wlr_subsurface*)data;
|
const auto PSUBSURFACE = (wlr_subsurface*)data;
|
||||||
|
|
||||||
pNode->childSubsurfaces.push_back(SSubsurface());
|
const auto PNEWSUBSURFACE = &pNode->childSubsurfaces.emplace_back();
|
||||||
const auto PNEWSUBSURFACE = &pNode->childSubsurfaces.back();
|
|
||||||
|
|
||||||
Debug::log(LOG, "Added a new subsurface %x", PSUBSURFACE);
|
Debug::log(LOG, "Added a new subsurface %x", PSUBSURFACE);
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
#include "../debug/Log.hpp"
|
#include "../debug/Log.hpp"
|
||||||
|
|
||||||
void handleWrapped(wl_listener* listener, void* data) {
|
void handleWrapped(wl_listener* listener, void* data) {
|
||||||
CHyprWLListener* pListener = wl_container_of(listener, pListener, m_sListener);
|
CHyprWLListener::SWrapper* pWrap = wl_container_of(listener, pWrap, m_sListener);
|
||||||
|
|
||||||
pListener->emit(data);
|
pWrap->m_pSelf->emit(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function<void(void*, void*)> callback, void* pOwner) {
|
CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function<void(void*, void*)> callback, void* pOwner) {
|
||||||
|
@ -14,7 +14,9 @@ CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function<void(void*, v
|
||||||
}
|
}
|
||||||
|
|
||||||
CHyprWLListener::CHyprWLListener() {
|
CHyprWLListener::CHyprWLListener() {
|
||||||
; //
|
m_swWrapper.m_pSelf = this;
|
||||||
|
m_swWrapper.m_sListener.notify = &handleWrapped;
|
||||||
|
wl_list_init(&m_swWrapper.m_sListener.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHyprWLListener::~CHyprWLListener() {
|
CHyprWLListener::~CHyprWLListener() {
|
||||||
|
@ -22,33 +24,28 @@ CHyprWLListener::~CHyprWLListener() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprWLListener::removeCallback() {
|
void CHyprWLListener::removeCallback() {
|
||||||
if (m_bIsConnected) {
|
if (isConnected()) {
|
||||||
Debug::log(LOG, "Callback %x -> %x, %s removed.", &m_pCallback, &m_pOwner, m_szAuthor.c_str());
|
Debug::log(LOG, "Callback %x -> %x, %s removed.", &m_pCallback, &m_pOwner, m_szAuthor.c_str());
|
||||||
wl_list_remove(&m_sListener.link);
|
wl_list_remove(&m_swWrapper.m_sListener.link);
|
||||||
wl_list_init(&m_sListener.link);
|
wl_list_init(&m_swWrapper.m_sListener.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bIsConnected = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CHyprWLListener::isConnected() {
|
bool CHyprWLListener::isConnected() {
|
||||||
return m_bIsConnected;
|
return !wl_list_empty(&m_swWrapper.m_sListener.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprWLListener::initCallback(wl_signal* pSignal, std::function<void(void*, void*)> callback, void* pOwner, std::string author) {
|
void CHyprWLListener::initCallback(wl_signal* pSignal, std::function<void(void*, void*)> callback, void* pOwner, std::string author) {
|
||||||
if (m_bIsConnected)
|
if (isConnected()) {
|
||||||
removeCallback();
|
Debug::log(ERR, "Tried to connect a listener twice?!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_pOwner = pOwner;
|
m_pOwner = pOwner;
|
||||||
m_pCallback = callback;
|
m_pCallback = callback;
|
||||||
m_szAuthor = author;
|
m_szAuthor = author;
|
||||||
|
|
||||||
m_sListener.notify = &handleWrapped;
|
addWLSignal(pSignal, &m_swWrapper.m_sListener, pOwner, m_szAuthor);
|
||||||
|
|
||||||
m_bIsConnected = true;
|
|
||||||
|
|
||||||
wl_list_init(&m_sListener.link);
|
|
||||||
addWLSignal(pSignal, &m_sListener, pOwner, m_szAuthor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprWLListener::emit(void* data) {
|
void CHyprWLListener::emit(void* data) {
|
||||||
|
|
|
@ -9,18 +9,26 @@ public:
|
||||||
CHyprWLListener();
|
CHyprWLListener();
|
||||||
~CHyprWLListener();
|
~CHyprWLListener();
|
||||||
|
|
||||||
|
CHyprWLListener(const CHyprWLListener&) = delete;
|
||||||
|
CHyprWLListener(CHyprWLListener&&) = delete;
|
||||||
|
CHyprWLListener& operator=(const CHyprWLListener&) = delete;
|
||||||
|
CHyprWLListener& operator=(CHyprWLListener&&) = delete;
|
||||||
|
|
||||||
void initCallback(wl_signal*, std::function<void(void*, void*)>, void* owner, std::string author = "");
|
void initCallback(wl_signal*, std::function<void(void*, void*)>, void* owner, std::string author = "");
|
||||||
|
|
||||||
void removeCallback();
|
void removeCallback();
|
||||||
|
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
|
|
||||||
|
struct SWrapper {
|
||||||
wl_listener m_sListener;
|
wl_listener m_sListener;
|
||||||
|
CHyprWLListener* m_pSelf;
|
||||||
|
};
|
||||||
|
|
||||||
void emit(void*);
|
void emit(void*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_bIsConnected = false;
|
SWrapper m_swWrapper;
|
||||||
|
|
||||||
void* m_pOwner = nullptr;
|
void* m_pOwner = nullptr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue