1 /** 2 * @file client.h 3 * @author Joe Wingbermuehle 4 * @date 2004-2007 5 * 6 * @brief Client window functions. 7 * 8 */ 9 10 #ifndef CLIENT_H 11 #define CLIENT_H 12 13 #include "main.h" 14 #include "border.h" 15 #include "hint.h" 16 17 struct TimeType; 18 19 /** Window border flags. 20 * We use an unsigned short for storing these, so we get at least 16 21 * on reasonable architectures. 22 */ 23 typedef unsigned short BorderFlags; 24 #define BORDER_NONE 0 25 #define BORDER_OUTLINE (1 << 0) /**< Window has a border. */ 26 #define BORDER_TITLE (1 << 1) /**< Window has a title bar. */ 27 #define BORDER_MIN (1 << 2) /**< Window supports minimize. */ 28 #define BORDER_MAX (1 << 3) /**< Window supports maximize. */ 29 #define BORDER_CLOSE (1 << 4) /**< Window supports close. */ 30 #define BORDER_RESIZE (1 << 5) /**< Window supports resizing. */ 31 #define BORDER_MOVE (1 << 6) /**< Window supports moving. */ 32 #define BORDER_MAX_V (1 << 7) /**< Maximize vertically. */ 33 #define BORDER_MAX_H (1 << 8) /**< Maximize horizontally. */ 34 #define BORDER_SHADE (1 << 9) /**< Allow shading. */ 35 #define BORDER_CONSTRAIN (1 << 10) /**< Constrain to the screen. */ 36 #define BORDER_FULLSCREEN (1 << 11) /**< Allow fullscreen. */ 37 38 /** The default border flags. */ 39 #define BORDER_DEFAULT ( \ 40 BORDER_OUTLINE \ 41 | BORDER_TITLE \ 42 | BORDER_MIN \ 43 | BORDER_MAX \ 44 | BORDER_CLOSE \ 45 | BORDER_RESIZE \ 46 | BORDER_MOVE \ 47 | BORDER_MAX_V \ 48 | BORDER_MAX_H \ 49 | BORDER_SHADE \ 50 | BORDER_FULLSCREEN ) 51 52 /** Window status flags. 53 * We use an unsigned int for storing these, so we get 32 on 54 * reasonable architectures. 55 */ 56 typedef unsigned int StatusFlags; 57 #define STAT_NONE 0 58 #define STAT_ACTIVE (1 << 0) /**< Has focus. */ 59 #define STAT_MAPPED (1 << 1) /**< Shown (on some desktop). */ 60 #define STAT_HIDDEN (1 << 2) /**< Not on the current desktop. */ 61 #define STAT_STICKY (1 << 3) /**< This client is on all desktops. */ 62 #define STAT_NOLIST (1 << 4) /**< Skip this client in the task list. */ 63 #define STAT_MINIMIZED (1 << 5) /**< Minimized. */ 64 #define STAT_SHADED (1 << 6) /**< Shaded. */ 65 #define STAT_WMDIALOG (1 << 7) /**< This is a JWM dialog window. */ 66 #define STAT_PIGNORE (1 << 8) /**< Ignore the program-position. */ 67 #define STAT_SDESKTOP (1 << 9) /**< Minimized to show desktop. */ 68 #define STAT_FULLSCREEN (1 << 10) /**< Full screen. */ 69 #define STAT_OPACITY (1 << 11) /**< Fixed opacity. */ 70 #define STAT_NOFOCUS (1 << 12) /**< Don't focus on map. */ 71 #define STAT_CANFOCUS (1 << 13) /**< Client accepts input focus. */ 72 #define STAT_DELETE (1 << 14) /**< Client accepts WM_DELETE. */ 73 #define STAT_TAKEFOCUS (1 << 15) /**< Client uses WM_TAKE_FOCUS. */ 74 #define STAT_URGENT (1 << 16) /**< Urgency hint is set. */ 75 #define STAT_NOTURGENT (1 << 17) /**< Ignore the urgency hint. */ 76 #define STAT_CENTERED (1 << 18) /**< Use centered window placement. */ 77 #define STAT_TILED (1 << 19) /**< Use tiled window placement. */ 78 #define STAT_IIGNORE (1 << 20) /**< Ignore increment when maximized. */ 79 #define STAT_NOPAGER (1 << 21) /**< Don't show in pager. */ 80 #define STAT_SHAPED (1 << 22) /**< This window is shaped. */ 81 #define STAT_FLASH (1 << 23) /**< Flashing for urgency. */ 82 #define STAT_DRAG (1 << 24) /**< Pass mouse events to JWM. */ 83 #define STAT_ILIST (1 << 25) /**< Ignore program-specified list. */ 84 #define STAT_IPAGER (1 << 26) /**< Ignore program-specified pager. */ 85 #define STAT_FIXED (1 << 27) /**< Keep on the specified desktop. */ 86 #define STAT_AEROSNAP (1 << 28) /**< Enable Aero Snap. */ 87 #define STAT_NODRAG (1 << 29) /**< Disable mod1+drag/resize. */ 88 #define STAT_POSITION (1 << 30) /**< Config-specified position. */ 89 90 /** Maximization flags. */ 91 typedef unsigned char MaxFlags; 92 #define MAX_NONE 0 /**< Don't maximize. */ 93 #define MAX_HORIZ (1 << 0) /**< Horizontal maximization. */ 94 #define MAX_VERT (1 << 1) /**< Vertical maximization. */ 95 #define MAX_LEFT (1 << 2) /**< Maximize on left. */ 96 #define MAX_RIGHT (1 << 3) /**< Maximize on right. */ 97 #define MAX_TOP (1 << 4) /**< Maximize on top. */ 98 #define MAX_BOTTOM (1 << 5) /**< Maximize on bottom. */ 99 100 /** Colormap window linked list. */ 101 typedef struct ColormapNode { 102 Window window; /**< A window containing a colormap. */ 103 struct ColormapNode *next; /**< Next value in the linked list. */ 104 } ColormapNode; 105 106 /** The aspect ratio of a window. */ 107 typedef struct AspectRatio { 108 int minx; /**< The x component of the minimum aspect ratio. */ 109 int miny; /**< The y component of the minimum aspect ratio. */ 110 int maxx; /**< The x component of the maximum aspect ratio. */ 111 int maxy; /**< The y component of the maximum aspect ratio. */ 112 } AspectRatio; 113 114 /** Struture to store information about a client window. */ 115 typedef struct ClientNode { 116 117 Window window; /**< The client window. */ 118 Window parent; /**< The frame window. */ 119 120 Window owner; /**< The owner window (for transients). */ 121 122 int x, y; /**< The location of the window. */ 123 int width; /**< The width of the window. */ 124 int height; /**< The height of the window. */ 125 int oldx; /**< The old x coordinate (for maximize). */ 126 int oldy; /**< The old y coordinate (for maximize). */ 127 int oldWidth; /**< The old width (for maximize). */ 128 int oldHeight; /**< The old height (for maximize). */ 129 130 long sizeFlags; /**< Size flags from XGetWMNormalHints. */ 131 int baseWidth; /**< Base width for resizing. */ 132 int baseHeight; /**< Base height for resizing. */ 133 int minWidth; /**< Minimum width of this window. */ 134 int minHeight; /**< Minimum height of this window. */ 135 int maxWidth; /**< Maximum width of this window. */ 136 int maxHeight; /**< Maximum height of this window. */ 137 int xinc; /**< Resize x increment. */ 138 int yinc; /**< Resize y increment. */ 139 AspectRatio aspect; /**< Aspect ratio. */ 140 int gravity; /**< Gravity for reparenting. */ 141 142 Colormap cmap; /**< This window's colormap. */ 143 ColormapNode *colormaps; /**< Colormaps assigned to this window. */ 144 145 char *name; /**< Name of this window for display. */ 146 char *instanceName; /**< Name of this window for properties. */ 147 char *className; /**< Name of the window class. */ 148 149 ClientState state; /**< Window state. */ 150 151 BorderActionType borderAction; 152 153 struct IconNode *icon; /**< Icon assigned to this window. */ 154 155 /** Callback to stop move/resize. */ 156 void (*controller)(int wasDestroyed); 157 158 struct ClientNode *prev; /**< The previous client in this layer. */ 159 struct ClientNode *next; /**< The next client in this layer. */ 160 161 } ClientNode; 162 163 /** The number of clients (maintained in client.c). */ 164 extern unsigned int clientCount; 165 166 /** Find a client by window or parent window. 167 * @param w The window. 168 * @return The client (NULL if not found). 169 */ 170 ClientNode *FindClient(Window w); 171 172 /** Find a client by window. 173 * @param w The window. 174 * @return The client (NULL if not found). 175 */ 176 ClientNode *FindClientByWindow(Window w); 177 178 /** Find a client by its parent window. 179 * @param p The parent window. 180 * @return The client (NULL if not found). 181 */ 182 ClientNode *FindClientByParent(Window p); 183 184 /** Get the active client. 185 * @return The active client (NULL if no client is active). 186 */ 187 ClientNode *GetActiveClient(void); 188 189 /*@{*/ 190 #define InitializeClients() (void)(0) 191 void StartupClients(void); 192 void ShutdownClients(void); 193 #define DestroyClients() (void)(0) 194 /*@}*/ 195 196 /** Add a window to management. 197 * @param w The client window. 198 * @param alreadyMapped 1 if the window is mapped, 0 if not. 199 * @param notOwner 1 if JWM doesn't own this window, 0 if JWM is the owner. 200 * @return The client window data. 201 */ 202 ClientNode *AddClientWindow(Window w, char alreadyMapped, char notOwner); 203 204 /** Remove a client from management. 205 * @param np The client to remove. 206 */ 207 void RemoveClient(ClientNode *np); 208 209 /** Minimize a client. 210 * @param np The client to minimize. 211 * @param lower Set to lower the client in the stacking order. 212 */ 213 void MinimizeClient(ClientNode *np, char lower); 214 215 /** Shade a client. 216 * @param np The client to shade. 217 */ 218 void ShadeClient(ClientNode *np); 219 220 /** Unshade a client. 221 * @param np The client to unshade. 222 */ 223 void UnshadeClient(ClientNode *np); 224 225 /** Set a client's status to withdrawn. 226 * A withdrawn client is a client that is not visible in any way to the 227 * user. This may be a window that an application keeps around so that 228 * it can be reused at a later time. 229 * @param np The client whose status to change. 230 */ 231 void SetClientWithdrawn(ClientNode *np); 232 233 /** Restore a client from minimized state. 234 * @param np The client to restore. 235 * @param raise 1 to raise the client, 0 to leave stacking unchanged. 236 */ 237 void RestoreClient(ClientNode *np, char raise); 238 239 /** Maximize a client. 240 * @param np The client to maximize (NULL is allowed). 241 * @param flags The type of maximization to perform. 242 */ 243 void MaximizeClient(ClientNode *np, MaxFlags flags); 244 245 /** Maximize a client using the default maximize settings. 246 * @param np The client to maximize. 247 */ 248 void MaximizeClientDefault(ClientNode *np); 249 250 /** Set the full screen status of a client. 251 * @param np The client. 252 * @param fullScreen 1 to make full screen, 0 to make not full screen. 253 */ 254 void SetClientFullScreen(ClientNode *np, char fullScreen); 255 256 /** Set the keyboard focus to a client. 257 * @param np The client to focus. 258 */ 259 void FocusClient(ClientNode *np); 260 261 /** Set the keyboard focus back to the active client. */ 262 void RefocusClient(void); 263 264 /** Tell a client to exit. 265 * @param np The client to delete. 266 */ 267 void DeleteClient(ClientNode *np); 268 269 /** Force a client to exit. 270 * @param np The client to kill. 271 */ 272 void KillClient(ClientNode *np); 273 274 /** Raise a client to the top of its layer. 275 * @param np The client to raise. 276 */ 277 void RaiseClient(ClientNode *np); 278 279 /** Restack a client. 280 * @param np The client to restack. 281 * @param above A reference window (or None). 282 * @param detail The stack mode (Above, Below, etc). 283 */ 284 void RestackClient(ClientNode *np, Window above, int detail); 285 286 /** Restack the clients. 287 * This is used when a client is mapped so that the stacking order 288 * remains consistent. 289 */ 290 void RestackClients(void); 291 292 /** Set the layer of a client. 293 * @param np The client whose layer to set. 294 * @param layer the layer to assign to the client. 295 */ 296 void SetClientLayer(ClientNode *np, unsigned int layer); 297 298 /** Set the desktop for a client. 299 * @param np The client. 300 * @param desktop The desktop to be assigned to the client. 301 */ 302 void SetClientDesktop(ClientNode *np, unsigned int desktop); 303 304 /** Set the sticky status of a client. 305 * A sticky client will appear on all desktops. 306 * @param np The client. 307 * @param isSticky 1 to make the client sticky, 0 to make it not sticky. 308 */ 309 void SetClientSticky(ClientNode *np, char isSticky); 310 311 /** Hide a client. 312 * This is used for changing desktops. 313 * @param np The client to hide. 314 */ 315 void HideClient(ClientNode *np); 316 317 /** Show a client. 318 * This is used for changing desktops. 319 * @param np The client to show. 320 */ 321 void ShowClient(ClientNode *np); 322 323 /** Update a client's colormap. 324 * @param np The client. 325 */ 326 void UpdateClientColormap(ClientNode *np); 327 328 /** Reparent a client. 329 * This will create a window for a frame (or destroy it) depending on 330 * whether a client needs a frame. 331 * @param np The client. 332 */ 333 void ReparentClient(ClientNode *np); 334 335 /** Send a configure event to a client. 336 * This will send updated location and size information to a client. 337 * @param np The client to get the event. 338 */ 339 void SendConfigureEvent(ClientNode *np); 340 341 /** Send a message to a client. 342 * @param w The client window. 343 * @param type The type of message to send. 344 * @param message The message to send. 345 */ 346 void SendClientMessage(Window w, AtomType type, AtomType message); 347 348 /** Update callback for clients with the urgency hint set. */ 349 void SignalUrgent(const struct TimeType *now, int x, int y, Window w, 350 void *data); 351 352 #endif /* CLIENT_H */ 353 354