moving wallpaper

Aaron J. Seigo aseigo at kde.org
Sat Jan 23 22:45:59 CET 2010


On January 23, 2010, andreas wrote:
> So what i did is simple. I took a still image, made it seamless and doubled
> its height. Than i needed only 20 lines of code to make it slowly move from
> top to bottom of my desktop.

nice :)

> I created a timer with 10 ticks per second and
> called a repaint when it hit to show the wallpaper with an offset that is
> simply controlled by the timer.
> 
> It is simple and beautiful and adds allot to the desktop experience.
> 
> But i have questions about it :
> 
> - is there anything like that already done or planned

there are a few animated wallpapers. personally, i have thought about creating 
a javascript driven wallpaper plugin that would let you choose an svg and 
control the elements in them using simple javascript. so, for instance, you 
might do:

=====

var pos = rect().topLeft()
var delta = 1;
function move()
{
    pos.moveBy(delta, delta)
    if (!wallpaper.rect().contains(pos)) {
        delta = delta * -1
        pos.move(delta * 2, delta *2)
    }

    element.move(pos)
}

var svg = wallpaper.load("mysvg") // an svg from the package
var svgElement = svg.element("someSvgElementId")
var element = wallpaper.addImage(animatedElement)
wallpaper.setBackground(wallpaper.defaultImage())

var timer = new QTimer
timer.duration = 100
timer.timeout.connect(move)
timer.start()

=====

something like that, anyways... i really haven't though much about the API in 
detail. but such a system would give us a generic way to quickly create neat 
little dynamic wallpapers.

including callbacks for mouse interaction (press, release, etc) and including 
bindings for things such as date and time, data engine and kinetic it would 
make this all very easy. we could even provide a standard "select the base 
image" config UI, perhaps.

> - is there a better way to implement it, with less resource usage
>   i have the proprietary amd driver installed on a 3 GHZ quadcore pc and it
> uses 20% cpu

if you are calling update(boundingRect()) then that wouldn't be much of a 
surprise, really, as it would be repainting the entire screen 10 time per 
second. since it's only 20 lines of code, perhaps you could include it as an 
attachment for us to look at?

> - how can i get access to a wallpaper selected in the systemsetting-
> 
> >selectWallpaper dialog
> 
> for now i am using an absolute path to the image
> 
> - how can i add options in systemsettings when my wallpaper-plugin is
> selected to control the animation-speed for instance

these two have the same answer, actually: implement 
createConfigurationInterface(QWidget* parent) in your wallpaper plugin. use 
parent as the parent widget for your configuration interface. unfortunately 
right now we don't offer a stock widget for selecting image files on disk, so 
the various wallpaper plugins tend to duplicate that code. we should probably 
address this in future :)

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Development Frameworks


More information about the Plasma-devel mailing list