Signed-off-by: rjb330 <122177540+rjb330@users.noreply.github.com>pull/11/head
parent
a5953b11fa
commit
ae5e4d76b1
@ -0,0 +1,137 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Sascha Hlusiak *
|
||||
* Spam84@gmx.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <tdeapplication.h>
|
||||
#include <tqimage.h>
|
||||
#include <kimageeffect.h>
|
||||
#include <tqdesktopwidget.h>
|
||||
#include "imageholder.h"
|
||||
|
||||
|
||||
QImageHolder::QImageHolder(TQImage act,TQImage inact)
|
||||
:img_active(NULL),img_inactive(NULL)
|
||||
{
|
||||
rootpixmap=NULL;
|
||||
setUserdefinedPictures( act,inact);
|
||||
initialized=userdefinedActive && userdefinedInactive;
|
||||
|
||||
emit repaintNeeded();
|
||||
}
|
||||
|
||||
QImageHolder::~QImageHolder()
|
||||
{
|
||||
if (rootpixmap)delete rootpixmap;
|
||||
if (img_active && !userdefinedActive)delete img_active;
|
||||
if (img_inactive && !userdefinedInactive)delete img_inactive;
|
||||
}
|
||||
|
||||
void QImageHolder::setUserdefinedPictures( TQImage act,TQImage inact)
|
||||
{
|
||||
int w=TQApplication::desktop()->width();
|
||||
int h=TQApplication::desktop()->height();
|
||||
if (img_active && !userdefinedActive)
|
||||
{
|
||||
delete img_active;
|
||||
img_active=NULL;
|
||||
}
|
||||
if (img_inactive && !userdefinedInactive)
|
||||
{
|
||||
delete img_inactive;
|
||||
img_inactive=NULL;
|
||||
}
|
||||
|
||||
if (!act.isNull())
|
||||
img_active=new TQPixmap(act);
|
||||
else
|
||||
img_active=NULL;
|
||||
if (!inact.isNull())
|
||||
img_inactive=new TQPixmap(inact);
|
||||
else
|
||||
img_inactive=NULL;
|
||||
|
||||
userdefinedActive=(img_active!=NULL);
|
||||
userdefinedInactive=(img_inactive!=NULL);
|
||||
|
||||
CheckSanity();
|
||||
}
|
||||
|
||||
void QImageHolder::Init()
|
||||
{
|
||||
if (initialized)return;
|
||||
|
||||
rootpixmap=new KMyRootPixmap(NULL/*,this*/);
|
||||
rootpixmap->start();
|
||||
rootpixmap->repaint(true);
|
||||
connect( rootpixmap,TQ_SIGNAL(backgroundUpdated(const TQImage*)),this, TQ_SLOT(BackgroundUpdated(const TQImage*)));
|
||||
connect(kapp, TQ_SIGNAL(backgroundChanged(int)),TQ_SLOT(handleDesktopChanged(int)));
|
||||
|
||||
initialized=true;
|
||||
}
|
||||
|
||||
void QImageHolder::repaint(bool force)
|
||||
{
|
||||
Init();
|
||||
if (rootpixmap)rootpixmap->repaint(force);
|
||||
}
|
||||
|
||||
void QImageHolder::handleDesktopChanged(int)
|
||||
{
|
||||
repaint(true);
|
||||
}
|
||||
|
||||
void QImageHolder::CheckSanity()
|
||||
{
|
||||
if (!initialized)return;
|
||||
if (userdefinedActive && userdefinedInactive)return;
|
||||
if (img_active!=NULL && !userdefinedActive)return;
|
||||
if (img_inactive!=NULL && !userdefinedInactive)return;
|
||||
|
||||
if (rootpixmap)delete rootpixmap;
|
||||
rootpixmap=NULL;
|
||||
|
||||
initialized=false;
|
||||
}
|
||||
|
||||
void QImageHolder::BackgroundUpdated(const TQImage *src)
|
||||
{
|
||||
if (img_active && !userdefinedActive)
|
||||
{
|
||||
delete img_active;
|
||||
img_active=NULL;
|
||||
}
|
||||
if (img_inactive && !userdefinedInactive)
|
||||
{
|
||||
delete img_inactive;
|
||||
img_inactive=NULL;
|
||||
}
|
||||
|
||||
if (src && !src->isNull())
|
||||
{
|
||||
if (!userdefinedInactive)
|
||||
img_inactive=new TQPixmap(src->copy());
|
||||
if (!userdefinedActive)
|
||||
img_active=new TQPixmap(src->copy());
|
||||
}
|
||||
|
||||
emit repaintNeeded();
|
||||
}
|
||||
|
||||
#include "imageholder.moc"
|
@ -0,0 +1,63 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Sascha Hlusiak *
|
||||
* Spam84@gmx.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef _IMAGEHOLDER_INCLUDED_
|
||||
#define _IMAGEHOLDER_INCLUDED_
|
||||
|
||||
|
||||
#include <twinmodule.h>
|
||||
#include "myrootpixmap.h"
|
||||
|
||||
struct WND_CONFIG;
|
||||
|
||||
class QImageHolder:public TQObject
|
||||
{
|
||||
TQ_OBJECT
|
||||
|
||||
public:
|
||||
QImageHolder(TQImage act,TQImage inact);
|
||||
virtual ~QImageHolder();
|
||||
|
||||
void Init();
|
||||
TQPixmap *image(bool active) { Init(); return active?img_active:img_inactive; }
|
||||
void repaint(bool force);
|
||||
|
||||
void setUserdefinedPictures(TQImage act,TQImage inact);
|
||||
|
||||
private:
|
||||
bool initialized;
|
||||
KMyRootPixmap *rootpixmap;
|
||||
TQPixmap *img_active,*img_inactive;
|
||||
bool userdefinedActive,userdefinedInactive;
|
||||
|
||||
TQPixmap* ApplyEffect(TQImage &src,WND_CONFIG* cfg,TQColorGroup colorgroup);
|
||||
|
||||
public slots:
|
||||
void BackgroundUpdated(const TQImage *);
|
||||
void handleDesktopChanged(int desk);
|
||||
void CheckSanity();
|
||||
|
||||
signals:
|
||||
void repaintNeeded();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,258 @@
|
||||
/*
|
||||
*
|
||||
* $Id: krootpixmap.cpp,v 1.20 2003/06/01 01:49:31 hadacek Exp $
|
||||
*
|
||||
* This file is part of the KDE project, module tdeui.
|
||||
* Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org>
|
||||
*
|
||||
* You can Freely distribute this program under the GNU Library
|
||||
* General Public License. See the file "COPYING.LIB" for the exact
|
||||
* licensing terms.
|
||||
*/
|
||||
|
||||
/* Modified by Sascha Hlusiak */
|
||||
/* Further modified 11/18/2014 by Timothy Pearson <kb9vqf@pearsoncomputing.net> */
|
||||
|
||||
#include <tqwidget.h>
|
||||
#include <tqtimer.h>
|
||||
#include <tqrect.h>
|
||||
#include <tqimage.h>
|
||||
|
||||
#ifndef TQ_WS_TQWS //FIXME
|
||||
#include <tdeapplication.h>
|
||||
#include <kimageeffect.h>
|
||||
#include <kpixmapio.h>
|
||||
#include <netwm.h>
|
||||
#include <twin.h>
|
||||
#include <kdebug.h>
|
||||
#include <netwm.h>
|
||||
#include <dcopclient.h>
|
||||
#include <dcopref.h>
|
||||
#include <tqpainter.h>
|
||||
|
||||
#include <ksharedpixmap.h>
|
||||
#include "myrootpixmap.h"
|
||||
|
||||
static TQString wallpaperForDesktop(int desktop)
|
||||
{
|
||||
return DCOPRef("kdesktop", "KBackgroundIface").call("currentWallpaper", desktop);
|
||||
}
|
||||
|
||||
DesktopWallpaperWatcher::DesktopWallpaperWatcher() : TQWidget(), m_old_current_desktop(-1)
|
||||
{
|
||||
kapp->installX11EventFilter( this );
|
||||
(void ) kapp->desktop(); //trigger desktop widget creation to select root window events
|
||||
}
|
||||
|
||||
DesktopWallpaperWatcher::~DesktopWallpaperWatcher()
|
||||
{
|
||||
}
|
||||
|
||||
bool DesktopWallpaperWatcher::x11Event( XEvent * ev )
|
||||
{
|
||||
if ( ev->xany.window == tqt_xrootwin() ) {
|
||||
NETRootInfo rinfo( tqt_xdisplay(), NET::CurrentDesktop );
|
||||
rinfo.activate();
|
||||
|
||||
if ( rinfo.currentDesktop() != m_old_current_desktop ) {
|
||||
emit currentDesktopChanged( rinfo.currentDesktop() );
|
||||
}
|
||||
|
||||
m_old_current_desktop = rinfo.currentDesktop();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
class KMyRootPixmapData
|
||||
{
|
||||
public:
|
||||
#ifdef TQ_WS_X11
|
||||
DesktopWallpaperWatcher *twin;
|
||||
#endif
|
||||
};
|
||||
|
||||
KMyRootPixmap::KMyRootPixmap( TQWidget * widget, const char *name )
|
||||
: TQObject(widget, name ? name : "KMyRootPixmap" )
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
KMyRootPixmap::KMyRootPixmap( TQWidget *, TQObject *parent, const char *name )
|
||||
: TQObject( parent, name ? name : "KMyRootPixmap" )
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void KMyRootPixmap::init()
|
||||
{
|
||||
d = new KMyRootPixmapData;
|
||||
// m_Fade = 0;
|
||||
m_pPixmap = new TDESharedPixmap;
|
||||
// m_pTimer = new TQTimer( this );
|
||||
m_bInit = false;
|
||||
m_bActive = false;
|
||||
m_Desk=-1;
|
||||
// m_bCustomPaint = false;
|
||||
|
||||
// connect(kapp, TQ_SIGNAL(backgroundChanged(int)), TQ_SLOT(slotBackgroundChanged(int)));
|
||||
connect(m_pPixmap, TQ_SIGNAL(done(bool)), TQ_SLOT(slotDone(bool)));
|
||||
// connect(m_pTimer, TQ_SIGNAL(timeout()), TQ_SLOT(repaint()));
|
||||
|
||||
#ifdef TQ_WS_X11
|
||||
d->twin = new DesktopWallpaperWatcher();
|
||||
connect(d->twin, TQ_SIGNAL(currentDesktopChanged(int)), TQ_SLOT(desktopChanged(int)));
|
||||
#endif
|
||||
|
||||
// d->toplevel = m_pWidget->topLevelWidget();
|
||||
// d->toplevel->installEventFilter(this);
|
||||
}
|
||||
|
||||
KMyRootPixmap::~KMyRootPixmap()
|
||||
{
|
||||
delete m_pPixmap;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void KMyRootPixmap::desktopChanged(int desktop)
|
||||
{
|
||||
if (wallpaperForDesktop(m_Desk) == wallpaperForDesktop(desktop) &&
|
||||
!wallpaperForDesktop(m_Desk).isNull())
|
||||
return;
|
||||
|
||||
// #ifdef TQ_WS_X11
|
||||
// if (KWin::windowInfo(m_pWidget->topLevelWidget()->winId()).desktop() == NET::OnAllDesktops &&
|
||||
// pixmapName(m_Desk) != pixmapName(desktop))
|
||||
// #endif
|
||||
repaint(true);
|
||||
}
|
||||
|
||||
int KMyRootPixmap::currentDesktop() const
|
||||
{
|
||||
NETRootInfo rinfo( tqt_xdisplay(), NET::CurrentDesktop );
|
||||
rinfo.activate();
|
||||
return rinfo.currentDesktop();
|
||||
}
|
||||
|
||||
void KMyRootPixmap::start()
|
||||
{
|
||||
if (m_bActive)
|
||||
return;
|
||||
|
||||
m_bActive = true;
|
||||
enableExports();
|
||||
return;
|
||||
// if (m_bInit)
|
||||
// repaint(true);
|
||||
}
|
||||
|
||||
void KMyRootPixmap::stop()
|
||||
{
|
||||
m_bActive = false;
|
||||
// m_pTimer->stop();
|
||||
}
|
||||
|
||||
|
||||
void KMyRootPixmap::repaint()
|
||||
{
|
||||
repaint(false);
|
||||
}
|
||||
|
||||
void KMyRootPixmap::repaint(bool force)
|
||||
{
|
||||
// printf("KMyRootPixmap::repaint(%s)\n",force?"true":"false");
|
||||
if ((!force) && (m_Desk==currentDesktop()))return;
|
||||
|
||||
m_Desk = currentDesktop();
|
||||
|
||||
if (!isAvailable())
|
||||
{
|
||||
emit backgroundUpdated(NULL);
|
||||
}else{
|
||||
// TDESharedPixmap will correctly generate a tile for us.
|
||||
m_pPixmap->loadFromShared(pixmapName(m_Desk));
|
||||
updateBackground( m_pPixmap );
|
||||
}
|
||||
}
|
||||
|
||||
bool KMyRootPixmap::isAvailable()
|
||||
{
|
||||
return m_pPixmap->isAvailable(pixmapName(m_Desk));
|
||||
}
|
||||
|
||||
TQString KMyRootPixmap::pixmapName(int desk)
|
||||
{
|
||||
TQString pattern = TQString("DESKTOP%1");
|
||||
int screen_number = DefaultScreen(tqt_xdisplay());
|
||||
if (screen_number) {
|
||||
pattern = TQString("SCREEN%1-DESKTOP").arg(screen_number) + "%1";
|
||||
}
|
||||
return pattern.arg( desk );
|
||||
}
|
||||
|
||||
|
||||
void KMyRootPixmap::enableExports()
|
||||
{
|
||||
// kdDebug(270) << k_lineinfo << "activating background exports.\n";
|
||||
DCOPClient *client = kapp->dcopClient();
|
||||
if (!client->isAttached())
|
||||
client->attach();
|
||||
TQByteArray data;
|
||||
TQDataStream args( data, IO_WriteOnly );
|
||||
args << 1;
|
||||
|
||||
TQCString appname( "kdesktop" );
|
||||
int screen_number = DefaultScreen(tqt_xdisplay());
|
||||
if ( screen_number )
|
||||
appname.sprintf("kdesktop-screen-%d", screen_number );
|
||||
|
||||
client->send( appname, "KBackgroundIface", "setExport(int)", data );
|
||||
}
|
||||
|
||||
|
||||
void KMyRootPixmap::slotDone(bool success)
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
// kdWarning(270) << k_lineinfo << "loading of desktop background failed.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to test active as the pixmap might become available
|
||||
// after the widget has been destroyed.
|
||||
if ( m_bActive )
|
||||
updateBackground( m_pPixmap );
|
||||
}
|
||||
|
||||
void KMyRootPixmap::updateBackground( TDESharedPixmap *spm )
|
||||
{
|
||||
// printf("KMyRootPixmap::updateBackground(%p)\n",spm);
|
||||
TQPixmap *px=spm;
|
||||
if (px->isNull() || px->width()==0 || px->height()==0)
|
||||
{ // This is NOT an image, something went wrong, update to plain
|
||||
emit backgroundUpdated(NULL);
|
||||
return;
|
||||
}
|
||||
KPixmapIO io;
|
||||
TQSize desktopsize(TQApplication::desktop()->width(),TQApplication::desktop()->height());
|
||||
|
||||
if (px->rect().size()==desktopsize)
|
||||
{ // Image has already the right dimension, make a quick update
|
||||
TQImage img = io.convertToImage(*spm);
|
||||
emit backgroundUpdated(&img);
|
||||
return;
|
||||
}else{ // we need to create a tiled pixmap and then the image to update
|
||||
TQPixmap pix(desktopsize,spm->TQPixmap::depth());
|
||||
TQPainter pufferPainter(&pix);
|
||||
|
||||
pufferPainter.drawTiledPixmap(pix.rect(),*spm);
|
||||
|
||||
pufferPainter.end();
|
||||
|
||||
TQImage img=io.convertToImage(pix);
|
||||
emit backgroundUpdated(&img);
|
||||
}
|
||||
}
|
||||
|
||||
#include "myrootpixmap.moc"
|
||||
#endif
|
@ -0,0 +1,116 @@
|
||||
/*
|
||||
*
|
||||
* $Id: krootpixmap.h,v 1.15 2003/05/19 08:02:48 coolo Exp $
|
||||
* This file is part of the KDE project, module kdesktop.
|
||||
* Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org>
|
||||
*
|
||||
* You can Freely distribute this program under the GNU Library General
|
||||
* Public License. See the file "COPYING.LIB" for the exact licensing terms.
|
||||
*/
|
||||
|
||||
/* Modified by Sascha Hlusiak */
|
||||
/* Further modified 11/18/2014 by Timothy Pearson <kb9vqf@pearsoncomputing.net> */
|
||||
|
||||
#ifndef __KRootPixmap_h_Included__
|
||||
#define __KRootPixmap_h_Included__
|
||||
|
||||
#include <tqobject.h>
|
||||
#include <tqwidget.h>
|
||||
#include <tqcolor.h>
|
||||
|
||||
#ifndef TQ_WS_TQWS //FIXME
|
||||
|
||||
class TQRect;
|
||||
class TQTimer;
|
||||
class TDESharedPixmap;
|
||||
class KMyRootPixmapData;
|
||||
|
||||
class DesktopWallpaperWatcher : public TQWidget
|
||||
{
|
||||
TQ_OBJECT
|
||||
|
||||
public:
|
||||
DesktopWallpaperWatcher();
|
||||
~DesktopWallpaperWatcher();
|
||||
|
||||
bool x11Event( XEvent * ev );
|
||||
|
||||
signals:
|
||||
void currentDesktopChanged( int desktop);
|
||||
|
||||
private:
|
||||
int m_old_current_desktop;
|
||||
};
|
||||
|
||||
class KMyRootPixmap: public TQObject
|
||||
{
|
||||
TQ_OBJECT
|
||||
|
||||
public:
|
||||
KMyRootPixmap( TQWidget *target=NULL, const char *name=0 );
|
||||
|
||||
KMyRootPixmap( TQWidget *target, TQObject *parent, const char *name=0 );
|
||||
|
||||
virtual ~KMyRootPixmap();
|
||||
|
||||
bool isAvailable();
|
||||
|
||||
bool isActive() const { return m_bActive; }
|
||||
|
||||
int currentDesktop() const;
|
||||
|
||||
// bool customPainting() const { return m_bCustomPaint; }
|
||||
|
||||
#ifndef KDE_NO_COMPAT
|
||||
|
||||
bool checkAvailable(bool) { return isAvailable(); }
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
virtual void start();
|
||||
|
||||
virtual void stop();
|
||||
|
||||
// void setFadeEffect(double strength, const TQColor &color);
|
||||
|
||||
void repaint( bool force );
|
||||
|
||||
void repaint();
|
||||
|
||||
// void setCustomPainting( bool enable ) { m_bCustomPaint = enable; }
|
||||
|
||||
void enableExports();
|
||||
|
||||
static TQString pixmapName(int desk);
|
||||
|
||||
signals:
|
||||
void backgroundUpdated( const TQImage *pm );
|
||||
|
||||
protected:
|
||||
// virtual bool eventFilter(TQObject *, TQEvent *);
|
||||
|
||||
virtual void updateBackground( TDESharedPixmap * );
|
||||
|
||||
private slots:
|
||||
// void slotBackgroundChanged(int);
|
||||
void slotDone(bool);
|
||||
void desktopChanged(int desktop);
|
||||
|
||||
private:
|
||||
bool m_bActive, m_bInit/*, m_bCustomPaint*/;
|
||||
int m_Desk;
|
||||
|
||||
// double m_Fade;
|
||||
// TQColor m_FadeColor;
|
||||
|
||||
TQRect m_Rect;
|
||||
// TQWidget *m_pWidget;
|
||||
// TQTimer *m_pTimer;
|
||||
TDESharedPixmap *m_pPixmap;
|
||||
KMyRootPixmapData *d;
|
||||
|
||||
void init();
|
||||
};
|
||||
|
||||
#endif // ! TQ_WS_TQWS
|
||||
#endif // __KRootPixmap_h_Included__
|
Loading…
Reference in new issue