aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/config.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-28 23:04:20 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-03-29 22:11:08 -0400
commitcab1352801b62d1b8a12ca1c995cb24445ce4bc9 (patch)
treebc67373916c06d48700c4f69b8c2470a2f86887f /swaybar/config.c
parentAllow sway IPC clients to fall back to i3 socket (diff)
downloadsway-cab1352801b62d1b8a12ca1c995cb24445ce4bc9.tar.gz
sway-cab1352801b62d1b8a12ca1c995cb24445ce4bc9.tar.zst
sway-cab1352801b62d1b8a12ca1c995cb24445ce4bc9.zip
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 'swaybar/config.c')
-rw-r--r--swaybar/config.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/swaybar/config.c b/swaybar/config.c
index 8fe552f2..0c2b57e0 100644
--- a/swaybar/config.c
+++ b/swaybar/config.c
@@ -1,21 +1,24 @@
1#define _XOPEN_SOURCE 500 1#define _XOPEN_SOURCE 500
2#include <stdlib.h> 2#include <stdlib.h>
3#include <string.h> 3#include <string.h>
4#include "wayland-desktop-shell-client-protocol.h"
5#include "log.h"
6#include "swaybar/config.h" 4#include "swaybar/config.h"
5#include "wlr-layer-shell-unstable-v1-client-protocol.h"
7 6
8uint32_t parse_position(const char *position) { 7uint32_t parse_position(const char *position) {
8 uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
9 ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
10 uint32_t vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
11 ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
9 if (strcmp("top", position) == 0) { 12 if (strcmp("top", position) == 0) {
10 return DESKTOP_SHELL_PANEL_POSITION_TOP; 13 return ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | horiz;
11 } else if (strcmp("bottom", position) == 0) { 14 } else if (strcmp("bottom", position) == 0) {
12 return DESKTOP_SHELL_PANEL_POSITION_BOTTOM; 15 return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz;
13 } else if (strcmp("left", position) == 0) { 16 } else if (strcmp("left", position) == 0) {
14 return DESKTOP_SHELL_PANEL_POSITION_LEFT; 17 return ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | vert;
15 } else if (strcmp("right", position) == 0) { 18 } else if (strcmp("right", position) == 0) {
16 return DESKTOP_SHELL_PANEL_POSITION_RIGHT; 19 return ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | vert;
17 } else { 20 } else {
18 return DESKTOP_SHELL_PANEL_POSITION_BOTTOM; 21 return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz;
19 } 22 }
20} 23}
21 24
@@ -30,11 +33,11 @@ char *parse_font(const char *font) {
30 return new_font; 33 return new_font;
31} 34}
32 35
33struct config *init_config() { 36struct swaybar_config *init_config() {
34 struct config *config = calloc(1, sizeof(struct config)); 37 struct swaybar_config *config = calloc(1, sizeof(struct swaybar_config));
35 config->status_command = NULL; 38 config->status_command = NULL;
36 config->pango_markup = false; 39 config->pango_markup = false;
37 config->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; 40 config->position = parse_position("bottom");
38 config->font = strdup("monospace 10"); 41 config->font = strdup("monospace 10");
39 config->mode = NULL; 42 config->mode = NULL;
40 config->sep_symbol = NULL; 43 config->sep_symbol = NULL;
@@ -48,18 +51,6 @@ struct config *init_config() {
48 /* height */ 51 /* height */
49 config->height = 0; 52 config->height = 0;
50 53
51#ifdef ENABLE_TRAY
52 config->tray_output = NULL;
53 config->icon_theme = NULL;
54 config->tray_padding = 2;
55 /**
56 * These constants are used by wayland and are defined in
57 * linux/input-event-codes.h
58 */
59 config->activate_button = 0x110; /* BTN_LEFT */
60 config->context_button = 0x111; /* BTN_RIGHT */
61#endif
62
63 /* colors */ 54 /* colors */
64 config->colors.background = 0x000000FF; 55 config->colors.background = 0x000000FF;
65 config->colors.statusline = 0xFFFFFFFF; 56 config->colors.statusline = 0xFFFFFFFF;
@@ -88,7 +79,7 @@ struct config *init_config() {
88 return config; 79 return config;
89} 80}
90 81
91void free_config(struct config *config) { 82void free_config(struct swaybar_config *config) {
92 free(config->status_command); 83 free(config->status_command);
93 free(config->font); 84 free(config->font);
94 free(config->mode); 85 free(config->mode);