summaryrefslogtreecommitdiff
path: root/src/private.h
blob: d624aba375ca30e635b3bc70f80a2c77d8df8a79 (plain)
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
#include <stdio.h>
#include <pixman.h>
#include <wayland-client.h>

#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])

#define container_of(ptr, type, member) ({				\
	const __typeof__( ((type *)0)->member ) *__mptr = (ptr);	\
	(type *)( (char *)__mptr - offsetof(type,member) );})

#define STUB() do { fprintf(stderr, "%s is a lie\n", __func__); } while (0)

struct csx_event {
	XEvent xevent;
	struct wl_list link;
};

struct csx_atom {
	uint32_t hash;
	char *name;
	Atom value;
};

struct csx_display {
	struct wl_display *display;
	struct wl_registry *registry;
	struct wl_compositor *compositor;
	struct wl_shm *shm;
	struct wl_shell *shell;
	uint32_t shm_formats;

	union entry *resource_map;
	uint32_t resource_size;
	uint32_t resource_count, free_resource;

	struct wl_list event_list;

	struct csx_window *root;

	Display *xdisplay;
	Screen screens[1];
	Depth depths[2];

	Visual depth24_visuals[1];
	Visual depth32_visuals[1];
	unsigned long serial;

	struct csx_atom *atom_table[256];
	struct csx_atom *atom_map[256];
	Atom next_atom;

	int major;
	int minor;
};

static inline struct csx_display *
csx_display(Display *display)
{
	return (struct csx_display *) ((_XPrivDisplay) display + 1);
}

void csx_display_enter(struct csx_display *display, int major, int minor);
XID csx_display_add_resource(struct csx_display *display, void *p);
void csx_display_remove_resource(struct csx_display *display, XID id);
void *csx_display_lookup_resource(struct csx_display *display, XID id);

void csx_display_error(struct csx_display *display, XID resourceid, int error);

void csx_display_add_seat(struct csx_display *display,
			  uint32_t name, uint32_t version);

struct csx_property {
	Atom name;
	Atom type;
	int format;
	int nelements;
	struct wl_list link;
};

struct csx_window {
	XID id;
	struct csx_window *parent;
	int x;
	int y;
	int width;
	int height;
	unsigned int border_width;
	int depth;
	unsigned int class;
	Visual *visual;
	unsigned long event_mask;

	struct csx_display *display;
	int mapped;
	struct wl_list link;
	struct wl_list child_list;
	pixman_region32_t output_clip;
	pixman_region32_t border_clip;
	struct csx_pixmap *pixmap; /* viewable iff has pixmap */
	struct wl_surface *surface;
	struct wl_shell_surface *shell_surface;

	struct wl_list property_list;
};

struct csx_window *
csx_window_create(struct csx_display *display, struct csx_window *parent);
void
csx_window_destroy(struct csx_window *window);
struct csx_window *csx_window_pick(struct csx_window *window,
				   int x, int y, int *local_x, int *local_y);

struct csx_pixmap {
	unsigned int width;
	unsigned int height;
	unsigned int depth;
	pixman_image_t *image;
	void *data;
	struct wl_buffer *buffer;
	int refcount;
};

struct csx_pixmap *
csx_pixmap_create(struct csx_display *display,
		  unsigned int width, unsigned int height,
		  unsigned int depth);

void
csx_pixmap_unref(struct csx_pixmap *pixmap);