From 6b30fb07918385ab02a97c27df5e3e2954f03487 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Tue, 5 Dec 2023 15:01:38 +0200 Subject: [PATCH] TWin showWindowMenu: add support for negative coordinates Negative coordinates change the popup menu origins: * Negative X: origin is right edge instead of left; * Negative Y: origin is bottom edge instead of top. Signed-off-by: Mavridis Philippe --- twin/useractions.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/twin/useractions.cpp b/twin/useractions.cpp index 2c6bc0a7a..1bcd2dafa 100644 --- a/twin/useractions.cpp +++ b/twin/useractions.cpp @@ -652,7 +652,6 @@ void Workspace::showWindowMenuAt( unsigned long window, int x, int y ) Client *client; if ((client = findClient(WindowMatchPredicate((WId)window)))) showWindowMenu( x, y, client ); - } void Workspace::slotActivateAttentionWindow() @@ -1072,17 +1071,21 @@ void Workspace::showWindowMenu( const TQRect &pos, Client* cl ) active_popup = p; int x = pos.left(); int y = pos.bottom(); - if (y == pos.top()) - p->exec( TQPoint( x, y ) ); + clientPopupAboutToShow(); // needed for sizeHint() to be correct :-/ + + TQRect area = clientArea(ScreenArea, TQPoint(x, y), currentDesktop()); + TQSize hint = p->sizeHint(); + if (x < 0) x = area.right() - hint.width() + x; + if (y < 0) y = area.bottom() - hint.height() + y; + + if (pos.bottom() == pos.top()) + p->exec( TQPoint( x, y ) ); else { - TQRect area = clientArea(ScreenArea, TQPoint(x, y), currentDesktop()); - clientPopupAboutToShow(); // needed for sizeHint() to be correct :-/ - int popupHeight = p->sizeHint().height(); - if (y + popupHeight < area.height()) - p->exec( TQPoint( x, y ) ); - else - p->exec( TQPoint( x, pos.top() - popupHeight ) ); + if (y + hint.height() < area.height()) + p->exec( TQPoint( x, y ) ); + else + p->exec( TQPoint( x, pos.top() - hint.height() ) ); } // active popup may be already changed (e.g. the window shortcut dialog) if( active_popup == p )