You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <effect/offscreeneffect.h>
|
|
|
|
#include <QSet>
|
|
|
|
#include <memory>
|
|
|
|
namespace KWin
|
|
{
|
|
class GLShader;
|
|
}
|
|
|
|
/**
|
|
* Rounds the corners of ordinary windows.
|
|
*
|
|
* The window is redirected into an offscreen texture, which is then painted with
|
|
* a shader that masks out the four corners with a rounded rectangle. The offscreen
|
|
* texture always has an alpha channel, so windows that do not have one themselves
|
|
* can be given a rounded shape as well.
|
|
*/
|
|
class RoundedWindow : public KWin::OffscreenEffect
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
RoundedWindow();
|
|
~RoundedWindow() override;
|
|
|
|
static bool supported();
|
|
static bool enabledByDefault();
|
|
|
|
int requestedEffectChainPosition() const override { return 99; }
|
|
|
|
void prePaintWindow(KWin::EffectWindow *window,
|
|
KWin::WindowPrePaintData &data,
|
|
std::chrono::milliseconds presentTime) override;
|
|
|
|
void drawWindow(const KWin::RenderTarget &renderTarget,
|
|
const KWin::RenderViewport &viewport,
|
|
KWin::EffectWindow *window,
|
|
int mask,
|
|
const QRegion ®ion,
|
|
KWin::WindowPaintData &data) override;
|
|
|
|
private:
|
|
bool shouldRound(KWin::EffectWindow *window) const;
|
|
bool isMaximized(KWin::EffectWindow *window) const;
|
|
KWin::GLShader *shader();
|
|
|
|
std::unique_ptr<KWin::GLShader> m_shader;
|
|
QSet<KWin::EffectWindow *> m_roundedWindows;
|
|
QSet<KWin::EffectWindow *> m_closingWindows;
|
|
QSet<KWin::EffectWindow *> m_maximizingWindows;
|
|
QSet<KWin::EffectWindow *> m_restoringWindows;
|
|
qreal m_frameRadius = 14;
|
|
};
|