release mouse buttons on map from LS

This commit is contained in:
Vaxry 2023-01-11 18:38:54 +01:00
parent c4e422644b
commit 11afb66010
3 changed files with 41 additions and 14 deletions

View file

@ -57,6 +57,9 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_bFadingOut = false; PWINDOW->m_bFadingOut = false;
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW); PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
if (g_pInputManager->m_bLastFocusOnLS) // waybar fix
g_pInputManager->releaseAllMouseButtons();
if (PWINDOW->m_iX11Type == 2) if (PWINDOW->m_iX11Type == 2)
g_pCompositor->moveUnmanagedX11ToWindows(PWINDOW); g_pCompositor->moveUnmanagedX11ToWindows(PWINDOW);

View file

@ -322,6 +322,14 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
m_tmrLastCursorMovement.reset(); 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) { switch (m_ecbClickBehavior) {
case CLICKMODE_DEFAULT: processMouseDownNormal(e); break; case CLICKMODE_DEFAULT: processMouseDownNormal(e); break;
case CLICKMODE_KILL: processMouseDownKill(e); break; case CLICKMODE_KILL: processMouseDownKill(e); break;
@ -1296,3 +1304,16 @@ SConstraint* CInputManager::constraintFromWlr(wlr_pointer_constraint_v1* constra
return nullptr; 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();
}

View file

@ -7,14 +7,12 @@
#include "../../helpers/Timer.hpp" #include "../../helpers/Timer.hpp"
#include "InputMethodRelay.hpp" #include "InputMethodRelay.hpp"
enum eClickBehaviorMode enum eClickBehaviorMode {
{
CLICKMODE_DEFAULT = 0, CLICKMODE_DEFAULT = 0,
CLICKMODE_KILL CLICKMODE_KILL
}; };
enum eMouseBindMode enum eMouseBindMode {
{
MBIND_INVALID = -1, MBIND_INVALID = -1,
MBIND_MOVE = 0, MBIND_MOVE = 0,
MBIND_RESIZE MBIND_RESIZE
@ -137,6 +135,11 @@ class CInputManager {
std::string deviceNameToInternalString(std::string); std::string deviceNameToInternalString(std::string);
std::string getNameForNewDevice(std::string); std::string getNameForNewDevice(std::string);
void releaseAllMouseButtons();
// for some bugs in follow mouse 0
bool m_bLastFocusOnLS = false;
private: private:
bool m_bCursorImageOverriden = false; bool m_bCursorImageOverriden = false;
@ -145,9 +148,6 @@ class CInputManager {
bool m_bEmptyFocusCursorSet = false; bool m_bEmptyFocusCursorSet = false;
Vector2D m_vLastCursorPosFloored = Vector2D(); Vector2D m_vLastCursorPosFloored = Vector2D();
// for some bugs in follow mouse 0
bool m_bLastFocusOnLS = false;
void processMouseDownNormal(wlr_pointer_button_event* e); void processMouseDownNormal(wlr_pointer_button_event* e);
void processMouseDownKill(wlr_pointer_button_event* e); void processMouseDownKill(wlr_pointer_button_event* e);
@ -166,6 +166,9 @@ class CInputManager {
SLayerSurface* m_pFoundLSToFocus = nullptr; SLayerSurface* m_pFoundLSToFocus = nullptr;
CWindow* m_pFoundWindowToFocus = nullptr; CWindow* m_pFoundWindowToFocus = nullptr;
// for releasing mouse buttons
std::list<uint32_t> m_lCurrentlyHeldButtons;
// swipe // swipe
void beginWorkspaceSwipe(); void beginWorkspaceSwipe();