Skip to content

Commit 2f72c9e

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 2f72c9e

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

panels/dock/pluginmanagerextension.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,14 @@ void PluginSurface::setGlobalPos(const QPoint &pos)
252252
send_raw_global_pos(p.x(), p.y());
253253
}
254254

255+
void PluginSurface::setKeyboardFocus()
256+
{
257+
QWaylandCompositor *compositor = surface()->compositor();
258+
if (QWaylandSeat *seat = compositor->defaultSeat()) {
259+
seat->setKeyboardFocus(surface());
260+
}
261+
}
262+
255263
void PluginSurface::plugin_source_size(Resource *resource, int32_t width, int32_t height)
256264
{
257265
Q_UNUSED(resource);

panels/dock/pluginmanagerextension_p.h

Lines changed: 4 additions & 1 deletion
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"
@@ -161,7 +163,8 @@ class PluginSurface : public QWaylandShellSurfaceTemplate<PluginSurface>, public
161163

162164
Q_INVOKABLE void updatePluginGeometry(const QRect &geometry);
163165
Q_INVOKABLE void setGlobalPos(const QPoint &pos);
164-
166+
Q_INVOKABLE void setKeyboardFocus();
167+
165168
int margins() const;
166169
void setMargins(int newMargins);
167170

panels/dock/tray/ShellSurfaceItemProxy.qml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ Item {
3838

3939
HoverHandler {
4040
id: hoverHandler
41+
onHoveredChanged: {
42+
if (hovered && root.shellSurface) {
43+
console.log("Calling setKeyboardFocus on shellSurface")
44+
shellSurface.setKeyboardFocus()
45+
}
46+
}
4147
}
4248
TapHandler {
4349
id: tapHandler

0 commit comments

Comments
 (0)