Skip to content

Commit

Permalink
add option to disable gesture
Browse files Browse the repository at this point in the history
  • Loading branch information
KZDKM committed Apr 13, 2024
1 parent cc0b2ad commit 9418d84
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Refer to the [Hyprland wiki](https://wiki.hyprland.org/Nix/Hyprland-on-Home-Mana
- `plugin:overview:exitOnSwitch` overview exits when overview is switched by clicking on workspace view or by `switchOnDrop`
- `plugin:overview:showNewWorkspace` add a new empty workspace at the end of workspaces view
- `plugin:overview:showEmptyWorkspace` show empty workspaces that are inbetween non-empty workspaces
- `plugin:overview:disableGestures`
- Touchpad gesture behavior follows Hyprland workspace swipe behavior
- `gestures:workspace_swipe_fingers`
- `gestures:workspace_swipe_min_speed_to_force`
Expand Down
2 changes: 2 additions & 0 deletions src/Globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ namespace Config {
extern bool showNewWorkspace;
extern bool showEmptyWorkspace;

extern bool disableGestures;

extern float overrideAnimSpeed;
extern float dragAlpha;
}
Expand Down
12 changes: 12 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ bool Config::exitOnSwitch = false;
bool Config::showNewWorkspace = true;
bool Config::showEmptyWorkspace = true;

bool Config::disableGestures = false;

float Config::overrideAnimSpeed = 0;

float Config::dragAlpha = 0.2;
Expand Down Expand Up @@ -167,6 +169,8 @@ void onMouseAxis(void* thisptr, SCallbackInfo& info, std::any args) {

void onSwipeBegin(void* thisptr, SCallbackInfo& info, std::any args) {

if (Config::disableGestures) return;

const auto e = std::any_cast<wlr_pointer_swipe_begin_event*>(args);

const auto widget = getWidgetForMonitor(g_pCompositor->getMonitorFromCursor());
Expand All @@ -183,6 +187,8 @@ void onSwipeBegin(void* thisptr, SCallbackInfo& info, std::any args) {

void onSwipeUpdate(void* thisptr, SCallbackInfo& info, std::any args) {

if (Config::disableGestures) return;

const auto e = std::any_cast<wlr_pointer_swipe_update_event*>(args);

const auto widget = getWidgetForMonitor(g_pCompositor->getMonitorFromCursor());
Expand All @@ -192,6 +198,8 @@ void onSwipeUpdate(void* thisptr, SCallbackInfo& info, std::any args) {

void onSwipeEnd(void* thisptr, SCallbackInfo& info, std::any args) {

if (Config::disableGestures) return;

const auto e = std::any_cast<wlr_pointer_swipe_end_event*>(args);

const auto widget = getWidgetForMonitor(g_pCompositor->getMonitorFromCursor());
Expand Down Expand Up @@ -275,6 +283,8 @@ void reloadConfig() {
Config::exitOnSwitch = std::any_cast<Hyprlang::INT>(HyprlandAPI::getConfigValue(pHandle, "plugin:overview:exitOnSwitch")->getValue());
Config::showNewWorkspace = std::any_cast<Hyprlang::INT>(HyprlandAPI::getConfigValue(pHandle, "plugin:overview:showNewWorkspace")->getValue());
Config::showEmptyWorkspace = std::any_cast<Hyprlang::INT>(HyprlandAPI::getConfigValue(pHandle, "plugin:overview:showEmptyWorkspace")->getValue());

Config::disableGestures = std::any_cast<Hyprlang::INT>(HyprlandAPI::getConfigValue(pHandle, "plugin:overview:disableGestures")->getValue());

Config::overrideAnimSpeed = std::any_cast<Hyprlang::FLOAT>(HyprlandAPI::getConfigValue(pHandle, "plugin:overview:overrideAnimSpeed")->getValue());

Expand Down Expand Up @@ -337,6 +347,8 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE inHandle) {
HyprlandAPI::addConfigValue(pHandle, "plugin:overview:showNewWorkspace", Hyprlang::INT{1});
HyprlandAPI::addConfigValue(pHandle, "plugin:overview:showEmptyWorkspace", Hyprlang::INT{1});

HyprlandAPI::addConfigValue(pHandle, "plugin:overview:disableGestures", Hyprlang::INT{1});

HyprlandAPI::addConfigValue(pHandle, "plugin:overview:overrideAnimSpeed", Hyprlang::FLOAT{0.0});
HyprlandAPI::addConfigValue(pHandle, "plugin:overview:dragAlpha", Hyprlang::FLOAT{0.2});

Expand Down

0 comments on commit 9418d84

Please sign in to comment.