Skip to content

Commit

Permalink
Moved dimensions option to state struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Limero committed Jul 3, 2018
1 parent 66d6f24 commit 36b653d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/slurp.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct slurp_state {
} colors;

uint32_t border_weight;
bool display_dimensions;

struct slurp_box result;
};
Expand All @@ -49,7 +50,6 @@ struct slurp_output {
bool configured;
bool frame_scheduled;
bool dirty;
bool display_dimensions;
int32_t width, height;
struct pool_buffer buffers[2];
struct pool_buffer *current_buffer;
Expand Down
6 changes: 2 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,17 @@ int main(int argc, char *argv[]) {
.selection = 0x00000000,
},
.border_weight = 2,
.display_dimensions = false,
};

bool display_dimensions = false;
int opt;
while ((opt = getopt(argc, argv, "hdb:c:s:w:")) != -1) {
switch (opt) {
case 'h':
printf("%s", usage);
return EXIT_SUCCESS;
case 'd':
display_dimensions = true;
state.display_dimensions = true;
break;
case 'b':
state.colors.background = parse_color(optarg);
Expand Down Expand Up @@ -437,8 +437,6 @@ int main(int argc, char *argv[]) {
output->surface = wl_compositor_create_surface(state.compositor);
// TODO: wl_surface_add_listener(output->surface, &surface_listener, output);

output->display_dimensions = display_dimensions;

output->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
state.layer_shell, output->surface, output->wl_output,
ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY, "selection");
Expand Down
3 changes: 1 addition & 2 deletions render.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ void render(struct slurp_output *output) {
struct pool_buffer *buffer = output->current_buffer;
cairo_t *cairo = buffer->cairo;
int32_t scale = output->scale;
bool display_dimensions = output->display_dimensions;

// Clear
cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
Expand Down Expand Up @@ -48,7 +47,7 @@ void render(struct slurp_output *output) {
width * scale, height * scale);
cairo_stroke(cairo);

if (display_dimensions) {
if (state->display_dimensions) {
cairo_select_font_face(cairo, "Sans", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cairo, 14);
Expand Down

0 comments on commit 36b653d

Please sign in to comment.