]> Pileus Git - wmpus/blob - types.h
Fix configure and raise
[wmpus] / types.h
1 /*
2  * Copyright (c) 2015 Andy Spencer <andy753421@gmail.com>
3  *
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.
7  *
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
14  */
15
16 /* Forward definitions for sys and wm */
17 typedef struct win_sys win_sys_t;
18 typedef struct win_wm  win_wm_t;
19
20 /* Window states */
21 typedef enum {
22         ST_HIDE,  // completely hidden
23         ST_SHOW,  // show as regular window
24         ST_FULL,  // fullscreen (without decorations)
25         ST_MAX,   // maximized (with decorations)
26         ST_SHADE, // show titlebar only
27         ST_ICON,  // iconified/minimized
28         ST_CLOSE, // close the window
29 } state_t;
30
31 /* Window types */
32 typedef enum {
33         TYPE_NORMAL,
34         TYPE_DIALOG,
35         TYPE_TOOLBAR,
36 } type_t;
37
38 /* Basic window type */
39 typedef struct win {
40         int x, y, z;
41         int w, h;
42         state_t state;
43         type_t  type;
44         struct win *parent;
45         win_sys_t  *sys;
46         win_wm_t   *wm;
47 } win_t;
48
49 /* Generic key codes, also used for some other events
50  * Keys map to their Unicode value */
51 typedef int event_t;
52 enum {
53         EV_ALERT       = '\a',
54         EV_BACKSPACE   = '\b',
55         EV_FORMFEED    = '\f',
56         EV_NEWLINE     = '\n',
57         EV_RETURN      = '\r',
58         EV_TAB         = '\t',
59         EV_VTAB        = '\v',
60         EV_SINGLEQUOTE = '\'',
61         EV_DOUBLEQUOTE = '\"',
62         EV_BACKSLASH   = '\\',
63         EV_QUESTION    = '\?',
64         EV_NONE        = 0xF0000, // unused Unicode space
65         EV_MOUSE0, EV_MOUSE1, EV_MOUSE2, EV_MOUSE3,
66         EV_MOUSE4, EV_MOUSE5, EV_MOUSE6, EV_MOUSE7,
67         EV_LEFT, EV_RIGHT, EV_UP,     EV_DOWN,
68         EV_HOME, EV_END,   EV_PAGEUP, EV_PAGEDOWN,
69         EV_F1, EV_F2,  EV_F3,  EV_F4,
70         EV_F5, EV_F6,  EV_F7,  EV_F8,
71         EV_F9, EV_F10, EV_F11, EV_F12,
72         EV_ALT, EV_CTRL, EV_SHIFT, EV_WIN,
73         EV_ENTER, EV_LEAVE, EV_FOCUS, EV_UNFOCUS,
74 };
75
76 /* Key modifiers, up is for button release */
77 typedef struct {
78         unsigned char alt   : 1;
79         unsigned char ctrl  : 1;
80         unsigned char shift : 1;
81         unsigned char win   : 1;
82         unsigned char up    : 1;
83 } mod_t;
84
85 /* Mouse movement */
86 typedef struct {
87         int  x,  y;
88         int rx, ry;
89 } ptr_t;
90
91 /* Creation functions */
92 #define MOD(...) ((mod_t){__VA_ARGS__})
93 #define PTR(...) ((ptr_t){__VA_ARGS__})
94
95 /* Conversion functions */
96 #define mod2int(mod) (*((unsigned char*)&(mod)))