Coverity: fix WPrefs workspace negative array index read
[wmaker-crm.git] / src / WindowMaker.h
blobe1b49295dc0efbd3492d4099c6c6c2b97dc4c175
1 /*
2 * Window Maker window manager
4 * Copyright (c) 1997-2003 Alfredo K. Kojima
5 * Copyright (c) 2014 Window Maker Team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef WINDOWMAKER_H_
23 #define WINDOWMAKER_H_
25 #include "wconfig.h"
26 #include <assert.h>
27 #include <limits.h>
28 #include <WINGs/WINGs.h>
31 /* class codes */
32 typedef enum {
33 WCLASS_UNKNOWN = 0,
34 WCLASS_WINDOW = 1, /* managed client windows */
35 WCLASS_MENU = 2, /* root menus */
36 WCLASS_APPICON = 3,
37 WCLASS_DUMMYWINDOW = 4, /* window that holds window group leader */
38 WCLASS_MINIWINDOW = 5,
39 WCLASS_DOCK_ICON = 6,
40 WCLASS_PAGER = 7,
41 WCLASS_TEXT_INPUT = 8,
42 WCLASS_FRAME = 9
43 } WClassType;
47 * generic window levels (a superset of the N*XTSTEP ones)
48 * Applications should use levels between WMDesktopLevel and
49 * WMScreensaverLevel anything boyond that range is allowed,
50 * but discouraged.
52 enum {
53 WMBackLevel = INT_MIN+1, /* Very lowest level */
54 WMDesktopLevel = -1000, /* Lowest level of normal use */
55 WMSunkenLevel = -1,
56 WMNormalLevel = 0,
57 WMFloatingLevel = 3,
58 WMDockLevel = 5,
59 WMSubmenuLevel = 15,
60 WMMainMenuLevel = 20,
61 WMStatusLevel = 21,
62 WMFullscreenLevel = 50,
63 WMModalLevel = 100,
64 WMPopUpLevel = 101,
65 WMScreensaverLevel = 1000,
66 WMOuterSpaceLevel = INT_MAX
70 * WObjDescriptor will be used by the event dispatcher to
71 * send events to a particular object through the methods in the
72 * method table. If all objects of the same class share the
73 * same methods, the class method table should be used, otherwise
74 * a new method table must be created for each object.
75 * It is also assigned to find the parent structure of a given
76 * window (like the WWindow or WMenu for a button)
79 typedef struct WObjDescriptor {
80 void *self; /* the object that will be called */
81 /* event handlers */
82 void (*handle_expose)(struct WObjDescriptor *sender, XEvent *event);
83 void (*handle_mousedown)(struct WObjDescriptor *sender, XEvent *event);
84 void (*handle_enternotify)(struct WObjDescriptor *sender, XEvent *event);
85 void (*handle_leavenotify)(struct WObjDescriptor *sender, XEvent *event);
87 WClassType parent_type; /* type code of the parent */
88 void *parent; /* parent object (WWindow or WMenu) */
89 } WObjDescriptor;
91 /* internal buttons */
92 #define WBUT_CLOSE 0
93 #define WBUT_BROKENCLOSE 1
94 #define WBUT_ICONIFY 2
95 #define WBUT_KILL 3
96 #ifdef XKB_BUTTON_HINT
97 #define WBUT_XKBGROUP1 4
98 #define WBUT_XKBGROUP2 5
99 #define WBUT_XKBGROUP3 6
100 #define WBUT_XKBGROUP4 7
101 #define PRED_BPIXMAPS 8 /* reserved for 4 groups */
102 #else
103 #define PRED_BPIXMAPS 4 /* count of WBUT icons */
104 #endif /* XKB_BUTTON_HINT */
106 /* Mouse cursors */
107 typedef enum {
108 WCUR_NORMAL,
109 WCUR_MOVE,
110 WCUR_RESIZE,
111 WCUR_TOPLEFTRESIZE,
112 WCUR_TOPRIGHTRESIZE,
113 WCUR_BOTTOMLEFTRESIZE,
114 WCUR_BOTTOMRIGHTRESIZE,
115 WCUR_VERTICALRESIZE,
116 WCUR_HORIZONRESIZE,
117 WCUR_WAIT,
118 WCUR_ARROW,
119 WCUR_QUESTION,
120 WCUR_TEXT,
121 WCUR_SELECT,
122 WCUR_ROOT,
123 WCUR_EMPTY,
125 /* Count of the number of cursors defined */
126 WCUR_LAST
127 } w_cursor;
129 /* geometry displays */
130 #define WDIS_NEW 0 /* new style */
131 #define WDIS_CENTER 1 /* center of screen */
132 #define WDIS_TOPLEFT 2 /* top left corner of screen */
133 #define WDIS_FRAME_CENTER 3 /* center of the frame */
134 #define WDIS_NONE 4
136 /* keyboard input focus mode */
137 #define WKF_CLICK 0
138 #define WKF_SLOPPY 2
140 /* colormap change mode */
141 #define WCM_CLICK 0
142 #define WCM_POINTER 1
144 /* window placement mode */
145 #define WPM_MANUAL 0
146 #define WPM_CASCADE 1
147 #define WPM_SMART 2
148 #define WPM_RANDOM 3
149 #define WPM_AUTO 4
150 #define WPM_CENTER 5
152 /* text justification */
153 #define WTJ_CENTER 0
154 #define WTJ_LEFT 1
155 #define WTJ_RIGHT 2
157 /* iconification styles */
158 #define WIS_ZOOM 0
159 #define WIS_TWIST 1
160 #define WIS_FLIP 2
161 #define WIS_NONE 3
162 #define WIS_RANDOM 4 /* secret */
164 /* switchmenu actions */
165 #define ACTION_ADD 0
166 #define ACTION_REMOVE 1
167 #define ACTION_CHANGE 2
168 #define ACTION_CHANGE_WORKSPACE 3
169 #define ACTION_CHANGE_STATE 4
172 /* speeds */
173 #define SPEED_ULTRAFAST 0
174 #define SPEED_FAST 1
175 #define SPEED_MEDIUM 2
176 #define SPEED_SLOW 3
177 #define SPEED_ULTRASLOW 4
180 /* window states */
181 #define WS_FOCUSED 0
182 #define WS_UNFOCUSED 1
183 #define WS_PFOCUSED 2
185 /* clip title colors */
186 #define CLIP_NORMAL 0
187 #define CLIP_COLLAPSED 1
190 /* icon yard position */
191 #define IY_VERT 1
192 #define IY_HORIZ 0
193 #define IY_TOP 2
194 #define IY_BOTTOM 0
195 #define IY_RIGHT 4
196 #define IY_LEFT 0
199 /* menu styles */
200 #define MS_NORMAL 0
201 #define MS_SINGLE_TEXTURE 1
202 #define MS_FLAT 2
204 /* workspace actions */
205 #define WA_NONE 0
206 #define WA_SELECT_WINDOWS 1
207 #define WA_OPEN_APPMENU 2
208 #define WA_OPEN_WINLISTMENU 3
209 #define WA_SWITCH_WORKSPACES 4
210 #define WA_MOVE_PREVWORKSPACE 5
211 #define WA_MOVE_NEXTWORKSPACE 6
212 #define WA_SWITCH_WINDOWS 7
213 #define WA_MOVE_PREVWINDOW 8
214 #define WA_MOVE_NEXTWINDOW 9
216 /* workspace display position */
217 #define WD_NONE 0
218 #define WD_CENTER 1
219 #define WD_TOP 2
220 #define WD_BOTTOM 3
221 #define WD_TOPLEFT 4
222 #define WD_TOPRIGHT 5
223 #define WD_BOTTOMLEFT 6
224 #define WD_BOTTOMRIGHT 7
226 /* titlebar style */
227 #define TS_NEW 0
228 #define TS_OLD 1
229 #define TS_NEXT 2
231 /* workspace border position */
232 #define WB_NONE 0
233 #define WB_LEFTRIGHT 1
234 #define WB_TOPBOTTOM 2
235 #define WB_ALLDIRS (WB_LEFTRIGHT|WB_TOPBOTTOM)
237 /* drag maximized window behaviors */
238 enum {
239 DRAGMAX_MOVE,
240 DRAGMAX_RESTORE,
241 DRAGMAX_UNMAXIMIZE,
242 DRAGMAX_NOMOVE
245 /* program states */
246 typedef enum {
247 WSTATE_NORMAL = 0,
248 WSTATE_NEED_EXIT = 1,
249 WSTATE_NEED_RESTART = 2,
250 WSTATE_EXITING = 3,
251 WSTATE_RESTARTING = 4,
252 WSTATE_MODAL = 5,
253 WSTATE_NEED_REREAD = 6
254 } wprog_state;
257 #define WCHECK_STATE(chk_state) (w_global.program.state == (chk_state))
260 #define WCHANGE_STATE(nstate) {\
261 if (w_global.program.state == WSTATE_NORMAL \
262 || (nstate) != WSTATE_MODAL) \
263 w_global.program.state = (nstate); \
264 if (w_global.program.signal_state != 0) \
265 w_global.program.state = w_global.program.signal_state; \
269 /* only call inside signal handlers, with signals blocked */
270 #define SIG_WCHANGE_STATE(nstate) {\
271 w_global.program.signal_state = (nstate); \
272 w_global.program.state = (nstate); \
276 /* Flags for the Window Maker state when restarting/crash situations */
277 #define WFLAGS_NONE (0)
278 #define WFLAGS_CRASHED (1<<0)
281 /* notifications */
283 #ifdef MAINFILE
284 #define NOTIFICATION(n) const char WN##n [] = #n
285 #else
286 #define NOTIFICATION(n) extern const char WN##n []
287 #endif
289 NOTIFICATION(WindowAppearanceSettingsChanged);
291 NOTIFICATION(IconAppearanceSettingsChanged);
293 NOTIFICATION(IconTileSettingsChanged);
295 NOTIFICATION(MenuAppearanceSettingsChanged);
297 NOTIFICATION(MenuTitleAppearanceSettingsChanged);
300 /* appearance settings clientdata flags */
301 enum {
302 WFontSettings = 1 << 0,
303 WTextureSettings = 1 << 1,
304 WColorSettings = 1 << 2
309 typedef struct {
310 int x1, y1;
311 int x2, y2;
312 } WArea;
314 typedef struct WCoord {
315 int x, y;
316 } WCoord;
318 extern struct WPreferences {
319 char *pixmap_path; /* : separated list of paths to find pixmaps */
320 char *icon_path; /* : separated list of paths to find icons */
321 WMArray *fallbackWMs; /* fallback window manager list */
322 char *logger_shell; /* shell to log child stdi/o */
323 RImage *button_images; /* titlebar button images */
324 char smooth_workspace_back;
325 signed char size_display; /* display type for resize geometry */
326 signed char move_display; /* display type for move geometry */
327 signed char window_placement; /* window placement mode */
328 signed char colormap_mode; /* colormap focus mode */
329 signed char focus_mode; /* window focusing mode */
331 char opaque_move; /* update window position during move */
332 char opaque_resize; /* update window position during resize */
333 char opaque_move_resize_keyboard; /* update window position during move,resize with keyboard */
334 char wrap_menus; /* wrap menus at edge of screen */
335 char scrollable_menus; /* let them be scrolled */
336 char vi_key_menus; /* use h/j/k/l to select */
337 char align_menus; /* align menu with their parents */
338 char use_saveunders; /* turn on SaveUnders for menus, icons etc. */
339 char no_window_over_dock;
340 char no_window_over_icons;
341 WCoord window_place_origin; /* Offset for windows placed on screen */
343 char constrain_window_size; /* don't let windows get bigger than screen */
344 char windows_cycling; /* windoze cycling */
345 char circ_raise; /* raise window after Alt-tabbing */
346 char ignore_focus_click;
347 char open_transients_with_parent; /* open transient window in same workspace as parent */
348 signed char title_justification; /* titlebar text alignment */
349 int window_title_clearance;
350 int window_title_min_height;
351 int window_title_max_height;
352 int menu_title_clearance;
353 int menu_title_min_height;
354 int menu_title_max_height;
355 int menu_text_clearance;
356 char multi_byte_text;
357 #ifdef KEEP_XKB_LOCK_STATUS
358 char modelock;
359 #endif
360 char no_dithering; /* use dithering or not */
361 char no_animations; /* enable/disable animations */
362 char no_autowrap; /* wrap workspace when window is moved to the edge */
363 char window_snapping; /* enable window snapping */
364 int snap_edge_detect; /* how far from edge to begin snap */
365 int snap_corner_detect; /* how far from corner to begin snap */
366 char snap_to_top_maximizes_fullscreen;
367 char drag_maximized_window; /* behavior when a maximized window is dragged */
368 char move_half_max_between_heads; /* move half maximized window between available heads */
369 char alt_half_maximize; /* alternative half-maximize feature behavior */
370 char pointer_with_half_max_windows;
372 char highlight_active_app; /* show the focused app by highlighting its icon */
373 char auto_arrange_icons; /* automagically arrange icons */
374 char icon_box_position; /* position to place icons */
375 signed char iconification_style; /* position to place icons */
376 char disable_root_mouse; /* disable button events in root window */
377 char auto_focus; /* focus window when it's mapped */
378 char *icon_back_file; /* background image for icons */
379 char enforce_icon_margin; /* auto-shrink icon images */
381 WCoord *root_menu_pos; /* initial position of the root menu*/
382 WCoord *app_menu_pos;
383 WCoord *win_menu_pos;
385 signed char icon_yard; /* aka iconbox */
387 int raise_delay; /* delay for autoraise. 0 is disabled */
388 int cmap_size; /* size of dithering colormap in colors per channel */
390 int icon_size; /* size of the icon */
391 signed char menu_style; /* menu decoration style */
392 signed char workspace_name_display_position;
393 unsigned int modifier_mask; /* mask to use as kbd modifier */
394 char *modifier_labels[7]; /* Names of the modifiers */
396 unsigned int supports_tiff; /* Use tiff files */
398 char ws_advance; /* Create new workspace and advance */
399 char ws_cycle; /* Cycle existing workspaces */
400 char save_session_on_exit; /* automatically save session on exit */
401 char sticky_icons; /* If miniwindows will be onmipresent */
402 char dont_confirm_kill; /* do not confirm Kill application */
403 char disable_miniwindows;
404 char enable_workspace_pager;
405 char ignore_gtk_decoration_hints;
407 char dont_blink; /* do not blink icon selection */
408 char keep_dock_on_primary_head; /* keep dock on primary head */
410 /* Appearance options */
411 char new_style; /* Use newstyle buttons */
412 char superfluous; /* Use superfluous things */
414 /* root window mouse bindings */
415 signed char mouse_button1; /* action for left mouse button */
416 signed char mouse_button2; /* action for middle mouse button */
417 signed char mouse_button3; /* action for right mouse button */
418 signed char mouse_button8; /* action for 4th button aka backward mouse button */
419 signed char mouse_button9; /* action for 5th button aka forward mouse button */
420 signed char mouse_wheel_scroll; /* action for mouse wheel scroll */
421 signed char mouse_wheel_tilt; /* action for mouse wheel tilt */
423 /* balloon text */
424 char window_balloon;
425 char miniwin_title_balloon;
426 char miniwin_preview_balloon;
427 char appicon_balloon;
428 char help_balloon;
430 /* some constants */
431 int dblclick_time; /* double click delay time in ms */
433 /* animate menus */
434 signed char menu_scroll_speed; /* how fast menus are scrolled */
436 /* animate icon sliding */
437 signed char icon_slide_speed; /* icon slide animation speed */
439 /* shading animation */
440 signed char shade_speed;
442 /* bouncing animation */
443 char bounce_appicons_when_urgent;
444 char raise_appicons_when_bouncing;
445 char do_not_make_appicons_bounce;
447 int edge_resistance;
448 int resize_increment;
449 char attract;
451 unsigned int workspace_border_size; /* Size in pixels of the workspace border */
452 char workspace_border_position; /* Where to leave a workspace border */
453 char single_click; /* single click to lauch applications */
454 int history_lines; /* history of "Run..." dialog */
455 char cycle_active_head_only; /* Cycle only windows on the active head */
456 char cycle_ignore_minimized; /* Ignore minimized windows when cycling */
457 char double_click_fullscreen; /* Double click on titlebar maximize a window to full screen*/
458 char close_rootmenu_left_right_click;/* Close application menu when mouse (left or right) is clicked outside focus */
459 char strict_windoze_cycle; /* don't close switch panel when shift is released */
460 char panel_only_open; /* Only open the switch panel; don't switch */
461 int minipreview_size; /* Size of Mini-Previews in pixels */
463 /* All delays here are in ms. 0 means instant auto-action. */
464 int clip_auto_raise_delay; /* Delay after which the clip will be raised when entered */
465 int clip_auto_lower_delay; /* Delay after which the clip will be lowered when leaved */
466 int clip_auto_expand_delay; /* Delay after which the clip will expand when entered */
467 int clip_auto_collapse_delay; /* Delay after which the clip will collapse when leaved */
469 RImage *swtileImage;
470 RImage *swbackImage[9];
472 union WTexture *wsmbackTexture;
474 char show_clip_title;
476 struct {
477 #ifdef USE_ICCCM_WMREPLACE
478 unsigned int replace:1; /* replace existing window manager */
479 #endif
480 unsigned int nodock:1; /* don't display the dock */
481 unsigned int noclip:1; /* don't display the clip */
482 unsigned int clip_merged_in_dock:1; /* disable clip, switch workspaces with dock */
483 unsigned int nodrawer:1; /* don't use drawers */
484 unsigned int wrap_appicons_in_dock:1; /* Whether to wrap appicons when Dock is moved up and down */
485 unsigned int noupdates:1; /* don't require ~/GNUstep (-static) */
486 unsigned int noautolaunch:1; /* don't autolaunch apps */
487 unsigned int norestore:1; /* don't restore session */
488 unsigned int restarting:2;
489 } flags; /* internal flags */
491 /* Map table between w_cursor and actual X id */
492 Cursor cursor[WCUR_LAST];
494 int switch_panel_icon_size; /* icon size in switch panel */
496 } wPreferences;
498 /****** Global Variables ******/
499 extern Display *dpy;
501 extern struct wmaker_global_variables {
502 /* Tracking of the state of the program */
503 struct {
504 wprog_state state;
505 wprog_state signal_state;
506 } program;
508 /* locale to use. NULL==POSIX or C */
509 const char *locale;
511 /* Tracking of X events timestamps */
512 struct {
513 /* ts of the last event we received */
514 Time last_event;
516 /* ts on the last time we did XSetInputFocus() */
517 Time focus_change;
519 } timestamp;
521 /* Global Domains, for storing dictionaries */
522 struct {
523 /* Note: you must #include <defaults.h> if you want to use them */
524 struct WDDomain *wmaker;
525 struct WDDomain *window_attr;
526 struct WDDomain *root_menu;
527 } domain;
529 /* Screens related */
530 int screen_count;
533 * Ignore Workspace Change:
534 * this variable is used to prevent workspace switch while certain
535 * operations are ongoing.
537 Bool ignore_workspace_change;
540 * Process WorkspaceMap Event:
541 * this variable is set when the Workspace Map window is being displayed,
542 * it is mainly used to avoid re-opening another one at the same time
544 Bool process_workspacemap_event;
546 #ifdef HAVE_INOTIFY
547 struct {
548 int fd_event_queue; /* Inotify's queue file descriptor */
549 int wd_defaults; /* Watch Descriptor for the 'Defaults' configuration file */
550 } inotify;
551 #endif
553 /* definition for X Atoms */
554 struct {
556 /* Window-Manager related */
557 struct {
558 Atom state;
559 Atom change_state;
560 Atom protocols;
561 Atom take_focus;
562 Atom delete_window;
563 Atom save_yourself;
564 Atom client_leader;
565 Atom colormap_windows;
566 Atom colormap_notify;
567 Atom ignore_focus_events;
568 } wm;
570 /* GNUStep related */
571 struct {
572 Atom wm_attr;
573 Atom wm_miniaturize_window;
574 Atom wm_resizebar;
575 Atom titlebar_state;
576 } gnustep;
578 /* Destkop-environment related */
579 struct {
580 Atom gtk_object_path;
581 } desktop;
583 /* WindowMaker specific */
584 struct {
585 Atom menu;
586 Atom wm_protocols;
587 Atom state;
589 Atom wm_function;
590 Atom noticeboard;
591 Atom command;
593 Atom icon_size;
594 Atom icon_tile;
595 } wmaker;
597 } atom;
599 /* X Contexts */
600 struct {
601 XContext client_win;
602 XContext app_win;
603 XContext stack;
604 } context;
606 /* X Extensions */
607 struct {
608 #ifdef USE_XSHAPE
609 struct {
610 Bool supported;
611 int event_base;
612 } shape;
613 #endif
615 #ifdef KEEP_XKB_LOCK_STATUS
616 struct {
617 Bool supported;
618 int event_base;
619 } xkb;
620 #endif
622 #ifdef USE_RANDR
623 struct {
624 Bool supported;
625 int event_base;
626 } randr;
627 #endif
630 * If no extension were activated, we would end up with an empty
631 * structure, which old compilers may not appreciate, so let's
632 * work around this with a simple:
634 int dummy;
635 } xext;
637 /* Keyboard and shortcuts */
638 struct {
640 * Bit-mask to hide special key modifiers which we don't want to
641 * impact the shortcuts (typically: CapsLock, NumLock, ScrollLock)
643 unsigned int modifiers_mask;
644 } shortcut;
645 } w_global;
647 /****** Notifications ******/
648 extern const char WMNManaged[];
649 extern const char WMNUnmanaged[];
650 extern const char WMNChangedWorkspace[];
651 extern const char WMNChangedState[];
652 extern const char WMNChangedFocus[];
653 extern const char WMNChangedStacking[];
654 extern const char WMNChangedName[];
656 extern const char WMNWorkspaceCreated[];
657 extern const char WMNWorkspaceDestroyed[];
658 extern const char WMNWorkspaceChanged[];
659 extern const char WMNWorkspaceNameChanged[];
661 extern const char WMNResetStacking[];
663 #endif