Added a new variant of showWindowMenu() that takes an originating rect instead
of a point. This method should be preferred to bring up the actions menu from the menu button, since it makes it a bit harder to select a menu item involuntaryily in some corner case. svn path=/trunk/kdebase/kwin/; revision=317016
This commit is contained in:
parent
d33e795f6b
commit
7240bff8f1
9 changed files with 66 additions and 13 deletions
|
@ -72,6 +72,11 @@ void Bridge::showWindowMenu( QPoint p )
|
|||
c->workspace()->showWindowMenu( p, c );
|
||||
}
|
||||
|
||||
void Bridge::showWindowMenu( const QRect &p )
|
||||
{
|
||||
c->workspace()->showWindowMenu( p, c );
|
||||
}
|
||||
|
||||
void Bridge::performWindowOperation( WindowOperation op )
|
||||
{
|
||||
c->workspace()->performWindowOperation( c, op );
|
||||
|
|
1
bridge.h
1
bridge.h
|
@ -42,6 +42,7 @@ class Bridge : public KDecorationBridge
|
|||
virtual QString caption() const;
|
||||
virtual void processMousePressEvent( QMouseEvent* );
|
||||
virtual void showWindowMenu( QPoint );
|
||||
virtual void showWindowMenu( const QRect & );
|
||||
virtual void performWindowOperation( WindowOperation );
|
||||
virtual void setMask( const QRegion&, int );
|
||||
virtual bool isPreview() const;
|
||||
|
|
|
@ -301,6 +301,10 @@ void KDecorationPreviewBridge::processMousePressEvent( QMouseEvent* )
|
|||
{
|
||||
}
|
||||
|
||||
void KDecorationPreviewBridge::showWindowMenu( const QRect &)
|
||||
{
|
||||
}
|
||||
|
||||
void KDecorationPreviewBridge::showWindowMenu( QPoint )
|
||||
{
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ class KDecorationPreviewBridge
|
|||
virtual QIconSet icon() const;
|
||||
virtual QString caption() const;
|
||||
virtual void processMousePressEvent( QMouseEvent* );
|
||||
virtual void showWindowMenu( const QRect &);
|
||||
virtual void showWindowMenu( QPoint );
|
||||
virtual void performWindowOperation( WindowOperation );
|
||||
virtual void setMask( const QRegion&, int );
|
||||
|
|
|
@ -176,11 +176,16 @@ void KDecoration::processMousePressEvent( QMouseEvent* e )
|
|||
return bridge_->processMousePressEvent( e );
|
||||
}
|
||||
|
||||
void KDecoration::showWindowMenu( QPoint pos )
|
||||
void KDecoration::showWindowMenu( const QRect &pos )
|
||||
{
|
||||
bridge_->showWindowMenu( pos );
|
||||
}
|
||||
|
||||
void KDecoration::showWindowMenu( QPoint pos )
|
||||
{
|
||||
bridge_->showWindowMenu( pos );
|
||||
}
|
||||
|
||||
void KDecoration::performWindowOperation( WindowOperation op )
|
||||
{
|
||||
bridge_->performWindowOperation( op );
|
||||
|
|
|
@ -406,12 +406,22 @@ class KDecoration
|
|||
*/
|
||||
QString caption() const;
|
||||
/**
|
||||
* This function invokes the window operations menu. IMPORTANT: As a result
|
||||
* of this function, the decoration object that called it may be destroyed
|
||||
* after the function returns. This means that the decoration object must
|
||||
* either return immediately after calling showWindowMenu(), or it must
|
||||
* use KDecorationFactory::exists() to check it's still valid. For example,
|
||||
* the code handling clicks on the menu button should look similarly like this:
|
||||
* This function invokes the window operations menu.
|
||||
* \param pos specifies the place on the screen where the menu should
|
||||
* show up. The menu pops up at the bottom-left corner of the specified
|
||||
* rectangle, unless there is no space, in which case the menu is
|
||||
* displayed above the rectangle.
|
||||
*
|
||||
* \note Decorations that enable a double-click operation for the menu
|
||||
* button must ensure to call \a showWindowMenu() with the \a pos
|
||||
* rectangle set to the menu button geometry.
|
||||
* IMPORTANT: As a result of this function, the decoration object that
|
||||
* called it may be destroyed after the function returns. This means
|
||||
* that the decoration object must either return immediately after
|
||||
* calling showWindowMenu(), or it must use
|
||||
* KDecorationFactory::exists() to check it's still valid. For example,
|
||||
* the code handling clicks on the menu button should look similarly
|
||||
* like this:
|
||||
*
|
||||
* \code
|
||||
* KDecorationFactory* f = factory(); // needs to be saved before
|
||||
|
@ -421,6 +431,11 @@ class KDecoration
|
|||
* button[MenuButton]->setDown(false);
|
||||
* \endcode
|
||||
*/
|
||||
void showWindowMenu( const QRect &pos );
|
||||
|
||||
/**
|
||||
* Overloaded version of the above.
|
||||
*/
|
||||
void showWindowMenu( QPoint pos );
|
||||
/**
|
||||
* This function performs the given window operation. This function may destroy
|
||||
|
@ -460,7 +475,7 @@ class KDecoration
|
|||
* Returns the intersection of the given region with the region left
|
||||
* unobscured by the windows stacked above the current one. You can use
|
||||
* this function to, for example, try to keep the titlebar visible if
|
||||
* there is an hole available. The region returned is in the coordinate
|
||||
* there is a hole available. The region returned is in the coordinate
|
||||
* space of the decoration.
|
||||
* @param r The region you want to check for holes
|
||||
*/
|
||||
|
|
|
@ -77,6 +77,7 @@ class KDecorationBridge : public KDecorationDefines
|
|||
virtual QIconSet icon() const = 0;
|
||||
virtual QString caption() const = 0;
|
||||
virtual void processMousePressEvent( QMouseEvent* ) = 0;
|
||||
virtual void showWindowMenu( const QRect &) = 0;
|
||||
virtual void showWindowMenu( QPoint ) = 0;
|
||||
virtual void performWindowOperation( WindowOperation ) = 0;
|
||||
virtual void setMask( const QRegion&, int ) = 0;
|
||||
|
|
|
@ -761,7 +761,7 @@ void Workspace::slotWindowOperations()
|
|||
showWindowMenu( pos.x(), pos.y(), active_client );
|
||||
}
|
||||
|
||||
void Workspace::showWindowMenu( int x, int y, Client* cl )
|
||||
void Workspace::showWindowMenu( const QRect &pos, Client* cl )
|
||||
{
|
||||
if (!kapp->authorizeKAction("kwin_rmb"))
|
||||
return;
|
||||
|
@ -776,7 +776,19 @@ void Workspace::showWindowMenu( int x, int y, Client* cl )
|
|||
|
||||
popup_client = cl;
|
||||
QPopupMenu* p = clientPopup();
|
||||
p->exec( QPoint( x, y ) );
|
||||
int x = pos.left();
|
||||
int y = pos.bottom();
|
||||
if (y == pos.top()) {
|
||||
p->exec( QPoint( x, y ) );
|
||||
} else {
|
||||
QRect area = clientArea(ScreenArea, QPoint(x, y), currentDesktop());
|
||||
int popupHeight = p->sizeHint().height();
|
||||
if (y + popupHeight < area.height()) {
|
||||
p->exec( QPoint( x, y ) );
|
||||
} else {
|
||||
p->exec( QPoint( x, pos.top() - popupHeight ) );
|
||||
}
|
||||
}
|
||||
popup_client = 0;
|
||||
}
|
||||
|
||||
|
|
15
workspace.h
15
workspace.h
|
@ -182,9 +182,13 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine
|
|||
void showWindowMenuAt( unsigned long id, int x, int y );
|
||||
|
||||
/**
|
||||
* Shows the menu operations menu for the client
|
||||
* and makes it active if it's not already.
|
||||
* Shows the menu operations menu for the client and makes it active if
|
||||
* it's not already.
|
||||
*/
|
||||
void showWindowMenu( const QRect &pos, Client* cl );
|
||||
/**
|
||||
* Backwards compatibility.
|
||||
*/
|
||||
void showWindowMenu( int x, int y, Client* cl );
|
||||
void showWindowMenu( QPoint pos, Client* cl );
|
||||
|
||||
|
@ -624,7 +628,12 @@ inline const ClientList& Workspace::stackingOrder() const
|
|||
|
||||
inline void Workspace::showWindowMenu(QPoint pos, Client* cl)
|
||||
{
|
||||
showWindowMenu(pos.x(), pos.y(), cl);
|
||||
showWindowMenu(QRect(pos, pos), cl);
|
||||
}
|
||||
|
||||
inline void Workspace::showWindowMenu(int x, int y, Client* cl)
|
||||
{
|
||||
showWindowMenu(QRect(QPoint(x, y), QPoint(x, y)), cl);
|
||||
}
|
||||
|
||||
inline
|
||||
|
|
Loading…
Reference in a new issue