renderer: add more uniforms to the screen shader (#11986)
These are: pointer_shape from the cursor-shape-v1 protocol prepared for v2, along with left_ptr...bottom_right_corner and killing (Hyprland specific)
pointer_shape_previous with
pointer_switch_time to blend between shapes
pointer_size scaled size as used by the normal cursor
pointer_pressed_positions[32] with
pointer_pressed_times[32] and
pointer_pressed_killed(32 bits) for click/touch animations and if they killed something
pointer_inactive_timeout with
pointer_last_active to smoothly fade the pointer out
pointer_hidden to hide it when the cursor is hidden (excluding by cursor:invisible as this config value can be used to turn off the normal cursor, which is useful when drawing it with the screen shader)
This commit is contained in:
parent
474cd004df
commit
46dab01bcc
11 changed files with 215 additions and 25 deletions
|
|
@ -26,6 +26,7 @@
|
|||
#include "../hyprerror/HyprError.hpp"
|
||||
#include "../debug/HyprDebugOverlay.hpp"
|
||||
#include "../debug/HyprNotificationOverlay.hpp"
|
||||
#include "helpers/CursorShapes.hpp"
|
||||
#include "helpers/Monitor.hpp"
|
||||
#include "pass/TexPassElement.hpp"
|
||||
#include "pass/ClearPassElement.hpp"
|
||||
|
|
@ -2042,6 +2043,42 @@ void CHyprRenderer::setCursorFromName(const std::string& name, bool force) {
|
|||
return;
|
||||
|
||||
m_lastCursorData.name = name;
|
||||
|
||||
static auto getShapeOrDefault = [](std::string_view name) -> wpCursorShapeDeviceV1Shape {
|
||||
const auto it = std::ranges::find(CURSOR_SHAPE_NAMES, name);
|
||||
|
||||
if (it == CURSOR_SHAPE_NAMES.end()) {
|
||||
// clang-format off
|
||||
static const auto overrites = std::unordered_map<std::string_view, wpCursorShapeDeviceV1Shape> {
|
||||
{"top_side", WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_N_RESIZE},
|
||||
{"bottom_side", WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_S_RESIZE},
|
||||
{"left_side", WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_W_RESIZE},
|
||||
{"right_side", WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_E_RESIZE},
|
||||
{"top_left_corner", WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NW_RESIZE},
|
||||
{"bottom_left_corner", WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_SW_RESIZE},
|
||||
{"top_right_corner", WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NE_RESIZE},
|
||||
{"bottom_right_corner", WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_SE_RESIZE},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
if (overrites.contains(name))
|
||||
return overrites.at(name);
|
||||
|
||||
return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT;
|
||||
}
|
||||
|
||||
return sc<wpCursorShapeDeviceV1Shape>(std::distance(CURSOR_SHAPE_NAMES.begin(), it));
|
||||
};
|
||||
|
||||
const auto newShape = getShapeOrDefault(name);
|
||||
|
||||
if (newShape != m_lastCursorData.shape) {
|
||||
m_lastCursorData.shapePrevious = m_lastCursorData.shape;
|
||||
m_lastCursorData.switchedTimer.reset();
|
||||
}
|
||||
|
||||
m_lastCursorData.shape = newShape;
|
||||
|
||||
m_lastCursorData.surf.reset();
|
||||
|
||||
if (m_cursorHidden && !force)
|
||||
|
|
@ -2066,7 +2103,9 @@ void CHyprRenderer::ensureCursorRenderingMode() {
|
|||
if (*PCURSORTIMEOUT > 0)
|
||||
m_cursorHiddenConditions.hiddenOnTimeout = *PCURSORTIMEOUT < g_pInputManager->m_lastCursorMovement.getSeconds();
|
||||
|
||||
const bool HIDE = m_cursorHiddenConditions.hiddenOnTimeout || m_cursorHiddenConditions.hiddenOnTouch || m_cursorHiddenConditions.hiddenOnKeyboard || (*PINVISIBLE != 0);
|
||||
m_cursorHiddenByCondition = m_cursorHiddenConditions.hiddenOnTimeout || m_cursorHiddenConditions.hiddenOnTouch || m_cursorHiddenConditions.hiddenOnKeyboard;
|
||||
|
||||
const bool HIDE = m_cursorHiddenByCondition || (*PINVISIBLE != 0);
|
||||
|
||||
if (HIDE == m_cursorHidden)
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue