mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 06:05:59 +01:00
Try mouse wheel configuration
This commit is contained in:
parent
5388b54442
commit
1eceae811f
5 changed files with 29 additions and 21 deletions
|
@ -102,3 +102,6 @@ bind=ALT,7,movetoworkspace,7
|
||||||
bind=ALT,8,movetoworkspace,8
|
bind=ALT,8,movetoworkspace,8
|
||||||
bind=ALT,9,movetoworkspace,9
|
bind=ALT,9,movetoworkspace,9
|
||||||
bind=ALT,0,movetoworkspace,10
|
bind=ALT,0,movetoworkspace,10
|
||||||
|
|
||||||
|
bind=SUPER,mouse_down,workspace,+1
|
||||||
|
bind=SUPER,mouse_up,workspace,-1
|
|
@ -111,4 +111,7 @@ bind=ALT,7,movetoworkspace,7
|
||||||
bind=ALT,8,movetoworkspace,8
|
bind=ALT,8,movetoworkspace,8
|
||||||
bind=ALT,9,movetoworkspace,9
|
bind=ALT,9,movetoworkspace,9
|
||||||
bind=ALT,0,movetoworkspace,10
|
bind=ALT,0,movetoworkspace,10
|
||||||
|
|
||||||
|
bind=SUPER,mouse_down,workspace,+1
|
||||||
|
bind=SUPER,mouse_up,workspace,-1
|
||||||
)#";
|
)#";
|
|
@ -82,10 +82,10 @@ uint32_t CKeybindManager::stringToModMask(std::string mods) {
|
||||||
return modMask;
|
return modMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key, const int& keycode) {
|
bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string& key, const xkb_keysym_t& keysym, const int& keycode) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if (handleInternalKeybinds(key))
|
if (handleInternalKeybinds(keysym))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (g_pCompositor->m_sSeat.exclusiveClient)
|
if (g_pCompositor->m_sSeat.exclusiveClient)
|
||||||
|
@ -95,13 +95,14 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
|
||||||
if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap)
|
if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!key.empty()) {
|
||||||
if (k.keycode != -1) {
|
if (key != k.key)
|
||||||
|
continue;
|
||||||
|
} else if (k.keycode != -1) {
|
||||||
if (keycode != k.keycode)
|
if (keycode != k.keycode)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (key == 0)
|
if (keysym == 0)
|
||||||
continue; // this is a keycode check run
|
continue; // this is a keycode check run
|
||||||
|
|
||||||
// oMg such performance hit!!11!
|
// oMg such performance hit!!11!
|
||||||
|
@ -110,7 +111,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
|
||||||
const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY);
|
const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY);
|
||||||
// small TODO: fix 0-9 keys and other modified ones with shift
|
// small TODO: fix 0-9 keys and other modified ones with shift
|
||||||
|
|
||||||
if (key != KBKEY && key != KBKEYUPPER)
|
if (keysym != KBKEY && keysym != KBKEYUPPER)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +122,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
|
||||||
Debug::log(ERR, "Inavlid handler in a keybind! (handler %s does not exist)", k.handler.c_str());
|
Debug::log(ERR, "Inavlid handler in a keybind! (handler %s does not exist)", k.handler.c_str());
|
||||||
} else {
|
} else {
|
||||||
// call the dispatcher
|
// call the dispatcher
|
||||||
Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %d)", modmask, key);
|
Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %s)", modmask, key);
|
||||||
DISPATCHER->second(k.arg);
|
DISPATCHER->second(k.arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class CKeybindManager {
|
||||||
public:
|
public:
|
||||||
CKeybindManager();
|
CKeybindManager();
|
||||||
|
|
||||||
bool handleKeybinds(const uint32_t&, const xkb_keysym_t&, const int&);
|
bool handleKeybinds(const uint32_t&, const std::string&, const xkb_keysym_t&, const int&);
|
||||||
void addKeybind(SKeybind);
|
void addKeybind(SKeybind);
|
||||||
void removeKeybind(uint32_t, const std::string&);
|
void removeKeybind(uint32_t, const std::string&);
|
||||||
uint32_t stringToModMask(std::string);
|
uint32_t stringToModMask(std::string);
|
||||||
|
|
|
@ -376,21 +376,20 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
|
void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
|
||||||
const auto PKEYBOARD = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
|
const auto MODS = accumulateModsFromAllKBs();
|
||||||
|
|
||||||
if (wlr_keyboard_get_modifiers(PKEYBOARD) == (uint32_t)g_pConfigManager->getInt("general:main_mod_internal") &&
|
|
||||||
e->source == WLR_AXIS_SOURCE_WHEEL && e->orientation == WLR_AXIS_ORIENTATION_VERTICAL) {
|
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
if (e->source == WLR_AXIS_SOURCE_WHEEL && e->orientation == WLR_AXIS_ORIENTATION_VERTICAL) {
|
||||||
if (e->delta < 0) {
|
if (e->delta < 0) {
|
||||||
g_pKeybindManager->m_mDispatchers["workspace"]("-1");
|
found = g_pKeybindManager->handleKeybinds(MODS, "mouse_down", 0, 0);
|
||||||
} else {
|
} else {
|
||||||
g_pKeybindManager->m_mDispatchers["workspace"]("m+1");
|
found = g_pKeybindManager->handleKeybinds(MODS, "mouse_up", 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, e->delta, e->delta_discrete, e->source);
|
wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, e->delta, e->delta_discrete, e->source);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2D CInputManager::getMouseCoordsInternal() {
|
Vector2D CInputManager::getMouseCoordsInternal() {
|
||||||
|
@ -631,10 +630,12 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||||
for (int i = 0; i < syms; ++i)
|
static const std::string empty = "";
|
||||||
found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i], 0) || found;
|
|
||||||
|
|
||||||
found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE) || found;
|
for (int i = 0; i < syms; ++i)
|
||||||
|
found = g_pKeybindManager->handleKeybinds(MODS, empty, keysyms[i], 0) || found;
|
||||||
|
|
||||||
|
found = g_pKeybindManager->handleKeybinds(MODS, empty, 0, KEYCODE) || found;
|
||||||
} else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
} else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
||||||
// hee hee
|
// hee hee
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue