diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-08-02 09:28:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-02 09:28:13 -0400 |
commit | ea14ef40955a94e21a5198d2469e54fe1e6056e5 (patch) | |
tree | 1a28ee032b762f471917c1f175ba02500f9ef794 /include | |
parent | 9aa258d33a9baa42895214da7e82f4568fcb8f76 (diff) | |
parent | 706c0fbe2376e15f8140be60f3c8b0713128ebba (diff) |
Merge pull request #2366 from RedSoxFan/nagbar
Implement swaynag
Diffstat (limited to 'include')
-rw-r--r-- | include/swaynag/config.h | 13 | ||||
-rw-r--r-- | include/swaynag/render.h | 7 | ||||
-rw-r--r-- | include/swaynag/swaynag.h | 100 | ||||
-rw-r--r-- | include/swaynag/types.h | 39 |
4 files changed, 159 insertions, 0 deletions
diff --git a/include/swaynag/config.h b/include/swaynag/config.h new file mode 100644 index 00000000..0d8889de --- /dev/null +++ b/include/swaynag/config.h @@ -0,0 +1,13 @@ +#ifndef _SWAYNAG_CONFIG_H +#define _SWAYNAG_CONFIG_H +#include "swaynag/swaynag.h" +#include "list.h" + +int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag, + list_t *types, struct swaynag_type *type, char **config, bool *debug); + +char *swaynag_get_config_path(void); + +int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types); + +#endif diff --git a/include/swaynag/render.h b/include/swaynag/render.h new file mode 100644 index 00000000..d09e5929 --- /dev/null +++ b/include/swaynag/render.h @@ -0,0 +1,7 @@ +#ifndef _SWAYNAG_RENDER_H +#define _SWAYNAG_RENDER_H +#include "swaynag/swaynag.h" + +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..1bf8b640 --- /dev/null +++ b/include/swaynag/swaynag.h @@ -0,0 +1,100 @@ +#ifndef _SWAYNAG_SWAYNAG_H +#define _SWAYNAG_SWAYNAG_H +#include <stdint.h> +#include <strings.h> +#include "list.h" +#include "pool-buffer.h" +#include "swaynag/types.h" +#include "xdg-output-unstable-v1-client-protocol.h" + +#define SWAYNAG_MAX_HEIGHT 500 + +struct swaynag; + +enum swaynag_action_type { + SWAYNAG_ACTION_DISMISS, + SWAYNAG_ACTION_EXPAND, + SWAYNAG_ACTION_COMMAND, +}; + +struct swaynag_pointer { + struct wl_pointer *pointer; + uint32_t serial; + 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; + uint32_t scale; + struct swaynag *swaynag; + struct wl_list link; +}; + +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 wl_list outputs; // swaynag_output::link + 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; + char *message; + 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 new file mode 100644 index 00000000..2183ce22 --- /dev/null +++ b/include/swaynag/types.h @@ -0,0 +1,39 @@ +#ifndef _SWAYNAG_TYPES_H +#define _SWAYNAG_TYPES_H + +struct swaynag_type { + char *name; + + char *font; + char *output; + uint32_t anchors; + + uint32_t button_background; + uint32_t background; + uint32_t text; + uint32_t border; + uint32_t border_bottom; + + uint32_t bar_border_thickness; + uint32_t message_padding; + uint32_t details_border_thickness; + uint32_t button_border_thickness; + uint32_t button_gap; + uint32_t button_gap_close; + uint32_t button_margin_right; + uint32_t button_padding; +}; + +void swaynag_types_add_default(list_t *types); + +struct swaynag_type *swaynag_type_get(list_t *types, char *name); + +struct swaynag_type *swaynag_type_clone(struct swaynag_type *type); + +void swaynag_type_merge(struct swaynag_type *dest, struct swaynag_type *src); + +void swaynag_type_free(struct swaynag_type *type); + +void swaynag_types_free(list_t *types); + +#endif |