fixed fullscreen, removed effective vars from windows

This commit is contained in:
vaxerski 2022-04-23 14:35:34 +02:00
parent 0147975faf
commit f84294fe07
7 changed files with 66 additions and 60 deletions

View File

@ -429,7 +429,7 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
g_pXWaylandManager->activateWindow(pWindow, true); // sets the m_pLastWindow
// do pointer focus too
const auto POINTERLOCAL = g_pInputManager->getMouseCoordsInternal() - pWindow->m_vEffectivePosition;
const auto POINTERLOCAL = g_pInputManager->getMouseCoordsInternal() - pWindow->m_vRealPosition.goalv();
wlr_seat_pointer_notify_enter(m_sSeat.seat, PWINDOWSURFACE, POINTERLOCAL.x, POINTERLOCAL.y);
const auto RENDERDATA = g_pLayoutManager->getCurrentLayout()->requestRenderHints(pWindow);

View File

@ -32,10 +32,6 @@ public:
Vector2D m_vPosition = Vector2D(0,0);
Vector2D m_vSize = Vector2D(0,0);
// this is the position and size of the goal placement
Vector2D m_vEffectivePosition = Vector2D(0,0);
Vector2D m_vEffectiveSize = Vector2D(0,0);
// this is the real position and size used to draw the thing
CAnimatedVariable m_vRealPosition;
CAnimatedVariable m_vRealSize;

View File

@ -95,8 +95,8 @@ void Events::listener_newPopupXDG(void* owner, void* data) {
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_vRealPosition.goalv().x;
PNEWPOPUP->ly = PWINDOW->m_vRealPosition.goalv().y;
PNEWPOPUP->parentWindow = PWINDOW;
PNEWPOPUP->monitor = PMONITOR;
createNewPopup(WLRPOPUP, PNEWPOPUP);

View File

@ -17,8 +17,8 @@
void addViewCoords(void* pWindow, int* x, int* y) {
const auto PWINDOW = (CWindow*)pWindow;
*x += PWINDOW->m_vEffectivePosition.x;
*y += PWINDOW->m_vEffectivePosition.y;
*x += PWINDOW->m_vRealPosition.goalv().x;
*y += PWINDOW->m_vRealPosition.goalv().y;
}
void Events::listener_mapWindow(void* owner, void* data) {
@ -114,8 +114,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
Debug::log(LOG, "Rule size, applying to window %x", PWINDOW);
PWINDOW->m_vRealSize = Vector2D(SIZEX, SIZEY);
PWINDOW->m_vEffectiveSize = Vector2D(SIZEX, SIZEY);
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vEffectiveSize);
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
} catch (...) {
Debug::log(LOG, "Rule size failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
}
@ -131,7 +130,6 @@ void Events::listener_mapWindow(void* owner, void* data) {
Debug::log(LOG, "Rule move, applying to window %x", PWINDOW);
PWINDOW->m_vRealPosition = Vector2D(POSX, POSY) + PMONITOR->vecPosition;
PWINDOW->m_vEffectivePosition = Vector2D(POSX, POSY) + PMONITOR->vecPosition;
} catch (...) {
Debug::log(LOG, "Rule move failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
}
@ -140,13 +138,13 @@ void Events::listener_mapWindow(void* owner, void* data) {
// set the pseudo size to the GOAL of our current size
// because the windows are animated on RealSize
PWINDOW->m_vPseudoSize = PWINDOW->m_vEffectiveSize;
PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goalv();
}
else {
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW);
// Set the pseudo size here too so that it doesnt end up being 0x0
PWINDOW->m_vPseudoSize = PWINDOW->m_vEffectiveSize - Vector2D(10,10);
PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goalv() - Vector2D(10,10);
}
g_pCompositor->focusWindow(PWINDOW);
@ -167,7 +165,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
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);
Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y, PWINDOW->m_vRealSize.goalv().x, PWINDOW->m_vRealSize.goalv().y);
}
void Events::listener_unmapWindow(void* owner, void* data) {
@ -310,10 +308,8 @@ void Events::listener_configureX11(void* owner, void* data) {
wlr_xwayland_surface_configure(PWINDOW->m_uSurface.xwayland, E->x, E->y, E->width, E->height);
wlr_xwayland_surface_restack(PWINDOW->m_uSurface.xwayland, NULL, XCB_STACK_MODE_ABOVE);
PWINDOW->m_vEffectivePosition = Vector2D(E->x, E->y);
PWINDOW->m_vEffectiveSize = Vector2D(E->width, E->height);
PWINDOW->m_vRealPosition.setValue(PWINDOW->m_vEffectivePosition);
PWINDOW->m_vRealSize.setValue(PWINDOW->m_vEffectiveSize);
PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(E->x, E->y));
PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(E->width, E->height));
PWINDOW->m_vPosition = PWINDOW->m_vPosition;
PWINDOW->m_vSize = PWINDOW->m_vSize;

View File

@ -21,21 +21,42 @@ public:
~CAnimatedVariable();
// gets the current vector value (real time)
Vector2D vec() {
ASSERT(m_eVarType == AVARTYPE_VECTOR);
return m_vValue;
}
// gets the current float value (real time)
float fl() {
ASSERT(m_eVarType == AVARTYPE_FLOAT);
return m_fValue;
}
// gets the current color value (real time)
CColor col() {
ASSERT(m_eVarType == AVARTYPE_COLOR);
return m_cValue;
}
// gets the goal vector value
Vector2D goalv() {
ASSERT(m_eVarType == AVARTYPE_VECTOR);
return m_vGoal;
}
// gets the goal float value
float goalf() {
ASSERT(m_eVarType == AVARTYPE_FLOAT);
return m_fGoal;
}
// gets the goal color value
CColor goalc() {
ASSERT(m_eVarType == AVARTYPE_COLOR);
return m_cGoal;
}
void operator=(const Vector2D& v) {
ASSERT(m_eVarType == AVARTYPE_VECTOR);
m_vGoal = v;

View File

@ -119,8 +119,8 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) {
PWINDOW->m_vSize = pNode->size;
PWINDOW->m_vPosition = pNode->position;
PWINDOW->m_vEffectivePosition = PWINDOW->m_vPosition + Vector2D(BORDERSIZE, BORDERSIZE);
PWINDOW->m_vEffectiveSize = PWINDOW->m_vSize - Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE);
auto calcPos = PWINDOW->m_vPosition + Vector2D(BORDERSIZE, BORDERSIZE);
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE);
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? GAPSOUT : GAPSIN,
DISPLAYTOP ? GAPSOUT : GAPSIN);
@ -128,37 +128,37 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) {
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? GAPSOUT : GAPSIN,
DISPLAYBOTTOM ? GAPSOUT : GAPSIN);
PWINDOW->m_vEffectivePosition = PWINDOW->m_vEffectivePosition + OFFSETTOPLEFT;
PWINDOW->m_vEffectiveSize = PWINDOW->m_vEffectiveSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
calcPos = calcPos + OFFSETTOPLEFT;
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
if (PWINDOW->m_bIsPseudotiled) {
// Calculate pseudo
float scale = 1;
// adjust if doesnt fit
if (PWINDOW->m_vPseudoSize.x > PWINDOW->m_vEffectiveSize.x || PWINDOW->m_vPseudoSize.y > PWINDOW->m_vEffectiveSize.y) {
if (PWINDOW->m_vPseudoSize.x > PWINDOW->m_vEffectiveSize.x) {
scale = PWINDOW->m_vEffectiveSize.x / PWINDOW->m_vPseudoSize.x;
if (PWINDOW->m_vPseudoSize.x > calcSize.x || PWINDOW->m_vPseudoSize.y > calcSize.y) {
if (PWINDOW->m_vPseudoSize.x > calcSize.x) {
scale = calcSize.x / PWINDOW->m_vPseudoSize.x;
}
if (PWINDOW->m_vPseudoSize.y * scale > PWINDOW->m_vEffectiveSize.y) {
scale = PWINDOW->m_vEffectiveSize.y / PWINDOW->m_vPseudoSize.y;
if (PWINDOW->m_vPseudoSize.y * scale > calcSize.y) {
scale = calcSize.y / PWINDOW->m_vPseudoSize.y;
}
auto DELTA = PWINDOW->m_vEffectiveSize - PWINDOW->m_vPseudoSize * scale;
PWINDOW->m_vEffectiveSize = PWINDOW->m_vPseudoSize * scale;
PWINDOW->m_vEffectivePosition = PWINDOW->m_vEffectivePosition + DELTA / 2.f; // center
auto DELTA = calcSize - PWINDOW->m_vPseudoSize * scale;
calcSize = PWINDOW->m_vPseudoSize * scale;
calcPos = calcPos + DELTA / 2.f; // center
} else {
auto DELTA = PWINDOW->m_vEffectiveSize - PWINDOW->m_vPseudoSize;
PWINDOW->m_vEffectivePosition = PWINDOW->m_vEffectivePosition + DELTA / 2.f; // center
PWINDOW->m_vEffectiveSize = PWINDOW->m_vPseudoSize;
auto DELTA = calcSize - PWINDOW->m_vPseudoSize;
calcPos = calcPos + DELTA / 2.f; // center
calcSize = PWINDOW->m_vPseudoSize;
}
}
PWINDOW->m_vRealSize = PWINDOW->m_vEffectiveSize;
PWINDOW->m_vRealPosition = PWINDOW->m_vEffectivePosition;
PWINDOW->m_vRealSize = calcSize;
PWINDOW->m_vRealPosition = calcPos;
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vEffectiveSize);
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
}
void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
@ -449,14 +449,11 @@ void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) {
if (g_pInputManager->dragButton == BTN_LEFT) {
DRAGGINGWINDOW->m_vRealPosition.setValueAndWarp(m_vBeginDragPositionXY + DELTA);
DRAGGINGWINDOW->m_vEffectivePosition = DRAGGINGWINDOW->m_vRealPosition.vec();
} else {
if (DRAGGINGWINDOW->m_bIsFloating) {
DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(m_vBeginDragSizeXY + DELTA);
DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(Vector2D(std::clamp(DRAGGINGWINDOW->m_vRealSize.vec().x, (double)20, (double)999999), std::clamp(DRAGGINGWINDOW->m_vRealSize.vec().y, (double)20, (double)999999)));
DRAGGINGWINDOW->m_vEffectiveSize = DRAGGINGWINDOW->m_vRealSize.vec();
g_pXWaylandManager->setWindowSize(DRAGGINGWINDOW, DRAGGINGWINDOW->m_vRealSize.vec());
} else {
// we need to adjust the splitratio
@ -543,12 +540,12 @@ void CHyprDwindleLayout::onWindowCreatedFloating(CWindow* pWindow) {
if (desiredGeometry.width <= 0 || desiredGeometry.height <= 0) {
const auto PWINDOWSURFACE = g_pXWaylandManager->getWindowSurface(pWindow);
pWindow->m_vEffectiveSize = Vector2D(PWINDOWSURFACE->current.width, PWINDOWSURFACE->current.height);
pWindow->m_vEffectivePosition = Vector2D(PMONITOR->vecPosition.x + (PMONITOR->vecSize.x - pWindow->m_vRealSize.vec().x) / 2.f, PMONITOR->vecPosition.y + (PMONITOR->vecSize.y - pWindow->m_vRealSize.vec().y) / 2.f);
pWindow->m_vRealSize = Vector2D(PWINDOWSURFACE->current.width, PWINDOWSURFACE->current.height);
pWindow->m_vRealPosition = Vector2D(PMONITOR->vecPosition.x + (PMONITOR->vecSize.x - pWindow->m_vRealSize.vec().x) / 2.f, PMONITOR->vecPosition.y + (PMONITOR->vecSize.y - pWindow->m_vRealSize.vec().y) / 2.f);
} else {
// we respect the size.
pWindow->m_vEffectiveSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
pWindow->m_vRealSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
// check if it's on the correct monitor!
Vector2D middlePoint = Vector2D(desiredGeometry.x, desiredGeometry.y) + Vector2D(desiredGeometry.width, desiredGeometry.height) / 2.f;
@ -556,26 +553,23 @@ void CHyprDwindleLayout::onWindowCreatedFloating(CWindow* pWindow) {
// TODO: detect a popup in a more consistent way.
if ((g_pCompositor->getMonitorFromVector(middlePoint) && g_pCompositor->getMonitorFromVector(middlePoint)->ID != pWindow->m_iMonitorID) || (desiredGeometry.x == 0 && desiredGeometry.y == 0)) {
// if it's not, fall back to the center placement
pWindow->m_vEffectivePosition = PMONITOR->vecPosition + Vector2D((PMONITOR->vecSize.x - desiredGeometry.width) / 2.f, (PMONITOR->vecSize.y - desiredGeometry.height) / 2.f);
pWindow->m_vRealPosition = PMONITOR->vecPosition + Vector2D((PMONITOR->vecSize.x - desiredGeometry.width) / 2.f, (PMONITOR->vecSize.y - desiredGeometry.height) / 2.f);
} else {
// if it is, we respect where it wants to put itself.
// most of these are popups
pWindow->m_vEffectivePosition = Vector2D(desiredGeometry.x, desiredGeometry.y);
pWindow->m_vRealPosition = Vector2D(desiredGeometry.x, desiredGeometry.y);
}
}
if (!pWindow->m_bX11DoesntWantBorders) {
pWindow->m_vRealPosition.setValue(pWindow->m_vEffectivePosition + pWindow->m_vEffectiveSize / 2.f);
pWindow->m_vRealPosition.setValue(pWindow->m_vRealPosition.goalv() + pWindow->m_vRealSize.goalv() / 2.f);
pWindow->m_vRealSize.setValue(Vector2D(5, 5));
} else {
pWindow->m_vRealPosition.setValue(pWindow->m_vEffectivePosition);
pWindow->m_vRealSize.setValue(pWindow->m_vEffectiveSize);
pWindow->m_vRealPosition.setValue(pWindow->m_vRealPosition.goalv());
pWindow->m_vRealSize.setValue(pWindow->m_vRealSize.goalv());
}
pWindow->m_vRealPosition = pWindow->m_vEffectivePosition;
pWindow->m_vRealSize = pWindow->m_vEffectiveSize;
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vEffectiveSize);
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv());
g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace);
g_pCompositor->moveWindowToTop(pWindow);
@ -605,10 +599,10 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow) {
applyNodeDataToWindow(PNODE);
else {
// get back its' dimensions from position and size
pWindow->m_vEffectivePosition = pWindow->m_vPosition;
pWindow->m_vEffectiveSize = pWindow->m_vSize;
pWindow->m_vRealPosition = pWindow->m_vPosition;
pWindow->m_vRealSize = pWindow->m_vSize;
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.vec());
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv());
}
} else {
// if it now got fullscreen, make it fullscreen
@ -620,10 +614,10 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow) {
}
// apply new pos and size being monitors' box
pWindow->m_vEffectivePosition = PMONITOR->vecPosition;
pWindow->m_vEffectiveSize = PMONITOR->vecSize;
pWindow->m_vRealPosition = PMONITOR->vecPosition;
pWindow->m_vRealSize = PMONITOR->vecSize;
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.vec());
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv());
}
g_pCompositor->moveWindowToTop(pWindow);

View File

@ -321,7 +321,6 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
if (PWINDOW->m_bIsFloating) {
PWINDOW->m_vRealPosition.setValue(PWINDOW->m_vRealPosition.vec() - g_pCompositor->getMonitorFromID(OLDWORKSPACE->m_iMonitorID)->vecPosition);
PWINDOW->m_vRealPosition.setValue(PWINDOW->m_vRealPosition.vec() + g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID)->vecPosition);
PWINDOW->m_vEffectivePosition = PWINDOW->m_vRealPosition.vec();
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.vec();
}
}
@ -338,7 +337,7 @@ void CKeybindManager::moveFocusTo(std::string args) {
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
Vector2D middle = PWINDOWTOCHANGETO->m_vEffectivePosition + PWINDOWTOCHANGETO->m_vEffectiveSize / 2.f;
Vector2D middle = PWINDOWTOCHANGETO->m_vRealPosition.goalv() + PWINDOWTOCHANGETO->m_vRealSize.goalv() / 2.f;
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, middle.x, middle.y);
};