From 6a47a305f8e5ddd7a4e813b47aca2af188e00d26 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Jun 2022 20:08:19 +0200 Subject: fix some xwayland popups --- src/managers/XWaylandManager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 65f5ddd8..fbb6693e 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -146,8 +146,10 @@ bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) { if (pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DIALOG"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_SPLASH"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLBAR"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_UTILITY"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLTIP"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_POPUP_MENU"] || - pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"]) + pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"] || + pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_MENU"]) { + pWindow->m_bNoInitialFocus = true; return true; } -- cgit v1.2.3 From 44aeb1fc909ec9cb3e6b82a5397e9eec8839192b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Jun 2022 22:15:06 +0200 Subject: added decoration:shadow_offset --- src/managers/AnimationManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 2ceefdd4..e8f1a1f1 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -47,7 +47,7 @@ void CAnimationManager::tick() { wlr_box WLRBOXPREV = {0,0,0,0}; if (PWINDOW) { - WLRBOXPREV = {(int)PWINDOW->m_vRealPosition.vec().x - (int)*PBORDERSIZE - 1, (int)PWINDOW->m_vRealPosition.vec().y - (int)*PBORDERSIZE - 1, (int)PWINDOW->m_vRealSize.vec().x + 2 * (int)*PBORDERSIZE + 2, (int)PWINDOW->m_vRealSize.vec().y + 2 * (int)*PBORDERSIZE + 2}; + WLRBOXPREV = PWINDOW->getFullWindowBoundingBox(); } else if (PWORKSPACE) { const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID); WLRBOXPREV = {(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecSize.x, (int)PMONITOR->vecSize.y}; -- cgit v1.2.3 From 3d48469cb43ac0609b112aea4e233276e04c4118 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 27 Jun 2022 00:25:37 +0200 Subject: fix decos with workspace offset --- src/managers/AnimationManager.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/managers') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index e8f1a1f1..61221938 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -150,8 +150,16 @@ void CAnimationManager::tick() { if (PWINDOW) { g_pHyprRenderer->damageWindow(PWINDOW); - for (auto& wd : PWINDOW->m_dWindowDecorations) { - wd->updateWindow(PWINDOW); + PWINDOW->updateWindowDecos(); + } else if (PWORKSPACE) { + for (auto& w : g_pCompositor->m_lWindows) { + if (!w.m_bIsMapped || w.m_bHidden) + continue; + + if (w.m_iWorkspaceID != PWORKSPACE->m_iID) + continue; + + w.updateWindowDecos(); } } break; -- cgit v1.2.3 From 781526dac58619fa313ca9bf86bfd712c01cb68f Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 27 Jun 2022 13:42:20 +0200 Subject: added hyprctl kill --- src/managers/KeybindManager.cpp | 23 +++++++-- src/managers/KeybindManager.hpp | 1 + src/managers/input/InputManager.cpp | 96 +++++++++++++++++++++++++++++++++++-- src/managers/input/InputManager.hpp | 15 ++++++ 4 files changed, 127 insertions(+), 8 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 10694e1b..aab79458 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -108,7 +108,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t return found; } -bool CKeybindManager::handleInternalKeybinds(xkb_keysym_t keysym) { +bool CKeybindManager::handleVT(xkb_keysym_t keysym) { // Handles the CTRL+ALT+FX TTY keybinds if (!(keysym >= XKB_KEY_XF86Switch_VT_1 && keysym <= XKB_KEY_XF86Switch_VT_12)) return false; @@ -119,19 +119,36 @@ bool CKeybindManager::handleInternalKeybinds(xkb_keysym_t keysym) { wlr_session_change_vt(PSESSION, TTY); for (auto& m : g_pCompositor->m_lMonitors) { - g_pHyprOpenGL->destroyMonitorResources(&m); // mark resources as unusable anymore + g_pHyprOpenGL->destroyMonitorResources(&m); // mark resources as unusable anymore m.noFrameSchedule = true; m.framesToSkip = 2; } Debug::log(LOG, "Switched to VT %i, destroyed all render data, frames to skip for each: 2", TTY); - + return true; } return false; } +bool CKeybindManager::handleInternalKeybinds(xkb_keysym_t keysym) { + if (handleVT(keysym)) + return true; + + // handle ESC while in kill mode + if (g_pInputManager->getClickMode() == CLICKMODE_KILL) { + const auto KBKEY = xkb_keysym_from_name("ESCAPE", XKB_KEYSYM_CASE_INSENSITIVE); + + if (keysym == KBKEY) { + g_pInputManager->setClickMode(CLICKMODE_DEFAULT); + return true; + } + } + + return false; +} + // Dispatchers void CKeybindManager::spawn(std::string args) { diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index c9132a11..117a5ec4 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -33,6 +33,7 @@ private: inline static std::string m_szCurrentSelectedSubmap = ""; bool handleInternalKeybinds(xkb_keysym_t); + bool handleVT(xkb_keysym_t); // -------------- Dispatchers -------------- // static void killActive(std::string); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index f99c6ab4..e5780608 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -164,7 +164,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords); if (!foundSurface) { - wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor); + if (m_ecbClickBehavior == CLICKMODE_KILL) + wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor); + else + wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor); wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat); @@ -211,10 +214,70 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) { m_tmrLastCursorMovement.reset(); + switch (m_ecbClickBehavior) { + case CLICKMODE_DEFAULT: + processMouseDownNormal(e); + break; + case CLICKMODE_KILL: + processMouseDownKill(e); + break; + default: + break; + } +} + +void CInputManager::processMouseRequest(wlr_seat_pointer_request_set_cursor_event* e) { + if (!g_pHyprRenderer->shouldRenderCursor()) + return; + + if (!e->surface) { + g_pHyprRenderer->m_bWindowRequestedCursorHide = true; + } else { + g_pHyprRenderer->m_bWindowRequestedCursorHide = false; + } + + if (m_ecbClickBehavior == CLICKMODE_KILL) { + wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor); + return; + } + + if (e->seat_client == g_pCompositor->m_sSeat.seat->pointer_state.focused_client) + wlr_cursor_set_surface(g_pCompositor->m_sWLRCursor, e->surface, e->hotspot_x, e->hotspot_y); +} + +eClickBehaviorMode CInputManager::getClickMode() { + return m_ecbClickBehavior; +} + +void CInputManager::setClickMode(eClickBehaviorMode mode) { + switch (mode) { + case CLICKMODE_DEFAULT: + Debug::log(LOG, "SetClickMode: DEFAULT"); + m_ecbClickBehavior = CLICKMODE_DEFAULT; + wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor); + break; + + case CLICKMODE_KILL: + Debug::log(LOG, "SetClickMode: KILL"); + m_ecbClickBehavior = CLICKMODE_KILL; + + // remove constraints + g_pCompositor->m_sSeat.mouse->constraintActive = false; + refocus(); + + // set cursor + wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor); + break; + default: + break; + } +} + +void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) { const auto PKEYBOARD = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat); - if (!PKEYBOARD) { // ??? - Debug::log(ERR, "No active keyboard in onMouseButton??"); + if (!PKEYBOARD) { // ??? + Debug::log(ERR, "No active keyboard in processMouseDownNormal??"); return; } @@ -242,7 +305,7 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) { currentlyDraggedWindow = nullptr; dragButton = -1; } - + break; } @@ -250,7 +313,30 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) { if (g_pCompositor->doesSeatAcceptInput(g_pCompositor->m_pLastFocus)) { wlr_seat_pointer_notify_button(g_pCompositor->m_sSeat.seat, e->time_msec, e->button, e->state); } - +} + +void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) { + switch (e->state) { + case WLR_BUTTON_PRESSED: { + const auto PWINDOW = g_pCompositor->m_pLastWindow; + + if (!g_pCompositor->windowValidMapped(PWINDOW)){ + Debug::log(ERR, "Cannot kill invalid window!"); + break; + } + + // kill the mf + kill(PWINDOW->getPID(), SIGKILL); + break; + } + case WLR_BUTTON_RELEASED: + break; + default: + break; + } + + // reset click behavior mode + m_ecbClickBehavior = CLICKMODE_DEFAULT; } Vector2D CInputManager::getMouseCoordsInternal() { diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 73c59b8f..5089e5e1 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -6,6 +6,11 @@ #include "../../Window.hpp" #include "../../helpers/Timer.hpp" +enum eClickBehaviorMode { + CLICKMODE_DEFAULT = 0, + CLICKMODE_KILL +}; + class CInputManager { public: @@ -31,6 +36,10 @@ public: void updateDragIcon(); void updateCapabilities(wlr_input_device*); + void setClickMode(eClickBehaviorMode); + eClickBehaviorMode getClickMode(); + void processMouseRequest(wlr_seat_pointer_request_set_cursor_event*); + // for dragging floating windows CWindow* currentlyDraggedWindow = nullptr; @@ -57,6 +66,12 @@ public: private: + // for click behavior override + eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT; + + void processMouseDownNormal(wlr_pointer_button_event* e); + void processMouseDownKill(wlr_pointer_button_event* e); + uint32_t m_uiCapabilities = 0; void mouseMoveUnified(uint32_t, bool refocus = false); -- cgit v1.2.3 From 2cdb29aa105a8f045cf87b900d1cb30a76bfa915 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 27 Jun 2022 19:46:04 +0200 Subject: fix anims with special workspace --- src/managers/KeybindManager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index aab79458..99b758b0 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -883,7 +883,10 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) { g_pCompositor->m_pLastMonitor->specialWorkspaceOpen = true; g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID); - g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID)->startAnim(true, true); + const auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID); + + PSPECIALWORKSPACE->startAnim(true, true); + PSPECIALWORKSPACE->m_iMonitorID = g_pCompositor->m_pLastMonitor->ID; } g_pInputManager->refocus(); -- cgit v1.2.3 From 73d0259210bd70889f8e169455110177efdd0da3 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 27 Jun 2022 22:01:10 +0200 Subject: don't guard changes in activateWindow --- src/managers/XWaylandManager.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/managers') diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index fbb6693e..48687163 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -42,9 +42,6 @@ void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate) } void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) { - if (pWindow == g_pCompositor->m_pLastWindow) - return; - if (pWindow->m_bIsX11) { if (pWindow->m_uSurface.xwayland->minimized) wlr_xwayland_surface_set_minimized(pWindow->m_uSurface.xwayland, false); -- cgit v1.2.3 From 3cbd69e7039c7ed020bde7f7a58ed5c8da93155b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 28 Jun 2022 12:39:56 +0200 Subject: added createworkspace destroyworkspace events --- src/managers/KeybindManager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 99b758b0..14c535d8 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -336,7 +336,7 @@ void CKeybindManager::changeworkspace(std::string args) { if (const auto POLDWORKSPACE = g_pCompositor->getWorkspaceByID(OLDWORKSPACE); POLDWORKSPACE) POLDWORKSPACE->startAnim(false, ANIMTOLEFT); - g_pCompositor->m_lWorkspaces.emplace_back(PMONITOR->ID, workspaceToChangeTo == SPECIAL_WORKSPACE_ID); + g_pCompositor->m_lWorkspaces.emplace_back(PMONITOR->ID, workspaceName, workspaceToChangeTo == SPECIAL_WORKSPACE_ID); const auto PWORKSPACE = &g_pCompositor->m_lWorkspaces.back(); // start anim on new workspace @@ -348,7 +348,6 @@ void CKeybindManager::changeworkspace(std::string args) { PWORKSPACE->m_iID = workspaceToChangeTo; PWORKSPACE->m_iMonitorID = PMONITOR->ID; - PWORKSPACE->m_szName = workspaceName; PMONITOR->specialWorkspaceOpen = false; -- cgit v1.2.3 From 3832720273ac1390faf3df52af6d00c09c370919 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 28 Jun 2022 15:40:14 +0200 Subject: fix possible crash in cinputmanager --- src/managers/input/InputManager.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index e5780608..85767e69 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -344,9 +344,7 @@ Vector2D CInputManager::getMouseCoordsInternal() { } void CInputManager::newKeyboard(wlr_input_device* keyboard) { - m_lKeyboards.push_back(SKeyboard()); - - const auto PNEWKEYBOARD = &m_lKeyboards.back(); + const auto PNEWKEYBOARD = &m_lKeyboards.emplace_back(); PNEWKEYBOARD->keyboard = keyboard; @@ -385,9 +383,14 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { const auto VARIANT = g_pConfigManager->getString("input:kb_variant"); const auto OPTIONS = g_pConfigManager->getString("input:kb_options"); - if (RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options) { - Debug::log(LOG, "Not applying config to keyboard, it did not change."); - return; + try { + if (RULES != "" && RULES == std::string(pKeyboard->currentRules.rules) && MODEL == std::string(pKeyboard->currentRules.model) && LAYOUT == std::string(pKeyboard->currentRules.layout) && VARIANT == std::string(pKeyboard->currentRules.variant) && OPTIONS == std::string(pKeyboard->currentRules.options)) { + Debug::log(LOG, "Not applying config to keyboard, it did not change."); + return; + } + } catch (std::exception& e) { + // can be libc errors for null std::string + // we can ignore those and just apply } xkb_rule_names rules = { -- cgit v1.2.3 From 13acfb1c306f863b695f1aa2f678445bb39f4239 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 29 Jun 2022 12:06:09 +0200 Subject: fix disabling in animationmanager --- src/managers/AnimationManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/managers') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 61221938..2774ee85 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -67,7 +67,7 @@ void CAnimationManager::tick() { if (!deltazero(av->m_fValue, av->m_fGoal)) { // for disabled anims just warp - if (av->m_pEnabled == 0 || animationsDisabled) { + if (*av->m_pEnabled == 0 || animationsDisabled) { av->warp(); break; } @@ -92,7 +92,7 @@ void CAnimationManager::tick() { if (!deltazero(av->m_vValue, av->m_vGoal)) { // for disabled anims just warp - if (av->m_pEnabled == 0 || animationsDisabled) { + if (*av->m_pEnabled == 0 || animationsDisabled) { av->warp(); break; } @@ -117,7 +117,7 @@ void CAnimationManager::tick() { if (!deltazero(av->m_cValue, av->m_cGoal)) { // for disabled anims just warp - if (av->m_pEnabled == 0 || animationsDisabled) { + if (*av->m_pEnabled == 0 || animationsDisabled) { av->warp(); break; } -- cgit v1.2.3 From 6ec16fdcdaf0ffa377db492a9d7d92bdd89044d9 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 29 Jun 2022 14:15:08 +0200 Subject: damage drag and drop --- src/managers/input/InputManager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 85767e69..fe51c494 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -568,9 +568,12 @@ void CInputManager::updateDragIcon() { switch (g_pInputManager->m_sDrag.dragIcon->drag->grab_type) { case WLR_DRAG_GRAB_KEYBOARD: break; - case WLR_DRAG_GRAB_KEYBOARD_POINTER: + case WLR_DRAG_GRAB_KEYBOARD_POINTER: { + wlr_box box = {g_pInputManager->m_sDrag.pos.x - 2, g_pInputManager->m_sDrag.pos.y - 2, g_pInputManager->m_sDrag.dragIcon->surface->current.width + 4, g_pInputManager->m_sDrag.dragIcon->surface->current.height + 4}; + g_pHyprRenderer->damageBox(&box); g_pInputManager->m_sDrag.pos = g_pInputManager->getMouseCoordsInternal(); break; + } default: break; } -- cgit v1.2.3 From 9391357063b05f3dd748b36b76549b51608e3444 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 29 Jun 2022 14:44:24 +0200 Subject: fix focus on maximize --- src/managers/input/InputManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index fe51c494..93a590d8 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -145,7 +145,11 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { // then windows if (!foundSurface) { - pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); + if (PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) + pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); + else + pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); + if (pFoundWindow) { if (!pFoundWindow->m_bIsX11) { foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); -- cgit v1.2.3 From 2659afee3cbb8ee5362e0acff2a384c7c7d474fe Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 29 Jun 2022 18:19:06 +0200 Subject: force workspace events --- src/managers/EventManager.cpp | 4 ++-- src/managers/EventManager.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/managers') diff --git a/src/managers/EventManager.cpp b/src/managers/EventManager.cpp index e42e87c2..5782718d 100644 --- a/src/managers/EventManager.cpp +++ b/src/managers/EventManager.cpp @@ -104,9 +104,9 @@ void CEventManager::startThread() { }).detach(); } -void CEventManager::postEvent(const SHyprIPCEvent event) { +void CEventManager::postEvent(const SHyprIPCEvent event, bool force) { - if (m_bIgnoreEvents) { + if (m_bIgnoreEvents && !force) { Debug::log(WARN, "Suppressed (ignoreevents true) event of type %s, content: %s",event.event.c_str(), event.data.c_str()); return; } diff --git a/src/managers/EventManager.hpp b/src/managers/EventManager.hpp index ae630ce8..b9598bca 100644 --- a/src/managers/EventManager.hpp +++ b/src/managers/EventManager.hpp @@ -15,7 +15,7 @@ class CEventManager { public: CEventManager(); - void postEvent(const SHyprIPCEvent event); + void postEvent(const SHyprIPCEvent event, bool force = false); void startThread(); -- cgit v1.2.3 From b0cd90a43c7281dc339b3dab6236646b1ed6439f Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 12:09:05 +0200 Subject: refactor a bunch of layout code --- src/managers/KeybindManager.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 14c535d8..64c0d886 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -221,6 +221,9 @@ void CKeybindManager::toggleActiveFloating(std::string args) { const auto ACTIVEWINDOW = g_pCompositor->m_pLastWindow; if (g_pCompositor->windowValidMapped(ACTIVEWINDOW)) { + // remove drag status + g_pInputManager->currentlyDraggedWindow = nullptr; + ACTIVEWINDOW->m_bIsFloating = !ACTIVEWINDOW->m_bIsFloating; if (ACTIVEWINDOW->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) { -- cgit v1.2.3 From cfc1f6c211b055dc54b91e1ed94aef120c9c143c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 12:54:58 +0200 Subject: optimize animationmanager --- src/managers/AnimationManager.cpp | 107 +++++++++++++++----------------------- 1 file changed, 43 insertions(+), 64 deletions(-) (limited to 'src/managers') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 2774ee85..c26ea5f2 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -40,6 +40,16 @@ void CAnimationManager::tick() { // get speed const auto SPEED = *av->m_pSpeed == 0 ? *PANIMSPEED : *av->m_pSpeed; + // get the spent % (0 - 1) + const auto DURATIONPASSED = std::chrono::duration_cast(std::chrono::system_clock::now() - av->animationBegin).count(); + const float SPENT = std::clamp((DURATIONPASSED / 100.f) / SPEED, 0.f, 1.f); + + // first of all, check if we need to update it at all + if (SPENT >= 1.f) { + av->warp(); + continue; + } + // window stuff const auto PWINDOW = (CWindow*)av->m_pWindow; const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace; @@ -58,84 +68,53 @@ void CAnimationManager::tick() { // beziers are with a switch unforto // TODO: maybe do something cleaner - // get the spent % (0 - 1) - const auto DURATIONPASSED = std::chrono::duration_cast(std::chrono::system_clock::now() - av->animationBegin).count(); - const float SPENT = std::clamp((DURATIONPASSED / 100.f) / SPEED, 0.f, 1.f); - switch (av->m_eVarType) { case AVARTYPE_FLOAT: { - if (!deltazero(av->m_fValue, av->m_fGoal)) { - - // for disabled anims just warp - if (*av->m_pEnabled == 0 || animationsDisabled) { - av->warp(); - break; - } - - const auto DELTA = av->m_fGoal - av->m_fBegun; - const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); + // for disabled anims just warp + if (*av->m_pEnabled == 0 || animationsDisabled) { + av->warp(); + break; + } - if (BEZIER != m_mBezierCurves.end()) - av->m_fValue = av->m_fBegun + BEZIER->second.getYForPoint(SPENT) * DELTA; - else - av->m_fValue = av->m_fBegun + DEFAULTBEZIER->second.getYForPoint(SPENT) * DELTA; + const auto DELTA = av->m_fGoal - av->m_fBegun; + const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); - if (SPENT >= 1.f) { - av->warp(); - } - } else { - continue; // dont process - } + if (BEZIER != m_mBezierCurves.end()) + av->m_fValue = av->m_fBegun + BEZIER->second.getYForPoint(SPENT) * DELTA; + else + av->m_fValue = av->m_fBegun + DEFAULTBEZIER->second.getYForPoint(SPENT) * DELTA; break; } case AVARTYPE_VECTOR: { - if (!deltazero(av->m_vValue, av->m_vGoal)) { - - // for disabled anims just warp - if (*av->m_pEnabled == 0 || animationsDisabled) { - av->warp(); - break; - } - - const auto DELTA = av->m_vGoal - av->m_vBegun; - const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); + // for disabled anims just warp + if (*av->m_pEnabled == 0 || animationsDisabled) { + av->warp(); + break; + } - if (BEZIER != m_mBezierCurves.end()) - av->m_vValue = av->m_vBegun + DELTA * BEZIER->second.getYForPoint(SPENT); - else - av->m_vValue = av->m_vBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT); + const auto DELTA = av->m_vGoal - av->m_vBegun; + const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); - if (SPENT >= 1.f) { - av->warp(); - } - } else { - continue; // dont process - } + if (BEZIER != m_mBezierCurves.end()) + av->m_vValue = av->m_vBegun + DELTA * BEZIER->second.getYForPoint(SPENT); + else + av->m_vValue = av->m_vBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT); break; } case AVARTYPE_COLOR: { - if (!deltazero(av->m_cValue, av->m_cGoal)) { - - // for disabled anims just warp - if (*av->m_pEnabled == 0 || animationsDisabled) { - av->warp(); - break; - } - - const auto DELTA = av->m_cGoal - av->m_cBegun; - const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); + // for disabled anims just warp + if (*av->m_pEnabled == 0 || animationsDisabled) { + av->warp(); + break; + } - if (BEZIER != m_mBezierCurves.end()) - av->m_cValue = av->m_cBegun + DELTA * BEZIER->second.getYForPoint(SPENT); - else - av->m_cValue = av->m_cBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT); + const auto DELTA = av->m_cGoal - av->m_cBegun; + const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); - if (SPENT >= 1.f) { - av->warp(); - } - } else { - continue; // dont process - } + if (BEZIER != m_mBezierCurves.end()) + av->m_cValue = av->m_cBegun + DELTA * BEZIER->second.getYForPoint(SPENT); + else + av->m_cValue = av->m_cBegun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT); break; } default: { -- cgit v1.2.3 From d1564299d23b52e6297fa4542ce42e4a54c28cbc Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 13:11:10 +0200 Subject: fix minor bug with new anim optimization --- src/managers/AnimationManager.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/managers') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index c26ea5f2..5e3df81f 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -37,6 +37,11 @@ void CAnimationManager::tick() { DEFAULTBEZIER = m_mBezierCurves.find("default"); for (auto& av : m_lAnimatedVariables) { + + // first of all, check if we need to update it at all + if (!av->isBeingAnimated()) + continue; + // get speed const auto SPEED = *av->m_pSpeed == 0 ? *PANIMSPEED : *av->m_pSpeed; @@ -44,12 +49,6 @@ void CAnimationManager::tick() { const auto DURATIONPASSED = std::chrono::duration_cast(std::chrono::system_clock::now() - av->animationBegin).count(); const float SPENT = std::clamp((DURATIONPASSED / 100.f) / SPEED, 0.f, 1.f); - // first of all, check if we need to update it at all - if (SPENT >= 1.f) { - av->warp(); - continue; - } - // window stuff const auto PWINDOW = (CWindow*)av->m_pWindow; const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace; @@ -76,6 +75,11 @@ void CAnimationManager::tick() { break; } + if (SPENT >= 1.f) { + av->warp(); + break; + } + const auto DELTA = av->m_fGoal - av->m_fBegun; const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); @@ -92,6 +96,11 @@ void CAnimationManager::tick() { break; } + if (SPENT >= 1.f) { + av->warp(); + break; + } + const auto DELTA = av->m_vGoal - av->m_vBegun; const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); @@ -108,6 +117,11 @@ void CAnimationManager::tick() { break; } + if (SPENT >= 1.f) { + av->warp(); + break; + } + const auto DELTA = av->m_cGoal - av->m_cBegun; const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); -- cgit v1.2.3 From 328b3fa4bc4f3776f2128f84709556569c4824d9 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 15:44:26 +0200 Subject: mordernize pointers --- src/managers/AnimationManager.cpp | 8 ++--- src/managers/KeybindManager.cpp | 65 ++++++++++++++++++------------------- src/managers/input/InputManager.cpp | 8 ++--- 3 files changed, 40 insertions(+), 41 deletions(-) (limited to 'src/managers') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 5e3df81f..e48b4d1e 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -145,14 +145,14 @@ void CAnimationManager::tick() { g_pHyprRenderer->damageWindow(PWINDOW); PWINDOW->updateWindowDecos(); } else if (PWORKSPACE) { - for (auto& w : g_pCompositor->m_lWindows) { - if (!w.m_bIsMapped || w.m_bHidden) + for (auto& w : g_pCompositor->m_vWindows) { + if (!w->m_bIsMapped || w->m_bHidden) continue; - if (w.m_iWorkspaceID != PWORKSPACE->m_iID) + if (w->m_iWorkspaceID != PWORKSPACE->m_iID) continue; - w.updateWindowDecos(); + w->updateWindowDecos(); } } break; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 64c0d886..e2a26781 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -118,10 +118,10 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) { const int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1; wlr_session_change_vt(PSESSION, TTY); - for (auto& m : g_pCompositor->m_lMonitors) { - g_pHyprOpenGL->destroyMonitorResources(&m); // mark resources as unusable anymore - m.noFrameSchedule = true; - m.framesToSkip = 2; + for (auto& m : g_pCompositor->m_vMonitors) { + g_pHyprOpenGL->destroyMonitorResources(m.get()); // mark resources as unusable anymore + m->noFrameSchedule = true; + m->framesToSkip = 2; } Debug::log(LOG, "Switched to VT %i, destroyed all render data, frames to skip for each: 2", TTY); @@ -339,8 +339,7 @@ void CKeybindManager::changeworkspace(std::string args) { if (const auto POLDWORKSPACE = g_pCompositor->getWorkspaceByID(OLDWORKSPACE); POLDWORKSPACE) POLDWORKSPACE->startAnim(false, ANIMTOLEFT); - g_pCompositor->m_lWorkspaces.emplace_back(PMONITOR->ID, workspaceName, workspaceToChangeTo == SPECIAL_WORKSPACE_ID); - const auto PWORKSPACE = &g_pCompositor->m_lWorkspaces.back(); + const auto PWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique(PMONITOR->ID, workspaceName, workspaceToChangeTo == SPECIAL_WORKSPACE_ID)).get(); // start anim on new workspace PWORKSPACE->startAnim(true, ANIMTOLEFT); @@ -456,8 +455,8 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) { toggleSpecialWorkspace(""); g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID)->startAnim(false, false, true); - for (auto& m : g_pCompositor->m_lMonitors) - m.specialWorkspaceOpen = false; + for (auto& m : g_pCompositor->m_vMonitors) + m->specialWorkspaceOpen = false; } g_pInputManager->refocus(); @@ -662,7 +661,7 @@ void CKeybindManager::focusMonitor(std::string arg) { Debug::log(ERR, "Error in focusMonitor: invalid num"); } - if (monID > -1 && monID < (int)g_pCompositor->m_lMonitors.size()) { + if (monID > -1 && monID < (int)g_pCompositor->m_vMonitors.size()) { changeworkspace(std::to_string(g_pCompositor->getMonitorFromID(monID)->activeWorkspace)); } else { Debug::log(ERR, "Error in focusMonitor: invalid arg 1"); @@ -681,9 +680,9 @@ void CKeybindManager::focusMonitor(std::string arg) { return; } } else { - for (auto& m : g_pCompositor->m_lMonitors) { - if (m.szName == arg) { - changeworkspace(std::to_string(m.activeWorkspace)); + for (auto& m : g_pCompositor->m_vMonitors) { + if (m->szName == arg) { + changeworkspace(std::to_string(m->activeWorkspace)); return; } } @@ -743,11 +742,11 @@ void CKeybindManager::workspaceOpt(std::string args) { PWORKSPACE->m_bDefaultPseudo = !PWORKSPACE->m_bDefaultPseudo; // apply - for (auto& w : g_pCompositor->m_lWindows) { - if (!w.m_bIsMapped || w.m_iWorkspaceID != PWORKSPACE->m_iID) + for (auto& w : g_pCompositor->m_vWindows) { + if (!w->m_bIsMapped || w->m_iWorkspaceID != PWORKSPACE->m_iID) continue; - w.m_bIsPseudotiled = PWORKSPACE->m_bDefaultPseudo; + w->m_bIsPseudotiled = PWORKSPACE->m_bDefaultPseudo; } } else if (args == "allfloat") { PWORKSPACE->m_bDefaultFloating = !PWORKSPACE->m_bDefaultFloating; @@ -755,8 +754,8 @@ void CKeybindManager::workspaceOpt(std::string args) { // we make a copy because changeWindowFloatingMode might invalidate the iterator std::deque ptrs; - for (auto& w : g_pCompositor->m_lWindows) - ptrs.push_back(&w); + for (auto& w : g_pCompositor->m_vWindows) + ptrs.push_back(w.get()); for (auto& w : ptrs) { if (!w->m_bIsMapped || w->m_iWorkspaceID != PWORKSPACE->m_iID) @@ -860,8 +859,8 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) { bool open = false; - for (auto& m : g_pCompositor->m_lMonitors) { - if (m.specialWorkspaceOpen) { + for (auto& m : g_pCompositor->m_vMonitors) { + if (m->specialWorkspaceOpen) { open = true; break; } @@ -873,10 +872,10 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) { Debug::log(LOG, "Toggling special workspace to open"); if (open) { - for (auto& m : g_pCompositor->m_lMonitors) { - if (m.specialWorkspaceOpen != !open) { - m.specialWorkspaceOpen = !open; - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID); + for (auto& m : g_pCompositor->m_vMonitors) { + if (m->specialWorkspaceOpen != !open) { + m->specialWorkspaceOpen = !open; + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID)->startAnim(false, false); } @@ -895,9 +894,9 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) { } void CKeybindManager::forceRendererReload(std::string args) { - for (auto& m : g_pCompositor->m_lMonitors) { - auto rule = g_pConfigManager->getMonitorRuleFor(m.szName); - g_pHyprRenderer->applyMonitorRule(&m, &rule, true); + for (auto& m : g_pCompositor->m_vMonitors) { + auto rule = g_pConfigManager->getMonitorRuleFor(m->szName); + g_pHyprRenderer->applyMonitorRule(m.get(), &rule, true); } } @@ -1013,22 +1012,22 @@ void CKeybindManager::circleNext(std::string) { void CKeybindManager::focusWindowByClass(std::string clazz) { std::regex classCheck(clazz); - for (auto& w : g_pCompositor->m_lWindows) { - if (!w.m_bIsMapped || w.m_bHidden) + for (auto& w : g_pCompositor->m_vWindows) { + if (!w->m_bIsMapped || w->m_bHidden) continue; - const auto windowClass = g_pXWaylandManager->getAppIDClass(&w); + const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get()); if (!std::regex_search(windowClass, classCheck)) continue; - Debug::log(LOG, "Focusing to window name: %s", w.m_szTitle.c_str()); + Debug::log(LOG, "Focusing to window name: %s", w->m_szTitle.c_str()); - changeworkspace(std::to_string(w.m_iWorkspaceID)); + changeworkspace(std::to_string(w->m_iWorkspaceID)); - g_pCompositor->focusWindow(&w); + g_pCompositor->focusWindow(w.get()); - const auto MIDPOINT = w.m_vRealPosition.goalv() + w.m_vRealSize.goalv() / 2.f; + const auto MIDPOINT = w->m_vRealPosition.goalv() + w->m_vRealSize.goalv() / 2.f; wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, MIDPOINT.x, MIDPOINT.y); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 93a590d8..e9d77489 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -123,10 +123,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { surfacePos = pFoundWindow->m_vRealPosition.vec(); // only check floating because tiled cant be over fullscreen - for (auto w = g_pCompositor->m_lWindows.rbegin(); w != g_pCompositor->m_lWindows.rend(); w++) { - wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y}; - if (((w->m_bIsFloating && w->m_bIsMapped && w->m_bCreatedOverFullscreen) || (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID) && !w->m_bHidden) { - pFoundWindow = &(*w); + for (auto w = g_pCompositor->m_vWindows.rbegin(); w != g_pCompositor->m_vWindows.rend(); w++) { + wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y}; + if ((((*w)->m_bIsFloating && (*w)->m_bIsMapped && (*w)->m_bCreatedOverFullscreen) || ((*w)->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->m_bHidden) { + pFoundWindow = (*w).get(); if (!pFoundWindow->m_bIsX11) { foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); -- cgit v1.2.3 From d010ca20492c7638d15690e888d80c6020685df1 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 21:26:00 +0200 Subject: added per-device config options --- src/managers/input/InputManager.cpp | 54 +++++++++++++++++++++++++------------ src/managers/input/Tablets.cpp | 12 +++++++++ 2 files changed, 49 insertions(+), 17 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index e9d77489..548af552 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -352,10 +352,11 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) { PNEWKEYBOARD->keyboard = keyboard; - const auto REPEATRATE = g_pConfigManager->getInt("input:repeat_rate"); - const auto REPEATDELAY = g_pConfigManager->getInt("input:repeat_delay"); - - wlr_keyboard_set_repeat_info(keyboard->keyboard, std::max(0, REPEATRATE), std::max(0, REPEATDELAY)); + try { + PNEWKEYBOARD->name = std::string(keyboard->name); + } catch (std::exception& e) { + Debug::log(ERR, "Keyboard had no name???"); // logic error + } PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&keyboard->keyboard->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard"); PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&keyboard->keyboard->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard"); @@ -378,17 +379,23 @@ void CInputManager::setKeyboardLayout() { } void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { + const auto HASCONFIG = g_pConfigManager->deviceConfigExists(pKeyboard->name); ASSERT(pKeyboard); - const auto RULES = g_pConfigManager->getString("input:kb_rules"); - const auto MODEL = g_pConfigManager->getString("input:kb_model"); - const auto LAYOUT = g_pConfigManager->getString("input:kb_layout"); - const auto VARIANT = g_pConfigManager->getString("input:kb_variant"); - const auto OPTIONS = g_pConfigManager->getString("input:kb_options"); + const auto REPEATRATE = HASCONFIG ? g_pConfigManager->getDeviceInt(pKeyboard->name, "repeat_rate") : g_pConfigManager->getInt("input:repeat_rate"); + const auto REPEATDELAY = HASCONFIG ? g_pConfigManager->getDeviceInt(pKeyboard->name, "repeat_delay") : g_pConfigManager->getInt("input:repeat_delay"); + + const auto NUMLOCKON = HASCONFIG ? g_pConfigManager->getDeviceInt(pKeyboard->name, "numlock_by_default") : g_pConfigManager->getInt("input:numlock_by_default"); + + const auto RULES = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_rules") : g_pConfigManager->getString("input:kb_rules"); + const auto MODEL = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_model") : g_pConfigManager->getString("input:kb_model"); + const auto LAYOUT = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_layout") : g_pConfigManager->getString("input:kb_layout"); + const auto VARIANT = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_variant") : g_pConfigManager->getString("input:kb_variant"); + const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_options") : g_pConfigManager->getString("input:kb_options"); try { - if (RULES != "" && RULES == std::string(pKeyboard->currentRules.rules) && MODEL == std::string(pKeyboard->currentRules.model) && LAYOUT == std::string(pKeyboard->currentRules.layout) && VARIANT == std::string(pKeyboard->currentRules.variant) && OPTIONS == std::string(pKeyboard->currentRules.options)) { + if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == std::string(pKeyboard->currentRules.rules) && MODEL == std::string(pKeyboard->currentRules.model) && LAYOUT == std::string(pKeyboard->currentRules.layout) && VARIANT == std::string(pKeyboard->currentRules.variant) && OPTIONS == std::string(pKeyboard->currentRules.options)) { Debug::log(LOG, "Not applying config to keyboard, it did not change."); return; } @@ -397,6 +404,12 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { // we can ignore those and just apply } + wlr_keyboard_set_repeat_info(pKeyboard->keyboard->keyboard, std::max(0, REPEATRATE), std::max(0, REPEATDELAY)); + + pKeyboard->repeatDelay = REPEATDELAY; + pKeyboard->repeatRate = REPEATRATE; + pKeyboard->numlockOn = NUMLOCKON; + xkb_rule_names rules = { .rules = RULES.c_str(), .model = MODEL.c_str(), @@ -430,7 +443,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { wlr_keyboard_modifiers wlrMods = {0}; - if (g_pConfigManager->getInt("input:numlock_by_default") == 1) { + if (NUMLOCKON == 1) { // lock numlock const auto IDX = xkb_map_mod_get_index(KEYMAP, XKB_MOD_NAME_NUM); @@ -453,37 +466,44 @@ void CInputManager::newMouse(wlr_input_device* mouse) { const auto PMOUSE = &m_lMice.back(); PMOUSE->mouse = mouse; + try { + PMOUSE->name = std::string(mouse->name); + } catch(std::exception& e) { + Debug::log(ERR, "Mouse had no name???"); // logic error + } + + const auto HASCONFIG = g_pConfigManager->deviceConfigExists(PMOUSE->name); if (wlr_input_device_is_libinput(mouse)) { const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(mouse); - if (g_pConfigManager->getInt("input:touchpad:clickfinger_behavior") == 0) // toggle software buttons or clickfinger + if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "clickfinger_behavior") : g_pConfigManager->getInt("input:touchpad:clickfinger_behavior")) == 0) // toggle software buttons or clickfinger libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); else libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); if (libinput_device_config_middle_emulation_is_available(LIBINPUTDEV)) { // middleclick on r+l mouse button pressed - if (g_pConfigManager->getInt("input:touchpad:middle_button_emulation") == 1) + if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "middle_button_emulation") : g_pConfigManager->getInt("input:touchpad:middle_button_emulation")) == 1) libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED); else libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED); } if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop) - if (g_pConfigManager->getInt("input:touchpad:tap-to-click") == 1) + if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "tap-to-click") : g_pConfigManager->getInt("input:touchpad:tap-to-click")) == 1) libinput_device_config_tap_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_ENABLED); if (libinput_device_config_scroll_has_natural_scroll(LIBINPUTDEV)) { double w = 0, h = 0; if (libinput_device_has_capability(LIBINPUTDEV, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(LIBINPUTDEV, &w, &h) == 0) // pointer with size is a touchpad - libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, g_pConfigManager->getInt("input:touchpad:natural_scroll")); + libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "natural_scroll") : g_pConfigManager->getInt("input:touchpad:natural_scroll"))); else - libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, g_pConfigManager->getInt("input:natural_scroll")); + libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "natural_scroll") : g_pConfigManager->getInt("input:natural_scroll"))); } if (libinput_device_config_dwt_is_available(LIBINPUTDEV)) { - const auto DWT = static_cast(g_pConfigManager->getInt("input:touchpad:disable_while_typing") != 0); + const auto DWT = static_cast((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "disable_while_typing") : g_pConfigManager->getInt("input:touchpad:disable_while_typing")) != 0); libinput_device_config_dwt_set_enabled(LIBINPUTDEV, DWT); } } diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp index 4285d06b..6a62e58e 100644 --- a/src/managers/input/Tablets.cpp +++ b/src/managers/input/Tablets.cpp @@ -4,6 +4,12 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { const auto PNEWTABLET = &m_lTablets.emplace_back(); + try { + PNEWTABLET->name = std::string(pDevice->name); + } catch (std::exception& e) { + Debug::log(ERR, "Tablet had no name???"); // logic error + } + PNEWTABLET->wlrTablet = pDevice->tablet; PNEWTABLET->wlrDevice = pDevice; PNEWTABLET->wlrTabletV2 = wlr_tablet_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice); @@ -151,6 +157,12 @@ STabletTool* CInputManager::ensureTabletToolPresent(wlr_tablet_tool* pTool) { void CInputManager::newTabletPad(wlr_input_device* pDevice) { const auto PNEWPAD = &m_lTabletPads.emplace_back(); + try { + PNEWPAD->name = std::string(pDevice->name); + } catch (std::exception& e) { + Debug::log(ERR, "Pad had no name???"); // logic error + } + PNEWPAD->wlrTabletPadV2 = wlr_tablet_pad_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice); PNEWPAD->hyprListener_Button.initCallback(&pDevice->tablet_pad->events.button, [](void* owner, void* data) { -- cgit v1.2.3 From 91d68513de5b182103393ee4abd3eb37db905bee Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 23:55:28 +0200 Subject: fix possible segfault by realloc --- src/managers/KeybindManager.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index e2a26781..f5554f57 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -894,10 +894,18 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) { } void CKeybindManager::forceRendererReload(std::string args) { + bool overAgain = false; + for (auto& m : g_pCompositor->m_vMonitors) { auto rule = g_pConfigManager->getMonitorRuleFor(m->szName); - g_pHyprRenderer->applyMonitorRule(m.get(), &rule, true); + if (!g_pHyprRenderer->applyMonitorRule(m.get(), &rule, true)) { + overAgain = true; + break; + } } + + if (overAgain) + forceRendererReload(args); } void CKeybindManager::resizeActive(std::string args) { -- cgit v1.2.3 From 6f2a36c12324b13ac3c05c364271810adc15f530 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 1 Jul 2022 10:37:17 +0200 Subject: limit events on socket2 to 1024 chars --- src/managers/EventManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/EventManager.cpp b/src/managers/EventManager.cpp index 5782718d..68bd94c5 100644 --- a/src/managers/EventManager.cpp +++ b/src/managers/EventManager.cpp @@ -89,7 +89,7 @@ void CEventManager::startThread() { for (auto& ev : m_dQueuedEvents) { std::string eventString = ev.event + ">>" + ev.data + "\n"; for (auto& fd : m_dAcceptedSocketFDs) { - write(fd, eventString.c_str(), eventString.length()); + write(fd, eventString.substr(0, 1023).c_str(), eventString.length()); } } -- cgit v1.2.3 From 1750a7cdbbccac32b7df2c9a672d5603740b4787 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 1 Jul 2022 11:54:52 +0200 Subject: oops --- src/managers/EventManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/managers') diff --git a/src/managers/EventManager.cpp b/src/managers/EventManager.cpp index 68bd94c5..22299a01 100644 --- a/src/managers/EventManager.cpp +++ b/src/managers/EventManager.cpp @@ -87,9 +87,9 @@ void CEventManager::startThread() { // write all queued events for (auto& ev : m_dQueuedEvents) { - std::string eventString = ev.event + ">>" + ev.data + "\n"; + std::string eventString = (ev.event + ">>" + ev.data).substr(0, 1022) + "\n"; for (auto& fd : m_dAcceptedSocketFDs) { - write(fd, eventString.substr(0, 1023).c_str(), eventString.length()); + write(fd, eventString.c_str(), eventString.length()); } } -- cgit v1.2.3 From 2225dca57665059102cd0225b8843a1d90a4f076 Mon Sep 17 00:00:00 2001 From: Dakes Date: Fri, 1 Jul 2022 16:24:37 +0200 Subject: Add focusWindow dispatcher. Takes titles & classes Removed focusWindowByClass function, replaced with focusWindow. Either takes a class matching regex, or a title matching one, beginning with "title:" Kept the focuswindowbyclass dispatcher identifier to stay backwards compatible with existing configs. --- src/managers/KeybindManager.cpp | 26 +++++++++++++++++++------- src/managers/KeybindManager.hpp | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index f5554f57..cb091c9f 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -30,7 +30,8 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["resizeactive"] = resizeActive; m_mDispatchers["moveactive"] = moveActive; m_mDispatchers["cyclenext"] = circleNext; - m_mDispatchers["focuswindowbyclass"] = focusWindowByClass; + m_mDispatchers["focuswindowbyclass"] = focusWindow; + m_mDispatchers["focuswindow"] = focusWindow; m_mDispatchers["submap"] = setSubmap; } @@ -1017,17 +1018,28 @@ void CKeybindManager::circleNext(std::string) { wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, MIDPOINT.x, MIDPOINT.y); } -void CKeybindManager::focusWindowByClass(std::string clazz) { - std::regex classCheck(clazz); +void CKeybindManager::focusWindow(std::string regexp) { + bool titleRegex = false; + std::regex regexCheck(regexp); + if (regexp.find("title:") == 0) { + titleRegex = true; + regexCheck = std::regex(regexp.substr(6)); + } for (auto& w : g_pCompositor->m_vWindows) { if (!w->m_bIsMapped || w->m_bHidden) continue; - const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get()); - - if (!std::regex_search(windowClass, classCheck)) - continue; + if (titleRegex) { + const auto windowTitle = g_pXWaylandManager->getTitle(w.get()); + if (!std::regex_search(windowTitle, regexCheck)) + continue; + } + else { + const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get()); + if (!std::regex_search(windowClass, regexCheck)) + continue; + } Debug::log(LOG, "Focusing to window name: %s", w->m_szTitle.c_str()); diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 117a5ec4..31498677 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -61,7 +61,7 @@ private: static void resizeActive(std::string); static void moveActive(std::string); static void circleNext(std::string); - static void focusWindowByClass(std::string); + static void focusWindow(std::string); static void setSubmap(std::string); friend class CCompositor; -- cgit v1.2.3 From 7d7e82d446f097692e24220614951da435dcca2b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 1 Jul 2022 17:59:11 +0200 Subject: only do mouseMoveUnified on pix change --- src/managers/input/InputManager.cpp | 7 +++++++ src/managers/input/InputManager.hpp | 1 + 2 files changed, 8 insertions(+) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 548af552..24143833 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -37,6 +37,13 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { } Vector2D mouseCoords = getMouseCoordsInternal(); + const auto MOUSECOORDSFLOORED = mouseCoords.floor(); + + if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored) + return; + + m_vLastCursorPosFloored = MOUSECOORDSFLOORED; + const auto PMONITOR = g_pCompositor->getMonitorFromCursor(); bool didConstraintOnCursor = false; diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 5089e5e1..e28e084b 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -68,6 +68,7 @@ private: // for click behavior override eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT; + Vector2D m_vLastCursorPosFloored = Vector2D(); void processMouseDownNormal(wlr_pointer_button_event* e); void processMouseDownKill(wlr_pointer_button_event* e); -- cgit v1.2.3 From 6f4f164071dec3119e2eb7337987c55f517a6bbd Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 1 Jul 2022 20:14:33 +0200 Subject: don't focus layers without keyboard_interactive --- src/managers/input/InputManager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 24143833..9d175fe9 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -117,10 +117,11 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { Vector2D surfaceCoords; Vector2D surfacePos = Vector2D(-1337, -1337); CWindow* pFoundWindow = nullptr; + SLayerSurface* pFoundLayerSurface = nullptr; // overlay is above fullscreen if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords); + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords, &pFoundLayerSurface); // then, we check if the workspace doesnt have a fullscreen window const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); @@ -148,7 +149,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { } if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords); + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords, &pFoundLayerSurface); // then windows if (!foundSurface) { @@ -169,10 +170,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { // then surfaces below if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], &surfaceCoords); + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], &surfaceCoords, &pFoundLayerSurface); if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords); + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords, &pFoundLayerSurface); if (!foundSurface) { if (m_ecbClickBehavior == CLICKMODE_KILL) @@ -213,7 +214,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { } else { g_pCompositor->focusWindow(pFoundWindow, foundSurface); } - } else + } else if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive) g_pCompositor->focusSurface(foundSurface); wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); -- cgit v1.2.3