Skip to content
Myr

main: move static window configuration variables into context struct

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 4edbcc1 · Browse files · 1 file+29 added−18 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+29 added−18 removed

  • other:+29 added−18 removed

1 file+29 added−18 removed

modified:main.c+29 added-18 removed
103 unmodified lines
104 } repeat;105106 bool frame_is_scheduled;107 struct buffer *pending;108109 /* Window configuration */110 int width;111 int height;112 const double x_margin;113 const double y_margin;114 const double border_size;115 struct { double r, g, b, a; } background;116};117110/* Window size */111static int width = 500;112static int height = 300;113114static const double x_margin = 20;115static const double y_margin = 4;116static const double border_size = 1;117118static int max_matches;119120static void refresh(struct context *c);121static void update_matches(struct context *c);
865 unmodified lines
987988static void989refresh(struct context *c)990{991 struct buffer *buf = shm_get_buffer(c->wl.shm, width, height);991 struct buffer *buf = shm_get_buffer(c->wl.shm, c->width, c->height);992993 /* Background */994 cairo_set_source_rgba(buf->cairo, 0.247, 0.247, 0.247, 0.9);994 cairo_set_source_rgba(995 buf->cairo,996 c->background.r, c->background.g, c->background.b, c->background.a);997 cairo_set_operator(buf->cairo, CAIRO_OPERATOR_SOURCE);998 cairo_paint(buf->cairo);9991000 /* Border */1001 cairo_set_source_rgba(buf->cairo, 1.0, 1.0, 1.0, 1.0);1002 cairo_set_line_width(buf->cairo, 2 * 1);1003 cairo_set_operator(buf->cairo, CAIRO_OPERATOR_OVER);1002 cairo_rectangle(buf->cairo, 0, 0, width, height);1004 cairo_rectangle(buf->cairo, 0, 0, c->width, c->height);1005 cairo_stroke(buf->cairo);10061007 render_prompt(c->render, buf, &c->prompt);1008 render_match_list(c->render, buf, c->matches, c->match_count,
29 unmodified lines
1038 };10391040 const char *output_name = NULL;1041 const char *font_name = "monospace";10421043 int width = 500;1044 int height = 300;1045 uint32_t text_color = 0xffffffff;1046 uint32_t match_color = 0xcc9393ff;10471048 while (true) {
62 unmodified lines
1111 .pipe_read_fd = repeat_pipe_fds[0],1112 .pipe_write_fd = repeat_pipe_fds[1],1113 .cmd = REPEAT_STOP,1114 },1115 .width = width,1116 .height = height,1117 .x_margin = 20,1118 .y_margin = 4,1119 .border_size = 1,1120 .background = {0.247, 0.247, 0.247, 0.9},1121 };11221123 mtx_init(&c.repeat.mutex, mtx_plain);1124 cnd_init(&c.repeat.cond);
12 unmodified lines
11371138 LOG_DBG("height: %f, ascent: %f, descent: %f",1139 fextents.height, fextents.ascent, fextents.descent);11401130 const double line_height = 2 * y_margin + fextents.height;1131 max_matches = (height - 2 * border_size - line_height) / line_height;1141 const double line_height = 2 * c.y_margin + fextents.height;1142 max_matches = (height - 2 * c.border_size - line_height) / line_height;1143 LOG_DBG("max matches: %d", max_matches);11441145 xdg_find_programs(fextents.height, &c.applications);1146 c.matches = malloc(tll_length(c.applications) * sizeof(c.matches[0]));
96 unmodified lines
1243 wl_surface_commit(c.wl.surface);1244 wl_display_roundtrip(c.wl.display);12451246 struct options options = {1236 .width = width,1237 .height = height,1238 .x_margin = x_margin,1239 .y_margin = y_margin,1240 .border_size = border_size,1247 .width = c.width,1248 .height = c.height,1249 .x_margin = c.x_margin,1250 .y_margin = c.y_margin,1251 .border_size = c.border_size,1252 .text_color = text_color,1253 .match_color = match_color,1254 };1255 c.render = render_init(font, options);
103 unmodified lines