mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 15:05:58 +01:00
added follow_mouse
This commit is contained in:
parent
402c11d341
commit
a558bcdfbf
5 changed files with 24 additions and 7 deletions
|
@ -12,6 +12,8 @@ input {
|
||||||
kb_model=
|
kb_model=
|
||||||
kb_options=
|
kb_options=
|
||||||
kb_rules=
|
kb_rules=
|
||||||
|
|
||||||
|
follow_mouse=1
|
||||||
}
|
}
|
||||||
|
|
||||||
general {
|
general {
|
||||||
|
|
|
@ -380,6 +380,9 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
|
||||||
|
|
||||||
g_pXWaylandManager->activateWindow(pWindow, true);
|
g_pXWaylandManager->activateWindow(pWindow, true);
|
||||||
|
|
||||||
|
// do pointer focus too
|
||||||
|
wlr_seat_pointer_notify_enter(m_sSeat.seat, PWINDOWSURFACE, 0, 0);
|
||||||
|
|
||||||
m_pLastWindow = pWindow;
|
m_pLastWindow = pWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,8 @@ CConfigManager::CConfigManager() {
|
||||||
configValues["input:kb_rules"].strValue = "";
|
configValues["input:kb_rules"].strValue = "";
|
||||||
configValues["input:kb_model"].strValue = "";
|
configValues["input:kb_model"].strValue = "";
|
||||||
|
|
||||||
|
configValues["input:follow_mouse"].intValue = 1;
|
||||||
|
|
||||||
configValues["autogenerated"].intValue = 0;
|
configValues["autogenerated"].intValue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,12 @@ void CInputManager::onMouseWarp(wlr_pointer_motion_absolute_event* e) {
|
||||||
mouseMoveUnified(e->time_msec);
|
mouseMoveUnified(e->time_msec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::mouseMoveUnified(uint32_t time) {
|
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
|
|
||||||
// update stuff
|
// update stuff
|
||||||
updateDragIcon();
|
updateDragIcon();
|
||||||
|
|
||||||
|
g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal());
|
||||||
|
|
||||||
// focus
|
// focus
|
||||||
wlr_surface* foundSurface = nullptr;
|
wlr_surface* foundSurface = nullptr;
|
||||||
|
@ -110,15 +111,24 @@ void CInputManager::mouseMoveUnified(uint32_t time) {
|
||||||
|
|
||||||
Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : Vector2D(g_pCompositor->m_sWLRCursor->x, g_pCompositor->m_sWLRCursor->y) - surfacePos;
|
Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : Vector2D(g_pCompositor->m_sWLRCursor->x, g_pCompositor->m_sWLRCursor->y) - surfacePos;
|
||||||
|
|
||||||
if (pFoundWindow)
|
if (pFoundWindow) {
|
||||||
|
if (g_pConfigManager->getInt("input:follow_mouse") == 0 && !refocus) {
|
||||||
|
if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating)) {
|
||||||
|
// enter if change floating style
|
||||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||||
|
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
|
||||||
|
}
|
||||||
|
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y);
|
||||||
|
return; // don't enter any new surfaces
|
||||||
|
} else {
|
||||||
|
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
g_pCompositor->focusSurface(foundSurface);
|
g_pCompositor->focusSurface(foundSurface);
|
||||||
|
|
||||||
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
|
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
|
||||||
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y);
|
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y);
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
|
void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
|
||||||
|
@ -288,7 +298,7 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::refocus() {
|
void CInputManager::refocus() {
|
||||||
mouseMoveUnified(0);
|
mouseMoveUnified(0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::updateDragIcon() {
|
void CInputManager::updateDragIcon() {
|
||||||
|
|
|
@ -37,7 +37,7 @@ private:
|
||||||
|
|
||||||
std::list<SKeyboard> m_lKeyboards;
|
std::list<SKeyboard> m_lKeyboards;
|
||||||
|
|
||||||
void mouseMoveUnified(uint32_t);
|
void mouseMoveUnified(uint32_t, bool refocus = false);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue