| @@ -109,10 +109,7 @@ static Space spaces[] = { · 108 unmodified lines |
| 109 | 109 | }, |
| 110 | 110 | }; |
| 111 | 111 | |
| 112 | | −static char *menu2i[nelem(spaces)+3] = { |
| 113 | | − "snarf", |
| 114 | | − "snarf all", |
| 115 | | −}; |
| 112 | +static char *menu2i[nelem(spaces)+4]; |
| 116 | 113 | static Menu menu2 = { .item = menu2i }; |
| 117 | 114 | |
| 118 | 115 | static Color *colors; |
| @@ -396,7 +393,10 @@ threadmain(int argc, char **argv) · 277 unmodified lines |
| 396 | 393 | } |
| 397 | 394 | |
| 398 | 395 | for (i = 0; i < nelem(spaces); i++) |
| 399 | | − menu2i[i+2] = spaces[i].name; |
| 396 | + menu2i[i] = spaces[i].name; |
| 397 | + menu2i[i++] = "snarf"; |
| 398 | + menu2i[i++] = "snarf all"; |
| 399 | + menu2i[i] = "exit"; |
| 400 | 400 | |
| 401 | 401 | if (initdraw(nil, nil, "picker") < 0) |
| 402 | 402 | sysfatal("initdraw: %r"); |
| @@ -466,9 +466,11 @@ changed: · 63 unmodified lines |
| 466 | 466 | goto next; |
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | | − } else if (m.buttons == 2 && (i = menuhit(2, mctl, &menu2, nil)) >= 0) { |
| 470 | | − if (i >= 2) { |
| 471 | | − space = &spaces[i-2]; |
| 469 | + } else if (m.buttons == 4 && (i = menuhit(3, mctl, &menu2, nil)) >= 0) { |
| 470 | + if (i == nelem(spaces)+2) |
| 471 | + goto end; |
| 472 | + if (i < nelem(spaces)) { |
| 473 | + space = &spaces[i]; |
| 472 | 474 | space->fromrgb(c->rgba, c->v); |
| 473 | 475 | for (i = 0; i < 3; i++) |
| 474 | 476 | c->v[i] = MAX(0.0, MIN(space->max[i], c->v[i])); |
| @@ -477,7 +479,7 @@ changed: · 2 unmodified lines |
| 477 | 479 | |
| 478 | 480 | int f; |
| 479 | 481 | if ((f = open("/dev/snarf", OWRITE)) >= 0) { |
| 480 | | − if (i == 0) { |
| 482 | + if (i == nelem(spaces)) { |
| 481 | 483 | write(f, hex, strlen(hex)); |
| 482 | 484 | } else { |
| 483 | 485 | for (i = 0; i < ncolors; i++) { |
| @@ -488,7 +490,7 @@ changed: · 4 unmodified lines |
| 488 | 490 | } |
| 489 | 491 | close(f); |
| 490 | 492 | } |
| 491 | | − } else if (m.buttons == 4) { |
| 493 | + } else if (m.buttons == 2) { |
| 492 | 494 | strcpy(buf, hex); |
| 493 | 495 | if (enter(nchan < 4 ? "rgb:" : "rgba:", buf, sizeof(buf), mctl, kctl, nil) > 0) { |
| 494 | 496 | u = c->u; |