fixup: account for focusState changes in 40d8fa8

This commit is contained in:
nnra6864
2025-11-27 10:31:40 +01:00
committed by outfoxxed
parent ff064747f5
commit c0437b27a3
5 changed files with 57 additions and 54 deletions

68
flake.lock generated
View File

@@ -20,11 +20,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1762356719, "lastModified": 1763922789,
"narHash": "sha256-qwd/xdoOya1m8FENle+4hWnydCtlXUWLAW/Auk6WL7s=", "narHash": "sha256-XnkWjCpeXfip9tqYdL0b0zzBDjq+dgdISvEdSVGdVyA=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "aquamarine", "repo": "aquamarine",
"rev": "6d0b3567584691bf9d8fedb5d0093309e2f979c7", "rev": "a20a0e67a33b6848378a91b871b89588d3a12573",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -36,11 +36,11 @@
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1747046372, "lastModified": 1761588595,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", "narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=",
"owner": "edolstra", "owner": "edolstra",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", "rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -116,11 +116,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1762462052, "lastModified": 1763733840,
"narHash": "sha256-6roLYzcDf4V38RUMSqycsOwAnqfodL6BmhRkUtwIgdA=", "narHash": "sha256-JnET78yl5RvpGuDQy3rCycOCkiKoLr5DN1fPhRNNMco=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprgraphics", "repo": "hyprgraphics",
"rev": "ffc999d980c7b3bca85d3ebd0a9fbadf984a8162", "rev": "8f1bec691b2d198c60cccabca7a94add2df4ed1a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -145,17 +145,17 @@
"xdph": "xdph" "xdph": "xdph"
}, },
"locked": { "locked": {
"lastModified": 1763427561, "lastModified": 1764110666,
"narHash": "sha256-jARAMSNHOZ5RNYlBZ2wlE2pdujedylA5QDBuaQs3Vrk=", "narHash": "sha256-prU18d3zNddHZsdqh5o8vLVNONDgxVloFhXZgUxO4CI=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprland", "repo": "hyprland",
"rev": "edc311544a54a06ce4acb759b4d9a30853695452", "rev": "40d8fa84919c6d0e9fcb1536f4bc09710d4c031c",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprland", "repo": "hyprland",
"rev": "edc311544a54a06ce4acb759b4d9a30853695452", "rev": "40d8fa84919c6d0e9fcb1536f4bc09710d4c031c",
"type": "github" "type": "github"
} }
}, },
@@ -192,11 +192,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1762755186, "lastModified": 1763727565,
"narHash": "sha256-ZjjETUHtoEhVN7JI1Cbt3p/KcXpK8ZQaPHx7UkG1OgA=", "narHash": "sha256-vRff/2R1U1jzPBy4OODqh2kfUzmizW/nfV2ROzTDIKo=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprland-guiutils", "repo": "hyprland-guiutils",
"rev": "66356e20a8ed348aa49c1b9ceace786e224225b3", "rev": "7724d3a12a0453e7aae05f2ef39474219f05a4b4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -246,11 +246,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1763254292, "lastModified": 1763819661,
"narHash": "sha256-JNgz3Fz2KMzkT7aR72wsgu/xNeJB//LSmdilh8Z/Zao=", "narHash": "sha256-0jLarTR/BLWdGlboM86bPVP2zKJNI2jvo3JietnDkOM=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprlang", "repo": "hyprlang",
"rev": "deea98d5b61d066bdc7a68163edd2c4bd28d3a6b", "rev": "a318deec0c12409ec39c68d2be8096b636dc2a5c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -298,11 +298,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1762463729, "lastModified": 1763503177,
"narHash": "sha256-2fYkU/mdz8WKY3dkDPlE/j6hTxIwqultsx4gMMsMns0=", "narHash": "sha256-VPoiswJBBmTLVuNncvT/8FpFR+sYcAi/LgP/zTZ+5rA=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprtoolkit", "repo": "hyprtoolkit",
"rev": "88483bdee5329ec985f0c8f834c519cd18cfe532", "rev": "f4e1e12755567ecf39090203b8f43eace8279630",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -323,11 +323,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1763323331, "lastModified": 1763996058,
"narHash": "sha256-+Z0OfCo1MS8/aIutSAW5aJR9zTae1wz9kcJYMgpwN6M=", "narHash": "sha256-DsqzFZvrEV+aDmavjaD4/bk5qxeZwhGxPWBQdpFyM9Y=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprutils", "repo": "hyprutils",
"rev": "0c6411851cc779d551edc89b83966696201611aa", "rev": "0168583075baffa083032ed13a8bea8ea12f281a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -348,11 +348,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1755184602, "lastModified": 1763640274,
"narHash": "sha256-RCBQN8xuADB0LEgaKbfRqwm6CdyopE1xIEhNc67FAbw=", "narHash": "sha256-Uan1Nl9i4TF/kyFoHnTq1bd/rsWh4GAK/9/jDqLbY5A=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprwayland-scanner", "repo": "hyprwayland-scanner",
"rev": "b3b0f1f40ae09d4447c20608e5a4faf8bf3c492d", "rev": "f6cf414ca0e16a4d30198fd670ec86df3c89f671",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -363,11 +363,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1763283776, "lastModified": 1763966396,
"narHash": "sha256-Y7TDFPK4GlqrKrivOcsHG8xSGqQx3A6c+i7novT85Uk=", "narHash": "sha256-6eeL1YPcY1MV3DDStIDIdy/zZCDKgHdkCmsrLJFiZf0=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "50a96edd8d0db6cc8db57dab6bb6d6ee1f3dc49a", "rev": "5ae3b07d8d6527c42f17c876e404993199144b6a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -387,11 +387,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1763319842, "lastModified": 1763988335,
"narHash": "sha256-YG19IyrTdnVn0l3DvcUYm85u3PaqBt6tI6VvolcuHnA=", "narHash": "sha256-QlcnByMc8KBjpU37rbq5iP7Cp97HvjRP0ucfdh+M4Qc=",
"owner": "cachix", "owner": "cachix",
"repo": "git-hooks.nix", "repo": "git-hooks.nix",
"rev": "7275fa67fbbb75891c16d9dee7d88e58aea2d761", "rev": "50b9238891e388c9fdc6a5c49e49c42533a1b5ce",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -1,6 +1,6 @@
{ {
inputs = { inputs = {
hyprland.url = "github:hyprwm/hyprland/edc311544a54a06ce4acb759b4d9a30853695452"; hyprland.url = "github:hyprwm/hyprland/40d8fa84919c6d0e9fcb1536f4bc09710d4c031c";
}; };
outputs = { self, hyprland, ... }: let outputs = { self, hyprland, ... }: let

View File

@@ -5,6 +5,7 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <hyprland/src/Compositor.hpp> #include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/state/FocusState.hpp>
#include <hyprland/src/config/ConfigManager.hpp> #include <hyprland/src/config/ConfigManager.hpp>
#include <hyprland/src/desktop/DesktopTypes.hpp> #include <hyprland/src/desktop/DesktopTypes.hpp>
#include <hyprland/src/desktop/Workspace.hpp> #include <hyprland/src/desktop/Workspace.hpp>
@@ -33,8 +34,8 @@
PHLWORKSPACE workspace_for_action(bool allow_fullscreen) { PHLWORKSPACE workspace_for_action(bool allow_fullscreen) {
if (g_pLayoutManager->getCurrentLayout() != g_Hy3Layout.get()) return nullptr; if (g_pLayoutManager->getCurrentLayout() != g_Hy3Layout.get()) return nullptr;
auto workspace = g_pCompositor->m_lastMonitor->m_activeSpecialWorkspace; auto workspace = Desktop::focusState()->monitor()->m_activeSpecialWorkspace;
if (!valid(workspace)) workspace = g_pCompositor->m_lastMonitor->m_activeWorkspace; if (!valid(workspace)) workspace = Desktop::focusState()->monitor()->m_activeWorkspace;
if (!valid(workspace)) return nullptr; if (!valid(workspace)) return nullptr;
if (!allow_fullscreen && workspace->m_hasFullscreenWindow) return nullptr; if (!allow_fullscreen && workspace->m_hasFullscreenWindow) return nullptr;
@@ -144,7 +145,7 @@ void Hy3Layout::insertNode(Hy3Node& node) {
} }
if (opening_after == nullptr) { if (opening_after == nullptr) {
auto last_window = g_pCompositor->m_lastWindow; auto last_window = Desktop::focusState()->window();
if (last_window != nullptr && last_window->m_workspace == node.workspace if (last_window != nullptr && last_window->m_workspace == node.workspace
&& !last_window->m_isFloating && !last_window->m_isFloating
&& (node.data.is_window() || last_window != node.data.as_window()) && (node.data.is_window() || last_window != node.data.as_window())
@@ -412,7 +413,7 @@ ShiftDirection reverse(ShiftDirection direction) {
} }
void Hy3Layout::resizeActiveWindow(const Vector2D& delta, eRectCorner corner, PHLWINDOW pWindow) { void Hy3Layout::resizeActiveWindow(const Vector2D& delta, eRectCorner corner, PHLWINDOW pWindow) {
auto window = pWindow ? pWindow : g_pCompositor->m_lastWindow.lock(); auto window = pWindow ? pWindow : Desktop::focusState()->window();
if (!valid(window)) return; if (!valid(window)) return;
auto* node = this->getNodeFromWindow(window.get()); auto* node = this->getNodeFromWindow(window.get());
@@ -943,7 +944,7 @@ void Hy3Layout::shiftFocus(
bool visible, bool visible,
bool warp bool warp
) { ) {
auto current_window = g_pCompositor->m_lastWindow.lock(); auto current_window = Desktop::focusState()->window();
if (current_window != nullptr) { if (current_window != nullptr) {
if (current_window->m_workspace->m_hasFullscreenWindow) { if (current_window->m_workspace->m_hasFullscreenWindow) {
@@ -956,7 +957,7 @@ void Hy3Layout::shiftFocus(
if (next_window != nullptr) { if (next_window != nullptr) {
g_pInputManager->unconstrainMouse(); g_pInputManager->unconstrainMouse();
g_pCompositor->focusWindow(next_window); Desktop::focusState()->fullWindowFocus(next_window);
if (warp) Hy3Layout::warpCursorToBox(next_window->m_position, next_window->m_size); if (warp) Hy3Layout::warpCursorToBox(next_window->m_position, next_window->m_size);
} }
return; return;
@@ -989,7 +990,7 @@ Hy3Node* Hy3Layout::focusMonitor(ShiftDirection direction) {
if (next_monitor) { if (next_monitor) {
bool found = false; bool found = false;
g_pCompositor->setActiveMonitor(next_monitor); Desktop::focusState()->rawMonitorFocus(next_monitor);
auto next_workspace = next_monitor->m_activeWorkspace; auto next_workspace = next_monitor->m_activeWorkspace;
if (next_workspace) { if (next_workspace) {
@@ -1017,7 +1018,7 @@ bool Hy3Layout::shiftMonitor(Hy3Node& node, ShiftDirection direction, bool follo
auto next_monitor = g_pCompositor->getMonitorInDirection(getShiftDirectionChar(direction)); auto next_monitor = g_pCompositor->getMonitorInDirection(getShiftDirectionChar(direction));
if (next_monitor) { if (next_monitor) {
g_pCompositor->setActiveMonitor(next_monitor); Desktop::focusState()->rawMonitorFocus(next_monitor);
auto next_workspace = next_monitor->m_activeWorkspace; auto next_workspace = next_monitor->m_activeWorkspace;
if (next_workspace) { if (next_workspace) {
moveNodeToWorkspace(node.workspace.get(), next_workspace->m_name, follow, false); moveNodeToWorkspace(node.workspace.get(), next_workspace->m_name, follow, false);
@@ -1028,7 +1029,7 @@ bool Hy3Layout::shiftMonitor(Hy3Node& node, ShiftDirection direction, bool follo
} }
void Hy3Layout::toggleFocusLayer(const CWorkspace* workspace, bool warp) { void Hy3Layout::toggleFocusLayer(const CWorkspace* workspace, bool warp) {
auto current_window = g_pCompositor->m_lastWindow.lock(); auto current_window = Desktop::focusState()->window();
if (!current_window) return; if (!current_window) return;
PHLWINDOW target; PHLWINDOW target;
@@ -1040,7 +1041,7 @@ void Hy3Layout::toggleFocusLayer(const CWorkspace* workspace, bool warp) {
if (!target) return; if (!target) return;
g_pCompositor->focusWindow(target); Desktop::focusState()->fullWindowFocus(target);
if (warp) { if (warp) {
Hy3Layout::warpCursorWithFocus(target->middle()); Hy3Layout::warpCursorWithFocus(target->middle());
@@ -1048,7 +1049,7 @@ void Hy3Layout::toggleFocusLayer(const CWorkspace* workspace, bool warp) {
} }
void Hy3Layout::warpCursor() { void Hy3Layout::warpCursor() {
auto current_window = g_pCompositor->m_lastWindow.lock(); auto current_window = Desktop::focusState()->window();
if (current_window != nullptr) { if (current_window != nullptr) {
if (current_window != nullptr) { if (current_window != nullptr) {
@@ -1056,7 +1057,7 @@ void Hy3Layout::warpCursor() {
} }
} else { } else {
auto* node = auto* node =
this->getWorkspaceFocusedNode(g_pCompositor->m_lastMonitor->m_activeWorkspace.get()); this->getWorkspaceFocusedNode(Desktop::focusState()->monitor()->m_activeWorkspace.get());
if (node != nullptr) { if (node != nullptr) {
Hy3Layout::warpCursorWithFocus(node->position + node->size / 2); Hy3Layout::warpCursorWithFocus(node->position + node->size / 2);
@@ -1099,7 +1100,7 @@ void Hy3Layout::moveNodeToWorkspace(
if (origin == workspace.get()) return; if (origin == workspace.get()) return;
auto* node = this->getWorkspaceFocusedNode(origin); auto* node = this->getWorkspaceFocusedNode(origin);
auto focused_window = g_pCompositor->m_lastWindow.lock(); auto focused_window = Desktop::focusState()->window();
auto* focused_window_node = this->getNodeFromWindow(focused_window.get()); auto* focused_window_node = this->getNodeFromWindow(focused_window.get());
auto origin_ws = node != nullptr ? node->workspace auto origin_ws = node != nullptr ? node->workspace
@@ -1387,7 +1388,7 @@ void Hy3Layout::setNodeSwallow(const CWorkspace* workspace, SetSwallowOption opt
} }
void Hy3Layout::killFocusedNode(const CWorkspace* workspace) { void Hy3Layout::killFocusedNode(const CWorkspace* workspace) {
auto last_window = g_pCompositor->m_lastWindow.lock(); auto last_window = Desktop::focusState()->window();
if (last_window != nullptr && last_window->m_isFloating) { if (last_window != nullptr && last_window->m_isFloating) {
g_pCompositor->closeWindow(last_window); g_pCompositor->closeWindow(last_window);
} else { } else {
@@ -1543,7 +1544,7 @@ bool Hy3Layout::shouldRenderSelected(const CWindow* window) {
auto* focused = root->getFocusedNode(); auto* focused = root->getFocusedNode();
if (focused == nullptr if (focused == nullptr
|| (focused->data.is_window() || (focused->data.is_window()
&& focused->data.as_window() != g_pCompositor->m_lastWindow.lock())) && focused->data.as_window() != Desktop::focusState()->window()))
return false; return false;
switch (focused->data.type()) { switch (focused->data.type()) {

View File

@@ -4,6 +4,7 @@
#include <bits/ranges_util.h> #include <bits/ranges_util.h>
#include <hyprland/src/Compositor.hpp> #include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/state/FocusState.hpp>
#include <hyprland/src/config/ConfigManager.hpp> #include <hyprland/src/config/ConfigManager.hpp>
#include <hyprland/src/defines.hpp> #include <hyprland/src/defines.hpp>
#include <hyprland/src/plugins/PluginAPI.hpp> #include <hyprland/src/plugins/PluginAPI.hpp>
@@ -176,12 +177,12 @@ void Hy3Node::focus(bool warp) {
case Hy3NodeType::Window: { case Hy3NodeType::Window: {
auto window = this->data.as_window(); auto window = this->data.as_window();
window->setHidden(false); window->setHidden(false);
g_pCompositor->focusWindow(window); Desktop::focusState()->fullWindowFocus(window);
if (warp) Hy3Layout::warpCursorToBox(window->m_position, window->m_size); if (warp) Hy3Layout::warpCursorToBox(window->m_position, window->m_size);
break; break;
} }
case Hy3NodeType::Group: { case Hy3NodeType::Group: {
g_pCompositor->focusWindow(nullptr); Desktop::focusState()->fullWindowFocus(nullptr);
this->raiseToTop(); this->raiseToTop();
if (warp) Hy3Layout::warpCursorToBox(this->position, this->size); if (warp) Hy3Layout::warpCursorToBox(this->position, this->size);
@@ -218,7 +219,7 @@ PHLWINDOW Hy3Node::bringToTop() {
void Hy3Node::focusWindow() { void Hy3Node::focusWindow() {
auto window = this->bringToTop(); auto window = this->bringToTop();
if (window != nullptr) g_pCompositor->focusWindow(window); if (window != nullptr) Desktop::focusState()->fullWindowFocus(window);
} }
void markGroupFocusedRecursive(Hy3GroupData& group) { void markGroupFocusedRecursive(Hy3GroupData& group) {

View File

@@ -6,6 +6,7 @@
#include <cairo/cairo.h> #include <cairo/cairo.h>
#include <hyprgraphics/color/Color.hpp> #include <hyprgraphics/color/Color.hpp>
#include <hyprland/src/Compositor.hpp> #include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/state/FocusState.hpp>
#include <hyprland/src/config/ConfigManager.hpp> #include <hyprland/src/config/ConfigManager.hpp>
#include <hyprland/src/desktop/DesktopTypes.hpp> #include <hyprland/src/desktop/DesktopTypes.hpp>
#include <hyprland/src/desktop/Workspace.hpp> #include <hyprland/src/desktop/Workspace.hpp>
@@ -524,7 +525,7 @@ exitloop:
auto active = parent_focused && (parent_group.focused_child == *node || parent_group.group_focused); auto active = parent_focused && (parent_group.focused_child == *node || parent_group.group_focused);
entry->setActive(active); entry->setActive(active);
auto& last_monitor = g_pCompositor->m_lastMonitor; auto last_monitor = Desktop::focusState()->monitor();
entry->setMonitorActive(active && (!last_monitor || (*node)->getMonitor() == last_monitor.get())); entry->setMonitorActive(active && (!last_monitor || (*node)->getMonitor() == last_monitor.get()));
entry->setUrgent((*node)->isUrgent()); entry->setUrgent((*node)->isUrgent());