From a6145914c60351d8e541192c7fe35556f8e02507 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Sat, 28 Jul 2018 23:15:12 -0400 Subject: swaynag: refactor {sway_,}nagbar to swaynag --- include/swaynag/config.h | 12 +++--- include/swaynag/nagbar.h | 104 ---------------------------------------------- include/swaynag/render.h | 7 ++-- include/swaynag/swaynag.h | 104 ++++++++++++++++++++++++++++++++++++++++++++++ include/swaynag/types.h | 18 ++++---- 5 files changed, 123 insertions(+), 122 deletions(-) delete mode 100644 include/swaynag/nagbar.h create mode 100644 include/swaynag/swaynag.h (limited to 'include/swaynag') diff --git a/include/swaynag/config.h b/include/swaynag/config.h index caa32710..3fd5b3ce 100644 --- a/include/swaynag/config.h +++ b/include/swaynag/config.h @@ -1,13 +1,13 @@ -#ifndef _SWAY_NAGBAR_CONFIG_H -#define _SWAY_NAGBAR_CONFIG_H -#include "swaynag/nagbar.h" +#ifndef _SWAYNAG_CONFIG_H +#define _SWAYNAG_CONFIG_H +#include "swaynag/swaynag.h" #include "list.h" -int nagbar_parse_options(int argc, char **argv, struct sway_nagbar *nagbar, +int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag, list_t *types, char **config, bool *debug); -char *nagbar_get_config_path(void); +char *swaynag_get_config_path(void); -int nagbar_load_config(char *path, struct sway_nagbar *nagbar, list_t *types); +int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types); #endif diff --git a/include/swaynag/nagbar.h b/include/swaynag/nagbar.h deleted file mode 100644 index 4ef101e9..00000000 --- a/include/swaynag/nagbar.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef _SWAY_NAGBAR_NAGBAR_H -#define _SWAY_NAGBAR_NAGBAR_H -#include -#include -#include "list.h" -#include "pool-buffer.h" -#include "swaynag/types.h" -#include "xdg-output-unstable-v1-client-protocol.h" - -#define NAGBAR_BAR_BORDER_THICKNESS 2 -#define NAGBAR_MESSAGE_PADDING 8 -#define NAGBAR_DETAILS_BORDER_THICKNESS 3 -#define NAGBAR_BUTTON_BORDER_THICKNESS 3 -#define NAGBAR_BUTTON_GAP 20 -#define NAGBAR_BUTTON_GAP_CLOSE 15 -#define NAGBAR_BUTTON_MARGIN_RIGHT 2 -#define NAGBAR_BUTTON_PADDING 3 - -#define NAGBAR_MAX_HEIGHT 500 - -enum sway_nagbar_action_type { - NAGBAR_ACTION_DISMISS, - NAGBAR_ACTION_EXPAND, - NAGBAR_ACTION_COMMAND, -}; - -struct sway_nagbar_pointer { - struct wl_pointer *pointer; - struct wl_cursor_theme *cursor_theme; - struct wl_cursor_image *cursor_image; - struct wl_surface *cursor_surface; - int x; - int y; -}; - -struct sway_nagbar_output { - char *name; - struct wl_output *wl_output; - uint32_t wl_name; -}; - -struct sway_nagbar_button { - char *text; - enum sway_nagbar_action_type type; - char *action; - int x; - int y; - int width; - int height; -}; - -struct sway_nagbar_details { - bool visible; - char *message; - - int x; - int y; - int width; - int height; - - int offset; - int visible_lines; - int total_lines; - struct sway_nagbar_button button_details; - struct sway_nagbar_button button_up; - struct sway_nagbar_button button_down; -}; - -struct sway_nagbar { - bool run_display; - int querying_outputs; - - struct wl_display *display; - struct wl_compositor *compositor; - struct wl_seat *seat; - struct wl_shm *shm; - struct sway_nagbar_pointer pointer; - struct zxdg_output_manager_v1 *xdg_output_manager; - struct sway_nagbar_output output; - struct zwlr_layer_shell_v1 *layer_shell; - struct zwlr_layer_surface_v1 *layer_surface; - struct wl_surface *surface; - - uint32_t width; - uint32_t height; - int32_t scale; - struct pool_buffer buffers[2]; - struct pool_buffer *current_buffer; - - struct sway_nagbar_type *type; - uint32_t anchors; - char *message; - char *font; - list_t *buttons; - struct sway_nagbar_details details; -}; - -void nagbar_setup(struct sway_nagbar *nagbar); - -void nagbar_run(struct sway_nagbar *nagbar); - -void nagbar_destroy(struct sway_nagbar *nagbar); - -#endif diff --git a/include/swaynag/render.h b/include/swaynag/render.h index d9429f7f..d09e5929 100644 --- a/include/swaynag/render.h +++ b/include/swaynag/render.h @@ -1,6 +1,7 @@ -#ifndef _SWAY_NAGBAR_RENDER_H -#define _SWAY_NAGBAR_RENDER_H +#ifndef _SWAYNAG_RENDER_H +#define _SWAYNAG_RENDER_H +#include "swaynag/swaynag.h" -void render_frame(struct sway_nagbar *nagbar); +void render_frame(struct swaynag *swaynag); #endif diff --git a/include/swaynag/swaynag.h b/include/swaynag/swaynag.h new file mode 100644 index 00000000..6a56f14f --- /dev/null +++ b/include/swaynag/swaynag.h @@ -0,0 +1,104 @@ +#ifndef _SWAYNAG_SWAYNAG_H +#define _SWAYNAG_SWAYNAG_H +#include +#include +#include "list.h" +#include "pool-buffer.h" +#include "swaynag/types.h" +#include "xdg-output-unstable-v1-client-protocol.h" + +#define SWAYNAG_BAR_BORDER_THICKNESS 2 +#define SWAYNAG_MESSAGE_PADDING 8 +#define SWAYNAG_DETAILS_BORDER_THICKNESS 3 +#define SWAYNAG_BUTTON_BORDER_THICKNESS 3 +#define SWAYNAG_BUTTON_GAP 20 +#define SWAYNAG_BUTTON_GAP_CLOSE 15 +#define SWAYNAG_BUTTON_MARGIN_RIGHT 2 +#define SWAYNAG_BUTTON_PADDING 3 + +#define SWAYNAG_MAX_HEIGHT 500 + +enum swaynag_action_type { + SWAYNAG_ACTION_DISMISS, + SWAYNAG_ACTION_EXPAND, + SWAYNAG_ACTION_COMMAND, +}; + +struct swaynag_pointer { + struct wl_pointer *pointer; + struct wl_cursor_theme *cursor_theme; + struct wl_cursor_image *cursor_image; + struct wl_surface *cursor_surface; + int x; + int y; +}; + +struct swaynag_output { + char *name; + struct wl_output *wl_output; + uint32_t wl_name; +}; + +struct swaynag_button { + char *text; + enum swaynag_action_type type; + char *action; + int x; + int y; + int width; + int height; +}; + +struct swaynag_details { + bool visible; + char *message; + + int x; + int y; + int width; + int height; + + int offset; + int visible_lines; + int total_lines; + struct swaynag_button button_details; + struct swaynag_button button_up; + struct swaynag_button button_down; +}; + +struct swaynag { + bool run_display; + int querying_outputs; + + struct wl_display *display; + struct wl_compositor *compositor; + struct wl_seat *seat; + struct wl_shm *shm; + struct swaynag_pointer pointer; + struct zxdg_output_manager_v1 *xdg_output_manager; + struct swaynag_output output; + struct zwlr_layer_shell_v1 *layer_shell; + struct zwlr_layer_surface_v1 *layer_surface; + struct wl_surface *surface; + + uint32_t width; + uint32_t height; + int32_t scale; + struct pool_buffer buffers[2]; + struct pool_buffer *current_buffer; + + struct swaynag_type *type; + uint32_t anchors; + char *message; + char *font; + list_t *buttons; + struct swaynag_details details; +}; + +void swaynag_setup(struct swaynag *swaynag); + +void swaynag_run(struct swaynag *swaynag); + +void swaynag_destroy(struct swaynag *swaynag); + +#endif diff --git a/include/swaynag/types.h b/include/swaynag/types.h index 32056514..af83bd83 100644 --- a/include/swaynag/types.h +++ b/include/swaynag/types.h @@ -1,7 +1,7 @@ -#ifndef _SWAY_NAGBAR_TYPES_H -#define _SWAY_NAGBAR_TYPES_H +#ifndef _SWAYNAG_TYPES_H +#define _SWAYNAG_TYPES_H -struct sway_nagbar_type { +struct swaynag_type { char *name; uint32_t button_background; uint32_t background; @@ -10,16 +10,16 @@ struct sway_nagbar_type { uint32_t border_bottom; }; -void nagbar_types_add_default(list_t *types); +void swaynag_types_add_default(list_t *types); -struct sway_nagbar_type *nagbar_type_get(list_t *types, char *name); +struct swaynag_type *swaynag_type_get(list_t *types, char *name); -struct sway_nagbar_type *nagbar_type_clone(struct sway_nagbar_type *type); +struct swaynag_type *swaynag_type_clone(struct swaynag_type *type); -void nagbar_type_free(struct sway_nagbar_type *type); +void swaynag_type_free(struct swaynag_type *type); -void nagbar_types_free(list_t *types); +void swaynag_types_free(list_t *types); -int nagbar_parse_type(int argc, char **argv, struct sway_nagbar_type *type); +int swaynag_parse_type(int argc, char **argv, struct swaynag_type *type); #endif -- cgit v1.2.3