1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#include <stdio.h>
#include <pixman.h>
#include "list.h"
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
typedef enum
{
WS_WINDOW_SIZE_CHANGED = (1 << 0),
WS_WINDOW_POSITION_CHANGED = (1 << 1)
} ws_window_configure_type_t;
typedef struct ws_t ws_t;
typedef struct drawable_t drawable_t;
typedef struct window_t window_t;
typedef struct surfade_t surface_t;
typedef union ws_event_t ws_event_t;
typedef enum
{
WS_CONFIGURE, // FIXME: rename to USER_POSITION?
WS_MOTION,
WS_BUTTON_DOWN,
WS_BUTTON_UP
} ws_event_type_t;
typedef struct
{
link_t link;
ws_event_type_t type;
} ws_event_common_t;
union ws_event_t
{
ws_event_common_t common;
struct
{
ws_event_common_t common;
ws_window_configure_type_t configure_type;
window_t * window;
} configure;
struct
{
ws_event_common_t common;
window_t * window;
int x;
int y;
int root_x;
int root_y;
} motion;
struct
{
ws_event_common_t common;
window_t * window;
int button;
int x;
int y;
int root_x;
int root_y;
} button, button_up, button_down;
};
typedef void (* ws_event_func_t) (window_t *window, ws_event_t *event, void *data);
/* Window system */
ws_t * ws_open (void);
int ws_get_width (ws_t *ws);
int ws_get_height (ws_t *ws);
int ws_get_fd (ws_t *ws);
void ws_process (ws_t *ws);
pixman_bool_t ws_pending (ws_t *ws);
/* Window */
window_t *ws_create_window (ws_t *ws,
int x,
int y,
int width,
int height);
void ws_window_set_callback (window_t *window,
ws_event_func_t func,
void * data);
void ws_window_ref (window_t *window);
void ws_window_unref (window_t *window);
void ws_window_show (window_t *window);
void ws_window_hide (window_t *window);
void ws_window_move (window_t *window,
int x,
int y);
int ws_window_get_width (window_t *window);
int ws_window_get_height (window_t *window);
int ws_window_get_x (window_t *window);
int ws_window_get_y (window_t *window);
void ws_window_resize (window_t *window,
int w,
int h);
void ws_window_copy_area (window_t *window,
int src_x,
int src_y,
int dst_x,
int dst_y,
int width,
int height);
void ws_window_copy_from_image (window_t *window,
pixman_image_t *image,
int image_x,
int image_y,
int win_x,
int win_y,
int width,
int height);
void ws_window_copy_to_image (window_t *window,
pixman_image_t *image,
int image_x,
int image_y,
int win_x,
int win_y,
int width,
int height);
void ws_window_finish (window_t **windows,
int n_windows);
|