Skip to content

Commit a8005ac

Browse files
committed
feat: add keyboard focus management for plugin surfaces
1. Added setKeyboardFocus method to PluginSurface class to handle keyboard focus via Wayland seat 2. Exposed the method as Q_INVOKABLE for QML access 3. Implemented focus handling in ShellSurfaceItemProxy when hovered 4. Includes necessary QWaylandSeat header for keyboard focus management 5. This ensures proper keyboard input handling when interacting with plugin surfaces feat: 为插件表面添加键盘焦点管理 1. 在 PluginSurface 类中添加 setKeyboardFocus 方法,通过 Wayland seat 处 理键盘焦点 2. 将方法暴露为 Q_INVOKABLE 以便 QML 访问 3. 在 ShellSurfaceItemProxy 中实现悬停时的焦点处理 4. 包含必要的 QWaylandSeat 头文件用于键盘焦点管理 5. 确保与插件表面交互时能正确处理键盘输入 Pms: BUG-312795
1 parent b5dd4d0 commit a8005ac

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

panels/dock/pluginmanagerextension.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <QtWaylandCompositor/QWaylandSurface>
1515
#include <QtWaylandCompositor/QWaylandResource>
1616
#include <QtWaylandCompositor/QWaylandCompositor>
17+
#include <QtWaylandCompositor/QWaylandView>
1718

1819
#include <QJsonObject>
1920
#include <QJsonParseError>
@@ -431,6 +432,9 @@ void PluginManager::initialize()
431432
#endif
432433

433434
init(compositor->display(), 1);
435+
436+
// 设置鼠标焦点监听器
437+
setupMouseFocusListener();
434438
}
435439

436440
void PluginManager::updateDockOverflowState(int state)
@@ -685,3 +689,26 @@ QString PluginManager::popupMinHeightMsg() const
685689

686690
return toJson(obj);
687691
}
692+
693+
void PluginManager::setupMouseFocusListener()
694+
{
695+
QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
696+
if (!compositor)
697+
return;
698+
699+
QWaylandSeat *seat = compositor->defaultSeat();
700+
if (!seat)
701+
return;
702+
703+
QObject::connect(seat, &QWaylandSeat::mouseFocusChanged, this,
704+
[seat](QWaylandView *newFocus, QWaylandView *oldFocus) {
705+
Q_UNUSED(oldFocus);
706+
if(!newFocus)
707+
return;
708+
709+
if (auto surface = newFocus->surface()) {
710+
qDebug()<<"setKeyboardFocus";
711+
seat->setKeyboardFocus(surface);
712+
}
713+
});
714+
}

panels/dock/pluginmanagerextension_p.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <QtWaylandCompositor/QWaylandCompositor>
1010
#include <QtWaylandCompositor/QWaylandSurface>
1111
#include <QtWaylandCompositor/QWaylandResource>
12+
#include <QtWaylandCompositor/QWaylandSeat>
13+
1214
#include <cstdint>
1315

1416
#include "qwayland-server-fractional-scale-v1.h"
@@ -76,6 +78,9 @@ class PluginManager : public QWaylandCompositorExtensionTemplate<PluginManager>,
7678

7779
void removePluginSurface(PluginSurface *plugin);
7880

81+
//处理鼠标焦点给到相应插件
82+
void setupMouseFocusListener();
83+
7984
Q_SIGNALS:
8085
void pluginPopupCreated(PluginPopup*);
8186
void pluginCloseQuickPanelPopup();

0 commit comments

Comments
 (0)