1 #ifndef TASKBAR_H 2 #define TASKBAR_H 3 4 #include "yaction.h" 5 #include "ytimer.h" 6 #include "wmclient.h" 7 #include "yxtray.h" 8 #include "applet.h" 9 10 class ObjectBar; 11 class ObjectButton; 12 class MEMStatus; 13 class CPUStatusControl; 14 class NetStatusControl; 15 class AddressBar; 16 class KeyboardStatus; 17 class MailBoxControl; 18 class MailBoxStatus; 19 class YButton; 20 class ClockSet; 21 class YApm; 22 class TaskBarMenu; 23 class TaskPane; 24 class TrayPane; 25 class AWorkspaces; 26 class WorkspacesPane; 27 class YXTray; 28 class YSMListener; 29 class TaskBar; 30 class TaskBarApp; 31 class TrayApp; 32 33 class EdgeTrigger: public YDndWindow, public YTimerListener { 34 public: 35 EdgeTrigger(TaskBar *owner); 36 virtual ~EdgeTrigger(); 37 38 static bool enabled(); 39 void show(bool enable); 40 enum HideOrShow { Hide, Show }; 41 void startTimer(HideOrShow = Hide); 42 void stopTimer(); 43 44 virtual void handleDNDEnter(); 45 virtual void handleDNDLeave(); 46 47 virtual void handleCrossing(const XCrossingEvent &crossing); 48 virtual bool handleTimer(YTimer *t); 49 private: 50 TaskBar *fTaskBar; 51 lazy<YTimer> fAutoHideTimer; 52 HideOrShow fHideOrShow; 53 }; 54 55 class TaskBar: 56 public YFrameClient, 57 public YActionListener, 58 public YPopDownListener, 59 public YXTrayNotifier, 60 public IAppletContainer 61 { 62 public: 63 TaskBar(IApp *app, YWindow *aParent, YActionListener *wmActionListener, YSMListener *smActionListener); 64 virtual ~TaskBar(); 65 66 private: 67 virtual void paint(Graphics &g, const YRect &r); 68 virtual bool handleKey(const XKeyEvent &key); 69 virtual void handleButton(const XButtonEvent &button); 70 virtual void handleClick(const XButtonEvent &up, int count); 71 virtual void handleDrag(const XButtonEvent &down, const XMotionEvent &motion); 72 virtual void handleEndDrag(const XButtonEvent &down, const XButtonEvent &up); 73 virtual void handleFocus(const XFocusChangeEvent& focus); 74 virtual void handleCrossing(const XCrossingEvent &crossing); handleExpose(const XExposeEvent & expose)75 virtual void handleExpose(const XExposeEvent &expose) {} 76 77 virtual void actionPerformed(YAction action, unsigned int modifiers); 78 virtual void handlePopDown(YPopupWindow *popup); 79 80 void updateWMHints(); 81 void updateLocation(); 82 void updateWinLayer(); 83 virtual void configure(const YRect2 &r); 84 virtual void repaint(); 85 86 public: 87 bool windowTrayRequestDock(Window w); 88 void setWorkspaceActive(long workspace, bool active); 89 void workspacesRepaint(); 90 void workspacesUpdateButtons(); 91 void workspacesRelabelButtons(); 92 void keyboardUpdate(mstring keyboard); 93 94 void updateFrame(YFrameWindow* frame); 95 void delistFrame(YFrameWindow* frame, TaskBarApp* task, TrayApp* tray); 96 void removeTasksApp(YFrameWindow* frame); 97 TaskBarApp* addTasksApp(YFrameWindow* frame); 98 void relayoutTasks(); 99 void relayoutTray(); 100 TrayApp* addTrayApp(YFrameWindow* frame); 101 void removeTrayApp(YFrameWindow* frame); 102 103 void popupStartMenu(); 104 void popupWindowListMenu(); 105 106 void showAddressBar(); 107 void showBar(); 108 void handleCollapseButton(); 109 relayout()110 void relayout() { fNeedRelayout = true; } 111 void relayoutNow(); 112 113 void detachDesktopTray(); 114 hidden()115 bool hidden() const { return fIsCollapsed | fIsHidden | !getFrame(); } 116 bool autoTimer(bool show); 117 void updateFullscreen(bool fullscreen); edgeTriggerWindow()118 Window edgeTriggerWindow() { return fEdgeTrigger->handle(); } 119 void switchToPrev(); 120 void switchToNext(); 121 void movePrev(); 122 void moveNext(); 123 void refresh(); 124 125 private: 126 void popOut(); 127 addressBar()128 AddressBar *addressBar() const { return fAddressBar; } taskPane()129 TaskPane *taskPane() const { return fTasks; } windowTrayPane()130 TrayPane *windowTrayPane() const { return fWindowTray; } 131 getGradient()132 virtual ref<YImage> getGradient() { return fGradient; } getSurface()133 const YSurface& getSurface() const { return fSurface; } 134 135 void contextMenu(int x_root, int y_root); 136 void buttonUpdate(); 137 void trayChanged(); netwmTray()138 YXTray *netwmTray() { return fDesktopTray; } 139 140 void initApplets(); 141 void updateLayout(unsigned& size_w, unsigned& size_h); 142 143 private: 144 YSurface fSurface; 145 TaskPane *fTasks; 146 147 ObjectButton *fCollapseButton; 148 TrayPane *fWindowTray; 149 ClockSet* fClock; 150 KeyboardStatus *fKeyboardStatus; 151 MailBoxControl *fMailBoxControl; 152 MEMStatus *fMEMStatus; 153 CPUStatusControl *fCPUStatus; 154 YApm *fApm; 155 NetStatusControl *fNetStatus; 156 157 ObjectBar *fObjectBar; 158 ObjectButton *fApplications; 159 ObjectButton *fWinList; 160 ObjectButton *fShowDesktop; 161 AddressBar *fAddressBar; 162 AWorkspaces *fWorkspaces; 163 YXTray *fDesktopTray; 164 EdgeTrigger *fEdgeTrigger; 165 YActionListener *wmActionListener; 166 YSMListener *smActionListener; 167 IApp *app; 168 169 lazy<TaskBarMenu> taskBarMenu; 170 ref<YImage> fGradient; 171 YArray<YFrameWindow*> fUpdates; 172 173 bool fIsHidden; 174 bool fFullscreen; 175 bool fIsCollapsed; 176 bool fMenuShown; 177 bool fNeedRelayout; 178 bool fButtonUpdate; 179 bool fWorkspacesUpdate; 180 181 class YStrut { 182 public: 183 Atom left, right, top, bottom; YStrut()184 YStrut() : left(0), right(0), top(0), bottom(0) { } 185 bool operator!=(const YStrut& s) const { 186 return left != s.left || right != s.right 187 || top != s.top || bottom != s.bottom; 188 } 189 const Atom* operator&() const { return &left; } 190 } fStrut; 191 }; 192 193 extern TaskBar *taskBar; // !!! get rid of this 194 195 extern YColorName taskBarBg; 196 197 #endif 198 199 // vim: set sw=4 ts=4 et: 200