URI: 
       tFix lots of warnings - ltk - Socket-based GUI for X11 (WIP)
  HTML git clone git://lumidify.org/ltk.git (fast, but not encrypted)
  HTML git clone https://lumidify.org/git/ltk.git (encrypted, but very slow)
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit df7e4a4517d0078deebaac2348838d8e4658d11f
   DIR parent 234dfa1c2918437f40a27a2fe70d6faf72289eaf
  HTML Author: lumidify <nobody@lumidify.org>
       Date:   Sat, 20 Feb 2021 22:52:57 +0100
       
       Fix lots of warnings
       
       ...but at what cost?
       Seriously, I need to rethink some things to make this less ugly.
       
       Diffstat:
         M box.c                               |      52 ++++++++++++++++----------------
         M button.c                            |      26 ++++++++++++++------------
         M color.c                             |       2 ++
         M draw.c                              |      37 ++++++++++++++++++-------------
         M grid.c                              |      46 ++++++++++++++++---------------
         M grid.h                              |      16 ++++++++--------
         M label.c                             |       7 ++++---
         M ltkc.c                              |       2 +-
         M ltkd.c                              |      10 ++++++----
         M memory.c                            |       2 +-
         M scrollbar.c                         |      15 +++++++++------
         M scrollbar.h                         |       4 ++--
         M strtonum.c                          |       4 ++--
         M text_pango.c                        |       3 +++
         M text_stb.c                          |      29 ++++++++++++++++-------------
         M util.c                              |       2 +-
         M util.h                              |       4 ++--
       
       17 files changed, 142 insertions(+), 119 deletions(-)
       ---
   DIR diff --git a/box.c b/box.c
       t@@ -25,6 +25,7 @@
        #include <stdlib.h>
        #include <stdarg.h>
        #include <stdint.h>
       +#include <string.h>
        
        #include <X11/Xlib.h>
        #include <X11/Xutil.h>
       t@@ -45,7 +46,7 @@ static void ltk_box_child_size_change(ltk_widget *self, ltk_widget *widget);
        static int ltk_box_add(ltk_window *window, ltk_widget *widget, ltk_box *box, unsigned short sticky, char **errstr);
        static int ltk_box_remove(ltk_window *window, ltk_widget *widget, ltk_widget *self, char **errstr);
        /* static int ltk_box_clear(ltk_window *window, ltk_box *box, int shallow, char **errstr); */
       -static void ltk_box_scroll(ltk_box *box);
       +static void ltk_box_scroll(ltk_widget *self);
        static int ltk_box_mouse_event(ltk_box *box, XEvent event, void (*handler)(ltk_widget *, XEvent));
        static int ltk_box_mouse_press(ltk_widget *self, XEvent event);
        static int ltk_box_mouse_release(ltk_widget *self, XEvent event);
       t@@ -76,7 +77,7 @@ static int ltk_box_cmd_create(
        
        static void
        ltk_box_draw(ltk_widget *self, ltk_rect clip) {
       -        ltk_box *box = self;
       +        ltk_box *box = (ltk_box *)self;
                ltk_widget *ptr;
                ltk_rect real_clip = ltk_rect_intersect(box->widget.rect, clip);
                for (size_t i = 0; i < box->num_widgets; i++) {
       t@@ -85,7 +86,7 @@ ltk_box_draw(ltk_widget *self, ltk_rect clip) {
                           obviously outside of clipping rect */
                        ptr->draw(ptr, real_clip);
                }
       -        box->sc->widget.draw(box->sc, real_clip);
       +        box->sc->widget.draw((ltk_widget *)box->sc, real_clip);
        }
        
        static ltk_box *
       t@@ -112,7 +113,7 @@ ltk_box_create(ltk_window *window, const char *id, ltk_orientation orient) {
        
        static void
        ltk_box_destroy(ltk_widget *self, int shallow) {
       -        ltk_box *box = self;
       +        ltk_box *box = (ltk_box *)self;
                ltk_widget *ptr;
                if (!shallow) {
                        for (size_t i = 0; i < box->num_widgets; i++) {
       t@@ -123,7 +124,7 @@ ltk_box_destroy(ltk_widget *self, int shallow) {
                ltk_free(box->widgets);
                ltk_remove_widget(box->widget.id);
                ltk_free(box->widget.id);
       -        box->sc->widget.destroy(box->sc, 0);
       +        box->sc->widget.destroy((ltk_widget *)box->sc, 0);
                ltk_free(box);
        }
        
       t@@ -133,7 +134,7 @@ ltk_box_destroy(ltk_widget *self, int shallow) {
           (in the scrolled direction) when resized. */
        static void
        ltk_recalculate_box(ltk_widget *self) {
       -        ltk_box *box = self;
       +        ltk_box *box = (ltk_box *)self;
                ltk_widget *ptr;
                ltk_rect *sc_rect = &box->sc->widget.rect;
                int offset = box->orient == LTK_HORIZONTAL ? box->widget.rect.x : box->widget.rect.y;
       t@@ -189,7 +190,7 @@ ltk_recalculate_box(ltk_widget *self) {
        
        static void
        ltk_box_child_size_change(ltk_widget *self, ltk_widget *widget) {
       -        ltk_box *box = self;
       +        ltk_box *box = (ltk_box *)self;
                short size_changed = 0;
                /* This is always reset here - if it needs to be changed,
                   the resize function called by the last child_size_change
       t@@ -214,9 +215,9 @@ ltk_box_child_size_change(ltk_widget *self, ltk_widget *widget) {
                }
        
                if (size_changed && box->widget.parent && box->widget.parent->child_size_change)
       -                box->widget.parent->child_size_change(box->widget.parent, box);
       +                box->widget.parent->child_size_change(box->widget.parent, (ltk_widget *)box);
                else
       -                ltk_recalculate_box(box);
       +                ltk_recalculate_box((ltk_widget *)box);
        }
        
        static int
       t@@ -245,9 +246,9 @@ ltk_box_add(ltk_window *window, ltk_widget *widget, ltk_box *box, unsigned short
                        if (widget->ideal_w + sc_w > box->widget.ideal_w)
                                box->widget.ideal_w = widget->ideal_w + sc_w;
                }
       -        widget->parent = box;
       +        widget->parent = (ltk_widget *)box;
                widget->sticky = sticky;
       -        ltk_box_child_size_change(box, widget);
       +        ltk_box_child_size_change((ltk_widget *)box, widget);
                ltk_window_invalidate_rect(window, box->widget.rect);
        
                return 0;
       t@@ -255,10 +256,10 @@ ltk_box_add(ltk_window *window, ltk_widget *widget, ltk_box *box, unsigned short
        
        static int
        ltk_box_remove(ltk_window *window, ltk_widget *widget, ltk_widget *self, char **errstr) {
       -        ltk_box *box = self;
       +        ltk_box *box = (ltk_box *)self;
                int sc_w = box->sc->widget.rect.w;
                int sc_h = box->sc->widget.rect.h;
       -        if (widget->parent != box) {
       +        if (widget->parent != (ltk_widget *)box) {
                        *errstr = "Widget isn't contained in given box.\n";
                        return 1;
                }
       t@@ -298,19 +299,18 @@ ltk_box_remove(ltk_window *window, ltk_widget *widget, ltk_widget *self, char **
        }
        
        static void
       -ltk_box_scroll(ltk_box *box) {
       -        ltk_recalculate_box(box);
       +ltk_box_scroll(ltk_widget *self) {
       +        ltk_box *box = (ltk_box *)self;
       +        ltk_recalculate_box(self);
                ltk_window_invalidate_rect(box->widget.window, box->widget.rect);
        }
        
        static int
        ltk_box_mouse_event(ltk_box *box, XEvent event, void (*handler)(ltk_widget *, XEvent)) {
       -        int pos, start, size;
                ltk_widget *widget;
       -        int old_sc_pos = box->sc->cur_pos;
        
                if (ltk_collide_rect(box->sc->widget.rect, event.xbutton.x, event.xbutton.y)) {
       -                handler(box->sc, event);
       +                handler((ltk_widget *)box->sc, event);
                        return 0;
                }
        
       t@@ -327,19 +327,19 @@ ltk_box_mouse_event(ltk_box *box, XEvent event, void (*handler)(ltk_widget *, XE
        
        static int
        ltk_box_mouse_press(ltk_widget *self, XEvent event) {
       -        ltk_box *box = self;
       +        ltk_box *box = (ltk_box *)self;
                return ltk_box_mouse_event(box, event, &ltk_widget_mouse_press_event);
        }
        
        static int
        ltk_box_mouse_release(ltk_widget *self, XEvent event) {
       -        ltk_box *box = self;
       +        ltk_box *box = (ltk_box *)self;
                return ltk_box_mouse_event(box, event, &ltk_widget_mouse_release_event);
        }
        
        static int
        ltk_box_motion_notify(ltk_widget *self, XEvent event) {
       -        ltk_box *box = self;
       +        ltk_box *box = (ltk_box *)self;
                return ltk_box_mouse_event(box, event, &ltk_widget_motion_notify_event);
        }
        
       t@@ -359,7 +359,7 @@ ltk_box_cmd_add(
                        *errstr = "Invalid number of arguments.\n";
                        return 1;
                }
       -        box = ltk_get_widget(tokens[1], LTK_BOX, errstr);
       +        box = (ltk_box *)ltk_get_widget(tokens[1], LTK_BOX, errstr);
                widget = ltk_get_widget(tokens[3], LTK_WIDGET, errstr);
                if (!box || !widget) {
                        *errstr = "Invalid widget ID.\n";
       t@@ -400,14 +400,14 @@ ltk_box_cmd_remove(
                        *errstr = "Invalid number of arguments.\n";
                        return 1;
                }
       -        box = ltk_get_widget(tokens[1], LTK_BOX, errstr);
       +        box = (ltk_box *)ltk_get_widget(tokens[1], LTK_BOX, errstr);
                widget = ltk_get_widget(tokens[3], LTK_WIDGET, errstr);
                if (!box || !widget) {
                        *errstr = "Invalid widget ID.\n";
                        return 1;
                }
        
       -        return ltk_box_remove(window, widget, box, errstr);
       +        return ltk_box_remove(window, widget, (ltk_widget *)box, errstr);
        }
        
        /* box <box id> create <orientation> */
       t@@ -436,8 +436,8 @@ ltk_box_cmd_create(
                        *errstr = "Invalid orientation.\n";
                        return 1;
                }
       -        box = ltk_box_create(window, tokens[1], orient);
       -        ltk_set_widget(box, tokens[1]);
       +        box = (ltk_box *)ltk_box_create(window, tokens[1], orient);
       +        ltk_set_widget((ltk_widget *)box, tokens[1]);
        
                return 0;
        }
   DIR diff --git a/button.c b/button.c
       t@@ -127,7 +127,7 @@ ltk_button_ini_handler(ltk_window *window, const char *prop, const char *value) 
        
        static void
        ltk_button_draw(ltk_widget *self, ltk_rect clip) {
       -        ltk_button *button = self;
       +        ltk_button *button = (ltk_button *)self;
                ltk_window *window = button->widget.window;
                ltk_rect rect = button->widget.rect;
                ltk_rect clip_final = ltk_rect_intersect(clip, rect);
       t@@ -188,16 +188,17 @@ ltk_button_redraw_pixmap(ltk_button *button) {
        /* FIXME: Make this amortised constant; make it generic for all widgets */
        static void
        ltk_button_resize(ltk_widget *self) {
       -        ltk_button *button = self;
       +        ltk_button *button = (ltk_button *)self;
                Window win;
       -        int x, y, w, h, bw, d;
       -        int new_w, new_h;
       +        int x, y;
       +        unsigned int w, h, bw, d;
       +        unsigned int new_w, new_h;
                ltk_window *window = button->widget.window;
                ltk_rect rect = button->widget.rect;
                XGetGeometry(window->dpy, button->pixmap, &win, &x, &y, &w, &h, &bw, &d);
        
       -        new_w = w < rect.w ? rect.w : w;
       -        new_h = h < rect.h ? rect.h : h;
       +        new_w = (int)w < rect.w ? rect.w : (int)w;
       +        new_h = (int)h < rect.h ? rect.h : (int)h;
                if (new_w < w && new_h < h)
                        return;
                XFreePixmap(window->dpy, button->pixmap);
       t@@ -208,8 +209,7 @@ ltk_button_resize(ltk_widget *self) {
        
        static void
        ltk_button_change_state(ltk_widget *self) {
       -        ltk_button *button = self;
       -        ltk_window *window = button->widget.window;
       +        ltk_button *button = (ltk_button *)self;
                LtkColor *fill;
                switch (button->widget.state) {
                case LTK_NORMAL:
       t@@ -233,7 +233,8 @@ ltk_button_change_state(ltk_widget *self) {
        
        static int
        ltk_button_mouse_release(ltk_widget *self, XEvent event) {
       -        ltk_button *button = self;
       +        (void)event;
       +        ltk_button *button = (ltk_button *)self;
                ltk_queue_event(button->widget.window, LTK_EVENT_BUTTON, button->widget.id, "button_click");
                return 1;
        }
       t@@ -257,14 +258,15 @@ ltk_button_create(ltk_window *window, const char *id, const char *text) {
                button->pixmap = XCreatePixmap(window->dpy, window->xwindow,
                    button->widget.ideal_w, button->widget.ideal_h, window->depth);
                /* render text */
       -        ltk_button_change_state(button);
       +        ltk_button_change_state((ltk_widget *)button);
        
                return button;
        }
        
        static void
        ltk_button_destroy(ltk_widget *self, int shallow) {
       -        ltk_button *button = self;
       +        (void)shallow;
       +        ltk_button *button = (ltk_button *)self;
                if (!button) {
                        ltk_warn("Tried to destroy NULL button.\n");
                        return;
       t@@ -292,7 +294,7 @@ ltk_button_cmd_create(
                        return 1;
                }
                button = ltk_button_create(window, tokens[1], tokens[3]);
       -        ltk_set_widget(button, tokens[1]);
       +        ltk_set_widget((ltk_widget *)button, tokens[1]);
        
                return 0;
        }
   DIR diff --git a/color.c b/color.c
       t@@ -15,5 +15,7 @@ ltk_color_create(Display *dpy, int screen, Colormap cm, const char *hex, LtkColo
                /* FIXME: replace with XftColorAllocValue; error checking */
                #if USE_PANGO == 1
                XftColorAllocName(dpy, DefaultVisual(dpy, screen), cm, hex, &col->xftcolor);
       +        #else
       +        (void)screen;
                #endif
        }
   DIR diff --git a/draw.c b/draw.c
       t@@ -36,7 +36,7 @@
        #include "util.h"
        #include "draw.h"
        
       -static void ltk_draw_draw(ltk_widget *self);
       +static void ltk_draw_draw(ltk_widget *self, ltk_rect clip_rect);
        static ltk_draw *ltk_draw_create(ltk_window *window,
            const char *id, int w, int h, const char *color);
        static void ltk_draw_resize(ltk_widget *self);
       t@@ -72,8 +72,9 @@ static int ltk_draw_cmd_create(
            char **errstr);
        
        static void
       -ltk_draw_draw(ltk_widget *self) {
       -        ltk_draw *draw = self;
       +ltk_draw_draw(ltk_widget *self, ltk_rect clip_rect) {
       +        (void)clip_rect; /* FIXME: actually use this */
       +        ltk_draw *draw = (ltk_draw *)self;
                ltk_window *window = draw->widget.window;
                ltk_rect rect = draw->widget.rect;
                XCopyArea(window->dpy, draw->pix, window->xwindow, window->gc, 0, 0, rect.w, rect.h, rect.x, rect.y);
       t@@ -103,16 +104,18 @@ ltk_draw_create(ltk_window *window, const char *id, int w, int h, const char *co
        
        static void
        ltk_draw_resize(ltk_widget *self) {
       -        ltk_draw *draw = self;
       +        ltk_draw *draw = (ltk_draw *)self;
                Window win;
       -        int x, y, w, h, bw, d;
       -        int new_w, new_h;
       +        int x, y;
       +        unsigned int w, h, bw, d;
       +        unsigned int new_w, new_h;
                ltk_window *window = draw->widget.window;
                ltk_rect rect = draw->widget.rect;
                XGetGeometry(window->dpy, draw->pix, &win, &x, &y, &w, &h, &bw, &d);
        
       -        new_w = w < rect.w ? rect.w : w;
       -        new_h = h < rect.h ? rect.h : h;
       +        /* FIXME: get rid of casts */
       +        new_w = (int)w < rect.w ? rect.w : (int)w;
       +        new_h = (int)h < rect.h ? rect.h : (int)h;
                if (new_w < w && new_h < h)
                        return;
                Pixmap tmp = XCreatePixmap(window->dpy, window->xwindow,
       t@@ -127,7 +130,8 @@ ltk_draw_resize(ltk_widget *self) {
        
        static void
        ltk_draw_destroy(ltk_widget *self, int shallow) {
       -        ltk_draw *draw = self;
       +        (void)shallow;
       +        ltk_draw *draw = (ltk_draw *)self;
                if (!draw) {
                        ltk_warn("Tried to destroy NULL draw.\n");
                        return;
       t@@ -141,11 +145,12 @@ ltk_draw_destroy(ltk_widget *self, int shallow) {
        static void
        ltk_draw_clear(ltk_window *window, ltk_draw *draw) {
                Window win;
       -        int x, y, w, h, bw, d;
       +        int x, y;
       +        unsigned int w, h, bw, d;
                XGetGeometry(window->dpy, draw->pix, &win, &x, &y, &w, &h, &bw, &d);
                XSetForeground(window->dpy, window->gc, draw->bg.pixel);
                XFillRectangle(window->dpy, window->xwindow, window->gc, 0, 0, w, h);
       -        ltk_draw_draw(draw);
       +        ltk_draw_draw((ltk_widget *)draw, draw->widget.rect);
        }
        
        /* FIXME: Error return */
       t@@ -204,7 +209,7 @@ ltk_draw_cmd_clear(
                        *errstr = "Invalid number of arguments.\n";
                        return 1;
                }
       -        draw = ltk_get_widget(tokens[1], LTK_DRAW, errstr);
       +        draw = (ltk_draw *)ltk_get_widget(tokens[1], LTK_DRAW, errstr);
                if (!draw) return 1;
                ltk_draw_clear(window, draw);
        
       t@@ -222,7 +227,7 @@ ltk_draw_cmd_set_color(
                        *errstr = "Invalid number of arguments.\n";
                        return 1;
                }
       -        draw = ltk_get_widget(tokens[1], LTK_DRAW, errstr);
       +        draw = (ltk_draw *)ltk_get_widget(tokens[1], LTK_DRAW, errstr);
                if (!draw) return 1;
                ltk_draw_set_color(window, draw, tokens[3]);
        
       t@@ -242,7 +247,7 @@ ltk_draw_cmd_line(
                        *errstr = "Invalid number of arguments.\n";
                        return 1;
                }
       -        draw = ltk_get_widget(tokens[1], LTK_DRAW, errstr);
       +        draw = (ltk_draw *)ltk_get_widget(tokens[1], LTK_DRAW, errstr);
                if (!draw) return 1;
                x1 = strtonum(tokens[3], 0, 100000, &errstr_num);
                if (errstr_num) {
       t@@ -282,7 +287,7 @@ ltk_draw_cmd_rect(
                        *errstr = "Invalid number of arguments.\n";
                        return 1;
                }
       -        draw = ltk_get_widget(tokens[1], LTK_DRAW, errstr);
       +        draw = (ltk_draw *)ltk_get_widget(tokens[1], LTK_DRAW, errstr);
                if (!draw) return 1;
                x = strtonum(tokens[3], 0, 100000, &errstr_num);
                if (errstr_num) {
       t@@ -343,7 +348,7 @@ ltk_draw_cmd_create(
                        return 1;
                }
                draw = ltk_draw_create(window, tokens[1], w, h, tokens[5]);
       -        ltk_set_widget(draw, tokens[1]);
       +        ltk_set_widget((ltk_widget *)draw, tokens[1]);
        
                return 0;
        }
   DIR diff --git a/grid.c b/grid.c
       t@@ -89,18 +89,18 @@ static int ltk_grid_cmd_set_column_weight(
        static void
        ltk_grid_set_row_weight(ltk_grid *grid, int row, int weight) {
                grid->row_weights[row] = weight;
       -        ltk_recalculate_grid(grid);
       +        ltk_recalculate_grid((ltk_widget *)grid);
        }
        
        static void
        ltk_grid_set_column_weight(ltk_grid *grid, int column, int weight) {
                grid->column_weights[column] = weight;
       -        ltk_recalculate_grid(grid);
       +        ltk_recalculate_grid((ltk_widget *)grid);
        }
        
        static void
        ltk_grid_draw(ltk_widget *self, ltk_rect clip) {
       -        ltk_grid *grid = self;
       +        ltk_grid *grid = (ltk_grid *)self;
                int i;
                for (i = 0; i < grid->rows * grid->columns; i++) {
                        if (!grid->widget_grid[i])
       t@@ -151,13 +151,13 @@ ltk_grid_create(ltk_window *window, const char *id, int rows, int columns) {
                        grid->widget_grid[i] = NULL;
                }
        
       -        ltk_recalculate_grid(grid);
       +        ltk_recalculate_grid((ltk_widget *)grid);
                return grid;
        }
        
        static void
        ltk_grid_destroy(ltk_widget *self, int shallow) {
       -        ltk_grid *grid = self;
       +        ltk_grid *grid = (ltk_grid *)self;
                ltk_widget *ptr;
                if (!shallow) {
                        for (int i = 0; i < grid->rows * grid->columns; i++) {
       t@@ -188,7 +188,7 @@ ltk_grid_destroy(ltk_widget *self, int shallow) {
        
        static void
        ltk_recalculate_grid(ltk_widget *self) {
       -        ltk_grid *grid = self;
       +        ltk_grid *grid = (ltk_grid *)self;
                unsigned int height_static = 0, width_static = 0;
                unsigned int total_row_weight = 0, total_column_weight = 0;
                float height_unit = 0, width_unit = 0;
       t@@ -275,7 +275,7 @@ ltk_recalculate_grid(ltk_widget *self) {
        /* FIXME: Maybe add debug stuff to check that grid is actually parent of widget */
        static void
        ltk_grid_child_size_change(ltk_widget *self, ltk_widget *widget) {
       -        ltk_grid *grid = self;
       +        ltk_grid *grid = (ltk_grid *)self;
                short size_changed = 0;
                widget->rect.w = widget->ideal_w;
                widget->rect.h = widget->ideal_h;
       t@@ -292,9 +292,9 @@ ltk_grid_child_size_change(ltk_widget *self, ltk_widget *widget) {
                        size_changed = 1;
                }
                if (size_changed && grid->widget.parent && grid->widget.parent->child_size_change)
       -                grid->widget.parent->child_size_change(grid->widget.parent, grid);
       +                grid->widget.parent->child_size_change(grid->widget.parent, (ltk_widget *)grid);
                else
       -                ltk_recalculate_grid(grid);
       +                ltk_recalculate_grid((ltk_widget *)grid);
        }
        
        /* FIXME: Check if widget already exists at position */
       t@@ -315,8 +315,8 @@ ltk_grid_add(ltk_window *window, ltk_widget *widget, ltk_grid *grid,
                                grid->widget_grid[i * grid->columns + j] = widget;
                        }
                }
       -        widget->parent = grid;
       -        ltk_grid_child_size_change(grid, widget);
       +        widget->parent = (ltk_widget *)grid;
       +        ltk_grid_child_size_change((ltk_widget *)grid, widget);
                ltk_window_invalidate_rect(window, grid->widget.rect);
        
                return 0;
       t@@ -324,8 +324,8 @@ ltk_grid_add(ltk_window *window, ltk_widget *widget, ltk_grid *grid,
        
        static int
        ltk_grid_ungrid(ltk_window *window, ltk_widget *widget, ltk_widget *self, char **errstr) {
       -        ltk_grid *grid = self;
       -        if (widget->parent != grid) {
       +        ltk_grid *grid = (ltk_grid *)self;
       +        if (widget->parent != (ltk_widget *)grid) {
                        *errstr = "Widget isn't gridded in given grid.\n";
                        return 1;
                }
       t@@ -364,7 +364,7 @@ ltk_grid_find_nearest_row(ltk_grid *grid, int y) {
        
        static int
        ltk_grid_mouse_press(ltk_widget *self, XEvent event) {
       -        ltk_grid *grid = self;
       +        ltk_grid *grid = (ltk_grid *)self;
                int x = event.xbutton.x;
                int y = event.xbutton.y;
                int row = ltk_grid_find_nearest_row(grid, y);
       t@@ -381,7 +381,7 @@ ltk_grid_mouse_press(ltk_widget *self, XEvent event) {
        
        static int
        ltk_grid_mouse_release(ltk_widget *self, XEvent event) {
       -        ltk_grid *grid = self;
       +        ltk_grid *grid = (ltk_grid *)self;
                int x = event.xbutton.x;
                int y = event.xbutton.y;
                int row = ltk_grid_find_nearest_row(grid, y);
       t@@ -398,7 +398,7 @@ ltk_grid_mouse_release(ltk_widget *self, XEvent event) {
        
        static int
        ltk_grid_motion_notify(ltk_widget *self, XEvent event) {
       -        ltk_grid *grid = self;
       +        ltk_grid *grid = (ltk_grid *)self;
                /* FIXME: Why does it check this? */
                short pressed = (event.xmotion.state & Button1Mask) == Button1Mask;
                if (pressed)
       t@@ -434,7 +434,7 @@ ltk_grid_cmd_add(
                        *errstr = "Invalid number of arguments.\n";
                        return 1;
                }
       -        grid = ltk_get_widget(tokens[1], LTK_GRID, errstr);
       +        grid = (ltk_grid *)ltk_get_widget(tokens[1], LTK_GRID, errstr);
                widget = ltk_get_widget(tokens[3], LTK_WIDGET, errstr);
                if (!grid || !widget) {
                        *errstr = "Invalid widget ID.\n";
       t@@ -494,10 +494,10 @@ ltk_grid_cmd_ungrid(
                        *errstr = "Invalid number of arguments.\n";
                        return 1;
                }
       -        grid = ltk_get_widget(tokens[1], LTK_GRID, errstr);
       +        grid = (ltk_grid *)ltk_get_widget(tokens[1], LTK_GRID, errstr);
                widget = ltk_get_widget(tokens[3], LTK_WIDGET, errstr);
                if (!grid || !widget) return 1;
       -        return ltk_grid_ungrid(window, widget, grid, errstr);
       +        return ltk_grid_ungrid(window, widget, (ltk_widget *)grid, errstr);
        }
        
        /* grid <grid id> create <rows> <columns> */
       t@@ -529,7 +529,7 @@ ltk_grid_cmd_create(
                        return 1;
                }
                grid = ltk_grid_create(window, tokens[1], rows, columns);
       -        ltk_set_widget(grid, tokens[1]);
       +        ltk_set_widget((ltk_widget *)grid, tokens[1]);
        
                return 0;
        }
       t@@ -541,6 +541,7 @@ ltk_grid_cmd_set_row_weight(
            char **tokens,
            size_t num_tokens,
            char **errstr) {
       +        (void)window;
                ltk_grid *grid;
                int row, weight;
                const char *errstr_num;
       t@@ -548,7 +549,7 @@ ltk_grid_cmd_set_row_weight(
                        *errstr = "Invalid number of arguments.\n";
                        return 1;
                }
       -        grid = ltk_get_widget(tokens[1], LTK_GRID, errstr);
       +        grid = (ltk_grid *)ltk_get_widget(tokens[1], LTK_GRID, errstr);
                if (!grid) return 1;
                row    = strtonum(tokens[3], 0, grid->rows, &errstr_num);
                if (errstr_num) {
       t@@ -572,6 +573,7 @@ ltk_grid_cmd_set_column_weight(
            char **tokens,
            size_t num_tokens,
            char **errstr) {
       +        (void)window;
                ltk_grid *grid;
                int column, weight;
                const char *errstr_num;
       t@@ -579,7 +581,7 @@ ltk_grid_cmd_set_column_weight(
                        *errstr = "Invalid number of arguments.\n";
                        return 1;
                }
       -        grid = ltk_get_widget(tokens[1], LTK_GRID, errstr);
       +        grid = (ltk_grid *)ltk_get_widget(tokens[1], LTK_GRID, errstr);
                if (!grid) return 1;
                column = strtonum(tokens[3], 0, grid->columns, &errstr_num);
                if (errstr_num) {
   DIR diff --git a/grid.h b/grid.h
       t@@ -31,15 +31,15 @@
         */
        typedef struct {
                ltk_widget widget;
       -        unsigned int rows;
       -        unsigned int columns;
       +        int rows;
       +        int columns;
                ltk_widget **widget_grid;
       -        unsigned int *row_heights;
       -        unsigned int *column_widths;
       -        unsigned int *row_weights;
       -        unsigned int *column_weights;
       -        unsigned int *row_pos;
       -        unsigned int *column_pos;
       +        int *row_heights;
       +        int *column_widths;
       +        int *row_weights;
       +        int *column_weights;
       +        int *row_pos;
       +        int *column_pos;
        } ltk_grid;
        
        int ltk_grid_cmd(ltk_window *window, char **tokens, size_t num_tokens, char **errstr);
   DIR diff --git a/label.c b/label.c
       t@@ -74,7 +74,7 @@ ltk_label_ini_handler(ltk_window *window, const char *prop, const char *value) {
        
        static void
        ltk_label_draw(ltk_widget *self, ltk_rect clip) {
       -        ltk_label *label = self;
       +        ltk_label *label = (ltk_label *)self;
                ltk_window *window = label->widget.window;
                ltk_rect rect = label->widget.rect;
                ltk_rect clip_final = ltk_rect_intersect(clip, rect);
       t@@ -119,7 +119,8 @@ ltk_label_create(ltk_window *window, const char *id, const char *text) {
        
        static void
        ltk_label_destroy(ltk_widget *self, int shallow) {
       -        ltk_label *label = self;
       +        (void)shallow;
       +        ltk_label *label = (ltk_label *)self;
                if (!label) {
                        ltk_warn("Tried to destroy NULL label.\n");
                        return;
       t@@ -147,7 +148,7 @@ ltk_label_cmd_create(
                        return 1;
                }
                label = ltk_label_create(window, tokens[1], tokens[3]);
       -        ltk_set_widget(label, tokens[1]);
       +        ltk_set_widget((ltk_widget *)label, tokens[1]);
        
                return 0;
        }
   DIR diff --git a/ltkc.c b/ltkc.c
       t@@ -59,7 +59,7 @@ int main(int argc, char *argv[]) {
                struct timeval tv, tv_master;
                tv_master.tv_sec = 0;
                tv_master.tv_usec = 20000;
       -        int path_size;
       +        size_t path_size;
        
                if (argc != 2) {
                        (void)fprintf(stderr, "USAGE: ltkc <socket id>\n");
   DIR diff --git a/ltkd.c b/ltkd.c
       t@@ -335,7 +335,6 @@ get_sock_path(char *basedir, Window id) {
        
        static FILE *
        open_log(char *dir) {
       -        int len;
                FILE *f;
                char *path;
        
       t@@ -384,6 +383,7 @@ ltk_cleanup(void) {
        
        void
        ltk_quit(ltk_window *window) {
       +        (void)window;
                running = 0;
        }
        
       t@@ -427,6 +427,9 @@ ltk_set_root_widget_cmd(
                return 0;
        }
        
       +/* FIXME */
       +#undef MAX
       +#undef MIN
        #define MAX(a, b) ((a) > (b) ? (a) : (b))
        #define MIN(a, b) ((a) < (b) ? (a) : (b))
        
       t@@ -509,7 +512,7 @@ static void
        ltk_window_other_event(ltk_window *window, XEvent event) {
                ltk_widget *ptr = window->root_widget;
                if (event.type == ConfigureNotify) {
       -                unsigned int w, h;
       +                int w, h;
                        w = event.xconfigure.width;
                        h = event.xconfigure.height;
                        int orig_w = window->rect.w;
       t@@ -532,7 +535,7 @@ ltk_window_other_event(ltk_window *window, XEvent event) {
                        r.h = event.xexpose.height;
                        ltk_window_invalidate_rect(window, r);
                } else if (event.type == ClientMessage
       -            && event.xclient.data.l[0] == window->wm_delete_msg) {
       +            && (Atom)event.xclient.data.l[0] == window->wm_delete_msg) {
                        ltk_quit(window);
                }
        }
       t@@ -1187,7 +1190,6 @@ ltk_widget_destroy(
            size_t num_tokens,
            char **errstr) {
                int err = 0, shallow = 1;
       -        khint_t k;
                if (num_tokens != 2 && num_tokens != 3) {
                        *errstr = "Invalid number of arguments.\n";
                        return 1;
   DIR diff --git a/memory.c b/memory.c
       t@@ -43,7 +43,7 @@ char *
        ltk_strdup_debug(const char *s, const char *caller, const char *file, int line) {
                char *str = strdup(s);
                fprintf(stderr, "DEBUG: strdup %p to %p in %s (%s:%d)\n",
       -                s, str, caller, file, line);
       +                (void *)s, (void *)str, caller, file, line);
                if (!str)
                        ltk_fatal("Out of memory.\n");
                return str;
   DIR diff --git a/scrollbar.c b/scrollbar.c
       t@@ -106,7 +106,8 @@ ltk_scrollbar_set_virtual_size(ltk_scrollbar *scrollbar, int virtual_size) {
        
        static void
        ltk_scrollbar_draw(ltk_widget *self, ltk_rect clip) {
       -        ltk_scrollbar *scrollbar = self;
       +        (void)clip; /* FIXME: actually use this */
       +        ltk_scrollbar *scrollbar = (ltk_scrollbar *)self;
                LtkColor *bg, *fg;
                int handle_x, handle_y, handle_w, handle_h;
                ltk_window *window = scrollbar->widget.window;
       t@@ -162,7 +163,7 @@ ltk_scrollbar_draw(ltk_widget *self, ltk_rect clip) {
        
        static int
        ltk_scrollbar_mouse_press(ltk_widget *self, XEvent event) {
       -        ltk_scrollbar *sc = self;
       +        ltk_scrollbar *sc = (ltk_scrollbar *)self;
                int max_pos;
                double rel_pos;
                if (event.xbutton.button != 1 && event.xbutton.button != 3)
       t@@ -195,7 +196,8 @@ ltk_scrollbar_mouse_press(ltk_widget *self, XEvent event) {
        /* FIXME: Make this scrollbar more "traditional" */
        static int
        ltk_scrollbar_motion_notify(ltk_widget *self, XEvent event) {
       -        ltk_scrollbar *sc = self;
       +        (void)self;
       +        (void)event;
                /*
                double scale;
                int delta, max_pos;
       t@@ -224,9 +226,9 @@ ltk_scrollbar_motion_notify(ltk_widget *self, XEvent event) {
        }
        
        ltk_scrollbar *
       -ltk_scrollbar_create(ltk_window *window, ltk_orientation orient, void (*callback)(void *), void *data) {
       +ltk_scrollbar_create(ltk_window *window, ltk_orientation orient, void (*callback)(ltk_widget *), void *data) {
                ltk_scrollbar *sc = ltk_malloc(sizeof(ltk_scrollbar));
       -        ltk_fill_widget_defaults(sc, NULL, window, &ltk_scrollbar_draw,
       +        ltk_fill_widget_defaults((ltk_widget *)sc, NULL, window, &ltk_scrollbar_draw,
                    NULL, &ltk_scrollbar_destroy, 1, LTK_UNKNOWN);
                sc->last_mouse_x = sc->last_mouse_y = 0;
                sc->widget.motion_notify = &ltk_scrollbar_motion_notify;
       t@@ -247,6 +249,7 @@ ltk_scrollbar_create(ltk_window *window, ltk_orientation orient, void (*callback
        
        static void
        ltk_scrollbar_destroy(ltk_widget *self, int shallow) {
       -        ltk_scrollbar *scrollbar = self;
       +        (void)shallow;
       +        ltk_scrollbar *scrollbar = (ltk_scrollbar *)self;
                ltk_free(scrollbar);
        }
   DIR diff --git a/scrollbar.h b/scrollbar.h
       t@@ -28,7 +28,7 @@
        
        typedef struct {
                ltk_widget widget;
       -        void (*callback)(void *);
       +        void (*callback)(ltk_widget *);
                void *callback_data;
                double cur_pos;
                int virtual_size;
       t@@ -40,6 +40,6 @@ typedef struct {
        void ltk_scrollbar_set_virtual_size(ltk_scrollbar *scrollbar, int virtual_size);
        void ltk_scrollbar_setup_theme_defaults(ltk_window *window);
        void ltk_scrollbar_ini_handler(ltk_window *window, const char *prop, const char *value);
       -ltk_scrollbar *ltk_scrollbar_create(ltk_window *window, ltk_orientation orient, void (*callback)(void *), void *data);
       +ltk_scrollbar *ltk_scrollbar_create(ltk_window *window, ltk_orientation orient, void (*callback)(ltk_widget *), void *data);
        
        #endif /* _LTK_SCROLLBAR_H_ */
   DIR diff --git a/strtonum.c b/strtonum.c
       t@@ -17,7 +17,7 @@
         * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
         */
        
       -#ifndef __OpenBSD__
       +/* #ifndef __OpenBSD__ */
        
        #include <errno.h>
        #include <limits.h>
       t@@ -68,4 +68,4 @@ strtonum(const char *numstr, long long minval, long long maxval,
        /* FIXME: What does this do? - lumidify */
        /* DEF_WEAK(strtonum); */
        
       -#endif
       +/* #endif */
   DIR diff --git a/text_pango.c b/text_pango.c
       t@@ -54,6 +54,8 @@ ltk_cleanup_text(void) {
        
        void
        ltk_text_line_set_width(LtkTextLine *tl, int width) {
       +        (void)tl;
       +        (void)width;
                /* TODO: Implement! */
        }
        
       t@@ -99,6 +101,7 @@ ltk_text_line_render(LtkTextLine *tl, LtkColor *bg, LtkColor *fg) {
        
        void
        ltk_text_line_draw(LtkTextLine *tl, Drawable d, GC gc, int x, int y, ltk_rect clip) {
       +        (void)clip; /* FIXME: use this */
                XCopyArea(tm.dpy, tl->pixmap, d, gc, 0, 0, tl->w, tl->h, x, y);
        }
        
   DIR diff --git a/text_stb.c b/text_stb.c
       t@@ -128,7 +128,7 @@ static XImage *ltk_create_ximage(int w, int h, int depth, XColor bg);
        /* These unicode routines are taken from
         * https://github.com/JeffBezanson/cutef8 */
        
       -static size_t u8_wc_toutf8(char *dest, uint32_t ch);
       +/* static size_t u8_wc_toutf8(char *dest, uint32_t ch); */
        static size_t u8_strlen(const char *s);
        static uint32_t u8_nextmemchar(const char *s, size_t *i);
        
       t@@ -171,6 +171,7 @@ static size_t u8_strlen(const char *s) {
            return count;
        }
        
       +/*
        static size_t u8_wc_toutf8(char *dest, uint32_t ch) {
            if (ch < 0x80) {
                dest[0] = (char)ch;
       t@@ -196,6 +197,7 @@ static size_t u8_wc_toutf8(char *dest, uint32_t ch) {
            }
            return 0;
        }
       +*/
        
        void
        ltk_init_text(const char *default_font, Display *dpy, int screen, Colormap cm) {
       t@@ -214,7 +216,7 @@ ltk_cleanup_text(void) {
                        ltk_destroy_font(tm.fonts[i]);
                }
                if (!tm.glyph_cache) return;
       -        for (int k = kh_begin(tm.glyph_cache); k != kh_end(tm.glyph_cache); k++) {
       +        for (khint_t k = kh_begin(tm.glyph_cache); k != kh_end(tm.glyph_cache); k++) {
                        if (kh_exist(tm.glyph_cache, k)) {
                                ltk_destroy_glyph_cache(kh_value(tm.glyph_cache, k));
                        }
       t@@ -285,8 +287,7 @@ ltk_create_glyph_cache(uint16_t font_id, uint16_t font_size) {
        
        static void
        ltk_destroy_glyph_cache(khash_t(glyphinfo) *cache) {
       -        int k;
       -        for (k = kh_begin(cache); k != kh_end(cache); k++) {
       +        for (khint_t k = kh_begin(cache); k != kh_end(cache); k++) {
                        if (kh_exist(cache, k)) {
                                ltk_destroy_glyph_info(kh_value(cache, k));
                        }
       t@@ -300,11 +301,11 @@ ltk_load_default_font(const char *name) {
                FcResult result;
                char *file;
                int index;
       -        uint16_t font;
        
       -        tm.fcpattern = FcNameParse(name);
       +        /* FIXME: Get rid of this stupid cast somehow */
       +        tm.fcpattern = FcNameParse((const FcChar8 *)name);
                /*tm.fcpattern = FcPatternCreate();*/
       -        FcPatternAddString(tm.fcpattern, FC_FONTFORMAT, "truetype");
       +        FcPatternAddString(tm.fcpattern, FC_FONTFORMAT, (const FcChar8 *)"truetype");
                FcConfigSubstitute(NULL, tm.fcpattern, FcMatchPattern);
                FcDefaultSubstitute(tm.fcpattern);
                match = FcFontMatch(NULL, tm.fcpattern, &result);
       t@@ -324,8 +325,8 @@ ltk_create_font(char *path, uint16_t id, int index) {
                char *contents = ltk_read_file(path, &len);
                if (!contents)
                        ltk_fatal_errno("Unable to read font file %s\n", path);
       -        int offset = stbtt_GetFontOffsetForIndex(contents, index);
       -        if (!stbtt_InitFont(&font->info, contents, offset))
       +        int offset = stbtt_GetFontOffsetForIndex((unsigned char *)contents, index);
       +        if (!stbtt_InitFont(&font->info, (unsigned char *)contents, offset))
                        ltk_fatal("Failed to load font %s\n", path);
                font->id = id;
                font->refs = 0;
       t@@ -409,7 +410,7 @@ ltk_text_to_glyphs(LtkGlyph *glyphs, int num_glyphs, char *text, uint16_t font_s
                                match = FcFontMatch(NULL, pat, &result);
                                FcPatternGetString(match, FC_FILE, 0, &file);
                                FcPatternGetInteger(match, FC_INDEX, 0, &index);
       -                        font = ltk_get_font(file, index);
       +                        font = ltk_get_font((char *)file, index);
                                glyph_cache = ltk_get_glyph_cache(font->id, font_size);
                                FcPatternDestroy(match);
                                FcPatternDestroy(pat);
       t@@ -513,8 +514,6 @@ ltk_text_line_render(
                LtkColor *bg,
                LtkColor *fg)
        {
       -        LtkGlyph *glyph;
       -
                XWindowAttributes attrs;
                XGetWindowAttributes(tm.dpy, tl->window, &attrs);
                int depth = attrs.depth;
       t@@ -522,7 +521,7 @@ ltk_text_line_render(
                if (tl->img)
                        XDestroyImage(tl->img);
                tl->img = ltk_create_ximage(tl->w, tl->h, depth, bg->xcolor);
       -        for (int i = 0; i < tl->glyph_len; i++) {
       +        for (size_t i = 0; i < tl->glyph_len; i++) {
                        ltk_text_line_draw_glyph(&tl->glyphs[i], -tl->x_min, -tl->y_min, tl->img, fg->xcolor);
                }
        }
       t@@ -530,6 +529,7 @@ ltk_text_line_render(
        /* FIXME: error checking if img is rendered yet, tm initialized, etc. */
        void
        ltk_text_line_draw(LtkTextLine *tl, Drawable d, GC gc, int x, int y, ltk_rect clip) {
       +        (void)clip;
                /*
                int xoff = clip.x - x;
                int yoff = clip.y - y;
       t@@ -544,6 +544,8 @@ ltk_text_line_draw(LtkTextLine *tl, Drawable d, GC gc, int x, int y, ltk_rect cl
        
        void
        ltk_text_line_set_width(LtkTextLine *tl, int width) {
       +        (void)tl;
       +        (void)width;
                /* FIXME: implement */
        }
        
       t@@ -567,6 +569,7 @@ ltk_text_line_create_glyphs(LtkTextLine *tl) {
        
        LtkTextLine *
        ltk_text_line_create(Window window, uint16_t font_size, char *text, int width) {
       +        (void)width;
                LtkTextLine *line = ltk_malloc(sizeof(LtkTextLine));
                line->window = window;
                line->img = NULL;
   DIR diff --git a/util.c b/util.c
       t@@ -138,7 +138,7 @@ ltk_fatal(const char *format, ...) {
                ltk_cleanup();
        
                exit(1);
       -};
       +}
        
        void
        ltk_warn_errno(const char *format, ...) {
   DIR diff --git a/util.h b/util.h
       t@@ -23,11 +23,11 @@
        
        /* Requires: <stdarg.h> */
        
       -#ifndef __OpenBSD__
       +/* #ifndef __OpenBSD__ */
        long long
        strtonum(const char *numstr, long long minval, long long maxval,
            const char **errstrp);
       -#endif
       +/* #endif */
        
        char *ltk_read_file(const char *path, unsigned long *len);
        int ltk_grow_string(char **str, int *alloc_size, int needed);