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. */
27 /* Basic window type */
28 typedef struct win_sys win_sys_t;
29 typedef struct win_wm win_wm_t;
37 /* Generic key codes, also used for some other events
38 * Keys map to their Unicode value */
47 key_singlequote = '\'',
48 key_doublequote = '\"',
51 key_none = 0xF0000, // unused Unicode space
52 key_mouse0, key_mouse1, key_mouse2, key_mouse3,
53 key_mouse4, key_mouse5, key_mouse6, key_mouse7,
54 key_left, key_right, key_up, key_down,
55 key_home, key_end, key_pageup, key_pagedown,
56 key_f1, key_f2, key_f3, key_f4,
57 key_f5, key_f6, key_f7, key_f8,
58 key_f9, key_f10, key_f11, key_f12,
59 key_alt, key_ctrl, key_shift, key_win,
60 key_enter, key_leave, key_focus, key_unfocus,
63 /* Key modifiers, up is for button release */
65 unsigned char alt : 1;
66 unsigned char ctrl : 1;
67 unsigned char shift : 1;
68 unsigned char win : 1;
71 #define MOD(...) ((mod_t){__VA_ARGS__})
72 #define mod2int(mod) (*((unsigned char*)&(mod)))
79 #define PTR(...) ((ptr_t){__VA_ARGS__})
83 st_show, // show as regular window
84 st_full, // fullscreen/maximized
85 st_shade, // show titlebar only
86 st_icon, // iconified/minimized
87 st_hide, // completely hidden
91 /* Move the window to the specified location and set it's
92 * geometry. The position and size include borders and
93 * window decorations. */
94 void sys_move(win_t *win, int x, int y, int w, int h);
96 /* Rise the window above all other windows */
97 void sys_raise(win_t *win);
99 /* Give keyboard focus to the window and update window
101 void sys_focus(win_t *win);
103 /* Set the windows drawing state */
104 void sys_show(win_t *win, state_t st);
106 /* Start watching for a key events. The sys subsequently
107 * calls wm_handle_key whenever the event occurs. */
108 void sys_watch(win_t *win, Key_t key, mod_t mod);
110 /* Stop watching a key event */
111 void sys_unwatch(win_t *win, Key_t key, mod_t mod);
113 /* Return a list of windows representing the geometry of the
114 * physical displays attached to the computer. */
115 list_t *sys_info(win_t *root);
117 /* First call, calls wm_insert for each existing window */
118 win_t *sys_init(void);
120 /* Starts the main loop */
121 void sys_run(win_t *root);