2 * Copyright (c) 2011-2012, 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_HIDE, // completely hidden
30 ST_SHOW, // show as regular window
31 ST_FULL, // fullscreen (without decorations)
32 ST_MAX, // maximized (with decorations)
33 ST_SHADE, // show titlebar only
34 ST_ICON, // iconified/minimized
35 ST_CLOSE, // close the window
45 /* Basic window type */
46 typedef struct win_sys win_sys_t;
47 typedef struct win_wm win_wm_t;
58 /* Generic key codes, also used for some other events
59 * Keys map to their Unicode value */
69 EV_SINGLEQUOTE = '\'',
70 EV_DOUBLEQUOTE = '\"',
73 EV_NONE = 0xF0000, // unused Unicode space
74 EV_MOUSE0, EV_MOUSE1, EV_MOUSE2, EV_MOUSE3,
75 EV_MOUSE4, EV_MOUSE5, EV_MOUSE6, EV_MOUSE7,
76 EV_LEFT, EV_RIGHT, EV_UP, EV_DOWN,
77 EV_HOME, EV_END, EV_PAGEUP, EV_PAGEDOWN,
78 EV_F1, EV_F2, EV_F3, EV_F4,
79 EV_F5, EV_F6, EV_F7, EV_F8,
80 EV_F9, EV_F10, EV_F11, EV_F12,
81 EV_ALT, EV_CTRL, EV_SHIFT, EV_WIN,
82 EV_ENTER, EV_LEAVE, EV_FOCUS, EV_UNFOCUS,
85 /* Key modifiers, up is for button release */
87 unsigned char alt : 1;
88 unsigned char ctrl : 1;
89 unsigned char shift : 1;
90 unsigned char win : 1;
93 #define MOD(...) ((mod_t){__VA_ARGS__})
94 #define mod2int(mod) (*((unsigned char*)&(mod)))
101 #define PTR(...) ((ptr_t){__VA_ARGS__})
104 /* Move the window to the specified location and set it's
105 * geometry. The position and size include borders and
106 * window decorations. */
107 void sys_move(win_t *win, int x, int y, int w, int h);
109 /* Rise the window above all other windows */
110 void sys_raise(win_t *win);
112 /* Give keyboard focus to the window and update window
114 void sys_focus(win_t *win);
116 /* Set the windows drawing state */
117 void sys_show(win_t *win, state_t st);
119 /* Start watching for an event. The sys subsequently
120 * calls wm_handle_event whenever the event occurs. */
121 void sys_watch(win_t *win, event_t ev, mod_t mod);
123 /* Stop watching an event */
124 void sys_unwatch(win_t *win, event_t event, mod_t mod);
126 /* Return a list of windows representing the geometry of the
127 * physical displays attached to the computer. */
128 list_t *sys_info(win_t *root);
130 /* First call, calls wm_insert for each existing window */
131 win_t *sys_init(void);
133 /* Starts the main loop */
134 void sys_run(win_t *root);
139 /* Free all static data, for memory debugging */
140 void sys_free(win_t *root);