Skip to content

Commit

Permalink
Merge pull request #178 from matt1432/chase-45.2
Browse files Browse the repository at this point in the history
Chase Hyprland 45.2
  • Loading branch information
horriblename authored Nov 20, 2024
2 parents cb92909 + a06677b commit c8fa4e2
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ compile_commands.json
.ccls-cache
.ccls
.direnv
result*
42 changes: 21 additions & 21 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions hyprpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ commit_pins = [
["4520b30d498daca8079365bdb909a8dea38e8d55", "78eb74357b428498a8225b2d753b2fe9a463f89e"], # v0.44.1
["f044e4c9514ec89c4c1fc8a523ca90b8cb907fb7", "070ca398300bf5b9e1a636ca057882c0312c228d"], # CMonitor* -> PHLMONITOR
["a425fbebe4cf4238e48a42f724ef2208959d66cf", "a86ed5581498186ed31241c0c246629ef771d1e6"], # v0.45.0
["12f9a0d0b93f691d4d9923716557154d74777b0a", "47f6fea6d297dbee8a9c5dea905783bde506fe79"], # v0.45.2
]

[hyprgrass]
Expand Down
23 changes: 12 additions & 11 deletions src/GestureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "wayfire/touch/touch.hpp"
#include <algorithm>
#include <cstdint>
#include <hyprutils/memory/SharedPtr.hpp>
#include <string>

#define private public
Expand Down Expand Up @@ -200,33 +201,33 @@ bool GestureManager::handleGestureBind(std::string bind, bool pressed) {
bool found = false;
Debug::log(LOG, "[hyprgrass] Looking for binds matching: {}", bind);

auto allBinds = std::ranges::views::join(std::array{g_pKeybindManager->m_lKeybinds, this->internalBinds});
auto allBinds = std::ranges::views::join(std::array{g_pKeybindManager->m_vKeybinds, this->internalBinds});

for (const auto& k : allBinds) {
if (k.key != bind)
if (k->key != bind)
continue;

const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find(k.mouse ? "mouse" : k.handler);
const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find(k->mouse ? "mouse" : k->handler);

// Should never happen, as we check in the ConfigManager, but oh well
if (DISPATCHER == g_pKeybindManager->m_mDispatchers.end()) {
Debug::log(ERR, "Invalid handler in a keybind! (handler {} does not exist)", k.handler);
Debug::log(ERR, "Invalid handler in a keybind! (handler {} does not exist)", k->handler);
continue;
}

// call the dispatcher
Debug::log(LOG, "[hyprgrass] calling dispatcher ({})", bind);

if (k.handler == "pass")
if (k->handler == "pass")
continue;

if (k.handler == "mouse") {
DISPATCHER->second((pressed ? "1" : "0") + k.arg);
if (k->handler == "mouse") {
DISPATCHER->second((pressed ? "1" : "0") + k->arg);
} else {
DISPATCHER->second(k.arg);
DISPATCHER->second(k->arg);
}

if (!k.nonConsuming) {
if (!k->nonConsuming) {
found = true;
}
}
Expand Down Expand Up @@ -519,9 +520,9 @@ void GestureManager::touchBindDispatcher(std::string args) {
const auto dispatcher = trim(argsSplit[2]);
const auto dispatcherArgs = trim(argsSplit[3]);

this->internalBinds.emplace_back(SKeybind{
this->internalBinds.emplace_back(makeShared<SKeybind>(SKeybind{
.key = key,
.handler = dispatcher,
.arg = dispatcherArgs,
});
}));
}
3 changes: 1 addition & 2 deletions src/GestureManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
#include <hyprland/src/protocols/core/Seat.hpp>
#undef private

#include <list>
#include <wayfire/touch/touch.hpp>
#include <wayland-server-core.h>

class GestureManager : public IGestureManager {
public:
uint32_t long_press_next_trigger_time;
std::list<SKeybind> internalBinds;
std::vector<SP<SKeybind>> internalBinds;

GestureManager();
~GestureManager();
Expand Down
13 changes: 7 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <hyprland/src/version.h>

#include <hyprlang.hpp>
#include <hyprutils/memory/SharedPtr.hpp>
#include <string>

const CColor s_pluginColor = {0x61 / 255.0f, 0xAF / 255.0f, 0xEF / 255.0f, 1.0f};
Expand Down Expand Up @@ -39,10 +40,10 @@ static void onPreConfigReload() {
void listInternalBinds(std::string) {
Debug::log(LogLevel::LOG, "[hyprgrass] Listing internal binds:");
for (const auto& bind : g_pGestureManager->internalBinds) {
Debug::log(LogLevel::LOG, "[hyprgrass] | gesture: {}", bind.key);
Debug::log(LogLevel::LOG, "[hyprgrass] | dispatcher: {}", bind.handler);
Debug::log(LogLevel::LOG, "[hyprgrass] | arg: {}", bind.arg);
Debug::log(LogLevel::LOG, "[hyprgrass] | mouse: {}", bind.mouse);
Debug::log(LogLevel::LOG, "[hyprgrass] | gesture: {}", bind->key);
Debug::log(LogLevel::LOG, "[hyprgrass] | dispatcher: {}", bind->handler);
Debug::log(LogLevel::LOG, "[hyprgrass] | arg: {}", bind->arg);
Debug::log(LogLevel::LOG, "[hyprgrass] | mouse: {}", bind->mouse);
Debug::log(LogLevel::LOG, "[hyprgrass] |");
}
}
Expand All @@ -67,12 +68,12 @@ Hyprlang::CParseResult onNewBind(const char* K, const char* V) {
const auto dispatcher = mouse ? "mouse" : vars[2];
const auto dispatcherArgs = mouse ? vars[2] : vars[3];

g_pGestureManager->internalBinds.emplace_back(SKeybind{
g_pGestureManager->internalBinds.emplace_back(makeShared<SKeybind>(SKeybind{
.key = key,
.handler = dispatcher,
.arg = dispatcherArgs,
.mouse = mouse,
});
}));

return result;
}
Expand Down

0 comments on commit c8fa4e2

Please sign in to comment.