Implement set_frost in contrast protocol

This commit is contained in:
Jan Blackquill 2021-07-05 21:34:06 -04:00
parent e31d10c18d
commit c2680d7108
2 changed files with 29 additions and 1 deletions

View file

@ -13,7 +13,7 @@
namespace KWaylandServer
{
static const quint32 s_version = 1;
static const quint32 s_version = 2;
class ContrastManagerInterfacePrivate : public QtWaylandServer::org_kde_kwin_contrast_manager
{
@ -96,6 +96,8 @@ public:
qreal currentIntensity;
qreal pendingSaturation;
qreal currentSaturation;
QColor currentFrost;
QColor pendingFrost;
ContrastInterface *q;
protected:
@ -104,6 +106,8 @@ protected:
void org_kde_kwin_contrast_set_contrast(Resource *resource, wl_fixed_t contrast) override;
void org_kde_kwin_contrast_set_intensity(Resource *resource, wl_fixed_t intensity) override;
void org_kde_kwin_contrast_set_saturation(Resource *resource, wl_fixed_t saturation) override;
void org_kde_kwin_contrast_set_frost(Resource *resource, int r, int g, int b, int a) override;
void org_kde_kwin_contrast_unset_frost(Resource *resource) override;
void org_kde_kwin_contrast_release(Resource *resource) override;
void org_kde_kwin_contrast_destroy_resource(Resource *resource) override;
};
@ -115,6 +119,7 @@ void ContrastInterfacePrivate::org_kde_kwin_contrast_commit(Resource *resource)
currentContrast = pendingContrast;
currentIntensity = pendingIntensity;
currentSaturation = pendingSaturation;
currentFrost = pendingFrost;
}
void ContrastInterfacePrivate::org_kde_kwin_contrast_set_region(Resource *resource, wl_resource *region)
@ -146,6 +151,20 @@ void ContrastInterfacePrivate::org_kde_kwin_contrast_set_saturation(Resource *re
pendingSaturation = wl_fixed_to_double(saturation);
}
void ContrastInterfacePrivate::org_kde_kwin_contrast_set_frost(Resource *resource, int r, int g, int b, int a)
{
Q_UNUSED(resource)
pendingFrost = QColor(r, g, b, a);
}
void ContrastInterfacePrivate::org_kde_kwin_contrast_unset_frost(Resource *resource)
{
Q_UNUSED(resource)
pendingFrost = {};
}
void ContrastInterfacePrivate::org_kde_kwin_contrast_release(Resource *resource)
{
wl_resource_destroy(resource->handle);
@ -191,4 +210,9 @@ qreal ContrastInterface::saturation() const
return d->currentSaturation;
}
QColor ContrastInterface::frost() const
{
return d->currentFrost;
}
}

View file

@ -6,6 +6,9 @@
*/
#pragma once
#include <optional>
#include <QColor>
#include <QObject>
#include <KWaylandServer/kwaylandserver_export.h>
@ -62,6 +65,7 @@ public:
qreal contrast() const;
qreal intensity() const;
qreal saturation() const;
QColor frost() const;
private:
explicit ContrastInterface(wl_resource *resource);