Smarter desktop applet placement

Ambroz Bizjak ambro at b4ever.net
Thu Aug 14 00:11:54 CEST 2008


Ok, I consider my patch feature-complete now. From now on, it works
properly with panels and positions proxy widgets properly as well.

To summarize what it provides:
- It keeps a working area, that is the area between panels, and only
allows applets to be in there (e.g. if a panel is added on top, applets
together with the working area are moved downwards).
- It places newly added items to an empty place in the working area (old
code).
- When the screen shrinks, it pushes applets that were left outside of the
working area (partially or fully) inside the screen. When pushing an
applet, items in its way are also pushed to make space. If the applet
already overlappes with other applets, the group of overlapping applets is
pushed together as one item. Failing to push the item inside the working
area, it is temporarily made visible somewhere else using the old
positioning algorithm. The applet is made visible at the original position
as soon as it gets back inside the working area.
- Inversely, when the screen expands, it pushes applets back towards their
preferred positions.

About proxy widgets: regular applets report a proper size in their
geometry() method when added, however they return useless size hints. On
the other hand, proxy applets do exactly the opposite.
Strangely, if I assign a new geometry (any) to a proxy applet, its
geometry actually gets updated with a good size. So, after calling:

applet->setGeometry(applet->geometry())

its size can be read with geometry() as for regular applets. I used that
in my code. Because I want to make the layout code as clean as possible, I
put the size reading to desktop.cpp, and added an option to the layout to
use a specific starting size (or default to PreferredSize hint).

Attached is patch for 4.1, for trunk, and the new demo app.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plasma-placement-layout8-kde4.1.patch.bz2
Type: application/octet-stream
Size: 7377 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20080814/8d1565d4/attachment-0003.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plasma-placement-layout8.patch.bz2
Type: application/octet-stream
Size: 8547 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20080814/8d1565d4/attachment-0004.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: desktop-layout-demo-0.3.tar.bz2
Type: application/octet-stream
Size: 7313 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20080814/8d1565d4/attachment-0005.obj 


More information about the Plasma-devel mailing list