summaryrefslogtreecommitdiffstats
path: root/include/swaybar/bar.h
blob: 0037190b3c63604443a410a32024c4599df2557a (plain) (blame)
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
#ifndef _SWAYBAR_BAR_H
#define _SWAYBAR_BAR_H
#include <wayland-client.h>
#include "pool-buffer.h"

struct swaybar_config;
struct swaybar_output;
struct swaybar_workspace;

struct swaybar_pointer {
	struct wl_pointer *pointer;
	struct wl_cursor_theme *cursor_theme;
	struct wl_cursor_image *cursor_image;
	struct wl_surface *cursor_surface;
	struct swaybar_output *current;
	int x, y;
};

struct swaybar_hotspot {
	struct wl_list link;
	int x, y, width, height;
	void (*callback)(struct swaybar_output *output,
			int x, int y, uint32_t button, void *data);
	void (*destroy)(void *data);
	void *data;
};

struct swaybar {
	struct wl_display *display;
	struct wl_compositor *compositor;
	struct zwlr_layer_shell_v1 *layer_shell;
	struct wl_shm *shm;
	struct wl_seat *seat;

	struct swaybar_config *config;
	struct swaybar_output *focused_output;
	struct swaybar_pointer pointer;
	struct status_line *status;

	int ipc_event_socketfd;
	int ipc_socketfd;

	struct wl_list outputs;
};

struct swaybar_output {
	struct wl_list link;
	struct swaybar *bar;
	struct wl_output *output;
	struct wl_surface *surface;
	struct zwlr_layer_surface_v1 *layer_surface;
	uint32_t wl_name;

	struct wl_list workspaces;
	struct wl_list hotspots;

	char *name;
	size_t index;
	bool focused;

	uint32_t width, height;
	int32_t scale;
	struct pool_buffer buffers[2];
	struct pool_buffer *current_buffer;
};

struct swaybar_workspace {
	struct wl_list link;
	int num;
	char *name;
	bool focused;
	bool visible;
	bool urgent;
};

void bar_setup(struct swaybar *bar,
	const char *socket_path,
	const char *bar_id);
void bar_run(struct swaybar *bar);
void bar_teardown(struct swaybar *bar);

#endif