mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 15:05:59 +01:00
🎉 Wrapped dynamic event handlers
This commit is contained in:
parent
000b16585f
commit
ad4fc28f78
12 changed files with 243 additions and 175 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "includes.hpp"
|
||||
#include "debug/Log.hpp"
|
||||
#include "helpers/MiscFunctions.hpp"
|
||||
#include "helpers/WLListener.hpp"
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define ISDEBUG true
|
||||
|
@ -11,7 +12,8 @@
|
|||
#define RIP(format, ... ) { fprintf(stderr, format "\n", ##__VA_ARGS__); exit(EXIT_FAILURE); }
|
||||
|
||||
#define LISTENER(name) void listener_##name(wl_listener*, void*); inline wl_listener listen_##name = { .notify = listener_##name };
|
||||
#define DYNLISTENER(name) wl_listener listen_##name = { .notify = Events::listener_##name };
|
||||
#define DYNLISTENFUNC(name) void listener_##name(void*, void*);
|
||||
#define DYNLISTENER(name) CHyprWLListener hyprListener_##name;
|
||||
#define DYNMULTILISTENER(name) wl_listener listen_##name;
|
||||
|
||||
#define VECINRECT(vec, x1, y1, x2, y2) (vec.x >= (x1) && vec.x <= (x2) && vec.y >= (y1) && vec.y <= (y2))
|
||||
|
|
|
@ -15,20 +15,20 @@
|
|||
// //
|
||||
// ---------------------------------------------------- //
|
||||
|
||||
void Events::listener_keyboardDestroy(wl_listener* listener, void* data) {
|
||||
SKeyboard* PKEYBOARD = wl_container_of(listener, PKEYBOARD, listen_keyboardDestroy);
|
||||
void Events::listener_keyboardDestroy(void* owner, void* data) {
|
||||
SKeyboard* PKEYBOARD = (SKeyboard*)owner;
|
||||
g_pInputManager->destroyKeyboard(PKEYBOARD);
|
||||
|
||||
Debug::log(LOG, "Destroyed keyboard %x", PKEYBOARD);
|
||||
}
|
||||
|
||||
void Events::listener_keyboardKey(wl_listener* listener, void* data) {
|
||||
SKeyboard* PKEYBOARD = wl_container_of(listener, PKEYBOARD, listen_keyboardKey);
|
||||
void Events::listener_keyboardKey(void* owner, void* data) {
|
||||
SKeyboard* PKEYBOARD = (SKeyboard*)owner;
|
||||
g_pInputManager->onKeyboardKey((wlr_keyboard_key_event*)data, PKEYBOARD);
|
||||
}
|
||||
|
||||
void Events::listener_keyboardMod(wl_listener* listener, void* data) {
|
||||
SKeyboard* PKEYBOARD = wl_container_of(listener, PKEYBOARD, listen_keyboardMod);
|
||||
void Events::listener_keyboardMod(void* owner, void* data) {
|
||||
SKeyboard* PKEYBOARD = (SKeyboard*)owner;
|
||||
g_pInputManager->onKeyboardMod(data, PKEYBOARD);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,41 +14,41 @@ namespace Events {
|
|||
|
||||
// Layer events
|
||||
LISTENER(newLayerSurface);
|
||||
LISTENER(destroyLayerSurface);
|
||||
LISTENER(mapLayerSurface);
|
||||
LISTENER(unmapLayerSurface);
|
||||
LISTENER(commitLayerSurface);
|
||||
DYNLISTENFUNC(destroyLayerSurface);
|
||||
DYNLISTENFUNC(mapLayerSurface);
|
||||
DYNLISTENFUNC(unmapLayerSurface);
|
||||
DYNLISTENFUNC(commitLayerSurface);
|
||||
|
||||
// Subsurfaces
|
||||
LISTENER(newSubsurfaceNode);
|
||||
LISTENER(destroySubsurfaceNode);
|
||||
LISTENER(mapSubsurface);
|
||||
LISTENER(unmapSubsurface);
|
||||
LISTENER(destroySubsurface);
|
||||
LISTENER(commitSubsurface);
|
||||
DYNLISTENFUNC(newSubsurfaceNode);
|
||||
DYNLISTENFUNC(destroySubsurfaceNode);
|
||||
DYNLISTENFUNC(mapSubsurface);
|
||||
DYNLISTENFUNC(unmapSubsurface);
|
||||
DYNLISTENFUNC(destroySubsurface);
|
||||
DYNLISTENFUNC(commitSubsurface);
|
||||
|
||||
// Popups
|
||||
LISTENER(newPopup); // LayerSurface
|
||||
DYNLISTENFUNC(newPopup); // LayerSurface
|
||||
|
||||
LISTENER(newPopupXDG);
|
||||
LISTENER(mapPopupXDG);
|
||||
LISTENER(unmapPopupXDG);
|
||||
LISTENER(destroyPopupXDG);
|
||||
LISTENER(commitPopupXDG);
|
||||
LISTENER(newPopupFromPopupXDG);
|
||||
DYNLISTENFUNC(newPopupXDG);
|
||||
DYNLISTENFUNC(mapPopupXDG);
|
||||
DYNLISTENFUNC(unmapPopupXDG);
|
||||
DYNLISTENFUNC(destroyPopupXDG);
|
||||
DYNLISTENFUNC(commitPopupXDG);
|
||||
DYNLISTENFUNC(newPopupFromPopupXDG);
|
||||
|
||||
// Surface XDG (window)
|
||||
LISTENER(newXDGSurface);
|
||||
|
||||
// Window events
|
||||
LISTENER(commitWindow);
|
||||
LISTENER(mapWindow);
|
||||
LISTENER(unmapWindow);
|
||||
LISTENER(destroyWindow);
|
||||
LISTENER(setTitleWindow);
|
||||
LISTENER(fullscreenWindow);
|
||||
LISTENER(activateX11);
|
||||
LISTENER(configureX11);
|
||||
DYNLISTENFUNC(commitWindow);
|
||||
DYNLISTENFUNC(mapWindow);
|
||||
DYNLISTENFUNC(unmapWindow);
|
||||
DYNLISTENFUNC(destroyWindow);
|
||||
DYNLISTENFUNC(setTitleWindow);
|
||||
DYNLISTENFUNC(fullscreenWindow);
|
||||
DYNLISTENFUNC(activateX11);
|
||||
DYNLISTENFUNC(configureX11);
|
||||
|
||||
// Window subsurfaces
|
||||
// LISTENER(newSubsurfaceWindow);
|
||||
|
@ -62,23 +62,23 @@ namespace Events {
|
|||
|
||||
LISTENER(newInput);
|
||||
|
||||
LISTENER(keyboardKey);
|
||||
LISTENER(keyboardMod);
|
||||
LISTENER(keyboardDestroy);
|
||||
DYNLISTENFUNC(keyboardKey);
|
||||
DYNLISTENFUNC(keyboardMod);
|
||||
DYNLISTENFUNC(keyboardDestroy);
|
||||
|
||||
// Various
|
||||
LISTENER(requestMouse);
|
||||
LISTENER(requestSetSel);
|
||||
LISTENER(requestSetPrimarySel);
|
||||
LISTENER(activate);
|
||||
DYNLISTENFUNC(activate);
|
||||
|
||||
// outputMgr
|
||||
LISTENER(outputMgrApply);
|
||||
LISTENER(outputMgrTest);
|
||||
|
||||
// Monitor part 2 the sequel
|
||||
LISTENER(monitorFrame);
|
||||
LISTENER(monitorDestroy);
|
||||
DYNLISTENFUNC(monitorFrame);
|
||||
DYNLISTENFUNC(monitorDestroy);
|
||||
|
||||
// XWayland
|
||||
LISTENER(readyXWayland);
|
||||
|
|
|
@ -39,11 +39,11 @@ void Events::listener_newLayerSurface(wl_listener* listener, void* data) {
|
|||
WLRLAYERSURFACE->output = g_pCompositor->m_lMonitors.front().output; // TODO: current mon
|
||||
}
|
||||
|
||||
addWLSignal(&WLRLAYERSURFACE->surface->events.commit, &layerSurface->listen_commitLayerSurface, layerSurface, "layerSurface");
|
||||
addWLSignal(&WLRLAYERSURFACE->surface->events.destroy, &layerSurface->listen_destroyLayerSurface, layerSurface, "layerSurface");
|
||||
addWLSignal(&WLRLAYERSURFACE->events.map, &layerSurface->listen_mapLayerSurface, layerSurface, "layerSurface");
|
||||
addWLSignal(&WLRLAYERSURFACE->events.unmap, &layerSurface->listen_unmapLayerSurface, layerSurface, "layerSurface");
|
||||
addWLSignal(&WLRLAYERSURFACE->events.new_popup, &layerSurface->listen_newPopup, layerSurface, "layerSurface");
|
||||
layerSurface->hyprListener_commitLayerSurface.initCallback(&WLRLAYERSURFACE->surface->events.commit, &Events::listener_commitLayerSurface, layerSurface, "layerSurface");
|
||||
layerSurface->hyprListener_destroyLayerSurface.initCallback(&WLRLAYERSURFACE->surface->events.destroy, &Events::listener_destroyLayerSurface, layerSurface, "layerSurface");
|
||||
layerSurface->hyprListener_mapLayerSurface.initCallback(&WLRLAYERSURFACE->events.map, &Events::listener_mapLayerSurface, layerSurface, "layerSurface");
|
||||
layerSurface->hyprListener_unmapLayerSurface.initCallback(&WLRLAYERSURFACE->events.unmap, &Events::listener_unmapLayerSurface, layerSurface, "layerSurface");
|
||||
layerSurface->hyprListener_newPopup.initCallback(&WLRLAYERSURFACE->events.new_popup, &Events::listener_newPopup, layerSurface, "layerSurface");
|
||||
|
||||
layerSurface->layerSurface = WLRLAYERSURFACE;
|
||||
layerSurface->layer = WLRLAYERSURFACE->current.layer;
|
||||
|
@ -53,8 +53,8 @@ void Events::listener_newLayerSurface(wl_listener* listener, void* data) {
|
|||
Debug::log(LOG, "LayerSurface %x (namespace %s layer %d) created on monitor %s", layerSurface->layerSurface, layerSurface->layerSurface->_namespace, layerSurface->layer, PMONITOR->szName.c_str());
|
||||
}
|
||||
|
||||
void Events::listener_destroyLayerSurface(wl_listener* listener, void* data) {
|
||||
SLayerSurface* layersurface = wl_container_of(listener, layersurface, listen_destroyLayerSurface);
|
||||
void Events::listener_destroyLayerSurface(void* owner, void* data) {
|
||||
SLayerSurface* layersurface = (SLayerSurface*)owner;
|
||||
|
||||
Debug::log(LOG, "LayerSurface %x destroyed", layersurface->layerSurface);
|
||||
|
||||
|
@ -64,10 +64,11 @@ void Events::listener_destroyLayerSurface(wl_listener* listener, void* data) {
|
|||
if (layersurface->layerSurface->surface == g_pCompositor->m_pLastFocus)
|
||||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
|
||||
wl_list_remove(&layersurface->listen_destroyLayerSurface.link);
|
||||
wl_list_remove(&layersurface->listen_mapLayerSurface.link);
|
||||
wl_list_remove(&layersurface->listen_unmapLayerSurface.link);
|
||||
wl_list_remove(&layersurface->listen_commitLayerSurface.link);
|
||||
layersurface->hyprListener_commitLayerSurface.removeCallback();
|
||||
layersurface->hyprListener_destroyLayerSurface.removeCallback();
|
||||
layersurface->hyprListener_mapLayerSurface.removeCallback();
|
||||
layersurface->hyprListener_unmapLayerSurface.removeCallback();
|
||||
layersurface->hyprListener_newPopup.removeCallback();
|
||||
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(layersurface->monitorID);
|
||||
|
||||
|
@ -82,8 +83,8 @@ void Events::listener_destroyLayerSurface(wl_listener* listener, void* data) {
|
|||
}
|
||||
}
|
||||
|
||||
void Events::listener_mapLayerSurface(wl_listener* listener, void* data) {
|
||||
SLayerSurface* layersurface = wl_container_of(listener, layersurface, listen_mapLayerSurface);
|
||||
void Events::listener_mapLayerSurface(void* owner, void* data) {
|
||||
SLayerSurface* layersurface = (SLayerSurface*)owner;
|
||||
|
||||
Debug::log(LOG, "LayerSurface %x mapped", layersurface->layerSurface);
|
||||
|
||||
|
@ -111,8 +112,8 @@ void Events::listener_mapLayerSurface(wl_listener* listener, void* data) {
|
|||
layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y);
|
||||
}
|
||||
|
||||
void Events::listener_unmapLayerSurface(wl_listener* listener, void* data) {
|
||||
SLayerSurface* layersurface = wl_container_of(listener, layersurface, listen_unmapLayerSurface);
|
||||
void Events::listener_unmapLayerSurface(void* owner, void* data) {
|
||||
SLayerSurface* layersurface = (SLayerSurface*)owner;
|
||||
|
||||
Debug::log(LOG, "LayerSurface %x unmapped", layersurface->layerSurface);
|
||||
|
||||
|
@ -123,8 +124,8 @@ void Events::listener_unmapLayerSurface(wl_listener* listener, void* data) {
|
|||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
}
|
||||
|
||||
void Events::listener_commitLayerSurface(wl_listener* listener, void* data) {
|
||||
SLayerSurface* layersurface = wl_container_of(listener, layersurface, listen_commitLayerSurface);
|
||||
void Events::listener_commitLayerSurface(void* owner, void* data) {
|
||||
SLayerSurface* layersurface = (SLayerSurface*)owner;
|
||||
|
||||
if (!layersurface->layerSurface || !layersurface->layerSurface->output)
|
||||
return;
|
||||
|
|
|
@ -79,8 +79,8 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
|
|||
g_pCompositor->m_lMonitors.push_back(newMonitor);
|
||||
//
|
||||
|
||||
addWLSignal(&OUTPUT->events.frame, &g_pCompositor->m_lMonitors.back().listen_monitorFrame, &g_pCompositor->m_lMonitors.back(), "Monitor");
|
||||
addWLSignal(&OUTPUT->events.destroy, &g_pCompositor->m_lMonitors.back().listen_monitorDestroy, &g_pCompositor->m_lMonitors.back(), "Monitor");
|
||||
g_pCompositor->m_lMonitors.back().hyprListener_monitorFrame.initCallback(&OUTPUT->events.frame, &Events::listener_monitorFrame, &g_pCompositor->m_lMonitors.back());
|
||||
g_pCompositor->m_lMonitors.back().hyprListener_monitorDestroy.initCallback(&OUTPUT->events.destroy, &Events::listener_monitorDestroy, &g_pCompositor->m_lMonitors.back());
|
||||
|
||||
wlr_output_enable(OUTPUT, 1);
|
||||
if (!wlr_output_commit(OUTPUT)) {
|
||||
|
@ -95,8 +95,8 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
|
|||
Debug::log(LOG, "Added new monitor with name %s at %i,%i with size %ix%i@%i, pointer %x", OUTPUT->name, (int)monitorRule.offset.x, (int)monitorRule.offset.y, (int)monitorRule.resolution.x, (int)monitorRule.resolution.y, (int)monitorRule.refreshRate, OUTPUT);
|
||||
}
|
||||
|
||||
void Events::listener_monitorFrame(wl_listener* listener, void* data) {
|
||||
SMonitor* const PMONITOR = wl_container_of(listener, PMONITOR, listen_monitorFrame);
|
||||
void Events::listener_monitorFrame(void* owner, void* data) {
|
||||
SMonitor* const PMONITOR = (SMonitor*)owner;
|
||||
|
||||
// Hack: only check when monitor number 1 refreshes, saves a bit of resources.
|
||||
// This is for stuff that should be run every frame
|
||||
|
@ -125,7 +125,7 @@ void Events::listener_monitorFrame(wl_listener* listener, void* data) {
|
|||
wlr_output_commit(PMONITOR->output);
|
||||
}
|
||||
|
||||
void Events::listener_monitorDestroy(wl_listener* listener, void* data) {
|
||||
void Events::listener_monitorDestroy(void* owner, void* data) {
|
||||
const auto OUTPUT = (wlr_output*)data;
|
||||
|
||||
SMonitor* pMonitor = nullptr;
|
||||
|
|
|
@ -43,15 +43,10 @@ void addPopupGlobalCoords(void* pPopup, int* x, int* y) {
|
|||
void createNewPopup(wlr_xdg_popup* popup, SXDGPopup* pHyprPopup) {
|
||||
pHyprPopup->popup = popup;
|
||||
|
||||
pHyprPopup->listen_mapPopupXDG.notify = Events::listener_mapPopupXDG;
|
||||
pHyprPopup->listen_unmapPopupXDG.notify = Events::listener_unmapPopupXDG;
|
||||
pHyprPopup->listen_destroyPopupXDG.notify = Events::listener_destroyPopupXDG;
|
||||
pHyprPopup->listen_newPopupFromPopupXDG.notify = Events::listener_newPopupXDG;
|
||||
|
||||
addWLSignal(&popup->base->events.map, &pHyprPopup->listen_mapPopupXDG, pHyprPopup, "HyprPopup");
|
||||
addWLSignal(&popup->base->events.unmap, &pHyprPopup->listen_unmapPopupXDG, pHyprPopup, "HyprPopup");
|
||||
addWLSignal(&popup->base->surface->events.destroy, &pHyprPopup->listen_destroyPopupXDG, pHyprPopup, "HyprPopup");
|
||||
addWLSignal(&popup->base->events.new_popup, &pHyprPopup->listen_newPopupFromPopupXDG, pHyprPopup, "HyprPopup");
|
||||
pHyprPopup->hyprListener_destroyPopupXDG.initCallback(&popup->base->surface->events.destroy, &Events::listener_destroyPopupXDG, pHyprPopup, "HyprPopup");
|
||||
pHyprPopup->hyprListener_mapPopupXDG.initCallback(&popup->base->events.map, &Events::listener_mapPopupXDG, pHyprPopup, "HyprPopup");
|
||||
pHyprPopup->hyprListener_unmapPopupXDG.initCallback(&popup->base->events.unmap, &Events::listener_unmapPopupXDG, pHyprPopup, "HyprPopup");
|
||||
pHyprPopup->hyprListener_newPopupFromPopupXDG.initCallback(&popup->base->events.new_popup, &Events::listener_newPopupFromPopupXDG, pHyprPopup, "HyprPopup");
|
||||
|
||||
const auto PMONITOR = g_pCompositor->m_pLastMonitor;
|
||||
|
||||
|
@ -60,8 +55,8 @@ void createNewPopup(wlr_xdg_popup* popup, SXDGPopup* pHyprPopup) {
|
|||
wlr_xdg_popup_unconstrain_from_box(popup, &box);
|
||||
}
|
||||
|
||||
void Events::listener_newPopup(wl_listener* listener, void* data) {
|
||||
SLayerSurface* layersurface = wl_container_of(listener, layersurface, listen_newPopup);
|
||||
void Events::listener_newPopup(void* owner, void* data) {
|
||||
SLayerSurface* layersurface = (SLayerSurface*)owner;
|
||||
|
||||
Debug::log(LOG, "New layer popup created from surface %x", layersurface);
|
||||
|
||||
|
@ -76,8 +71,8 @@ void Events::listener_newPopup(wl_listener* listener, void* data) {
|
|||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||
}
|
||||
|
||||
void Events::listener_newPopupXDG(wl_listener* listener, void* data) {
|
||||
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_newPopupXDG);
|
||||
void Events::listener_newPopupXDG(void* owner, void* data) {
|
||||
CWindow* PWINDOW = (CWindow*)owner;
|
||||
|
||||
Debug::log(LOG, "New layer popup created from XDG window %x -> %s", PWINDOW, PWINDOW->m_szTitle.c_str());
|
||||
|
||||
|
@ -92,8 +87,8 @@ void Events::listener_newPopupXDG(wl_listener* listener, void* data) {
|
|||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||
}
|
||||
|
||||
void Events::listener_newPopupFromPopupXDG(wl_listener* listener, void* data) {
|
||||
SXDGPopup* PPOPUP = wl_container_of(listener, PPOPUP, listen_newPopupFromPopupXDG);
|
||||
void Events::listener_newPopupFromPopupXDG(void* owner, void* data) {
|
||||
SXDGPopup* PPOPUP = (SXDGPopup*)owner;
|
||||
|
||||
Debug::log(LOG, "New layer popup created from XDG popup %x -> %s", PPOPUP, PPOPUP->parentWindow->m_szTitle.c_str());
|
||||
|
||||
|
@ -110,8 +105,8 @@ void Events::listener_newPopupFromPopupXDG(wl_listener* listener, void* data) {
|
|||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||
}
|
||||
|
||||
void Events::listener_mapPopupXDG(wl_listener* listener, void* data) {
|
||||
SXDGPopup* PPOPUP = wl_container_of(listener, PPOPUP, listen_mapPopupXDG);
|
||||
void Events::listener_mapPopupXDG(void* owner, void* data) {
|
||||
SXDGPopup* PPOPUP = (SXDGPopup*)owner;
|
||||
|
||||
Debug::log(LOG, "New XDG Popup mapped");
|
||||
|
||||
|
@ -120,8 +115,8 @@ void Events::listener_mapPopupXDG(wl_listener* listener, void* data) {
|
|||
Debug::log(LOG, "XDG Popup got assigned a surfaceTreeNode %x", PPOPUP->pSurfaceTree);
|
||||
}
|
||||
|
||||
void Events::listener_unmapPopupXDG(wl_listener* listener, void* data) {
|
||||
SXDGPopup* PPOPUP = wl_container_of(listener, PPOPUP, listen_unmapPopupXDG);
|
||||
void Events::listener_unmapPopupXDG(void* owner, void* data) {
|
||||
SXDGPopup* PPOPUP = (SXDGPopup*)owner;
|
||||
Debug::log(LOG, "XDG Popup unmapped");
|
||||
|
||||
SubsurfaceTree::destroySurfaceTree(PPOPUP->pSurfaceTree);
|
||||
|
@ -129,8 +124,8 @@ void Events::listener_unmapPopupXDG(wl_listener* listener, void* data) {
|
|||
PPOPUP->pSurfaceTree = nullptr;
|
||||
}
|
||||
|
||||
void Events::listener_destroyPopupXDG(wl_listener* listener, void* data) {
|
||||
SXDGPopup* PPOPUP = wl_container_of(listener, PPOPUP, listen_destroyPopupXDG);
|
||||
void Events::listener_destroyPopupXDG(void* owner, void* data) {
|
||||
SXDGPopup* PPOPUP = (SXDGPopup*)owner;
|
||||
|
||||
Debug::log(LOG, "Destroyed popup XDG %x", PPOPUP);
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ void addViewCoords(void* pWindow, int* x, int* y) {
|
|||
*y += PWINDOW->m_vEffectivePosition.y;
|
||||
}
|
||||
|
||||
void Events::listener_mapWindow(wl_listener* listener, void* data) {
|
||||
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_mapWindow);
|
||||
void Events::listener_mapWindow(void* owner, void* data) {
|
||||
CWindow* PWINDOW = (CWindow*)owner;
|
||||
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromCursor();
|
||||
PWINDOW->m_iMonitorID = PMONITOR->ID;
|
||||
|
@ -115,37 +115,37 @@ void Events::listener_mapWindow(wl_listener* listener, void* data) {
|
|||
Debug::log(LOG, "Window got assigned a surfaceTreeNode %x", PWINDOW->m_pSurfaceTree);
|
||||
|
||||
if (!PWINDOW->m_bIsX11) {
|
||||
addWLSignal(&PWINDOW->m_uSurface.xdg->surface->events.commit, &PWINDOW->listen_commitWindow, PWINDOW, "XDG Window Late");
|
||||
addWLSignal(&PWINDOW->m_uSurface.xdg->toplevel->events.set_title, &PWINDOW->listen_setTitleWindow, PWINDOW, "XDG Window Late");
|
||||
addWLSignal(&PWINDOW->m_uSurface.xdg->toplevel->events.request_fullscreen, &PWINDOW->listen_fullscreenWindow, PWINDOW, "XDG Window Late");
|
||||
addWLSignal(&PWINDOW->m_uSurface.xdg->events.new_popup, &PWINDOW->listen_newPopupXDG, PWINDOW, "XDG Window Late");
|
||||
PWINDOW->hyprListener_commitWindow.initCallback(&PWINDOW->m_uSurface.xdg->surface->events.commit, &Events::listener_commitWindow, PWINDOW, "XDG Window Late");
|
||||
PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XDG Window Late");
|
||||
PWINDOW->hyprListener_fullscreenWindow.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_fullscreen, &Events::listener_fullscreenWindow, PWINDOW, "XDG Window Late");
|
||||
PWINDOW->hyprListener_newPopupXDG.initCallback(&PWINDOW->m_uSurface.xdg->events.new_popup, &Events::listener_newPopupXDG, PWINDOW, "XDG Window Late");
|
||||
} else {
|
||||
addWLSignal(&PWINDOW->m_uSurface.xwayland->events.request_fullscreen, &PWINDOW->listen_fullscreenWindow, PWINDOW, "XWayland Window Late");
|
||||
addWLSignal(&PWINDOW->m_uSurface.xwayland->events.request_activate, &PWINDOW->listen_activateX11, PWINDOW, "XWayland Window Late");
|
||||
addWLSignal(&PWINDOW->m_uSurface.xwayland->events.request_configure, &PWINDOW->listen_configureX11, PWINDOW, "XWayland Window Late");
|
||||
addWLSignal(&PWINDOW->m_uSurface.xwayland->events.set_title, &PWINDOW->listen_setTitleWindow, PWINDOW, "XWayland Window Late");
|
||||
PWINDOW->hyprListener_fullscreenWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_fullscreen, &Events::listener_fullscreenWindow, PWINDOW, "XWayland Window Late");
|
||||
PWINDOW->hyprListener_activateX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_activate, &Events::listener_activateX11, PWINDOW, "XWayland Window Late");
|
||||
PWINDOW->hyprListener_configureX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_configure, &Events::listener_configureX11, PWINDOW, "XWayland Window Late");
|
||||
PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XWayland Window Late");
|
||||
}
|
||||
|
||||
Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vEffectivePosition.x, PWINDOW->m_vEffectivePosition.y, PWINDOW->m_vEffectiveSize.x, PWINDOW->m_vEffectiveSize.y);
|
||||
}
|
||||
|
||||
void Events::listener_unmapWindow(wl_listener* listener, void* data) {
|
||||
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_unmapWindow);
|
||||
void Events::listener_unmapWindow(void* owner, void* data) {
|
||||
CWindow* PWINDOW = (CWindow*)owner;
|
||||
|
||||
Debug::log(LOG, "Window %x unmapped", PWINDOW);
|
||||
|
||||
if (!PWINDOW->m_bIsX11) {
|
||||
wl_list_remove(&PWINDOW->listen_commitWindow.link);
|
||||
wl_list_remove(&PWINDOW->listen_setTitleWindow.link);
|
||||
wl_list_remove(&PWINDOW->listen_fullscreenWindow.link);
|
||||
wl_list_remove(&PWINDOW->listen_newPopupXDG.link);
|
||||
Debug::log(LOG, "Unregistered late callbacks XDG: %x %x %x %x", &PWINDOW->listen_commitWindow.link, &PWINDOW->listen_setTitleWindow.link, &PWINDOW->listen_fullscreenWindow.link, &PWINDOW->listen_newPopupXDG.link);
|
||||
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);
|
||||
PWINDOW->hyprListener_commitWindow.removeCallback();
|
||||
PWINDOW->hyprListener_setTitleWindow.removeCallback();
|
||||
PWINDOW->hyprListener_fullscreenWindow.removeCallback();
|
||||
PWINDOW->hyprListener_newPopupXDG.removeCallback();
|
||||
} else {
|
||||
wl_list_remove(&PWINDOW->listen_fullscreenWindow.link);
|
||||
wl_list_remove(&PWINDOW->listen_activateX11.link);
|
||||
wl_list_remove(&PWINDOW->listen_configureX11.link);
|
||||
wl_list_remove(&PWINDOW->listen_setTitleWindow.link);
|
||||
Debug::log(LOG, "Unregistered late callbacks XWL: %x %x %x %x", &PWINDOW->listen_fullscreenWindow.link, &PWINDOW->listen_activateX11.link, &PWINDOW->listen_configureX11.link, &PWINDOW->listen_setTitleWindow.link);
|
||||
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);
|
||||
PWINDOW->hyprListener_fullscreenWindow.removeCallback();
|
||||
PWINDOW->hyprListener_activateX11.removeCallback();
|
||||
PWINDOW->hyprListener_configureX11.removeCallback();
|
||||
PWINDOW->hyprListener_setTitleWindow.removeCallback();
|
||||
}
|
||||
|
||||
if (g_pXWaylandManager->getWindowSurface(PWINDOW) == g_pCompositor->m_pLastFocus)
|
||||
|
@ -173,23 +173,23 @@ void Events::listener_unmapWindow(wl_listener* listener, void* data) {
|
|||
PWINDOW->m_pSurfaceTree = nullptr;
|
||||
}
|
||||
|
||||
void Events::listener_commitWindow(wl_listener* listener, void* data) {
|
||||
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_commitWindow);
|
||||
void Events::listener_commitWindow(void* owner, void* data) {
|
||||
CWindow* PWINDOW = (CWindow*)owner;
|
||||
|
||||
// Debug::log(LOG, "Window %x committed", PWINDOW); // SPAM!
|
||||
// Debug::log(LOG, "Window %x committed", PWINDOW); // SPAM!
|
||||
}
|
||||
|
||||
void Events::listener_destroyWindow(wl_listener* listener, void* data) {
|
||||
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_destroyWindow);
|
||||
void Events::listener_destroyWindow(void* owner, void* data) {
|
||||
CWindow* PWINDOW = (CWindow*)owner;
|
||||
|
||||
Debug::log(LOG, "Window %x destroyed", PWINDOW);
|
||||
|
||||
if (g_pXWaylandManager->getWindowSurface(PWINDOW) == g_pCompositor->m_pLastFocus)
|
||||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
|
||||
wl_list_remove(&PWINDOW->listen_mapWindow.link);
|
||||
wl_list_remove(&PWINDOW->listen_unmapWindow.link);
|
||||
wl_list_remove(&PWINDOW->listen_destroyWindow.link);
|
||||
PWINDOW->hyprListener_mapWindow.removeCallback();
|
||||
PWINDOW->hyprListener_unmapWindow.removeCallback();
|
||||
PWINDOW->hyprListener_destroyWindow.removeCallback();
|
||||
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW);
|
||||
|
||||
|
@ -201,8 +201,8 @@ void Events::listener_destroyWindow(wl_listener* listener, void* data) {
|
|||
g_pCompositor->removeWindowFromVectorSafe(PWINDOW);
|
||||
}
|
||||
|
||||
void Events::listener_setTitleWindow(wl_listener* listener, void* data) {
|
||||
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_setTitleWindow);
|
||||
void Events::listener_setTitleWindow(void* owner, void* data) {
|
||||
CWindow* PWINDOW = (CWindow*)owner;
|
||||
|
||||
if (!g_pCompositor->windowValidMapped(PWINDOW))
|
||||
return;
|
||||
|
@ -212,28 +212,28 @@ void Events::listener_setTitleWindow(wl_listener* listener, void* data) {
|
|||
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
||||
}
|
||||
|
||||
void Events::listener_fullscreenWindow(wl_listener* listener, void* data) {
|
||||
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_fullscreenWindow);
|
||||
void Events::listener_fullscreenWindow(void* owner, void* data) {
|
||||
CWindow* PWINDOW = (CWindow*)owner;
|
||||
|
||||
Debug::log(LOG, "Window %x fullscreen to %i", PWINDOW, PWINDOW->m_bIsFullscreen);
|
||||
|
||||
g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PWINDOW);
|
||||
}
|
||||
|
||||
void Events::listener_activate(wl_listener* listener, void* data) {
|
||||
void Events::listener_activate(void* owner, void* data) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Events::listener_activateX11(wl_listener* listener, void* data) {
|
||||
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_activateX11);
|
||||
void Events::listener_activateX11(void* owner, void* data) {
|
||||
CWindow* PWINDOW = (CWindow*)owner;
|
||||
|
||||
if (PWINDOW->m_iX11Type == 1 /* Managed */) {
|
||||
wlr_xwayland_surface_activate(PWINDOW->m_uSurface.xwayland, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void Events::listener_configureX11(wl_listener* listener, void* data) {
|
||||
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_configureX11);
|
||||
void Events::listener_configureX11(void* owner, void* data) {
|
||||
CWindow* PWINDOW = (CWindow*)owner;
|
||||
|
||||
const auto E = (wlr_xwayland_surface_configure_event*)data;
|
||||
|
||||
|
@ -253,10 +253,9 @@ void Events::listener_surfaceXWayland(wl_listener* listener, void* data) {
|
|||
PNEWWINDOW->m_iX11Type = XWSURFACE->override_redirect ? 2 : 1;
|
||||
PNEWWINDOW->m_bIsX11 = true;
|
||||
|
||||
addWLSignal(&XWSURFACE->events.map, &PNEWWINDOW->listen_mapWindow, PNEWWINDOW, "XWayland Window");
|
||||
addWLSignal(&XWSURFACE->events.unmap, &PNEWWINDOW->listen_unmapWindow, PNEWWINDOW, "XWayland Window");
|
||||
addWLSignal(&XWSURFACE->events.destroy, &PNEWWINDOW->listen_destroyWindow, PNEWWINDOW, "XWayland Window");
|
||||
|
||||
PNEWWINDOW->hyprListener_mapWindow.initCallback(&XWSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XWayland Window");
|
||||
PNEWWINDOW->hyprListener_unmapWindow.initCallback(&XWSURFACE->events.unmap, &Events::listener_unmapWindow, PNEWWINDOW, "XWayland Window");
|
||||
PNEWWINDOW->hyprListener_destroyWindow.initCallback(&XWSURFACE->events.destroy, &Events::listener_destroyWindow, PNEWWINDOW, "XWayland Window");
|
||||
}
|
||||
|
||||
void Events::listener_newXDGSurface(wl_listener* listener, void* data) {
|
||||
|
@ -272,8 +271,7 @@ void Events::listener_newXDGSurface(wl_listener* listener, void* data) {
|
|||
const auto PNEWWINDOW = &g_pCompositor->m_lWindows.back();
|
||||
PNEWWINDOW->m_uSurface.xdg = XDGSURFACE;
|
||||
|
||||
|
||||
addWLSignal(&XDGSURFACE->events.map, &PNEWWINDOW->listen_mapWindow, PNEWWINDOW, "XDG Window");
|
||||
addWLSignal(&XDGSURFACE->events.unmap, &PNEWWINDOW->listen_unmapWindow, PNEWWINDOW, "XDG Window");
|
||||
addWLSignal(&XDGSURFACE->events.destroy, &PNEWWINDOW->listen_destroyWindow, PNEWWINDOW, "XDG Window");
|
||||
PNEWWINDOW->hyprListener_mapWindow.initCallback(&XDGSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XDG Window");
|
||||
PNEWWINDOW->hyprListener_unmapWindow.initCallback(&XDGSURFACE->events.unmap, &Events::listener_unmapWindow, PNEWWINDOW, "XDG Window");
|
||||
PNEWWINDOW->hyprListener_destroyWindow.initCallback(&XDGSURFACE->events.destroy, &Events::listener_destroyWindow, PNEWWINDOW, "XDG Window");
|
||||
}
|
||||
|
|
|
@ -26,13 +26,9 @@ SSurfaceTreeNode* createTree(wlr_surface* pSurface) {
|
|||
|
||||
PNODE->pSurface = pSurface;
|
||||
|
||||
PNODE->listen_newSubsurface.notify = Events::listener_newSubsurfaceNode;
|
||||
PNODE->listen_commit.notify = Events::listener_commitSubsurface;
|
||||
PNODE->listen_destroy.notify = Events::listener_destroySubsurfaceNode;
|
||||
|
||||
addWLSignal(&pSurface->events.commit, &PNODE->listen_commit, PNODE, "SurfaceTreeNode");
|
||||
addWLSignal(&pSurface->events.destroy, &PNODE->listen_destroy, PNODE, "SurfaceTreeNode");
|
||||
addWLSignal(&pSurface->events.new_subsurface, &PNODE->listen_newSubsurface, PNODE, "SurfaceTreeNode");
|
||||
PNODE->hyprListener_newSubsurface.initCallback(&pSurface->events.new_subsurface, &Events::listener_newSubsurfaceNode, PNODE, "SurfaceTreeNode");
|
||||
PNODE->hyprListener_commit.initCallback(&pSurface->events.commit, &Events::listener_commitSubsurface, PNODE, "SurfaceTreeNode");
|
||||
PNODE->hyprListener_destroy.initCallback(&pSurface->events.destroy, &Events::listener_destroySubsurfaceNode, PNODE, "SurfaceTreeNode");
|
||||
|
||||
return PNODE;
|
||||
}
|
||||
|
@ -75,9 +71,9 @@ void SubsurfaceTree::destroySurfaceTree(SSurfaceTreeNode* pNode) {
|
|||
|
||||
pNode->childSubsurfaces.clear();
|
||||
|
||||
wl_list_remove(&pNode->listen_newSubsurface.link);
|
||||
wl_list_remove(&pNode->listen_commit.link);
|
||||
wl_list_remove(&pNode->listen_destroy.link);
|
||||
pNode->hyprListener_commit.removeCallback();
|
||||
pNode->hyprListener_destroy.removeCallback();
|
||||
pNode->hyprListener_newSubsurface.removeCallback();
|
||||
|
||||
Debug::log(LOG, "SurfaceTree Node removed");
|
||||
}
|
||||
|
@ -88,17 +84,17 @@ void destroySubsurface(SSubsurface* pSubsurface) {
|
|||
pSubsurface->pChild = nullptr;
|
||||
}
|
||||
|
||||
wl_list_remove(&pSubsurface->listen_map.link);
|
||||
wl_list_remove(&pSubsurface->listen_unmap.link);
|
||||
wl_list_remove(&pSubsurface->listen_destroy.link);
|
||||
pSubsurface->hyprListener_destroy.removeCallback();
|
||||
pSubsurface->hyprListener_map.removeCallback();
|
||||
pSubsurface->hyprListener_unmap.removeCallback();
|
||||
}
|
||||
|
||||
//
|
||||
// Subsurface listeners
|
||||
//
|
||||
|
||||
void Events::listener_newSubsurfaceNode(wl_listener* listener, void* data) {
|
||||
SSurfaceTreeNode* pNode = wl_container_of(listener, pNode, listen_newSubsurface);
|
||||
void Events::listener_newSubsurfaceNode(void* owner, void* data) {
|
||||
SSurfaceTreeNode* pNode = (SSurfaceTreeNode*)owner;
|
||||
|
||||
const auto PSUBSURFACE = (wlr_subsurface*)data;
|
||||
|
||||
|
@ -110,25 +106,21 @@ void Events::listener_newSubsurfaceNode(wl_listener* listener, void* data) {
|
|||
PNEWSUBSURFACE->pSubsurface = PSUBSURFACE;
|
||||
PNEWSUBSURFACE->pParent = pNode;
|
||||
|
||||
PNEWSUBSURFACE->listen_map.notify = Events::listener_mapSubsurface;
|
||||
PNEWSUBSURFACE->listen_unmap.notify = Events::listener_unmapSubsurface;
|
||||
PNEWSUBSURFACE->listen_destroy.notify = Events::listener_destroySubsurface;
|
||||
|
||||
addWLSignal(&PSUBSURFACE->events.map, &PNEWSUBSURFACE->listen_map, PNEWSUBSURFACE, "Subsurface");
|
||||
addWLSignal(&PSUBSURFACE->events.unmap, &PNEWSUBSURFACE->listen_unmap, PNEWSUBSURFACE, "Subsurface");
|
||||
addWLSignal(&PSUBSURFACE->events.destroy, &PNEWSUBSURFACE->listen_destroy, PNEWSUBSURFACE, "Subsurface");
|
||||
PNEWSUBSURFACE->hyprListener_map.initCallback(&PSUBSURFACE->events.map, &Events::listener_mapSubsurface, PNEWSUBSURFACE, "Subsurface");
|
||||
PNEWSUBSURFACE->hyprListener_unmap.initCallback(&PSUBSURFACE->events.unmap, &Events::listener_unmapLayerSurface, PNEWSUBSURFACE, "Subsurface");
|
||||
PNEWSUBSURFACE->hyprListener_destroy.initCallback(&PSUBSURFACE->events.destroy, &Events::listener_destroySubsurface, PNEWSUBSURFACE, "Subsurface");
|
||||
}
|
||||
|
||||
void Events::listener_mapSubsurface(wl_listener* listener, void* data) {
|
||||
SSubsurface* subsurface = wl_container_of(listener, subsurface, listen_map);
|
||||
void Events::listener_mapSubsurface(void* owner, void* data) {
|
||||
SSubsurface* subsurface = (SSubsurface*)owner;
|
||||
|
||||
Debug::log(LOG, "Subsurface %x mapped", subsurface->pSubsurface);
|
||||
|
||||
subsurface->pChild = createSubsurfaceNode(subsurface->pParent, subsurface, subsurface->pSubsurface->surface);
|
||||
}
|
||||
|
||||
void Events::listener_unmapSubsurface(wl_listener* listener, void* data) {
|
||||
SSubsurface* subsurface = wl_container_of(listener, subsurface, listen_unmap);
|
||||
void Events::listener_unmapSubsurface(void* owner, void* data) {
|
||||
SSubsurface* subsurface = (SSubsurface*)owner;
|
||||
|
||||
Debug::log(LOG, "Subsurface %x unmapped", subsurface);
|
||||
|
||||
|
@ -149,29 +141,29 @@ void Events::listener_unmapSubsurface(wl_listener* listener, void* data) {
|
|||
}
|
||||
}
|
||||
|
||||
void Events::listener_commitSubsurface(wl_listener* listener, void* data) {
|
||||
SSurfaceTreeNode* pNode = wl_container_of(listener, pNode, listen_commit);
|
||||
void Events::listener_commitSubsurface(void* owner, void* data) {
|
||||
SSurfaceTreeNode* pNode = (SSurfaceTreeNode*)owner;
|
||||
}
|
||||
|
||||
void Events::listener_destroySubsurface(wl_listener* listener, void* data) {
|
||||
SSubsurface* subsurface = wl_container_of(listener, subsurface, listen_destroy);
|
||||
void Events::listener_destroySubsurface(void* owner, void* data) {
|
||||
SSubsurface* subsurface = (SSubsurface*)owner;
|
||||
|
||||
Debug::log(LOG, "Subsurface %x destroyed", subsurface);
|
||||
|
||||
subsurface->pParent->childSubsurfaces.remove(*subsurface);
|
||||
}
|
||||
|
||||
void Events::listener_destroySubsurfaceNode(wl_listener* listener, void* data) {
|
||||
SSurfaceTreeNode* pNode = wl_container_of(listener, pNode, listen_destroy);
|
||||
void Events::listener_destroySubsurfaceNode(void* owner, void* data) {
|
||||
SSurfaceTreeNode* pNode = (SSurfaceTreeNode*)owner;
|
||||
|
||||
Debug::log(LOG, "Subsurface Node %x destroyed", pNode);
|
||||
|
||||
for (auto& c : pNode->childSubsurfaces)
|
||||
destroySubsurface(&c);
|
||||
|
||||
wl_list_remove(&pNode->listen_newSubsurface.link);
|
||||
wl_list_remove(&pNode->listen_commit.link);
|
||||
wl_list_remove(&pNode->listen_destroy.link);
|
||||
pNode->hyprListener_commit.removeCallback();
|
||||
pNode->hyprListener_newSubsurface.removeCallback();
|
||||
pNode->hyprListener_destroy.removeCallback();
|
||||
|
||||
SubsurfaceTree::surfaceTreeNodes.remove(*pNode);
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ typedef void (*applyGlobalOffsetFn)(void *, int *, int *);
|
|||
struct SSurfaceTreeNode {
|
||||
wlr_surface* pSurface = nullptr;
|
||||
|
||||
DYNMULTILISTENER(newSubsurface);
|
||||
DYNMULTILISTENER(commit);
|
||||
DYNMULTILISTENER(destroy);
|
||||
DYNLISTENER(newSubsurface);
|
||||
DYNLISTENER(commit);
|
||||
DYNLISTENER(destroy);
|
||||
|
||||
SSurfaceTreeNode* pParent = nullptr;
|
||||
SSubsurface* pSubsurface = nullptr;
|
||||
|
@ -33,9 +33,9 @@ struct SSubsurface {
|
|||
SSurfaceTreeNode* pParent = nullptr;
|
||||
SSurfaceTreeNode* pChild = nullptr;
|
||||
|
||||
DYNMULTILISTENER(map);
|
||||
DYNMULTILISTENER(unmap);
|
||||
DYNMULTILISTENER(destroy);
|
||||
DYNLISTENER(map);
|
||||
DYNLISTENER(unmap);
|
||||
DYNLISTENER(destroy);
|
||||
|
||||
bool operator==(const SSubsurface& rhs) {
|
||||
return pSubsurface == rhs.pSubsurface;
|
||||
|
|
50
src/helpers/WLListener.cpp
Normal file
50
src/helpers/WLListener.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
#include "WLListener.hpp"
|
||||
#include "MiscFunctions.hpp"
|
||||
#include <string>
|
||||
|
||||
void handleWrapped(wl_listener* listener, void* data) {
|
||||
CHyprWLListener* pListener = wl_container_of(listener, pListener, m_sListener);
|
||||
|
||||
pListener->emit(data);
|
||||
}
|
||||
|
||||
CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function<void(void*, void*)> callback, void* pOwner) {
|
||||
initCallback(pSignal, callback, pOwner);
|
||||
}
|
||||
|
||||
CHyprWLListener::CHyprWLListener() {
|
||||
; //
|
||||
}
|
||||
|
||||
CHyprWLListener::~CHyprWLListener() {
|
||||
removeCallback();
|
||||
}
|
||||
|
||||
void CHyprWLListener::removeCallback() {
|
||||
if (m_bIsConnected) {
|
||||
wl_list_remove(&m_sListener.link);
|
||||
wl_list_init(&m_sListener.link);
|
||||
}
|
||||
|
||||
m_bIsConnected = false;
|
||||
}
|
||||
|
||||
bool CHyprWLListener::isConnected() {
|
||||
return m_bIsConnected;
|
||||
}
|
||||
|
||||
void CHyprWLListener::initCallback(wl_signal* pSignal, std::function<void(void*, void*)> callback, void* pOwner, std::string author) {
|
||||
m_pOwner = pOwner;
|
||||
m_pCallback = callback;
|
||||
m_szAuthor = author;
|
||||
|
||||
m_sListener.notify = &handleWrapped;
|
||||
|
||||
m_bIsConnected = true;
|
||||
|
||||
addWLSignal(pSignal, &m_sListener, pOwner, m_szAuthor);
|
||||
}
|
||||
|
||||
void CHyprWLListener::emit(void* data) {
|
||||
m_pCallback(m_pOwner, data);
|
||||
}
|
30
src/helpers/WLListener.hpp
Normal file
30
src/helpers/WLListener.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
|
||||
#include "../includes.hpp"
|
||||
#include <functional>
|
||||
|
||||
class CHyprWLListener {
|
||||
public:
|
||||
CHyprWLListener(wl_signal*, std::function<void(void*, void*)>, void* owner);
|
||||
CHyprWLListener();
|
||||
~CHyprWLListener();
|
||||
|
||||
void initCallback(wl_signal*, std::function<void(void*, void*)>, void* owner, std::string author = "");
|
||||
|
||||
void removeCallback();
|
||||
|
||||
bool isConnected();
|
||||
|
||||
wl_listener m_sListener;
|
||||
|
||||
void emit(void*);
|
||||
|
||||
private:
|
||||
bool m_bIsConnected = false;
|
||||
|
||||
void* m_pOwner = nullptr;
|
||||
|
||||
std::function<void(void*, void*)> m_pCallback = nullptr;
|
||||
|
||||
std::string m_szAuthor = "";
|
||||
};
|
|
@ -137,9 +137,9 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
|
|||
xkb_context_unref(CONTEXT);
|
||||
wlr_keyboard_set_repeat_info(keyboard->keyboard, 25, 600);
|
||||
|
||||
addWLSignal(&keyboard->keyboard->events.modifiers, &PNEWKEYBOARD->listen_keyboardMod, PNEWKEYBOARD, "Keyboard");
|
||||
addWLSignal(&keyboard->keyboard->events.key, &PNEWKEYBOARD->listen_keyboardKey, PNEWKEYBOARD, "Keyboard");
|
||||
addWLSignal(&keyboard->events.destroy, &PNEWKEYBOARD->listen_keyboardDestroy, PNEWKEYBOARD, "Keyboard");
|
||||
PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&keyboard->keyboard->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard");
|
||||
PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&keyboard->keyboard->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard");
|
||||
PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard");
|
||||
|
||||
wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, keyboard->keyboard);
|
||||
|
||||
|
@ -200,9 +200,9 @@ void CInputManager::newMouse(wlr_input_device* mouse) {
|
|||
}
|
||||
|
||||
void CInputManager::destroyKeyboard(SKeyboard* pKeyboard) {
|
||||
wl_list_remove(&pKeyboard->listen_keyboardMod.link);
|
||||
wl_list_remove(&pKeyboard->listen_keyboardKey.link);
|
||||
wl_list_remove(&pKeyboard->listen_keyboardDestroy.link);
|
||||
pKeyboard->hyprListener_keyboardDestroy.removeCallback();
|
||||
pKeyboard->hyprListener_keyboardMod.removeCallback();
|
||||
pKeyboard->hyprListener_keyboardKey.removeCallback();
|
||||
|
||||
m_lKeyboards.remove(*pKeyboard);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue