aboutsummaryrefslogtreecommitdiff
path: root/include/client/window.h
blob: e07e3509e266912006d369a35799fc28ddb17e6b (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
#ifndef _CLIENT_H
#define _CLIENT_H

#include <wayland-client.h>
#include "wayland-desktop-shell-client-protocol.h"
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
#include <stdbool.h>
#include "list.h"
#include "client/registry.h"

struct window;

struct buffer {
	struct wl_buffer *buffer;
	cairo_surface_t *surface;
	cairo_t *cairo;
	PangoContext *pango;
	uint32_t width, height;
	bool busy;
};

struct cursor {
	struct wl_surface *surface;
	struct wl_cursor_theme *cursor_theme;
	struct wl_cursor *cursor;
	struct wl_poitner *pointer;
};

enum scroll_direction {
	SCROLL_UP,
	SCROLL_DOWN,
	SCROLL_LEFT,
	SCROLL_RIGHT,
};

struct pointer_input {
	int last_x;
	int last_y;

	void (*notify_button)(struct window *window, int x, int y, uint32_t button);

	void (*notify_scroll)(struct window *window, enum scroll_direction direction);
};

struct window {
	struct registry *registry;
	struct buffer buffers[2];
	struct buffer *buffer;
	struct wl_surface *surface;
	struct wl_shell_surface *shell_surface;
	struct wl_callback *frame_cb;
	struct cursor cursor;
	uint32_t width, height;
	char *font;
	cairo_t *cairo;
	struct pointer_input pointer_input;
};

struct window *window_setup(struct registry *registry, uint32_t width, uint32_t height, bool shell_surface);
void window_teardown(struct window *state);
int window_prerender(struct window *state);
int window_render(struct window *state);
void window_make_shell(struct window *window);

#endif