Skip to content

Commit

Permalink
Add option to add outputs as choice boxes
Browse files Browse the repository at this point in the history
Alternative to emersion#60
  • Loading branch information
tmccombs authored and emersion committed Sep 7, 2020
1 parent 2c09c84 commit ed155f6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
19 changes: 18 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ static const char usage[] =
" -s #rrggbbaa Set selection color.\n"
" -w n Set border weight.\n"
" -f s Set output format.\n"
" -o Select a display output.\n"
" -p Select a single point.\n";

uint32_t parse_color(const char *color) {
Expand Down Expand Up @@ -723,6 +724,10 @@ static void add_choice_box(struct slurp_state *state,
return;
}
*b = *box;
// copy label, so that this has ownership of its label
if (box->label) {
b->label = strdup(box->label);
}
wl_list_insert(state->boxes.prev, &b->link);
}

Expand All @@ -741,7 +746,8 @@ int main(int argc, char *argv[]) {

int opt;
char *format = "%x,%y %wx%h\n";
while ((opt = getopt(argc, argv, "hdb:c:s:w:pf:")) != -1) {
bool output_boxes = false;
while ((opt = getopt(argc, argv, "hdb:c:s:w:pof:")) != -1) {
switch (opt) {
case 'h':
printf("%s", usage);
Expand Down Expand Up @@ -774,6 +780,9 @@ int main(int argc, char *argv[]) {
case 'p':
state.single_point = true;
break;
case 'o':
output_boxes = true;
break;
default:
printf("%s", usage);
return EXIT_FAILURE;
Expand All @@ -792,6 +801,7 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
add_choice_box(&state, &in_box);
free(in_box.label);
}
free(line);
}
Expand Down Expand Up @@ -901,6 +911,13 @@ int main(int argc, char *argv[]) {
// second roundtrip for xdg-output
wl_display_roundtrip(state.display);

if (output_boxes) {
struct slurp_output *box_output;
wl_list_for_each(box_output, &state.outputs, link) {
add_choice_box(&state, &box_output->logical_geometry);
}
}

struct slurp_seat *seat;
wl_list_for_each(seat, &state.seats, link) {
seat->cursor_surface =
Expand Down
4 changes: 4 additions & 0 deletions slurp.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ held, the selection is moved instead of being resized.
Select a single pixel instead of a rectangle. This mode ignores any
predefined rectangles read from the standard input.

*-o*
Add predefined rectangles for all outputs, as if provided on standard input.
The label will be the name of the output.

# COLORS

Colors may be specified in #RRGGBB or #RRGGBBAA format. The # is optional.
Expand Down

0 comments on commit ed155f6

Please sign in to comment.