summaryrefslogtreecommitdiffstats
path: root/src/kooldock.h
blob: 1e8f0c1fdf87e604d30cd3e923edce8d72dd02c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/***************************************************************************
                          kooldock.h  -  description
                             -------------------
    begin                : Tue Jun 10 22:18:34 BST 2003
    copyright            : (C) 2003 by KoolDock team
    email                : 
 ***************************************************************************/

/***************************************************************************
 *   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.                                   *
 ***************************************************************************/

#ifndef KOOLDOCK_H
#define KOOLDOCK_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <kapp.h>
#include <tdepopupmenu.h>
#include <twinmodule.h>
#include <tdeaboutdialog.h>
#include <krootpixmap.h>
#include <kpixmap.h>
#include <kurifilter.h>

#include <tqwidget.h>
#include <tqptrlist.h>
#include <tqtimer.h>
#include <tqcolor.h>

#include <netwm.h>

#include <tqdatetime.h>

#include "item.h"
#include "xosd.h"
#include "clip.h"
#include "setupdialogprg.h"
#include "dinfo.h"

const int MAX_ICONS = 150; // max number of icons
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; // default priority
const int DEF_HIDDEN = 1; // default hidden priority
const int ANIM_TOTAL_STEP = 6; // not in use yet

const int SPACE_W = 1; // space between quick launchers and tasks (the seperator)

const int ON_CHANGE_ANIM_INTERVAL = 50; // animation's interval

/** KoolDock is the base class of the project */
class KoolDock : public TQWidget
{
   TQ_OBJECT

   public:
   /** construtor */
   KoolDock(TQWidget* parent = 0, const char* name = 0);
   /** destructor */
   ~KoolDock();

   void setMainPath(const TQString& path); // send run paramenters to the widget
   void setArgs(const TQString& param);
   clip *clipw; // clipping window - makes kooldock's edge sticky

   private:
      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; // 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
      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; // enables speed control
      TQColor borderColor;
      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; // 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; // 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 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
      int fCurrent; //whether to only show windows on current desktop
      int oldDesktop; //number of previous desktop
      bool firstTime; //to control certain things
      TQString curTheme; //for the background theme (to preserve changes)
      int leftRes; //Left monitor resolution
      int XinDesiredHeight; // size of screen on which kooldock is visible in Xinerama
      int XinPreviousWidth;
      int fpercentPos; // sets position of dock on screen

      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; // 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; //paths to background images
      TQString fRightImg;
      TQString fCenterImg;
      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;

      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; // variables used in background positioning
      int oldfirstX, oldtmpw;
      int lastX;

      int dockOpacity;
      TQColor bgColor;

      TQColor sepColor; // separator bar's color

      int Ybase; // sets position of dock, and how big part of dock is out of screen

      // normal variables
      TQString progPath;
      TQString menuPath;
      TQString confFile;
      TQString iFilename;  // right clicked item filename
      TQString mainPath;
      TQString args;

      TQStringList ignoreList;

      NETWinInfo* info; // window informations
      KWinModule* wm;
      SetupDialog* setupdlg;

      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; // positions *0 - small *1 big
      int rx, ry, rw, rh, uw; //current position
      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 adjust; // offset of first zoomed icon
      int fAmount; // amount of big icons
      int last_mx; // mouse position
      int last_ncx;

      TQPtrList<Item> items;//currently visible items
      TQPtrList<Item> witems;//all windows on all desktops
      int iSize[MAX_ICONS + 1];//icon sizes
      int cx[MAX_ICONS + 1];//positions of small icons
      int cur_cx[MAX_ICONS + 1];//positions of visible icons
      TQPixmap offscr;//drawing buffer

      KRootPixmap* rootpix;
      KPixmap bottomBg;
      KPixmap bottomBgf; // faded bottom background
      TQPixmap topBg;

      TDEAboutDialog* aboutDlg;
      TQTimer* mkbigTimer; //zoom animation timers
      TQTimer* mksmallTimer;
      TQTimer* mTimer; //mouse move emulator (can't use normal event instead)
      TQTimer* onChangeTimer; // used when a window has changed and we need to notify user
      TQTimer* trackTimer; //checks whether mouse touches screen edge

      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)
      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<TDEPopupMenu> popups;
      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<dInfo> desks;

      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;
      int xosd_st;
      int showNames;
      int fCleaner;
      int xosdShadowOffset;
      TQString xosdFont;
      TQString xosdColor;
      TQString xosdShadowColor;
      bool xosdBold;
      bool xosdItalic;
      int xosdSize;
      KURIFilterData* _filterData;
      xosd* xosdw;

      int animValue; // icon highlight
      int animState;

      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(); // 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); // 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(); // 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(); // 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); // 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*); // 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(); // shows launcher editing page
      void editPref(); // shows preferences
      void about();
      void windowAdded(WId id); // events called when window appaers/disappears
      void windowRemoved(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(); // called when icon is highlighted
      void updateBackground(const TQPixmap&);
      void moveApp(); // functions used to manipulate windows
      void resizeApp();
      void minApp();
      void maxApp();
      void restApp();
      void minAllApps();
      void maxAllApps();
      void restAllApps();
      void closeAllApps();
      void shadeApp();
      void activateApp();
      void closeApp();
      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);

      /* menus */
      void aboutToShow(); // events associated with all popups
      void aboutToHide();

      static void addFile(const TQString& filename,
                          const TQString& iconname,
                          const TQString& execname,
                          const TQString& name,
                          bool notify = true,
                          bool terminal = false,
                          bool tclose = false,
                          bool cuser = false,
                          TQString = "na");
      bool ignored(const TQString& appname);

      #ifdef _ENABLE_DEBUG
      static void debug(TQString message);
      #endif
      #ifndef _ENABLE_DEBUG
      static void debug(TQString);
      #endif
      void mkbigTimerDo(); // tick of animation timers
      void mksmallTimerDo();
      void endProg();
      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(); // sub called by preferences window, after clicking apply or ok
      void refreshBackground();
      void unhighlight();
      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); // 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