mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-02 00:25:58 +01:00
fix: change cursor for all non-fullscreen windows
This commit is contained in:
parent
26dfc244f8
commit
8a6e7009c8
2 changed files with 56 additions and 53 deletions
|
@ -37,7 +37,6 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
static auto* const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
|
static auto* const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
|
||||||
static auto* const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue;
|
static auto* const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue;
|
||||||
static auto* const PFLOATBEHAVIOR = &g_pConfigManager->getConfigValuePtr("input:float_switch_override_focus")->intValue;
|
static auto* const PFLOATBEHAVIOR = &g_pConfigManager->getConfigValuePtr("input:float_switch_override_focus")->intValue;
|
||||||
static auto* const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
|
||||||
static auto* const PRESIZEONBORDER = &g_pConfigManager->getConfigValuePtr("general:resize_on_borders")->intValue;
|
static auto* const PRESIZEONBORDER = &g_pConfigManager->getConfigValuePtr("general:resize_on_borders")->intValue;
|
||||||
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
static auto* const PBORDERGRABEXTEND = &g_pConfigManager->getConfigValuePtr("general:extend_border_grab_area")->intValue;
|
static auto* const PBORDERGRABEXTEND = &g_pConfigManager->getConfigValuePtr("general:extend_border_grab_area")->intValue;
|
||||||
|
@ -199,54 +198,6 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
} else {
|
} else {
|
||||||
pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
|
pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
|
||||||
|
|
||||||
// TODO check if is being dragged, skip setting cursor icon if so
|
|
||||||
if (*PRESIZEONBORDER) {
|
|
||||||
const auto CORNER = *PROUNDING + *PBORDERSIZE + 10;
|
|
||||||
wlr_box box = {pFoundWindow->m_vRealPosition.vec().x, pFoundWindow->m_vRealPosition.vec().y, pFoundWindow->m_vRealSize.vec().x, pFoundWindow->m_vRealSize.vec().y};
|
|
||||||
if (wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y)) {
|
|
||||||
if (pFoundWindow->isInCurvedCorner(mouseCoords.x, mouseCoords.y)) {
|
|
||||||
if (mouseCoords.y < box.y + CORNER) {
|
|
||||||
if (mouseCoords.x < box.x + CORNER)
|
|
||||||
setCursorImageUntilUnset("top_left_corner");
|
|
||||||
else
|
|
||||||
setCursorImageUntilUnset("top_right_corner");
|
|
||||||
} else {
|
|
||||||
if (mouseCoords.x < box.x + CORNER)
|
|
||||||
setCursorImageUntilUnset("bottom_left_corner");
|
|
||||||
else
|
|
||||||
setCursorImageUntilUnset("bottom_right_corner");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
unsetCursorImage();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// give a small leeway (10 px) for corner icon
|
|
||||||
if (mouseCoords.y < box.y + CORNER) {
|
|
||||||
if (mouseCoords.x < box.x + CORNER)
|
|
||||||
setCursorImageUntilUnset("top_left_corner");
|
|
||||||
else if (mouseCoords.x > box.x + box.width - CORNER)
|
|
||||||
setCursorImageUntilUnset("top_right_corner");
|
|
||||||
else
|
|
||||||
setCursorImageUntilUnset("top_side");
|
|
||||||
} else if (mouseCoords.y > box.y + box.height - CORNER) {
|
|
||||||
if (mouseCoords.x < box.x)
|
|
||||||
setCursorImageUntilUnset("bottom_left_corner");
|
|
||||||
else if (mouseCoords.x > box.x + box.width - CORNER)
|
|
||||||
setCursorImageUntilUnset("bottom_right_corner");
|
|
||||||
else
|
|
||||||
setCursorImageUntilUnset("bottom_side");
|
|
||||||
} else {
|
|
||||||
if (mouseCoords.x < box.x + CORNER)
|
|
||||||
setCursorImageUntilUnset("left_side");
|
|
||||||
else if (mouseCoords.x > box.x + box.width - CORNER)
|
|
||||||
setCursorImageUntilUnset("right_side");
|
|
||||||
else {
|
|
||||||
// unreachable
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: this causes crashes, sometimes. ???
|
// TODO: this causes crashes, sometimes. ???
|
||||||
// if (refocus && !pFoundWindow) {
|
// if (refocus && !pFoundWindow) {
|
||||||
// pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace);
|
// pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace);
|
||||||
|
@ -357,6 +308,11 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// change cursor icon if hovering over border
|
||||||
|
if (*PRESIZEONBORDER && !pFoundWindow->m_bIsFullscreen && !g_pKeybindManager->m_bIsMouseBindActive) {
|
||||||
|
setCursorIconOnBorder(pFoundWindow);
|
||||||
|
}
|
||||||
|
|
||||||
m_bLastFocusOnLS = false;
|
m_bLastFocusOnLS = false;
|
||||||
} else {
|
} else {
|
||||||
if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive && *PFOLLOWMOUSE != 3 && allowKeyboardRefocus) {
|
if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive && *PFOLLOWMOUSE != 3 && allowKeyboardRefocus) {
|
||||||
|
@ -1362,3 +1318,50 @@ SConstraint* CInputManager::constraintFromWlr(wlr_pointer_constraint_v1* constra
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInputManager::setCursorIconOnBorder(CWindow* w) {
|
||||||
|
static auto* const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
||||||
|
static const auto* PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
|
// give a small leeway (10 px) for corner icon
|
||||||
|
const auto CORNER = *PROUNDING + *PBORDERSIZE + 10;
|
||||||
|
const auto mouseCoords = getMouseCoordsInternal();
|
||||||
|
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
|
||||||
|
if (wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y)) {
|
||||||
|
if (w->isInCurvedCorner(mouseCoords.x, mouseCoords.y)) {
|
||||||
|
if (mouseCoords.y < box.y + CORNER) {
|
||||||
|
if (mouseCoords.x < box.x + CORNER)
|
||||||
|
setCursorImageUntilUnset("top_left_corner");
|
||||||
|
else
|
||||||
|
setCursorImageUntilUnset("top_right_corner");
|
||||||
|
} else {
|
||||||
|
if (mouseCoords.x < box.x + CORNER)
|
||||||
|
setCursorImageUntilUnset("bottom_left_corner");
|
||||||
|
else
|
||||||
|
setCursorImageUntilUnset("bottom_right_corner");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unsetCursorImage();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mouseCoords.y < box.y + CORNER) {
|
||||||
|
if (mouseCoords.x < box.x + CORNER)
|
||||||
|
setCursorImageUntilUnset("top_left_corner");
|
||||||
|
else if (mouseCoords.x > box.x + box.width - CORNER)
|
||||||
|
setCursorImageUntilUnset("top_right_corner");
|
||||||
|
else
|
||||||
|
setCursorImageUntilUnset("top_side");
|
||||||
|
} else if (mouseCoords.y > box.y + box.height - CORNER) {
|
||||||
|
if (mouseCoords.x < box.x)
|
||||||
|
setCursorImageUntilUnset("bottom_left_corner");
|
||||||
|
else if (mouseCoords.x > box.x + box.width - CORNER)
|
||||||
|
setCursorImageUntilUnset("bottom_right_corner");
|
||||||
|
else
|
||||||
|
setCursorImageUntilUnset("bottom_side");
|
||||||
|
} else {
|
||||||
|
if (mouseCoords.x < box.x + CORNER)
|
||||||
|
setCursorImageUntilUnset("left_side");
|
||||||
|
else if (mouseCoords.x > box.x + box.width - CORNER)
|
||||||
|
setCursorImageUntilUnset("right_side");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
@ -169,6 +167,8 @@ class CInputManager {
|
||||||
// swipe
|
// swipe
|
||||||
void beginWorkspaceSwipe();
|
void beginWorkspaceSwipe();
|
||||||
|
|
||||||
|
void setCursorIconOnBorder(CWindow* w);
|
||||||
|
|
||||||
friend class CKeybindManager;
|
friend class CKeybindManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue