aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-03-28 23:04:20 -0400
committerDrew DeVault <sir@cmpwn.com>2018-03-29 22:11:08 -0400
commitcab1352801b62d1b8a12ca1c995cb24445ce4bc9 (patch)
treebc67373916c06d48700c4f69b8c2470a2f86887f /include
parent382e8af418a7e1b8cf93d3398509b93c6874cb0d (diff)
Start port of swaybar to layer shell
This starts up the event loop and wayland display and shims out the basic top level rendering concepts. Also includes some changes to incorporate pango into the 1.x codebase properly.
Diffstat (limited to 'include')
-rw-r--r--include/pango.h16
-rw-r--r--include/sway/config.h7
-rw-r--r--include/swaybar/bar.h89
-rw-r--r--include/swaybar/config.h43
-rw-r--r--include/swaybar/event_loop.h4
-rw-r--r--include/swaybar/ipc.h22
-rw-r--r--include/swaybar/render.h22
7 files changed, 67 insertions, 136 deletions
diff --git a/include/pango.h b/include/pango.h
new file mode 100644
index 00000000..f6325f28
--- /dev/null
+++ b/include/pango.h
@@ -0,0 +1,16 @@
+#ifndef _SWAY_PANGO_H
+#define _SWAY_PANGO_H
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <cairo/cairo.h>
+#include <pango/pangocairo.h>
+
+PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
+ const char *text, int32_t scale, bool markup);
+void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
+ int32_t scale, bool markup, const char *fmt, ...);
+void pango_printf(cairo_t *cairo, const char *font,
+ int32_t scale, bool markup, const char *fmt, ...);
+
+#endif
diff --git a/include/sway/config.h b/include/sway/config.h
index 48a8b0ab..8c9e04de 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -1,17 +1,16 @@
#ifndef _SWAY_CONFIG_H
#define _SWAY_CONFIG_H
-
#define PID_WORKSPACE_TIMEOUT 60
-
#include <libinput.h>
#include <stdint.h>
#include <string.h>
+#include <time.h>
#include <wlr/types/wlr_box.h>
#include <xkbcommon/xkbcommon.h>
-#include <time.h>
#include "list.h"
#include "layout.h"
#include "container.h"
+#include "wlr-layer-shell-unstable-v1-protocol.h"
/**
* Describes a variable created via the `set` command.
@@ -152,7 +151,7 @@ struct bar_config {
char *id;
uint32_t modifier;
list_t *outputs;
- //enum desktop_shell_panel_position position; // TODO
+ char *position;
list_t *bindings;
char *status_command;
bool pango_markup;
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h
index 50d36e76..3ae8c0b3 100644
--- a/include/swaybar/bar.h
+++ b/include/swaybar/bar.h
@@ -1,72 +1,45 @@
#ifndef _SWAYBAR_BAR_H
#define _SWAYBAR_BAR_H
-
-#include "client/registry.h"
-#include "client/window.h"
+#include <wayland-client.h>
+#include "pool-buffer.h"
#include "list.h"
-struct bar {
- struct config *config;
- struct status_line *status;
- list_t *outputs;
- struct output *focused_output;
+struct swaybar_config;
+struct swaybar_output;
+struct swaybar_workspace;
+
+struct swaybar {
+ struct wl_display *display;
+ struct wl_compositor *compositor;
+ struct zwlr_layer_shell_v1 *layer_shell;
+ struct wl_shm *shm;
- int ipc_event_socketfd;
- int ipc_socketfd;
- int status_read_fd;
- int status_write_fd;
- pid_t status_command_pid;
+ struct swaybar_config *config;
+ struct swaybar_output *focused_output;
+
+ struct wl_list outputs;
};
-struct output {
- struct window *window;
- struct registry *registry;
- list_t *workspaces;
-#ifdef ENABLE_TRAY
- list_t *items;
-#endif
+struct swaybar_output {
+ struct wl_list link;
+ struct swaybar *bar;
+ struct wl_output *output;
+ struct wl_surface *surface;
+ struct zwlr_layer_surface_v1 *layer_surface;
+
char *name;
int idx;
bool focused;
-};
-struct workspace {
- int num;
- char *name;
- bool focused;
- bool visible;
- bool urgent;
+ uint32_t width, height;
+ struct pool_buffer buffers[2];
+ struct pool_buffer *current_buffer;
};
-/** Global bar state */
-extern struct bar swaybar;
+void bar_setup(struct swaybar *bar,
+ const char *socket_path,
+ const char *bar_id);
+void bar_run(struct swaybar *bar);
+void bar_teardown(struct swaybar *bar);
-/** True if sway needs to render */
-extern bool dirty;
-
-/**
- * Setup bar.
- */
-void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id);
-
-/**
- * Create new output struct from name.
- */
-struct output *new_output(const char *name);
-
-/**
- * Bar mainloop.
- */
-void bar_run(struct bar *bar);
-
-/**
- * free workspace list.
- */
-void free_workspaces(list_t *workspaces);
-
-/**
- * Teardown bar.
- */
-void bar_teardown(struct bar *bar);
-
-#endif /* _SWAYBAR_BAR_H */
+#endif
diff --git a/include/swaybar/config.h b/include/swaybar/config.h
index 651f0ee3..1bfe4843 100644
--- a/include/swaybar/config.h
+++ b/include/swaybar/config.h
@@ -1,9 +1,7 @@
#ifndef _SWAYBAR_CONFIG_H
#define _SWAYBAR_CONFIG_H
-
-#include <stdint.h>
#include <stdbool.h>
-
+#include <stdint.h>
#include "list.h"
#include "util.h"
@@ -19,10 +17,10 @@ struct box_colors {
/**
* Swaybar config.
*/
-struct config {
+struct swaybar_config {
char *status_command;
bool pango_markup;
- uint32_t position;
+ uint32_t position; // zwlr_layer_surface_v1_anchor
char *font;
char *sep_symbol;
char *mode;
@@ -32,18 +30,6 @@ struct config {
bool workspace_buttons;
bool all_outputs;
list_t *outputs;
-
-#ifdef ENABLE_TRAY
- // Tray
- char *tray_output;
- char *icon_theme;
-
- uint32_t tray_padding;
- uint32_t activate_button;
- uint32_t context_button;
- uint32_t secondary_button;
-#endif
-
int height;
struct {
@@ -63,24 +49,7 @@ struct config {
} colors;
};
-/**
- * Parse position top|bottom|left|right.
- */
-uint32_t parse_position(const char *position);
-
-/**
- * Parse font.
- */
-char *parse_font(const char *font);
-
-/**
- * Initialize default sway config.
- */
-struct config *init_config();
-
-/**
- * Free config struct.
- */
-void free_config(struct config *config);
+struct swaybar_config *init_config();
+void free_config(struct swaybar_config *config);
-#endif /* _SWAYBAR_CONFIG_H */
+#endif
diff --git a/include/swaybar/event_loop.h b/include/swaybar/event_loop.h
index a0cde07f..99f6ed36 100644
--- a/include/swaybar/event_loop.h
+++ b/include/swaybar/event_loop.h
@@ -1,6 +1,5 @@
#ifndef _SWAYBAR_EVENT_LOOP_H
#define _SWAYBAR_EVENT_LOOP_H
-
#include <stdbool.h>
#include <time.h>
@@ -23,4 +22,5 @@ bool remove_timer(timer_t timer);
void event_loop_poll();
void init_event_loop();
-#endif /*_SWAYBAR_EVENT_LOOP_H */
+
+#endif
diff --git a/include/swaybar/ipc.h b/include/swaybar/ipc.h
index c11931d0..57a1b925 100644
--- a/include/swaybar/ipc.h
+++ b/include/swaybar/ipc.h
@@ -1,23 +1,9 @@
#ifndef _SWAYBAR_IPC_H
#define _SWAYBAR_IPC_H
+#include "swaybar/bar.h"
-#include "bar.h"
-
-/**
- * Initialize ipc connection to sway and get sway state, outputs, bar_config.
- */
-void ipc_bar_init(struct bar *bar, const char *bar_id);
-
-/**
- * Handle ipc event from sway.
- */
-bool handle_ipc_event(struct bar *bar);
-
-
-/**
- * Send workspace command to sway
- */
+void ipc_bar_init(struct swaybar *bar, const char *bar_id);
+bool handle_ipc_event(struct swaybar *bar);
void ipc_send_workspace_command(const char *workspace_name);
-#endif /* _SWAYBAR_IPC_H */
-
+#endif
diff --git a/include/swaybar/render.h b/include/swaybar/render.h
index 114f43f4..071e2298 100644
--- a/include/swaybar/render.h
+++ b/include/swaybar/render.h
@@ -1,22 +1,10 @@
#ifndef _SWAYBAR_RENDER_H
#define _SWAYBAR_RENDER_H
-#include "config.h"
-#include "bar.h"
+struct swaybar;
+struct swaybar_output;
+struct swaybar_config;
-/**
- * Render swaybar.
- */
-void render(struct output *output, struct config *config, struct status_line *line);
+void render_frame(struct swaybar *bar, struct swaybar_output *output);
-/**
- * Set window height and modify internal spacing accordingly.
- */
-void set_window_height(struct window *window, int height);
-
-/**
- * Compute the size of a workspace name
- */
-void workspace_button_size(struct window *window, const char *workspace_name, int *width, int *height);
-
-#endif /* _SWAYBAR_RENDER_H */
+#endif