From f311668119a080a8ea6c02291d08f89083d6abf1 Mon Sep 17 00:00:00 2001 From: pascal Date: Sat, 9 Mar 2024 08:44:40 +0100 Subject: [PATCH] config: don't set arrow type to none when size is defined --- README.md | 2 +- src/callbacks.c | 10 +++++----- src/config.c | 3 +-- src/main.c | 6 ++---- src/main.h | 1 - 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index abe818e..39f8270 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,7 @@ A `LINE`-tool draws straight lines. A `RECT`-tool draws rectangles. - "red Rectangle" = LINE (color = "red"); + "red Rectangle" = RECT (color = "red"); If you define a tool with the same name as an input-device (see the output of `xinput --list`) this input-device uses this tool: diff --git a/src/callbacks.c b/src/callbacks.c index 98b5bb2..2737f7b 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -143,9 +143,9 @@ void on_monitors_changed ( GdkScreen *screen, data->default_pen = paint_context_new (data, GROMIT_PEN, data->red, 7, - 0, GROMIT_ARROW_NONE, 1, G_MAXUINT); + 0, GROMIT_ARROW_END, 1, G_MAXUINT); data->default_eraser = paint_context_new (data, GROMIT_ERASER, data->red, 75, - 0, GROMIT_ARROW_NONE, 1, G_MAXUINT); + 0, GROMIT_ARROW_END, 1, G_MAXUINT); if(!data->composited) // set shape { @@ -398,10 +398,10 @@ gboolean on_motion (GtkWidget *win, } if (type == GROMIT_LINE) { - GromitArrowType atype = devdata->cur_context->arrow_type; draw_line (data, ev->device, devdata->lastx, devdata->lasty, ev->x, ev->y); - if (atype != GROMIT_ARROW_NONE) + if (devdata->cur_context->arrowsize > 0) { + GromitArrowType atype = devdata->cur_context->arrow_type; gint width = devdata->cur_context->arrowsize * devdata->cur_context->width / 2; gfloat direction = atan2(ev->y - devdata->lasty, ev->x - devdata->lastx); @@ -616,7 +616,7 @@ void on_mainapp_selection_received (GtkWidget *widget, } GromitPaintContext* line_ctx = paint_context_new(data, GROMIT_PEN, fg_color, thickness, - 0, GROMIT_ARROW_NONE, thickness, thickness); + 0, GROMIT_ARROW_END, thickness, thickness); GdkRectangle rect; rect.x = MIN (startX,endX) - thickness / 2; diff --git a/src/config.c b/src/config.c index b8a9329..87ea016 100644 --- a/src/config.c +++ b/src/config.c @@ -227,7 +227,7 @@ gboolean parse_config (GromitData *data) type = GROMIT_PEN; width = 7; arrowsize = 0; - arrowtype = GROMIT_ARROW_NONE; + arrowtype = GROMIT_ARROW_END; minwidth = 1; maxwidth = G_MAXUINT; fg_color = data->red; @@ -340,7 +340,6 @@ gboolean parse_config (GromitData *data) goto cleanup; } arrowsize = scanner->value.v_float; - arrowtype = GROMIT_ARROW_END; } else if ((intptr_t) scanner->value.v_symbol == 4) { diff --git a/src/main.c b/src/main.c index 4ad5832..b54ccb7 100644 --- a/src/main.c +++ b/src/main.c @@ -114,8 +114,6 @@ void paint_context_print (gchar *name, case GROMIT_ARROW_DOUBLE: g_printerr(" arrowtype: double, "); break; - case GROMIT_ARROW_NONE: - break; } } g_printerr ("color: %s\n", gdk_rgba_to_string(context->paint_color)); @@ -778,10 +776,10 @@ void setup_main_app (GromitData *data, int argc, char ** argv) data->default_pen = paint_context_new (data, GROMIT_PEN, data->red, 7, - 0, GROMIT_ARROW_NONE, 1, G_MAXUINT); + 0, GROMIT_ARROW_END, 1, G_MAXUINT); data->default_eraser = paint_context_new (data, GROMIT_ERASER, data->red, 75, - 0, GROMIT_ARROW_NONE, 1, G_MAXUINT); + 0, GROMIT_ARROW_END, 1, G_MAXUINT); gdk_event_handler_set ((GdkEventFunc) main_do_event, data, NULL); gtk_key_snooper_install (snoop_key_press, data); diff --git a/src/main.h b/src/main.h index d7122df..8fea9ba 100644 --- a/src/main.h +++ b/src/main.h @@ -72,7 +72,6 @@ typedef enum typedef enum { - GROMIT_ARROW_NONE = 0, GROMIT_ARROW_START = 1, GROMIT_ARROW_END = 2, GROMIT_ARROW_DOUBLE = (GROMIT_ARROW_START | GROMIT_ARROW_END )