From b4e5e1381f909b173a171fb3941610aec989df48 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 19 Nov 2015 07:58:57 -0500 Subject: Refactor the crap out of wayland clients And create a background surface on every output when invoking swaybg. --- include/client/buffer.h | 4 ++-- include/client/client.h | 57 ----------------------------------------------- include/client/registry.h | 28 +++++++++++++++++++++++ include/client/window.h | 45 +++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 59 deletions(-) delete mode 100644 include/client/client.h create mode 100644 include/client/registry.h create mode 100644 include/client/window.h (limited to 'include/client') diff --git a/include/client/buffer.h b/include/client/buffer.h index aa8d68a1..eb9973ed 100644 --- a/include/client/buffer.h +++ b/include/client/buffer.h @@ -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 diff --git a/include/client/client.h b/include/client/client.h deleted file mode 100644 index 30ec25c0..00000000 --- a/include/client/client.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _CLIENT_H -#define _CLIENT_H - -#include -#include "wayland-desktop-shell-client-protocol.h" -#include -#include -#include -#include "list.h" - -struct output_state { - struct wl_output *output; - uint32_t flags; - uint32_t width, height; -}; - -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; -}; - -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 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); - -#endif diff --git a/include/client/registry.h b/include/client/registry.h new file mode 100644 index 00000000..68a9bc02 --- /dev/null +++ b/include/client/registry.h @@ -0,0 +1,28 @@ +#ifndef _SWAY_CLIENT_REGISTRY_H +#define _SWAY_CLIENT_REGISTRY_H + +#include +#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 diff --git a/include/client/window.h b/include/client/window.h new file mode 100644 index 00000000..af954003 --- /dev/null +++ b/include/client/window.h @@ -0,0 +1,45 @@ +#ifndef _CLIENT_H +#define _CLIENT_H + +#include +#include "wayland-desktop-shell-client-protocol.h" +#include +#include +#include +#include "list.h" +#include "client/registry.h" + +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; +}; + +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; + cairo_t *cairo; +}; + +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 -- cgit v1.2.3-54-g00ecf