1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 3 #ifndef _MANAGER_H_ 4 #define _MANAGER_H_ 5 6 #include "General.h" 7 #include "listmacro.h" 8 9 class Client; 10 declarePList(ClientList, Client); 11 12 #if CONFIG_GROUPS != False 13 declarePList(ListList, ClientList); 14 #endif 15 16 class WindowManager { 17 public: 18 WindowManager(int argc, char **argv); 19 ~WindowManager(); 20 21 void fatal(const char *); 22 23 // for call from Client and within: 24 25 Client *windowToClient(Window, Boolean create = False); activeClient()26 Client *activeClient() { return m_activeClient; } 27 Boolean raiseTransients(Client *); // true if raised any 28 Time timestamp(Boolean reset); 29 void clearFocus(); 30 31 void setActiveClient(Client *const c); 32 33 void addToHiddenList(Client *); 34 void removeFromHiddenList(Client *); 35 void skipInRevert(Client *, Client *); 36 display()37 Display *display() { return m_display; } root()38 Window root() { return m_root[screen()]; } mroot(int i)39 Window mroot(int i) { return m_root[i]; } screen()40 int screen() { return m_screenNumber; } screensTotal()41 int screensTotal() { return m_screensTotal; } setScreen(int i)42 void setScreen(int i) { m_screenNumber = i; } 43 void setScreenFromRoot(Window); 44 void setScreenFromPointer(); 45 altModMask()46 int altModMask() { return m_altModMask; } 47 48 enum RootCursor { 49 NormalCursor, DeleteCursor, DownCursor, RightCursor, DownrightCursor 50 }; 51 52 #if CONFIG_USE_WINDOW_GROUPS 53 void withdrawGroup(Window groupParent, Client *omit, 54 Boolean changeState = True); 55 void hideGroup(Window groupParent, Client *omit); 56 void unhideGroup(Window groupParent, Client *omit, Boolean map); 57 void killGroup(Window groupParent, Client *omit); 58 #endif 59 60 void installCursor(RootCursor); 61 void installCursorOnWindow(RootCursor, Window); 62 void installColormap(Colormap); 63 unsigned long allocateColour(int, const char *, const char *); 64 65 void considerFocusChange(Client *, Window, Time timestamp); 66 void stopConsideringFocus(); 67 68 // shouldn't really be public 69 int attemptGrab(Window, Window, int, int); 70 int attemptGrabKey(Window, int); 71 void releaseGrab(XButtonEvent *); 72 void releaseGrabKeyMode(XButtonEvent *); 73 void releaseGrabKeyMode(XKeyEvent *); 74 void spawn(char *, char *); 75 channel()76 int channel() { return m_currentChannel; } channels()77 int channels() { return m_channels; } setSignalled()78 void setSignalled() { m_looping = False; } // ... 79 void gotoChannel(int channel, Client *push); 80 void ensureChannelExists(int channel); 81 clients()82 ClientList &clients() { return m_clients; } hiddenClients()83 ClientList &hiddenClients() { return m_hiddenClients; } 84 85 void hoistToTop(Client *); 86 void hoistToBottom(Client *); 87 void removeFromOrderedList(Client *); 88 Boolean isTop(Client *); 89 90 // Instruct the X-Server to reorder the windows to match our ordering. 91 // Takes account of layering. 92 void updateStackingOrder(); 93 94 // for exposures during client grab, and window map/unmap/destroy 95 // during menu display: 96 void dispatchEvent(XEvent *); 97 98 #if CONFIG_GROUPS != False 99 void windowGrouping(XKeyEvent *ev, KeySym key, Client *c); 100 #endif 101 102 // debug output: 103 void printClientList(); 104 105 void netwmUpdateWindowList(); 106 void netwmUpdateStackingOrder(); 107 void netwmUpdateActiveClient(); 108 void netwmUpdateChannelList(); 109 void netwmUpdateCurrentChannel(); 110 111 // Stupid little helper function 112 static int numdigits(int); 113 114 private: 115 int loop(); 116 void release(); 117 118 Display *m_display; 119 int m_screenNumber; 120 int m_screensTotal; 121 122 Window *m_root; 123 124 Colormap *m_defaultColormap; 125 // int *m_minimumColormaps; 126 127 Cursor m_cursor; 128 Cursor m_xCursor; 129 Cursor m_vCursor; 130 Cursor m_hCursor; 131 Cursor m_vhCursor; 132 133 char *m_terminal; 134 char *m_shell; 135 136 ClientList m_clients; 137 ClientList m_hiddenClients; 138 139 ClientList m_orderedClients[MAX_LAYER + 1]; 140 // One list for each netwm/MWM layer 141 // Layer 4 (NORMAL_LAYER) is the default. 142 Client *m_activeClient; 143 144 #if CONFIG_GROUPS != False 145 ListList grouping; 146 #endif 147 148 int m_shapeEvent; 149 int m_currentTime; 150 151 int m_channels; 152 int m_currentChannel; // from 1 to ... 153 void flipChannel(Boolean statusOnly, Boolean flipDown, 154 Boolean quickFlip, Client *push); // bleah! 155 Window createNumberWindow(int screen, const char *colour); 156 int shapeNumberWindow(Window w, int number, int minDigits); // returns width in pixels 157 void instateChannel(); 158 void createNewChannel(); 159 void checkChannel(int); 160 Time m_channelChangeTime; 161 Window *m_channelWindow; 162 163 void updateClock(); 164 Window *m_clockWindow; 165 Time m_clockUpdateTime; 166 167 Boolean m_looping; 168 int m_returnCode; 169 170 static Boolean m_initialising; 171 static int errorHandler(Display *, XErrorEvent *); 172 static void sigHandler(int); 173 static int m_signalled; 174 static int m_restart; 175 176 void initialiseScreen(); 177 void scanInitialWindows(); 178 179 void circulate(Boolean activeFirst); 180 181 Boolean m_focusChanging; // checking times for focus change 182 Client *m_focusCandidate; 183 Window m_focusCandidateWindow; 184 Time m_focusTimestamp; // time of last crossing event 185 Boolean m_focusPointerMoved; 186 Boolean m_focusPointerNowStill; 187 void checkDelaysForFocus(); 188 189 #if CONFIG_USE_SESSION_MANAGER != False 190 int m_smFD; 191 IceConn m_smIceConnection; 192 SmcConn m_smConnection; 193 char *m_oldSessionId; 194 char *m_newSessionId; 195 char *m_sessionProgram; 196 197 static void smWatchFD(IceConn c, IcePointer, Bool, IcePointer *); 198 static void smSaveYourself(SmcConn, SmPointer, int, Bool, int, Bool); 199 static void smShutdownCancelled(SmcConn, SmPointer); 200 static void smSaveComplete(SmcConn, SmPointer); 201 static void smDie(SmcConn, SmPointer); 202 203 void initialiseSession(char *sessionProgram, char *oldSessionId); 204 void setSessionProperties(); 205 #endif 206 207 void nextEvent(XEvent *); // return 208 209 void eventButton(XButtonEvent *, XEvent *); 210 void eventKeyRelease(XKeyEvent *); 211 void eventMapRequest(XMapRequestEvent *); 212 void eventMap(XMapEvent *); 213 void eventConfigureRequest(XConfigureRequestEvent *); 214 void eventUnmap(XUnmapEvent *); 215 void eventCreate(XCreateWindowEvent *); 216 void eventDestroy(XDestroyWindowEvent *); 217 void eventClient(XClientMessageEvent *); 218 void eventColormap(XColormapEvent *); 219 void eventProperty(XPropertyEvent *); 220 void eventEnter(XCrossingEvent *); 221 void eventReparent(XReparentEvent *); 222 void eventFocusIn(XFocusInEvent *); 223 void eventExposure(XExposeEvent *); 224 225 Boolean m_altPressed; 226 Boolean m_altStateRetained; 227 void eventKeyPress(XKeyEvent *); 228 229 void netwmInitialiseCompliance(); 230 Window m_netwmCheckWin; 231 232 int m_altModMask; 233 }; 234 235 #endif 236 237