mirror of https://github.com/hyprwm/Hyprland
Compare commits
5 Commits
2803d12c38
...
760576a8ee
Author | SHA1 | Date |
---|---|---|
|
760576a8ee | |
|
9c5dd59d4b | |
|
d16c6aa1db | |
|
4387c2ebf0 | |
|
b7f42a1e88 |
|
@ -1,4 +1,5 @@
|
|||
#include "Compositor.hpp"
|
||||
#include "desktop/DesktopTypes.hpp"
|
||||
#include "helpers/Splashes.hpp"
|
||||
#include "config/ConfigValue.hpp"
|
||||
#include "managers/CursorManager.hpp"
|
||||
|
@ -6,6 +7,7 @@
|
|||
#include "managers/PointerManager.hpp"
|
||||
#include "managers/SeatManager.hpp"
|
||||
#include "managers/eventLoop/EventLoopManager.hpp"
|
||||
#include <cstdint>
|
||||
#include <random>
|
||||
#include <unordered_set>
|
||||
#include "debug/HyprCtl.hpp"
|
||||
|
@ -671,6 +673,30 @@ CMonitor* CCompositor::getMonitorFromVector(const Vector2D& point) {
|
|||
return mon.get();
|
||||
}
|
||||
|
||||
SP<CMonitor> CCompositor::getNextMonitor(uint64_t curID, bool reverse) {
|
||||
const auto LN = m_vMonitors.size();
|
||||
if (LN == 1) {
|
||||
return m_vMonitors[0];
|
||||
}
|
||||
|
||||
size_t curPos = LN + 1;
|
||||
for (size_t i = 0; i < LN; i++) {
|
||||
if (m_vMonitors[i]->ID == curID) {
|
||||
curPos = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (curPos == LN && !reverse) {
|
||||
return m_vMonitors[0];
|
||||
}
|
||||
|
||||
if (curPos == 0 && reverse) {
|
||||
return m_vMonitors[LN - 1];
|
||||
}
|
||||
|
||||
return reverse ? m_vMonitors[curPos - 1] : m_vMonitors[curPos + 1];
|
||||
}
|
||||
|
||||
void CCompositor::removeWindowFromVectorSafe(PHLWINDOW pWindow) {
|
||||
if (!pWindow->m_bFadingOut) {
|
||||
EMIT_HOOK_EVENT("destroyWindow", pWindow);
|
||||
|
@ -1565,29 +1591,14 @@ PHLWINDOW CCompositor::getWindowInDirection(PHLWINDOW pWindow, char dir) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool isWindowMatch(PHLWINDOW pWindow, bool focusableOnly, std::optional<bool> floating, const PHLWINDOW& w) {
|
||||
return (!floating.has_value() || w->m_bIsFloating == floating.value()) && w != pWindow && w->m_pWorkspace == pWindow->m_pWorkspace && w->m_bIsMapped && !w->isHidden() &&
|
||||
(!focusableOnly || !w->m_sAdditionalConfigData.noFocus);
|
||||
}
|
||||
|
||||
PHLWINDOW CCompositor::getNextWindowOnWorkspace(PHLWINDOW pWindow, bool focusableOnly, std::optional<bool> floating) {
|
||||
bool gotToWindow = false;
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w != pWindow && !gotToWindow)
|
||||
continue;
|
||||
|
||||
if (w == pWindow) {
|
||||
gotToWindow = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
||||
continue;
|
||||
|
||||
if (w->m_pWorkspace == pWindow->m_pWorkspace && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sAdditionalConfigData.noFocus))
|
||||
return w;
|
||||
}
|
||||
|
||||
for (auto& w : m_vWindows) {
|
||||
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
||||
continue;
|
||||
|
||||
if (w != pWindow && w->m_pWorkspace == pWindow->m_pWorkspace && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sAdditionalConfigData.noFocus))
|
||||
for (const auto& w : m_vWindows) {
|
||||
if (isWindowMatch(pWindow, focusableOnly, floating, w))
|
||||
return w;
|
||||
}
|
||||
|
||||
|
@ -1595,29 +1606,50 @@ PHLWINDOW CCompositor::getNextWindowOnWorkspace(PHLWINDOW pWindow, bool focusabl
|
|||
}
|
||||
|
||||
PHLWINDOW CCompositor::getPrevWindowOnWorkspace(PHLWINDOW pWindow, bool focusableOnly, std::optional<bool> floating) {
|
||||
bool gotToWindow = false;
|
||||
for (auto& w : m_vWindows | std::views::reverse) {
|
||||
if (w != pWindow && !gotToWindow)
|
||||
continue;
|
||||
|
||||
if (w == pWindow) {
|
||||
gotToWindow = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
||||
continue;
|
||||
|
||||
if (w->m_pWorkspace == pWindow->m_pWorkspace && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sAdditionalConfigData.noFocus))
|
||||
for (const auto& w : m_vWindows | std::views::reverse) {
|
||||
if (isWindowMatch(pWindow, focusableOnly, floating, w))
|
||||
return w;
|
||||
}
|
||||
|
||||
for (auto& w : m_vWindows | std::views::reverse) {
|
||||
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
||||
continue;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (w != pWindow && w->m_pWorkspace == pWindow->m_pWorkspace && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sAdditionalConfigData.noFocus))
|
||||
PHLWINDOW CCompositor::getNextVisibleWindow(PHLWINDOW pWindow, bool focusableOnly, std::optional<bool> floating) {
|
||||
if (pWindow == getTopLeftWindowOnWorkspace(pWindow->workspaceID()))
|
||||
if (const auto& w = getWindowOnAnotherMonitor(pWindow->m_iMonitorID, floating, true); w && m_pLastWindow->m_iMonitorID == w->m_iMonitorID)
|
||||
return w;
|
||||
|
||||
for (const auto& w : m_vWindows) {
|
||||
if (isWindowMatch(pWindow, focusableOnly, floating, w))
|
||||
return w;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PHLWINDOW CCompositor::getPrevVisibleWindow(PHLWINDOW pWindow, bool focusableOnly, std::optional<bool> floating) {
|
||||
if (pWindow == getTopLeftWindowOnWorkspace(pWindow->workspaceID()))
|
||||
if (const auto& w = getWindowOnAnotherMonitor(pWindow->m_iMonitorID, floating, true); w && m_pLastWindow->m_iMonitorID == w->m_iMonitorID)
|
||||
return w;
|
||||
|
||||
for (const auto& w : m_vWindows | std::views::reverse) {
|
||||
if (isWindowMatch(pWindow, focusableOnly, floating, w))
|
||||
return w;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PHLWINDOW CCompositor::getWindowOnAnotherMonitor(uint64_t curMonID, std::optional<bool> floating, bool reverse) {
|
||||
for (auto mon = getNextMonitor(curMonID, reverse); mon->ID != curMonID; mon = getNextMonitor(curMonID, reverse)) {
|
||||
if (mon->activeWorkspace == nullptr) {
|
||||
curMonID = mon->ID;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (const auto w = mon->activeWorkspace->getLastFocusedWindow(); w && (!floating.has_value() || floating.value() == w->m_bIsFloating)) {
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
|
@ -107,6 +107,7 @@ class CCompositor {
|
|||
CMonitor* getMonitorFromDesc(const std::string&);
|
||||
CMonitor* getMonitorFromCursor();
|
||||
CMonitor* getMonitorFromVector(const Vector2D&);
|
||||
SP<CMonitor> getNextMonitor(uint64_t cur, bool reverse = false);
|
||||
void removeWindowFromVectorSafe(PHLWINDOW);
|
||||
void focusWindow(PHLWINDOW, SP<CWLSurfaceResource> pSurface = nullptr);
|
||||
void focusSurface(SP<CWLSurfaceResource>, PHLWINDOW pWindowOwner = nullptr);
|
||||
|
@ -139,8 +140,11 @@ class CCompositor {
|
|||
void changeWindowZOrder(PHLWINDOW, bool);
|
||||
void cleanupFadingOut(const int& monid);
|
||||
PHLWINDOW getWindowInDirection(PHLWINDOW, char);
|
||||
PHLWINDOW getNextVisibleWindow(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
|
||||
PHLWINDOW getPrevVisibleWindow(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
|
||||
PHLWINDOW getNextWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
|
||||
PHLWINDOW getPrevWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
|
||||
PHLWINDOW getWindowOnAnotherMonitor(uint64_t curMonID, std::optional<bool> floating = {}, bool reverse = false);
|
||||
int getNextAvailableNamedWorkspace();
|
||||
bool isPointOnAnyMonitor(const Vector2D&);
|
||||
bool isPointOnReservedArea(const Vector2D& point, const CMonitor* monitor = nullptr);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "debug/Log.hpp"
|
||||
#include "helpers/varlist/VarList.hpp"
|
||||
|
||||
#include <hyprutils/string/VarList.hpp>
|
||||
#include <optional>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
|
@ -91,6 +92,7 @@ CKeybindManager::CKeybindManager() {
|
|||
m_mDispatchers["resizeactive"] = resizeActive;
|
||||
m_mDispatchers["moveactive"] = moveActive;
|
||||
m_mDispatchers["cyclenext"] = circleNext;
|
||||
m_mDispatchers["cyclenextvisible"] = circleNextVisible;
|
||||
m_mDispatchers["focuswindowbyclass"] = focusWindow;
|
||||
m_mDispatchers["focuswindow"] = focusWindow;
|
||||
m_mDispatchers["tagwindow"] = tagWindow;
|
||||
|
@ -311,8 +313,10 @@ bool CKeybindManager::tryMoveFocusToMonitor(CMonitor* monitor) {
|
|||
}
|
||||
|
||||
void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO) {
|
||||
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow.lock();
|
||||
if (PWINDOWTOCHANGETO == nullptr)
|
||||
return;
|
||||
|
||||
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow.lock();
|
||||
if (PWINDOWTOCHANGETO == PLASTWINDOW || !PWINDOWTOCHANGETO)
|
||||
return;
|
||||
|
||||
|
@ -330,23 +334,23 @@ void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO) {
|
|||
|
||||
if (!PWINDOWTOCHANGETO->m_bPinned)
|
||||
g_pCompositor->setWindowFullscreen(PWINDOWTOCHANGETO, true, FSMODE);
|
||||
} else {
|
||||
updateRelativeCursorCoords();
|
||||
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
|
||||
PWINDOWTOCHANGETO->warpCursor();
|
||||
|
||||
g_pInputManager->m_pForcedFocus = PWINDOWTOCHANGETO;
|
||||
g_pInputManager->simulateMouseMovement();
|
||||
g_pInputManager->m_pForcedFocus.reset();
|
||||
|
||||
if (PLASTWINDOW && PLASTWINDOW->m_iMonitorID != PWINDOWTOCHANGETO->m_iMonitorID) {
|
||||
// event
|
||||
const auto PNEWMON = g_pCompositor->getMonitorFromID(PWINDOWTOCHANGETO->m_iMonitorID);
|
||||
|
||||
g_pCompositor->setActiveMonitor(PNEWMON);
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
updateRelativeCursorCoords();
|
||||
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
|
||||
PWINDOWTOCHANGETO->warpCursor();
|
||||
|
||||
g_pInputManager->m_pForcedFocus = PWINDOWTOCHANGETO;
|
||||
g_pInputManager->simulateMouseMovement();
|
||||
g_pInputManager->m_pForcedFocus.reset();
|
||||
|
||||
if (!PLASTWINDOW || PLASTWINDOW->m_iMonitorID == PWINDOWTOCHANGETO->m_iMonitorID)
|
||||
return;
|
||||
|
||||
// event
|
||||
const auto PNEWMON = g_pCompositor->getMonitorFromID(PWINDOWTOCHANGETO->m_iMonitorID);
|
||||
g_pCompositor->setActiveMonitor(PNEWMON);
|
||||
}
|
||||
|
||||
bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) {
|
||||
if (!g_pCompositor->m_bSessionActive || g_pCompositor->m_bUnsafeState) {
|
||||
|
@ -1048,14 +1052,20 @@ SWorkspaceIDName getWorkspaceToChangeFromArgs(std::string args, PHLWORKSPACE PCU
|
|||
return {WORKSPACE_NOT_CHANGED, ""};
|
||||
}
|
||||
|
||||
const auto ID = PCURRENTWORKSPACE->m_iID;
|
||||
if (const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(PPREVWS.id); PWORKSPACETOCHANGETO) {
|
||||
if (PER_MON && PCURRENTWORKSPACE->m_iMonitorID != PWORKSPACETOCHANGETO->m_iMonitorID)
|
||||
return {WORKSPACE_NOT_CHANGED, ""};
|
||||
return {ID, PWORKSPACETOCHANGETO->m_szName};
|
||||
}
|
||||
const auto ID = PCURRENTWORKSPACE->m_iID;
|
||||
const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(PPREVWS.id);
|
||||
if (!PWORKSPACETOCHANGETO)
|
||||
return {ID, PPREVWS.name.empty() ? std::to_string(PPREVWS.id) : PPREVWS.name};
|
||||
|
||||
return {ID, PPREVWS.name.empty() ? std::to_string(PPREVWS.id) : PPREVWS.name};
|
||||
if (!PER_MON || PCURRENTWORKSPACE->m_iMonitorID == PWORKSPACETOCHANGETO->m_iMonitorID)
|
||||
return {ID, PWORKSPACETOCHANGETO->m_szName};
|
||||
|
||||
// PER_MON and cur ws is not on same monitor with prev per monitor
|
||||
const auto POTHERWSTOCHANGETO = g_pCompositor->getWorkspaceByID(PCURRENTWORKSPACE->getPrevWorkspaceIDName(false).id);
|
||||
if (POTHERWSTOCHANGETO && POTHERWSTOCHANGETO->m_iMonitorID == PCURRENTWORKSPACE->m_iMonitorID)
|
||||
return {ID, POTHERWSTOCHANGETO->m_szName};
|
||||
|
||||
return {WORKSPACE_NOT_CHANGED, ""};
|
||||
}
|
||||
|
||||
void CKeybindManager::changeworkspace(std::string args) {
|
||||
|
@ -1898,31 +1908,48 @@ void CKeybindManager::resizeWindow(std::string args) {
|
|||
PWINDOW->setHidden(false);
|
||||
}
|
||||
|
||||
std::optional<bool> getFloatStatus(CVarList args) {
|
||||
if (args.contains("tile") || args.contains("tiled"))
|
||||
return false;
|
||||
if (args.contains("float") || args.contains("floating"))
|
||||
return true;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool argsIsPrevious(CVarList args) {
|
||||
return args.contains("prev") || args.contains("p") || args.contains("last") || args.contains("l");
|
||||
}
|
||||
|
||||
void CKeybindManager::circleNext(std::string arg) {
|
||||
|
||||
if (g_pCompositor->m_pLastWindow.expired()) {
|
||||
// if we have a clear focus, find the first window and get the next focusable.
|
||||
if (g_pCompositor->getWindowsOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspaceID()) > 0) {
|
||||
const auto PWINDOW = g_pCompositor->getFirstWindowOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspaceID());
|
||||
if (g_pCompositor->getWindowsOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspaceID()) <= 0)
|
||||
return; // if we have a clear focus, find the first window and get the next focusable.
|
||||
|
||||
switchToWindow(PWINDOW);
|
||||
}
|
||||
|
||||
return;
|
||||
const auto PWINDOW = g_pCompositor->getFirstWindowOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspaceID());
|
||||
switchToWindow(PWINDOW);
|
||||
}
|
||||
|
||||
CVarList args{arg, 0, 's', true};
|
||||
|
||||
std::optional<bool> floatStatus = {};
|
||||
if (args.contains("tile") || args.contains("tiled"))
|
||||
floatStatus = false;
|
||||
else if (args.contains("float") || args.contains("floating"))
|
||||
floatStatus = true;
|
||||
|
||||
if (args.contains("prev") || args.contains("p") || args.contains("last") || args.contains("l"))
|
||||
switchToWindow(g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow.lock(), true, floatStatus));
|
||||
CVarList args{arg, 0, 's', true};
|
||||
if (argsIsPrevious(arg))
|
||||
switchToWindow(g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow.lock(), true, getFloatStatus(arg)));
|
||||
else
|
||||
switchToWindow(g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow.lock(), true, floatStatus));
|
||||
switchToWindow(g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow.lock(), true, getFloatStatus(arg)));
|
||||
}
|
||||
|
||||
void CKeybindManager::circleNextVisible(std::string arg) {
|
||||
if (g_pCompositor->m_pLastWindow.expired()) {
|
||||
if (g_pCompositor->getWindowsOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspaceID()) <= 0)
|
||||
return; // if we have a clear focus, find the first window and get the next focusable.
|
||||
const auto PWINDOW = g_pCompositor->getFirstWindowOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspaceID());
|
||||
switchToWindow(PWINDOW);
|
||||
}
|
||||
|
||||
CVarList args{arg, 0, 's', true};
|
||||
if (argsIsPrevious(args))
|
||||
switchToWindow(g_pCompositor->getPrevVisibleWindow(g_pCompositor->m_pLastWindow.lock(), true, getFloatStatus(args)));
|
||||
else
|
||||
switchToWindow(g_pCompositor->getNextVisibleWindow(g_pCompositor->m_pLastWindow.lock(), true, getFloatStatus(args)));
|
||||
}
|
||||
|
||||
void CKeybindManager::focusWindow(std::string regexp) {
|
||||
|
|
|
@ -182,6 +182,7 @@ class CKeybindManager {
|
|||
static void moveWindow(std::string);
|
||||
static void resizeWindow(std::string);
|
||||
static void circleNext(std::string);
|
||||
static void circleNextVisible(std::string);
|
||||
static void focusWindow(std::string);
|
||||
static void tagWindow(std::string);
|
||||
static void setSubmap(std::string);
|
||||
|
|
|
@ -1473,14 +1473,7 @@ void CInputManager::updateCapabilities() {
|
|||
if (h.expired())
|
||||
continue;
|
||||
|
||||
auto cap = h->getCapabilities();
|
||||
|
||||
if (cap & HID_INPUT_CAPABILITY_KEYBOARD)
|
||||
caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
||||
if (cap & HID_INPUT_CAPABILITY_POINTER)
|
||||
caps |= WL_SEAT_CAPABILITY_POINTER;
|
||||
if (cap & HID_INPUT_CAPABILITY_TOUCH)
|
||||
caps |= WL_SEAT_CAPABILITY_TOUCH;
|
||||
caps |= h->getCapabilities();
|
||||
}
|
||||
|
||||
g_pSeatManager->updateCapabilities(caps);
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#define LOGM PROTO::constraints->protoLog
|
||||
|
||||
CPointerConstraint::CPointerConstraint(SP<CZwpLockedPointerV1> resource_, SP<CWLSurfaceResource> surf, wl_resource* region_, zwpPointerConstraintsV1Lifetime lifetime) :
|
||||
resourceL(resource_), locked(true) {
|
||||
CPointerConstraint::CPointerConstraint(SP<CZwpLockedPointerV1> resource_, SP<CWLSurfaceResource> surf, wl_resource* region_, zwpPointerConstraintsV1Lifetime lifetime_) :
|
||||
resourceL(resource_), locked(true), lifetime(lifetime_) {
|
||||
if (!resource_->resource())
|
||||
return;
|
||||
|
||||
|
@ -46,8 +46,8 @@ CPointerConstraint::CPointerConstraint(SP<CZwpLockedPointerV1> resource_, SP<CWL
|
|||
sharedConstructions();
|
||||
}
|
||||
|
||||
CPointerConstraint::CPointerConstraint(SP<CZwpConfinedPointerV1> resource_, SP<CWLSurfaceResource> surf, wl_resource* region_, zwpPointerConstraintsV1Lifetime lifetime) :
|
||||
resourceC(resource_), locked(false) {
|
||||
CPointerConstraint::CPointerConstraint(SP<CZwpConfinedPointerV1> resource_, SP<CWLSurfaceResource> surf, wl_resource* region_, zwpPointerConstraintsV1Lifetime lifetime_) :
|
||||
resourceC(resource_), locked(false), lifetime(lifetime_) {
|
||||
if (!resource_->resource())
|
||||
return;
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ class CWLSurfaceResource;
|
|||
|
||||
class CPointerConstraint {
|
||||
public:
|
||||
CPointerConstraint(SP<CZwpLockedPointerV1> resource_, SP<CWLSurfaceResource> surf, wl_resource* region, zwpPointerConstraintsV1Lifetime lifetime);
|
||||
CPointerConstraint(SP<CZwpConfinedPointerV1> resource_, SP<CWLSurfaceResource> surf, wl_resource* region, zwpPointerConstraintsV1Lifetime lifetime);
|
||||
CPointerConstraint(SP<CZwpLockedPointerV1> resource_, SP<CWLSurfaceResource> surf, wl_resource* region, zwpPointerConstraintsV1Lifetime lifetime_);
|
||||
CPointerConstraint(SP<CZwpConfinedPointerV1> resource_, SP<CWLSurfaceResource> surf, wl_resource* region, zwpPointerConstraintsV1Lifetime lifetime_);
|
||||
~CPointerConstraint();
|
||||
|
||||
bool good();
|
||||
|
|
Loading…
Reference in New Issue