mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 23:25:59 +01:00
popups handled properly
This commit is contained in:
parent
332fa8a802
commit
decb2f638d
6 changed files with 100 additions and 2 deletions
|
@ -325,3 +325,12 @@ SLayerSurface* CCompositor::getLayerForPopup(SLayerPopup* pPopup) {
|
||||||
|
|
||||||
return CurrentPopup->parentSurface;
|
return CurrentPopup->parentSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CWindow* CCompositor::getWindowForPopup(wlr_xdg_popup* popup) {
|
||||||
|
for (auto& p : m_lXDGPopups) {
|
||||||
|
if (p.popup == popup)
|
||||||
|
return p.parentWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
|
@ -49,6 +49,7 @@ public:
|
||||||
std::list<SMonitor> m_lMonitors;
|
std::list<SMonitor> m_lMonitors;
|
||||||
std::list<CWindow> m_lWindows;
|
std::list<CWindow> m_lWindows;
|
||||||
std::list<SLayerPopup> m_lLayerPopups;
|
std::list<SLayerPopup> m_lLayerPopups;
|
||||||
|
std::list<SXDGPopup> m_lXDGPopups;
|
||||||
|
|
||||||
void startCompositor();
|
void startCompositor();
|
||||||
|
|
||||||
|
@ -70,6 +71,7 @@ public:
|
||||||
CWindow* windowFloatingFromCursor();
|
CWindow* windowFloatingFromCursor();
|
||||||
SMonitor* getMonitorFromOutput(wlr_output*);
|
SMonitor* getMonitorFromOutput(wlr_output*);
|
||||||
SLayerSurface* getLayerForPopup(SLayerPopup*);
|
SLayerSurface* getLayerForPopup(SLayerPopup*);
|
||||||
|
CWindow* getWindowForPopup(wlr_xdg_popup*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initAllSignals();
|
void initAllSignals();
|
||||||
|
|
|
@ -13,6 +13,7 @@ public:
|
||||||
DYNLISTENER(destroyWindow);
|
DYNLISTENER(destroyWindow);
|
||||||
DYNLISTENER(setTitleWindow);
|
DYNLISTENER(setTitleWindow);
|
||||||
DYNLISTENER(fullscreenWindow);
|
DYNLISTENER(fullscreenWindow);
|
||||||
|
DYNLISTENER(newPopupXDG);
|
||||||
|
|
||||||
union {
|
union {
|
||||||
wlr_xdg_surface* xdg;
|
wlr_xdg_surface* xdg;
|
||||||
|
|
|
@ -321,7 +321,7 @@ void createNewPopup(wlr_xdg_popup* popup, void* parent, bool parentIsLayer) {
|
||||||
const auto PLAYER = g_pCompositor->getLayerForPopup(PNEWPOPUP);
|
const auto PLAYER = g_pCompositor->getLayerForPopup(PNEWPOPUP);
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromOutput(PLAYER->layerSurface->output);
|
const auto PMONITOR = g_pCompositor->getMonitorFromOutput(PLAYER->layerSurface->output);
|
||||||
|
|
||||||
wlr_box box = { .x = -PLAYER->geometry.x, .y = -PLAYER->geometry.y, .width = PMONITOR->vecSize.x, .height = PMONITOR->vecSize.y };
|
wlr_box box = {.x = PMONITOR->vecPosition.x, .y = PMONITOR->vecPosition.y, .width = PMONITOR->vecSize.x, .height = PMONITOR->vecSize.y};
|
||||||
|
|
||||||
wlr_xdg_popup_unconstrain_from_box(PNEWPOPUP->popup, &box);
|
wlr_xdg_popup_unconstrain_from_box(PNEWPOPUP->popup, &box);
|
||||||
}
|
}
|
||||||
|
@ -379,6 +379,74 @@ void Events::listener_commitPopup(wl_listener* listener, void* data) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void createNewPopupXDG(wlr_xdg_popup* popup, void* parent, bool parentIsWindow) {
|
||||||
|
if (!popup)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_pCompositor->m_lXDGPopups.push_back(SXDGPopup());
|
||||||
|
const auto PNEWPOPUP = &g_pCompositor->m_lXDGPopups.back();
|
||||||
|
|
||||||
|
PNEWPOPUP->popup = popup;
|
||||||
|
if (parentIsWindow)
|
||||||
|
PNEWPOPUP->parentWindow = (CWindow*)parent;
|
||||||
|
else {
|
||||||
|
PNEWPOPUP->parentPopup = (wlr_xdg_popup*)parent;
|
||||||
|
PNEWPOPUP->parentWindow = g_pCompositor->getWindowForPopup((wlr_xdg_popup*)parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wl_signal_add(&popup->base->events.map, &PNEWPOPUP->listen_mapPopupXDG);
|
||||||
|
wl_signal_add(&popup->base->events.unmap, &PNEWPOPUP->listen_unmapPopupXDG);
|
||||||
|
wl_signal_add(&popup->base->events.destroy, &PNEWPOPUP->listen_destroyPopupXDG);
|
||||||
|
wl_signal_add(&popup->base->events.new_popup, &PNEWPOPUP->listen_newPopupFromPopupXDG);
|
||||||
|
|
||||||
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PNEWPOPUP->parentWindow->m_iMonitorID);
|
||||||
|
|
||||||
|
wlr_box box = {.x = PMONITOR->vecPosition.x, .y = PMONITOR->vecPosition.y, .width = PMONITOR->vecSize.x, .height = PMONITOR->vecSize.y};
|
||||||
|
|
||||||
|
wlr_xdg_popup_unconstrain_from_box(PNEWPOPUP->popup, &box);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Events::listener_newPopupXDG(wl_listener* listener, void* data) {
|
||||||
|
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_newPopupXDG);
|
||||||
|
|
||||||
|
const auto WLRPOPUP = (wlr_xdg_popup*)data;
|
||||||
|
|
||||||
|
createNewPopupXDG(WLRPOPUP, PWINDOW, true);
|
||||||
|
|
||||||
|
Debug::log(LOG, "New layer popup created from XDG window %x -> %s", PWINDOW, PWINDOW->m_szTitle.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Events::listener_newPopupFromPopupXDG(wl_listener* listener, void* data) {
|
||||||
|
SXDGPopup* PPOPUP = wl_container_of(listener, PPOPUP, listen_newPopupFromPopupXDG);
|
||||||
|
|
||||||
|
const auto WLRPOPUP = (wlr_xdg_popup*)data;
|
||||||
|
|
||||||
|
createNewPopupXDG(WLRPOPUP, PPOPUP, true);
|
||||||
|
|
||||||
|
Debug::log(LOG, "New layer popup created from XDG popup %x -> %s", PPOPUP, PPOPUP->parentWindow->m_szTitle.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Events::listener_mapPopupXDG(wl_listener* listener, void* data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Events::listener_unmapPopupXDG(wl_listener* listener, void* data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Events::listener_destroyPopupXDG(wl_listener* listener, void* data) {
|
||||||
|
SXDGPopup* PPOPUP = wl_container_of(listener, PPOPUP, listen_destroyPopupXDG);
|
||||||
|
|
||||||
|
wl_list_remove(&PPOPUP->listen_mapPopupXDG.link);
|
||||||
|
wl_list_remove(&PPOPUP->listen_unmapPopupXDG.link);
|
||||||
|
wl_list_remove(&PPOPUP->listen_destroyPopupXDG.link);
|
||||||
|
|
||||||
|
g_pCompositor->m_lXDGPopups.remove(*PPOPUP);
|
||||||
|
|
||||||
|
Debug::log(LOG, "Destroyed popup XDG %x", PPOPUP);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------ //
|
// ------------------------------------------------------------ //
|
||||||
// __ _______ _ _ _____ ______ _______ //
|
// __ _______ _ _ _____ ______ _______ //
|
||||||
// \ \ / /_ _| \ | | __ \ / __ \ \ / / ____| //
|
// \ \ / /_ _| \ | | __ \ / __ \ \ / / ____| //
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace Events {
|
||||||
LISTENER(unmapPopupXDG);
|
LISTENER(unmapPopupXDG);
|
||||||
LISTENER(destroyPopupXDG);
|
LISTENER(destroyPopupXDG);
|
||||||
LISTENER(commitPopupXDG);
|
LISTENER(commitPopupXDG);
|
||||||
|
LISTENER(newPopupFromPopupXDG);
|
||||||
|
|
||||||
// Surface XDG (window)
|
// Surface XDG (window)
|
||||||
LISTENER(newXDGSurface);
|
LISTENER(newXDGSurface);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "../events/Events.hpp"
|
#include "../events/Events.hpp"
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
#include "../../wlr-layer-shell-unstable-v1-protocol.h"
|
#include "../../wlr-layer-shell-unstable-v1-protocol.h"
|
||||||
|
#include "../Window.hpp"
|
||||||
|
|
||||||
struct SLayerSurface {
|
struct SLayerSurface {
|
||||||
wlr_layer_surface_v1* layerSurface;
|
wlr_layer_surface_v1* layerSurface;
|
||||||
|
@ -62,3 +63,19 @@ struct SLayerPopup {
|
||||||
return popup == rhs.popup;
|
return popup == rhs.popup;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SXDGPopup {
|
||||||
|
CWindow* parentWindow = nullptr;
|
||||||
|
wlr_xdg_popup* parentPopup = nullptr;
|
||||||
|
wlr_xdg_popup* popup = nullptr;
|
||||||
|
|
||||||
|
DYNLISTENER(newPopupFromPopupXDG);
|
||||||
|
DYNLISTENER(destroyPopupXDG);
|
||||||
|
DYNLISTENER(mapPopupXDG);
|
||||||
|
DYNLISTENER(unmapPopupXDG);
|
||||||
|
|
||||||
|
// For the list lookup
|
||||||
|
bool operator==(const SXDGPopup& rhs) {
|
||||||
|
return popup == rhs.popup;
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue