mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-23 22:29:49 +01:00
keybinds: add visible arg for cyclenext (#9045)
Co-authored-by: Крылов Александр <aleksandr.krylov@hyperus.team>
This commit is contained in:
parent
a661203bb6
commit
da6e966313
3 changed files with 41 additions and 66 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "Compositor.hpp"
|
#include "Compositor.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
|
#include "desktop/DesktopTypes.hpp"
|
||||||
#include "helpers/Splashes.hpp"
|
#include "helpers/Splashes.hpp"
|
||||||
#include "config/ConfigValue.hpp"
|
#include "config/ConfigValue.hpp"
|
||||||
#include "config/ConfigWatcher.hpp"
|
#include "config/ConfigWatcher.hpp"
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
#include "managers/VersionKeeperManager.hpp"
|
#include "managers/VersionKeeperManager.hpp"
|
||||||
#include "managers/DonationNagManager.hpp"
|
#include "managers/DonationNagManager.hpp"
|
||||||
#include "managers/eventLoop/EventLoopManager.hpp"
|
#include "managers/eventLoop/EventLoopManager.hpp"
|
||||||
|
#include <algorithm>
|
||||||
#include <aquamarine/output/Output.hpp>
|
#include <aquamarine/output/Output.hpp>
|
||||||
#include <bit>
|
#include <bit>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
@ -19,13 +21,13 @@
|
||||||
#include <print>
|
#include <print>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <ranges>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include "debug/HyprCtl.hpp"
|
#include "debug/HyprCtl.hpp"
|
||||||
#include "debug/CrashReporter.hpp"
|
#include "debug/CrashReporter.hpp"
|
||||||
#ifdef USES_SYSTEMD
|
#ifdef USES_SYSTEMD
|
||||||
#include <helpers/SdDaemon.hpp> // for SdNotify
|
#include <helpers/SdDaemon.hpp> // for SdNotify
|
||||||
#endif
|
#endif
|
||||||
#include <ranges>
|
|
||||||
#include "helpers/varlist/VarList.hpp"
|
#include "helpers/varlist/VarList.hpp"
|
||||||
#include "helpers/fs/FsUtils.hpp"
|
#include "helpers/fs/FsUtils.hpp"
|
||||||
#include "protocols/FractionalScale.hpp"
|
#include "protocols/FractionalScale.hpp"
|
||||||
|
@ -1638,62 +1640,37 @@ PHLWINDOW CCompositor::getWindowInDirection(const CBox& box, PHLWORKSPACE pWorks
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
PHLWINDOW CCompositor::getNextWindowOnWorkspace(PHLWINDOW pWindow, bool focusableOnly, std::optional<bool> floating) {
|
PHLWINDOW CCompositor::getNextWindowOnWorkspace(PHLWINDOW pWindow, bool focusableOnly, std::optional<bool> floating, bool visible) {
|
||||||
bool gotToWindow = false;
|
auto it = std::ranges::find(m_vWindows, pWindow);
|
||||||
for (auto const& w : m_vWindows) {
|
const auto FINDER = [&](const PHLWINDOW& w) { return isWindowAvailableForCycle(pWindow, w, focusableOnly, floating, visible); };
|
||||||
if (w != pWindow && !gotToWindow)
|
const auto IN_RIGHT = std::find_if(it, m_vWindows.end(), FINDER);
|
||||||
continue;
|
if (IN_RIGHT != m_vWindows.end())
|
||||||
|
return *IN_RIGHT;
|
||||||
if (w == pWindow) {
|
const auto IN_LEFT = std::find_if(m_vWindows.begin(), it, FINDER);
|
||||||
gotToWindow = true;
|
return *IN_LEFT;
|
||||||
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_sWindowData.noFocus.valueOrDefault()))
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto const& 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_sWindowData.noFocus.valueOrDefault()))
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PHLWINDOW CCompositor::getPrevWindowOnWorkspace(PHLWINDOW pWindow, bool focusableOnly, std::optional<bool> floating) {
|
PHLWINDOW CCompositor::getPrevWindowOnWorkspace(PHLWINDOW pWindow, bool focusableOnly, std::optional<bool> floating, bool visible) {
|
||||||
bool gotToWindow = false;
|
auto it = std::ranges::find(std::ranges::reverse_view(m_vWindows), pWindow);
|
||||||
for (auto const& w : m_vWindows | std::views::reverse) {
|
const auto FINDER = [&](const PHLWINDOW& w) { return isWindowAvailableForCycle(pWindow, w, focusableOnly, floating, visible); };
|
||||||
if (w != pWindow && !gotToWindow)
|
const auto IN_LEFT = std::find_if(it, m_vWindows.rend(), FINDER);
|
||||||
continue;
|
if (IN_LEFT != m_vWindows.rend())
|
||||||
|
return *IN_LEFT;
|
||||||
|
const auto IN_RIGHT = std::find_if(m_vWindows.rbegin(), it, FINDER);
|
||||||
|
return *IN_RIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
if (w == pWindow) {
|
inline static bool isWorkspaceMatches(PHLWINDOW pWindow, const PHLWINDOW w, bool anyWorkspace) {
|
||||||
gotToWindow = true;
|
return anyWorkspace ? w->m_pWorkspace && w->m_pWorkspace->isVisible() : w->m_pWorkspace == pWindow->m_pWorkspace;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (floating.has_value() && w->m_bIsFloating != floating.value())
|
inline static bool isFloatingMatches(PHLWINDOW w, std::optional<bool> floating) {
|
||||||
continue;
|
return !floating.has_value() || w->m_bIsFloating == floating.value();
|
||||||
|
};
|
||||||
|
|
||||||
if (w->m_pWorkspace == pWindow->m_pWorkspace && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_sWindowData.noFocus.valueOrDefault()))
|
bool CCompositor::isWindowAvailableForCycle(PHLWINDOW pWindow, const PHLWINDOW w, bool focusableOnly, std::optional<bool> floating, bool anyWorkspace) {
|
||||||
return w;
|
return isFloatingMatches(w, floating) && w != pWindow && isWorkspaceMatches(pWindow, w, anyWorkspace) && w->m_bIsMapped && !w->isHidden() &&
|
||||||
}
|
(!focusableOnly || !w->m_sWindowData.noFocus.valueOrDefault());
|
||||||
|
|
||||||
for (auto const& w : m_vWindows | std::views::reverse) {
|
|
||||||
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_sWindowData.noFocus.valueOrDefault()))
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WORKSPACEID CCompositor::getNextAvailableNamedWorkspace() {
|
WORKSPACEID CCompositor::getNextAvailableNamedWorkspace() {
|
||||||
|
@ -1728,12 +1705,8 @@ PHLWORKSPACE CCompositor::getWorkspaceByString(const std::string& str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCompositor::isPointOnAnyMonitor(const Vector2D& point) {
|
bool CCompositor::isPointOnAnyMonitor(const Vector2D& point) {
|
||||||
for (auto const& m : m_vMonitors) {
|
return std::ranges::any_of(
|
||||||
if (VECINRECT(point, m->vecPosition.x, m->vecPosition.y, m->vecSize.x + m->vecPosition.x, m->vecSize.y + m->vecPosition.y))
|
m_vMonitors, [&](const PHLMONITOR& m) { return VECINRECT(point, m->vecPosition.x, m->vecPosition.y, m->vecSize.x + m->vecPosition.x, m->vecSize.y + m->vecPosition.y); });
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCompositor::isPointOnReservedArea(const Vector2D& point, const PHLMONITOR pMonitor) {
|
bool CCompositor::isPointOnReservedArea(const Vector2D& point, const PHLMONITOR pMonitor) {
|
||||||
|
|
|
@ -106,8 +106,8 @@ class CCompositor {
|
||||||
void cleanupFadingOut(const MONITORID& monid);
|
void cleanupFadingOut(const MONITORID& monid);
|
||||||
PHLWINDOW getWindowInDirection(PHLWINDOW, char);
|
PHLWINDOW getWindowInDirection(PHLWINDOW, char);
|
||||||
PHLWINDOW getWindowInDirection(const CBox& box, PHLWORKSPACE pWorkspace, char dir, PHLWINDOW ignoreWindow = nullptr, bool useVectorAngles = false);
|
PHLWINDOW getWindowInDirection(const CBox& box, PHLWORKSPACE pWorkspace, char dir, PHLWINDOW ignoreWindow = nullptr, bool useVectorAngles = false);
|
||||||
PHLWINDOW getNextWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
|
PHLWINDOW getNextWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {}, bool visible = false);
|
||||||
PHLWINDOW getPrevWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
|
PHLWINDOW getPrevWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {}, bool visible = false);
|
||||||
WORKSPACEID getNextAvailableNamedWorkspace();
|
WORKSPACEID getNextAvailableNamedWorkspace();
|
||||||
bool isPointOnAnyMonitor(const Vector2D&);
|
bool isPointOnAnyMonitor(const Vector2D&);
|
||||||
bool isPointOnReservedArea(const Vector2D& point, const PHLMONITOR monitor = nullptr);
|
bool isPointOnReservedArea(const Vector2D& point, const PHLMONITOR monitor = nullptr);
|
||||||
|
@ -163,6 +163,7 @@ class CCompositor {
|
||||||
void setRandomSplash();
|
void setRandomSplash();
|
||||||
void initManagers(eManagersInitStage stage);
|
void initManagers(eManagersInitStage stage);
|
||||||
void prepareFallbackOutput();
|
void prepareFallbackOutput();
|
||||||
|
bool isWindowAvailableForCycle(PHLWINDOW pWindow, PHLWINDOW w, bool focusableOnly, std::optional<bool> floating, bool anyWorkspace = false);
|
||||||
|
|
||||||
uint64_t m_iHyprlandPID = 0;
|
uint64_t m_iHyprlandPID = 0;
|
||||||
wl_event_source* m_critSigSource = nullptr;
|
wl_event_source* m_critSigSource = nullptr;
|
||||||
|
|
|
@ -750,7 +750,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP
|
||||||
Debug::log(ERR, "Invalid handler in a keybind! (handler {} does not exist)", k->handler);
|
Debug::log(ERR, "Invalid handler in a keybind! (handler {} does not exist)", k->handler);
|
||||||
} else {
|
} else {
|
||||||
// call the dispatcher
|
// call the dispatcher
|
||||||
Debug::log(LOG, "Keybind triggered, calling dispatcher ({}, {}, {})", modmask, key.keyName, key.keysym);
|
Debug::log(LOG, "Keybind triggered, calling dispatcher ({}, {}, {}, {})", modmask, key.keyName, key.keysym, DISPATCHER->first);
|
||||||
|
|
||||||
m_iPassPressed = (int)pressed;
|
m_iPassPressed = (int)pressed;
|
||||||
|
|
||||||
|
@ -2201,7 +2201,6 @@ SDispatchResult CKeybindManager::resizeWindow(std::string args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDispatchResult CKeybindManager::circleNext(std::string arg) {
|
SDispatchResult CKeybindManager::circleNext(std::string arg) {
|
||||||
|
|
||||||
if (g_pCompositor->m_pLastWindow.expired()) {
|
if (g_pCompositor->m_pLastWindow.expired()) {
|
||||||
// if we have a clear focus, find the first window and get the next focusable.
|
// if we have a clear focus, find the first window and get the next focusable.
|
||||||
const auto PWS = g_pCompositor->m_pLastMonitor->activeWorkspace;
|
const auto PWS = g_pCompositor->m_pLastMonitor->activeWorkspace;
|
||||||
|
@ -2221,10 +2220,12 @@ SDispatchResult CKeybindManager::circleNext(std::string arg) {
|
||||||
else if (args.contains("float") || args.contains("floating"))
|
else if (args.contains("float") || args.contains("floating"))
|
||||||
floatStatus = true;
|
floatStatus = true;
|
||||||
|
|
||||||
if (args.contains("prev") || args.contains("p") || args.contains("last") || args.contains("l"))
|
const auto VISIBLE = args.contains("visible") || args.contains("v");
|
||||||
switchToWindow(g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow.lock(), true, floatStatus));
|
const auto& w = (args.contains("prev") || args.contains("p") || args.contains("last") || args.contains("l")) ?
|
||||||
else
|
g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow.lock(), true, floatStatus, VISIBLE) :
|
||||||
switchToWindow(g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow.lock(), true, floatStatus));
|
g_pCompositor->getNextWindowOnWorkspace(g_pCompositor->m_pLastWindow.lock(), true, floatStatus, VISIBLE);
|
||||||
|
|
||||||
|
switchToWindow(w);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue