mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 14:45:59 +01:00
XDG popup tweaks
This commit is contained in:
parent
4db773b1e7
commit
c923b4f075
5 changed files with 37 additions and 12 deletions
|
@ -335,6 +335,8 @@ wlr_surface* CCompositor::vectorWindowToSurface(const Vector2D& pos, CWindow* pW
|
|||
if (PFOUND) {
|
||||
sl.x = subx;
|
||||
sl.y = suby;
|
||||
if (PFOUND != PSURFACE->surface)
|
||||
Debug::log(LOG, "found non-base on window XDG %x", pWindow);
|
||||
return PFOUND;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
void addPopupGlobalCoords(void* pPopup, int* x, int* y) {
|
||||
SXDGPopup *const PPOPUP = (SXDGPopup*)pPopup;
|
||||
|
||||
int px = 0;
|
||||
int py = 0;
|
||||
int px = PPOPUP->monitor->vecPosition.x;
|
||||
int py = PPOPUP->monitor->vecPosition.y;
|
||||
|
||||
auto curPopup = PPOPUP;
|
||||
while (true) {
|
||||
|
@ -33,8 +33,8 @@ void addPopupGlobalCoords(void* pPopup, int* x, int* y) {
|
|||
}
|
||||
}
|
||||
|
||||
px += *PPOPUP->lx;
|
||||
py += *PPOPUP->ly;
|
||||
px += PPOPUP->lx;
|
||||
py += PPOPUP->ly;
|
||||
|
||||
*x += px;
|
||||
*y += py;
|
||||
|
@ -53,6 +53,8 @@ void createNewPopup(wlr_xdg_popup* popup, SXDGPopup* pHyprPopup) {
|
|||
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(popup, &box);
|
||||
|
||||
pHyprPopup->monitor = PMONITOR;
|
||||
}
|
||||
|
||||
void Events::listener_newPopup(void* owner, void* data) {
|
||||
|
@ -67,9 +69,12 @@ void Events::listener_newPopup(void* owner, void* data) {
|
|||
g_pCompositor->m_lXDGPopups.push_back(SXDGPopup());
|
||||
const auto PNEWPOPUP = &g_pCompositor->m_lXDGPopups.back();
|
||||
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(layersurface->monitorID);
|
||||
|
||||
PNEWPOPUP->popup = WLRPOPUP;
|
||||
PNEWPOPUP->lx = &layersurface->position.x;
|
||||
PNEWPOPUP->ly = &layersurface->position.y;
|
||||
PNEWPOPUP->lx = layersurface->position.x;
|
||||
PNEWPOPUP->ly = layersurface->position.y;
|
||||
PNEWPOPUP->monitor = PMONITOR;
|
||||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||
}
|
||||
|
||||
|
@ -85,10 +90,13 @@ void Events::listener_newPopupXDG(void* owner, void* data) {
|
|||
g_pCompositor->m_lXDGPopups.push_back(SXDGPopup());
|
||||
const auto PNEWPOPUP = &g_pCompositor->m_lXDGPopups.back();
|
||||
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||
|
||||
PNEWPOPUP->popup = WLRPOPUP;
|
||||
PNEWPOPUP->lx = &PWINDOW->m_vEffectivePosition.x;
|
||||
PNEWPOPUP->ly = &PWINDOW->m_vEffectivePosition.y;
|
||||
PNEWPOPUP->lx = PWINDOW->m_vEffectivePosition.x;
|
||||
PNEWPOPUP->ly = PWINDOW->m_vEffectivePosition.y;
|
||||
PNEWPOPUP->parentWindow = PWINDOW;
|
||||
PNEWPOPUP->monitor = PMONITOR;
|
||||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||
}
|
||||
|
||||
|
@ -112,6 +120,7 @@ void Events::listener_newPopupFromPopupXDG(void* owner, void* data) {
|
|||
PNEWPOPUP->lx = PPOPUP->lx;
|
||||
PNEWPOPUP->ly = PPOPUP->ly;
|
||||
PNEWPOPUP->parentWindow = PPOPUP->parentWindow;
|
||||
PNEWPOPUP->monitor = PPOPUP->monitor;
|
||||
|
||||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||
}
|
||||
|
@ -121,7 +130,7 @@ void Events::listener_mapPopupXDG(void* owner, void* data) {
|
|||
|
||||
ASSERT(PPOPUP);
|
||||
|
||||
Debug::log(LOG, "New XDG Popup mapped at %d %d", (int)*PPOPUP->lx, (int)*PPOPUP->ly);
|
||||
Debug::log(LOG, "New XDG Popup mapped at %d %d", (int)PPOPUP->lx, (int)PPOPUP->ly);
|
||||
|
||||
PPOPUP->pSurfaceTree = SubsurfaceTree::createTreeRoot(PPOPUP->popup->base->surface, addPopupGlobalCoords, PPOPUP);
|
||||
|
||||
|
|
|
@ -142,7 +142,11 @@ void Events::listener_unmapSubsurface(void* owner, void* data) {
|
|||
}
|
||||
|
||||
void Events::listener_commitSubsurface(void* owner, void* data) {
|
||||
// SSurfaceTreeNode* pNode = (SSurfaceTreeNode*)owner;
|
||||
SSurfaceTreeNode* pNode = (SSurfaceTreeNode*)owner;
|
||||
|
||||
int lx = 0, ly = 0;
|
||||
|
||||
addSurfaceGlobalOffset(pNode, &lx, &ly);
|
||||
}
|
||||
|
||||
void Events::listener_destroySubsurface(void* owner, void* data) {
|
||||
|
|
|
@ -38,6 +38,7 @@ struct SRenderData {
|
|||
void* data = nullptr;
|
||||
wlr_surface* surface = nullptr;
|
||||
int w, h;
|
||||
void* pMonitor = nullptr;
|
||||
};
|
||||
|
||||
struct SKeyboard {
|
||||
|
@ -53,18 +54,21 @@ struct SKeyboard {
|
|||
}
|
||||
};
|
||||
|
||||
struct SMonitor;
|
||||
|
||||
struct SXDGPopup {
|
||||
CWindow* parentWindow = nullptr;
|
||||
SXDGPopup* parentPopup = nullptr;
|
||||
wlr_xdg_popup* popup = nullptr;
|
||||
SMonitor* monitor = nullptr;
|
||||
|
||||
DYNLISTENER(newPopupFromPopupXDG);
|
||||
DYNLISTENER(destroyPopupXDG);
|
||||
DYNLISTENER(mapPopupXDG);
|
||||
DYNLISTENER(unmapPopupXDG);
|
||||
|
||||
double* lx;
|
||||
double* ly;
|
||||
double lx;
|
||||
double ly;
|
||||
|
||||
SSurfaceTreeNode* pSurfaceTree = nullptr;
|
||||
|
||||
|
|
|
@ -18,6 +18,11 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
|||
double outputX = 0, outputY = 0;
|
||||
wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, RDATA->output, &outputX, &outputY);
|
||||
|
||||
if (RDATA->pMonitor) { // BUG THIS TODO: this is just to show the popup on a monitor that isnt at 0,0
|
||||
// the popups are broken.
|
||||
x -= ((SMonitor*)RDATA->pMonitor)->vecPosition.x;
|
||||
y -= ((SMonitor*)RDATA->pMonitor)->vecPosition.y;
|
||||
}
|
||||
|
||||
wlr_box windowBox;
|
||||
if (RDATA->surface && surface == RDATA->surface) {
|
||||
|
@ -101,6 +106,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec*
|
|||
}
|
||||
}
|
||||
else {
|
||||
renderdata.pMonitor = pMonitor;
|
||||
wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue