mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-10 19:45:58 +01:00
parent
a197fe3c11
commit
48ecb13b14
2 changed files with 41 additions and 19 deletions
|
@ -2020,10 +2020,10 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
return true;
|
||||
}
|
||||
|
||||
void CHyprRenderer::setCursorSurface(wlr_surface* surf, int hotspotX, int hotspotY) {
|
||||
void CHyprRenderer::setCursorSurface(wlr_surface* surf, int hotspotX, int hotspotY, bool force) {
|
||||
m_bCursorHasSurface = surf;
|
||||
|
||||
if (surf == m_sLastCursorData.surf)
|
||||
if ((surf == m_sLastCursorData.surf || m_bCursorHidden) && !force)
|
||||
return;
|
||||
|
||||
m_sLastCursorData.name = "";
|
||||
|
@ -2034,10 +2034,10 @@ void CHyprRenderer::setCursorSurface(wlr_surface* surf, int hotspotX, int hotspo
|
|||
wlr_cursor_set_surface(g_pCompositor->m_sWLRCursor, surf, hotspotX, hotspotY);
|
||||
}
|
||||
|
||||
void CHyprRenderer::setCursorFromName(const std::string& name) {
|
||||
void CHyprRenderer::setCursorFromName(const std::string& name, bool force) {
|
||||
m_bCursorHasSurface = true;
|
||||
|
||||
if (name == m_sLastCursorData.name)
|
||||
if ((name == m_sLastCursorData.name || m_bCursorHidden) && !force)
|
||||
return;
|
||||
|
||||
m_sLastCursorData.name = name;
|
||||
|
@ -2055,28 +2055,49 @@ void CHyprRenderer::ensureCursorRenderingMode() {
|
|||
if (*PCURSORTIMEOUT > 0 || *PHIDEONTOUCH) {
|
||||
const bool HIDE = (*PCURSORTIMEOUT > 0 && *PCURSORTIMEOUT < PASSEDCURSORSECONDS) || (g_pInputManager->m_bLastInputTouch && *PHIDEONTOUCH);
|
||||
|
||||
if (HIDE && !m_bTimeoutRequestedCursorHide) {
|
||||
m_bTimeoutRequestedCursorHide = true;
|
||||
|
||||
if (HIDE && !m_bCursorHidden) {
|
||||
Debug::log(LOG, "Hiding the cursor (timeout)");
|
||||
|
||||
for (auto& m : g_pCompositor->m_vMonitors)
|
||||
g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area?
|
||||
} else if (!HIDE && m_bTimeoutRequestedCursorHide) {
|
||||
m_bTimeoutRequestedCursorHide = false;
|
||||
|
||||
setCursorHidden(true);
|
||||
|
||||
} else if (!HIDE && m_bCursorHidden) {
|
||||
Debug::log(LOG, "Showing the cursor (timeout)");
|
||||
|
||||
for (auto& m : g_pCompositor->m_vMonitors)
|
||||
g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area?
|
||||
|
||||
setCursorHidden(false);
|
||||
}
|
||||
} else {
|
||||
m_bTimeoutRequestedCursorHide = false;
|
||||
setCursorHidden(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CHyprRenderer::setCursorHidden(bool hide) {
|
||||
|
||||
if (hide == m_bCursorHidden)
|
||||
return;
|
||||
|
||||
m_bCursorHidden = hide;
|
||||
|
||||
if (hide) {
|
||||
wlr_cursor_unset_image(g_pCompositor->m_sWLRCursor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_sLastCursorData.surf.has_value())
|
||||
setCursorSurface(m_sLastCursorData.surf.value(), m_sLastCursorData.hotspotX, m_sLastCursorData.hotspotY, true);
|
||||
else if (!m_sLastCursorData.name.empty())
|
||||
setCursorFromName(m_sLastCursorData.name, true);
|
||||
else
|
||||
setCursorFromName("left_ptr", true);
|
||||
}
|
||||
|
||||
bool CHyprRenderer::shouldRenderCursor() {
|
||||
return !m_bTimeoutRequestedCursorHide && !m_bWindowRequestedCursorHide && m_bCursorHasSurface;
|
||||
return !m_bCursorHidden && !m_bWindowRequestedCursorHide && m_bCursorHasSurface;
|
||||
}
|
||||
|
||||
std::tuple<float, float, float> CHyprRenderer::getRenderTimes(CMonitor* pMonitor) {
|
||||
|
|
|
@ -56,14 +56,15 @@ class CHyprRenderer {
|
|||
bool shouldRenderWindow(CWindow*);
|
||||
void ensureCursorRenderingMode();
|
||||
bool shouldRenderCursor();
|
||||
void setCursorHidden(bool hide);
|
||||
void calculateUVForSurface(CWindow*, wlr_surface*, bool main = false);
|
||||
std::tuple<float, float, float> getRenderTimes(CMonitor* pMonitor); // avg max min
|
||||
void renderLockscreen(CMonitor* pMonitor, timespec* now);
|
||||
void setOccludedForBackLayers(CRegion& region, CWorkspace* pWorkspace);
|
||||
bool canSkipBackBufferClear(CMonitor* pMonitor);
|
||||
void recheckSolitaryForMonitor(CMonitor* pMonitor);
|
||||
void setCursorSurface(wlr_surface* surf, int hotspotX, int hotspotY);
|
||||
void setCursorFromName(const std::string& name);
|
||||
void setCursorSurface(wlr_surface* surf, int hotspotX, int hotspotY, bool force = false);
|
||||
void setCursorFromName(const std::string& name, bool force = false);
|
||||
void renderSoftwareCursors(CMonitor* pMonitor, const CRegion& damage, std::optional<Vector2D> overridePos = {});
|
||||
void onRenderbufferDestroy(CRenderbuffer* rb);
|
||||
CRenderbuffer* getCurrentRBO();
|
||||
|
@ -117,7 +118,7 @@ class CHyprRenderer {
|
|||
void renderWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* now, const CBox& geometry);
|
||||
void renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* now, const Vector2D& translate = {0, 0}, const float& scale = 1.f);
|
||||
|
||||
bool m_bTimeoutRequestedCursorHide = false;
|
||||
bool m_bCursorHidden = false;
|
||||
bool m_bCursorHasSurface = false;
|
||||
CRenderbuffer* m_pCurrentRenderbuffer = nullptr;
|
||||
wlr_buffer* m_pCurrentWlrBuffer = nullptr;
|
||||
|
|
Loading…
Reference in a new issue