From bb10bf015d04227eedd4f44112c75babb95a26b6 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Tue, 5 Dec 2023 15:53:55 +0200 Subject: [PATCH] TWin: add tileHorizontally(), tileVertically(), tileGrid() DCOP calls Signed-off-by: Mavridis Philippe --- twin/KWinInterface.h | 3 +++ twin/client.h | 1 + twin/geometry.cpp | 12 ++++++++++++ twin/useractions.cpp | 38 ++++++++++++++++++++++++++++++++++++++ twin/workspace.h | 3 +++ 5 files changed, 57 insertions(+) diff --git a/twin/KWinInterface.h b/twin/KWinInterface.h index dbc132888..c12cf6556 100644 --- a/twin/KWinInterface.h +++ b/twin/KWinInterface.h @@ -28,6 +28,9 @@ class KWinInterface : virtual public DCOPObject virtual void circulateDesktopApplications() = 0; virtual void updateOverlappingShadows(unsigned long window) = 0; virtual void setShadowed(unsigned long window, bool shadowed) = 0; + virtual void tileHorizontally(unsigned long w1, unsigned long w2) = 0; + virtual void tileVertically(unsigned long w1, unsigned long w2) = 0; + virtual void tileGrid(unsigned long w1, unsigned long w2, unsigned long w3, unsigned long w4) = 0; // kompmgr stuff virtual void startKompmgr() = 0; diff --git a/twin/client.h b/twin/client.h index 00703608d..8e46c292b 100644 --- a/twin/client.h +++ b/twin/client.h @@ -240,6 +240,7 @@ class Client : public TQObject, public KDecorationDefines void cancelActiveBorderMaximizing(); bool isActiveBorderMaximizing() const; TQRect activeBorderMaximizeGeometry(); + void tile(ActiveBorder border); void growHorizontal(); void shrinkHorizontal(); diff --git a/twin/geometry.cpp b/twin/geometry.cpp index 65285cab6..f2b6f3a00 100644 --- a/twin/geometry.cpp +++ b/twin/geometry.cpp @@ -2828,4 +2828,16 @@ TQRect Client::activeBorderMaximizeGeometry() return ret; } +void Client::tile(ActiveBorder border) { + if (!isResizable()) return; + activeTiled = true; + setActiveBorderMode(ActiveTilingMode); + setActiveBorder(border); + TQRect geo = activeBorderMaximizeGeometry(); + if (geo.isValid() && !geo.isEmpty()) { + setGeometry(geo); + } + workspace()->raiseClient(this); +} + } // namespace diff --git a/twin/useractions.cpp b/twin/useractions.cpp index de78a5b64..5c453228e 100644 --- a/twin/useractions.cpp +++ b/twin/useractions.cpp @@ -653,6 +653,44 @@ void Workspace::showWindowMenuAt( unsigned long, int, int ) slotWindowOperations(); } +void Workspace::tileHorizontally(unsigned long w1, unsigned long w2) { + if (w1 == w2) return; + + Client *c1 = findClient(WindowMatchPredicate((WId)w1)); + Client *c2 = findClient(WindowMatchPredicate((WId)w2)); + if (!c1 || !c2) return; + + c1->tile(ActiveTop); + c2->tile(ActiveBottom); +} + +void Workspace::tileVertically(unsigned long w1, unsigned long w2) { + if (w1 == w2) return; + + Client *c1 = findClient(WindowMatchPredicate((WId)w1)); + Client *c2 = findClient(WindowMatchPredicate((WId)w2)); + if (!c1 || !c2) return; + + c1->tile(ActiveLeft); + c2->tile(ActiveRight); +} + +void Workspace::tileGrid(unsigned long w1, unsigned long w2, unsigned long w3, unsigned long w4) { + if (w1 == w2 || w1 == w3 || w1 == w4 || w2 == w3 || w2 == w4 || w3 == w4) + return; + + Client *c1 = findClient(WindowMatchPredicate((WId)w1)); + Client *c2 = findClient(WindowMatchPredicate((WId)w2)); + Client *c3 = findClient(WindowMatchPredicate((WId)w3)); + Client *c4 = findClient(WindowMatchPredicate((WId)w4)); + if (!c1 || !c2 || !c3 || !c4) return; + + c1->tile(ActiveTopLeft); + c2->tile(ActiveTopRight); + c3->tile(ActiveBottomLeft); + c4->tile(ActiveBottomRight); +} + void Workspace::slotActivateAttentionWindow() { if( attention_chain.count() > 0 ) diff --git a/twin/workspace.h b/twin/workspace.h index 47ba7bb15..e784d08d7 100644 --- a/twin/workspace.h +++ b/twin/workspace.h @@ -206,6 +206,9 @@ class Workspace : public TQObject, public KWinInterface, public KDecorationDefin // KDE4 remove me - and it's also in the DCOP interface :( void showWindowMenuAt( unsigned long id, int x, int y ); + void tileHorizontally(unsigned long w1, unsigned long w2); + void tileVertically(unsigned long w1, unsigned long w2); + void tileGrid(unsigned long w1, unsigned long w2, unsigned long w3, unsigned long w4); void kDestopResized(); /**