mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-15 06:25:59 +01:00
internal: optimize cursor move a bit (#8264)
* window: inline and const getWindowMainSurfaceBox getWindowMainSurfaceBox gets called a lot of times from deep down from mousemoveunified, profiling mousemoveunified it spends quite a lot of cpu time in here, let the compiler optimize the call to getWindowMainSurfaceBox by inlining and making it const. reducing the overhead. * inputmgr: return early and use std::any_of return early in mousemoveunified to reduce the amount of unnecessery calls to various pointers when not needed, also make isconstrained use std::any_of instead of for loop to use the STL optimized paths with hopes and dreams marginally faster. * decoration: return early, reduce temporar copy return earlier and reduce the temp copies by using one .lock instead of two
This commit is contained in:
parent
a3d3b4fd64
commit
f9b52203f5
4 changed files with 27 additions and 36 deletions
|
@ -240,10 +240,6 @@ CBox CWindow::getWindowBoxUnified(uint64_t properties) {
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBox CWindow::getWindowMainSurfaceBox() {
|
|
||||||
return {m_vRealPosition.value().x, m_vRealPosition.value().y, m_vRealSize.value().x, m_vRealSize.value().y};
|
|
||||||
}
|
|
||||||
|
|
||||||
SBoxExtents CWindow::getFullWindowReservedArea() {
|
SBoxExtents CWindow::getFullWindowReservedArea() {
|
||||||
return g_pDecorationPositioner->getWindowDecorationReserved(m_pSelf.lock());
|
return g_pDecorationPositioner->getWindowDecorationReserved(m_pSelf.lock());
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,10 +396,12 @@ class CWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
CBox getFullWindowBoundingBox();
|
CBox getFullWindowBoundingBox();
|
||||||
SBoxExtents getFullWindowExtents();
|
SBoxExtents getFullWindowExtents();
|
||||||
CBox getWindowBoxUnified(uint64_t props);
|
CBox getWindowBoxUnified(uint64_t props);
|
||||||
CBox getWindowMainSurfaceBox();
|
inline CBox getWindowMainSurfaceBox() const {
|
||||||
|
return {m_vRealPosition.value().x, m_vRealPosition.value().y, m_vRealSize.value().x, m_vRealSize.value().y};
|
||||||
|
}
|
||||||
CBox getWindowIdealBoundingBoxIgnoreReserved();
|
CBox getWindowIdealBoundingBoxIgnoreReserved();
|
||||||
void addWindowDeco(std::unique_ptr<IHyprWindowDecoration> deco);
|
void addWindowDeco(std::unique_ptr<IHyprWindowDecoration> deco);
|
||||||
void updateWindowDecos();
|
void updateWindowDecos();
|
||||||
|
|
|
@ -139,6 +139,15 @@ void CInputManager::sendMotionEventsToFocused() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
|
if (!g_pCompositor->m_bReadyToProcess || g_pCompositor->m_bIsShuttingDown || g_pCompositor->m_bUnsafeState)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Vector2D const mouseCoords = getMouseCoordsInternal();
|
||||||
|
auto const MOUSECOORDSFLOORED = mouseCoords.floor();
|
||||||
|
|
||||||
|
if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored && !refocus)
|
||||||
|
return;
|
||||||
|
|
||||||
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
|
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
|
||||||
static auto PMOUSEREFOCUS = CConfigValue<Hyprlang::INT>("input:mouse_refocus");
|
static auto PMOUSEREFOCUS = CConfigValue<Hyprlang::INT>("input:mouse_refocus");
|
||||||
static auto PFOLLOWONDND = CConfigValue<Hyprlang::INT>("misc:always_follow_on_dnd");
|
static auto PFOLLOWONDND = CConfigValue<Hyprlang::INT>("misc:always_follow_on_dnd");
|
||||||
|
@ -159,15 +168,6 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
PHLWINDOW pFoundWindow;
|
PHLWINDOW pFoundWindow;
|
||||||
PHLLS pFoundLayerSurface;
|
PHLLS pFoundLayerSurface;
|
||||||
|
|
||||||
if (!g_pCompositor->m_bReadyToProcess || g_pCompositor->m_bIsShuttingDown || g_pCompositor->m_bUnsafeState)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Vector2D mouseCoords = getMouseCoordsInternal();
|
|
||||||
const auto MOUSECOORDSFLOORED = mouseCoords.floor();
|
|
||||||
|
|
||||||
if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored && !refocus)
|
|
||||||
return;
|
|
||||||
|
|
||||||
EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED);
|
EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED);
|
||||||
|
|
||||||
m_vLastCursorPosFloored = MOUSECOORDSFLOORED;
|
m_vLastCursorPosFloored = MOUSECOORDSFLOORED;
|
||||||
|
@ -1418,19 +1418,10 @@ void CInputManager::unconstrainMouse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInputManager::isConstrained() {
|
bool CInputManager::isConstrained() {
|
||||||
for (auto const& c : m_vConstraints) {
|
return std::any_of(m_vConstraints.begin(), m_vConstraints.end(), [](auto const& c) {
|
||||||
const auto C = c.lock();
|
const auto constraint = c.lock();
|
||||||
|
return constraint && constraint->isActive() && constraint->owner()->resource() == g_pCompositor->m_pLastFocus;
|
||||||
if (!C)
|
});
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!C->isActive() || C->owner()->resource() != g_pCompositor->m_pLastFocus)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInputManager::isLocked() {
|
bool CInputManager::isLocked() {
|
||||||
|
|
|
@ -297,15 +297,16 @@ SBoxExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow,
|
||||||
CBox accum = pWindow->getWindowMainSurfaceBox();
|
CBox accum = pWindow->getWindowMainSurfaceBox();
|
||||||
|
|
||||||
for (auto const& data : m_vWindowPositioningDatas) {
|
for (auto const& data : m_vWindowPositioningDatas) {
|
||||||
if (data->pWindow.lock() != pWindow)
|
if (!data->pDecoration)
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!data->pWindow.lock() || !data->pDecoration)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!(data->pDecoration->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT) && inputOnly)
|
if (!(data->pDecoration->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT) && inputOnly)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
auto const window = data->pWindow.lock();
|
||||||
|
if (!window || window != pWindow)
|
||||||
|
continue;
|
||||||
|
|
||||||
CBox decoBox;
|
CBox decoBox;
|
||||||
|
|
||||||
if (data->positioningInfo.policy == DECORATION_POSITION_ABSOLUTE) {
|
if (data->positioningInfo.policy == DECORATION_POSITION_ABSOLUTE) {
|
||||||
|
@ -373,9 +374,10 @@ CBox CDecorationPositioner::getBoxWithIncludedDecos(PHLWINDOW pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CBox CDecorationPositioner::getWindowDecorationBox(IHyprWindowDecoration* deco) {
|
CBox CDecorationPositioner::getWindowDecorationBox(IHyprWindowDecoration* deco) {
|
||||||
const auto DATA = getDataFor(deco, deco->m_pWindow.lock());
|
auto const window = deco->m_pWindow.lock();
|
||||||
|
const auto DATA = getDataFor(deco, window);
|
||||||
|
|
||||||
CBox box = DATA->lastReply.assignedGeometry;
|
CBox box = DATA->lastReply.assignedGeometry;
|
||||||
box.translate(getEdgeDefinedPoint(DATA->positioningInfo.edges, deco->m_pWindow.lock()));
|
box.translate(getEdgeDefinedPoint(DATA->positioningInfo.edges, window));
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue