monitor.h (5850B)
1 // Copyright (c) 2003 - 2009 Anselm R Garbe <anselm@garbe.us> 2 // See LICENSE for license details. 3 4 #ifndef __MONITOR_H 5 #define __MONITOR_H 6 7 extern "C" { 8 #include <X11/Xlib.h> 9 } 10 11 #include <list> 12 #include <map> 13 #include <string> 14 #include "wmi.h" 15 16 #include "container.h" 17 #include "rectangle.h" 18 19 class Action; 20 class Box; 21 class Client; 22 class ClientBar; 23 class Frame; 24 class InputBar; 25 class Manager; 26 class MultiFrame; 27 #ifdef SLOT_SUPPORT 28 class Slot; 29 #endif // SLOT_SUPPORT 30 class StatusBar; 31 class Theme; 32 class Thing; 33 class WFont; 34 class Workspace; 35 class XFont; 36 37 typedef list<Client *> LClient; 38 typedef list<Thing *> LThing; 39 typedef list<Workspace *> LWorkspace; 40 typedef map<long, Client *, less<long> > MClient; 41 typedef map<string, string, less<string> > MSettings; 42 typedef Container<Monitor, LClient, LClient::iterator, Client> CClient; 43 44 /** 45 * Represents a physical monitor in multi-head or single-head 46 * configurations not using Xinerama or a Xinerama monitor in 47 * configurations using Xinerama of WMI. 48 */ 49 class Monitor : 50 public Container<Display, LWorkspace, LWorkspace::iterator, Workspace>, 51 public Rectangle 52 { 53 54 public: 55 56 //////////////////////////////////////////////////////////// 57 // Monitor stuff 58 Monitor(Display *display, unsigned int id); 59 ~Monitor(); 60 61 unsigned int id() const; 62 63 /** Returns the root window of this monitor. */ 64 Window rootWindow() const; 65 66 string displayString() const; 67 68 Theme *theme() const; 69 70 unsigned int resizeFactor() const; 71 72 string prefix() const; 73 74 void serialize(); 75 76 //////////////////////////////////////////////////////////// 77 // Bar stuff 78 StatusBar *statusBar() const; 79 80 ClientBar *clientBar() const; 81 82 InputBar *inputBar() const; 83 84 void toggleStatusBar(); 85 86 void toggleClientBar(); 87 88 void scanWindows(); 89 void updateBars(); 90 91 //////////////////////////////////////////////////////////// 92 // Client stuff 93 94 Client *focusedClient(); 95 96 /** 97 * Returns the client for the given window if it exists, 98 * otherwise <code>0</code>. 99 * If the window is the root window or <code>0</code> 100 * then <code>0</code> will be returned. 101 */ 102 Client *clientForWindow(Window window); 103 104 /** Adds client. */ 105 void addClient(Client *client); 106 107 /** Removes the specified client. */ 108 void removeClient(Client *client); 109 110 void detachClient(); // hide 111 void detachClient(Client *client); 112 void attachLastClient(); // show 113 void attachClientByName(string name); // show 114 // with transient handling 115 void attachClient(Client *client); 116 117 /** Attaches all detached clients. */ 118 void attachAllClients(); 119 void detachAllClients(); 120 void toggleAllClientStates(); 121 122 CClient *detachedClients(); 123 124 /** Maximization handling. */ 125 void toggleThingMaximization(); 126 127 bool isThingMaximized(); 128 129 /** Attaches detached client to workspace. */ 130 void attachDetachedClient(Workspace *workspace, Client *client); 131 132 unsigned int titleBarHeight() const; 133 unsigned int buttonWidth() const; 134 135 //////////////////////////////////////////////////////////// 136 // Workspace stuff 137 void createNewWorkspace(string name); 138 139 void focus(Workspace *workspace); 140 void focusWorkspaceNum(unsigned int workspaceNum); 141 void focusWorkspaceByName(string name); 142 void focusClientByName(string name); 143 void focusClientById(string id); 144 145 void destroyWorkspace(Workspace *workspace); 146 147 /** Rename methods. */ 148 void renameWorkspace(Workspace *workspace, string newName); 149 150 void matchWorkspace(Workspace *workspace, Direction dir); 151 void illuminateTransRect(Rectangle *rect, unsigned int barHeight = 0); 152 void illuminateTransText(Rectangle *rect, string text); 153 154 Thing *thingWindow(Window window); 155 156 Bar *barWindow(Window window); 157 158 Menu *menuWindow(Window window); 159 160 #ifdef SLOT_SUPPORT 161 Slot *slotWindow(Window window); 162 Slot *slot() const; 163 void unslotClient(); 164 void slotClient(); 165 void toggleSlot(); 166 void cycleSlotTabPrev(); 167 void cycleSlotTabNext(); 168 #endif // SLOT_SUPPORT 169 170 /** 171 * Used for differentiation of clients, each client has an 172 * unique id. 173 */ 174 unsigned int nextClientId(); 175 176 void resetClientId() { 177 clientIds_ = 0; 178 }; 179 180 GC borderGC(); 181 182 CClient *stickyClients(); 183 184 WFont *font() const; 185 186 /** 187 * Reparents all client windows to the root window, destroys all 188 * frames and WMI related items of clients. 189 */ 190 void cleanup(); 191 192 MClient *clients(); 193 void banish(); 194 195 Workspace *workspaceForName(string name); 196 197 Box *box() const; 198 199 void hookClient(); 200 void unhookClient(); 201 202 private: 203 204 /** Inits all fonts. */ 205 void initFonts(); 206 207 /** Inits display string. */ 208 void initDisplayString(); 209 210 /** Inits workspaces. */ 211 void initWorkspaces(); 212 213 /** Inits the bar. */ 214 void initBars(); 215 216 /** Inits gc. */ 217 void initGC(); 218 219 /** Initializes rectangle with workspace size. */ 220 void rectForWorkspace(Workspace *workspace); 221 222 void focusClient(Client *client); 223 224 GC pseudoBorderGC_; 225 GC borderGC_; 226 Window rootWindow_; 227 WFont *font_; 228 XFont *fixed_; // default font for pseudo border, if XFT 229 // font is used 230 231 232 Box *box_; 233 StatusBar *statusBar_; 234 ClientBar *clientBar_; 235 InputBar *inputBar_; 236 237 #ifdef SLOT_SUPPORT 238 /** Inits slot. */ 239 void initSlot(); 240 241 Slot *slot_; 242 #endif // SLOT_SUPPORT 243 244 245 unsigned int resizeFactor_; 246 247 unsigned int id_; 248 249 string displayString_; 250 251 Theme *theme_; 252 253 MClient clients_; 254 255 CClient detachedClients_; 256 CClient stickyClients_; 257 258 MSettings *themeSettings_; 259 MSettings *sessionSettings_; 260 MSettings *commonSettings_; 261 string prefix_; 262 263 Thing *maxThing_; 264 265 unsigned int clientIds_; 266 }; 267 268 #endif // __MONITOR_H