2 * Copyright (c) 2011, Andy Spencer <andy753421@gmail.com>
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 /* Windowing system interface:
18 * The sys provides input to the window manager. It creates
19 * the main loop and responds to input events from the user,
20 * generally by converting them to a system independent form
21 * and then passing them to the wm.
23 * The sys also provides the API used by the wm to position
24 * and control windows. */
29 st_show, // show as regular window
30 st_full, // fullscreen/maximized
31 st_shade, // show titlebar only
32 st_icon, // iconified/minimized
33 st_hide, // completely hidden
36 /* Basic window type */
37 typedef struct win_sys win_sys_t;
38 typedef struct win_wm win_wm_t;
47 /* Generic key codes, also used for some other events
48 * Keys map to their Unicode value */
57 key_singlequote = '\'',
58 key_doublequote = '\"',
61 key_none = 0xF0000, // unused Unicode space
62 key_mouse0, key_mouse1, key_mouse2, key_mouse3,
63 key_mouse4, key_mouse5, key_mouse6, key_mouse7,
64 key_left, key_right, key_up, key_down,
65 key_home, key_end, key_pageup, key_pagedown,
66 key_f1, key_f2, key_f3, key_f4,
67 key_f5, key_f6, key_f7, key_f8,
68 key_f9, key_f10, key_f11, key_f12,
69 key_alt, key_ctrl, key_shift, key_win,
70 key_enter, key_leave, key_focus, key_unfocus,
73 /* Key modifiers, up is for button release */
75 unsigned char alt : 1;
76 unsigned char ctrl : 1;
77 unsigned char shift : 1;
78 unsigned char win : 1;
81 #define MOD(...) ((mod_t){__VA_ARGS__})
82 #define mod2int(mod) (*((unsigned char*)&(mod)))
89 #define PTR(...) ((ptr_t){__VA_ARGS__})
92 /* Move the window to the specified location and set it's
93 * geometry. The position and size include borders and
94 * window decorations. */
95 void sys_move(win_t *win, int x, int y, int w, int h);
97 /* Rise the window above all other windows */
98 void sys_raise(win_t *win);
100 /* Give keyboard focus to the window and update window
102 void sys_focus(win_t *win);
104 /* Set the windows drawing state */
105 void sys_show(win_t *win, state_t st);
107 /* Start watching for a key events. The sys subsequently
108 * calls wm_handle_key whenever the event occurs. */
109 void sys_watch(win_t *win, Key_t key, mod_t mod);
111 /* Stop watching a key event */
112 void sys_unwatch(win_t *win, Key_t key, mod_t mod);
114 /* Return a list of windows representing the geometry of the
115 * physical displays attached to the computer. */
116 list_t *sys_info(win_t *root);
118 /* First call, calls wm_insert for each existing window */
119 win_t *sys_init(void);
121 /* Starts the main loop */
122 void sys_run(win_t *root);
127 /* Free all static data, for memory debugging */
128 void sys_free(win_t *root);