summaryrefslogtreecommitdiffstats
path: root/swaybar/main.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-11-29 15:27:28 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-11-29 15:27:28 -0500
commit82d464bb90af7fed57a36aacc2dce22994849bac (patch)
tree471b8eba3fb838115b163980b558cb151c6dbefc /swaybar/main.c
parentOnly strip comments at the start of a line (diff)
downloadsway-82d464bb90af7fed57a36aacc2dce22994849bac.tar.gz
sway-82d464bb90af7fed57a36aacc2dce22994849bac.tar.zst
sway-82d464bb90af7fed57a36aacc2dce22994849bac.zip
Add text rendering support to wayland clients
Diffstat (limited to 'swaybar/main.c')
-rw-r--r--swaybar/main.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/swaybar/main.c b/swaybar/main.c
index b25d8252..7a54f74b 100644
--- a/swaybar/main.c
+++ b/swaybar/main.c
@@ -2,8 +2,11 @@
2#include <stdlib.h> 2#include <stdlib.h>
3#include "client/registry.h" 3#include "client/registry.h"
4#include "client/window.h" 4#include "client/window.h"
5#include "client/pango.h"
5#include "log.h" 6#include "log.h"
6 7
8#define MARGIN 5
9
7struct box_colors { 10struct box_colors {
8 uint32_t border; 11 uint32_t border;
9 uint32_t background; 12 uint32_t background;
@@ -71,15 +74,17 @@ void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
71} 74}
72 75
73void render() { 76void render() {
74 // Reset buffer
75 cairo_save(window->cairo); 77 cairo_save(window->cairo);
76 cairo_set_operator(window->cairo, CAIRO_OPERATOR_CLEAR); 78 cairo_set_operator(window->cairo, CAIRO_OPERATOR_CLEAR);
77 cairo_paint(window->cairo); 79 cairo_paint(window->cairo);
78 cairo_restore(window->cairo); 80 cairo_restore(window->cairo);
79 81
80 // Draw bar
81 cairo_set_source_u32(window->cairo, colors.background); 82 cairo_set_source_u32(window->cairo, colors.background);
82 cairo_paint(window->cairo); 83 cairo_paint(window->cairo);
84
85 cairo_move_to(window->cairo, MARGIN, MARGIN);
86 cairo_set_source_u32(window->cairo, colors.statusline);
87 pango_printf(window, "TODO: finish bar");
83} 88}
84 89
85int main(int argc, char **argv) { 90int main(int argc, char **argv) {
@@ -101,6 +106,10 @@ int main(int argc, char **argv) {
101 desktop_shell_set_panel(registry->desktop_shell, output->output, window->surface); 106 desktop_shell_set_panel(registry->desktop_shell, output->output, window->surface);
102 desktop_shell_set_panel_position(registry->desktop_shell, DESKTOP_SHELL_PANEL_POSITION_BOTTOM); 107 desktop_shell_set_panel_position(registry->desktop_shell, DESKTOP_SHELL_PANEL_POSITION_BOTTOM);
103 108
109 int width, height;
110 get_text_size(window, &width, &height, "Test string for measuring purposes");
111 window->height = height + MARGIN * 2;
112
104 do { 113 do {
105 if (window_prerender(window) && window->cairo) { 114 if (window_prerender(window) && window->cairo) {
106 render(); 115 render();