internal: Window storage rework - part 1 (#5762)
* Window storage rework - part 1 * format * remove useless include * fix pch * format * fix crash in dwindle * fix vram leak * prefer .expired() for bool checks
This commit is contained in:
parent
25aec3ac8c
commit
bca7804bb6
72 changed files with 1416 additions and 1346 deletions
|
|
@ -19,7 +19,7 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) {
|
|||
PINHIBIT->pWindow = PWINDOW;
|
||||
PINHIBIT->windowDestroyListener = PWINDOW->events.destroy.registerListener([PINHIBIT](std::any data) {
|
||||
Debug::log(WARN, "Inhibitor got its window destroyed before its inhibitor resource.");
|
||||
PINHIBIT->pWindow = nullptr;
|
||||
PINHIBIT->pWindow.reset();
|
||||
});
|
||||
} else
|
||||
Debug::log(WARN, "Inhibitor is for no window?");
|
||||
|
|
@ -29,10 +29,10 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) {
|
|||
void CInputManager::recheckIdleInhibitorStatus() {
|
||||
|
||||
for (auto& ii : m_vIdleInhibitors) {
|
||||
if (!ii->pWindow) {
|
||||
if (ii->pWindow.expired()) {
|
||||
g_pCompositor->setIdleActivityInhibit(false);
|
||||
return;
|
||||
} else if (g_pHyprRenderer->shouldRenderWindow(ii->pWindow)) {
|
||||
} else if (g_pHyprRenderer->shouldRenderWindow(ii->pWindow.lock())) {
|
||||
g_pCompositor->setIdleActivityInhibit(false);
|
||||
return;
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ void CInputManager::recheckIdleInhibitorStatus() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (w->m_eIdleInhibitMode == IDLEINHIBIT_FOCUS && g_pCompositor->isWindowActive(w.get())) {
|
||||
if (w->m_eIdleInhibitMode == IDLEINHIBIT_FOCUS && g_pCompositor->isWindowActive(w)) {
|
||||
g_pCompositor->setIdleActivityInhibit(false);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,13 +118,13 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
|
||||
const auto FOLLOWMOUSE = *PFOLLOWONDND && m_sDrag.drag ? 1 : *PFOLLOWMOUSE;
|
||||
|
||||
m_pFoundSurfaceToFocus = nullptr;
|
||||
m_pFoundLSToFocus = nullptr;
|
||||
m_pFoundWindowToFocus = nullptr;
|
||||
m_pFoundSurfaceToFocus = nullptr;
|
||||
m_pFoundLSToFocus = nullptr;
|
||||
m_pFoundWindowToFocus.reset();
|
||||
wlr_surface* foundSurface = nullptr;
|
||||
Vector2D surfaceCoords;
|
||||
Vector2D surfacePos = Vector2D(-1337, -1337);
|
||||
CWindow* pFoundWindow = nullptr;
|
||||
Vector2D surfacePos = Vector2D(-1337, -1337);
|
||||
PHLWINDOW pFoundWindow;
|
||||
SLayerSurface* pFoundLayerSurface = nullptr;
|
||||
|
||||
if (!g_pCompositor->m_bReadyToProcess || g_pCompositor->m_bIsShuttingDown || g_pCompositor->m_bUnsafeState)
|
||||
|
|
@ -157,10 +157,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
if (*PZOOMFACTOR != 1.f)
|
||||
g_pHyprRenderer->damageMonitor(PMONITOR);
|
||||
|
||||
if (!PMONITOR->solitaryClient && g_pHyprRenderer->shouldRenderCursor() && PMONITOR->output->software_cursor_locks > 0)
|
||||
if (!PMONITOR->solitaryClient.lock() && g_pHyprRenderer->shouldRenderCursor() && PMONITOR->output->software_cursor_locks > 0)
|
||||
g_pCompositor->scheduleFrameForMonitor(PMONITOR);
|
||||
|
||||
CWindow* forcedFocus = m_pForcedFocus;
|
||||
PHLWINDOW forcedFocus = m_pForcedFocus.lock();
|
||||
|
||||
if (!forcedFocus)
|
||||
forcedFocus = g_pCompositor->getForceFocus();
|
||||
|
|
@ -213,9 +213,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
surfacePos = foundPopup->globalBox().pos();
|
||||
m_bFocusHeldByButtons = true;
|
||||
m_bRefocusHeldByButtons = refocus;
|
||||
} else if (g_pCompositor->m_pLastWindow) {
|
||||
} else if (!g_pCompositor->m_pLastWindow.expired()) {
|
||||
foundSurface = m_pLastMouseSurface;
|
||||
pFoundWindow = g_pCompositor->m_pLastWindow;
|
||||
pFoundWindow = g_pCompositor->m_pLastWindow.lock();
|
||||
|
||||
surfaceCoords = g_pCompositor->vectorToSurfaceLocal(mouseCoords, pFoundWindow, foundSurface);
|
||||
m_bFocusHeldByButtons = true;
|
||||
|
|
@ -226,7 +226,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
|
||||
g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal());
|
||||
|
||||
if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor && (*PMOUSEFOCUSMON || refocus) && !m_pForcedFocus)
|
||||
if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor && (*PMOUSEFOCUSMON || refocus) && m_pForcedFocus.expired())
|
||||
g_pCompositor->setActiveMonitor(PMONITOR);
|
||||
|
||||
if (g_pSessionLockManager->isSessionLocked()) {
|
||||
|
|
@ -356,7 +356,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat);
|
||||
m_pLastMouseSurface = nullptr;
|
||||
|
||||
if (refocus || !g_pCompositor->m_pLastWindow) // if we are forcing a refocus, and we don't find a surface, clear the kb focus too!
|
||||
if (refocus || g_pCompositor->m_pLastWindow.expired()) // if we are forcing a refocus, and we don't find a surface, clear the kb focus too!
|
||||
g_pCompositor->focusWindow(nullptr);
|
||||
|
||||
return;
|
||||
|
|
@ -393,7 +393,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
m_pFoundSurfaceToFocus = foundSurface;
|
||||
}
|
||||
|
||||
if (currentlyDraggedWindow && pFoundWindow != currentlyDraggedWindow) {
|
||||
if (currentlyDraggedWindow.lock() && pFoundWindow != currentlyDraggedWindow.lock()) {
|
||||
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
|
||||
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y);
|
||||
return;
|
||||
|
|
@ -418,8 +418,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
}
|
||||
|
||||
if (FOLLOWMOUSE != 1 && !refocus) {
|
||||
if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow &&
|
||||
((pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR == 2) || (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR != 0))) {
|
||||
if (pFoundWindow != g_pCompositor->m_pLastWindow.lock() && g_pCompositor->m_pLastWindow.lock() &&
|
||||
((pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR == 2) ||
|
||||
(g_pCompositor->m_pLastWindow.lock()->m_bIsFloating != pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR != 0))) {
|
||||
// enter if change floating style
|
||||
if (FOLLOWMOUSE != 3 && allowKeyboardRefocus)
|
||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||
|
|
@ -430,24 +431,24 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
|
||||
}
|
||||
|
||||
if (pFoundWindow == g_pCompositor->m_pLastWindow) {
|
||||
if (pFoundWindow == g_pCompositor->m_pLastWindow.lock()) {
|
||||
m_pLastMouseSurface = foundSurface;
|
||||
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
|
||||
}
|
||||
|
||||
if (FOLLOWMOUSE != 0 || pFoundWindow == g_pCompositor->m_pLastWindow)
|
||||
if (FOLLOWMOUSE != 0 || pFoundWindow == g_pCompositor->m_pLastWindow.lock())
|
||||
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y);
|
||||
|
||||
m_bLastFocusOnLS = false;
|
||||
return; // don't enter any new surfaces
|
||||
} else {
|
||||
if (allowKeyboardRefocus && ((FOLLOWMOUSE != 3 && (*PMOUSEREFOCUS || m_pLastMouseFocus != pFoundWindow)) || refocus)) {
|
||||
if (m_pLastMouseFocus != pFoundWindow || g_pCompositor->m_pLastWindow != pFoundWindow || g_pCompositor->m_pLastFocus != foundSurface || refocus) {
|
||||
if (allowKeyboardRefocus && ((FOLLOWMOUSE != 3 && (*PMOUSEREFOCUS || m_pLastMouseFocus.lock() != pFoundWindow)) || refocus)) {
|
||||
if (m_pLastMouseFocus.lock() != pFoundWindow || g_pCompositor->m_pLastWindow.lock() != pFoundWindow || g_pCompositor->m_pLastFocus != foundSurface || refocus) {
|
||||
m_pLastMouseFocus = pFoundWindow;
|
||||
|
||||
// TODO: this looks wrong. When over a popup, it constantly is switching.
|
||||
// Temp fix until that's figured out. Otherwise spams windowrule lookups and other shit.
|
||||
if (m_pLastMouseFocus != pFoundWindow || g_pCompositor->m_pLastWindow != pFoundWindow)
|
||||
if (m_pLastMouseFocus.lock() != pFoundWindow || g_pCompositor->m_pLastWindow.lock() != pFoundWindow)
|
||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||
else
|
||||
g_pCompositor->focusSurface(foundSurface, pFoundWindow);
|
||||
|
|
@ -642,7 +643,7 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
|
|||
break;
|
||||
|
||||
if ((!g_pCompositor->m_sSeat.mouse || !isConstrained()) /* No constraints */
|
||||
&& (w && g_pCompositor->m_pLastWindow != w) /* window should change */) {
|
||||
&& (w && g_pCompositor->m_pLastWindow.lock() != w) /* window should change */) {
|
||||
// a bit hacky
|
||||
// if we only pressed one button, allow us to refocus. m_lCurrentlyHeldButtons.size() > 0 will stick the focus
|
||||
if (m_lCurrentlyHeldButtons.size() == 1) {
|
||||
|
|
@ -655,8 +656,8 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
|
|||
}
|
||||
|
||||
// if clicked on a floating window make it top
|
||||
if (g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bIsFloating)
|
||||
g_pCompositor->changeWindowZOrder(g_pCompositor->m_pLastWindow, true);
|
||||
if (g_pCompositor->m_pLastWindow.lock() && g_pCompositor->m_pLastWindow.lock()->m_bIsFloating)
|
||||
g_pCompositor->changeWindowZOrder(g_pCompositor->m_pLastWindow.lock(), true);
|
||||
|
||||
break;
|
||||
case WL_POINTER_BUTTON_STATE_RELEASED: break;
|
||||
|
|
@ -1615,7 +1616,7 @@ void CInputManager::releaseAllMouseButtons() {
|
|||
m_lCurrentlyHeldButtons.clear();
|
||||
}
|
||||
|
||||
void CInputManager::setCursorIconOnBorder(CWindow* w) {
|
||||
void CInputManager::setCursorIconOnBorder(PHLWINDOW w) {
|
||||
// do not override cursor icons set by mouse binds
|
||||
if (g_pKeybindManager->m_bIsMouseBindActive) {
|
||||
m_eBorderIconDirection = BORDERICON_NONE;
|
||||
|
|
@ -1636,7 +1637,7 @@ void CInputManager::setCursorIconOnBorder(CWindow* w) {
|
|||
|
||||
if (w->hasPopupAt(mouseCoords))
|
||||
direction = BORDERICON_NONE;
|
||||
else if (!boxFullGrabInput.containsPoint(mouseCoords) || (!m_lCurrentlyHeldButtons.empty() && !currentlyDraggedWindow))
|
||||
else if (!boxFullGrabInput.containsPoint(mouseCoords) || (!m_lCurrentlyHeldButtons.empty() && currentlyDraggedWindow.expired()))
|
||||
direction = BORDERICON_NONE;
|
||||
else {
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ enum eBorderIconDirection {
|
|||
};
|
||||
|
||||
struct STouchData {
|
||||
CWindow* touchFocusWindow = nullptr;
|
||||
PHLWINDOWREF touchFocusWindow;
|
||||
SLayerSurface* touchFocusLS = nullptr;
|
||||
wlr_surface* touchFocusSurface = nullptr;
|
||||
Vector2D touchSurfaceOrigin;
|
||||
|
|
@ -114,12 +114,12 @@ class CInputManager {
|
|||
STouchData m_sTouchData;
|
||||
|
||||
// for dragging floating windows
|
||||
CWindow* currentlyDraggedWindow = nullptr;
|
||||
eMouseBindMode dragMode = MBIND_INVALID;
|
||||
bool m_bWasDraggingWindow = false;
|
||||
PHLWINDOWREF currentlyDraggedWindow;
|
||||
eMouseBindMode dragMode = MBIND_INVALID;
|
||||
bool m_bWasDraggingWindow = false;
|
||||
|
||||
// for refocus to be forced
|
||||
CWindow* m_pForcedFocus = nullptr;
|
||||
PHLWINDOWREF m_pForcedFocus;
|
||||
|
||||
SDrag m_sDrag;
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ class CInputManager {
|
|||
bool m_bLastInputTouch = false;
|
||||
|
||||
// for tracking mouse refocus
|
||||
CWindow* m_pLastMouseFocus = nullptr;
|
||||
PHLWINDOWREF m_pLastMouseFocus;
|
||||
wlr_surface* m_pLastMouseSurface = nullptr;
|
||||
|
||||
//
|
||||
|
|
@ -226,7 +226,7 @@ class CInputManager {
|
|||
// this will be set after a refocus()
|
||||
wlr_surface* m_pFoundSurfaceToFocus = nullptr;
|
||||
SLayerSurface* m_pFoundLSToFocus = nullptr;
|
||||
CWindow* m_pFoundWindowToFocus = nullptr;
|
||||
PHLWINDOWREF m_pFoundWindowToFocus;
|
||||
|
||||
// for holding focus on buttons held
|
||||
bool m_bFocusHeldByButtons = false;
|
||||
|
|
@ -238,7 +238,7 @@ class CInputManager {
|
|||
// idle inhibitors
|
||||
struct SIdleInhibitor {
|
||||
std::shared_ptr<CIdleInhibitor> inhibitor;
|
||||
CWindow* pWindow = nullptr;
|
||||
PHLWINDOWREF pWindow;
|
||||
CHyprSignalListener windowDestroyListener;
|
||||
};
|
||||
std::vector<std::unique_ptr<SIdleInhibitor>> m_vIdleInhibitors;
|
||||
|
|
@ -249,7 +249,7 @@ class CInputManager {
|
|||
void endWorkspaceSwipe();
|
||||
|
||||
void setBorderCursorIcon(eBorderIconDirection);
|
||||
void setCursorIconOnBorder(CWindow* w);
|
||||
void setCursorIconOnBorder(PHLWINDOW w);
|
||||
|
||||
// temporary. Obeys setUntilUnset.
|
||||
void setCursorImageOverride(const std::string& name);
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) {
|
|||
void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool motion) {
|
||||
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(pTool);
|
||||
|
||||
if (const auto PWINDOW = g_pCompositor->m_pLastWindow; PWINDOW) {
|
||||
if (const auto PWINDOW = g_pCompositor->m_pLastWindow.lock(); PWINDOW) {
|
||||
const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal();
|
||||
|
||||
if (PTOOL->pSurface != g_pInputManager->m_pLastMouseSurface)
|
||||
|
|
|
|||
|
|
@ -64,12 +64,13 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {
|
|||
|
||||
Vector2D local;
|
||||
|
||||
if (m_sTouchData.touchFocusWindow) {
|
||||
if (m_sTouchData.touchFocusWindow->m_bIsX11) {
|
||||
local = (g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchFocusWindow->m_vRealPosition.goal()) * m_sTouchData.touchFocusWindow->m_fX11SurfaceScaledBy;
|
||||
m_sTouchData.touchSurfaceOrigin = m_sTouchData.touchFocusWindow->m_vRealPosition.goal();
|
||||
if (!m_sTouchData.touchFocusWindow.expired()) {
|
||||
if (m_sTouchData.touchFocusWindow.lock()->m_bIsX11) {
|
||||
local = (g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchFocusWindow.lock()->m_vRealPosition.goal()) *
|
||||
m_sTouchData.touchFocusWindow.lock()->m_fX11SurfaceScaledBy;
|
||||
m_sTouchData.touchSurfaceOrigin = m_sTouchData.touchFocusWindow.lock()->m_vRealPosition.goal();
|
||||
} else {
|
||||
g_pCompositor->vectorWindowToSurface(g_pInputManager->getMouseCoordsInternal(), m_sTouchData.touchFocusWindow, local);
|
||||
g_pCompositor->vectorWindowToSurface(g_pInputManager->getMouseCoordsInternal(), m_sTouchData.touchFocusWindow.lock(), local);
|
||||
m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
|
||||
}
|
||||
} else if (m_sTouchData.touchFocusLS) {
|
||||
|
|
@ -126,14 +127,14 @@ void CInputManager::onTouchMove(wlr_touch_motion_event* e) {
|
|||
updateWorkspaceSwipe(SWIPEDISTANCE * (1 - (VERTANIMS ? e->y : e->x)));
|
||||
return;
|
||||
}
|
||||
if (m_sTouchData.touchFocusWindow && g_pCompositor->windowValidMapped(m_sTouchData.touchFocusWindow)) {
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusWindow->m_iMonitorID);
|
||||
if (validMapped(m_sTouchData.touchFocusWindow)) {
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusWindow.lock()->m_iMonitorID);
|
||||
|
||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
|
||||
|
||||
auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin;
|
||||
if (m_sTouchData.touchFocusWindow->m_bIsX11)
|
||||
local = local * m_sTouchData.touchFocusWindow->m_fX11SurfaceScaledBy;
|
||||
if (m_sTouchData.touchFocusWindow.lock()->m_bIsX11)
|
||||
local = local * m_sTouchData.touchFocusWindow.lock()->m_fX11SurfaceScaledBy;
|
||||
|
||||
wlr_seat_touch_notify_motion(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id, local.x, local.y);
|
||||
// wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, e->time_msec, local.x, local.y);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue