Better error message when defaults file is missing.
[xfwm4.git] / src / client.h
blobd6cdca87f4febff8ed08997bade225f50b52073d
1 /* $Id$
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 oroborus - (c) 2001 Ken Lynch
18 xfwm4 - (c) 2002-2007 Olivier Fourdan
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <string.h>
29 #include <signal.h>
30 #include <unistd.h>
32 #include <X11/X.h>
33 #include <X11/Xlib.h>
34 #include <X11/Xutil.h>
35 #include <X11/Xmd.h>
36 #include <X11/cursorfont.h>
37 #include <X11/extensions/shape.h>
39 #include <glib.h>
40 #include <gtk/gtk.h>
41 #include <sys/time.h>
42 #include <time.h>
44 #include "screen.h"
45 #include "misc.h"
46 #include "hints.h"
47 #include "keyboard.h"
48 #include "mypixmap.h"
49 #include "mywindow.h"
50 #include "settings.h"
52 #ifndef INC_CLIENT_H
53 #define INC_CLIENT_H
55 #define APPLY +1
56 #define REMOVE -1
58 #define PLACEMENT_MOUSE 0
59 #define PLACEMENT_ROOT 1
61 #define NO_CFG_FLAG 0
62 #define CFG_CONSTRAINED (1<<0)
63 #define CFG_REQUEST (1<<1)
64 #define CFG_NOTIFY (1<<2)
65 #define CFG_FORCE_REDRAW (1<<3)
67 #define INCLUDE_HIDDEN (1<<0)
68 #define INCLUDE_SHADED (1<<1)
69 #define INCLUDE_ALL_WORKSPACES (1<<2)
70 #define INCLUDE_SKIP_FOCUS (1<<3)
71 #define INCLUDE_SKIP_PAGER (1<<4)
72 #define INCLUDE_SKIP_TASKBAR (1<<5)
74 #define NO_UPDATE_FLAG 0
75 #define UPDATE_BUTTON_GRABS (1<<0)
76 #define UPDATE_FRAME (1<<1)
77 #define UPDATE_GRAVITY (1<<2)
78 #define UPDATE_MAXIMIZE (1<<3)
79 #define UPDATE_CACHE (1<<4)
80 #define UPDATE_ALL (UPDATE_BUTTON_GRABS | \
81 UPDATE_FRAME | \
82 UPDATE_GRAVITY | \
83 UPDATE_MAXIMIZE | \
84 UPDATE_CACHE)
86 #define CLIENT_FILL_VERT (1L<<0)
87 #define CLIENT_FILL_HORIZ (1L<<1)
88 #define CLIENT_FILL (CLIENT_FILL_VERT | \
89 CLIENT_FILL_HORIZ)
92 #define STRUTS_SIZE 12
94 #ifndef CLIENT_MIN_VISIBLE
95 #define CLIENT_MIN_VISIBLE 15
96 #endif
98 #ifndef CLIENT_XSYNC_TIMEOUT
99 #define CLIENT_XSYNC_TIMEOUT 1000 /* ms */
100 #endif
102 #ifndef CLIENT_BLINK_TIMEOUT
103 #define CLIENT_BLINK_TIMEOUT 500 /* ms */
104 #endif
106 #define XFWM_FLAG_HAS_BORDER (1L<<0)
107 #define XFWM_FLAG_HAS_MENU (1L<<1)
108 #define XFWM_FLAG_HAS_MAXIMIZE (1L<<2)
109 #define XFWM_FLAG_HAS_CLOSE (1L<<3)
110 #define XFWM_FLAG_HAS_HIDE (1L<<4)
111 #define XFWM_FLAG_HAS_MOVE (1L<<5)
112 #define XFWM_FLAG_HAS_RESIZE (1L<<6)
113 #define XFWM_FLAG_HAS_STICK (1L<<7)
114 #define XFWM_FLAG_FOCUS (1L<<8)
115 #define XFWM_FLAG_IS_RESIZABLE (1L<<9)
116 #define XFWM_FLAG_MAP_PENDING (1L<<10)
117 #define XFWM_FLAG_VISIBLE (1L<<11)
118 #define XFWM_FLAG_MANAGED (1L<<13)
119 #define XFWM_FLAG_SESSION_MANAGED (1L<<14)
120 #define XFWM_FLAG_WORKSPACE_SET (1L<<15)
121 #define XFWM_FLAG_WAS_SHOWN (1L<<16)
122 #define XFWM_FLAG_DRAW_ACTIVE (1L<<17)
123 #define XFWM_FLAG_SEEN_ACTIVE (1L<<18)
124 #define XFWM_FLAG_FIRST_MAP (1L<<19)
125 #define XFWM_FLAG_LEGACY_FULLSCREEN (1L<<20)
126 #define XFWM_FLAG_MOVING_RESIZING (1L<<21)
128 #define CLIENT_FLAG_HAS_STRUT (1L<<0)
129 #define CLIENT_FLAG_HAS_STRUT_PARTIAL (1L<<1)
130 #define CLIENT_FLAG_HAS_USER_TIME (1L<<2)
131 #define CLIENT_FLAG_HAS_STARTUP_TIME (1L<<3)
132 #define CLIENT_FLAG_ABOVE (1L<<4)
133 #define CLIENT_FLAG_BELOW (1L<<5)
134 #define CLIENT_FLAG_FULLSCREEN (1L<<6)
135 #define CLIENT_FLAG_ICONIFIED (1L<<7)
136 #define CLIENT_FLAG_MAXIMIZED_VERT (1L<<8)
137 #define CLIENT_FLAG_MAXIMIZED_HORIZ (1L<<9)
138 #define CLIENT_FLAG_MAXIMIZED (CLIENT_FLAG_MAXIMIZED_VERT | \
139 CLIENT_FLAG_MAXIMIZED_HORIZ)
140 #define CLIENT_FLAG_SHADED (1L<<10)
141 #define CLIENT_FLAG_SKIP_PAGER (1L<<11)
142 #define CLIENT_FLAG_SKIP_TASKBAR (1L<<12)
143 #define CLIENT_FLAG_STATE_MODAL (1L<<13)
144 #define CLIENT_FLAG_STICKY (1L<<15)
145 #define CLIENT_FLAG_NAME_CHANGED (1L<<16)
146 #define CLIENT_FLAG_DEMANDS_ATTENTION (1L<<17)
147 #define CLIENT_FLAG_HAS_SHAPE (1L<<18)
149 #define WM_FLAG_DELETE (1L<<0)
150 #define WM_FLAG_INPUT (1L<<1)
151 #define WM_FLAG_TAKEFOCUS (1L<<2)
152 #define WM_FLAG_CONTEXT_HELP (1L<<3)
153 #define WM_FLAG_URGENT (1L<<4)
155 #define CLIENT_FLAG_INITIAL_VALUES XFWM_FLAG_HAS_BORDER | \
156 XFWM_FLAG_HAS_MENU | \
157 XFWM_FLAG_HAS_MAXIMIZE | \
158 XFWM_FLAG_HAS_STICK | \
159 XFWM_FLAG_HAS_HIDE | \
160 XFWM_FLAG_HAS_CLOSE | \
161 XFWM_FLAG_HAS_MOVE | \
162 XFWM_FLAG_HAS_RESIZE | \
163 XFWM_FLAG_FIRST_MAP
165 #define ALL_WORKSPACES (int) 0xFFFFFFFF
167 #define CONSTRAINED_WINDOW(c) ((c->win_layer > WIN_LAYER_DESKTOP) && \
168 !(c->type & (WINDOW_DESKTOP | WINDOW_DOCK)) && \
169 !FLAG_TEST(c->xfwm_flags, XFWM_FLAG_LEGACY_FULLSCREEN))
171 #define WINDOW_TYPE_DIALOG (WINDOW_DIALOG | \
172 WINDOW_MODAL_DIALOG)
173 #define WINDOW_TYPE_DONT_PLACE (WINDOW_DESKTOP | \
174 WINDOW_DOCK | \
175 WINDOW_UTILITY | \
176 WINDOW_SPLASHSCREEN)
177 #define WINDOW_REGULAR_FOCUSABLE (WINDOW_NORMAL | \
178 WINDOW_DIALOG | \
179 WINDOW_MODAL_DIALOG)
180 #define WINDOW_TYPE_DONT_FOCUS (WINDOW_SPLASHSCREEN | \
181 WINDOW_DOCK)
183 /* Which bits of opacity are applied */
184 #define OPACITY_MOVE (1<<0)
185 #define OPACITY_RESIZE (1<<1)
186 #define OPACITY_INACTIVE (1<<2)
188 /* Convenient macros */
189 #define FLAG_TEST(flag,bits) (flag & (bits))
190 #define FLAG_TEST_ALL(flag,bits) ((flag & (bits)) == (bits))
191 #define FLAG_TEST_AND_NOT(flag,bits1,bits2) ((flag & (bits1 | bits2)) == (bits1))
192 #define FLAG_SET(flag,bits) (flag |= (bits))
193 #define FLAG_UNSET(flag,bits) (flag &= ~(bits))
194 #define FLAG_TOGGLE(flag,bits) (flag ^= (bits))
196 #define CLIENT_CAN_HIDE_WINDOW(c) (!(c->transient_for) && \
197 FLAG_TEST(c->xfwm_flags, XFWM_FLAG_HAS_HIDE) && \
198 !FLAG_TEST(c->flags, CLIENT_FLAG_SKIP_TASKBAR))
199 #define CLIENT_CAN_MAXIMIZE_WINDOW(c) (FLAG_TEST_AND_NOT(c->xfwm_flags, XFWM_FLAG_HAS_MAXIMIZE | \
200 XFWM_FLAG_HAS_RESIZE | \
201 XFWM_FLAG_IS_RESIZABLE, \
202 XFWM_FLAG_LEGACY_FULLSCREEN) && \
203 !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
204 #define CLIENT_CAN_FILL_WINDOW(c) (FLAG_TEST_AND_NOT(c->xfwm_flags, XFWM_FLAG_HAS_RESIZE | \
205 XFWM_FLAG_IS_RESIZABLE, \
206 XFWM_FLAG_LEGACY_FULLSCREEN) && \
207 !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN | CLIENT_FLAG_MAXIMIZED))
209 #define CLIENT_CAN_STICK_WINDOW(c) (!(c->transient_for) && \
210 FLAG_TEST(c->xfwm_flags, XFWM_FLAG_HAS_STICK))
212 typedef enum
214 UNSET = 0,
215 WINDOW_NORMAL = (1 << 0),
216 WINDOW_DESKTOP = (1 << 1),
217 WINDOW_DOCK = (1 << 2),
218 WINDOW_DIALOG = (1 << 3),
219 WINDOW_MODAL_DIALOG = (1 << 4),
220 WINDOW_TOOLBAR = (1 << 5),
221 WINDOW_MENU = (1 << 6),
222 WINDOW_UTILITY = (1 << 7),
223 WINDOW_SPLASHSCREEN = (1 << 8)
225 netWindowType;
227 struct _Client
229 /* Reference to our screen structure */
230 ScreenInfo *screen_info;
232 Window window;
233 Window frame;
234 Window transient_for;
235 Window *cmap_windows;
236 xfwmWindow title;
237 xfwmWindow sides[SIDE_COUNT];
238 xfwmWindow corners[CORNER_COUNT];
239 xfwmWindow buttons[BUTTON_COUNT];
240 Window client_leader;
241 Window group_leader;
242 xfwmPixmap appmenu[STATE_TOGGLED];
243 Colormap cmap;
244 unsigned long win_hints;
245 unsigned long win_state;
246 unsigned long win_layer;
247 unsigned long serial;
248 Atom type_atom;
249 Visual *visual;
250 XSizeHints *size;
251 XWMHints *wmhints;
252 XClassHint class;
253 Client *next;
254 Client *prev;
255 netWindowType type;
256 int x;
257 int y;
258 int width;
259 int height;
260 int depth;
261 int border_width;
262 int gravity;
263 int win_workspace;
264 unsigned int ignore_unmap;
265 int old_x;
266 int old_y;
267 int old_width;
268 int old_height;
269 int fullscreen_old_x;
270 int fullscreen_old_y;
271 int fullscreen_old_width;
272 int fullscreen_old_height;
273 int fullscreen_old_layer;
274 int previous_width;
275 int previous_height;
276 int initial_layer;
277 int ncmap;
278 int button_status[BUTTON_COUNT];
279 int struts[STRUTS_SIZE];
280 gchar *name;
281 Time user_time;
282 unsigned long flags;
283 unsigned long wm_flags;
284 unsigned long xfwm_flags;
285 /* Timout for asynchronous icon update */
286 guint icon_timeout_id;
287 /* Timout for asynchronous frame update */
288 guint frame_timeout_id;
289 /* Timout to manage blinking decorations for urgent windows */
290 guint blink_timeout_id;
291 /* Opacity for the compositor */
292 guint opacity;
293 guint opacity_applied;
294 guint opacity_flags;
295 gboolean opacity_locked;
297 #ifdef HAVE_LIBSTARTUP_NOTIFICATION
298 /* Startup notification */
299 gchar *startup_id;
300 #endif /* HAVE_LIBSTARTUP_NOTIFICATION */
302 #ifdef HAVE_XSYNC
303 XSyncAlarm xsync_alarm;
304 XSyncCounter xsync_counter;
305 XSyncValue xsync_value;
306 guint xsync_timeout_id;
307 gboolean xsync_waiting;
308 gboolean xsync_enabled;
309 #endif /* HAVE_XSYNC */
312 extern Client *clients;
313 extern unsigned int client_count;
315 Display *clientGetXDisplay (Client *);
316 void clientClearLastOpTime (Client *);
317 void clientUpdateWinState (Client *,
318 XClientMessageEvent *);
319 void clientUpdateUrgency (Client *);
320 void clientCoordGravitate (Client *,
321 int,
322 int *,
323 int *);
324 void clientGravitate (Client *,
325 int);
326 void clientConfigure (Client *,
327 XWindowChanges *,
328 unsigned long,
329 unsigned short);
330 void clientGetMWMHints (Client *,
331 gboolean);
332 void clientGetWMNormalHints (Client *,
333 gboolean);
334 void clientGetWMProtocols (Client *);
335 void clientUpdateIcon (Client * c);
336 Client *clientFrame (DisplayInfo *,
337 Window,
338 gboolean);
339 void clientUnframe (Client *,
340 gboolean);
341 void clientFrameAll (ScreenInfo *);
342 void clientUnframeAll (ScreenInfo *);
343 void clientInstallColormaps (Client *);
344 void clientUpdateColormaps (Client *);
345 void clientUpdateName (Client *);
346 void clientUpdateAllFrames (ScreenInfo *,
347 gboolean);
348 void clientGrabButtons (Client *);
349 void clientUngrabButtons (Client *);
350 Client *clientGetFromWindow (Client *,
351 Window,
352 unsigned short);
353 void clientShow (Client *,
354 gboolean);
355 void clientHide (Client *,
356 int,
357 gboolean);
358 void clientHideAll (Client *,
359 int);
360 void clientClearAllShowDesktop (ScreenInfo *);
361 void clientToggleShowDesktop (ScreenInfo *);
362 void clientActivate (Client *,
363 Time);
364 void clientClose (Client *);
365 void clientKill (Client *);
366 void clientEnterContextMenuState (Client *);
367 void clientSetLayer (Client *,
368 int);
369 void clientSetWorkspace (Client *,
370 int,
371 gboolean);
372 void clientShade (Client *);
373 void clientUnshade (Client *);
374 void clientToggleShaded (Client *);
375 void clientStick (Client *,
376 gboolean);
377 void clientUnstick (Client *,
378 gboolean);
379 void clientToggleSticky (Client *,
380 gboolean);
381 void clientToggleFullscreen (Client *);
382 void clientToggleAbove (Client *);
383 void clientToggleBelow (Client *);
384 void clientRemoveMaximizeFlag (Client *);
385 void clientToggleMaximized (Client *,
386 int,
387 gboolean);
388 void clientFill (Client *,
389 int);
390 void clientUpdateOpacity (ScreenInfo *,
391 Client *);
392 void clientSetOpacity (Client *,
393 guint,
394 guint, guint);
395 void clientIncOpacity (Client *);
396 void clientDecOpacity (Client *);
397 void clientScreenResize (ScreenInfo *);
398 void clientMove (Client *,
399 XEvent *);
400 void clientResize (Client *,
401 int,
402 XEvent *);
403 void clientCycle (Client *,
404 XEvent *);
405 void clientButtonPress (Client *,
406 Window,
407 XButtonEvent *);
408 xfwmPixmap * clientGetButtonPixmap (Client *,
409 int,
410 int);
411 int clientGetButtonState (Client *,
412 int,
413 int);
414 Client *clientGetLeader (Client *);
415 #ifdef HAVE_LIBSTARTUP_NOTIFICATION
416 char *clientGetStartupId (Client *);
417 #endif /* HAVE_LIBSTARTUP_NOTIFICATION */
418 #ifdef HAVE_XSYNC
419 void clientXSyncRequest (Client *);
420 #endif /* HAVE_XSYNC */
422 #endif /* INC_CLIENT_H */