- /* After the user pressed any valid key or the backspace key, we
- * highlight a random part of the unlock indicator to confirm this
- * keypress. */
- if (unlock_state == STATE_KEY_ACTIVE ||
- unlock_state == STATE_BACKSPACE_ACTIVE) {
- cairo_new_sub_path(ctx);
- double highlight_start = (rand() % (int)(2 * M_PI * 100)) / 100.0;
- DEBUG("Highlighting part %.2f\n", highlight_start);
- cairo_arc(ctx, resolution[0] / 2 /* x */, resolution[1] / 2 /* y */,
- BUTTON_RADIUS /* radius */, highlight_start,
- highlight_start + (M_PI / 3.0));
- if (unlock_state == STATE_KEY_ACTIVE) {
- /* For normal keys, we use a lighter green. */
- outer_pat = cairo_pattern_create_linear(0, 0, 0, BUTTON_DIAMETER);
- cairo_pattern_add_color_stop_rgb(outer_pat, 0, 139.0/255, 219.0/255, 0);
- cairo_pattern_add_color_stop_rgb(outer_pat, 1, 51.0/255, 219.0/255, 0);
- } else {
- /* For backspace, we use red. */
- outer_pat = cairo_pattern_create_linear(0, 0, 0, BUTTON_DIAMETER);
- cairo_pattern_add_color_stop_rgb(outer_pat, 0, 219.0/255, 139.0/255, 0);
- cairo_pattern_add_color_stop_rgb(outer_pat, 1, 219.0/255, 51.0/255, 0);
- }
- cairo_set_source(ctx, outer_pat);
- cairo_stroke(ctx);
-
- /* Draw two little separators for the highlighted part of the
- * unlock indicator. */
- cairo_set_source_rgb(ctx, 0, 0, 0);
- cairo_arc(ctx,
- (resolution[0] / 2) /* x */,
- (resolution[1] / 2) /* y */,
- BUTTON_RADIUS /* radius */,
- highlight_start /* start */,
- highlight_start + (M_PI / 128.0) /* end */);
- cairo_stroke(ctx);
- cairo_arc(ctx,
- (resolution[0] / 2) /* x */,
- (resolution[1] / 2) /* y */,
- BUTTON_RADIUS /* radius */,
- highlight_start + (M_PI / 3.0) /* start */,
- (highlight_start + (M_PI / 3.0)) + (M_PI / 128.0) /* end */);
- cairo_stroke(ctx);
- }