diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | config.h.cmake | 7 | ||||
-rw-r--r-- | kicker/applets/systemtray/systemtrayapplet.cpp | 6 | ||||
-rw-r--r-- | kioslave/media/mediamanager/CMakeLists.txt | 37 | ||||
-rw-r--r-- | krootbacking/CMakeLists.txt | 30 | ||||
-rw-r--r-- | krootbacking/krootbacking.cpp | 261 | ||||
-rw-r--r-- | krootbacking/krootbacking.h | 179 | ||||
-rw-r--r-- | krootbacking/main.cpp | 73 | ||||
-rw-r--r-- | ksmserver/shutdown.cpp | 12 | ||||
-rw-r--r-- | ksmserver/shutdowndlg.cpp | 144 | ||||
-rw-r--r-- | ksmserver/shutdowndlg.h | 7 |
11 files changed, 697 insertions, 61 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8da3cd8f9..f932d64b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,7 +183,7 @@ tde_conditional_add_subdirectory( BUILD_KSYSTRAYCMD ksystraycmd ) tde_conditional_add_subdirectory( BUILD_NSPLUGINS nsplugins ) tde_conditional_add_subdirectory( BUILD_KSYSGUARD ksysguard ) tde_conditional_add_subdirectory( BUILD_KXKB kxkb ) - +add_subdirectory( krootbacking ) ##### install startkde & related stuff ########## diff --git a/config.h.cmake b/config.h.cmake index 318d2eac3..d7017346a 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -18,6 +18,13 @@ // kdm, kioslave #cmakedefine HAVE_TERMIOS_H 1 +// kioslave/media +#cmakedefine WITH_HAL 1 +#ifdef WITH_HAL +#define COMPILE_HALBACKEND +#define COMPILE_LINUXCDPOLLING +#endif + // kioslave/fish, kcontrol/info #cmakedefine HAVE_SYS_IOCTL_H 1 diff --git a/kicker/applets/systemtray/systemtrayapplet.cpp b/kicker/applets/systemtray/systemtrayapplet.cpp index 97d1cd55c..9be1bbfe2 100644 --- a/kicker/applets/systemtray/systemtrayapplet.cpp +++ b/kicker/applets/systemtray/systemtrayapplet.cpp @@ -1170,7 +1170,11 @@ void TrayEmbed::setBackground() { XClearArea(x11Display(), embeddedWinId(), 0, 0, 0, 0, True); - ensureBackgroundSet(); + if (pbg) + { + ensureBackgroundSet(); + TQTimer::singleShot( 250, this, SLOT(ensureBackgroundSet()) ); + } } } diff --git a/kioslave/media/mediamanager/CMakeLists.txt b/kioslave/media/mediamanager/CMakeLists.txt index ae35f45f2..58854b630 100644 --- a/kioslave/media/mediamanager/CMakeLists.txt +++ b/kioslave/media/mediamanager/CMakeLists.txt @@ -19,10 +19,12 @@ include_directories( ${CMAKE_BINARY_DIR} ${TDE_INCLUDE_DIR} ${TQT_INCLUDE_DIRS} + ${HAL_INCLUDE_DIRS} ) link_directories( ${TQT_LIBRARY_DIRS} + ${DBUS_TQT_LIBRARY_DIRS} ) @@ -35,14 +37,29 @@ install( FILES mediamanager.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded ) set( target kded_mediamanager ) -set( ${target}_SRCS - mediamanager.cpp mediamanager.skel medialist.cpp - backendbase.cpp fstabbackend.cpp removablebackend.cpp - mediadirnotify.cpp mediadirnotify.skel -) +if( WITH_HAL ) + set( ${target}_SRCS + mediamanager.cpp mediamanager.skel medialist.cpp + backendbase.cpp fstabbackend.cpp removablebackend.cpp + mediadirnotify.cpp mediadirnotify.skel + halbackend.cpp linuxcdpolling.cpp + ) -tde_add_kpart( ${target} AUTOMOC - SOURCES ${${target}_SRCS} - LINK mediacommon-static kdeinit_kded-shared - DESTINATION ${PLUGIN_INSTALL_DIR} -) + tde_add_kpart( ${target} AUTOMOC + SOURCES ${${target}_SRCS} + LINK mediacommon-static kdeinit_kded-shared ${HAL_LIBRARIES} -lhal-storage ${DBUS_TQT_LIBRARIES} + DESTINATION ${PLUGIN_INSTALL_DIR} + ) +else( ) + set( ${target}_SRCS + mediamanager.cpp mediamanager.skel medialist.cpp + backendbase.cpp fstabbackend.cpp removablebackend.cpp + mediadirnotify.cpp mediadirnotify.skel + ) + + tde_add_kpart( ${target} AUTOMOC + SOURCES ${${target}_SRCS} + LINK mediacommon-static kdeinit_kded-shared + DESTINATION ${PLUGIN_INSTALL_DIR} + ) +endif( ) diff --git a/krootbacking/CMakeLists.txt b/krootbacking/CMakeLists.txt new file mode 100644 index 000000000..ee7096b94 --- /dev/null +++ b/krootbacking/CMakeLists.txt @@ -0,0 +1,30 @@ +################################################# +# +# (C) 2011 Timothy Pearson +# kb9vqf (AT) pearsoncomputing (DOT) net +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + +##### krootbacking (executable) #################### + +tde_add_executable( krootbacking AUTOMOC + SOURCES + main.cpp krootbacking.cpp + LINK kdeui-shared + DESTINATION ${BIN_INSTALL_DIR} +) diff --git a/krootbacking/krootbacking.cpp b/krootbacking/krootbacking.cpp new file mode 100644 index 000000000..c105f8d57 --- /dev/null +++ b/krootbacking/krootbacking.cpp @@ -0,0 +1,261 @@ +/*************************************************************************** + * Copyright (C) 2011 by Timothy Pearson <kb9vqf@pearsoncomputing.net> * + * * + * 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 <tqwidget.h> +#include <tqtimer.h> +#include <tqrect.h> +#include <tqimage.h> + +#include <kapplication.h> +#include <kimageeffect.h> +#include <kpixmapio.h> +#include <kwinmodule.h> +#include <kwin.h> +#include <kdebug.h> +#include <netwm.h> +#include <dcopclient.h> +#include <dcopref.h> + +#include <ksharedpixmap.h> +#include <kstandarddirs.h> +#include <krootbacking.h> + +static TQString wallpaperForDesktop(int desktop) +{ + return DCOPRef("kdesktop", "KBackgroundIface").call("currentWallpaper", desktop); +} + +class KRootBackingData +{ +public: + TQWidget *toplevel; +#ifdef Q_WS_X11 + KWinModule *kwin; +#endif +}; + + +KRootBacking::KRootBacking() + : TQObject(KApplication::desktop(), "KRootBacking" ), m_Desk(0), m_timeout(0) +{ + init(); +} + +void KRootBacking::init() +{ + d = new KRootBackingData; + m_Fade = 0; + m_pPixmap = new KSharedPixmap; //ordinary KPixmap on win32 + m_pTimer = new TQTimer( this ); + m_bInit = false; + m_bActive = false; + + connect(kapp, TQT_SIGNAL(backgroundChanged(int)), TQT_SLOT(slotBackgroundChanged(int))); + connect(m_pTimer, TQT_SIGNAL(timeout()), TQT_SLOT(tqrepaint())); +#ifdef Q_WS_X11 + connect(m_pPixmap, TQT_SIGNAL(done(bool)), TQT_SLOT(slotDone(bool))); + + d->kwin = new KWinModule( this ); +#endif + + m_bInit = true; +} + +KRootBacking::~KRootBacking() +{ + delete m_pPixmap; + delete d; +} + + +int KRootBacking::currentDesktop() const +{ +#ifdef Q_WS_X11 + NETRootInfo rinfo( qt_xdisplay(), NET::CurrentDesktop ); + rinfo.activate(); + return rinfo.currentDesktop(); +#endif +} + + +void KRootBacking::start() +{ + if (m_bActive) + return; + + m_bActive = true; + if ( !isAvailable() ) + { + // We should get a KIPC message when the shared pixmap is available... + enableExports(); + if (m_timeout < 50) { + TQTimer::singleShot( 100, this, SLOT(show()) ); // ...but it doesn't always work! + m_timeout++; + return; + } + } + if (m_bInit) { + tqrepaint(true); + } +} + + +void KRootBacking::stop() +{ + m_bActive = false; + m_pTimer->stop(); +} + + +void KRootBacking::setFadeEffect(double fade, const TQColor &color) +{ + if (fade < 0) + m_Fade = 0; + else if (fade > 1) + m_Fade = 1; + else + m_Fade = fade; + m_FadeColor = color; + + if ( m_bActive && m_bInit ) tqrepaint(true); +} + +void KRootBacking::tqrepaint() +{ + tqrepaint(false); +} + + +void KRootBacking::tqrepaint(bool force) +{ + TQWidget* desktopWidget = KApplication::desktop(); + TQPoint p1 = desktopWidget->mapToGlobal(desktopWidget->rect().topLeft()); + TQPoint p2 = desktopWidget->mapToGlobal(desktopWidget->rect().bottomRight()); + if (!force && (m_Rect == TQRect(p1, p2))) + return; + + m_Rect = TQRect(p1, p2); +#ifdef Q_WS_X11 + m_Desk = currentDesktop(); + + // KSharedPixmap will correctly generate a tile for us. + m_pPixmap->loadFromShared(pixmapName(m_Desk), m_Rect); +#else + m_Desk = currentDesktop(); + // !x11 note: tile is not generated! + // TODO: pixmapName() is a nonsense now! + m_pPixmap->load( pixmapName(m_Desk) ); + if (!m_pPixmap->isNull()) { + m_pPixmap->resize( m_Rect.size() ); + slotDone(true); + } +#endif +} + +bool KRootBacking::isAvailable() const +{ +// #ifdef Q_WS_X11 +// return m_pPixmap->isAvailable(pixmapName(m_Desk)); +// #else + return m_pPixmap->isNull(); +// #endif +} + +TQString KRootBacking::pixmapName(int desk) { + TQString pattern = TQString("DESKTOP%1"); +#ifdef Q_WS_X11 + int screen_number = DefaultScreen(qt_xdisplay()); + if (screen_number) { + pattern = TQString("SCREEN%1-DESKTOP").arg(screen_number) + "%1"; + } +#endif + return pattern.arg( desk ); +} + + +void KRootBacking::enableExports() +{ +#ifdef Q_WS_X11 + 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(qt_xdisplay()); + if ( screen_number ) + appname.sprintf("kdesktop-screen-%d", screen_number ); + + client->send( appname, "KBackgroundIface", "setExport(int)", data ); +#endif +} + + +void KRootBacking::slotDone(bool success) +{ + if (!success) + { + kdWarning(270) << k_lineinfo << "loading of desktop background failed.\n"; + if (m_timeout < 50) { + TQTimer::singleShot( 100, this, SLOT(show()) ); + m_timeout++; + 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 KRootBacking::updateBackground( KSharedPixmap *spm ) +{ + TQPixmap pm = *spm; + + if (m_Fade > 1e-6) + { + KPixmapIO io; + TQImage img = io.convertToImage(pm); + img = KImageEffect::fade(img, m_Fade, m_FadeColor); + pm = io.convertToPixmap(img); + } + + TQString filename = getenv("USER"); + filename.prepend("/tmp/kde-"); + filename.append("/krootbacking.png"); + pm.save(filename, "PNG"); + printf("%s\n\r", filename.ascii()); fflush(stdout); + exit(0); +} + + +void KRootBacking::slotBackgroundChanged(int desk) +{ + if (!m_bInit || !m_bActive) + return; + + if (desk == m_Desk) + tqrepaint(true); +} + +#include "krootbacking.moc" diff --git a/krootbacking/krootbacking.h b/krootbacking/krootbacking.h new file mode 100644 index 000000000..12d6b1bfd --- /dev/null +++ b/krootbacking/krootbacking.h @@ -0,0 +1,179 @@ +/*************************************************************************** + * Copyright (C) 2011 by Timothy Pearson <kb9vqf@pearsoncomputing.net> * + * * + * 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 KROOTBACKING_H +#define KROOTBACKING_H + +#include <stdlib.h> + +#include <tqobject.h> +#include <tqcolor.h> +#include <kdelibs_export.h> + +#ifndef Q_WS_QWS //FIXME + +class TQRect; +class TQWidget; +class TQTimer; +class KSharedPixmap; +class KRootBackingData; + +/** + * Gets the current full shared desktop pixmap and feeds it to xscreensaver + * + * @author Timothy Pearson <kb9vqf@pearsoncomputing.net> + */ +class KRootBacking: public TQObject +{ + Q_OBJECT + +public: + /** + * Constructs a KRootBacking. + */ + KRootBacking(); + + /** + * Destructs the object. + */ + virtual ~KRootBacking(); + + /** + * Checks if pseudo-transparency is available. + * @return @p true if transparency is available, @p false otherwise. + */ + bool isAvailable() const; + + /** + * Returns true if the KRootBacking is active. + */ + bool isActive() const { return m_bActive; } + + /** + * Returns the number of the current desktop. + */ + int currentDesktop() const; + +#ifndef KDE_NO_COMPAT + /** + * Deprecated, use isAvailable() instead. + * @deprecated + */ + KDE_DEPRECATED bool checkAvailable(bool) { return isAvailable(); } +#endif + + /** @since 3.2 + * @return the fade color. + */ + const TQColor &color() const { return m_FadeColor; } + + /** @since 3.2 + * @return the color opacity. + */ + double opacity() const { return m_Fade; } + +public slots: + /** + * Starts background handling. + */ + virtual void start(); + + /** + * Stops background handling. + */ + virtual void stop(); + + /** + * Sets the fade effect. + * + * This effect will fade the background to the + * specified color. + * @param opacity A value between 0 and 1, indicating the opacity + * of the color. A value of 0 will not change the image, a value of 1 + * will use the fade color unchanged. + * @param color The color to fade to. + */ + void setFadeEffect(double opacity, const TQColor &color); + + /** + * Repaints the widget background. Normally, you shouldn't need this + * as it is handled automatically. + * + * @param force Force a tqrepaint, even if the contents did not change. + */ + void tqrepaint( bool force ); + + /** + * Repaints the widget background. Normally, you shouldn't need this + * as it is handled automatically. This is equivalent to calling + * tqrepaint( false ). + */ + void tqrepaint(); + + /** + * Asks KDesktop to export the desktop background as a KSharedPixmap. + * This method uses DCOP to call KBackgroundIface/setExport(int). + */ + void enableExports(); + + /** + * Returns the name of the shared pixmap (only needed for low level access) + */ + static TQString pixmapName(int desk); +signals: + /** + * Emitted when the background needs updating and custom painting + * (see setCustomPainting(bool) ) is enabled. + * + * @param pm A pixmap containing the new background. + */ + void backgroundUpdated( const TQPixmap &pm ); + +protected: + /** + * Called when the pixmap has been updated. The default implementation + * applies the fade effect, then sets the target's background, or emits + * backgroundUpdated(const TQPixmap &) depending on the painting mode. + */ + virtual void updateBackground( KSharedPixmap * ); + +private slots: + void slotBackgroundChanged(int); + void slotDone(bool); + +private: + bool m_bActive, m_bInit; + int m_Desk; + int m_timeout; + + double m_Fade; + TQColor m_FadeColor; + + TQRect m_Rect; + TQTimer *m_pTimer; + KSharedPixmap *m_pPixmap; + KRootBackingData *d; + + void init(); +}; + +#endif // ! Q_WS_QWS + +#endif // KROOTBACKING_H diff --git a/krootbacking/main.cpp b/krootbacking/main.cpp new file mode 100644 index 000000000..6b35a51af --- /dev/null +++ b/krootbacking/main.cpp @@ -0,0 +1,73 @@ +/*************************************************************************** + * Copyright (C) 2011 by Timothy Pearson <kb9vqf@pearsoncomputing.net> * + * * + * 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 <unistd.h> +#include <stdio.h> +#include <stdlib.h> + +#include <tqobject.h> +#include <tqtimer.h> + +#include <kapplication.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <klocale.h> +#include <kdebug.h> + +#include "krootbacking.h" + +bool argb_visual = false; + +static const char description[] = + I18N_NOOP("A program to grab the current TDE desktop backrounds for xscreensaver"); + +static const char version[] = "0.1"; + +static KCmdLineOptions options[] = +{ + KCmdLineLastOption +}; + +int main(int argc, char **argv) +{ + KAboutData about("krootbacking", I18N_NOOP("krootbacking"), version, description, + KAboutData::License_GPL, "(C) 2011 Timothy Pearson", 0, 0, "kb9vqf@pearsoncomputing.net"); + about.addAuthor( "Timothy Pearson", 0, "kb9vqf@pearsoncomputing.net" ); + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions( options ); + + KApplication app; + + // no session.. just start up normally + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + /// @todo do something with the command line args here + args->clear(); + + TQObject* mainWin = new KRootBacking(); + TQTimer *timer = new QTimer( mainWin ); + TQObject::connect( timer, SIGNAL(timeout()), mainWin, SLOT(start()) ); + timer->start( 100, TRUE ); // 100ms single shot timer + + app.exec(); + + delete timer; + delete mainWin; +} + diff --git a/ksmserver/shutdown.cpp b/ksmserver/shutdown.cpp index d298b2cf3..549fd2cc3 100644 --- a/ksmserver/shutdown.cpp +++ b/ksmserver/shutdown.cpp @@ -158,6 +158,13 @@ void KSMServer::shutdownInternal( KApplication::ShutdownConfirm confirm, if (sdmode == KApplication::ShutdownModeDefault) sdmode = KApplication::ShutdownModeInteractive; + // shall we show a nice fancy logout screen? + bool showFancyLogout = KConfigGroup(KGlobal::config(), "Logout").readBoolEntry("showFancyLogout", true); + + if (showFancyLogout) { + KSMShutdownIPFeedback::start(); + } + dialogActive = true; if ( !logoutConfirmed ) { KSMShutdownFeedback::start(); // make the screen gray @@ -179,11 +186,8 @@ void KSMServer::shutdownInternal( KApplication::ShutdownConfirm confirm, // shall we save the session on logout? saveSession = ( config->readEntry( "loginMode", "restorePreviousLogout" ) == "restorePreviousLogout" ); - // shall we show a nice fancy logout screen? - bool showFancyLogout = KConfigGroup(KGlobal::config(), "Logout").readBoolEntry("showFancyLogout", true); - if (showFancyLogout) { -// KSMShutdownIPFeedback::start(); // hide the UGLY logout process from the user + KSMShutdownIPFeedback::showit(); // hide the UGLY logout process from the user KSMShutdownIPDlg::showShutdownIP(); } diff --git a/ksmserver/shutdowndlg.cpp b/ksmserver/shutdowndlg.cpp index 52960ad6d..810260c2d 100644 --- a/ksmserver/shutdowndlg.cpp +++ b/ksmserver/shutdowndlg.cpp @@ -497,26 +497,24 @@ void KSMShutdownFeedback::slotPaintEffect() KSMShutdownIPFeedback * KSMShutdownIPFeedback::s_pSelf = 0L; KSMShutdownIPFeedback::KSMShutdownIPFeedback() - : TQWidget( 0L, "feedbackipwidget", Qt::WType_Popup | Qt::WStyle_StaysOnTop | Qt::WX11BypassWM ), m_sharedpixmap(0), m_timeout(0) + : TQWidget( 0L, "feedbackipwidget", Qt::WType_Dialog | Qt::WStyle_StaysOnTop | Qt::WX11BypassWM ), m_timeout(0) { - m_sharedpixmap = new KSharedPixmap(); - resize(0, 0); - setShown(true); + setShown(false); - // At least show SOMETHING while waiting for the root pixmap... - TQPixmap drawable = TQPixmap(TQPixmap::grabWindow(qt_xrootwin(), 0, 0, TQApplication::desktop()->width(), TQApplication::desktop()->height())).convertToImage(); - bitBlt( this, 0, 0, &drawable ); + // Try to get the root pixmap + system("krootbacking &"); +} - // Try to get and show the root pixmap - enableExports(); - TQTimer::singleShot( 100, this, SLOT(slotPaintEffect()) ); +void KSMShutdownIPFeedback::showNow() +{ +// slotPaintEffect(); + TQTimer::singleShot( 0, this, SLOT(slotPaintEffect()) ); } KSMShutdownIPFeedback::~KSMShutdownIPFeedback() { - if (m_sharedpixmap) - delete m_sharedpixmap; + } void KSMShutdownIPFeedback::fadeBack( void ) @@ -535,29 +533,46 @@ TQString KSMShutdownIPFeedback::pixmapName(int desk) { void KSMShutdownIPFeedback::slotPaintEffect() { - NETRootInfo rinfo( qt_xdisplay(), NET::CurrentDesktop ); - rinfo.activate(); - int current_desktop = rinfo.currentDesktop(); - - m_sharedpixmap->loadFromShared(pixmapName(current_desktop), TQRect(0, 0, width(), height())); -} + TQPixmap pm; + TQString filename = getenv("USER"); + filename.prepend("/tmp/kde-"); + filename.append("/krootbacking.png"); + bool success = pm.load(filename, "PNG"); + if (!success) { + sleep(1); + success = pm.load(filename, "PNG"); + if (!success) { + pm = TQPixmap(kapp->desktop()->width(), kapp->desktop()->height()); + pm.fill(Qt::black); + } + } -void KSMShutdownIPFeedback::slotDone(bool success) -{ - if (!success) - { - kdWarning(270) << k_lineinfo << "loading of desktop background failed.\n"; - if (m_timeout < 50) { - TQTimer::singleShot( 100, this, SLOT(slotPaintEffect()) ); - m_timeout++; - return; + if (TQPaintDevice::x11AppDepth() == 32) { + // Remove the alpha components from the image + TQImage correctedImage = pm.convertToImage(); + correctedImage = correctedImage.convertDepth(32); + correctedImage.setAlphaBuffer(true); + int w = correctedImage.width(); + int h = correctedImage.height(); + for (int y = 0; y < h; ++y) { + TQRgb *ls = (TQRgb *)correctedImage.scanLine( y ); + for (int x = 0; x < w; ++x) { + TQRgb l = ls[x]; + int r = int( tqRed( l ) ); + int g = int( tqGreen( l ) ); + int b = int( tqBlue( l ) ); + int a = int( 255 ); + ls[x] = tqRgba( r, g, b, a ); + } } + pm.convertFromImage(correctedImage); } - TQImage image = m_sharedpixmap->convertToImage(); - TQPixmap drawable; - drawable.convertFromImage( image ); - bitBlt( this, 0, 0, &drawable ); + resize(kapp->desktop()->width(), kapp->desktop()->height()); + move(0,0); + setShown(true); + + setBackgroundPixmap( pm ); } void KSMShutdownIPFeedback::enableExports() @@ -1071,7 +1086,8 @@ void KSMShutdownIPDlg::showShutdownIP() } KSMShutdownIPDlg::KSMShutdownIPDlg(TQWidget* parent) - : TQDialog( 0, "", TRUE, Qt::WType_Popup | Qt::WDestructiveClose ) +// : TQDialog( 0, "", TRUE, Qt::WStyle_Customize | Qt::WType_Dialog | Qt::WStyle_NoBorder | Qt::WStyle_Title | Qt::WStyle_StaysOnTop | Qt::WDestructiveClose ) + : TQDialog( 0, "", TRUE, Qt::WStyle_Customize | Qt::WType_Popup | Qt::WStyle_NoBorder | Qt::WStyle_Title | Qt::WStyle_StaysOnTop | Qt::WX11BypassWM | Qt::WDestructiveClose ) { TQVBoxLayout* vbox = new TQVBoxLayout( this ); @@ -1083,30 +1099,64 @@ KSMShutdownIPDlg::KSMShutdownIPDlg(TQWidget* parent) frame->setMinimumWidth(400); vbox->addWidget( frame ); TQGridLayout* gbox = new TQGridLayout( frame, 1, 1, 2 * KDialog::marginHint(), 2 * KDialog::spacingHint() ); + TQHBoxLayout* centerbox = new TQHBoxLayout( gbox, KDialog::spacingHint() ); + TQHBoxLayout* seperatorbox = new TQHBoxLayout( gbox, 0 ); TQWidget* ticon = new TQWidget( frame ); KIconLoader * ldr = KGlobal::iconLoader(); TQPixmap trinityPixmap = ldr->loadIcon("kmenu", KIcon::Panel, KIcon::SizeLarge, KIcon::DefaultState, 0L, true); + if (TQPaintDevice::x11AppDepth() == 32) { + // Manually draw the alpha portions onto the widget background color... + TQRgb backgroundRgb = ticon->paletteBackgroundColor().rgb(); + TQImage correctedImage = trinityPixmap.convertToImage(); + correctedImage = correctedImage.convertDepth(32); + correctedImage.setAlphaBuffer(true); + int w = correctedImage.width(); + int h = correctedImage.height(); + for (int y = 0; y < h; ++y) { + TQRgb *ls = (TQRgb *)correctedImage.scanLine( y ); + for (int x = 0; x < w; ++x) { + TQRgb l = ls[x]; + float alpha_adjust = tqAlpha( l )/255.0; + int r = int( (tqRed( l ) * alpha_adjust) + (tqRed( backgroundRgb ) * (1.0-alpha_adjust)) ); + int g = int( (tqGreen( l ) * alpha_adjust) + (tqGreen( backgroundRgb ) * (1.0-alpha_adjust)) ); + int b = int( (tqBlue( l ) * alpha_adjust) + (tqBlue( backgroundRgb ) * (1.0-alpha_adjust)) ); + int a = int( 255 ); + ls[x] = tqRgba( r, g, b, a ); + } + } + trinityPixmap.convertFromImage(correctedImage); + } ticon->setBackgroundPixmap(trinityPixmap); ticon->setMinimumSize(trinityPixmap.size()); ticon->setMaximumSize(trinityPixmap.size()); ticon->resize(trinityPixmap.size()); -// gbox->addMultiCellWidget( ticon, 0, 1, 0, 0, AlignCenter ); - gbox->addWidget( ticon, 0, 0, AlignHCenter ); + centerbox->addWidget( ticon, AlignCenter ); + + TQWidget* swidget = new TQWidget( frame ); + swidget->resize(2, frame->sizeHint().width()); + swidget->setBackgroundColor(Qt::black); + seperatorbox->addWidget( swidget, AlignCenter ); - TQLabel* label = new TQLabel( i18n("Trinity is saving your settings, please wait..."), frame ); + TQLabel* label = new TQLabel( i18n("Trinity Desktop Environment"), frame ); TQFont fnt = label->font(); fnt.setBold( true ); + fnt.setPointSize( fnt.pointSize() * 3 / 2 ); + label->setFont( fnt ); + centerbox->addWidget( label, AlignCenter ); + + label = new TQLabel( i18n("Saving your settings..."), frame ); + fnt = label->font(); + fnt.setBold( false ); fnt.setPointSize( fnt.pointSize() * 1 ); label->setFont( fnt ); - gbox->addWidget( label, 0, 1, AlignHCenter ); - -// label = new TQLabel( i18n("Logging off"), frame ); -// fnt = label->font(); -// fnt.setBold( true ); -// fnt.setPointSize( fnt.pointSize() * 3 / 2 ); -// label->setFont( fnt ); -// gbox->addWidget( label, 0, 1, AlignHCenter ); + gbox->addMultiCellWidget( label, 2, 2, 0, 0, AlignLeft | AlignVCenter ); + + gbox->addLayout(centerbox, 0, 0); + gbox->addLayout(seperatorbox, 1, 0); + + setFixedSize( sizeHint() ); + setCaption( i18n("Please wait...") ); } KSMShutdownIPDlg::~KSMShutdownIPDlg() @@ -1114,6 +1164,14 @@ KSMShutdownIPDlg::~KSMShutdownIPDlg() } +void KSMShutdownIPDlg::closeEvent(TQCloseEvent *e) +{ + //--------------------------------------------- + // Don't call the base function because + // we want to ignore the close event + //--------------------------------------------- +} + KSMDelayedPushButton::KSMDelayedPushButton( const KGuiItem &item, TQWidget *parent, const char *name) diff --git a/ksmserver/shutdowndlg.h b/ksmserver/shutdowndlg.h index 5beb32ca4..e6bcfdab2 100644 --- a/ksmserver/shutdowndlg.h +++ b/ksmserver/shutdowndlg.h @@ -81,6 +81,7 @@ class KSMShutdownIPFeedback : public TQWidget public: static void start() { s_pSelf = new KSMShutdownIPFeedback(); } + static void showit() { if ( s_pSelf != 0L ) s_pSelf->showNow(); } static void stop() { if ( s_pSelf != 0L ) s_pSelf->fadeBack(); delete s_pSelf; s_pSelf = 0L; } static KSMShutdownIPFeedback * self() { return s_pSelf; } @@ -89,7 +90,6 @@ protected: private slots: void slotPaintEffect(); - void slotDone(bool success); private: static KSMShutdownIPFeedback * s_pSelf; @@ -97,8 +97,8 @@ private: int m_currentY; TQPixmap m_root; void fadeBack( void ); + void showNow( void ); TQString pixmapName(int desk); - KSharedPixmap* m_sharedpixmap; void enableExports(); int m_timeout; }; @@ -144,6 +144,9 @@ public: protected: ~KSMShutdownIPDlg(); +protected slots: + void closeEvent(TQCloseEvent *e); + private: KSMShutdownIPDlg( TQWidget* parent ); }; |