Add "SkipSwitcher" to API

Summary:
Adding "SkipSwitcher" to API, as a result of discussion in
BUG 375921

Depends on / related to D11924 and D11926.

Reviewers: hein, graesslin

Reviewed By: graesslin

Subscribers: kde-frameworks-devel, lbeltrame, rikmills, davidedmundson, #plasma, graesslin

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D11925
This commit is contained in:
Scott Harvey 2018-05-22 07:11:22 -05:00
parent 73cac6211b
commit 7d3deb7e68
8 changed files with 96 additions and 4 deletions

View file

@ -70,6 +70,7 @@ private Q_SLOTS:
void testIsOnAllDesktops();
void testIsDemandingAttention();
void testSkipTaskbar();
void testSkipSwitcher();
void testIsShadeable();
void testIsShaded();
void testIsMovable();
@ -235,6 +236,7 @@ void PlasmaWindowModelTest::testRoleNames_data()
QTest::newRow("IsOnAllDesktops") << int(PlasmaWindowModel::IsOnAllDesktops) << QByteArrayLiteral("IsOnAllDesktops");
QTest::newRow("IsDemandingAttention") << int(PlasmaWindowModel::IsDemandingAttention) << QByteArrayLiteral("IsDemandingAttention");
QTest::newRow("SkipTaskbar") << int(PlasmaWindowModel::SkipTaskbar) << QByteArrayLiteral("SkipTaskbar");
QTest::newRow("SkipSwitcher") << int(PlasmaWindowModel::SkipSwitcher) << QByteArrayLiteral("SkipSwitcher");
QTest::newRow("IsShadeable") << int(PlasmaWindowModel::IsShadeable) << QByteArrayLiteral("IsShadeable");
QTest::newRow("IsShaded") << int(PlasmaWindowModel::IsShaded) << QByteArrayLiteral("IsShaded");
QTest::newRow("IsMovable") << int(PlasmaWindowModel::IsMovable) << QByteArrayLiteral("IsMovable");
@ -414,6 +416,11 @@ void PlasmaWindowModelTest::testSkipTaskbar()
QVERIFY(testBooleanData(PlasmaWindowModel::SkipTaskbar, &PlasmaWindowInterface::setSkipTaskbar));
}
void PlasmaWindowModelTest::testSkipSwitcher()
{
QVERIFY(testBooleanData(PlasmaWindowModel::SkipSwitcher, &PlasmaWindowInterface::setSkipSwitcher));
}
void PlasmaWindowModelTest::testIsShadeable()
{
QVERIFY(testBooleanData(PlasmaWindowModel::IsShadeable, &PlasmaWindowInterface::setShadeable));

View file

@ -47,6 +47,7 @@ private Q_SLOTS:
void testRole();
void testPosition();
void testSkipTaskbar();
void testSkipSwitcher();
void testPanelBehavior_data();
void testPanelBehavior();
void testAutoHidePanel();
@ -297,6 +298,41 @@ void TestPlasmaShell::testSkipTaskbar()
QVERIFY(!sps->skipTaskbar());
}
void TestPlasmaShell::testSkipSwitcher()
{
// this test verifies that Skip Switcher is properly passed to server
QSignalSpy plasmaSurfaceCreatedSpy(m_plasmaShellInterface, &PlasmaShellInterface::surfaceCreated);
QVERIFY(plasmaSurfaceCreatedSpy.isValid());
QScopedPointer<Surface> s(m_compositor->createSurface());
QScopedPointer<PlasmaShellSurface> ps(m_plasmaShell->createSurface(s.data()));
QVERIFY(plasmaSurfaceCreatedSpy.wait());
QCOMPARE(plasmaSurfaceCreatedSpy.count(), 1);
// verify that we got a plasma shell surface
auto sps = plasmaSurfaceCreatedSpy.first().first().value<PlasmaShellSurfaceInterface*>();
QVERIFY(sps);
QVERIFY(sps->surface());
QVERIFY(!sps->skipSwitcher());
// now change
QSignalSpy skipSwitcherChangedSpy(sps, &PlasmaShellSurfaceInterface::skipSwitcherChanged);
QVERIFY(skipSwitcherChangedSpy.isValid());
ps->setSkipSwitcher(true);
QVERIFY(skipSwitcherChangedSpy.wait());
QVERIFY(sps->skipSwitcher());
// setting to same again should not emit the signal
ps->setSkipSwitcher(true);
QEXPECT_FAIL("", "Should not be emitted if not changed", Continue);
QVERIFY(!skipSwitcherChangedSpy.wait(100));
QVERIFY(sps->skipSwitcher());
// setting to false should change again
ps->setSkipSwitcher(false);
QVERIFY(skipSwitcherChangedSpy.wait());
QVERIFY(!sps->skipSwitcher());
}
void TestPlasmaShell::testPanelBehavior_data()
{
QTest::addColumn<PlasmaShellSurface::PanelBehavior>("client");

View file

@ -407,6 +407,7 @@ void TestWindowManagement::testRequestsBoolean_data()
QTest::newRow("maximizable") << &PlasmaWindowInterface::maximizeableRequested << int(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MAXIMIZABLE);
QTest::newRow("fullscreenable") << &PlasmaWindowInterface::fullscreenableRequested << int(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_FULLSCREENABLE);
QTest::newRow("skiptaskbar") << &PlasmaWindowInterface::skipTaskbarRequested << int(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPTASKBAR);
QTest::newRow("skipSwitcher") << &PlasmaWindowInterface::skipSwitcherRequested << int(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPSWITCHER);
QTest::newRow("shadeable") << &PlasmaWindowInterface::shadeableRequested << int(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADEABLE);
QTest::newRow("shaded") << &PlasmaWindowInterface::shadedRequested << int(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADED);
QTest::newRow("movable") << &PlasmaWindowInterface::movableRequested << int(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_MOVABLE);

View file

@ -50,7 +50,7 @@ private:
static const quint32 s_version;
};
const quint32 PlasmaShellInterface::Private::s_version = 4;
const quint32 PlasmaShellInterface::Private::s_version = 5;
PlasmaShellInterface::Private::Private(PlasmaShellInterface *q, Display *d)
: Global::Private(d, &org_kde_plasma_shell_interface, s_version)
@ -76,6 +76,7 @@ public:
bool m_positionSet = false;
PanelBehavior m_panelBehavior = PanelBehavior::AlwaysVisible;
bool m_skipTaskbar = false;
bool m_skipSwitcher = false;
bool panelTakesFocus = false;
private:
@ -85,6 +86,7 @@ private:
static void setRoleCallback(wl_client *client, wl_resource *resource, uint32_t role);
static void setPanelBehaviorCallback(wl_client *client, wl_resource *resource, uint32_t flag);
static void setSkipTaskbarCallback(wl_client *client, wl_resource *resource, uint32_t skip);
static void setSkipSwitcherCallback(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);
@ -165,7 +167,8 @@ const struct org_kde_plasma_surface_interface PlasmaShellSurfaceInterface::Priva
setSkipTaskbarCallback,
panelAutoHideHideCallback,
panelAutoHideShowCallback,
panelTakesFocusCallback
panelTakesFocusCallback,
setSkipSwitcherCallback
};
#endif
@ -277,6 +280,14 @@ void PlasmaShellSurfaceInterface::Private::setSkipTaskbarCallback(wl_client *cli
emit s->q_func()->skipTaskbarChanged();
}
void PlasmaShellSurfaceInterface::Private::setSkipSwitcherCallback(wl_client *client, wl_resource *resource, uint32_t skip)
{
auto s = cast<Private>(resource);
Q_ASSERT(client == *s->client);
s->m_skipSwitcher = (bool)skip;
emit s->q_func()->skipSwitcherChanged();
}
void PlasmaShellSurfaceInterface::Private::panelAutoHideHideCallback(wl_client *client, wl_resource *resource)
{
auto s = cast<Private>(resource);
@ -361,6 +372,12 @@ bool PlasmaShellSurfaceInterface::skipTaskbar() const
return d->m_skipTaskbar;
}
bool PlasmaShellSurfaceInterface::skipSwitcher() const
{
Q_D();
return d->m_skipSwitcher;
}
void PlasmaShellSurfaceInterface::hideAutoHidingPanel()
{
Q_D();

View file

@ -135,9 +135,16 @@ public:
* @returns true if this window doesn't want to be listed
* in the taskbar
* @since 5.5
*/
**/
bool skipTaskbar() const;
/**
* @returns true if this window doesn't want to be listed
* in a window switcher
* @since 5.45
**/
bool skipSwitcher() const;
/**
* Informs the PlasmaShellSurfaceInterface that the auto-hiding panel got hidden.
* Once it is shown again the method {@link showAutoHidingPanel} should be used.
@ -192,6 +199,10 @@ Q_SIGNALS:
* A change in the skip taskbar property has been requested
*/
void skipTaskbarChanged();
/**
* A change in the skip switcher property has been requested
**/
void skipSwitcherChanged();
/**
* A surface with Role Panel and PanelBehavior AutoHide requested to be hidden.

View file

@ -119,7 +119,7 @@ private:
static const struct org_kde_plasma_window_interface s_interface;
};
const quint32 PlasmaWindowManagementInterface::Private::s_version = 7;
const quint32 PlasmaWindowManagementInterface::Private::s_version = 9;
PlasmaWindowManagementInterface::Private::Private(PlasmaWindowManagementInterface *q, Display *d)
: Global::Private(d, &org_kde_plasma_window_management_interface, s_version)
@ -602,6 +602,9 @@ void PlasmaWindowInterface::Private::setStateCallback(wl_client *client, wl_reso
if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPTASKBAR) {
emit p->q->skipTaskbarRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPTASKBAR);
}
if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPSWITCHER) {
emit p->q->skipSwitcherRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPSWITCHER);
}
if (flags & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADEABLE) {
emit p->q->shadeableRequested(state & ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SHADEABLE);
}
@ -761,6 +764,11 @@ void PlasmaWindowInterface::setSkipTaskbar(bool set)
d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPTASKBAR, set);
}
void PlasmaWindowInterface::setSkipSwitcher(bool skip)
{
d->setState(ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STATE_SKIPSWITCHER, skip);
}
#ifndef KWAYLANDSERVER_NO_DEPRECATED
void PlasmaWindowInterface::setThemedIconName(const QString &iconName)
{

View file

@ -108,6 +108,7 @@ public:
void setMaximizeable(bool set);
void setFullscreenable(bool set);
void setSkipTaskbar(bool skip);
void setSkipSwitcher(bool skip);
/**
* @deprecated since 5.28 use setIcon
* @see setIcon
@ -204,6 +205,7 @@ Q_SIGNALS:
void maximizeableRequested(bool set);
void fullscreenableRequested(bool set);
void skipTaskbarRequested(bool set);
void skipSwitcherRequested(bool set);
QRect minimizedGeometriesChanged();
/**
* @since 5.22

View file

@ -49,6 +49,10 @@ public:
m_skipTaskbar = set;
}
void setSkipSwitcher(bool set) {
m_skipSwitcher = set;
}
private:
void setupRegistry(Registry *registry);
void render();
@ -64,6 +68,7 @@ private:
PlasmaShellSurface *m_plasmaShellSurface = nullptr;
PlasmaShellSurface::Role m_role = PlasmaShellSurface::Role::Normal;
bool m_skipTaskbar = false;
bool m_skipSwitcher = false;
};
PlasmaSurfaceTest::PlasmaSurfaceTest(QObject *parent)
@ -136,6 +141,7 @@ void PlasmaSurfaceTest::setupRegistry(Registry *registry)
m_plasmaShellSurface = m_plasmaShell->createSurface(m_surface, this);
Q_ASSERT(m_plasmaShellSurface);
m_plasmaShellSurface->setSkipTaskbar(m_skipTaskbar);
m_plasmaShellSurface->setSkipSwitcher(m_skipSwitcher);
m_plasmaShellSurface->setRole(m_role);
render();
}
@ -177,6 +183,9 @@ int main(int argc, char **argv)
QCommandLineOption skipTaskbarOption(QStringLiteral("skipTaskbar"));
parser.addOption(skipTaskbarOption);
parser.process(app);
QCommandLineOption skipSwitcherOption(QStringLiteral("skipSwitcher"));
parser.addOption(skipSwitcherOption);
parser.process(app);
PlasmaSurfaceTest client;
@ -192,6 +201,7 @@ int main(int argc, char **argv)
client.setRole(PlasmaShellSurface::Role::ToolTip);
}
client.setSkipTaskbar(parser.isSet(skipTaskbarOption));
client.setSkipSwitcher(parser.isSet(skipSwitcherOption));
client.init();