ref: 0186d78da9e83103eb80b3814d4de8031f29232f
parent: a7e738aceb36e4a70d41cf09a74b2d7a3af6cbe0
author: Ben Harris <bjh21@bjh21.me.uk>
date: Thu Feb 16 16:21:15 EST 2023
Mark many more function (and some objects) static I noticed commit db3b531e2cab765a00475054d2e9046c9d0437d3 in the history where Simon added a bunch of "static" qualifiers. That suggested that consistently marking internal functions "static" is desirable, so I tried a build using GCC's -Wmissing-declarations, which requires prior declaration (presumed to be in a header file) of all global functions. This commit makes the GTK build clean under GCC's -Wmissing-declarations. I've also adding "static" to a few obviously internal objects, but GCC doesn't complain about those so I certainly haven't got them all.
--- a/dominosa.c
+++ b/dominosa.c
@@ -930,7 +930,7 @@
int i;
};
-int parity_neighbour(int vertex, void *vctx)
+static int parity_neighbour(int vertex, void *vctx)
{
struct parity_findloop_ctx *ctx = (struct parity_findloop_ctx *)vctx;
struct solver_placement *p;
--- a/gtk.c
+++ b/gtk.c
@@ -319,7 +319,7 @@
output[0] = output[1] = output[2] = 0.9F;
}
-void gtk_status_bar(void *handle, const char *text)
+static void gtk_status_bar(void *handle, const char *text)
{
frontend *fe = (frontend *)handle;
@@ -1154,7 +1154,7 @@
* The exported drawing functions.
*/
-void gtk_start_draw(void *handle)
+static void gtk_start_draw(void *handle)
{
frontend *fe = (frontend *)handle;
fe->bbox_l = fe->w;
@@ -1164,20 +1164,21 @@
setup_drawing(fe);
}
-void gtk_clip(void *handle, int x, int y, int w, int h)
+static void gtk_clip(void *handle, int x, int y, int w, int h)
{
frontend *fe = (frontend *)handle;
do_clip(fe, x, y, w, h);
}
-void gtk_unclip(void *handle)
+static void gtk_unclip(void *handle)
{
frontend *fe = (frontend *)handle;
do_unclip(fe);
}
-void gtk_draw_text(void *handle, int x, int y, int fonttype, int fontsize,
- int align, int colour, const char *text)
+static void gtk_draw_text(void *handle, int x, int y, int fonttype,
+ int fontsize, int align, int colour,
+ const char *text)
{
frontend *fe = (frontend *)handle;
int i;
@@ -1209,7 +1210,7 @@
align_and_draw_text(fe, i, align, x, y, text);
}
-void gtk_draw_rect(void *handle, int x, int y, int w, int h, int colour)
+static void gtk_draw_rect(void *handle, int x, int y, int w, int h, int colour)
{
frontend *fe = (frontend *)handle;
fe->dr_api->set_colour(fe, colour);
@@ -1216,7 +1217,8 @@
do_draw_rect(fe, x, y, w, h);
}
-void gtk_draw_line(void *handle, int x1, int y1, int x2, int y2, int colour)
+static void gtk_draw_line(void *handle, int x1, int y1, int x2, int y2,
+ int colour)
{
frontend *fe = (frontend *)handle;
fe->dr_api->set_colour(fe, colour);
@@ -1223,8 +1225,9 @@
do_draw_line(fe, x1, y1, x2, y2);
}
-void gtk_draw_thick_line(void *handle, float thickness,
- float x1, float y1, float x2, float y2, int colour)
+static void gtk_draw_thick_line(void *handle, float thickness,
+ float x1, float y1, float x2, float y2,
+ int colour)
{
frontend *fe = (frontend *)handle;
fe->dr_api->set_colour(fe, colour);
@@ -1231,21 +1234,21 @@
do_draw_thick_line(fe, thickness, x1, y1, x2, y2);
}
-void gtk_draw_poly(void *handle, const int *coords, int npoints,
- int fillcolour, int outlinecolour)
+static void gtk_draw_poly(void *handle, const int *coords, int npoints,
+ int fillcolour, int outlinecolour)
{
frontend *fe = (frontend *)handle;
do_draw_poly(fe, coords, npoints, fillcolour, outlinecolour);
}
-void gtk_draw_circle(void *handle, int cx, int cy, int radius,
- int fillcolour, int outlinecolour)
+static void gtk_draw_circle(void *handle, int cx, int cy, int radius,
+ int fillcolour, int outlinecolour)
{
frontend *fe = (frontend *)handle;
do_draw_circle(fe, cx, cy, radius, fillcolour, outlinecolour);
}
-blitter *gtk_blitter_new(void *handle, int w, int h)
+static blitter *gtk_blitter_new(void *handle, int w, int h)
{
blitter *bl = snew(blitter);
setup_blitter(bl, w, h);
@@ -1254,13 +1257,13 @@
return bl;
}
-void gtk_blitter_free(void *handle, blitter *bl)
+static void gtk_blitter_free(void *handle, blitter *bl)
{
teardown_blitter(bl);
sfree(bl);
}
-void gtk_blitter_save(void *handle, blitter *bl, int x, int y)
+static void gtk_blitter_save(void *handle, blitter *bl, int x, int y)
{
frontend *fe = (frontend *)handle;
do_blitter_save(fe, bl, x, y);
@@ -1268,7 +1271,7 @@
bl->y = y;
}
-void gtk_blitter_load(void *handle, blitter *bl, int x, int y)
+static void gtk_blitter_load(void *handle, blitter *bl, int x, int y)
{
frontend *fe = (frontend *)handle;
if (x == BLITTER_FROMSAVED && y == BLITTER_FROMSAVED) {
@@ -1278,7 +1281,7 @@
do_blitter_load(fe, bl, x, y);
}
-void gtk_draw_update(void *handle, int x, int y, int w, int h)
+static void gtk_draw_update(void *handle, int x, int y, int w, int h)
{
frontend *fe = (frontend *)handle;
if (fe->bbox_l > x ) fe->bbox_l = x ;
@@ -1287,7 +1290,7 @@
if (fe->bbox_d < y+h) fe->bbox_d = y+h;
}
-void gtk_end_draw(void *handle)
+static void gtk_end_draw(void *handle)
{
frontend *fe = (frontend *)handle;
@@ -1311,7 +1314,8 @@
}
#ifdef USE_PANGO
-char *gtk_text_fallback(void *handle, const char *const *strings, int nstrings)
+static char *gtk_text_fallback(void *handle, const char *const *strings,
+ int nstrings)
{
/*
* We assume Pango can cope with any UTF-8 likely to be emitted
@@ -1322,18 +1326,18 @@
#endif
#ifdef USE_PRINTING
-void gtk_begin_doc(void *handle, int pages)
+static void gtk_begin_doc(void *handle, int pages)
{
frontend *fe = (frontend *)handle;
gtk_print_operation_set_n_pages(fe->printop, pages);
}
-void gtk_begin_page(void *handle, int number)
+static void gtk_begin_page(void *handle, int number)
{
}
-void gtk_begin_puzzle(void *handle, float xm, float xc,
- float ym, float yc, int pw, int ph, float wmm)
+static void gtk_begin_puzzle(void *handle, float xm, float xc,
+ float ym, float yc, int pw, int ph, float wmm)
{
frontend *fe = (frontend *)handle;
double ppw, pph, pox, poy, dpmmx, dpmmy;
@@ -1371,27 +1375,27 @@
fe->hatchspace = 1.0 * pw / wmm;
}
-void gtk_end_puzzle(void *handle)
+static void gtk_end_puzzle(void *handle)
{
frontend *fe = (frontend *)handle;
cairo_restore(fe->cr);
}
-void gtk_end_page(void *handle, int number)
+static void gtk_end_page(void *handle, int number)
{
}
-void gtk_end_doc(void *handle)
+static void gtk_end_doc(void *handle)
{
}
-void gtk_line_width(void *handle, float width)
+static void gtk_line_width(void *handle, float width)
{
frontend *fe = (frontend *)handle;
cairo_set_line_width(fe->cr, width);
}
-void gtk_line_dotted(void *handle, bool dotted)
+static void gtk_line_dotted(void *handle, bool dotted)
{
frontend *fe = (frontend *)handle;
@@ -1404,7 +1408,7 @@
}
#endif /* USE_PRINTING */
-const struct internal_drawing_api internal_drawing = {
+static const struct internal_drawing_api internal_drawing = {
draw_set_colour,
#ifdef USE_CAIRO
do_draw_fill,
@@ -1413,7 +1417,7 @@
};
#ifdef USE_CAIRO
-const struct internal_drawing_api internal_printing = {
+static const struct internal_drawing_api internal_printing = {
print_set_colour,
do_print_fill,
do_print_fill_preserve,
@@ -1420,7 +1424,7 @@
};
#endif
-const struct drawing_api gtk_drawing = {
+static const struct drawing_api gtk_drawing = {
gtk_draw_text,
gtk_draw_rect,
gtk_draw_line,
@@ -1798,8 +1802,8 @@
}
#if GTK_CHECK_VERSION(3,0,0)
-bool message_box(GtkWidget *parent, const char *title, const char *msg,
- bool centre, int type)
+static bool message_box(GtkWidget *parent, const char *title, const char *msg,
+ bool centre, int type)
{
GtkWidget *window;
gint ret;
@@ -1893,7 +1897,7 @@
}
#endif /* GTK_CHECK_VERSION(3,0,0) */
-void error_box(GtkWidget *parent, const char *msg)
+static void error_box(GtkWidget *parent, const char *msg)
{
message_box(parent, "Error", msg, false, MB_OK);
}
@@ -2414,7 +2418,7 @@
}
}
-void write_clip(frontend *fe, char *data)
+static void write_clip(frontend *fe, char *data)
{
if (fe->paste_data)
sfree(fe->paste_data);
@@ -2426,8 +2430,8 @@
set_selection(fe, GDK_SELECTION_CLIPBOARD);
}
-void selection_get(GtkWidget *widget, GtkSelectionData *seldata,
- guint info, guint time_stamp, gpointer data)
+static void selection_get(GtkWidget *widget, GtkSelectionData *seldata,
+ guint info, guint time_stamp, gpointer data)
{
frontend *fe = (frontend *)data;
gtk_selection_data_set(seldata, gtk_selection_data_get_target(seldata), 8,
@@ -2434,8 +2438,8 @@
fe->paste_data, fe->paste_data_len);
}
-gint selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
- gpointer data)
+static gint selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
+ gpointer data)
{
frontend *fe = (frontend *)data;
@@ -2533,7 +2537,7 @@
#endif
#ifdef USE_PRINTING
-GObject *create_print_widget(GtkPrintOperation *print, gpointer data)
+static GObject *create_print_widget(GtkPrintOperation *print, gpointer data)
{
GtkLabel *count_label, *width_label, *height_label,
*scale_llabel, *scale_rlabel;
@@ -2674,8 +2678,8 @@
return G_OBJECT(grid);
}
-void apply_print_widget(GtkPrintOperation *print,
- GtkWidget *widget, gpointer data)
+static void apply_print_widget(GtkPrintOperation *print,
+ GtkWidget *widget, gpointer data)
{
frontend *fe = (frontend *)data;
@@ -2698,8 +2702,8 @@
}
}
-void print_begin(GtkPrintOperation *printop,
- GtkPrintContext *context, gpointer data)
+static void print_begin(GtkPrintOperation *printop,
+ GtkPrintContext *context, gpointer data)
{
frontend *fe = (frontend *)data;
midend *nme = NULL; /* non-interactive midend for bulk puzzle generation */
@@ -2750,16 +2754,16 @@
document_begin(fe->doc, fe->print_dr);
}
-void draw_page(GtkPrintOperation *printop,
- GtkPrintContext *context,
- gint page_nr, gpointer data)
+static void draw_page(GtkPrintOperation *printop,
+ GtkPrintContext *context,
+ gint page_nr, gpointer data)
{
frontend *fe = (frontend *)data;
document_print_page(fe->doc, fe->print_dr, page_nr);
}
-void print_end(GtkPrintOperation *printop,
- GtkPrintContext *context, gpointer data)
+static void print_end(GtkPrintOperation *printop,
+ GtkPrintContext *context, gpointer data)
{
frontend *fe = (frontend *)data;
--- a/latin.c
+++ b/latin.c
@@ -1352,7 +1352,7 @@
sfree(sq);
}
-void test_soak(int order, random_state *rs)
+static void test_soak(int order, random_state *rs)
{
digit *sq;
int n = 0;
@@ -1375,7 +1375,7 @@
}
}
-void usage_exit(const char *msg)
+static void usage_exit(const char *msg)
{
if (msg)
fprintf(stderr, "%s: %s\n", quis, msg);
--- a/magnets.c
+++ b/magnets.c
@@ -2492,11 +2492,11 @@
const char *quis = NULL;
bool csv = false;
-void usage(FILE *out) {
+static void usage(FILE *out) {
fprintf(out, "usage: %s [-v] [--print] <params>|<game id>\n", quis);
}
-void doprint(game_state *state)
+static void doprint(game_state *state)
{
char *fmt = game_text_format(state);
printf("%s", fmt);
--- a/matching.c
+++ b/matching.c
@@ -368,13 +368,13 @@
#include "tree234.h"
-int nl, nr, count;
-int **adjlists, *adjsizes;
-int *adjdata, *outl, *outr, *witness;
-void *scratch;
-random_state *rs;
+static int nl, nr, count;
+static int **adjlists, *adjsizes;
+static int *adjdata, *outl, *outr, *witness;
+static void *scratch;
+static random_state *rs;
-void allocate(int nl_, int nr_, int maxedges)
+static void allocate(int nl_, int nr_, int maxedges)
{
nl = nl_;
nr = nr_;
@@ -387,7 +387,7 @@
scratch = smalloc(matching_scratch_size(nl, nr));
}
-void deallocate(void)
+static void deallocate(void)
{
sfree(adjlists);
sfree(adjsizes);
@@ -398,7 +398,7 @@
sfree(scratch);
}
-void find_and_check_matching(void)
+static void find_and_check_matching(void)
{
int i, j, k;
@@ -454,7 +454,7 @@
int index;
};
-int compare_nodes(void *av, void *bv)
+static int compare_nodes(void *av, void *bv)
{
const struct nodename *a = (const struct nodename *)av;
const struct nodename *b = (const struct nodename *)bv;
@@ -461,7 +461,7 @@
return strcmp(a->name, b->name);
}
-int node_index(tree234 *n2i, tree234 *i2n, const char *name)
+static int node_index(tree234 *n2i, tree234 *i2n, const char *name)
{
struct nodename *nn, *nn_prev;
char *namedup = dupstr(name);
@@ -485,7 +485,7 @@
int L, R;
};
-int compare_edges(void *av, void *bv)
+static int compare_edges(void *av, void *bv)
{
const struct edge *a = (const struct edge *)av;
const struct edge *b = (const struct edge *)bv;
@@ -496,7 +496,7 @@
return 0;
}
-void matching_from_user_input(FILE *fp, const char *filename)
+static void matching_from_user_input(FILE *fp, const char *filename)
{
tree234 *Ln2i, *Li2n, *Rn2i, *Ri2n, *edges;
char *line = NULL;
@@ -576,7 +576,7 @@
deallocate();
}
-void test_subsets(void)
+static void test_subsets(void)
{
int b = 8;
int n = 1 << b;
--- a/penrose.c
+++ b/penrose.c
@@ -512,7 +512,7 @@
int show_recursion = 0;
int ntiles, nfinal;
-int test_cb(penrose_state *state, vector *vs, int n, int depth)
+static int test_cb(penrose_state *state, vector *vs, int n, int depth)
{
int i, xoff = 0, yoff = 0;
double l = penrose_side_length(state->start_size, depth);
@@ -542,7 +542,7 @@
return 0;
}
-void usage_exit(void)
+static void usage_exit(void)
{
fprintf(stderr, "Usage: penrose-test [--recursion] P2|P3 SIZE DEPTH\n");
exit(1);
--- a/signpost.c
+++ b/signpost.c
@@ -2321,7 +2321,7 @@
const char *quis = NULL;
int verbose = 0;
-void usage(FILE *out) {
+static void usage(FILE *out) {
fprintf(out, "usage: %s [--stdin] [--soak] [--seed SEED] <params>|<game id>\n", quis);
}
--- a/sort.c
+++ b/sort.c
@@ -93,7 +93,7 @@
#include <stdlib.h>
#include <time.h>
-int testcmp(const void *av, const void *bv, void *ctx)
+static int testcmp(const void *av, const void *bv, void *ctx)
{
int a = *(const int *)av, b = *(const int *)bv;
const int *keys = (const int *)ctx;
@@ -100,7 +100,7 @@
return keys[a] < keys[b] ? -1 : keys[a] > keys[b] ? +1 : 0;
}
-int resetcmp(const void *av, const void *bv)
+static int resetcmp(const void *av, const void *bv)
{
int a = *(const int *)av, b = *(const int *)bv;
return a < b ? -1 : a > b ? +1 : 0;
--- a/tree234.c
+++ b/tree234.c
@@ -1491,7 +1491,7 @@
/*
* Error reporting function.
*/
-void error(const char *fmt, ...) {
+static void error(const char *fmt, ...) {
va_list ap;
printf("ERROR: ");
va_start(ap, fmt);
@@ -1517,7 +1517,7 @@
char **levels;
} dispctx;
-int dispnode(node234 *n, int level, dispctx *ctx) {
+static int dispnode(node234 *n, int level, dispctx *ctx) {
if (level == 0) {
int xpos = strlen(ctx->levels[0]);
int len;
@@ -1614,7 +1614,7 @@
}
}
-void disptree(tree234 *t) {
+static void disptree(tree234 *t) {
dispctx ctx;
char *leveldata;
int width = count234(t);
@@ -1646,8 +1646,8 @@
int elemcount;
} chkctx;
-int chknode(chkctx *ctx, int level, node234 *node,
- void *lowbound, void *highbound) {
+static int chknode(chkctx *ctx, int level, node234 *node,
+ void *lowbound, void *highbound) {
int nkids, nelems;
int i;
int count;
@@ -1756,7 +1756,7 @@
return count;
}
-void verifytree(tree234 *tree, void **array, int arraylen) {
+static void verifytree(tree234 *tree, void **array, int arraylen) {
chkctx ctx;
int i;
void *p;
@@ -1795,9 +1795,9 @@
ctx.elemcount, i);
}
}
-void verify(void) { verifytree(tree, array, arraylen); }
+static void verify(void) { verifytree(tree, array, arraylen); }
-void internal_addtest(void *elem, int index, void *realret) {
+static void internal_addtest(void *elem, int index, void *realret) {
int i, j;
void *retval;
@@ -1822,7 +1822,7 @@
verify();
}
-void addtest(void *elem) {
+static void addtest(void *elem) {
int i;
void *realret;
@@ -1840,7 +1840,7 @@
internal_addtest(elem, i, realret);
}
-void addpostest(void *elem, int i) {
+static void addpostest(void *elem, int i) {
void *realret;
realret = addpos234(tree, elem, i);
@@ -1848,7 +1848,7 @@
internal_addtest(elem, i, realret);
}
-void delpostest(int i) {
+static void delpostest(int i) {
int index = i;
void *elem = array[i], *ret;
@@ -1871,7 +1871,7 @@
verify();
}
-void deltest(void *elem) {
+static void deltest(void *elem) {
int i;
i = 0;
@@ -1890,19 +1890,19 @@
* given in ANSI C99 draft N869. It assumes `unsigned' is 32 bits;
* change it if not.
*/
-int randomnumber(unsigned *seed) {
+static int randomnumber(unsigned *seed) {
*seed *= 1103515245;
*seed += 12345;
return ((*seed) / 65536) % 32768;
}
-int mycmp(void *av, void *bv) {
+static int mycmp(void *av, void *bv) {
char const *a = (char const *)av;
char const *b = (char const *)bv;
return strcmp(a, b);
}
-const char *const strings_init[] = {
+static const char *const strings_init[] = {
"0", "2", "3", "I", "K", "d", "H", "J", "Q", "N", "n", "q", "j", "i",
"7", "G", "F", "D", "b", "x", "g", "B", "e", "v", "V", "T", "f", "E",
"S", "8", "A", "k", "X", "p", "C", "R", "a", "o", "r", "O", "Z", "u",
@@ -1924,9 +1924,9 @@
};
#define NSTR lenof(strings_init)
-char *strings[NSTR];
+static char *strings[NSTR];
-void findtest(void) {
+static void findtest(void) {
static const int rels[] = {
REL234_EQ, REL234_GE, REL234_LE, REL234_LT, REL234_GT
};
@@ -2015,7 +2015,7 @@
}
}
-void splittest(tree234 *tree, void **array, int arraylen) {
+static void splittest(tree234 *tree, void **array, int arraylen) {
int i;
tree234 *tree3, *tree4;
for (i = 0; i <= arraylen; i++) {
--- a/unfinished/numgame.c
+++ b/unfinished/numgame.c
@@ -987,11 +987,11 @@
/*
* Print a text formula for producing a given output.
*/
-void print_recurse(struct sets *s, struct set *ss, int pathindex, int index,
- int priority, int assoc, int child);
-void print_recurse_inner(struct sets *s, struct set *ss,
- struct ancestor *a, int pathindex, int index,
- int priority, int assoc, int child)
+static void print_recurse(struct sets *s, struct set *ss, int pathindex,
+ int index, int priority, int assoc, int child);
+static void print_recurse_inner(struct sets *s, struct set *ss,
+ struct ancestor *a, int pathindex, int index,
+ int priority, int assoc, int child)
{
if (a->prev && index != a->pr) {
int pi;
@@ -1066,8 +1066,8 @@
printf("/%d", ss->numbers[2*index+1]);
}
}
-void print_recurse(struct sets *s, struct set *ss, int pathindex, int index,
- int priority, int assoc, int child)
+static void print_recurse(struct sets *s, struct set *ss, int pathindex,
+ int index, int priority, int assoc, int child)
{
if (!ss->a.prev || pathindex < ss->a.prev->npaths) {
print_recurse_inner(s, ss, &ss->a, pathindex,
@@ -1085,7 +1085,7 @@
}
}
}
-void print(int pathindex, struct sets *s, struct output *o)
+static void print(int pathindex, struct sets *s, struct output *o)
{
print_recurse(s, o->set, pathindex, o->index, 0, 0, 0);
}
--- a/unfinished/separate.c
+++ b/unfinished/separate.c
@@ -215,7 +215,7 @@
int *tmp;
};
-struct solver_scratch *solver_scratch_new(int w, int h, int k)
+static struct solver_scratch *solver_scratch_new(int w, int h, int k)
{
int wh = w*h;
struct solver_scratch *sc = snew(struct solver_scratch);
@@ -233,7 +233,7 @@
return sc;
}
-void solver_scratch_free(struct solver_scratch *sc)
+static void solver_scratch_free(struct solver_scratch *sc)
{
sfree(sc->dsf);
sfree(sc->size);
@@ -243,7 +243,7 @@
sfree(sc);
}
-void solver_connect(struct solver_scratch *sc, int yx1, int yx2)
+static void solver_connect(struct solver_scratch *sc, int yx1, int yx2)
{
int w = sc->w, h = sc->h, k = sc->k;
int wh = w*h;
@@ -297,7 +297,7 @@
sc->disconnect[i*wh+yx2]);
}
-void solver_disconnect(struct solver_scratch *sc, int yx1, int yx2)
+static void solver_disconnect(struct solver_scratch *sc, int yx1, int yx2)
{
int w = sc->w, h = sc->h;
int wh = w*h;
@@ -316,7 +316,7 @@
sc->disconnect[yx2*wh+yx1] = true;
}
-void solver_init(struct solver_scratch *sc)
+static void solver_init(struct solver_scratch *sc)
{
int w = sc->w, h = sc->h;
int wh = w*h;
@@ -332,8 +332,8 @@
memset(sc->disconnect, 0, wh*wh * sizeof(bool));
}
-int solver_attempt(struct solver_scratch *sc, const unsigned char *grid,
- bool *gen_lock)
+static int solver_attempt(struct solver_scratch *sc, const unsigned char *grid,
+ bool *gen_lock)
{
int w = sc->w, h = sc->h, k = sc->k;
int wh = w*h;
@@ -492,7 +492,7 @@
return 0;
}
-unsigned char *generate(int w, int h, int k, random_state *rs)
+static unsigned char *generate(int w, int h, int k, random_state *rs)
{
int wh = w*h;
int n = wh/k;
--- a/unfinished/sokoban.c
+++ b/unfinished/sokoban.c
@@ -957,7 +957,7 @@
* subfunction. move_type() returns -1 for an illegal move, 0 for a
* movement, and 1 for a push.
*/
-int move_type(const game_state *state, int dx, int dy)
+static int move_type(const game_state *state, int dx, int dy)
{
int w = state->p.w, h = state->p.h;
int px = state->px, py = state->py;