Ignoring KDE shortcuts and and pointer related actions in own application.
-
Holding of the <Alt> key + dragging of the left mouse button causes moving of the window under cursor in KDE by default.
I wish to do some action in own application when this event is occurred, but not window movement.
Is there is a recipe for doing it without changing KDE settings? -
It is not only KDE, it is a default behaviour of X-based window managers (at least it was, don't know whether the current ones still do the same). I don't think you can change it from your application, but as far as KWin is concerned, you can create a special application rule that targets only your application and disables this behaviour.
When I come to think of it, you might (possibly) make your application to create such a rule manually and push it to kwin.
-
Only one widget in my application requires specific actions on dragging by the left mouse button depended on keyboard modifiers state to do some operations on graphics objects. I have decided to enable mouse tracking for this widget and to call the grabMouse() function in reimplemented focusInEvent() and enterEvent() functions. To restore the default processing of mouse events I call the releaseMouse() function in reimplemented focusOutEvent() and leaveEvent() functions.
If there are situations when some dialogs can be appeared then the following event filter
@
bool GraphWidget::eventFilter(QObject *watched, QEvent *event)
{
if (watched != this && event->type() == QEvent::FocusIn)
{
QApplication::instance()->removeEventFilter(this);
releaseMouse();
}
return false;
}
@can help to catch situations when the releaseMouse() function must be called.
This event filter should be installed anywhere where the grabMouse() function is called:@
...
grabMouse();
QApplication::instance()->installEventFilter(this);
...
@May be there more preferred methods to prevent executing actions reserved by KDE or by other window management system and to execute custom action for own application on occurring specified events.
I will glad if anybody propose other methods to do it.