]> Pileus Git - wmpus/blob - sys.h
Add floating layer
[wmpus] / sys.h
1 /*
2  * Copyright (C) 2011 Andy Spencer <andy753421@gmail.com>
3  * 
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.
8  * 
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.
13  * 
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/>.
16  */
17
18 /* Windowing system interface:
19  *
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.
24  *
25  * The sys also provides the API used by the wm to position
26  * and control windows. */
27
28
29 /* Basic window type */
30 typedef struct win_sys win_sys_t;
31 typedef struct win_wm  win_wm_t;
32 typedef struct {
33         int x, y, z;
34         int w, h;
35         win_sys_t *sys;
36         win_wm_t  *wm;
37 } win_t;
38
39 /* Generic key codes, also used for some other events
40  * Keys map to their Unicode value */
41 typedef enum {
42         key_alert       = '\a',
43         key_backspace   = '\b',
44         key_formfeed    = '\f',
45         key_newline     = '\n',
46         key_return      = '\r',
47         key_tab         = '\t',
48         key_vtab        = '\v',
49         key_singlequote = '\'',
50         key_doublequote = '\"',
51         key_backslash   = '\\',
52         key_question    = '\?',
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,
63 } Key_t;
64
65 /* Key modifiers, up is for button release */
66 typedef struct {
67         unsigned char alt   : 1;
68         unsigned char ctrl  : 1;
69         unsigned char shift : 1;
70         unsigned char win   : 1;
71         unsigned char up    : 1;
72 } mod_t;
73 #define MOD(...)     ((mod_t){__VA_ARGS__})
74 #define mod2int(mod) (*((unsigned char*)&(mod)))
75
76 /* Mouse movement */
77 typedef struct {
78         int  x,  y;
79         int rx, ry;
80 } ptr_t;
81 #define PTR(...) ((ptr_t){__VA_ARGS__})
82
83 /* Window states */
84 typedef enum {
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
90 } state_t;
91
92
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);
97
98 /* Rise the window above all other windows */
99 void sys_raise(win_t *win);
100
101 /* Give keyboard focus to the window and update window
102  * decorations. */
103 void sys_focus(win_t *win);
104
105 /* Set the windows drawing state */
106 void sys_show(win_t *win, state_t st);
107
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);
111
112 /* Stop watching a key event */
113 void sys_unwatch(win_t *win, Key_t key, mod_t mod);
114
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);
118
119 /* First call, calls wm_insert for each existing window */
120 win_t *sys_init(void);
121
122 /* Starts the main loop */
123 void sys_run(win_t *root);