From 7efa4a53051e6ee43d30ee1573f55cb0d2797769 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 14 Sep 2018 08:30:09 +0100 Subject: [PATCH] Clean up a 'void *' in a unix.h typedef. 'struct draw_ctx' has a structure tag inside gtkwin.c, so as per this week's standard practice, let's expose the tag elsewhere so that pointers declared that way can't be confused with anything else. --- fuzzterm.c | 6 +----- unix/gtkwin.c | 16 ++++++---------- unix/unix.h | 2 +- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/fuzzterm.c b/fuzzterm.c index fda9f6c8..fb68482c 100644 --- a/fuzzterm.c +++ b/fuzzterm.c @@ -73,11 +73,7 @@ void set_sbar(Frontend *frontend, int a, int b, int c) { } void ldisc_send(Ldisc *ldisc, const void *buf, int len, int interactive) {} void ldisc_echoedit_update(Ldisc *ldisc) {} -Context get_ctx(Frontend *frontend) { - static char x; - - return &x; -} +Context get_ctx(Frontend *frontend) { return NULL; } void free_ctx(Context ctx) { } void palette_set(Frontend *frontend, int a, int b, int c, int d) { } void palette_reset(Frontend *frontend) { } diff --git a/unix/gtkwin.c b/unix/gtkwin.c index aebeff8f..46b62782 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -3481,9 +3481,8 @@ Context get_ctx(Frontend *inst) return dctx; } -void free_ctx(Context ctx) +void free_ctx(Context dctx) { - struct draw_ctx *dctx = (struct draw_ctx *)ctx; /* Frontend *inst = dctx->inst; */ #ifdef DRAW_TEXT_GDK if (dctx->uctx.type == DRAWTYPE_GDK) { @@ -3796,10 +3795,9 @@ static void draw_backing_rect(Frontend *inst) * * We are allowed to fiddle with the contents of `text'. */ -void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, +void do_text_internal(Context dctx, int x, int y, wchar_t *text, int len, unsigned long attr, int lattr, truecolour truecolour) { - struct draw_ctx *dctx = (struct draw_ctx *)ctx; Frontend *inst = dctx->inst; int ncombining; int nfg, nbg, t, fontid, shadow, rlen, widefactor, bold; @@ -3953,14 +3951,13 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, } } -void do_text(Context ctx, int x, int y, wchar_t *text, int len, +void do_text(Context dctx, int x, int y, wchar_t *text, int len, unsigned long attr, int lattr, truecolour truecolour) { - struct draw_ctx *dctx = (struct draw_ctx *)ctx; Frontend *inst = dctx->inst; int widefactor; - do_text_internal(ctx, x, y, text, len, attr, lattr, truecolour); + do_text_internal(dctx, x, y, text, len, attr, lattr, truecolour); if (attr & ATTR_WIDE) { widefactor = 2; @@ -3983,10 +3980,9 @@ void do_text(Context ctx, int x, int y, wchar_t *text, int len, len*widefactor*inst->font_width, inst->font_height); } -void do_cursor(Context ctx, int x, int y, wchar_t *text, int len, +void do_cursor(Context dctx, int x, int y, wchar_t *text, int len, unsigned long attr, int lattr, truecolour truecolour) { - struct draw_ctx *dctx = (struct draw_ctx *)ctx; Frontend *inst = dctx->inst; int active, passive, widefactor; @@ -4001,7 +3997,7 @@ void do_cursor(Context ctx, int x, int y, wchar_t *text, int len, active = 1; } else active = 0; - do_text_internal(ctx, x, y, text, len, attr, lattr, truecolour); + do_text_internal(dctx, x, y, text, len, attr, lattr, truecolour); if (attr & TATTR_COMBINING) len = 1; diff --git a/unix/unix.h b/unix/unix.h index 3dd2864a..9a93a059 100644 --- a/unix/unix.h +++ b/unix/unix.h @@ -65,7 +65,7 @@ struct FontSpec { }; struct FontSpec *fontspec_new(const char *name); -typedef void *Context; /* FIXME: probably needs changing */ +typedef struct draw_ctx *Context; extern const struct Backend_vtable pty_backend;