[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Transparency -- take 2
From:       Mosfet <mosfet () jorsm ! com>
Date:       1999-09-29 13:06:12
[Download RAW message or body]

On Wed, 29 Sep 1999, Geert Jansen wrote:
> Hi!
> 
> Maybe this is not the perfect timing with the CORBA thread going on but I'll
> try it anyways... Maybe this will give you a little diversion from all the
> heavy stuff :)
> 
> I want to implement pseudo transparency for KDE apps. I discussed this
> before on the list. The outcome was that real transparecy is not possible
> (QWidget::setMask is very slow with complex shapes and doesn't allow effects).
> 
> On the contrary, pseudo transparency is rather easy: do a 
> QWidget::setBackgroundPixmap() with a pixmap that contains the correct part 
> of the desktop background and you're there.
> 
> The part that is not obvious is how to get a background pixmap. The current
> solution is (used by konsole) to read the desktop configfile and render a
> pixmap on your own. 
> 
> I don't like this way. A better way (IMO) would be: kdesktop renders the
> backgroup (like it is doing now). It writes it to the root window's
> background and keeps it. It then publishes the pixmap ID to a property on
> the root window. The clients read this property and do a XCopyArea() to a
> QPixmap's handle(). A special class ("KBackgroundPixmap") will be provided 
> for the latter.
> 

I like this too and considered it (sharing the Pixmap handles across
applications). The problem: When KDesktop crashes all psudeo-transparent apps
will crash. You will need to check before each access and do something else if
the "server" is gone.

I actually messed around with doing this for sharing the KThemeBase pixmap
cache - it would be really cool but not much has come from it yet, mostly
because of the above issue. Feel free to play around with it if you like, but
try to make it a generic pixmap sharing mechanism.

> Some advantages:
> * Reduced code duplication (kpager, konsole, kdesktop)
> * The possibility to use "background painting" programs with transparent
>   windows. Maybe we could include xglobe or xearth as a standard option in
>   kdmdisplay. Cool screenshots !
> * Easy "transparent" windows.
> 
> Disadvantages:
> * Not really. It is some work but I have some time.
> * Backward compatibility? I think I can safely say the current desktop 
>   configfiles are a mess and I'd like to clean this up. Maybe provide 
>   a perl script to do the conversion of the configfiles?
> * Memory requirements. We'll have N desktop sized pixmaps in the X server.
>   But a control will be provided to disable keeping. And also most people
>   have   their "Pixmap Cache" on maximum so it won't matter much in the
>   common case.
> 
> 
> At the end of this mail, I included some class prototypes of how I think 
> this problem should be tackled. I also commented on where I think they
> should go. Please comment!!
> 
> 
> BTW: If we decide we want to do this, I cannot garantee that it will be done
>      before the KRASH freeze. If not, we have to do this after KRASH.
> BTW2: Cristian: were you working on this too?
> 

I was ;-)

> Greetings,
> Geert
> ------ CUT ------
> 
> /**
>  * KDE dekstop background classes.
>  */
> 
> 
> /**
>  * One background pattern.
>  *
>  * Store in a private lib.
>  * Used by kcmdisplay and "class KBackgroundSettings"
>  */
> class KBackgroundPattern
> {
> public:
>     KBackgroundPattern(QString name);
> 
>     int setName(QString name);
>     QString name();
> 
>     int setPattern(int *pattern);
>     int *pattern();
> 
>     /** I/O from/to configfile (section [patterns] in desktoprc */
>     int readSettings();
>     int writeSettings();
> 
>     /** List available patterns */
>     static QStringList list();
> 
> private:
>     QString mName;
>     int mPattern[8];
> }
>     
> /**
>  * One background program.
>  *
>  * Store in a private lib.
>  * Used by kcmdisplay and "class KBackgroundSettings"
>  */
> class KBackgroundProgram
> {
> public:
>     KBackgroundProgram(QString name);
> 
>     void setName(QString name);
>     QString name();
> 
>     /** Something like: "program -resolution %r -file %f -options" */
>     void setProgram(QString program);
>     QString program();
> 
>     void setRefresh(int refresh);
>     int refresh();
> 
>     /** I/O from/to configfile (section [programs] in desktoprc) */
>     int readSettings();
>     int writeSettings();
> 
>     /** List available programs */
>     static QStringList list();
> 
> private:
>     QString mName, mProgram;
>     int refresh;
> };
> 
> 
> /**
>  * All desktop background setting for one desk.
>  *
>  * Store in a private lib.
>  * Used by kcmdisplay and "class KBackground"
>  */
> class KBackgroundSettings
> {
> public:
>     KBackgroundSettings(int desk);
> 
>     /** Desktop name */
>     void setName(QString name);
>     QString name();
> 
>     /** Color modes */
>     void setColor1(QColor &color);
>     QColor &color1();
>     void setColor2(QColor &color);
>     QColor &color2();
> 
>     enum KColorMode {
> 	HorizontalGradient, VerticalGradient, Pattern
>     };
>     void setColorMode(KColorMode mode);
>     KColorMode ColorMode();
> 
>     int setBackgroundPattern(QString name);
>     KBackgroundPattern *pattern();
> 
>     /** Wallpaper modes */
>     void setWallpaper(QString name);
>     QString wallpaper();
> 
>     enum KWallpaperMode {
> 	Tiled, Mirrored, CenterTiled, Centered, 
> 	CenteredMaxpect, SymmetricalTiled, 
> 	SymmetricalMirrored, Scaled
>     };
>     void setWallpaperMode(KWallpaperMode mode);
>     KWallpaperMode WallpaperMode();
> 
>     /** Program (xearth) modes */
>     void setProgram(QString name);
>     KBackgroundProgram *program();
> 
>     /** I/O from/to configfile (section [desktop%d] in desktoprc) */
>     int readSettings();
>     int writeSettings();
> 
> private:
>     QColor mColor1, mColor2;
>     KColorMode mColorMode;
>     QString mWallpaper;
>     KWallPaperMode mWallpaperMode;
>     KBackgroundPattern mPattern;
>     KBackgroundProgram mProgram;
> };
> 
> 
> /**
>  * KBackground: All desktop background settings plus render and publishing 
>  * funcionality.
>  *
>  * Store in a private lib.
>  * Used by kdesktop and kcmdisplay
>  */
> 
> class KBackground
> {
> public:
>     KBackground();
> 
>     /** Set common desktop, -1 for individual settings */
>     void setCommon(int common=-1);
> 
>     /** Active/max desktops */
>     setDesktop(int desk);
>     int desktop();
>     int numDesktops();
> 
>     /** Per desktop settings */
>     KBackgroundSettings *settings();
> 
>     /** Render a desktop (asynchronously). The size argument can be 
>       * used to generate a preview (kcmdisplay) */
>     int render(QSize size = QSize());
>     QPixmap data();
> 
>     /** Publish a handle() to the current pixmap as a
>       * property on the root window */
>     void publish();
> 
>     /** I/O from/to configfile:
>       * also calls KBackgroundSettings->writeSettings(); */
>     int readSettings();
>     int writeSettings();
> 
> signals:
>     void dataReady();
> 
> private:
>     QPixmap mPixmap[8];
>     KBackgroundSettings mSettings[8];
> }
>     
> 
> /**
>  * Use KBackgroundPixmap to get (a part of) the desktop background. 
>  * Uses the handle() published by KBackground::publish and XCopyArea().
>  *
>  * In kdecore ??
>  * Used by: konsole, kpager, every app that wants pseudo transparent
>  *          backgrounds. Use KPixmapEffect to apply effects.
>  */
> 
> class KBackgroundPixmap(): public QPixmap
> {
> public:
>     KBackgroundPixmap(QRect rect = QRect());
>     KBackgroundPixmap(QWidget w);
> 
> private:
>     QRect mRect();
> }
> 
> 
> 
> -- 
>     Geert Jansen                       email: <g.t.jansen at stud.tue.nl>
>     Phylosopher, Physicist                        PGP key ID: 0xD2B5E7CE
-- 
Daniel M. Duley - Unix developer & sys admin.
mosfet@mandrakesoft.com
mosfet@kde.org
mosfet@jorsm.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic