Commit f8dcf697 authored by David Redondo's avatar David Redondo 🏎
Browse files

Drop input grabbing hack

Apparently this was introduced to prevent the window losing focus if
https://bugs.kde.org/show_bug.cgi?id=310476 is to be believed. However
on X the window does not lose focus without it.
Furthermore it actually improves keyboard navigation on X, which after a
child menu was closed stopped working.
On Wayland this prevents things working at all.
BUG:420980
FIXED-IN:5.23
parent 36a09b6c
......@@ -38,40 +38,3 @@ VerticalMenu::VerticalMenu(QWidget *parent)
VerticalMenu::~VerticalMenu()
{
}
QMenu *VerticalMenu::leafMenu()
{
QMenu *leaf = this;
while (true) {
QAction *act = leaf->activeAction();
if (act && act->menu() && act->menu()->isVisible()) {
leaf = act->menu();
continue;
}
return leaf == this ? nullptr : leaf;
}
return nullptr; // make gcc happy
}
void VerticalMenu::paintEvent(QPaintEvent *pe)
{
QMenu::paintEvent(pe);
if (QWidget::mouseGrabber() == this)
return;
if (QWidget::mouseGrabber())
QWidget::mouseGrabber()->releaseMouse();
grabMouse();
grabKeyboard();
}
#define FORWARD(_EVENT_, _TYPE_) \
void VerticalMenu::_EVENT_##Event(Q##_TYPE_##Event *e) \
{ \
if (QMenu *leaf = leafMenu()) \
QCoreApplication::sendEvent(leaf, e); \
else \
QMenu::_EVENT_##Event(e); \
}
FORWARD(keyPress, Key)
FORWARD(keyRelease, Key)
......@@ -54,14 +54,7 @@ public:
m_menuObjectPath = menuObjectPath;
}
protected:
void keyPressEvent(QKeyEvent *) override;
void keyReleaseEvent(QKeyEvent *) override;
void paintEvent(QPaintEvent *) override;
private:
QMenu *leafMenu();
QString m_serviceName;
QDBusObjectPath m_menuObjectPath;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment