Try mouse wheel configuration

This commit is contained in:
Darksome 2022-07-15 21:54:05 +03:00
parent 5388b54442
commit 1eceae811f
5 changed files with 29 additions and 21 deletions

View file

@ -102,3 +102,6 @@ bind=ALT,7,movetoworkspace,7
bind=ALT,8,movetoworkspace,8
bind=ALT,9,movetoworkspace,9
bind=ALT,0,movetoworkspace,10
bind=SUPER,mouse_down,workspace,+1
bind=SUPER,mouse_up,workspace,-1

View file

@ -111,4 +111,7 @@ bind=ALT,7,movetoworkspace,7
bind=ALT,8,movetoworkspace,8
bind=ALT,9,movetoworkspace,9
bind=ALT,0,movetoworkspace,10
bind=SUPER,mouse_down,workspace,+1
bind=SUPER,mouse_up,workspace,-1
)#";

View file

@ -82,10 +82,10 @@ uint32_t CKeybindManager::stringToModMask(std::string mods) {
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;
if (handleInternalKeybinds(key))
if (handleInternalKeybinds(keysym))
return true;
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)
continue;
if (k.keycode != -1) {
if (!key.empty()) {
if (key != k.key)
continue;
} else if (k.keycode != -1) {
if (keycode != k.keycode)
continue;
} else {
if (key == 0)
if (keysym == 0)
continue; // this is a keycode check run
// 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);
// small TODO: fix 0-9 keys and other modified ones with shift
if (key != KBKEY && key != KBKEYUPPER)
if (keysym != KBKEY && keysym != KBKEYUPPER)
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());
} else {
// 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);
}

View file

@ -20,7 +20,7 @@ class CKeybindManager {
public:
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 removeKeybind(uint32_t, const std::string&);
uint32_t stringToModMask(std::string);

View file

@ -376,21 +376,20 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
}
void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
const auto PKEYBOARD = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
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) {
const auto MODS = accumulateModsFromAllKBs();
bool found = false;
if (e->source == WLR_AXIS_SOURCE_WHEEL && e->orientation == WLR_AXIS_ORIENTATION_VERTICAL) {
if (e->delta < 0) {
g_pKeybindManager->m_mDispatchers["workspace"]("-1");
found = g_pKeybindManager->handleKeybinds(MODS, "mouse_down", 0, 0);
} else {
g_pKeybindManager->m_mDispatchers["workspace"]("m+1");
}
return;
found = g_pKeybindManager->handleKeybinds(MODS, "mouse_up", 0, 0);
}
}
if (!found) {
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() {
@ -631,10 +630,12 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar
bool found = false;
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
for (int i = 0; i < syms; ++i)
found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i], 0) || found;
static const std::string empty = "";
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) {
// hee hee
}