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.
This commit is contained in:
Drew DeVault 2018-03-28 23:04:20 -04:00
parent 382e8af418
commit cab1352801
23 changed files with 345 additions and 3787 deletions

View file

@ -1,21 +1,24 @@
#define _XOPEN_SOURCE 500
#include <stdlib.h>
#include <string.h>
#include "wayland-desktop-shell-client-protocol.h"
#include "log.h"
#include "swaybar/config.h"
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
uint32_t parse_position(const char *position) {
uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
uint32_t vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
if (strcmp("top", position) == 0) {
return DESKTOP_SHELL_PANEL_POSITION_TOP;
return ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | horiz;
} else if (strcmp("bottom", position) == 0) {
return DESKTOP_SHELL_PANEL_POSITION_BOTTOM;
return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz;
} else if (strcmp("left", position) == 0) {
return DESKTOP_SHELL_PANEL_POSITION_LEFT;
return ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | vert;
} else if (strcmp("right", position) == 0) {
return DESKTOP_SHELL_PANEL_POSITION_RIGHT;
return ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | vert;
} else {
return DESKTOP_SHELL_PANEL_POSITION_BOTTOM;
return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz;
}
}
@ -30,11 +33,11 @@ char *parse_font(const char *font) {
return new_font;
}
struct config *init_config() {
struct config *config = calloc(1, sizeof(struct config));
struct swaybar_config *init_config() {
struct swaybar_config *config = calloc(1, sizeof(struct swaybar_config));
config->status_command = NULL;
config->pango_markup = false;
config->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM;
config->position = parse_position("bottom");
config->font = strdup("monospace 10");
config->mode = NULL;
config->sep_symbol = NULL;
@ -48,18 +51,6 @@ struct config *init_config() {
/* height */
config->height = 0;
#ifdef ENABLE_TRAY
config->tray_output = NULL;
config->icon_theme = NULL;
config->tray_padding = 2;
/**
* These constants are used by wayland and are defined in
* linux/input-event-codes.h
*/
config->activate_button = 0x110; /* BTN_LEFT */
config->context_button = 0x111; /* BTN_RIGHT */
#endif
/* colors */
config->colors.background = 0x000000FF;
config->colors.statusline = 0xFFFFFFFF;
@ -88,7 +79,7 @@ struct config *init_config() {
return config;
}
void free_config(struct config *config) {
void free_config(struct swaybar_config *config) {
free(config->status_command);
free(config->font);
free(config->mode);