mirror of
https://github.com/hyprwm/Hyprland
synced 2025-02-17 00:42:11 +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) {
|
if (PFOUND) {
|
||||||
sl.x = subx;
|
sl.x = subx;
|
||||||
sl.y = suby;
|
sl.y = suby;
|
||||||
|
if (PFOUND != PSURFACE->surface)
|
||||||
|
Debug::log(LOG, "found non-base on window XDG %x", pWindow);
|
||||||
return PFOUND;
|
return PFOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
void addPopupGlobalCoords(void* pPopup, int* x, int* y) {
|
void addPopupGlobalCoords(void* pPopup, int* x, int* y) {
|
||||||
SXDGPopup *const PPOPUP = (SXDGPopup*)pPopup;
|
SXDGPopup *const PPOPUP = (SXDGPopup*)pPopup;
|
||||||
|
|
||||||
int px = 0;
|
int px = PPOPUP->monitor->vecPosition.x;
|
||||||
int py = 0;
|
int py = PPOPUP->monitor->vecPosition.y;
|
||||||
|
|
||||||
auto curPopup = PPOPUP;
|
auto curPopup = PPOPUP;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -33,8 +33,8 @@ void addPopupGlobalCoords(void* pPopup, int* x, int* y) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
px += *PPOPUP->lx;
|
px += PPOPUP->lx;
|
||||||
py += *PPOPUP->ly;
|
py += PPOPUP->ly;
|
||||||
|
|
||||||
*x += px;
|
*x += px;
|
||||||
*y += py;
|
*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_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);
|
wlr_xdg_popup_unconstrain_from_box(popup, &box);
|
||||||
|
|
||||||
|
pHyprPopup->monitor = PMONITOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_newPopup(void* owner, void* data) {
|
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());
|
g_pCompositor->m_lXDGPopups.push_back(SXDGPopup());
|
||||||
const auto PNEWPOPUP = &g_pCompositor->m_lXDGPopups.back();
|
const auto PNEWPOPUP = &g_pCompositor->m_lXDGPopups.back();
|
||||||
|
|
||||||
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(layersurface->monitorID);
|
||||||
|
|
||||||
PNEWPOPUP->popup = WLRPOPUP;
|
PNEWPOPUP->popup = WLRPOPUP;
|
||||||
PNEWPOPUP->lx = &layersurface->position.x;
|
PNEWPOPUP->lx = layersurface->position.x;
|
||||||
PNEWPOPUP->ly = &layersurface->position.y;
|
PNEWPOPUP->ly = layersurface->position.y;
|
||||||
|
PNEWPOPUP->monitor = PMONITOR;
|
||||||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,10 +90,13 @@ void Events::listener_newPopupXDG(void* owner, void* data) {
|
||||||
g_pCompositor->m_lXDGPopups.push_back(SXDGPopup());
|
g_pCompositor->m_lXDGPopups.push_back(SXDGPopup());
|
||||||
const auto PNEWPOPUP = &g_pCompositor->m_lXDGPopups.back();
|
const auto PNEWPOPUP = &g_pCompositor->m_lXDGPopups.back();
|
||||||
|
|
||||||
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
|
|
||||||
PNEWPOPUP->popup = WLRPOPUP;
|
PNEWPOPUP->popup = WLRPOPUP;
|
||||||
PNEWPOPUP->lx = &PWINDOW->m_vEffectivePosition.x;
|
PNEWPOPUP->lx = PWINDOW->m_vEffectivePosition.x;
|
||||||
PNEWPOPUP->ly = &PWINDOW->m_vEffectivePosition.y;
|
PNEWPOPUP->ly = PWINDOW->m_vEffectivePosition.y;
|
||||||
PNEWPOPUP->parentWindow = PWINDOW;
|
PNEWPOPUP->parentWindow = PWINDOW;
|
||||||
|
PNEWPOPUP->monitor = PMONITOR;
|
||||||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +120,7 @@ void Events::listener_newPopupFromPopupXDG(void* owner, void* data) {
|
||||||
PNEWPOPUP->lx = PPOPUP->lx;
|
PNEWPOPUP->lx = PPOPUP->lx;
|
||||||
PNEWPOPUP->ly = PPOPUP->ly;
|
PNEWPOPUP->ly = PPOPUP->ly;
|
||||||
PNEWPOPUP->parentWindow = PPOPUP->parentWindow;
|
PNEWPOPUP->parentWindow = PPOPUP->parentWindow;
|
||||||
|
PNEWPOPUP->monitor = PPOPUP->monitor;
|
||||||
|
|
||||||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +130,7 @@ void Events::listener_mapPopupXDG(void* owner, void* data) {
|
||||||
|
|
||||||
ASSERT(PPOPUP);
|
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);
|
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) {
|
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) {
|
void Events::listener_destroySubsurface(void* owner, void* data) {
|
||||||
|
|
|
@ -38,6 +38,7 @@ struct SRenderData {
|
||||||
void* data = nullptr;
|
void* data = nullptr;
|
||||||
wlr_surface* surface = nullptr;
|
wlr_surface* surface = nullptr;
|
||||||
int w, h;
|
int w, h;
|
||||||
|
void* pMonitor = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SKeyboard {
|
struct SKeyboard {
|
||||||
|
@ -53,18 +54,21 @@ struct SKeyboard {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SMonitor;
|
||||||
|
|
||||||
struct SXDGPopup {
|
struct SXDGPopup {
|
||||||
CWindow* parentWindow = nullptr;
|
CWindow* parentWindow = nullptr;
|
||||||
SXDGPopup* parentPopup = nullptr;
|
SXDGPopup* parentPopup = nullptr;
|
||||||
wlr_xdg_popup* popup = nullptr;
|
wlr_xdg_popup* popup = nullptr;
|
||||||
|
SMonitor* monitor = nullptr;
|
||||||
|
|
||||||
DYNLISTENER(newPopupFromPopupXDG);
|
DYNLISTENER(newPopupFromPopupXDG);
|
||||||
DYNLISTENER(destroyPopupXDG);
|
DYNLISTENER(destroyPopupXDG);
|
||||||
DYNLISTENER(mapPopupXDG);
|
DYNLISTENER(mapPopupXDG);
|
||||||
DYNLISTENER(unmapPopupXDG);
|
DYNLISTENER(unmapPopupXDG);
|
||||||
|
|
||||||
double* lx;
|
double lx;
|
||||||
double* ly;
|
double ly;
|
||||||
|
|
||||||
SSurfaceTreeNode* pSurfaceTree = nullptr;
|
SSurfaceTreeNode* pSurfaceTree = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,11 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
||||||
double outputX = 0, outputY = 0;
|
double outputX = 0, outputY = 0;
|
||||||
wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, RDATA->output, &outputX, &outputY);
|
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;
|
wlr_box windowBox;
|
||||||
if (RDATA->surface && surface == RDATA->surface) {
|
if (RDATA->surface && surface == RDATA->surface) {
|
||||||
|
@ -101,6 +106,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
renderdata.pMonitor = pMonitor;
|
||||||
wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata);
|
wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue