summaryrefslogtreecommitdiffstats
path: root/kpager
diff options
context:
space:
mode:
Diffstat (limited to 'kpager')
-rw-r--r--kpager/CMakeLists.txt40
-rw-r--r--kpager/Makefile.am22
-rw-r--r--kpager/TODO1
-rw-r--r--kpager/config.cpp180
-rw-r--r--kpager/config.h78
-rw-r--r--kpager/desktop.cpp692
-rw-r--r--kpager/desktop.h130
-rw-r--r--kpager/hi16-app-kpager.pngbin0 -> 288 bytes
-rw-r--r--kpager/hi22-app-kpager.pngbin0 -> 1059 bytes
-rw-r--r--kpager/hi32-app-kpager.pngbin0 -> 784 bytes
-rw-r--r--kpager/hi48-app-kpager.pngbin0 -> 1081 bytes
-rw-r--r--kpager/kpager.cpp674
-rw-r--r--kpager/kpager.desktop106
-rw-r--r--kpager/kpager.h139
-rw-r--r--kpager/kpagerIface.h22
-rw-r--r--kpager/main.cpp107
-rw-r--r--kpager/uninstall.desktop2
-rw-r--r--kpager/windowdrag.cpp60
-rw-r--r--kpager/windowdrag.h41
19 files changed, 2294 insertions, 0 deletions
diff --git a/kpager/CMakeLists.txt b/kpager/CMakeLists.txt
new file mode 100644
index 000000000..abe022683
--- /dev/null
+++ b/kpager/CMakeLists.txt
@@ -0,0 +1,40 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+##### icons #######################
+
+tde_install_icons()
+
+##### other data ################################
+
+install( FILES kpager.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
+install( FILES uninstall.desktop DESTINATION ${APPS_INSTALL_DIR}/Utilities RENAME kpager.desktop )
+
+
+##### kpager (executable) #######################
+
+tde_add_executable( kpager AUTOMOC
+ SOURCES
+ desktop.cpp kpager.cpp config.cpp windowdrag.cpp
+ kpagerIface.skel main.cpp
+ LINK tdeui-shared
+ DESTINATION ${BIN_INSTALL_DIR}
+)
diff --git a/kpager/Makefile.am b/kpager/Makefile.am
new file mode 100644
index 000000000..dd72707fc
--- /dev/null
+++ b/kpager/Makefile.am
@@ -0,0 +1,22 @@
+INCLUDES= $(all_includes)
+
+bin_PROGRAMS = kpager
+
+kpager_SOURCES = desktop.cpp kpager.cpp config.cpp windowdrag.cpp \
+ kpagerIface.skel main.cpp
+
+kpager_METASOURCES = AUTO
+kpager_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor
+
+kpager_LDADD = $(LIB_TDEUI)
+
+KDE_ICON = kpager
+
+xdg_apps_DATA = kpager.desktop
+
+install-data-local: uninstall.desktop
+ $(mkinstalldirs) $(DESTDIR)$(kde_appsdir)/Utilities
+ $(INSTALL_DATA) $(srcdir)/uninstall.desktop $(DESTDIR)$(kde_appsdir)/Utilities/kpager.desktop
+
+messages:
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kpager.pot
diff --git a/kpager/TODO b/kpager/TODO
new file mode 100644
index 000000000..9794e7fc1
--- /dev/null
+++ b/kpager/TODO
@@ -0,0 +1 @@
+Mantain the aspect ratio
diff --git a/kpager/config.cpp b/kpager/config.cpp
new file mode 100644
index 000000000..0c022d4bb
--- /dev/null
+++ b/kpager/config.cpp
@@ -0,0 +1,180 @@
+/**************************************************************************
+
+ config.cpp - KPager config dialog
+ Copyright (C) 2000 Antonio Larrosa Jimenez
+
+ 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.
+
+ Send comments and bug fixes to [email protected]
+
+***************************************************************************/
+
+#include <tqcheckbox.h>
+#include <tqradiobutton.h>
+#include <tqbuttongroup.h>
+#include <tqwidget.h>
+#include <tqvbox.h>
+#include <tqhbox.h>
+#include <tqlayout.h>
+
+#include <kdialogbase.h>
+#include <tdelocale.h>
+#include <tdeconfig.h>
+#include <kseparator.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+
+#include "config.h"
+#include "config.moc"
+#include "desktop.h"
+#include "kpager.h"
+
+
+KPagerConfigDialog::KPagerConfigDialog (TQWidget *parent)
+ : KDialogBase ( parent, "configdialog", true, i18n("Configuration"), Ok|Cancel, Ok, true )
+{
+ TQVBox *box = new TQVBox( this );
+ m_chkWindowDragging=new TQCheckBox(i18n("Enable window dragging"),box,0);
+ (void ) new KSeparator( box );
+ connect(m_chkWindowDragging, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(enableWindowDragging(bool)));
+
+ TQHBox *page = new TQHBox( box );
+ TQVBox *lpage = new TQVBox( page );
+ setMainWidget(box);
+
+ m_chkShowName=new TQCheckBox(i18n("Show name"),lpage,0);
+ connect(m_chkShowName, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setShowName(bool)));
+ m_chkShowNumber=new TQCheckBox(i18n("Show number"),lpage,0);
+ connect(m_chkShowNumber, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setShowNumber(bool)));
+ m_chkShowBackground=new TQCheckBox(i18n("Show background"),lpage,0);
+ connect(m_chkShowBackground, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setShowBackground(bool)));
+ m_chkShowWindows=new TQCheckBox(i18n("Show windows"),lpage,0);
+ connect(m_chkShowWindows, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setShowWindows(bool)));
+
+ m_grpWindowDrawMode=new TQButtonGroup(i18n("Type of Window"),page);
+ m_grpWindowDrawMode->setExclusive(true);
+ TQVBoxLayout *vbox = new TQVBoxLayout(m_grpWindowDrawMode, KDialog::marginHint(),
+ KDialog::spacingHint());
+ vbox->addSpacing(fontMetrics().lineSpacing());
+ vbox->addWidget(new TQRadioButton(i18n("Plain"),m_grpWindowDrawMode));
+ vbox->addWidget(new TQRadioButton(i18n("Icon"),m_grpWindowDrawMode));
+
+ TQRadioButton *rbpix = new TQRadioButton(i18n("Pixmap"),m_grpWindowDrawMode);
+// rbpix->setEnabled(false);
+ vbox->addWidget(rbpix);
+
+ connect(m_grpWindowDrawMode, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(setWindowDrawMode(int)));
+
+ m_grpLayoutType=new TQButtonGroup(i18n("Layout"),page);
+ m_grpLayoutType->setExclusive(true);
+ vbox = new TQVBoxLayout(m_grpLayoutType, KDialog::marginHint(), KDialog::spacingHint());
+ vbox->addSpacing(fontMetrics().lineSpacing());
+ vbox->addWidget(new TQRadioButton(i18n("Classical"),m_grpLayoutType));
+ vbox->addWidget(new TQRadioButton(i18n("Horizontal"),m_grpLayoutType));
+ vbox->addWidget(new TQRadioButton(i18n("Vertical"),m_grpLayoutType));
+
+ connect(m_grpLayoutType, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(setLayout(int)));
+ connect(this,TQT_SIGNAL(okClicked()),this,TQT_SLOT(slotOk()));
+ loadConfiguration();
+ setMinimumSize(360, 160);
+}
+
+void KPagerConfigDialog::setShowName(bool show)
+{
+ m_tmpShowName=show;
+}
+
+void KPagerConfigDialog::setShowNumber(bool show)
+{
+ m_tmpShowNumber=show;
+}
+
+void KPagerConfigDialog::setShowBackground(bool show)
+{
+ m_tmpShowBackground=show;
+}
+
+void KPagerConfigDialog::setShowWindows(bool show)
+{
+ m_tmpShowWindows=show;
+}
+
+void KPagerConfigDialog::enableWindowDragging(bool enable)
+{
+ m_tmpWindowDragging = enable;
+}
+
+void KPagerConfigDialog::setWindowDrawMode(int type)
+{
+ m_tmpWindowDrawMode=type;
+}
+
+void KPagerConfigDialog::setLayout(int layout)
+{
+ m_tmpLayoutType=layout;
+}
+
+void KPagerConfigDialog::loadConfiguration()
+{
+ m_chkShowName->setChecked(m_showName);
+ m_chkShowNumber->setChecked(m_showNumber);
+ m_chkShowBackground->setChecked(m_showBackground);
+ m_chkShowWindows->setChecked(m_showWindows);
+ m_grpWindowDrawMode->setButton(m_windowDrawMode);
+ m_grpLayoutType->setButton(m_layoutType);
+ m_chkWindowDragging->setChecked( m_windowDragging );
+ m_tmpShowName=m_showName;
+ m_tmpShowNumber=m_showNumber;
+ m_tmpShowBackground=m_showBackground;
+ m_tmpShowWindows=m_showWindows;
+ m_tmpWindowDrawMode=m_windowDrawMode;
+ m_tmpLayoutType=m_layoutType;
+ m_tmpWindowDragging=m_windowDragging;
+}
+
+void KPagerConfigDialog::initConfiguration(void)
+{
+ TDEConfig *cfg= kapp->config();
+ cfg->setGroup("KPager");
+
+ m_windowDrawMode=cfg->readNumEntry("windowDrawMode", Desktop::c_defWindowDrawMode);
+ m_showName=cfg->readBoolEntry("showName", Desktop::c_defShowName);
+ m_showNumber=cfg->readBoolEntry("showNumber", Desktop::c_defShowNumber);
+ m_showBackground=cfg->readBoolEntry("showBackground", Desktop::c_defShowBackground);
+ m_showWindows=cfg->readBoolEntry("showWindows", Desktop::c_defShowWindows);
+ m_layoutType=cfg->readNumEntry("layoutType", KPager::c_defLayout);
+ m_windowDragging=cfg->readBoolEntry("windowDragging", true );
+}
+
+void KPagerConfigDialog::slotOk()
+{
+ m_showName=m_tmpShowName;
+ m_showNumber=m_tmpShowNumber;
+ m_showBackground=m_tmpShowBackground;
+ m_showWindows=m_tmpShowWindows;
+ m_windowDrawMode=m_tmpWindowDrawMode;
+ m_layoutType=m_tmpLayoutType;
+ m_windowDragging=m_tmpWindowDragging;
+ accept();
+}
+
+bool KPagerConfigDialog::m_showName=Desktop::c_defShowName;
+bool KPagerConfigDialog::m_showNumber=Desktop::c_defShowNumber;
+bool KPagerConfigDialog::m_showBackground=Desktop::c_defShowBackground;
+bool KPagerConfigDialog::m_showWindows=Desktop::c_defShowWindows;
+bool KPagerConfigDialog::m_windowDragging=Desktop::c_defWindowDragging;
+int KPagerConfigDialog::m_windowDrawMode=Desktop::c_defWindowDrawMode;
+int KPagerConfigDialog::m_layoutType=KPager::c_defLayout;
+
diff --git a/kpager/config.h b/kpager/config.h
new file mode 100644
index 000000000..2b8b095d3
--- /dev/null
+++ b/kpager/config.h
@@ -0,0 +1,78 @@
+/**************************************************************************
+
+ config.h - KPager config dialog
+ Copyright (C) 2000 Antonio Larrosa Jimenez
+
+ 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.
+
+ Send comments and bug fixes to [email protected]
+
+***************************************************************************/
+#ifndef __KPCONFIG_H
+#define __KPCONFIG_H
+
+#include <kdialogbase.h>
+
+class TQCheckBox;
+class TQButtonGroup;
+
+class KPagerConfigDialog : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ KPagerConfigDialog(TQWidget *parent);
+
+public slots:
+ void setShowName(bool show);
+ void setShowNumber(bool show);
+ void setShowBackground(bool show);
+ void setShowWindows(bool show);
+
+ void setWindowDrawMode(int mode);
+ void setLayout(int layout);
+
+ void enableWindowDragging(bool);
+
+ void loadConfiguration();
+ void slotOk();
+public:
+ static void initConfiguration(void);
+ static bool m_showName;
+ static bool m_showNumber;
+ static bool m_showBackground;
+ static bool m_showWindows;
+ static int m_windowDrawMode;
+ static int m_layoutType;
+ static bool m_windowDragging;
+
+protected:
+ TQCheckBox *m_chkShowName;
+ TQCheckBox *m_chkShowNumber;
+ TQCheckBox *m_chkShowBackground;
+ TQCheckBox *m_chkShowWindows;
+ TQButtonGroup *m_grpWindowDrawMode;
+ TQButtonGroup *m_grpLayoutType;
+ TQCheckBox* m_chkWindowDragging;
+ bool m_tmpShowName;
+ bool m_tmpShowNumber;
+ bool m_tmpShowBackground;
+ bool m_tmpShowWindows;
+ int m_tmpWindowDrawMode;
+ int m_tmpLayoutType;
+ bool m_tmpWindowDragging;
+};
+
+#endif
diff --git a/kpager/desktop.cpp b/kpager/desktop.cpp
new file mode 100644
index 000000000..74ead587f
--- /dev/null
+++ b/kpager/desktop.cpp
@@ -0,0 +1,692 @@
+/**************************************************************************
+
+ desktop.cpp - KPager's desktop
+ Copyright (C) 2000 Antonio Larrosa Jimenez
+ Matthias Ettrich
+ Matthias Elter
+
+ 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.
+
+ Send comments and bug fixes to [email protected]
+
+***************************************************************************/
+
+#include "kpager.h"
+
+#include <dcopobject.h>
+#include <dcopclient.h>
+#include <kdatastream.h>
+#include <tdeapplication.h>
+#include <tdeglobalsettings.h>
+#include <twinmodule.h>
+#include <twin.h>
+#include <tdeconfig.h>
+#include <tdeglobal.h>
+#include <kdebug.h>
+#include <ksharedpixmap.h>
+#include <kpixmapio.h>
+#include <tdepopupmenu.h>
+#include <netwm.h>
+#include <tqcstring.h>
+#include <tqpixmap.h>
+#include <tqpainter.h>
+#include <tqdrawutil.h>
+#include <tqpoint.h>
+
+#include "desktop.h"
+#include "config.h"
+#include "windowdrag.h"
+
+Desktop::Desktop( int desk, TQString desktopName, TQWidget *parent, const char *name): TQWidget(parent,name)
+{
+ m_desk = desk;
+ m_name = desktopName;
+ m_bgSmallPixmap=0L;
+ m_bgCommonSmallPixmap=0L;
+ m_bgPixmap = 0L;
+ m_bgDirty=true;
+ m_grabWindows=false;
+ setAcceptDrops(TRUE);
+ setBackgroundMode(NoBackground);
+
+ if (m_desk==1) Desktop::m_windowPixmaps.setAutoDelete(true);
+ TDEConfig *cfg= TDEGlobal::config();
+ m_transparentMode=static_cast<WindowTransparentMode>
+ (cfg->readNumEntry("windowTransparentMode", c_defWindowTransparentMode));
+ resize(67, 50);
+}
+
+Desktop::~Desktop()
+{
+ delete m_bgPixmap;
+ delete m_bgSmallPixmap;
+}
+
+void Desktop::mouseMoveEvent( TQMouseEvent *ev )
+{
+ if ( !KPagerConfigDialog::m_windowDragging )
+ return;
+ if ( (ev->state() & Qt::LeftButton) == 0 )
+ return;
+ TQPoint p( ev->pos() - pressPos );
+ if ( p.manhattanLength() >= tqApp->startDragDistance() )
+ startDrag( pressPos );
+}
+
+void Desktop::mousePressEvent( TQMouseEvent * ev)
+{
+ bool showWindows= KPagerConfigDialog::m_showWindows;
+ if (ev->button()==Qt::LeftButton){
+ pressPos = ev->pos();
+ }
+ else if ((ev->button()==Qt::MidButton)&&(showWindows))
+ startDrag(ev->pos());
+ else if (ev->button()==Qt::RightButton) {
+ TQPoint pos;
+ KWin::WindowInfo *info = windowAtPosition(ev->pos(), &pos);
+ if ( info && showWindows )
+ pager()->showPopupMenu(info->win(), mapToGlobal(ev->pos()));
+ else
+ pager()->showPopupMenu(0, mapToGlobal(ev->pos()));
+ }
+}
+
+void Desktop::mouseReleaseEvent( TQMouseEvent *ev )
+{
+/** Note that mouseReleaseEvent is not called when releasing the mouse
+ to drop a window in this desktop */
+ if (ev->button()==Qt::LeftButton)
+ {
+ bool showWindows= KPagerConfigDialog::m_showWindows;
+ TQPoint pos;
+ KWin::setCurrentDesktop(m_desk);
+ if (showWindows)
+ {
+ KWin::WindowInfo *info = windowAtPosition(ev->pos(), &pos);
+ if (info)
+ {
+ KWin::forceActiveWindow(info->win());
+
+ // if ( static_cast<WindowDrawMode>( KPagerConfigDialog::m_windowDrawMode ) == Pixmap )
+ // m_windowPixmapsDirty.replace(info->win,true);
+ }
+ }
+ }
+}
+
+KWin::WindowInfo *Desktop::windowAtPosition(const TQPoint &p, TQPoint *internalpos)
+{
+ TQRect r;
+ const TQValueList<WId> &list(pager()->twin()->stackingOrder());
+ if (list.count() <= 0)
+ return 0L;
+
+ for (TQValueList<WId>::ConstIterator it = list.fromLast(); ; --it)
+ {
+ KWin::WindowInfo* info = pager()->info( *it );
+ if (shouldPaintWindow(info))
+ {
+ r=info->geometry();
+ convertRectS2P(r);
+ if (r.contains(p))
+ {
+ if (internalpos)
+ {
+ internalpos->setX(p.x()-r.x());
+ internalpos->setY(p.y()-r.y());
+ }
+ return info;
+ }
+ }
+
+ if (it == list.begin())
+ break;
+ }
+ return 0L;
+}
+
+void Desktop::convertRectS2P(TQRect &r)
+{
+ TQRect tmp(r);
+ r.setRect(deskX()+tmp.x()*deskWidth()/kapp->desktop()->width(),
+ deskY()+tmp.y()*deskHeight()/kapp->desktop()->height(),
+ tmp.width()*deskWidth()/kapp->desktop()->width(),
+ tmp.height()*deskHeight()/kapp->desktop()->height());
+}
+
+void Desktop::convertCoordP2S(int &x, int &y)
+{
+ x=(x-deskX())*(kapp->desktop()->width())/deskWidth();
+ y=(y-deskY())*(kapp->desktop()->height())/deskHeight();
+}
+
+TQPixmap scalePixmap(const TQPixmap &pixmap, int width, int height)
+{
+ if (pixmap.width()>100)
+ {
+ KPixmapIO io;
+ TQImage img(io.convertToImage(pixmap));
+ return io.convertToPixmap(img.smoothScale(width,height));
+ }
+
+ TQImage img(TQImage(pixmap.convertToImage()).smoothScale(width,height));
+ TQPixmap pix;
+ pix.convertFromImage(img);
+
+ return pix;
+}
+
+TQPixmap fastScalePixmap(const TQPixmap &pixmap, int width, int height)
+{
+ TQWMatrix m;
+ m.scale(width/(double)pixmap.width(),
+ height/(double)pixmap.height());
+ return pixmap.xForm(m);
+}
+
+void Desktop::loadBgPixmap(void)
+{
+ bool retval;
+
+// if (!m_bgDirty) return;
+ DCOPClient *client = kapp->dcopClient();
+ if (!client->isAttached())
+ client->attach();
+ TQByteArray data, data2, replyData;
+ TQCString replyType;
+ if (client->call("kdesktop", "KBackgroundIface", "isCommon()",
+ data, replyType, replyData))
+ {
+ TQDataStream reply(replyData, IO_ReadOnly);
+ if (replyType == "bool") {
+ reply >> m_isCommon;
+ }
+ }
+ if ( m_isCommon && m_desk!=1 ) return;
+
+/*
+ TQDataStream args2( data2, IO_WriteOnly );
+ args2 << m_desk-1 << 0 << 0 << -1 << -1 << 200 << 150 ;
+ if (client->call("kdesktop", "KBackgroundIface",
+ "wallpaper(int,int,int,int,int,int,int)", data2, replyType, replyData))
+ {
+ TQDataStream reply(replyData, IO_ReadOnly);
+ if (replyType == "TQPixmap") {
+ TQPixmap pixmap;
+ reply >> pixmap;
+ if (!pixmap.isNull())
+ {
+ kdDebug() << "getting small bg through dcop\n";
+ if (m_isCommon)
+ {
+ if (m_bgSmallPixmap) { delete m_bgSmallPixmap; m_bgSmallPixmap=0L; }
+
+ if (!m_bgCommonSmallPixmap) m_bgCommonSmallPixmap=new TQPixmap(pixmap);
+ else *m_bgCommonSmallPixmap=pixmap;
+ }
+ else
+ {
+ if (m_bgCommonSmallPixmap)
+ {
+ delete m_bgCommonSmallPixmap;
+ m_bgCommonSmallPixmap=0L;
+ }
+
+ if (!m_bgSmallPixmap) m_bgSmallPixmap=new TQPixmap(pixmap);
+ else *m_bgSmallPixmap=pixmap;
+ }
+ return;
+ }
+ }
+ }
+ kdDebug() << "getting whole bg through shpixmap\n";
+ */
+
+ if (!m_bgPixmap)
+ {
+ m_bgPixmap = new TDESharedPixmap;
+ connect(m_bgPixmap, TQT_SIGNAL(done(bool)), TQT_SLOT(backgroundLoaded(bool)));
+ }
+
+ retval = m_bgPixmap->loadFromShared(TQString("DESKTOP%1").arg(m_isCommon?1:m_desk));
+ if (retval == false) {
+ TQDataStream args( data, IO_WriteOnly );
+ args << 1; // Argument is 1 (true)
+ client->send("kdesktop", "KBackgroundIface", "setExport(int)", data);
+ retval = m_bgPixmap->loadFromShared(TQString("DESKTOP%1").arg(m_isCommon?1:m_desk));
+ }
+
+}
+
+void Desktop::paintWindow(TQPainter &p, const KWin::WindowInfo *info, bool onDesktop)
+{
+ switch (static_cast<WindowDrawMode>(KPagerConfigDialog::m_windowDrawMode ) )
+ {
+ case (Plain) : paintWindowPlain (p, info, onDesktop);break;
+ case (Icon) : paintWindowIcon (p, info, onDesktop);break;
+ case (Pixmap) : paintWindowPixmap(p, info, onDesktop);break;
+ }
+}
+
+TQPixmap *Desktop::paintNewWindow(const KWin::WindowInfo *info)
+{
+ TQRect r = info->frameGeometry();
+ int dw = TQApplication::desktop()->width();
+ int dh = TQApplication::desktop()->height();
+ r = TQRect( r.x() * width() / dw, 2 + r.y() * height() / dh,
+ r.width() * width() / dw, r.height() * height() / dh );
+ r.moveTopLeft(TQPoint(0,0));
+
+
+ TQPixmap *pixmap=new TQPixmap(r.width(),r.height());
+ TQPainter p;
+
+ p.begin(pixmap);
+ p.setFont(font());
+ p.fillRect( r, colorGroup().brush(TQColorGroup::Dark));
+ paintWindow(p, info, false);
+ p.end();
+
+ return pixmap;
+}
+
+void Desktop::startDrag(const TQPoint &p)
+{
+ TQPoint dragpos;
+ KWin::WindowInfo *info=windowAtPosition(p,&dragpos);
+ if ( (!info)/* || (info->state & NET::Max)*/ ) return;
+
+ TQPixmap *pixmap=paintNewWindow(info);
+
+ int deltax=dragpos.x();
+ int deltay=dragpos.y();
+ PagerWindowDrag *wdrag= new PagerWindowDrag( info->win(), deltax, deltay,
+ m_desk, this);
+ wdrag->setPixmap( *pixmap, TQPoint( deltax, deltay) );
+ delete pixmap;
+ wdrag->dragCopy();
+
+}
+
+void Desktop::dragEnterEvent(TQDragEnterEvent *ev)
+{
+ if (PagerWindowDrag::canDecode( ev )) ev->accept();
+}
+
+void Desktop::dragMoveEvent(TQDragMoveEvent *)
+{
+ // TODO Moving the window while dragging would be cool, wouldn't it ?
+ // Matthias: No, is way to slow on low end machines.
+ // Antonio:Ok, I'll make it configurable after 2.0 (it would add a string)
+}
+
+void Desktop::dropEvent(TQDropEvent *ev)
+{
+ WId win=0;
+ int deltax,deltay;
+ int origdesk;
+ if (!PagerWindowDrag::decode(ev,win,deltax,deltay,origdesk)) return;
+
+ int x=ev->pos().x()-deltax;
+ int y=ev->pos().y()-deltay;
+ /*
+ * x and y now contain the position (in local coordinates) which
+ * has the origin of the window
+ */
+ convertCoordP2S(x,y);
+
+// kdDebug() << "moving window " << win << "d from " << origdesk << " to " << m_desk << endl;
+// NETWinInfo NETinfo( tqt_xdisplay(), win, tqt_xrootwin(), NET::Client | NET::WMDesktop);
+
+ if (m_desk==0)
+ {
+ /*
+ * The next line moves the window to the active desktop. This is done
+ * because in other case, kwm raises the window when it's in a semi
+ * changed state and doesn't work well with kpager. Let's see how well
+ * KWin behaves.
+ * if (activedesktop!=KWM::desktop(w))
+ * KWM::moveToDesktop(w,activedesktop);
+ */
+// KWin::setState(win, NET::Sticky);
+ KWin::setOnAllDesktops(win, true);
+ }
+ else
+ {
+ if (origdesk==0) KWin::setOnAllDesktops(win, false);
+
+ KWin::WindowInfo *info = pager()->info(win);
+ if (!info->onAllDesktops())
+ KWin::setOnDesktop(win, m_desk);
+ }
+
+ XMoveWindow(x11Display(), win, x, y );
+}
+
+bool Desktop::shouldPaintWindow( KWin::WindowInfo *info )
+{
+ if (!info)
+ return false;
+
+// if (info->mappingState != NET::Visible)
+// return false;
+
+ NET::WindowType type = info->windowType( NET::NormalMask | NET::DesktopMask
+ | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask
+ | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask );
+ if (type == NET::Desktop || type == NET::Dock
+ || type == NET::TopMenu)
+ return false;
+
+ if (!info->isOnDesktop(m_desk))
+ return false;
+
+ if (info->state() & NET::SkipPager
+ || info->state() & NET::Shaded )
+ return false;
+
+ if (info->win() == pager()->winId())
+ return false;
+
+ if ( info->isMinimized() )
+ return false;
+
+ return true;
+}
+
+void Desktop::paintFrame(bool active)
+{
+ TQPainter p(this);
+
+ if ( active )
+ p.setPen(yellow);
+ else
+ p.setPen(TQColorGroup::Base);
+ p.drawRect(rect());
+ p.end();
+}
+
+void Desktop::paintEvent( TQPaintEvent * )
+{
+ TQPixmap pixmap(width(),height());
+ TQPainter p;
+
+ p.begin(&pixmap);
+// p.setFont(font());
+// p.fillRect(rect(), colorGroup().brush(TQColorGroup::Dark));
+// p.setPen(Qt::black);
+// p.drawRect(rect());
+
+ if (KPagerConfigDialog::m_showBackground )
+ {
+ if ( ( !m_isCommon && !m_bgSmallPixmap )
+ || (m_isCommon && !m_bgCommonSmallPixmap) )
+ loadBgPixmap();
+
+ if ( ( !m_isCommon && m_bgSmallPixmap && !m_bgSmallPixmap->isNull() )
+ || ( m_isCommon &&
+ m_bgCommonSmallPixmap && !m_bgCommonSmallPixmap->isNull() ) )
+ {
+ TQPixmap tmp;
+ if ( m_isCommon )
+ tmp=fastScalePixmap(*m_bgCommonSmallPixmap, width(),height());
+ else
+ tmp=fastScalePixmap(*m_bgSmallPixmap, width(),height());
+
+ p.drawPixmap(0,0,tmp);
+ }
+ else pixmap.fill(Qt::gray);
+ }
+ else
+ p.fillRect(rect(), colorGroup().brush(TQColorGroup::Mid));
+
+ // set in/active pen
+ if (isCurrent())
+ p.setPen(yellow);
+ else
+ p.setPen(TQColorGroup::Base);
+
+ // paint number & name
+ bool sname=KPagerConfigDialog::m_showName;
+ bool snumber=KPagerConfigDialog::m_showNumber;
+ if ( sname || snumber ) {
+ TQString txt;
+
+ // set font
+ if (sname) {
+ TQFont f(TDEGlobalSettings::generalFont().family(), 10, TQFont::Bold);
+ p.setFont(f);
+ }
+ else {
+ TQFont f(TDEGlobalSettings::generalFont().family(), 12, TQFont::Bold);
+ p.setFont(f);
+ }
+
+ // draw text
+ if ( sname && snumber )
+ txt=TQString("%1. %2").arg(m_desk).arg(pager()->twin()->desktopName( m_desk ));
+ else if ( sname )
+ txt=pager()->twin()->desktopName( m_desk );
+ else if ( snumber )
+ txt=TQString::number( m_desk );
+ p.drawText(2, 0, width()-4, height(), AlignCenter, txt );
+ }
+
+ // paint windows
+ if ( KPagerConfigDialog::m_showWindows ) {
+ TQValueList<WId>::ConstIterator it;
+ for ( it = pager()->twin()->stackingOrder().begin();
+ it != pager()->twin()->stackingOrder().end(); ++it ) {
+
+ KWin::WindowInfo* info = pager()->info( *it );
+
+ if (shouldPaintWindow(info))
+ paintWindow(p,info);
+ }
+ }
+
+ // paint border rectangle
+ p.drawRect(rect());
+ p.end();
+
+ // blit pixmap to widget
+ p.begin(this);
+ p.drawPixmap(0,0,pixmap);
+ p.end();
+
+ m_grabWindows=false;
+}
+
+void Desktop::paintWindowPlain(TQPainter &p, const KWin::WindowInfo *info, bool onDesktop)
+{
+ TQRect r = info->frameGeometry();
+ int dw = TQApplication::desktop()->width();
+ int dh = TQApplication::desktop()->height();
+ r = TQRect( r.x() * width() / dw, 2 + r.y() * height() / dh,
+ r.width() * width() / dw, r.height() * height() / dh );
+ if ( !onDesktop )
+ r.moveTopLeft(TQPoint(0,0));
+
+ bool isActive=(pager()->twin()->activeWindow() == info->win());
+
+ TQBrush brush;
+
+ if ( isActive ) brush=colorGroup().brush( TQColorGroup::Highlight );
+ else brush=colorGroup().brush( TQColorGroup::Button );
+
+ if ( m_transparentMode==AllWindows
+ || (m_transparentMode==MaximizedWindows && ( info->state() & NET::Max )) )
+ brush.setStyle(Qt::Dense4Pattern);
+
+ if ( isActive )
+ {
+ qDrawShadeRect( &p, r, colorGroup(), false, 1, 0, &brush );
+ }
+ else
+ {
+ p.fillRect( r, brush );
+ qDrawShadeRect( &p, r, colorGroup(), true, 1, 0 );
+ }
+
+}
+
+
+void Desktop::paintWindowIcon(TQPainter &p, const KWin::WindowInfo *info, bool onDesktop)
+{
+ TQRect r = info->frameGeometry();
+ int dw = TQApplication::desktop()->width();
+ int dh = TQApplication::desktop()->height();
+ r = TQRect( r.x() * width() / dw, 2 + r.y() * height() / dh,
+ r.width() * width() / dw, r.height() * height() / dh );
+ TQPixmap icon=KWin::icon( info->win(), int(r.width()*0.8),
+ int(r.height()*0.8), true);
+
+ NET::WindowType type = info->windowType( NET::NormalMask | NET::DesktopMask
+ | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask
+ | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask );
+ if ( icon.isNull() || type!=NET::Override )
+ paintWindowPlain(p,info,onDesktop);
+
+ if ( !onDesktop )
+ r.moveTopLeft(TQPoint(0,0));
+
+ p.drawPixmap( r.topLeft()+ TQPoint(int(r.width()*0.1),int(r.height()*0.1)),
+ icon );
+
+}
+
+void Desktop::paintWindowPixmap(TQPainter &p, const KWin::WindowInfo *info,
+ bool onDesktop)
+{
+ const int knDefaultPixmapWd = 100;
+ const int knDefaultPixmapHg = 75;
+ TQRect rSmall, r = info->frameGeometry();
+
+ int dw = TQApplication::desktop()->width();
+ int dh = TQApplication::desktop()->height();
+ rSmall = TQRect( r.x() * width() / dw, 2 + r.y() * height() / dh,
+ r.width() * width() / dw, r.height() * height() / dh );
+
+ TQPixmap *pixmap=m_windowPixmaps[info->win()];
+ bool isDirty=m_windowPixmapsDirty[info->win()];
+ if ( !pixmap || isDirty || m_grabWindows )
+ {
+ if ( isCurrent() )
+ {
+ TQPixmap tmp=TQPixmap::grabWindow(info->win(),
+ 0,0,r.width(),r.height());
+ if (!tmp.isNull() && tmp.width() > 0 && tmp.height() > 0)
+ {
+ tmp.setOptimization(TQPixmap::BestOptim);
+ int nWd, nHg;
+ if (rSmall.width() > knDefaultPixmapWd || rSmall.height() > knDefaultPixmapHg)
+ {
+ nWd = knDefaultPixmapWd;
+ nHg = knDefaultPixmapHg;
+ }
+ else
+ {
+ nWd = rSmall.width();
+ nHg = rSmall.height();
+ }
+ pixmap=new TQPixmap(fastScalePixmap(tmp, nWd, nHg));
+ m_windowPixmaps.replace(info->win(),pixmap);
+ m_windowPixmapsDirty.replace(info->win(),false);
+ }
+ }
+
+ // It was impossible to get the pixmap, let's fallback to the icon mode.
+ if ( !pixmap || pixmap->isNull() )
+ {
+ paintWindowIcon(p, info, onDesktop);
+ return;
+ }
+
+ }
+
+ if ( !onDesktop )
+ rSmall.moveTopLeft(TQPoint(0,0));
+
+ if (rSmall.width() != pixmap->width() || rSmall.height() != pixmap->height())
+ {
+ TQPixmap pixmapSmall(fastScalePixmap(*pixmap,rSmall.width(),rSmall.height()));
+ p.drawPixmap( rSmall.topLeft(), pixmapSmall );
+ }
+ else
+ {
+ p.drawPixmap( rSmall.topLeft(), *pixmap);
+ }
+
+}
+
+KPager *Desktop::pager() const
+{
+ return reinterpret_cast<KPager *>(parent());
+}
+
+bool Desktop::isCurrent() const
+{
+ return pager()->twin()->currentDesktop()==m_desk;
+}
+
+void Desktop::backgroundLoaded(bool b)
+{
+ if (b)
+ {
+ if (m_isCommon)
+ {
+ if (m_bgSmallPixmap) { delete m_bgSmallPixmap; m_bgSmallPixmap=0L ; };
+
+ if (!m_bgCommonSmallPixmap) m_bgCommonSmallPixmap=new TQPixmap;
+ *m_bgCommonSmallPixmap=scalePixmap(*m_bgPixmap,200,150);
+ }
+ else
+ {
+ if (m_bgCommonSmallPixmap) { delete m_bgCommonSmallPixmap;
+ m_bgCommonSmallPixmap=0L ; };
+
+ if (!m_bgSmallPixmap) m_bgSmallPixmap=new TQPixmap;
+ *m_bgSmallPixmap=fastScalePixmap(*m_bgPixmap,200,150);
+ }
+ delete m_bgPixmap;
+ m_bgPixmap=0L;
+
+
+ if (m_isCommon) pager()->redrawDesktops();
+ else update();
+ } else kdDebug() << "Error getting the background\n";
+}
+
+TQSize Desktop::sizeHint() const
+{
+ return TQSize(67,50);
+}
+
+TQPixmap *Desktop::m_bgCommonSmallPixmap=0L;
+bool Desktop::m_isCommon=false;
+TQIntDict<TQPixmap> Desktop::m_windowPixmaps;
+TQMap<int,bool> Desktop::m_windowPixmapsDirty;
+
+// Default Configuration -------------------------------------------------
+
+const bool Desktop::c_defShowName=false;
+const bool Desktop::c_defShowNumber=false;
+const bool Desktop::c_defShowWindows=true;
+const bool Desktop::c_defShowBackground=true;
+const bool Desktop::c_defWindowDragging=true;
+const Desktop::WindowDrawMode Desktop::c_defWindowDrawMode=Desktop::Icon;
+const Desktop::WindowTransparentMode
+ Desktop::c_defWindowTransparentMode=Desktop::AllWindows;
+#include "desktop.moc"
diff --git a/kpager/desktop.h b/kpager/desktop.h
new file mode 100644
index 000000000..cff05594a
--- /dev/null
+++ b/kpager/desktop.h
@@ -0,0 +1,130 @@
+/**************************************************************************
+
+ desktop.h - KPager's desktop
+ Copyright (C) 2000 Antonio Larrosa Jimenez
+ Matthias Ettrich
+ Matthias Elter
+
+ 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.
+
+ Send comments and bug fixes to [email protected]
+
+***************************************************************************/
+#ifndef __DESKTOP_H
+#define __DESKTOP_H
+
+#include <tqwidget.h>
+#include <tqintdict.h>
+#include <twin.h>
+
+class TDESharedPixmap;
+class TDEPopupMenu;
+
+class TQPainter;
+class TQPoint;
+
+class Desktop : public TQWidget
+{
+ Q_OBJECT
+
+public:
+ Desktop( int desk, TQString desktopName, TQWidget *parent=0,
+ const char *name=0);
+ ~Desktop();
+
+ int id() const { return m_desk; };
+ bool isCurrent() const;
+
+// int widthForHeight(int height) const;
+// int heightForWidth(int width) const;
+
+ static const bool c_defShowName;
+ static const bool c_defShowNumber;
+ static const bool c_defShowBackground;
+ static const bool c_defShowWindows;
+ static const bool c_defWindowDragging;
+ enum WindowDrawMode { Plain=0, Icon=1, Pixmap=2 };
+ enum WindowTransparentMode { NoWindows=0, MaximizedWindows=1, AllWindows=2};
+ static const WindowDrawMode c_defWindowDrawMode;
+ static const WindowTransparentMode c_defWindowTransparentMode;
+
+ virtual int deskX() const { return 0; };
+ virtual int deskY() const { return 0; };
+ virtual int deskWidth() const { return width(); };
+ virtual int deskHeight() const { return height(); };
+
+ void startDrag(const TQPoint &point);
+ void dragEnterEvent(TQDragEnterEvent *ev);
+ void dragMoveEvent(TQDragMoveEvent *);
+ void dropEvent(TQDropEvent *ev);
+ void convertRectS2P(TQRect &r);
+ void convertCoordP2S(int &x, int &y);
+
+ static void removeCachedPixmap(int nWin) { m_windowPixmaps.remove(nWin); };
+
+ TQSize sizeHint() const;
+
+ /**
+ * active is a bool that specifies if the frame is the active
+ * one or not (so that it's painted highlighted or not)
+ */
+ void paintFrame(bool active);
+
+ bool m_grabWindows;
+public slots:
+ void backgroundLoaded(bool b);
+
+ void loadBgPixmap();
+
+protected:
+ void mousePressEvent( TQMouseEvent *ev );
+ void mouseMoveEvent( TQMouseEvent *ev );
+ void mouseReleaseEvent( TQMouseEvent *ev );
+
+ void paintEvent( TQPaintEvent *ev );
+
+ KWin::WindowInfo *windowAtPosition (const TQPoint &p, TQPoint *internalpos);
+
+ bool shouldPaintWindow( KWin::WindowInfo *info );
+
+ int m_desk;
+ TQString m_name;
+ TDESharedPixmap *m_bgPixmap;
+ bool m_bgDirty;
+ TQPixmap *m_bgSmallPixmap;
+ static TQPixmap *m_bgCommonSmallPixmap;
+ static bool m_isCommon;
+ static TQIntDict<TQPixmap> m_windowPixmaps;
+ static TQMap<int,bool> m_windowPixmapsDirty;
+ WindowTransparentMode m_transparentMode;
+
+ TQPixmap *paintNewWindow(const KWin::WindowInfo *info);
+
+ void paintWindow(TQPainter &p, const KWin::WindowInfo *info,
+ bool onDesktop=true);
+ void paintWindowPlain(TQPainter &p, const KWin::WindowInfo *info,
+ bool onDesktop=true);
+ void paintWindowIcon(TQPainter &p, const KWin::WindowInfo *info,
+ bool onDesktop=true);
+ void paintWindowPixmap(TQPainter &p, const KWin::WindowInfo *info,
+ bool onDesktop=true);
+
+private:
+ class KPager* pager() const;
+ TQPoint pressPos;
+
+};
+
+#endif
diff --git a/kpager/hi16-app-kpager.png b/kpager/hi16-app-kpager.png
new file mode 100644
index 000000000..b58c33643
--- /dev/null
+++ b/kpager/hi16-app-kpager.png
Binary files differ
diff --git a/kpager/hi22-app-kpager.png b/kpager/hi22-app-kpager.png
new file mode 100644
index 000000000..f549d927b
--- /dev/null
+++ b/kpager/hi22-app-kpager.png
Binary files differ
diff --git a/kpager/hi32-app-kpager.png b/kpager/hi32-app-kpager.png
new file mode 100644
index 000000000..00e5c0c26
--- /dev/null
+++ b/kpager/hi32-app-kpager.png
Binary files differ
diff --git a/kpager/hi48-app-kpager.png b/kpager/hi48-app-kpager.png
new file mode 100644
index 000000000..529954009
--- /dev/null
+++ b/kpager/hi48-app-kpager.png
Binary files differ
diff --git a/kpager/kpager.cpp b/kpager/kpager.cpp
new file mode 100644
index 000000000..4775576ee
--- /dev/null
+++ b/kpager/kpager.cpp
@@ -0,0 +1,674 @@
+/**************************************************************************
+
+ kpager.cpp - KPager's main window
+ Copyright (C) 2000 Antonio Larrosa Jimenez
+ Matthias Ettrich
+ Matthias Elter
+
+ 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.
+
+ Send comments and bug fixes to [email protected]
+
+***************************************************************************/
+
+/*
+ * There is a features that is only configurable by manually editing the
+ * config file due to the translation freeze . The key is
+ * windowTransparentMode and the values are :
+ * 0 = Never
+ * 1 = Only maximized windows are painted transparent
+ * 2 = Every window is painted transparent (default)
+ *
+ */
+
+#include "config.h"
+#include "kpager.h"
+
+#include <tqintdict.h>
+#include <tqptrlist.h>
+#include <tqlayout.h>
+#include <tqtooltip.h>
+#include <tqtimer.h>
+
+#include <tdeapplication.h>
+#include <tdeglobalsettings.h>
+#include <tdeaction.h>
+#include <kstdaction.h>
+#include <tdeglobal.h>
+#include <tdeconfig.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <twin.h>
+#include <twinmodule.h>
+#include <netwm.h>
+#include "desktop.h"
+#include <tqpopupmenu.h>
+#include <tdepopupmenu.h>
+#include <kiconloader.h>
+#include <assert.h>
+
+KPagerMainWindow::KPagerMainWindow(TQWidget *parent, const char *name)
+ : DCOPObject("KPagerIface"), TDEMainWindow(parent, name)
+{
+ m_reallyClose=false;
+
+ m_pPager = new KPager(this, 0);
+ setCentralWidget(m_pPager);
+
+ TDEConfig *cfg = kapp->config();
+ cfg->setGroup("KPager");
+
+ // Update the last used geometry
+ int w = cfg->readNumEntry(m_pPager->lWidth(),-1);
+ int h = cfg->readNumEntry(m_pPager->lHeight(),-1);
+ if (w > 0 && h > 0)
+ resize(w,h);
+ else
+ resize(m_pPager->sizeHint());
+ // resize(cfg->readNumEntry(lWidth(),200),cfg->readNumEntry(lHeight(),90));
+
+ int xpos=cfg->readNumEntry("xPos",-1);
+ int ypos=cfg->readNumEntry("yPos",-1);
+ if (xpos > 0 && ypos > 0)
+ move(xpos,ypos);
+ else
+ {
+// NETRootInfo ri( tqt_xdisplay(), NET::WorkArea );
+// NETRect rect=ri.workArea(1);
+// move(rect.pos.x+rect.size.width-m_pPager->width(),
+// rect.pos.y+rect.size.height-m_pPager->height());
+// antonio:The above lines don't work. I should look at them when I have
+// more time
+ move(kapp->desktop()->width()-m_pPager->sizeHint().width()-5,kapp->desktop()->height()-m_pPager->sizeHint().height()-25);
+ }
+
+ // Set the wm flags to this window
+ KWin::setState( winId(), NET::StaysOnTop | NET::SkipTaskbar | NET::Sticky | NET::SkipPager );
+ KWin::setOnAllDesktops( winId(), true);
+ if ( KWin::windowInfo( winId(), NET::WMWindowType, 0 ).windowType(NET::Normal) == NET::Normal )
+ {
+ KWin::setType( winId(), NET::Utility );
+ }
+
+ XWMHints *hints = XGetWMHints(x11Display(), winId());
+ if( hints == NULL )
+ hints = XAllocWMHints();
+ hints->input = false;
+ hints->flags |= InputHint;
+ XSetWMHints(x11Display(), winId(), hints);
+ XFree(reinterpret_cast<char *>(hints));
+
+ timeout=new TQTimer(this,"timeoutToQuit");
+ connect(timeout,TQT_SIGNAL(timeout()),this, TQT_SLOT(reallyClose()));
+}
+
+KPagerMainWindow::~KPagerMainWindow()
+{
+}
+
+extern bool closed_by_sm;
+
+bool KPagerMainWindow::queryClose()
+{
+ TDEConfig *cfg=TDEGlobal::config();
+
+ cfg->setGroup("KPager");
+ cfg->writeEntry("layoutType", static_cast<int>(m_pPager->m_layoutType));
+ cfg->writeEntry(m_pPager->lWidth(),width());
+ cfg->writeEntry(m_pPager->lHeight(),height());
+ cfg->writeEntry("xPos",x());
+ cfg->writeEntry("yPos",y());
+ cfg->sync();
+
+ kdDebug() << "queryCLose " << m_reallyClose << " " << closed_by_sm << endl;
+ if (m_reallyClose || closed_by_sm) return true;
+
+ hide();
+ timeout->start(10 /*minutes*/ *60000, true);
+
+ return false;
+}
+
+void KPagerMainWindow::showEvent( TQShowEvent *ev )
+{
+ timeout->stop();
+ TDEMainWindow::showEvent(ev);
+}
+
+void KPagerMainWindow::reallyClose()
+{
+ m_reallyClose=true;
+ close();
+}
+
+void KPagerMainWindow::showAt(int x, int y)
+{
+ // Just in case we lost the sticky bit... (as when a window is hidden)
+ KWin::setOnAllDesktops( winId(), true);
+
+ if (x>kapp->desktop()->width()/2) // Right
+ x-=m_pPager->width()+5;
+ if (y>kapp->desktop()->height()/2) // Bottom
+ y-=m_pPager->height()+25;
+ move(x,y);
+ show();
+}
+
+void KPagerMainWindow::toggleShow(int x, int y)
+{
+ if (isVisible())
+ {
+ hide();
+ timeout->start(10 /*minutes*/ *60000, true);
+ }
+ else
+ showAt(x,y);
+}
+
+KPager::KPager(KPagerMainWindow *parent, const char *name)
+ : TQFrame (parent, name, (WFlags)(WStyle_Customize | WStyle_NoBorder | WStyle_Tool))
+ , m_layout(0)
+ , m_mnu(0)
+ , m_smnu(0)
+ , m_dmnu(0)
+{
+ m_windows.setAutoDelete(true); // delete windows info after removal
+
+ setBackgroundColor( black );
+ m_winmodule=new KWinModule(TQT_TQOBJECT(this));
+ m_currentDesktop=m_winmodule->currentDesktop();
+
+ m_grabWinTimer=new TQTimer(this,"grabWinTimer");
+ connect(m_grabWinTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotGrabWindows()));
+
+ KPagerConfigDialog::initConfiguration();
+
+ TDEConfig *cfg = kapp->config();
+ cfg->setGroup("KPager");
+ m_showStickyOption=cfg->readBoolEntry("ShowStickyOption",false);
+
+ int numberOfDesktops=m_winmodule->numberOfDesktops();
+ for (int i=0;i<numberOfDesktops;i++)
+ {
+ Desktop *dsk=new Desktop(i+1,m_winmodule->desktopName(i),this);
+ m_desktops.append(dsk);
+ }
+
+ m_layoutType=static_cast<enum KPager::LayoutTypes>( KPagerConfigDialog::m_layoutType );
+
+ connect( m_winmodule, TQT_SIGNAL( activeWindowChanged(WId)),
+ TQT_SLOT(slotActiveWindowChanged(WId)));
+ connect( m_winmodule, TQT_SIGNAL( windowAdded(WId) ),
+ TQT_SLOT( slotWindowAdded(WId) ) );
+ connect( m_winmodule, TQT_SIGNAL( windowRemoved(WId) ),
+ TQT_SLOT( slotWindowRemoved(WId) ) );
+ connect( m_winmodule, TQT_SIGNAL( windowChanged(WId,unsigned int) ),
+ TQT_SLOT( slotWindowChanged(WId,unsigned int) ) );
+ connect( m_winmodule, TQT_SIGNAL( stackingOrderChanged() ),
+ TQT_SLOT( slotStackingOrderChanged() ) );
+ connect( m_winmodule, TQT_SIGNAL( desktopNamesChanged() ),
+ TQT_SLOT( slotDesktopNamesChanged() ) );
+ connect( m_winmodule, TQT_SIGNAL( numberOfDesktopsChanged(int) ),
+ TQT_SLOT( slotNumberOfDesktopsChanged(int) ) );
+ connect( m_winmodule, TQT_SIGNAL( currentDesktopChanged(int)),
+ TQT_SLOT( slotCurrentDesktopChanged(int) ) );
+ connect(kapp, TQT_SIGNAL(backgroundChanged(int)),
+ TQT_SLOT(slotBackgroundChanged(int)));
+
+ TQFont defFont(TDEGlobalSettings::generalFont().family(), 10, TQFont::Bold);
+ defFont = cfg->readFontEntry("Font", &defFont);
+ setFont(defFont);
+
+ m_prefs_action = KStdAction::preferences(TQT_TQOBJECT(this), TQT_SLOT(configureDialog()), parent->actionCollection());
+ m_quit_action = KStdAction::quit(TQT_TQOBJECT(kapp), TQT_SLOT(quit()), parent->actionCollection());
+
+ updateLayout();
+}
+
+KPager::~KPager()
+{
+
+}
+
+const TQString KPager::lWidth()
+{
+ switch (m_layoutType) {
+ case (Classical) : return "layoutClassicalWidth";break;
+ case (Horizontal) : return "layoutHorizontalWidth";break;
+ case (Vertical) : return "layoutVerticalWidth";break;
+ };
+ return "Width";
+}
+
+const TQString KPager::lHeight()
+{
+ switch (m_layoutType) {
+ case (Classical) : return "layoutClassicalHeight";break;
+ case (Horizontal) : return "layoutHorizontalHeight";break;
+ case (Vertical) : return "layoutVerticalHeight";break;
+ };
+ return "Height";
+}
+
+void KPager::updateLayout()
+{
+ int w=m_desktops[0]->width();
+ int h=m_desktops[0]->height();
+
+ delete m_layout;
+
+ switch (m_layoutType)
+ {
+ case (Classical) : m_layout=new TQGridLayout(this, 2, 0); break;
+ case (Horizontal) : m_layout=new TQGridLayout(this, 0, 1); break;
+ case (Vertical) : m_layout=new TQGridLayout(this, 1, 0); break;
+ };
+
+ TQValueList <Desktop *>::Iterator it;
+ int i,j;
+ i=j=0;
+ int ndesks=0;
+ int halfdesks = (m_desktops.count() + 1) / 2;
+ for( it = m_desktops.begin(); it != m_desktops.end(); ++it )
+ {
+ m_layout->addWidget(*it,i,j);
+ ndesks++;
+ switch (m_layoutType)
+ {
+ case (Classical) : i= ndesks / halfdesks; j = ndesks % halfdesks; break;
+ case (Horizontal) : j++; break;
+ case (Vertical) : i++; break;
+ };
+ }
+
+ m_layout->activate();
+ updateGeometry();
+
+ switch (m_layoutType)
+ {
+ case (Classical) : resize(w*(ndesks/2+(ndesks%2)),h*2);break;
+ case (Horizontal) : resize(w*ndesks,h);break;
+ case (Vertical) : resize(w, h*ndesks);break;
+ };
+
+}
+
+void KPager::showPopupMenu( WId wid, TQPoint pos)
+{
+ if (wid <= 0) {
+ if(!m_smnu) {
+ m_smnu = new TQPopupMenu(this);
+ m_prefs_action->plug(m_smnu);
+ m_quit_action->plug(m_smnu);
+ }
+ m_smnu->popup(pos);
+ }
+ else {
+ m_winfo = KWin::windowInfo(wid);
+
+ if (!m_mnu) {
+ m_mnu = new TDEPopupMenu(this);
+
+ m_mnu->insertTitle( TQString::fromUtf8("KPager"), 1);
+ m_mnu->setCheckable(true);
+ connect(m_mnu, TQT_SIGNAL(aboutToShow()), TQT_SLOT(clientPopupAboutToShow()));
+ connect(m_mnu, TQT_SIGNAL(activated(int)), TQT_SLOT(clientPopupActivated(int)));
+
+ m_dmnu = new TQPopupMenu(m_mnu);
+ m_dmnu->setCheckable(true);
+ connect(m_dmnu, TQT_SIGNAL(aboutToShow()), TQT_SLOT(desktopPopupAboutToShow()));
+ connect(m_dmnu, TQT_SIGNAL(activated(int)), TQT_SLOT(sendToDesktop(int)));
+
+ m_mnu->insertItem( i18n("Mi&nimize"), IconifyOp );
+ m_mnu->insertItem( i18n("Ma&ximize"), MaximizeOp );
+ if (m_showStickyOption)
+ m_mnu->insertItem( TQString("&Sticky"), StickyOp ); // Add translation
+ m_mnu->insertSeparator();
+
+ m_mnu->insertItem(i18n("&To Desktop"), m_dmnu );
+ m_mnu->insertSeparator();
+
+ m_mnu->insertItem(SmallIcon("window-close"),i18n("&Close"), CloseOp);
+
+ m_mnu->insertSeparator();
+ m_prefs_action->plug(m_mnu);
+ m_quit_action->plug(m_mnu);
+ }
+ m_mnu->popup(pos);
+ }
+}
+
+void KPager::configureDialog()
+{
+ KPagerConfigDialog *dialog= new KPagerConfigDialog(this);
+ if (dialog->exec())
+ {
+ m_layoutType=static_cast<enum KPager::LayoutTypes>(KPagerConfigDialog::m_layoutType);
+ TDEConfig *cfg=TDEGlobal::config();
+ int nWd = (parent() ? ((TQWidget *)parent())->width() : width());
+ int nHg = (parent() ? ((TQWidget *)parent())->width() : width());
+
+ cfg->setGroup("KPager");
+
+ cfg->writeEntry(lWidth(),nWd);
+ cfg->writeEntry(lHeight(),nHg);
+ cfg->writeEntry("windowDrawMode",KPagerConfigDialog::m_windowDrawMode);
+ cfg->writeEntry("layoutType",KPagerConfigDialog::m_layoutType);
+ cfg->writeEntry("showNumber",KPagerConfigDialog::m_showNumber);
+ cfg->writeEntry("showName",KPagerConfigDialog::m_showName);
+ cfg->writeEntry("showWindows",KPagerConfigDialog::m_showWindows);
+ cfg->writeEntry("showBackground",KPagerConfigDialog::m_showBackground);
+ cfg->writeEntry("windowDragging",KPagerConfigDialog::m_windowDragging);
+
+ updateLayout();
+ for( TQValueList <Desktop *>::Iterator it = m_desktops.begin(); it != m_desktops.end(); ++it )
+ (*it)->repaint();
+ }
+}
+
+KWin::WindowInfo* KPager::info( WId win )
+{
+ KWin::WindowInfo* info = m_windows[win];
+ if (!info )
+ {
+ info = new KWin::WindowInfo( KWin::windowInfo( win ) );
+ if( !info->valid() || info->desktop() == 0 )
+ {
+ delete info;
+ return NULL; // window no longer valid
+ }
+ m_windows.insert( (long) win, info );
+ }
+ return info;
+}
+
+void KPager::slotActiveWindowChanged( WId win )
+{
+ KWin::WindowInfo* inf1 = info( m_activeWin );
+ KWin::WindowInfo* inf2 = info( win );
+ m_activeWin = win;
+
+ // update window pixmap
+ // in case of active desktop change it will be updated anyway by timer
+// if (!m_grabWinTimer->isActive())
+// Desktop::removeCachedPixmap(win);
+
+ for ( int i=1; i <= (int) m_desktops.count(); ++i)
+ {
+ if ( (inf1 && inf1->isOnDesktop(i))
+ || (inf2 && inf2->isOnDesktop(i) ) )
+ m_desktops[i-1]->repaint(false);
+ }
+}
+
+void KPager::slotWindowAdded( WId win)
+{
+ KWin::WindowInfo* inf = info( win );
+ if (!inf)
+ return; // never should be here
+
+ for ( int i=1; i <= (int) m_desktops.count(); ++i)
+ {
+ if ( inf->isOnDesktop( i ))
+ m_desktops[i-1]->repaint(false);
+ }
+}
+
+void KPager::slotWindowRemoved( WId win )
+{
+ KWin::WindowInfo* inf = m_windows[win];
+ if (inf)
+ {
+ bool onAllDesktops = inf->onAllDesktops();
+ int desktop = inf->desktop();
+ m_windows.remove( (long)win );
+ Desktop::removeCachedPixmap(win);
+ for (int i = 1; i <= (int) m_desktops.count(); ++i)
+ {
+ if (onAllDesktops || desktop == i)
+ m_desktops[i-1]->repaint(false);
+ }
+ }
+}
+
+void KPager::slotWindowChanged( WId win , unsigned int prop)
+{
+ bool repaint=false;
+
+ KWin::WindowInfo* inf = m_windows[win];
+ if (!inf)
+ {
+ inf=info(win);
+ prop=0; // info already calls KWin::info, so there's no need
+ // to update anything else.
+ repaint=true;
+ };
+
+ bool onAllDesktops = inf ? inf->onAllDesktops() : false;
+ int desktop = inf ? inf->desktop() : 0;
+
+ if (prop)
+ {
+ m_windows.remove( (long) win );
+ inf = info( win );
+ }
+
+ if((prop & ~( NET::WMName | NET::WMVisibleName )) != 0 )
+ repaint = true;
+
+ if (repaint)
+ for ( int i=1; i <= (int) m_desktops.count(); ++i)
+ {
+ if ((inf && (inf->isOnDesktop(i)))
+ || onAllDesktops || desktop == i )
+ {
+ m_desktops[i-1]->repaint(false);
+ }
+ }
+// redrawDesktops();
+}
+
+void KPager::slotStackingOrderChanged()
+{
+ m_desktops[m_currentDesktop-1]->m_grabWindows=true;
+ for ( int i=1; i <= (int) m_desktops.count(); ++i)
+ {
+ m_desktops[i-1]->repaint(false);
+ }
+// repaint(true);
+}
+
+void KPager::slotDesktopNamesChanged()
+{
+ for ( int i=1; i <= (int) m_desktops.count(); ++i)
+ {
+ TQToolTip::remove(m_desktops[i-1]);
+ TQToolTip::add(m_desktops[i-1], twin()->desktopName(i));
+ }
+
+ update();
+ emit updateLayout();
+}
+
+void KPager::slotNumberOfDesktopsChanged(int ndesktops)
+{
+ unsigned int nDesktops=static_cast<unsigned int>(ndesktops);
+ if (nDesktops<m_desktops.count())
+ {
+ TQValueList <Desktop *>::Iterator it;
+ for ( int i=m_desktops.count()-nDesktops; i > 0; i--)
+ {
+ it = m_desktops.fromLast();
+ delete (*it);
+ m_desktops.remove(it);
+ }
+
+ emit updateLayout();
+ }
+ else if (nDesktops>m_desktops.count())
+ {
+ int i,j;
+ i=j=m_desktops.count();
+ switch (m_layoutType)
+ {
+ case (Classical) : i%=2;j/=2; break;
+ case (Horizontal) : i=0; break;
+ case (Vertical) : j=0; break;
+ }
+
+ for (unsigned int d=m_desktops.count()+1;d<=nDesktops; d++)
+ {
+ Desktop *dsk=new Desktop(d,twin()->desktopName(d-1),this);
+ m_desktops.append(dsk);
+ dsk->show();
+ }
+
+ emit updateLayout();
+ }
+}
+
+
+void KPager::slotCurrentDesktopChanged(int desk)
+{
+ if (m_currentDesktop==desk) return;
+ m_desktops[m_currentDesktop-1]->paintFrame( false );
+ m_desktops[m_currentDesktop-1]->update();
+ m_desktops[desk-1]->paintFrame( true );
+ m_desktops[desk-1]->update();
+// m_desktops[m_currentDesktop-1]->repaint();
+// m_desktops[desk-1]->repaint();
+
+ m_currentDesktop=desk;
+
+ if (m_grabWinTimer->isActive()) m_grabWinTimer->stop();
+
+ if ( static_cast<Desktop::WindowDrawMode>( KPagerConfigDialog::m_windowDrawMode ) == Desktop::Pixmap )
+ m_grabWinTimer->start(1000,true);
+}
+
+void KPager::slotBackgroundChanged(int desk)
+{
+ m_desktops[desk-1]->loadBgPixmap();
+}
+
+void KPager::sendToDesktop(int desk)
+{
+ if (desk == 0)
+ KWin::setOnAllDesktops(m_winfo.win(), true);
+ else {
+ KWin::setOnDesktop(m_winfo.win(), desk);
+ }
+}
+
+void KPager::clientPopupAboutToShow()
+{
+ if (!m_mnu) return;
+
+ m_mnu->changeTitle(1,KWin::icon(m_winfo.win(),16,16,true), m_winfo.name());
+ m_mnu->setItemChecked(IconifyOp, m_winfo.isMinimized());
+ m_mnu->setItemChecked(MaximizeOp, m_winfo.state() & NET::Max);
+ if (m_showStickyOption) // Add translation
+ m_mnu->changeItem(StickyOp,
+ (m_winfo.onAllDesktops()) ? TQString("Un&sticky"):TQString("&Sticky"));
+}
+
+void KPager::desktopPopupAboutToShow()
+{
+ if (!m_dmnu) return;
+
+ m_dmnu->clear();
+ m_dmnu->insertItem( i18n("&All Desktops"), 0 );
+ m_dmnu->insertSeparator();
+
+ if (m_winfo.onAllDesktops())
+ m_dmnu->setItemChecked( 0, true );
+
+ int id;
+ for ( int i = 1; i <= m_winmodule->numberOfDesktops(); i++ ) {
+ id = m_dmnu->insertItem( TQString("&")+TQString::number(i )+TQString(" ")
+ + m_winmodule->desktopName(i), i );
+ if ( m_winfo.desktop() == i )
+ m_dmnu->setItemChecked( id, TRUE );
+ }
+}
+
+void KPager::clientPopupActivated( int id )
+{
+ switch ( id ) {
+ case MaximizeOp:
+ if ( (m_winfo.state() & NET::Max) == 0 ) {
+ NETWinInfo ni( tqt_xdisplay(), m_winfo.win(), tqt_xrootwin(), 0);
+ ni.setState( NET::Max, NET::Max );
+ } else {
+ NETWinInfo ni( tqt_xdisplay(), m_winfo.win(), tqt_xrootwin(), 0);
+ ni.setState( 0, NET::Max );
+ }
+ break;
+ case IconifyOp:
+ if ( !m_winfo.isMinimized() ) {
+ KWin::iconifyWindow( m_winfo.win());
+ } else {
+ KWin::forceActiveWindow( m_winfo.win() );
+ }
+ break;
+ case StickyOp:
+ if ( m_winfo.onAllDesktops() ) {
+ KWin::setOnAllDesktops(m_winfo.win(), false);
+ } else {
+ KWin::setOnAllDesktops(m_winfo.win(), true);
+ }
+ break;
+ case CloseOp: {
+ NETRootInfo ri( tqt_xdisplay(), 0 );
+ ri.closeWindowRequest( m_winfo.win() );
+ } break;
+ default:
+ break;
+ }
+}
+
+void KPager::redrawDesktops()
+{
+ TQValueList <Desktop *>::Iterator it;
+ for( it = m_desktops.begin(); it != m_desktops.end(); ++it )
+ (*it)->repaint();
+}
+
+void KPager::slotGrabWindows()
+{
+ m_desktops[m_currentDesktop-1]->m_grabWindows=true;
+ m_desktops[m_currentDesktop-1]->repaint();
+}
+
+TQSize KPager::sizeHint() const
+{
+ int n=m_desktops.count();
+ int w=-1,h=-1;
+
+ TQSize size=m_desktops[0]->sizeHint();
+ int wDsk=size.width();
+ int hDsk=size.height();
+ switch (m_layoutType)
+ {
+ case (Classical) : w=wDsk*(n/2+(n%2)); h=hDsk*2;break;
+ case (Horizontal) : w=wDsk*n; h=hDsk;break;
+ case (Vertical) : w=wDsk; h=hDsk*n;break;
+ };
+ return TQSize(w,h);
+}
+
+const KPager::LayoutTypes KPager::c_defLayout=KPager::Horizontal;
+
+#include "kpager.moc"
diff --git a/kpager/kpager.desktop b/kpager/kpager.desktop
new file mode 100644
index 000000000..5e3ffb277
--- /dev/null
+++ b/kpager/kpager.desktop
@@ -0,0 +1,106 @@
+[Desktop Entry]
+Name=KPager
+Name[cy]=KSwnyn
+Name[eo]=Paĝilo
+Name[hi]=के-पेजर
+Name[ko]=호출기
+Name[lo]=ຕົວຮງກພື້ນທີ່ທຳງານ - K
+Name[lv]=KPeidžers
+Name[mk]=КПејџер
+Name[ne]=के पेजर
+Name[nso]=KSephetli
+Name[pa]=ਕੇਪੇਜਰ
+Name[ro]=Paginator
+Name[rw]=K-Paja
+Name[sv]=Kpager
+Name[te]=కెపేజర్
+Name[tg]=KПейҷер
+Name[th]=เปลี่ยนพื้นที่ทำงาน
+Name[tr]=TDE Sayfalayıcı
+Name[ven]=Pheidzha ya K
+Name[wa]=KPådjeu
+GenericName=Desktop Pager
+GenericName[af]=Werkskerm Boodskapper
+GenericName[ar]=Pager لسطح المكتب
+GenericName[be]=Пэйджар для працоўнага стала
+GenericName[bg]=Пейджър на работните плотове
+GenericName[bn]=ডেস্কটপ পেজার
+GenericName[br]=Pajenner ar Burev
+GenericName[bs]=Promjena radne površine
+GenericName[ca]=Paginador de l'escriptori
+GenericName[cs]=Přepínač ploch
+GenericName[csb]=Przestôwnik pùltów
+GenericName[cy]=Swnyn Penbwrdd
+GenericName[da]=desktop-skifter
+GenericName[de]=Umschalten zwischen Arbeitsflächen
+GenericName[el]=Αλλαγή Επιφάνειας Εργασίας
+GenericName[eo]=Tabula paĝilo
+GenericName[es]=Paginador del escritorio
+GenericName[et]=Töölaua peiler
+GenericName[eu]=Mahaigaineko orrialdekatzailea
+GenericName[fa]=پی‌جوی رومیزی
+GenericName[fi]=Työpöydänvaihtotyökalu
+GenericName[fr]=Gestionnaire de bureaux virtuels
+GenericName[fy]=Buroblêdpager
+GenericName[ga]=Brabhsálaí na nDeasc
+GenericName[gl]=Paxinador do Escritório
+GenericName[he]=מנהל חלונות
+GenericName[hi]=डेस्कटॉप पेजर
+GenericName[hr]=Pager na radnoj površini
+GenericName[hu]=Asztalváltó
+GenericName[is]=Skjáborðflettir
+GenericName[it]=Gestione dei desktop virtuali
+GenericName[ja]=デスクトップページャー
+GenericName[ka]=სამუშაო დაფათა გადამრთველი
+GenericName[kk]=Виртуалды үстелдер ақтарғышы
+GenericName[lo]=ແວ້ນຂະຫຍາຍພື້ນທີ່ທຳງານ
+GenericName[lt]=Darbastalio puslapiuotojas
+GenericName[lv]=Darbvirsmas Peidžers
+GenericName[mk]=Пејџер на раб. површина
+GenericName[mn]=Ажлын тавцан хоорондын сэлгүүр
+GenericName[ms]=Penghalaman Desktop
+GenericName[mt]=Desktops multipli
+GenericName[nb]=Skrivebordsbytter
+GenericName[nds]=Schriefdisch-Ümschalter
+GenericName[ne]=डेस्कटप पेजर
+GenericName[nl]=Bureaubladpager
+GenericName[nn]=Skrivebordsbytar
+GenericName[nso]=Sephetli sa Desktop
+GenericName[pa]=ਡੈਸਕਟਾਪ ਪੇਜਰ
+GenericName[pl]=Przełącznik pulpitów
+GenericName[pt]=Paginador do Ecrã
+GenericName[pt_BR]=Pager de Área de Trabalho
+GenericName[ro]=Paginator de ecran
+GenericName[ru]=Переключатель рабочих столов
+GenericName[rw]=Paja y'Ibiro
+GenericName[se]=Čállinbeavde molssuhanprográmma
+GenericName[sk]=Pager pracovnej plochy
+GenericName[sl]=Namizni pager
+GenericName[sr]=Пејџер радне површине
+GenericName[sr@Latn]=Pejdžer radne površine
+GenericName[ss]=Sivulikhasi se-desktop
+GenericName[sv]=Skrivbordsväljare
+GenericName[ta]=மேல்மேசை பேஜர்
+GenericName[te]=రంగస్థల పేజర్
+GenericName[tg]=Pager-и мизи корӣ
+GenericName[th]=เรียกพื้นที่หน้าจอน
+GenericName[tr]=Masaüstü Sayfalayıcı
+GenericName[tt]=Östäl Bitçese
+GenericName[uk]=Прогортач стільниць
+GenericName[uz]=Ish stolining peyjeri
+GenericName[uz@cyrillic]=Иш столининг пейжери
+GenericName[ven]=Pheidzha ya Desikithopo
+GenericName[vi]=Pager Màn hình nền
+GenericName[wa]=Pådjeu do scribanne
+GenericName[zh_CN]=桌面分页器
+GenericName[zh_TW]=桌面呼叫器
+GenericName[zu]=I-Pager ye-Desktop
+
+Icon=kpager
+Type=Application
+Exec=kpager
+X-DocPath=kpager/index.html
+Terminal=false
+X-TDE-StartupNotify=false
+X-DCOP-ServiceType=Unique
+Categories=Qt;TDE;Utility;X-TDE-Utilities-Desktop;
diff --git a/kpager/kpager.h b/kpager/kpager.h
new file mode 100644
index 000000000..4a3d2ef8f
--- /dev/null
+++ b/kpager/kpager.h
@@ -0,0 +1,139 @@
+/**************************************************************************
+
+ kpager.h - KPager's main window
+ Copyright (C) 2000 Antonio Larrosa Jimenez
+ Matthias Ettrich
+ Matthias Elter
+
+ 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.
+
+ Send comments and bug fixes to [email protected]
+
+***************************************************************************/
+#ifndef __KPAGER_H
+#define __KPAGER_H
+
+#include <tqwidget.h>
+#include <tqintdict.h>
+#include <tdemainwindow.h>
+#include <twin.h>
+#include "kpagerIface.h"
+
+class KPager;
+class TQPopupMenu;
+
+class KPagerMainWindow : public TDEMainWindow, public virtual KPagerIface
+{
+ Q_OBJECT
+
+public:
+ KPagerMainWindow(TQWidget *parent=0, const char *name=0);
+ ~KPagerMainWindow();
+
+ virtual void showAt(int x, int y);
+ virtual void toggleShow(int x, int y);
+
+public slots:
+ virtual void reallyClose();
+
+protected:
+ bool queryClose();
+ void showEvent(TQShowEvent *ev);
+
+ KPager *m_pPager;
+ class TQTimer *timeout;
+ bool m_reallyClose;
+};
+
+class KPager : public TQFrame
+{
+ Q_OBJECT
+
+ friend class KPagerMainWindow;
+
+public:
+ KPager(KPagerMainWindow *parent=0, const char *name=0);
+ ~KPager();
+
+ class KWinModule *twin() const { return m_winmodule; };
+ void updateLayout();
+
+ void redrawDesktops();
+
+ void showPopupMenu( WId wid, TQPoint pos);
+
+ KWin::WindowInfo* info( WId win );
+
+ TQSize sizeHint() const;
+
+ enum LayoutTypes { Classical=0, Horizontal, Vertical };
+
+public slots:
+ void configureDialog();
+
+ void slotActiveWindowChanged( WId win );
+ void slotWindowAdded( WId );
+ void slotWindowRemoved( WId );
+ void slotWindowChanged( WId, unsigned int );
+ void slotStackingOrderChanged();
+ void slotDesktopNamesChanged();
+ void slotNumberOfDesktopsChanged(int ndesktops);
+ void slotCurrentDesktopChanged(int);
+
+ void slotGrabWindows();
+
+protected slots:
+ void slotBackgroundChanged(int);
+ void clientPopupAboutToShow();
+ void clientPopupActivated(int);
+ void desktopPopupAboutToShow();
+ void sendToDesktop(int desk);
+
+protected:
+ enum WindowOperation {
+ MaximizeOp = 100,
+ IconifyOp,
+ StickyOp,
+ CloseOp
+ };
+
+protected:
+ KWinModule *m_winmodule;
+ TQValueList<class Desktop *> m_desktops;
+
+ TQIntDict<KWin::WindowInfo> m_windows;
+ WId m_activeWin;
+
+ const TQString lWidth();
+ const TQString lHeight();
+
+ LayoutTypes m_layoutType;
+
+ class TQGridLayout *m_layout;
+ TDEPopupMenu *m_mnu;
+ TQPopupMenu *m_smnu, *m_dmnu;
+ TDEAction *m_quit_action;
+ TDEAction *m_prefs_action;
+ KWin::WindowInfo m_winfo;
+ bool m_showStickyOption; // To be removed after the message freeze
+
+ TQTimer *m_grabWinTimer;
+ int m_currentDesktop;
+
+public:
+ static const LayoutTypes c_defLayout;
+};
+
+#endif
diff --git a/kpager/kpagerIface.h b/kpager/kpagerIface.h
new file mode 100644
index 000000000..5288a21f3
--- /dev/null
+++ b/kpager/kpagerIface.h
@@ -0,0 +1,22 @@
+#ifndef _KPAGERIFACE_H_
+#define _KPAGERIFACE_H_
+
+#include <dcopobject.h>
+
+class KPagerIface : virtual public DCOPObject
+{
+ K_DCOP
+
+k_dcop:
+/**
+ * If it's closed, open the window at the specified location
+ */
+ virtual void showAt(int x, int y)=0;
+
+/**
+ * Toggles the show/hide state of kpager
+ */
+ virtual void toggleShow(int x, int y)=0;
+};
+#endif
+
diff --git a/kpager/main.cpp b/kpager/main.cpp
new file mode 100644
index 000000000..4a6ab2bcd
--- /dev/null
+++ b/kpager/main.cpp
@@ -0,0 +1,107 @@
+/**************************************************************************
+
+ main.cpp - The main function for KPager
+ Copyright (C) 1998-2000 Antonio Larrosa Jimenez
+
+ 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.
+
+ Send comments and bug fixes to [email protected]
+
+***************************************************************************/
+
+#include <kuniqueapplication.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+#include <tdeaboutdata.h>
+#include <tqcolor.h>
+#include <kdebug.h>
+#include <stdlib.h>
+#include <tqsessionmanager.h>
+
+#include "kpager.h"
+
+static TDECmdLineOptions pagerOpts[] =
+{
+ { "hidden", I18N_NOOP("Create pager but keep the window hidden"), 0 },
+ TDECmdLineLastOption
+};
+
+bool closed_by_sm = false;
+
+class KPagerApplication : public KUniqueApplication
+{
+public:
+ KPagerApplication() : KUniqueApplication() {}
+
+ void commitData(TQSessionManager& sm) {
+ if (mainWidget()->isHidden()) {
+ sm.setRestartHint( TQSessionManager::RestartNever );
+ return;
+ }
+ closed_by_sm = true;
+ KUniqueApplication::commitData( sm );
+ closed_by_sm = false;
+ }
+
+ int newInstance() {
+ mainWidget()->show();
+ return 0;
+ }
+
+};
+
+int main(int argc, char **argv)
+{
+ TDEAboutData *aboutdata = new TDEAboutData("kpager", "KPager", "1.5",
+ I18N_NOOP("Desktop Overview"), TDEAboutData::License_GPL,
+ "(C) 1998-2002, Antonio Larrosa Jimenez","",
+ "http://developer.kde.org/~larrosa/kpager.html");
+
+ aboutdata->addAuthor("Antonio Larrosa Jimenez",
+ I18N_NOOP("Original Developer/Maintainer"),"[email protected]",
+ "http://developer.kde.org/~larrosa/index.html");
+ aboutdata->addAuthor("Matthias Elter",
+ I18N_NOOP("Developer"),"[email protected]", "");
+ aboutdata->addAuthor("Matthias Ettrich",
+ I18N_NOOP("Developer"),"[email protected]", "");
+
+ TDECmdLineArgs::init(argc, argv, aboutdata);
+ TDECmdLineArgs::addCmdLineOptions(pagerOpts);
+ KUniqueApplication::addCmdLineOptions();
+
+ if (!KUniqueApplication::start())
+ {
+ kdError() << "kpager is already running!" << endl;
+ return 0;
+ }
+
+
+ TDEApplication * app = new KPagerApplication;
+ TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
+
+ KPagerMainWindow *kpager = new KPagerMainWindow(0,"KPager");
+ kpager->setPlainCaption( i18n("Desktop Pager") );
+
+
+ app->setMainWidget(kpager);
+ if (!args->isSet("hidden")) kpager->show();
+ else kpager->hide();
+
+ int ret = app->exec();
+
+ delete app;
+ return ret;
+}
+
diff --git a/kpager/uninstall.desktop b/kpager/uninstall.desktop
new file mode 100644
index 000000000..e1e3e1732
--- /dev/null
+++ b/kpager/uninstall.desktop
@@ -0,0 +1,2 @@
+[Desktop Entry]
+Hidden=true
diff --git a/kpager/windowdrag.cpp b/kpager/windowdrag.cpp
new file mode 100644
index 000000000..fc854b8a9
--- /dev/null
+++ b/kpager/windowdrag.cpp
@@ -0,0 +1,60 @@
+/*************************************************************************
+
+ windowdrag.cpp - The windowDrag object, used to drag windows across
+ desktops
+
+ Copyright (C) 1998,99,2000 Antonio Larrosa Jimenez <[email protected]>
+
+ 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.
+
+ Send comments and bug fixes to [email protected]
+
+*************************************************************************/
+
+#include "windowdrag.h"
+
+PagerWindowDrag::PagerWindowDrag(WId w,int deltax,int deltay, int origdesk,TQWidget *parent)
+ : TQStoredDrag("application/x-kpager",parent,"windowdrag")
+{
+ TQString tmp;
+ tmp.sprintf("%d %d %d %d", static_cast<int>(w), deltax, deltay, origdesk);
+ TQByteArray data;
+ data.setRawData(tmp.latin1(),tmp.length()+1);
+
+ setEncodedData(data);
+ data.resetRawData(tmp.latin1(),tmp.length()+1);
+}
+
+PagerWindowDrag::~PagerWindowDrag()
+{
+}
+
+bool PagerWindowDrag::canDecode (TQDragMoveEvent *e)
+{
+ return e->provides("application/x-kpager");
+}
+
+bool PagerWindowDrag::decode( TQDropEvent *e, WId &w,int &deltax,int &deltay,int &origdesk)
+{
+ TQByteArray data=e->data("application/x-kpager");
+ if (data.size())
+ {
+ char *tmp=data.data();
+ sscanf(tmp,"%lu %d %d %d", &w, &deltax, &deltay, &origdesk);
+ e->accept();
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/kpager/windowdrag.h b/kpager/windowdrag.h
new file mode 100644
index 000000000..a123ea1b5
--- /dev/null
+++ b/kpager/windowdrag.h
@@ -0,0 +1,41 @@
+/*************************************************************************
+
+ windowdrag.h - The windowDrag object, used to drag windows across
+ desktops
+ Copyright (C) 1998,99,2000 Antonio Larrosa Jimenez
+
+ 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.
+
+ Send comments and bug fixes to [email protected]
+
+*************************************************************************/
+#ifndef WINDOWDRAG_H
+#define WINDOWDRAG_H
+
+#include <tqdragobject.h>
+#include <X11/Xlib.h>
+
+class PagerWindowDrag : public TQStoredDrag
+{
+public:
+ PagerWindowDrag(WId w,int deltax,int deltay,int origdesk,TQWidget *parent);
+ virtual ~PagerWindowDrag();
+
+ static bool canDecode( TQDragMoveEvent *e);
+ static bool decode ( TQDropEvent *e, WId &w,int &deltax,int &deltay,int &origdesk);
+
+};
+
+#endif