Add request to have focus in a PlasmaShellSurface of Role Panel
Summary: By default a panel does not take focus. But there are panels which should get keyboard focus. Examples in a Plasma session are the widget explorer. This change adds a new request to PlasmaShell interface to specify whether a panel should get focus. The compositor can use this request to decide whether to pass focus to a panel. Reviewers: #plasma_on_wayland Subscribers: plasma-devel Tags: #plasma_on_wayland Differential Revision: https://phabricator.kde.org/D3035
This commit is contained in:
parent
c291752819
commit
41d07de410
3 changed files with 51 additions and 1 deletions
|
@ -50,6 +50,7 @@ private Q_SLOTS:
|
|||
void testPanelBehavior_data();
|
||||
void testPanelBehavior();
|
||||
void testAutoHidePanel();
|
||||
void testPanelTakesFocus();
|
||||
void testDisconnect();
|
||||
void testWhileDestroying();
|
||||
|
||||
|
@ -396,6 +397,29 @@ void TestPlasmaShell::testAutoHidePanel()
|
|||
QVERIFY(errorSpy.wait());
|
||||
}
|
||||
|
||||
void TestPlasmaShell::testPanelTakesFocus()
|
||||
{
|
||||
// this test verifies that whether a panel wants to take focus is passed through correctly
|
||||
QSignalSpy plasmaSurfaceCreatedSpy(m_plasmaShellInterface, &PlasmaShellInterface::surfaceCreated);
|
||||
QVERIFY(plasmaSurfaceCreatedSpy.isValid());
|
||||
QScopedPointer<Surface> s(m_compositor->createSurface());
|
||||
QScopedPointer<PlasmaShellSurface> ps(m_plasmaShell->createSurface(s.data()));
|
||||
ps->setRole(PlasmaShellSurface::Role::Panel);
|
||||
QVERIFY(plasmaSurfaceCreatedSpy.wait());
|
||||
QCOMPARE(plasmaSurfaceCreatedSpy.count(), 1);
|
||||
auto sps = plasmaSurfaceCreatedSpy.first().first().value<PlasmaShellSurfaceInterface*>();
|
||||
QVERIFY(sps);
|
||||
QCOMPARE(sps->role(), PlasmaShellSurfaceInterface::Role::Panel);
|
||||
QCOMPARE(sps->panelTakesFocus(), false);
|
||||
|
||||
ps->setPanelTakesFocus(true);
|
||||
m_connection->flush();
|
||||
QTRY_COMPARE(sps->panelTakesFocus(), true);
|
||||
ps->setPanelTakesFocus(false);
|
||||
m_connection->flush();
|
||||
QTRY_COMPARE(sps->panelTakesFocus(), false);
|
||||
}
|
||||
|
||||
void TestPlasmaShell::testDisconnect()
|
||||
{
|
||||
// this test verifies that a disconnect cleans up
|
||||
|
|
|
@ -76,6 +76,7 @@ public:
|
|||
bool m_positionSet = false;
|
||||
PanelBehavior m_panelBehavior = PanelBehavior::AlwaysVisible;
|
||||
bool m_skipTaskbar = false;
|
||||
bool panelTakesFocus = false;
|
||||
|
||||
private:
|
||||
// interface callbacks
|
||||
|
@ -86,6 +87,7 @@ private:
|
|||
static void setSkipTaskbarCallback(wl_client *client, wl_resource *resource, uint32_t skip);
|
||||
static void panelAutoHideHideCallback(wl_client *client, wl_resource *resource);
|
||||
static void panelAutoHideShowCallback(wl_client *client, wl_resource *resource);
|
||||
static void panelTakesFocusCallback(wl_client *client, wl_resource *resource, uint32_t takesFocus);
|
||||
|
||||
void setPosition(const QPoint &globalPos);
|
||||
void setRole(uint32_t role);
|
||||
|
@ -162,7 +164,8 @@ const struct org_kde_plasma_surface_interface PlasmaShellSurfaceInterface::Priva
|
|||
setPanelBehaviorCallback,
|
||||
setSkipTaskbarCallback,
|
||||
panelAutoHideHideCallback,
|
||||
panelAutoHideShowCallback
|
||||
panelAutoHideShowCallback,
|
||||
panelTakesFocusCallback
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -296,6 +299,13 @@ void PlasmaShellSurfaceInterface::Private::panelAutoHideShowCallback(wl_client *
|
|||
emit s->q_func()->panelAutoHideShowRequested();
|
||||
}
|
||||
|
||||
void PlasmaShellSurfaceInterface::Private::panelTakesFocusCallback(wl_client *client, wl_resource *resource, uint32_t takesFocus)
|
||||
{
|
||||
auto s = cast<Private>(resource);
|
||||
Q_ASSERT(client == *s->client);
|
||||
s->panelTakesFocus = takesFocus;
|
||||
}
|
||||
|
||||
void PlasmaShellSurfaceInterface::Private::setPanelBehavior(org_kde_plasma_surface_panel_behavior behavior)
|
||||
{
|
||||
PanelBehavior newBehavior = PanelBehavior::AlwaysVisible;
|
||||
|
@ -369,6 +379,12 @@ void PlasmaShellSurfaceInterface::showAutoHidingPanel()
|
|||
org_kde_plasma_surface_send_auto_hidden_panel_shown(d->resource);
|
||||
}
|
||||
|
||||
bool PlasmaShellSurfaceInterface::panelTakesFocus() const
|
||||
{
|
||||
Q_D();
|
||||
return d->panelTakesFocus;
|
||||
}
|
||||
|
||||
PlasmaShellSurfaceInterface *PlasmaShellSurfaceInterface::get(wl_resource *native)
|
||||
{
|
||||
return Private::get<PlasmaShellSurfaceInterface>(native);
|
||||
|
|
|
@ -159,6 +159,16 @@ public:
|
|||
**/
|
||||
void showAutoHidingPanel();
|
||||
|
||||
/**
|
||||
* Whether a PlasmaShellSurfaceInterface with Role Panel wants to have focus.
|
||||
*
|
||||
* By default a Panel does not get focus, but the PlasmaShellSurfaceInterface can
|
||||
* request that it wants to have focus. The compositor can use this information to
|
||||
* pass focus to the panel.
|
||||
* @since 5.28
|
||||
**/
|
||||
bool panelTakesFocus() const;
|
||||
|
||||
/**
|
||||
* @returns The PlasmaShellSurfaceInterface for the @p native resource.
|
||||
* @since 5.5
|
||||
|
|
Loading…
Reference in a new issue