[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: [PATCH] Make kslideshow.kss xinerama aware
From: Arno <arno () disconnect ! de>
Date: 2007-07-28 10:28:48
Message-ID: 200707281228.49042.arno () disconnect ! de
[Download RAW message or body]
Hello,
When used with multiple screens (Xinerama) kslideshow.kss paints right in the
middle of the xinerama screen, between two monitors. This patch fixes this
behavior. It paints a different picture on each screen.
The patch is against kde-3.5.7. slideshow.(cpp|h) are in the kdeartwork
package (kscreensaver/kdesavers).
From a quick glance the patch should also appy to trunk. I haven't tested it
since I don't have a working env for kde4 development. It breaks portability
though, because it calls X11-specific functions.
--
Regards,
Arno.
["slideshow.h.patch" (text/x-diff)]
--- slideshow.h.old 2007-07-28 11:48:24.854947743 +0200
+++ slideshow.h 2007-07-28 11:29:14.659085750 +0200
@@ -85,6 +85,14 @@
void startPainter(Qt::PenStyle penStyle=NoPen);
protected:
+ struct mScreenGeo {
+ mScreenGeo(int w, int h, int x, int y) : mW(w), mH(h), mXorg(x), mYorg(y) {};
+ int mW;
+ int mH;
+ int mXorg;
+ int mYorg;
+ };
+ QPtrList<mScreenGeo> mGeoList;
bool mEffectRunning;
QTimer mTimer;
int mColorContext;
["slideshow.cpp.patch" (text/x-diff)]
--- slideshow.cpp.old 2007-07-28 11:48:14.290617982 +0200
+++ slideshow.cpp 2007-07-28 12:13:49.382390706 +0200
@@ -34,6 +34,8 @@
#include <kaboutapplication.h>
#include <kdebug.h>
+#include <X11/extensions/Xinerama.h>
+
#include <stdlib.h>
#include <assert.h>
#include <math.h>
@@ -94,11 +96,26 @@
mColorContext = QColor::enterAllocContext();
mEffectRunning = false;
- loadNextImage();
- createNextScreen();
mTimer.start(10, true);
connect(&mTimer, SIGNAL(timeout()), SLOT(slotTimeout()));
+
+ Display *dPtr = QPaintDevice::x11AppDisplay();
+ mGeoList.setAutoDelete(true);
+ if(XineramaIsActive(dPtr))
+ {
+ int numScreens = 0;
+ XineramaScreenInfo *scrInfo = XineramaQueryScreens(dPtr, &numScreens);
+ for(int i = 0; i < numScreens; ++i)
+ {
+ mGeoList.append(new mScreenGeo(scrInfo[i].width, scrInfo[i].height, \
scrInfo[i].x_org, scrInfo[i].y_org)); + }
+ }
+ else
+ {
+ mGeoList.append(new mScreenGeo(mNextScreen.width(), mNextScreen.height(), 0, \
0)); + }
+ createNextScreen();
}
@@ -724,12 +741,17 @@
mNextScreen.fill(black);
- ww = mNextScreen.width();
- wh = mNextScreen.height();
+ p.begin(&mNextScreen);
+
+ mScreenGeo *geoptr = 0;
+ for(geoptr = mGeoList.first(); geoptr; geoptr = mGeoList.next())
+ {
+ loadNextImage();
+
iw = mImage.width();
ih = mImage.height();
-
- p.begin(&mNextScreen);
+ ww = geoptr->mW;
+ wh = geoptr->mH;
if (mFileList.isEmpty())
{
@@ -749,8 +771,8 @@
ih = (int)(ih * fx);
QImage scaledImg = mImage.smoothScale(iw, ih);
- x = (ww - iw) >> 1;
- y = (wh - ih) >> 1;
+ x = ((ww - iw) >> 1) + geoptr->mXorg;
+ y = ((wh - ih) >> 1) + geoptr->mYorg;
p.drawImage(x, y, scaledImg);
}
@@ -766,8 +788,8 @@
ih = (int)(ih * fx);
QImage scaledImg = mImage.smoothScale(iw, ih);
- x = (ww - iw) >> 1;
- y = (wh - ih) >> 1;
+ x = ((ww - iw) >> 1) + geoptr->mXorg;
+ y = ((wh - ih) >> 1) + geoptr->mYorg;
p.drawImage(x, y, scaledImg);
}
@@ -775,13 +797,13 @@
{
if(mRandomPosition)
{
- x = rand() % (ww - iw);
- y = rand() % (wh - ih);
+ x = (rand() % (ww - iw)) + geoptr->mXorg;
+ y = (rand() % (wh - ih)) + geoptr->mYorg;
}
else
{
- x = (ww - iw) >> 1;
- y = (wh - ih) >> 1;
+ x = ((ww - iw) >> 1) + geoptr->mXorg;
+ y = ((wh - ih) >> 1) + geoptr->mYorg;
}
// bitBlt(&mNextScreen, x, y, &mImage, 0, 0, iw, ih, CopyROP, false);
@@ -794,12 +816,12 @@
p.setPen(QColor("black"));
for (x=9; x<=11; x++)
for (y=21; y>=19; y--)
- p.drawText(x, wh-y, mImageName);
+ p.drawText(x + geoptr->mXorg, wh-y+geoptr->mYorg, mImageName);
p.setPen(QColor("white"));
- p.drawText(10, wh-20, mImageName);
+ p.drawText(10 + geoptr->mXorg, wh-20 + geoptr->mYorg, mImageName);
+ }
}
}
-
p.end();
}
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic