diff --git a/src/kooldock.cpp b/src/kooldock.cpp index 93d43ee..cad4541 100644 --- a/src/kooldock.cpp +++ b/src/kooldock.cpp @@ -73,8 +73,7 @@ KoolDock::KoolDock(TQWidget* parent, const char* name) : menuPath = progPath + TQString("/menu/"); confFile = locateLocal("config", "kooldockrc"); - noSet = false; - firstInit = true; + lockSetTab= false; // disables changing opened tab in preferences window setupdlg = new SetupDialogPrg(); // create the setup dialog object. connect(setupdlg, SIGNAL(apply()), SLOT(chkRestart())); @@ -100,24 +99,7 @@ KoolDock::KoolDock(TQWidget* parent, const char* name) : connect(tasklist, SIGNAL(activated(int)), this, SLOT(goToWindow(int))); connect(deskpopup, SIGNAL(activated(int)), this, SLOT(sendToDesktop(int))); menuCount = 0; - - init1(); - - if (fFirstRun) - { - // Show welcome dialog. - const char* welcomeMsg = - I18N_NOOP("
Welcome
It appears to be the first time you run KoolDock.
" - "By default the dock is hidden at the botton of the screen, move your mouse" - " to the bottom edge of the screen and the dock will appear.
" - "Right click on the dock for a menu that allows you to configure it
" - "or run with -o parameter to have preferences window at start.
" - "We hope this software is usefull for you
-- The KoolDock Team"); - KMessageBox::information(0L, i18n(welcomeMsg)); - saveConf(); // create initial configuration. - } - init2(); - firstInit = false; + init(); //initialization } KoolDock::~KoolDock() @@ -136,13 +118,13 @@ KoolDock::~KoolDock() if (_filterData) delete(_filterData); } -void KoolDock::mTimerEnd() +void KoolDock::mTimerEnd() // mouse emulation timer { if (menuCount > 0) { - return; + return; // a popup is still opened - disable scrolling } TQPoint pointer = TQCursor::pos(); - lastXPos = pointer.x() - rx; + lastXPos = pointer.x() - rx; // remember current mouse position (relative to window position) lastYPos = pointer.y() - ry; int px, py, pw, ph; int mpx = pointer.x(); @@ -250,7 +232,6 @@ void KoolDock::trackTimer2End() getTopBG(); } debug(TQString("tracktimer: grabWindow(%1, %2, %3, %4)").arg(x1).arg(dh - h1).arg(w1).arg(h1)); - move2(x, dh - h); resize2(w, h); Ybase = iwBig2; enterEvent(NULL); @@ -303,7 +284,7 @@ void KoolDock::paintEvent(TQPaintEvent *) int p1 = 0; int p2 = 0; KPixmapIO pixio; - + if (!fLeftImg.isEmpty()) { TempBG = pixio.convertToImage(LeftImg); if ((fOrientation & 1) == 1) { @@ -625,7 +606,7 @@ void KoolDock::paintEvent(TQPaintEvent *) KPixmapEffect::fade(*currentIcon, ((float) 60) * 0.01, TQColor("#FFFFFF")); } // End drawing icon effects - + Xpos += x; if ((fOrientation & 1) == 1) { std::swap(Xpos, Ypos); @@ -637,7 +618,7 @@ void KoolDock::paintEvent(TQPaintEvent *) } } // End drawing icons - // Draw the seperator between launcher and taskbar + // Draw the seperators between launcher and taskbar, and between tasbar and systray if (fShowTaskbar && ((numLaunchers > 0 && ((int) items.count() > numLaunchers)) || ((fShowKMenu == 1) && (items.count() > 1)))) { i = numLaunchers - 1; if ((i >= 0) && (i < (int) items.count() - 1)) { @@ -1406,7 +1387,7 @@ void KoolDock::enterEvent (TQEvent *) iwBig = iwSmall; } resize2(w, h); - move2(x, dh - h); + move2(x, rdh); funcH = iwBig - iwSmall; iy = (iDist - iwSmall) / 2; @@ -1414,12 +1395,14 @@ void KoolDock::enterEvent (TQEvent *) fExpanded = true; oldfirstX = x; oldtmpw = w; - paintEvent(NULL); debug("enterEvent"); zoomTicksB = 0; zoomTicksS = 0; perf->start(); mkbigTimer->start(zoomStep, false); + mkbigTimerDo(); + paintEvent(NULL); + move2(x,dh-h); } void KoolDock::onleaveEvent(TQEvent *) @@ -2013,7 +1996,7 @@ void KoolDock::rmwTask(int iFound) Item* item; int i; int ind = witems.at(iFound)->getIndex(); - + for (i = 0, item = witems.at(0); item; i++, item = witems.next()) { if (item->getIndex() > ind) { item->setIndex(item->getIndex() - 1); @@ -2458,10 +2441,8 @@ void KoolDock::editPref() } loadIgnore(); // Load Ignore List - if (!setupdlg->isVisible()) { - if (!noSet) { - setupdlg->tabWidget->setCurrentPage(0); - } + if (!setupdlg->isVisible() && !lockSetTab) { + setupdlg->tabWidget->setCurrentPage(0); } setupdlg->toReloadIcons->setChecked(false); @@ -3084,16 +3065,15 @@ void KoolDock::reload() items.clear(); witems.clear(); } - init1(); - init2(); + init(); if (setupdlg->isVisible()) { - noSet = true; + lockSetTab=true; editPref(); if (reloadIcons) { setupdlg->appClear(); setupdlg->appFill(); } - noSet = false; + lockSetTab=false; } } @@ -3313,10 +3293,10 @@ void KoolDock::menuX(int num) } } -void KoolDock::init1() +void KoolDock::init() { initialization = true; - nDesks=-1; + nDesks=-2; ptPart = 5; // Load the configuration loadConf(); @@ -3374,7 +3354,7 @@ void KoolDock::init1() } } - // Load the menu entries + //Lets load the menu entries if (reloadIcons) { loadMenu(); } @@ -3491,6 +3471,7 @@ void KoolDock::init1() ii_last = items.count() - 1; iOnClick = -1; onChangeTimer = NULL; + Ybase = 0; soffset = 0; eoffset = 0; @@ -3552,10 +3533,21 @@ void KoolDock::init1() iSpace * 2) / 2 - 4 * iwSmall - (int) ((3 * iDist + 1 - funcW) * (func(0) + func (iDist) - 2 * iwSmall) / (2 * iDist)) + 1; eoffset= (int) ((iwBig2 - iwSmall) * fAmount / 100); doUpdateGeometry(); -} + if (fFirstRun) + { + fFirstRun=false; + // Show welcome dialog. + const char* welcomeMsg = + I18N_NOOP("
Welcome
It appears to be the first time you run KoolDock.
" + "By default the dock is hidden at the botton of the screen, move your mouse" + " to the bottom edge of the screen and the dock will appear.
" + "Right click on the dock for a menu that allows you to configure it
" + "or run with -o parameter to have preferences window at start.
" + "We hope this software is usefull for you
-- The KoolDock Team"); + KMessageBox::information(0L, i18n(welcomeMsg)); + saveConf(); // create initial configuration. + } -void KoolDock::init2() -{ clipw = new clip(); if (fHidden == 1) { @@ -3631,6 +3623,7 @@ void KoolDock::init2() } else { pTest(); + } } @@ -3705,6 +3698,7 @@ void KoolDock::dropEvent(TQDropEvent* event) useList = false; } +//Funtion used in window grouping void KoolDock::movetoback(WId id) { int i; @@ -3740,6 +3734,7 @@ void KoolDock::movetoback(WId id) } } +//Gets index of an incon by position int KoolDock::itemFromPoint(int x) { int i, Xpos = -1; @@ -3749,10 +3744,10 @@ int KoolDock::itemFromPoint(int x) break; } } - currXPos = Xpos; return i; } +//Gets position of an icon by its index int KoolDock::xFromIndex(int i) { int Xpos; @@ -3825,7 +3820,7 @@ void KoolDock::updTaskList() desks.setAutoDelete(true); //tasklist; menu to access every window throught navigation menu - int j, index, incr, nDesks; + int j, index, incr; KWin::WindowInfo tmpinfo; nDesks = KWin::numberOfDesktops(); diff --git a/src/kooldock.h b/src/kooldock.h index 1c6458d..32843cb 100644 --- a/src/kooldock.h +++ b/src/kooldock.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include @@ -48,7 +48,7 @@ const int UPDATE_DIST = 1; // update when x - last_x <= UPDATE_DIST const int DEF_SMALL_SIZE = 32; // default small icon size const int DEF_BIG_SIZE = 90; // default big icon size const int DEF_DOCK_OPACITY = 50; // default dock opacity -const int DEF_PRIORITY = 5; +const int DEF_PRIORITY = 5; // default priority const int DEF_HIDDEN = 1; // default hidden priority const int ANIM_TOTAL_STEP = 6; // not in use yet @@ -66,44 +66,43 @@ class KoolDock : public TQWidget KoolDock(TQWidget* parent = 0, const char* name = 0); /** destructor */ ~KoolDock(); - - void setMainPath(const TQString& path); + + void setMainPath(const TQString& path); // send run paramenters to the widget void setArgs(const TQString& param); - clip *clipw; - + clip *clipw; // clipping window - makes kooldock's edge sticky + private: - TQTime* perf; + TQTime* perf; // variable used to control animation speed // configuration variables int fShowTaskbar; // show-taskbar flag int fMinimizedOnly; // show only minimized icons flag int fShowNotification; // show-notification flag int fShowBorders; // show-borders flag int fShowKMenu; // show the K menu - int fUseKBFX; + int fUseKBFX; // makes kooldock use KBFX insted of K menu int fPriority; // "nice" priority int fMouseTimer; // Mouse timer interval - int fClipping; //window area clippig - int fClipIcons; //icon area clipping + int fClipping; // window area clippig + int fClipIcons; // icon area clipping long int fzoomSpeed, zoomStep, zoomStepB, zoomStepS, zoomVal; //speed of show/hide animation int zoomTicksB, zoomTicksS; //counts timer ticks int neededTicksB,neededTicksS; //sets how many ticks is necessary to calculate new speed - bool fSpeed; + bool fSpeed; // enables speed control TQColor borderColor; - int fHidden; // hidden dockbar - int fStayBelow; + int fHidden; // determines dock's autohide + int fStayBelow; // makes dock stay below other windows while not focused int fOrientation; //bottom/left/top/right - int fHideOnClick; - int fSteppy; + int fHideOnClick; // determines if kooldock should hide after clicking an icon + int fSteppy; // enables autocenter on icon int fShowFrames; // frames to show the dock "growing from bottom" int fGrowFrames; // frames to grow the icon when the mouse is over it. int fHighLightTime; - bool fFirstRun; - bool fShowShot; - bool fGrouping; - int fRepaintInterval; + bool fFirstRun; // shows information box one time + bool fShowShot; // makes kooldock do screenshot of minimized window + bool fGrouping; // enables window grouping int xinerama; //whether we want xinerama int hideTimer; //user define time to show dock - int Solid; //whether using backgroung Image or not (for preference controls) + int Solid; //whether using background Image or not (for preference controls) int fShowNav; //whether we want the navigation menu (clock + desktop chooser) in kooldocks main menu int numSystray; //for systray control int fSystray; //whether we want the systray or not @@ -112,43 +111,38 @@ class KoolDock : public TQWidget bool firstTime; //to control certain things TQString curTheme; //for the background theme (to preserve changes) int leftRes; //Left monitor resolution - int XinDesiredHeight; + int XinDesiredHeight; // size of screen on which kooldock is visible in Xinerama int XinPreviousWidth; - int fpercentPos; + int fpercentPos; // sets position of dock on screen - bool noSet; - bool firstInit; - bool reloadIcons; - bool initialization; - int ptPart; + bool lockSetTab; // disables changing opened tab in preferences window + bool reloadIcons; // sets the need of reloading icons after changes in setting + bool initialization; // blocks dock during loading settings + int ptPart; // variable used in speed control as state data - bool mouseOnLauncher; - TQStringList lstDrop; - bool useList; + bool mouseOnLauncher; // determines if mouse is on laucher icon or on window icon + TQStringList lstDrop; // list of dropped elements + bool useList; // determines if dropped elements should be sent to selected application Atom net_system_tray_selection; Atom net_system_tray_opcode; - TQString fLeftImg; + TQString fLeftImg; //paths to background images TQString fRightImg; TQString fCenterImg; - bool fNWideBg; - bool scaleMax; + bool fNWideBg; // determines if background should not be wider than screen + bool scaleMax; // sets scaling mode of background corners TQPixmap LeftImg; TQPixmap RightImg; TQPixmap CenterImg; - TQPixmap TempScaledCenter; - TQPixmap TestPix; - TQImage TestIm; - - unsigned int oLeft, oRight; + TQPixmap TempScaledCenter; - int iwSmall; - int iwBig; - int iwBig2; + int iwSmall; // sizes of small and big icon + int iwBig; // size of current big icon - during animation its value is between iwSmall and iwBig2 + int iwBig2; // size of base size of big icon - int firstX, tmpw; + int firstX, tmpw; // variables used in background positioning int oldfirstX, oldtmpw; int lastX; @@ -157,7 +151,7 @@ class KoolDock : public TQWidget TQColor sepColor; // separator bar's color - int Ybase; + int Ybase; // sets position of dock, and how big part of dock is out of screen // normal variables TQString progPath; @@ -169,23 +163,22 @@ class KoolDock : public TQWidget TQStringList ignoreList; - NETWinInfo* info; + NETWinInfo* info; // window informations KWinModule* wm; SetupDialog* setupdlg; - int Offset; + int Offset; // scrolls dock if all icons are wider than screen int numLaunchers; // number of quick launcher items - int x, y, w, h, h0, h1, w0, x0, w1, x1; + int x, y, w, h, h0, h1, w0, x0, w1, x1; // positions *0 - small *1 big int rx, ry, rw, rh, uw; //current position - int ix, iy, iDist, iSpace; - int dw, dh, rdh; - int funcW, funcH; - int ii_first, ii_last; + int ix, iy, iDist, iSpace; // sizes of dock's elements - icons, distance between small icon centres, space between them + int dw, dh, rdh; // real current position + int funcW, funcH; // variables used to calculate zoomed icons sizes + int ii_first, ii_last; // idexes of first and last zoomed icons int soffset, eoffset; //used in icon positioning - int sx, sw; - int adjust; - int fAmount; - int last_mx; + int adjust; // offset of first zoomed icon + int fAmount; // amount of big icons + int last_mx; // mouse position int last_ncx; TQPtrList items;//currently visible items @@ -197,7 +190,7 @@ class KoolDock : public TQWidget KRootPixmap* rootpix; KPixmap bottomBg; - KPixmap bottomBgf; + KPixmap bottomBgf; // faded bottom background TQPixmap topBg; TDEAboutDialog* aboutDlg; @@ -210,24 +203,23 @@ class KoolDock : public TQWidget int animStep; // animation step, not in use yet int iOnClick; // index of the quick launcher being clicked WId cId; // id of the application (used in the right click menu over the taskbar) - TQString cClass; - WId CurrentFocus; - int onChangeAnimStep; - TDEPopupMenu* deskpopup; - TDEPopupMenu* appMenu; - TDEPopupMenu* godesk; - TDEPopupMenu* tasklist; - TDEPopupMenu* popup; - TDEPopupMenu* advMenu; - int menuCount, currMenu; - bool allApps; + WId CurrentFocus; // id of window that is currently active + TDEPopupMenu *deskpopup; // moving between desktops + TDEPopupMenu *appMenu; // list of windows in selected group + TDEPopupMenu *godesk; // sends window to another desktop + TDEPopupMenu *tasklist; // list of all windows + TDEPopupMenu *popup; // main popup + TDEPopupMenu *advMenu; // kicker like advanced menu of window icon + int menuCount; // counts menus - disable dock hiding when popups are visible, and determines if user want to do some changes to specific window, or to all windows in group + int currMenu; // information to which window user apply changes + bool allApps; // sets if dock should apply changes to all windows TQPtrList popups; - bool iGroup; - int dIndex, nDesks; + bool iGroup; // menu of icon is connect with single window or with group of windows + int dIndex, nDesks; // index of desktop (0 for all), count of desktops TQPtrList desks; - bool fExpanded; - bool track2active; + bool fExpanded; // informs if kooldock is zoomed + bool track2active; // checks if second tracking timer is active - to make kooldock open in proper time /*Xosd Section */ TQString nom; TQString aux; @@ -243,62 +235,62 @@ class KoolDock : public TQWidget int xosdSize; KURIFilterData* _filterData; xosd* xosdw; - int animValue; + + int animValue; // icon highlight int animState; - void run(const TQString& cmd); - int func(int x); + bool doRepaint; + int lastXPos; // postion of mouse - used in autocenter + int lastYPos; + + void run(const TQString& cmd); // runs command, including data dropped of launcher + int func(int x); // function used in scaling zoomed icons int func2(int x); - void doUpdateGeometry(); - bool addTask(WId id, int iFound = -1); - bool rmTask(WId id, int iFound = -1); - void rmwTask(int iFound); + void doUpdateGeometry(); // updates kooldock dimentios, and icon positions + bool addTask(WId id, int iFound=-1); // add window to dock + bool rmTask(WId id, int iFound=-1); // remove window from dock + void rmwTask(int iFound); // remove window from list (hidden, used for performance) bool addwTask(WId id); - void movetoback(WId id); + void movetoback(WId id); // send icon in group to end of list - used to determine order of windows in group void loadConf(); void loadIgnore(); void saveConf(); void loadMenu(); - void addWindows(); - int itemFromPoint(int x); - int xFromIndex(int i); + void addWindows(); // refreshes list of windows (hidden list, and icons on dock) + int itemFromPoint(int x); // gets icon in specified point + int xFromIndex(int i); // gets position of icon from its index void createMenu(TDEPopupMenu* tmpMenu, KWin::WindowInfo* info); - void updTaskList(); - void addToTaskList(WId id); - void rmFromTaskList(WId id); - bool doRepaint; - int currXPos; - int lastXPos; - int lastYPos; - void init1(); - void init2(); + void updTaskList(); // recreate popup menu of all applications + void addToTaskList(WId id); // add window to menu + void rmFromTaskList(WId id); // remove from menu + void init(); protected: void paintEvent(TQPaintEvent*); void mousePressEvent(TQMouseEvent*); - void mMoveEvent(int ex, int ey); - void mPress( int mx, int my, ButtonState srcButton); + void mMoveEvent(int ex, int ey); // mouse move event called by timer (to avoid 'freezes' i.e. when menu are open) + void mPress(int mx, int my, ButtonState srcButton); // press event, used insted of normal event for simplicity of calling void wheelEvent(TQWheelEvent*); void enterEvent(TQEvent*); - void onleaveEvent(TQEvent*); - void mksmallTimerstop(); + void onleaveEvent(TQEvent*); // event called when mouse leves dock + void mksmallTimerstop(); // called when stopping smalling aninamtion void dragMoveEvent(TQDragMoveEvent* event); void dropEvent(TQDropEvent* event); public slots: - void edit(); - void editPref(); + void edit(); // shows launcher editing page + void editPref(); // shows preferences void about(); - void windowAdded(WId id); + void windowAdded(WId id); // events called when window appaers/disappears void windowRemoved(WId id); - void numberOfDesktopsChanged(int); - void windowChanged(WId id, unsigned int properties); - void activeWindowChanged(WId id); + void numberOfDesktopsChanged(int); // called when number of desktops has changed + void windowChanged(WId id, unsigned int properties); // when window was modified - moved, resized, minimized, etc. + void activeWindowChanged(WId id); // focus changed void workAreaChanged(); void currentDesktopChanged(int); - void onChangeTimerTicked(); + void onChangeTimerTicked(); // called when icon is highlighted void updateBackground(const TQPixmap&); - void moveApp(); + void moveApp(); // functions used to manipulate windows void resizeApp(); void minApp(); void maxApp(); @@ -310,21 +302,23 @@ class KoolDock : public TQWidget void shadeApp(); void activateApp(); void closeApp(); - void editItem(); - void removeItem(); - void sendToDesktop(int); - void goToDesktop(int); - void goToWindow(int); + void toggleAlwaysOnTop(); + void toggleKeptBelowOthers(); + void toggleFullScreen(); + void sendToDesktop(int); // sends app to another desktop + void goToWindow(int); // sets focus + void editItem(); // edit launcher + void removeItem(); // remove launcher + void goToDesktop(int); // changes current desktop + /* Systray support */ void systemTrayWindowAdded(WId id); void systemTrayWindowRemoved(WId id); - void aboutToShow(); + + /* menus */ + void aboutToShow(); // events associated with all popups void aboutToHide(); - - void toggleAlwaysOnTop(); - void toggleKeptBelowOthers(); - void toggleFullScreen(); - + static void addFile(const TQString& filename, const TQString& iconname, const TQString& execname, @@ -342,27 +336,27 @@ class KoolDock : public TQWidget #ifndef _ENABLE_DEBUG static void debug(TQString); #endif - void mkbigTimerDo(); + void mkbigTimerDo(); // tick of animation timers void mksmallTimerDo(); void endProg(); - void mTimerEnd(); - void trackTimerEnd(); - void trackTimer2End(); + void mTimerEnd(); // event called by mTimer - detects mouse position + void trackTimerEnd(); // checks if cursor touched screen edge, on which kooldock is autohided + void trackTimer2End(); // enabled by first trackTimer - provides kooldock's opening in proper time void restart(); void reload(); - void chkRestart(); + void chkRestart(); // sub called by preferences window, after clicking apply or ok void refreshBackground(); void unhighlight(); - void move2(int nx, int ny); - void resize2(int nw, int nh); - void getBottomBG(); - void getTopBG(); - void setDesktopIconsArea(int, int, int, int); + void move2(int nx, int ny); // moves dock + void resize2(int nw, int nh); // resizes dock + void getBottomBG(); // gets bottom part of background - covered by small icons + void getTopBG(); // gets upper part of background - covered by zoomed icons + void setDesktopIconsArea(int, int, int, int); // changes KDE desktop area void setDockAbove(); void setDockBelow(); - void menuX(int num); - void menuShow(); - void pTest(); + void menuX(int num); // event called when user highlighted menu of specified window in window group menu + void menuShow(); // event called when deskpopup is about to show - updates settings on menu for selected window + void pTest(); // performance test }; #endif // KOOLDOCK_H diff --git a/src/xosd.cpp b/src/xosd.cpp index fed3313..37f1f2b 100644 --- a/src/xosd.cpp +++ b/src/xosd.cpp @@ -15,15 +15,19 @@ #include #include -xosd::xosd(TQWidget* parent, const char* name) : +xosd::xosd(TQWidget *parent, const char *name) : TQWidget(parent, name, WStyle_Customize | WRepaintNoErase | WStyle_NoBorder | - WDestructiveClose | WResizeNoErase | WMouseNoMask | WStyle_StaysOnTop | WX11BypassWM) + WDestructiveClose | WStyle_StaysOnTop | WX11BypassWM) { info = new NETWinInfo(tqt_xdisplay(), winId(), tqt_xrootwin(), NET::WMState); info->setDesktop(NETWinInfo::OnAllDesktops); hide(); KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager); setCaption("kooldock xosd window"); + w=0; + h=0; + yOffset=0; + fCleaner=0; } xosd::~xosd() @@ -110,7 +114,7 @@ void xosd::paintEvent(TQPaintEvent*) TQPixmap pm(size()); TQBitmap bm(size()); TQPainter p; - + // Drawing text p.begin(&pm, this); if (fCleaner == 1) {