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