Refactor the crap out of wayland clients

And create a background surface on every output when invoking swaybg.
This commit is contained in:
Drew DeVault 2015-11-19 07:58:57 -05:00
parent 4a1584be53
commit b4e5e1381f
8 changed files with 331 additions and 268 deletions

View file

@ -1,8 +1,8 @@
#ifndef _BUFFER_H
#define _BUFFER_H
#include "client/client.h"
#include "client/window.h"
struct buffer *get_next_buffer(struct client_state *state);
struct buffer *get_next_buffer(struct window *state);
#endif

28
include/client/registry.h Normal file
View file

@ -0,0 +1,28 @@
#ifndef _SWAY_CLIENT_REGISTRY_H
#define _SWAY_CLIENT_REGISTRY_H
#include <wayland-client.h>
#include "wayland-desktop-shell-client-protocol.h"
#include "list.h"
struct output_state {
struct wl_output *output;
uint32_t flags;
uint32_t width, height;
};
struct registry {
struct wl_compositor *compositor;
struct wl_display *display;
struct wl_pointer *pointer;
struct wl_seat *seat;
struct wl_shell *shell;
struct wl_shm *shm;
struct desktop_shell *desktop_shell;
list_t *outputs;
};
struct registry *registry_poll(void);
void registry_teardown(struct registry *registry);
#endif

View file

@ -7,12 +7,7 @@
#include <pango/pangocairo.h>
#include <stdbool.h>
#include "list.h"
struct output_state {
struct wl_output *output;
uint32_t flags;
uint32_t width, height;
};
#include "client/registry.h"
struct buffer {
struct wl_buffer *buffer;
@ -30,28 +25,21 @@ struct cursor {
struct wl_poitner *pointer;
};
struct client_state {
struct wl_compositor *compositor;
struct wl_display *display;
struct wl_pointer *pointer;
struct wl_seat *seat;
struct wl_shell *shell;
struct wl_shm *shm;
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 desktop_shell *desktop_shell;
struct cursor cursor;
uint32_t width, height;
cairo_t *cairo;
list_t *outputs;
};
struct client_state *client_setup(uint32_t width, uint32_t height, bool shell_surface);
void client_teardown(struct client_state *state);
int client_prerender(struct client_state *state);
int client_render(struct client_state *state);
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);
#endif