Commit 9177fd18 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

kwineffects: Make clientArea() return a QRectF

Make EffectsHandler::clientArea() return same type as
Workspace::clientArea().
parent 34344c8d
Pipeline #209825 failed with stage
in 23 minutes and 11 seconds
......@@ -1275,23 +1275,23 @@ static VirtualDesktop *resolveVirtualDesktop(int desktopId)
}
}
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectScreen *screen, int desktop) const
QRectF EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectScreen *screen, int desktop) const
{
const EffectScreenImpl *screenImpl = static_cast<const EffectScreenImpl *>(screen);
return Workspace::self()->clientArea(opt, screenImpl->platformOutput(), resolveVirtualDesktop(desktop)).toRect();
return Workspace::self()->clientArea(opt, screenImpl->platformOutput(), resolveVirtualDesktop(desktop));
}
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectWindow *effectWindow) const
QRectF EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectWindow *effectWindow) const
{
const Window *window = static_cast<const EffectWindowImpl *>(effectWindow)->window();
return Workspace::self()->clientArea(opt, window).toRect();
return Workspace::self()->clientArea(opt, window);
}
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const QPoint &p, int desktop) const
QRectF EffectsHandlerImpl::clientArea(clientAreaOption opt, const QPoint &p, int desktop) const
{
const Output *output = Workspace::self()->outputAt(p);
const VirtualDesktop *virtualDesktop = resolveVirtualDesktop(desktop);
return Workspace::self()->clientArea(opt, output, virtualDesktop).toRect();
return Workspace::self()->clientArea(opt, output, virtualDesktop);
}
QRect EffectsHandlerImpl::virtualScreenGeometry() const
......
......@@ -139,9 +139,9 @@ public:
void addRepaint(const QRegion &r) override;
void addRepaint(int x, int y, int w, int h) override;
EffectScreen *activeScreen() const override;
QRect clientArea(clientAreaOption, const EffectScreen *screen, int desktop) const override;
QRect clientArea(clientAreaOption, const EffectWindow *c) const override;
QRect clientArea(clientAreaOption, const QPoint &p, int desktop) const override;
QRectF clientArea(clientAreaOption, const EffectScreen *screen, int desktop) const override;
QRectF clientArea(clientAreaOption, const EffectWindow *c) const override;
QRectF clientArea(clientAreaOption, const QPoint &p, int desktop) const override;
QSize virtualScreenSize() const override;
QRect virtualScreenGeometry() const override;
double animationTimeFactor() const override;
......
......@@ -146,7 +146,7 @@ void MagicLampEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, Wi
if (panel) {
// Assumption: width of horizonal panel is greater than its height and vice versa
// The panel has to border one screen edge, so get it's screen area
QRect panelScreen = effects->clientArea(ScreenArea, panel);
QRectF panelScreen = effects->clientArea(ScreenArea, panel);
if (panel->width() >= panel->height()) {
// horizontal panel
if (panel->y() <= panelScreen.height() / 2) {
......@@ -164,9 +164,9 @@ void MagicLampEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, Wi
}
} else {
// we did not find a panel, so it might be autohidden
QRect iconScreen = effects->clientArea(ScreenArea, icon.topLeft(), effects->currentDesktop());
QRectF iconScreen = effects->clientArea(ScreenArea, icon.topLeft(), effects->currentDesktop());
// as the icon geometry could be overlap a screen edge we use an intersection
QRect rect = iconScreen.intersected(icon);
QRectF rect = iconScreen.intersected(icon);
// here we need a different assumption: icon geometry borders one screen edge
// this assumption might be wrong for e.g. task applet being the only applet in panel
// in this case the icon borders two screen edges
......
......@@ -14,22 +14,22 @@ ExpoArea::ExpoArea(QObject *parent)
{
}
int ExpoArea::x() const
qreal ExpoArea::x() const
{
return m_rect.x();
}
int ExpoArea::y() const
qreal ExpoArea::y() const
{
return m_rect.y();
}
int ExpoArea::width() const
qreal ExpoArea::width() const
{
return m_rect.width();
}
int ExpoArea::height() const
qreal ExpoArea::height() const
{
return m_rect.height();
}
......@@ -59,7 +59,7 @@ void ExpoArea::update()
if (!m_screen) {
return;
}
const QRect oldRect = m_rect;
const QRectF oldRect = m_rect;
m_rect = effects->clientArea(MaximizeArea, m_screen, effects->currentDesktop());
......
......@@ -15,10 +15,10 @@ class ExpoArea : public QObject
{
Q_OBJECT
Q_PROPERTY(KWin::EffectScreen *screen READ screen WRITE setScreen NOTIFY screenChanged)
Q_PROPERTY(int x READ x NOTIFY xChanged)
Q_PROPERTY(int y READ y NOTIFY yChanged)
Q_PROPERTY(int width READ width NOTIFY widthChanged)
Q_PROPERTY(int height READ height NOTIFY heightChanged)
Q_PROPERTY(qreal x READ x NOTIFY xChanged)
Q_PROPERTY(qreal y READ y NOTIFY yChanged)
Q_PROPERTY(qreal width READ width NOTIFY widthChanged)
Q_PROPERTY(qreal height READ height NOTIFY heightChanged)
public:
explicit ExpoArea(QObject *parent = nullptr);
......@@ -26,10 +26,10 @@ public:
EffectScreen *screen() const;
void setScreen(EffectScreen *screen);
int x() const;
int y() const;
int width() const;
int height() const;
qreal x() const;
qreal y() const;
qreal width() const;
qreal height() const;
Q_SIGNALS:
void screenChanged();
......@@ -41,7 +41,7 @@ Q_SIGNALS:
private:
void update();
QRect m_rect;
QRectF m_rect;
EffectScreen *m_screen = nullptr;
};
......
......@@ -32,20 +32,20 @@ static QRegion computeDirtyRegion(const QRectF &windowRect)
const QList<EffectScreen *> screens = effects->screens();
for (EffectScreen *screen : screens) {
const QRect screenRect = effects->clientArea(ScreenArea, screen, effects->currentDesktop());
const QRectF screenRect = effects->clientArea(ScreenArea, screen, effects->currentDesktop());
QRectF screenWindowRect = windowRect;
screenWindowRect.moveCenter(screenRect.center());
QRect verticalBarRect(0, 0, s_lineWidth, screenRect.height());
QRectF verticalBarRect(0, 0, s_lineWidth, screenRect.height());
verticalBarRect.moveCenter(screenRect.center());
verticalBarRect.adjust(-1, -1, 1, 1);
dirtyRegion += verticalBarRect;
dirtyRegion += verticalBarRect.toAlignedRect();
QRect horizontalBarRect(0, 0, screenRect.width(), s_lineWidth);
QRectF horizontalBarRect(0, 0, screenRect.width(), s_lineWidth);
horizontalBarRect.moveCenter(screenRect.center());
horizontalBarRect.adjust(-1, -1, 1, 1);
dirtyRegion += horizontalBarRect;
dirtyRegion += horizontalBarRect.toAlignedRect();
const QRectF outlineOuterRect = screenWindowRect
.marginsAdded(outlineMargins)
......@@ -117,7 +117,7 @@ void SnapHelperEffect::paintScreen(int mask, const QRegion &region, ScreenPaintD
QVector<float> verts;
verts.reserve(screens.count() * 24);
for (EffectScreen *screen : screens) {
const QRect rect = effects->clientArea(ScreenArea, screen, effects->currentDesktop());
const QRectF rect = effects->clientArea(ScreenArea, screen, effects->currentDesktop());
const int midX = rect.x() + rect.width() / 2;
const int midY = rect.y() + rect.height() / 2;
const int halfWidth = m_geometry.width() / 2;
......@@ -163,13 +163,13 @@ void SnapHelperEffect::paintScreen(int mask, const QRegion &region, ScreenPaintD
painter->setBrush(Qt::NoBrush);
for (EffectScreen *screen : screens) {
const QRect rect = effects->clientArea(ScreenArea, screen, effects->currentDesktop());
const QRectF rect = effects->clientArea(ScreenArea, screen, effects->currentDesktop());
// Center lines.
painter->drawLine(rect.center().x(), rect.y(), rect.center().x(), rect.y() + rect.height());
painter->drawLine(rect.x(), rect.center().y(), rect.x() + rect.width(), rect.center().y());
// Window outline.
QRect outlineRect(0, 0, m_geometry.width(), m_geometry.height());
QRectF outlineRect(0, 0, m_geometry.width(), m_geometry.height());
outlineRect.moveCenter(rect.center());
painter->drawRect(outlineRect);
}
......
......@@ -159,7 +159,7 @@ void ThumbnailAsideEffect::arrange()
if (!effectiveScreen) {
effectiveScreen = effects->activeScreen();
}
QRect area = effects->clientArea(MaximizeArea, effectiveScreen, effects->currentDesktop());
QRectF area = effects->clientArea(MaximizeArea, effectiveScreen, effects->currentDesktop());
double scale = area.height() / double(height);
scale = qMin(scale, maxwidth / double(mwidth)); // don't be wider than maxwidth pixels
int add = 0;
......
......@@ -446,7 +446,7 @@ void WobblyWindowsEffect::stepMovedResized(EffectWindow *w)
WindowWobblyInfos &wwi = windows[w];
wwi.status = Free;
QRect maximized_area = effects->clientArea(MaximizeArea, w);
QRectF maximized_area = effects->clientArea(MaximizeArea, w);
bool throb_direction_out = (new_geometry.top() == maximized_area.top() && new_geometry.bottom() == maximized_area.bottom()) || (new_geometry.left() == maximized_area.left() && new_geometry.right() == maximized_area.right());
qreal magnitude = throb_direction_out ? 10 : -30; // a small throb out when maximized, a larger throb inwards when restored
for (unsigned int j = 0; j < wwi.height; ++j) {
......
......@@ -89,7 +89,7 @@ void AnimationEffect::validate(Attribute a, uint &meta, FPx2 *from, FPx2 *to, co
{
if (a < NonFloatBase) {
if (a == Scale) {
QRect area = effects->clientArea(ScreenArea, w);
QRectF area = effects->clientArea(ScreenArea, w);
if (from && from->isValid()) {
RELATIVE_XY(Source);
from->set(relative[0] ? (*from)[0] * area.width() / w->width() : (*from)[0],
......@@ -143,7 +143,7 @@ void AnimationEffect::validate(Attribute a, uint &meta, FPx2 *from, FPx2 *to, co
}
} else if (a == Size) {
QRect area = effects->clientArea(ScreenArea, w);
QRectF area = effects->clientArea(ScreenArea, w);
if (from) {
if (from->isValid()) {
RELATIVE_XY(Source);
......
......@@ -1069,9 +1069,9 @@ public:
virtual bool optionRollOverDesktops() const = 0;
virtual EffectScreen *activeScreen() const = 0; // Xinerama
virtual QRect clientArea(clientAreaOption, const EffectScreen *screen, int desktop) const = 0;
virtual QRect clientArea(clientAreaOption, const EffectWindow *c) const = 0;
virtual QRect clientArea(clientAreaOption, const QPoint &p, int desktop) const = 0;
virtual QRectF clientArea(clientAreaOption, const EffectScreen *screen, int desktop) const = 0;
virtual QRectF clientArea(clientAreaOption, const EffectWindow *c) const = 0;
virtual QRectF clientArea(clientAreaOption, const QPoint &p, int desktop) const = 0;
/**
* The bounding size of all screens combined. Overlapping areas
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment