Add support for hyprland movewindow dispatcher

Note that this support is worse than hy3:movwindow and you should
still use that. This fixes the api breakage though.
This commit is contained in:
outfoxxed 2023-09-05 02:12:35 -07:00
parent 0cc5af9e60
commit 14dec2e15c
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
3 changed files with 43 additions and 23 deletions

20
flake.lock generated
View file

@ -9,11 +9,11 @@
"xdph": "xdph" "xdph": "xdph"
}, },
"locked": { "locked": {
"lastModified": 1692123043, "lastModified": 1693851147,
"narHash": "sha256-6YoTjAZgtJb9OzKrZxtLxjfYiGWSqMmh1Wyh9dvwXn8=", "narHash": "sha256-kkI7FXwKufOmNIIQQHr868tneIV8ggqupBA0EJ/jAuI=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "Hyprland", "repo": "Hyprland",
"rev": "4986d74ef201171a930c312a8e3b72a22d9b84ee", "rev": "4ddcda93f5887792a953332bf1b487e4b2c3b4ed",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -49,11 +49,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1691654369, "lastModified": 1693158576,
"narHash": "sha256-gSILTEx1jRaJjwZxRlnu3ZwMn1FVNk80qlwiCX8kmpo=", "narHash": "sha256-aRTTXkYvhXosGx535iAFUaoFboUrZSYb1Ooih/auGp0=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "ce5e4a6ef2e59d89a971bc434ca8ca222b9c7f5e", "rev": "a999c1cc0c9eb2095729d5aa03e0d8f7ed256780",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -87,18 +87,18 @@
"flake": false, "flake": false,
"locked": { "locked": {
"host": "gitlab.freedesktop.org", "host": "gitlab.freedesktop.org",
"lastModified": 1691073628, "lastModified": 1692976565,
"narHash": "sha256-LlxE3o3UzRY7APYVLGNKM30DBMcDifCRIQiMVSbYLIc=", "narHash": "sha256-eBKkG7tMxg92NskEn8dHRFY245JwjirWRoOZzW6DnUw=",
"owner": "wlroots", "owner": "wlroots",
"repo": "wlroots", "repo": "wlroots",
"rev": "c74f89d4f84bfed0284d3908aee5d207698c70c5", "rev": "717ded9bb0191ea31bf4368be32e7a15fe1b8294",
"type": "gitlab" "type": "gitlab"
}, },
"original": { "original": {
"host": "gitlab.freedesktop.org", "host": "gitlab.freedesktop.org",
"owner": "wlroots", "owner": "wlroots",
"repo": "wlroots", "repo": "wlroots",
"rev": "c74f89d4f84bfed0284d3908aee5d207698c70c5", "rev": "717ded9bb0191ea31bf4368be32e7a15fe1b8294",
"type": "gitlab" "type": "gitlab"
} }
}, },

View file

@ -673,6 +673,20 @@ void Hy3Layout::switchWindows(CWindow* pWindowA, CWindow* pWindowB) {
// todo // todo
} }
void Hy3Layout::moveWindowTo(CWindow* window, const std::string& direction) {
auto* node = this->getNodeFromWindow(window);
if (node == nullptr) return;
ShiftDirection shift;
if (direction == "l") shift = ShiftDirection::Left;
else if (direction == "r") shift = ShiftDirection::Right;
else if (direction == "u") shift = ShiftDirection::Up;
else if (direction == "d") shift = ShiftDirection::Down;
else return;
this->shiftNode(*node, shift, false, false);
}
void Hy3Layout::alterSplitRatio(CWindow* pWindow, float delta, bool exact) { void Hy3Layout::alterSplitRatio(CWindow* pWindow, float delta, bool exact) {
// todo // todo
} }
@ -874,24 +888,28 @@ void Hy3Layout::changeGroupEphemeralityOn(Hy3Node& node, bool ephemeral) {
); );
} }
void Hy3Layout::shiftNode(Hy3Node& node, ShiftDirection direction, bool once, bool visible) {
if (once && node.parent != nullptr && node.parent->data.as_group.children.size() == 1) {
if (node.parent->parent == nullptr) {
node.parent->data.as_group.setLayout(Hy3GroupLayout::SplitH);
node.parent->recalcSizePosRecursive();
} else {
auto* node2 = node.parent;
Hy3Node::swapData(node, *node2);
node2->layout->nodes.remove(node);
node2->recalcSizePosRecursive();
}
} else {
this->shiftOrGetFocus(node, direction, true, once, visible);
}
}
void Hy3Layout::shiftWindow(int workspace, ShiftDirection direction, bool once, bool visible) { void Hy3Layout::shiftWindow(int workspace, ShiftDirection direction, bool once, bool visible) {
auto* node = this->getWorkspaceFocusedNode(workspace); auto* node = this->getWorkspaceFocusedNode(workspace);
Debug::log(LOG, "ShiftWindow %p %d", node, direction); Debug::log(LOG, "ShiftWindow %p %d", node, direction);
if (node == nullptr) return; if (node == nullptr) return;
if (once && node->parent != nullptr && node->parent->data.as_group.children.size() == 1) { this->shiftNode(*node, direction, once, visible);
if (node->parent->parent == nullptr) {
node->parent->data.as_group.setLayout(Hy3GroupLayout::SplitH);
node->parent->recalcSizePosRecursive();
} else {
auto* node2 = node->parent;
Hy3Node::swapData(*node, *node2);
node2->layout->nodes.remove(*node);
node2->recalcSizePosRecursive();
}
} else {
this->shiftOrGetFocus(*node, direction, true, once, visible);
}
} }
void Hy3Layout::shiftFocus(int workspace, ShiftDirection direction, bool visible) { void Hy3Layout::shiftFocus(int workspace, ShiftDirection direction, bool visible) {

View file

@ -79,6 +79,7 @@ public:
virtual std::any layoutMessage(SLayoutMessageHeader header, std::string content); virtual std::any layoutMessage(SLayoutMessageHeader header, std::string content);
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*); virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
virtual void switchWindows(CWindow*, CWindow*); virtual void switchWindows(CWindow*, CWindow*);
virtual void moveWindowTo(CWindow*, const std::string& direction);
virtual void alterSplitRatio(CWindow*, float, bool); virtual void alterSplitRatio(CWindow*, float, bool);
virtual std::string getLayoutName(); virtual std::string getLayoutName();
virtual CWindow* getNextWindowCandidate(CWindow*); virtual CWindow* getNextWindowCandidate(CWindow*);
@ -102,6 +103,7 @@ public:
void toggleTabGroupOn(Hy3Node&); void toggleTabGroupOn(Hy3Node&);
void changeGroupToOppositeOn(Hy3Node&); void changeGroupToOppositeOn(Hy3Node&);
void changeGroupEphemeralityOn(Hy3Node&, bool ephemeral); void changeGroupEphemeralityOn(Hy3Node&, bool ephemeral);
void shiftNode(Hy3Node&, ShiftDirection, bool once, bool visible);
void shiftWindow(int workspace, ShiftDirection, bool once, bool visible); void shiftWindow(int workspace, ShiftDirection, bool once, bool visible);
void shiftFocus(int workspace, ShiftDirection, bool visible); void shiftFocus(int workspace, ShiftDirection, bool visible);
void changeFocus(int workspace, FocusShift); void changeFocus(int workspace, FocusShift);