aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-01-11 18:38:54 +0100
committervaxerski <[email protected]>2023-01-11 19:15:18 +0100
commit11afb660102198abb1e74fffdffd00f8c1a11cd9 (patch)
tree9c78b0694e1b32537c0da802d31907c60079bf79
parentc4e422644b82e04f5664661bd1b133476410a449 (diff)
downloadHyprland-11afb660102198abb1e74fffdffd00f8c1a11cd9.tar.gz
Hyprland-11afb660102198abb1e74fffdffd00f8c1a11cd9.zip
release mouse buttons on map from LS
-rw-r--r--src/events/Windows.cpp3
-rw-r--r--src/managers/input/InputManager.cpp21
-rw-r--r--src/managers/input/InputManager.hpp31
3 files changed, 41 insertions, 14 deletions
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp
index aa0612fc..134d822c 100644
--- a/src/events/Windows.cpp
+++ b/src/events/Windows.cpp
@@ -57,6 +57,9 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_bFadingOut = false;
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
+ if (g_pInputManager->m_bLastFocusOnLS) // waybar fix
+ g_pInputManager->releaseAllMouseButtons();
+
if (PWINDOW->m_iX11Type == 2)
g_pCompositor->moveUnmanagedX11ToWindows(PWINDOW);
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index a5ff20f7..be148e89 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -322,6 +322,14 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
m_tmrLastCursorMovement.reset();
+ if (e->state == WLR_BUTTON_PRESSED) {
+ m_lCurrentlyHeldButtons.push_back(e->button);
+ } else {
+ if (std::find_if(m_lCurrentlyHeldButtons.begin(), m_lCurrentlyHeldButtons.end(), [&](const auto& other) { return other == e->button; }) == m_lCurrentlyHeldButtons.end())
+ return;
+ std::erase_if(m_lCurrentlyHeldButtons, [&](const auto& other) { return other == e->button; });
+ }
+
switch (m_ecbClickBehavior) {
case CLICKMODE_DEFAULT: processMouseDownNormal(e); break;
case CLICKMODE_KILL: processMouseDownKill(e); break;
@@ -1296,3 +1304,16 @@ SConstraint* CInputManager::constraintFromWlr(wlr_pointer_constraint_v1* constra
return nullptr;
}
+
+void CInputManager::releaseAllMouseButtons() {
+ const auto buttonsCopy = m_lCurrentlyHeldButtons;
+
+ if (g_pInputManager->m_sDrag.drag)
+ return;
+
+ for (auto& mb : buttonsCopy) {
+ wlr_seat_pointer_notify_button(g_pCompositor->m_sSeat.seat, 0, mb, WLR_BUTTON_RELEASED);
+ }
+
+ m_lCurrentlyHeldButtons.clear();
+}
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index 91783f38..a520ce1c 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -7,14 +7,12 @@
#include "../../helpers/Timer.hpp"
#include "InputMethodRelay.hpp"
-enum eClickBehaviorMode
-{
+enum eClickBehaviorMode {
CLICKMODE_DEFAULT = 0,
CLICKMODE_KILL
};
-enum eMouseBindMode
-{
+enum eMouseBindMode {
MBIND_INVALID = -1,
MBIND_MOVE = 0,
MBIND_RESIZE
@@ -137,6 +135,11 @@ class CInputManager {
std::string deviceNameToInternalString(std::string);
std::string getNameForNewDevice(std::string);
+ void releaseAllMouseButtons();
+
+ // for some bugs in follow mouse 0
+ bool m_bLastFocusOnLS = false;
+
private:
bool m_bCursorImageOverriden = false;
@@ -145,27 +148,27 @@ class CInputManager {
bool m_bEmptyFocusCursorSet = false;
Vector2D m_vLastCursorPosFloored = Vector2D();
- // for some bugs in follow mouse 0
- bool m_bLastFocusOnLS = false;
-
- void processMouseDownNormal(wlr_pointer_button_event* e);
- void processMouseDownKill(wlr_pointer_button_event* e);
+ void processMouseDownNormal(wlr_pointer_button_event* e);
+ void processMouseDownKill(wlr_pointer_button_event* e);
- void disableAllKeyboards(bool virt = false);
+ void disableAllKeyboards(bool virt = false);
- uint32_t m_uiCapabilities = 0;
+ uint32_t m_uiCapabilities = 0;
- void mouseMoveUnified(uint32_t, bool refocus = false);
+ void mouseMoveUnified(uint32_t, bool refocus = false);
- STabletTool* ensureTabletToolPresent(wlr_tablet_tool*);
+ STabletTool* ensureTabletToolPresent(wlr_tablet_tool*);
- void applyConfigToKeyboard(SKeyboard*);
+ void applyConfigToKeyboard(SKeyboard*);
// this will be set after a refocus()
wlr_surface* m_pFoundSurfaceToFocus = nullptr;
SLayerSurface* m_pFoundLSToFocus = nullptr;
CWindow* m_pFoundWindowToFocus = nullptr;
+ // for releasing mouse buttons
+ std::list<uint32_t> m_lCurrentlyHeldButtons;
+
// swipe
void beginWorkspaceSwipe();