keybinds: add inhibiting gestures under shortcut inhibitors (#12692)
This commit is contained in:
parent
ea444c35bb
commit
f8464866eb
8 changed files with 530 additions and 21 deletions
|
|
@ -868,7 +868,7 @@ CConfigManager::CConfigManager() {
|
|||
m_config->registerHandler(&::handleSubmap, "submap", {false});
|
||||
m_config->registerHandler(&::handlePlugin, "plugin", {false});
|
||||
m_config->registerHandler(&::handlePermission, "permission", {false});
|
||||
m_config->registerHandler(&::handleGesture, "gesture", {false});
|
||||
m_config->registerHandler(&::handleGesture, "gesture", {true});
|
||||
m_config->registerHandler(&::handleEnv, "env", {true});
|
||||
|
||||
// pluginza
|
||||
|
|
@ -2845,9 +2845,17 @@ std::optional<std::string> CConfigManager::handleGesture(const std::string& comm
|
|||
if (direction == TRACKPAD_GESTURE_DIR_NONE)
|
||||
return std::format("Invalid direction: {}", data[1]);
|
||||
|
||||
int startDataIdx = 2;
|
||||
uint32_t modMask = 0;
|
||||
float deltaScale = 1.F;
|
||||
int startDataIdx = 2;
|
||||
uint32_t modMask = 0;
|
||||
float deltaScale = 1.F;
|
||||
bool disableInhibit = false;
|
||||
|
||||
for (const auto arg : command.substr(7)) {
|
||||
switch (arg) {
|
||||
case 'p': disableInhibit = true; break;
|
||||
default: return "gesture: invalid flag";
|
||||
}
|
||||
}
|
||||
|
||||
while (true) {
|
||||
|
||||
|
|
@ -2870,23 +2878,26 @@ std::optional<std::string> CConfigManager::handleGesture(const std::string& comm
|
|||
|
||||
if (data[startDataIdx] == "dispatcher")
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CDispatcherTrackpadGesture>(std::string{data[startDataIdx + 1]}, data.join(",", startDataIdx + 2)), fingerCount,
|
||||
direction, modMask, deltaScale);
|
||||
direction, modMask, deltaScale, disableInhibit);
|
||||
else if (data[startDataIdx] == "workspace")
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CWorkspaceSwipeGesture>(), fingerCount, direction, modMask, deltaScale);
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CWorkspaceSwipeGesture>(), fingerCount, direction, modMask, deltaScale, disableInhibit);
|
||||
else if (data[startDataIdx] == "resize")
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CResizeTrackpadGesture>(), fingerCount, direction, modMask, deltaScale);
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CResizeTrackpadGesture>(), fingerCount, direction, modMask, deltaScale, disableInhibit);
|
||||
else if (data[startDataIdx] == "move")
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CMoveTrackpadGesture>(), fingerCount, direction, modMask, deltaScale);
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CMoveTrackpadGesture>(), fingerCount, direction, modMask, deltaScale, disableInhibit);
|
||||
else if (data[startDataIdx] == "special")
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CSpecialWorkspaceGesture>(std::string{data[startDataIdx + 1]}), fingerCount, direction, modMask, deltaScale);
|
||||
result =
|
||||
g_pTrackpadGestures->addGesture(makeUnique<CSpecialWorkspaceGesture>(std::string{data[startDataIdx + 1]}), fingerCount, direction, modMask, deltaScale, disableInhibit);
|
||||
else if (data[startDataIdx] == "close")
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CCloseTrackpadGesture>(), fingerCount, direction, modMask, deltaScale);
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CCloseTrackpadGesture>(), fingerCount, direction, modMask, deltaScale, disableInhibit);
|
||||
else if (data[startDataIdx] == "float")
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CFloatTrackpadGesture>(std::string{data[startDataIdx + 1]}), fingerCount, direction, modMask, deltaScale);
|
||||
result =
|
||||
g_pTrackpadGestures->addGesture(makeUnique<CFloatTrackpadGesture>(std::string{data[startDataIdx + 1]}), fingerCount, direction, modMask, deltaScale, disableInhibit);
|
||||
else if (data[startDataIdx] == "fullscreen")
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CFullscreenTrackpadGesture>(std::string{data[startDataIdx + 1]}), fingerCount, direction, modMask, deltaScale);
|
||||
result = g_pTrackpadGestures->addGesture(makeUnique<CFullscreenTrackpadGesture>(std::string{data[startDataIdx + 1]}), fingerCount, direction, modMask, deltaScale,
|
||||
disableInhibit);
|
||||
else if (data[startDataIdx] == "unset")
|
||||
result = g_pTrackpadGestures->removeGesture(fingerCount, direction, modMask, deltaScale);
|
||||
result = g_pTrackpadGestures->removeGesture(fingerCount, direction, modMask, deltaScale, disableInhibit);
|
||||
else
|
||||
return std::format("Invalid gesture: {}", data[startDataIdx]);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include "TrackpadGestures.hpp"
|
||||
|
||||
#include "../InputManager.hpp"
|
||||
#include "../../../config/ConfigValue.hpp"
|
||||
#include "../../../protocols/ShortcutsInhibit.hpp"
|
||||
|
||||
#include <ranges>
|
||||
|
||||
|
|
@ -54,7 +56,7 @@ const char* CTrackpadGestures::stringForDir(eTrackpadGestureDirection dir) {
|
|||
}
|
||||
|
||||
std::expected<void, std::string> CTrackpadGestures::addGesture(UP<ITrackpadGesture>&& gesture, size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask,
|
||||
float deltaScale) {
|
||||
float deltaScale, bool disableInhibit) {
|
||||
for (const auto& g : m_gestures) {
|
||||
if (g->fingerCount != fingerCount)
|
||||
continue;
|
||||
|
|
@ -84,14 +86,16 @@ std::expected<void, std::string> CTrackpadGestures::addGesture(UP<ITrackpadGestu
|
|||
}
|
||||
}
|
||||
|
||||
m_gestures.emplace_back(makeShared<CTrackpadGestures::SGestureData>(std::move(gesture), fingerCount, modMask, direction, deltaScale));
|
||||
m_gestures.emplace_back(makeShared<CTrackpadGestures::SGestureData>(std::move(gesture), fingerCount, modMask, direction, deltaScale, disableInhibit));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
std::expected<void, std::string> CTrackpadGestures::removeGesture(size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale) {
|
||||
const auto IT = std::ranges::find_if(
|
||||
m_gestures, [&](const auto& g) { return g->fingerCount == fingerCount && g->direction == direction && g->modMask == modMask && g->deltaScale == deltaScale; });
|
||||
std::expected<void, std::string> CTrackpadGestures::removeGesture(size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale,
|
||||
bool disableInhibit) {
|
||||
const auto IT = std::ranges::find_if(m_gestures, [&](const auto& g) {
|
||||
return g->fingerCount == fingerCount && g->direction == direction && g->modMask == modMask && g->deltaScale == deltaScale && g->disableInhibit == disableInhibit;
|
||||
});
|
||||
|
||||
if (IT == m_gestures.end())
|
||||
return std::unexpected("Can't remove a non-existent gesture");
|
||||
|
|
@ -114,6 +118,8 @@ void CTrackpadGestures::gestureBegin(const IPointer::SSwipeBeginEvent& e) {
|
|||
}
|
||||
|
||||
void CTrackpadGestures::gestureUpdate(const IPointer::SSwipeUpdateEvent& e) {
|
||||
static auto PDISABLEINHIBIT = CConfigValue<Hyprlang::INT>("binds:disable_keybind_grabbing");
|
||||
|
||||
if (m_gestureFindFailed)
|
||||
return;
|
||||
|
||||
|
|
@ -148,6 +154,9 @@ void CTrackpadGestures::gestureUpdate(const IPointer::SSwipeUpdateEvent& e) {
|
|||
if (g->modMask != MODS)
|
||||
continue;
|
||||
|
||||
if (PROTO::shortcutsInhibit->isInhibited() && !*PDISABLEINHIBIT && !g->disableInhibit)
|
||||
continue;
|
||||
|
||||
m_activeGesture = g;
|
||||
g->currentDirection = g->gesture->isDirectionSensitive() ? g->direction : direction;
|
||||
m_activeGesture->gesture->begin({.swipe = &e, .direction = direction, .scale = g->deltaScale});
|
||||
|
|
@ -184,6 +193,8 @@ void CTrackpadGestures::gestureBegin(const IPointer::SPinchBeginEvent& e) {
|
|||
}
|
||||
|
||||
void CTrackpadGestures::gestureUpdate(const IPointer::SPinchUpdateEvent& e) {
|
||||
static auto PDISABLEINHIBIT = CConfigValue<Hyprlang::INT>("binds:disable_keybind_grabbing");
|
||||
|
||||
if (m_gestureFindFailed)
|
||||
return;
|
||||
|
||||
|
|
@ -211,6 +222,9 @@ void CTrackpadGestures::gestureUpdate(const IPointer::SPinchUpdateEvent& e) {
|
|||
if (g->modMask != MODS)
|
||||
continue;
|
||||
|
||||
if (PROTO::shortcutsInhibit->isInhibited() && !*PDISABLEINHIBIT && !g->disableInhibit)
|
||||
continue;
|
||||
|
||||
m_activeGesture = g;
|
||||
g->currentDirection = g->gesture->isDirectionSensitive() ? g->direction : direction;
|
||||
m_activeGesture->gesture->begin({.pinch = &e, .direction = direction});
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@
|
|||
class CTrackpadGestures {
|
||||
public:
|
||||
void clearGestures();
|
||||
std::expected<void, std::string> addGesture(UP<ITrackpadGesture>&& gesture, size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale);
|
||||
std::expected<void, std::string> removeGesture(size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale);
|
||||
std::expected<void, std::string> addGesture(UP<ITrackpadGesture>&& gesture, size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale,
|
||||
bool disableInhibit);
|
||||
std::expected<void, std::string> removeGesture(size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale, bool disableInhibit);
|
||||
|
||||
void gestureBegin(const IPointer::SSwipeBeginEvent& e);
|
||||
void gestureUpdate(const IPointer::SSwipeUpdateEvent& e);
|
||||
|
|
@ -32,6 +33,7 @@ class CTrackpadGestures {
|
|||
uint32_t modMask = 0;
|
||||
eTrackpadGestureDirection direction = TRACKPAD_GESTURE_DIR_NONE; // configured dir
|
||||
float deltaScale = 1.F;
|
||||
bool disableInhibit = false;
|
||||
eTrackpadGestureDirection currentDirection = TRACKPAD_GESTURE_DIR_NONE; // actual dir of that select swipe
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue