2 * Copyright (C) 2011 Andy Spencer <andy753421@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 /* Windowing system interface:
20 * The sys provides input to the window manager. It creates
21 * the main loop and responds to input events from the user,
22 * generally by converting them to a system independent form
23 * and then passing them to the wm.
25 * The sys also provides the API used by the wm to position
26 * and control windows. */
29 /* Basic window type */
30 typedef struct win_sys win_sys_t;
31 typedef struct win_wm win_wm_t;
39 /* Generic key codes, also used for some other events
40 * Keys map to their Unicode value */
49 key_singlequote = '\'',
50 key_doublequote = '\"',
53 key_none = 0xF0000, // unused Unicode space
54 key_mouse0, key_mouse1, key_mouse2, key_mouse3,
55 key_mouse4, key_mouse5, key_mouse6, key_mouse7,
56 key_left, key_right, key_up, key_down,
57 key_home, key_end, key_pageup, key_pagedown,
58 key_f1, key_f2, key_f3, key_f4,
59 key_f5, key_f6, key_f7, key_f8,
60 key_f9, key_f10, key_f11, key_f12,
61 key_alt, key_ctrl, key_shift, key_win,
62 key_enter, key_leave, key_focus, key_unfocus,
65 /* Key modifiers, up is for button release */
67 unsigned char alt : 1;
68 unsigned char ctrl : 1;
69 unsigned char shift : 1;
70 unsigned char win : 1;
73 #define MOD(...) ((mod_t){__VA_ARGS__})
74 #define mod2int(mod) (*((unsigned char*)&(mod)))
81 #define PTR(...) ((ptr_t){__VA_ARGS__})
85 st_show, // show as regular window
86 st_full, // fullscreen/maximized
87 st_shade, // show titlebar only
88 st_icon, // iconified/minimized
89 st_hide, // completely hidden
93 /* Move the window to the specified location and set it's
94 * geometry. The position and size include borders and
95 * window decorations. */
96 void sys_move(win_t *win, int x, int y, int w, int h);
98 /* Rise the window above all other windows */
99 void sys_raise(win_t *win);
101 /* Give keyboard focus to the window and update window
103 void sys_focus(win_t *win);
105 /* Set the windows drawing state */
106 void sys_show(win_t *win, state_t st);
108 /* Start watching for a key events. The sys subsequently
109 * calls wm_handle_key whenever the event occurs. */
110 void sys_watch(win_t *win, Key_t key, mod_t mod);
112 /* Stop watching a key event */
113 void sys_unwatch(win_t *win, Key_t key, mod_t mod);
115 /* Return a list of windows representing the geometry of the
116 * physical displays attached to the computer. */
117 list_t *sys_info(win_t *root);
119 /* First call, calls wm_insert for each existing window */
120 win_t *sys_init(void);
122 /* Starts the main loop */
123 void sys_run(win_t *root);