swaynag: refactor {sway_,}nagbar to swaynag

This commit is contained in:
Brian Ashworth 2018-07-28 23:15:12 -04:00
parent 6124d0f9a2
commit a6145914c6
10 changed files with 415 additions and 411 deletions

View file

@ -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

View file

@ -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

View file

@ -1,5 +1,5 @@
#ifndef _SWAY_NAGBAR_NAGBAR_H
#define _SWAY_NAGBAR_NAGBAR_H
#ifndef _SWAYNAG_SWAYNAG_H
#define _SWAYNAG_SWAYNAG_H
#include <stdint.h>
#include <strings.h>
#include "list.h"
@ -7,24 +7,24 @@
#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 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 NAGBAR_MAX_HEIGHT 500
#define SWAYNAG_MAX_HEIGHT 500
enum sway_nagbar_action_type {
NAGBAR_ACTION_DISMISS,
NAGBAR_ACTION_EXPAND,
NAGBAR_ACTION_COMMAND,
enum swaynag_action_type {
SWAYNAG_ACTION_DISMISS,
SWAYNAG_ACTION_EXPAND,
SWAYNAG_ACTION_COMMAND,
};
struct sway_nagbar_pointer {
struct swaynag_pointer {
struct wl_pointer *pointer;
struct wl_cursor_theme *cursor_theme;
struct wl_cursor_image *cursor_image;
@ -33,15 +33,15 @@ struct sway_nagbar_pointer {
int y;
};
struct sway_nagbar_output {
struct swaynag_output {
char *name;
struct wl_output *wl_output;
uint32_t wl_name;
};
struct sway_nagbar_button {
struct swaynag_button {
char *text;
enum sway_nagbar_action_type type;
enum swaynag_action_type type;
char *action;
int x;
int y;
@ -49,7 +49,7 @@ struct sway_nagbar_button {
int height;
};
struct sway_nagbar_details {
struct swaynag_details {
bool visible;
char *message;
@ -61,12 +61,12 @@ struct sway_nagbar_details {
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 swaynag_button button_details;
struct swaynag_button button_up;
struct swaynag_button button_down;
};
struct sway_nagbar {
struct swaynag {
bool run_display;
int querying_outputs;
@ -74,9 +74,9 @@ struct sway_nagbar {
struct wl_compositor *compositor;
struct wl_seat *seat;
struct wl_shm *shm;
struct sway_nagbar_pointer pointer;
struct swaynag_pointer pointer;
struct zxdg_output_manager_v1 *xdg_output_manager;
struct sway_nagbar_output output;
struct swaynag_output output;
struct zwlr_layer_shell_v1 *layer_shell;
struct zwlr_layer_surface_v1 *layer_surface;
struct wl_surface *surface;
@ -87,18 +87,18 @@ struct sway_nagbar {
struct pool_buffer buffers[2];
struct pool_buffer *current_buffer;
struct sway_nagbar_type *type;
struct swaynag_type *type;
uint32_t anchors;
char *message;
char *font;
list_t *buttons;
struct sway_nagbar_details details;
struct swaynag_details details;
};
void nagbar_setup(struct sway_nagbar *nagbar);
void swaynag_setup(struct swaynag *swaynag);
void nagbar_run(struct sway_nagbar *nagbar);
void swaynag_run(struct swaynag *swaynag);
void nagbar_destroy(struct sway_nagbar *nagbar);
void swaynag_destroy(struct swaynag *swaynag);
#endif

View file

@ -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