From d3331eed9c30f1f328dc2dccd522050df9abaa15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Wed, 2 Nov 2011 23:05:03 +0100 Subject: [PATCH] export the baseincrement size to the effectwindow and utilize it in the windowgeometry effect BUG: 283518 REVIEW: 103033 FIXED-IN: 4.8 --- client.h | 1 + effects.cpp | 6 ++++++ effects.h | 1 + effects/windowgeometry/windowgeometry.cpp | 4 +++- geometry.cpp | 5 +++++ libkwineffects/kwineffects.h | 7 ++++++- 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/client.h b/client.h index 8f5dfd0989..1b914aaea1 100644 --- a/client.h +++ b/client.h @@ -133,6 +133,7 @@ public: QSize minSize() const; QSize maxSize() const; + QSize basicUnit() const; virtual QPoint clientPos() const; // Inside of geometry() virtual QSize clientSize() const; virtual QRect visibleRect() const; diff --git a/effects.cpp b/effects.cpp index 4f8116af3c..c77c0e4793 100644 --- a/effects.cpp +++ b/effects.cpp @@ -1443,6 +1443,12 @@ int EffectWindowImpl::height() const return toplevel->height(); } +QSize EffectWindowImpl::basicUnit() const +{ + Client *client = dynamic_cast(toplevel); + return client ? client->basicUnit() : QSize(1,1); +} + QRect EffectWindowImpl::geometry() const { return toplevel->geometry(); diff --git a/effects.h b/effects.h index fc0c34dadc..08a3996e83 100644 --- a/effects.h +++ b/effects.h @@ -253,6 +253,7 @@ public: virtual int y() const; virtual int width() const; virtual int height() const; + virtual QSize basicUnit() const; virtual QRect geometry() const; virtual QRegion shape() const; virtual int screen() const; diff --git a/effects/windowgeometry/windowgeometry.cpp b/effects/windowgeometry/windowgeometry.cpp index 6d772af00d..2deaf637f2 100644 --- a/effects/windowgeometry/windowgeometry.cpp +++ b/effects/windowgeometry/windowgeometry.cpp @@ -157,7 +157,9 @@ void WindowGeometry::slotWindowStepUserMovedResized(EffectWindow *w, const QRect dx = r.width() - r2.width(); dy = r.height() - r2.height(); - myMeasure[1]->setText( i18nc(myResizeString, r.width(), r.height(), number(dx), number(dy) ) ); + const QSize baseInc = w->basicUnit(); + Q_ASSERT(baseInc.width() && baseInc.height()); + myMeasure[1]->setText( i18nc(myResizeString, r.width()/baseInc.width(), r.height()/baseInc.height(), number(dx/baseInc.width()), number(dy/baseInc.height()) ) ); // calc width for bottomright element, superfluous otherwise dx = r.right() - r2.right(); diff --git a/geometry.cpp b/geometry.cpp index 71335aef8b..528a0d852c 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1524,6 +1524,11 @@ QSize Client::maxSize() const return rules()->checkMaxSize(QSize(xSizeHint.max_width, xSizeHint.max_height)); } +QSize Client::basicUnit() const +{ + return QSize(xSizeHint.width_inc, xSizeHint.height_inc); +} + /*! Auxiliary function to inform the client about the current window configuration. diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 6ae0a6d145..780cc8906f 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -167,7 +167,7 @@ X-KDE-Library=kwin4_effect_cooleffect #define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor )) #define KWIN_EFFECT_API_VERSION_MAJOR 0 -#define KWIN_EFFECT_API_VERSION_MINOR 181 +#define KWIN_EFFECT_API_VERSION_MINOR 182 #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) @@ -1101,6 +1101,11 @@ public: virtual int y() const = 0; virtual int width() const = 0; virtual int height() const = 0; + /** + * By how much the window wishes to grow/shrink at least. Usually QSize(1,1). + * MAY BE DISOBEYED BY THE WM! It's only for information, do NOT rely on it at all. + */ + virtual QSize basicUnit() const = 0; virtual QRect geometry() const = 0; virtual QRegion shape() const = 0; virtual int screen() const = 0;