From: <sh...@us...> - 2003-04-04 15:23:05
|
Update of /cvsroot/sim-icq/sim/sim In directory sc8-pr-cvs1:/tmp/cvs-serv15765/sim Modified Files: transparent.cpp transparent.h Log Message: Fix transaprent for win32 Index: transparent.cpp =================================================================== RCS file: /cvsroot/sim-icq/sim/sim/transparent.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** transparent.cpp 4 Apr 2003 06:46:57 -0000 1.19 --- transparent.cpp 4 Apr 2003 15:22:59 -0000 1.20 *************** *** 142,146 **** useTransparent(_useTransparent), transparent(_transparent) ! { #if defined(USE_KDE) && defined(HAVE_KROOTPIXMAP_H) rootpixmap = new KRootPixmap(parent); --- 142,147 ---- useTransparent(_useTransparent), transparent(_transparent) ! { ! m_bUseTransparent = false; #if defined(USE_KDE) && defined(HAVE_KROOTPIXMAP_H) rootpixmap = new KRootPixmap(parent); *************** *** 155,169 **** } connect(pMain, SIGNAL(transparentChanged()), this, SLOT(transparentChanged())); - #ifdef WIN32 - if (bCanTransparent){ - SetWindowLongW(parent->winId(), GWL_EXSTYLE, GetWindowLongW(parent->winId(), GWL_EXSTYLE) | WS_EX_LAYERED); - SetLayeredWindowAttributes(parent->winId(), parent->colorGroup().background().rgb(), 255, LWA_ALPHA); - if (parent->isVisible()){ - RedrawWindow(parent->winId(), NULL, NULL, RDW_UPDATENOW); - QTimer::singleShot(500, this, SLOT(transparentChanged())); - } - } - parent->installEventFilter(this); - #endif transparentChanged(); } --- 156,159 ---- *************** *** 174,178 **** case QEvent::WindowActivate: case QEvent::WindowDeactivate: ! transparentChanged(); break; case QEvent::Show: --- 164,168 ---- case QEvent::WindowActivate: case QEvent::WindowDeactivate: ! setTransparent(); break; case QEvent::Show: *************** *** 181,185 **** QWidget *w = static_cast<QWidget*>(o); SetLayeredWindowAttributes(w->winId(), w->colorGroup().background().rgb(), 255, LWA_ALPHA); ! QTimer::singleShot(0, this, SLOT(transparentChanged())); } #endif --- 171,175 ---- QWidget *w = static_cast<QWidget*>(o); SetLayeredWindowAttributes(w->winId(), w->colorGroup().background().rgb(), 255, LWA_ALPHA); ! QTimer::singleShot(0, this, SLOT(setTransparent())); } #endif *************** *** 205,229 **** #endif } void TransparentTop::transparentChanged() ! { #ifdef WIN32 ! QWidget *p = static_cast<QWidget*>(parent()); ! bool bTransparent = true; ! if (pMain->isTransparentIfInactive()) bTransparent = !p->isActiveWindow(); ! setTransparent(p, *useTransparent && bTransparent, *transparent); ! #endif ! #if defined(USE_KDE) && defined(HAVE_KROOTPIXMAP_H) ! if (*useTransparent){ ! rootpixmap->start(); ! }else{ ! rootpixmap->stop(); ! saveBG = QPixmap(); ! genBG = QPixmap(); ! genFade = 0; ! emit backgroundUpdated(); ! } ! #endif } TransparentTop *TransparentTop::getTransparent(QWidget *w) --- 195,246 ---- #endif } + void TransparentTop::transparentChanged() ! { #ifdef WIN32 ! if (bCanTransparent){ ! QWidget *p = static_cast<QWidget*>(parent()); ! if (*useTransparent){ ! if (!m_bUseTransparent){ ! SetWindowLongW(p->winId(), GWL_EXSTYLE, GetWindowLongW(p->winId(), GWL_EXSTYLE) | WS_EX_LAYERED); ! SetLayeredWindowAttributes(p->winId(), p->colorGroup().background().rgb(), 255, LWA_ALPHA); ! if (p->isVisible()) ! RedrawWindow(p->winId(), NULL, NULL, RDW_UPDATENOW); ! p->installEventFilter(this); ! m_bUseTransparent = true; ! } ! }else{ ! if (m_bUseTransparent){ ! SetWindowLongW(p->winId(), GWL_EXSTYLE, GetWindowLongW(p->winId(), GWL_EXSTYLE) & ~WS_EX_LAYERED); ! p->removeEventFilter(this); ! m_bUseTransparent = false; ! } ! } ! } ! #endif ! setTransparent(); } + + void TransparentTop::setTransparent() + { + #ifdef WIN32 + QWidget *p = static_cast<QWidget*>(parent()); + bool bTransparent = true; + if (pMain->isTransparentIfInactive()) bTransparent = !p->isActiveWindow(); + setTransparent(p, *useTransparent && bTransparent, *transparent, *useTransparent); + #endif + #if defined(USE_KDE) && defined(HAVE_KROOTPIXMAP_H) + if (*useTransparent){ + rootpixmap->start(); + }else{ + rootpixmap->stop(); + saveBG = QPixmap(); + genBG = QPixmap(); + genFade = 0; + emit backgroundUpdated(); + } + #endif + } TransparentTop *TransparentTop::getTransparent(QWidget *w) *************** *** 262,279 **** void TransparentTop::setTransparent( #ifdef WIN32 ! QWidget *w, bool isTransparent, unsigned long transparency #else ! QWidget*, bool, unsigned long #endif ) { #ifdef WIN32 ! if (!bCanTransparent) return; ! if (isTransparent){ ! BYTE d = QMIN(transparency * 256 / 100, 255); ! SetLayeredWindowAttributes(w->winId(), w->colorGroup().background().rgb(), d, LWA_ALPHA); ! }else{ ! SetLayeredWindowAttributes(w->winId(), w->colorGroup().background().rgb(), 255, LWA_ALPHA); ! } #endif } --- 279,298 ---- void TransparentTop::setTransparent( #ifdef WIN32 ! QWidget *w, bool isTransparent, unsigned long transparency, bool set #else ! QWidget*, bool, unsigned long, bool #endif ) { #ifdef WIN32 ! if (!bCanTransparent) return; ! if (set){ ! if (isTransparent){ ! BYTE d = QMIN(transparency * 256 / 100, 255); ! SetLayeredWindowAttributes(w->winId(), w->colorGroup().background().rgb(), d, LWA_ALPHA); ! }else{ ! SetLayeredWindowAttributes(w->winId(), w->colorGroup().background().rgb(), 255, LWA_ALPHA); ! } ! } #endif } Index: transparent.h =================================================================== RCS file: /cvsroot/sim-icq/sim/sim/transparent.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** transparent.h 30 Dec 2002 00:52:21 -0000 1.9 --- transparent.h 4 Apr 2003 15:22:59 -0000 1.10 *************** *** 48,52 **** public: TransparentTop(QWidget *parent, bool *useTransparent, unsigned long *transparent); ! static void setTransparent(QWidget*, bool isTransparent, unsigned long transparency); static bool bCanTransparent; static TransparentTop *getTransparent(QWidget*); --- 48,52 ---- public: TransparentTop(QWidget *parent, bool *useTransparent, unsigned long *transparent); ! static void setTransparent(QWidget*, bool isTransparent, unsigned long transparency, bool isSet); static bool bCanTransparent; static TransparentTop *getTransparent(QWidget*); *************** *** 63,71 **** void backgroundUpdated(); protected slots: ! void transparentChanged(); protected: ! bool eventFilter(QObject *obj, QEvent *e); bool *useTransparent; ! unsigned long *transparent; }; --- 63,73 ---- void backgroundUpdated(); protected slots: ! void transparentChanged(); ! void setTransparent(); protected: ! bool eventFilter(QObject *obj, QEvent *e); bool *useTransparent; ! unsigned long *transparent; ! bool m_bUseTransparent; }; |