Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ https://github.com/KZDKM/Hyprspace/assets/41317840/ed1a585a-30d5-4a79-a6da-8cc07
- [x] Autodrag windows
- [x] Autoscroll workspaces
- [x] Responsive workspace switching
- [x] Responsive exiting
- [x] Responsive exiting
- [x] Exit on click / switch
- [x] Exit with escape key
- [x] Blacklisting workspaces
Expand Down Expand Up @@ -151,7 +151,7 @@ Refer to the [Hyprland wiki](https://wiki.hyprland.org/Nix/Hyprland-on-Home-Mana
- Use `plugin:overview:overrideAnimSpeed` to override the animation speed

### Behaviors
- `plugin:overview:autoDrag` mouse click always drags window when overview is open
- `plugin:overview:autoDrag` mouse click always drags window when overview is open; otherwise, it requires holding Super + mouse click
- `plugin:overview:autoScroll` mouse scroll on active workspace area always switch workspace
- `plugin:overview:exitOnClick` mouse click without dragging exits overview
- `plugin:overview:switchOnDrop` switch to the workspace when a window is droppped into it
Expand All @@ -166,5 +166,3 @@ Refer to the [Hyprland wiki](https://wiki.hyprland.org/Nix/Hyprland-on-Home-Mana
- `gestures:workspace_swipe_fingers`
- `gestures:workspace_swipe_cancel_ratio`
- `gestures:workspace_swipe_min_speed_to_force`


2 changes: 2 additions & 0 deletions src/Globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#include <hyprland/src/Compositor.hpp>
#include <hyprland/src/render/Renderer.hpp>
#include <hyprland/src/managers/input/InputManager.hpp>
#include <hyprland/src/managers/SeatManager.hpp>
#include <hyprland/src/managers/LayoutManager.hpp>
#include <hyprland/src/managers/AnimationManager.hpp>
#include <hyprland/src/devices/IKeyboard.hpp>
#include <hyprland/src/config/ConfigValue.hpp>

inline HANDLE pHandle = NULL;
Expand Down
41 changes: 32 additions & 9 deletions src/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,40 @@ bool CHyprspaceWidget::buttonEvent(bool pressed, Vector2D coords) {
}

// if the cursor is hovering over workspace, clicking should switch workspace instead of starting window drag
if (Config::autoDrag && (targetWorkspace == nullptr || !pressed)) {
// when overview is active, always drag windows on mouse click
if (const auto curWindow = g_pInputManager->currentlyDraggedWindow.lock()) {
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
g_pInputManager->currentlyDraggedWindow.reset();
g_pInputManager->dragMode = MBIND_INVALID;
if (targetWorkspace == nullptr || !pressed) {
bool canDrag = Config::autoDrag;

// if auto drag is disabled, check if super is pressed
if (!canDrag) {
uint32_t currentModifiers = 0;

if (g_pInputManager && g_pSeatManager->keyboard) {
currentModifiers = g_pSeatManager->keyboard->modifiersState.depressed;
}

const uint32_t HYPRLAND_SUPER_MOD = HL_MODIFIER_META;
const uint32_t HYPRLAND_OTHER_SIGNIFICANT_MODS = HL_MODIFIER_SHIFT | HL_MODIFIER_CTRL | HL_MODIFIER_ALT;

bool isOnlySuperPressed = (currentModifiers & HYPRLAND_SUPER_MOD) &&
!(currentModifiers & HYPRLAND_OTHER_SIGNIFICANT_MODS);

canDrag = isOnlySuperPressed;
}
std::string keybind = (pressed ? "1" : "0") + std::string("movewindow");
(*(tMouseKeybind)pMouseKeybind)(keybind);

if (canDrag) {
// when overview is active, always drag windows on mouse click/super + mouse click
if (const auto curWindow = g_pInputManager->currentlyDraggedWindow.lock()) {
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
g_pInputManager->currentlyDraggedWindow.reset();
g_pInputManager->dragMode = MBIND_INVALID;
}

std::string keybind = (pressed ? "1" : "0") + std::string("movewindow");
(*(tMouseKeybind)pMouseKeybind)(keybind);
}

Return = false;
}
Return = false;

// release window on workspace to drop it in
if (targetWindow && targetWorkspace != nullptr && !pressed) {
Expand Down
10 changes: 5 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bool Config::overrideGaps = true;
int Config::gapsIn = 20;
int Config::gapsOut = 60;

bool Config::autoDrag = true;
bool Config::autoDrag = false;
bool Config::autoScroll = true;
bool Config::exitOnClick = true;
bool Config::switchOnDrop = false;
Expand Down Expand Up @@ -259,11 +259,11 @@ void onKeyPress(void* thisptr, SCallbackInfo& info, std::any args) {

// Get configured exit key (default to ESC if not configured)
const auto exitKey = std::any_cast<Hyprlang::INT>(HyprlandAPI::getConfigValue(pHandle, "plugin:overview:exitKey")->getValue());

// If exit key is 0, disable keyboard exit
if (exitKey == 0)
return;

if (e.keycode == exitKey) {
// close all panels
bool overviewActive = false;
Expand Down Expand Up @@ -425,7 +425,7 @@ void reloadConfig() {
Config::disableBlur = std::any_cast<Hyprlang::INT>(HyprlandAPI::getConfigValue(pHandle, "plugin:overview:disableBlur")->getValue());

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

// We don't need to store exitKey in Config namespace as it's only used in onKeyPress

for (auto& widget : g_overviewWidgets) {
Expand Down Expand Up @@ -486,7 +486,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE inHandle) {
HyprlandAPI::addConfigValue(pHandle, "plugin:overview:gapsIn", Hyprlang::INT{20});
HyprlandAPI::addConfigValue(pHandle, "plugin:overview:gapsOut", Hyprlang::INT{60});

HyprlandAPI::addConfigValue(pHandle, "plugin:overview:autoDrag", Hyprlang::INT{1});
HyprlandAPI::addConfigValue(pHandle, "plugin:overview:autoDrag", Hyprlang::INT{0});
HyprlandAPI::addConfigValue(pHandle, "plugin:overview:autoScroll", Hyprlang::INT{1});
HyprlandAPI::addConfigValue(pHandle, "plugin:overview:exitOnClick", Hyprlang::INT{1});
HyprlandAPI::addConfigValue(pHandle, "plugin:overview:switchOnDrop", Hyprlang::INT{0});
Expand Down