mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 04:09:49 +01:00
cleaner code
This commit is contained in:
parent
20ad9d3e7d
commit
1810725a0c
1 changed files with 87 additions and 89 deletions
|
@ -88,112 +88,110 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
// focus
|
// focus
|
||||||
wlr_surface* foundSurface = nullptr;
|
wlr_surface* foundSurface = nullptr;
|
||||||
|
|
||||||
if (!didConstraintOnCursor) {
|
if (didConstraintOnCursor)
|
||||||
if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor) {
|
return; // don't process when cursor constrained
|
||||||
g_pCompositor->m_pLastMonitor = PMONITOR;
|
|
||||||
|
|
||||||
// set active workspace and deactivate all other in wlr
|
if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor) {
|
||||||
const auto ACTIVEWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
g_pCompositor->m_pLastMonitor = PMONITOR;
|
||||||
g_pCompositor->deactivateAllWLRWorkspaces(ACTIVEWORKSPACE->m_pWlrHandle);
|
|
||||||
ACTIVEWORKSPACE->setActive(true);
|
|
||||||
|
|
||||||
// event
|
// set active workspace and deactivate all other in wlr
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent("activemon", PMONITOR->szName + "," + ACTIVEWORKSPACE->m_szName));
|
const auto ACTIVEWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
||||||
}
|
g_pCompositor->deactivateAllWLRWorkspaces(ACTIVEWORKSPACE->m_pWlrHandle);
|
||||||
|
ACTIVEWORKSPACE->setActive(true);
|
||||||
|
|
||||||
Vector2D surfaceCoords;
|
// event
|
||||||
Vector2D surfacePos = Vector2D(-1337, -1337);
|
g_pEventManager->postEvent(SHyprIPCEvent("activemon", PMONITOR->szName + "," + ACTIVEWORKSPACE->m_szName));
|
||||||
CWindow* pFoundWindow = nullptr;
|
}
|
||||||
|
|
||||||
// overlay is above fullscreen
|
Vector2D surfaceCoords;
|
||||||
if (!foundSurface)
|
Vector2D surfacePos = Vector2D(-1337, -1337);
|
||||||
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords);
|
CWindow* pFoundWindow = nullptr;
|
||||||
|
|
||||||
// then, we check if the workspace doesnt have a fullscreen window
|
// overlay is above fullscreen
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
if (!foundSurface)
|
||||||
if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) {
|
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords);
|
||||||
pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
|
|
||||||
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
|
|
||||||
surfacePos = pFoundWindow->m_vRealPosition.vec();
|
|
||||||
|
|
||||||
// only check floating because tiled cant be over fullscreen
|
// then, we check if the workspace doesnt have a fullscreen window
|
||||||
for (auto w = g_pCompositor->m_lWindows.rbegin(); w != g_pCompositor->m_lWindows.rend(); w++) {
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
||||||
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
|
if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) {
|
||||||
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 = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
|
||||||
pFoundWindow = &(*w);
|
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
|
||||||
|
surfacePos = pFoundWindow->m_vRealPosition.vec();
|
||||||
|
|
||||||
if (!pFoundWindow->m_bIsX11) {
|
// only check floating because tiled cant be over fullscreen
|
||||||
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
|
for (auto w = g_pCompositor->m_lWindows.rbegin(); w != g_pCompositor->m_lWindows.rend(); w++) {
|
||||||
} else {
|
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
|
||||||
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
|
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) {
|
||||||
surfacePos = pFoundWindow->m_vRealPosition.vec();
|
pFoundWindow = &(*w);
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!foundSurface)
|
|
||||||
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords);
|
|
||||||
|
|
||||||
// then windows
|
|
||||||
if (!foundSurface) {
|
|
||||||
pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
|
|
||||||
if (pFoundWindow) {
|
|
||||||
if (!pFoundWindow->m_bIsX11) {
|
if (!pFoundWindow->m_bIsX11) {
|
||||||
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
|
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
|
||||||
} else {
|
} else {
|
||||||
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
|
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
|
||||||
surfacePos = pFoundWindow->m_vRealPosition.vec();
|
surfacePos = pFoundWindow->m_vRealPosition.vec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// then surfaces below
|
|
||||||
if (!foundSurface)
|
|
||||||
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], &surfaceCoords);
|
|
||||||
|
|
||||||
if (!foundSurface)
|
|
||||||
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);
|
|
||||||
|
|
||||||
wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (time)
|
|
||||||
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
|
|
||||||
|
|
||||||
Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : mouseCoords - surfacePos;
|
|
||||||
|
|
||||||
if (pFoundWindow) {
|
|
||||||
static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
|
||||||
if (*PFOLLOWMOUSE != 1 && !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);
|
|
||||||
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
|
|
||||||
}
|
|
||||||
else if (*PFOLLOWMOUSE == 2) {
|
|
||||||
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
|
|
||||||
g_pCompositor->focusSurface(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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!foundSurface)
|
||||||
|
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords);
|
||||||
|
|
||||||
|
// then windows
|
||||||
|
if (!foundSurface) {
|
||||||
|
pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
|
||||||
|
if (pFoundWindow) {
|
||||||
|
if (!pFoundWindow->m_bIsX11) {
|
||||||
|
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
|
||||||
|
} else {
|
||||||
|
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
|
||||||
|
surfacePos = pFoundWindow->m_vRealPosition.vec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// then surfaces below
|
||||||
|
if (!foundSurface)
|
||||||
|
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], &surfaceCoords);
|
||||||
|
|
||||||
|
if (!foundSurface)
|
||||||
|
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);
|
||||||
|
|
||||||
|
wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time)
|
||||||
|
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
|
||||||
|
|
||||||
|
Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : mouseCoords - surfacePos;
|
||||||
|
|
||||||
|
if (pFoundWindow) {
|
||||||
|
static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
||||||
|
if (*PFOLLOWMOUSE != 1 && !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);
|
||||||
|
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
|
||||||
|
} else if (*PFOLLOWMOUSE == 2) {
|
||||||
|
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
|
||||||
|
g_pCompositor->focusSurface(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
|
void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
|
||||||
|
|
Loading…
Reference in a new issue