From 50601338e09bb12adf3615f5333aa019fc72cf8c Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Fri, 20 Jun 2025 10:11:14 +0300
Subject: [PATCH 93/93] sdl: Add 'widget_id' type

See RM #1529

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/gui-sdl2/cma_fe.c           | 14 +++----
 client/gui-sdl2/gui_main.c         | 65 ++++++++++++++++--------------
 client/gui-sdl2/gui_main.h         | 28 +++++++------
 client/gui-sdl2/repodlgs.c         | 20 ++++-----
 client/gui-sdl2/widget.c           |  2 +-
 client/gui-sdl2/widget.h           |  4 +-
 client/gui-sdl2/widget_edit.c      | 32 +++++++--------
 client/gui-sdl2/widget_scrollbar.c | 10 ++---
 client/gui-sdl2/widget_window.c    | 12 +++---
 client/gui-sdl3/cma_fe.c           | 14 +++----
 client/gui-sdl3/gui_main.c         | 61 +++++++++++++++-------------
 client/gui-sdl3/gui_main.h         | 28 +++++++------
 client/gui-sdl3/repodlgs.c         | 20 ++++-----
 client/gui-sdl3/widget.c           |  2 +-
 client/gui-sdl3/widget.h           |  4 +-
 client/gui-sdl3/widget_edit.c      | 26 ++++++------
 client/gui-sdl3/widget_scrollbar.c | 10 ++---
 client/gui-sdl3/widget_window.c    | 12 +++---
 18 files changed, 190 insertions(+), 174 deletions(-)

diff --git a/client/gui-sdl2/cma_fe.c b/client/gui-sdl2/cma_fe.c
index 50916912fa..844d563f6c 100644
--- a/client/gui-sdl2/cma_fe.c
+++ b/client/gui-sdl2/cma_fe.c
@@ -91,17 +91,17 @@ static int exit_cma_dialog_callback(struct widget *pwidget)
 /**********************************************************************//**
   User released mouse button while in scrollbar.
 **************************************************************************/
-static Uint16 scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
-                                     void *data)
+static widget_id scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
+                                        void *data)
 {
-  return (Uint16)ID_SCROLLBAR;
+  return (widget_id)ID_SCROLLBAR;
 }
 
 /**********************************************************************//**
   User moved mouse while holding scrollbar.
 **************************************************************************/
-static Uint16 scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
-                                          void *data)
+static widget_id scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
+                                             void *data)
 {
   struct hmove *motion = (struct hmove *)data;
   char cbuf[4];
@@ -132,11 +132,11 @@ static Uint16 scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
                 *(int *)motion->pscroll_bar->data.ptr);
     copy_chars_to_utf8_str(motion->pscroll_bar->next->string_utf8, cbuf);
 
-    /* redraw label */
+    /* Redraw label */
     widget_redraw(motion->pscroll_bar->next);
     widget_mark_dirty(motion->pscroll_bar->next);
 
-    /* redraw scrollbar */
+    /* Redraw scrollbar */
     if (get_wflags(motion->pscroll_bar) & WF_RESTORE_BACKGROUND) {
       refresh_widget_background(motion->pscroll_bar);
     }
diff --git a/client/gui-sdl2/gui_main.c b/client/gui-sdl2/gui_main.c
index 1185131cb8..edad16c8db 100644
--- a/client/gui-sdl2/gui_main.c
+++ b/client/gui-sdl2/gui_main.c
@@ -231,7 +231,7 @@ static bool parse_options(int argc, char **argv)
 /**********************************************************************//**
   Main handler for key presses
 **************************************************************************/
-static Uint16 main_key_down_handler(SDL_Keysym key, void *data)
+static widget_id main_key_down_handler(SDL_Keysym key, void *data)
 {
   static struct widget *pwidget;
 
@@ -239,7 +239,7 @@ static Uint16 main_key_down_handler(SDL_Keysym key, void *data)
     return widget_pressed_action(pwidget);
   } else {
     if (key.sym == SDLK_TAB) {
-      /* input */
+      /* Input */
       popup_input_line();
     } else {
       if (map_event_handler(key)
@@ -312,7 +312,7 @@ static Uint16 main_key_down_handler(SDL_Keysym key, void *data)
 /**********************************************************************//**
   Main key release handler.
 **************************************************************************/
-static Uint16 main_key_up_handler(SDL_Keysym key, void *data)
+static widget_id main_key_up_handler(SDL_Keysym key, void *data)
 {
   if (selected_widget) {
     unselect_widget_action();
@@ -323,8 +323,8 @@ static Uint16 main_key_up_handler(SDL_Keysym key, void *data)
 /**********************************************************************//**
   Main finger down handler.
 **************************************************************************/
-static Uint16 main_finger_down_handler(SDL_TouchFingerEvent *touch_event,
-                                       void *data)
+static widget_id main_finger_down_handler(SDL_TouchFingerEvent *touch_event,
+                                          void *data)
 {
   struct widget *pwidget;
   /* Touch event coordinates are normalized (0...1). */
@@ -346,17 +346,20 @@ static Uint16 main_finger_down_handler(SDL_TouchFingerEvent *touch_event,
       finger_behavior.ptile = canvas_pos_to_tile(x, y, mouse_zoom);
     }
   }
+
   return ID_ERROR;
 }
+
 /**********************************************************************//**
   Main finger release handler.
 **************************************************************************/
-static Uint16 main_finger_up_handler(SDL_TouchFingerEvent *touch_event,
-                                     void *data)
+static widget_id main_finger_up_handler(SDL_TouchFingerEvent *touch_event,
+                                        void *data)
 {
   /* Touch event coordinates are normalized (0...1). */
   int x = touch_event->x * main_window_width();
   int y = touch_event->y * main_window_height();
+
   /* Screen wasn't pressed over a widget. */
   if (finger_behavior.finger_down_ticks
       && !find_next_widget_at_pos(NULL, x, y)) {
@@ -375,8 +378,8 @@ static Uint16 main_finger_up_handler(SDL_TouchFingerEvent *touch_event,
 /**********************************************************************//**
   Main mouse click handler.
 **************************************************************************/
-static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event,
-                                             void *data)
+static widget_id main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event,
+                                                void *data)
 {
   struct widget *pwidget;
 
@@ -387,12 +390,12 @@ static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event,
       return widget_pressed_action(pwidget);
     }
   } else {
-    /* no visible widget at this position -> map click */
+    /* No visible widget at this position -> map click */
 #ifdef UNDER_CE
     if (!check_scroll_area(button_event->x, button_event->y)) {
 #endif
     if (!button_behavior.counting) {
-      /* start counting */
+      /* Start counting */
       button_behavior.counting = TRUE;
       button_behavior.button_down_ticks = SDL_GetTicks();
       *button_behavior.event = *button_event;
@@ -411,10 +414,10 @@ static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event,
 /**********************************************************************//**
   Main mouse button release handler.
 **************************************************************************/
-static Uint16 main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event,
-                                           void *data)
+static widget_id main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event,
+                                              void *data)
 {
-  if (button_behavior.button_down_ticks /* button wasn't pressed over a widget */
+  if (button_behavior.button_down_ticks /* Button wasn't pressed over a widget */
       && !find_next_widget_at_pos(NULL, button_event->x, button_event->y)) {
     *button_behavior.event = *button_event;
     button_up_on_map(&button_behavior);
@@ -437,13 +440,13 @@ static Uint16 main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event,
 /**********************************************************************//**
   Main handler for mouse movement handling.
 **************************************************************************/
-static Uint16 main_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
-                                        void *data)
+static widget_id main_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
+                                           void *data)
 {
   static struct widget *pwidget;
   struct tile *ptile;
 
-  /* stop evaluating button hold time when moving to another tile in medium
+  /* Stop evaluating button hold time when moving to another tile in medium
    * hold state or above */
   if (button_behavior.counting && (button_behavior.hold_state >= MB_HOLD_MEDIUM)) {
     ptile = canvas_pos_to_tile(motion_event->x, motion_event->y,
@@ -600,21 +603,23 @@ int FilterMouseMotionEvents(void *data, SDL_Event *event)
 /**********************************************************************//**
   SDL2-client main loop.
 **************************************************************************/
-Uint16 gui_event_loop(void *data,
-                      void (*loop_action)(void *data),
-                      Uint16 (*key_down_handler)(SDL_Keysym key, void *data),
-                      Uint16 (*key_up_handler)(SDL_Keysym key, void *data),
-                      Uint16 (*textinput_handler)(const char *text, void *data),
-                      Uint16 (*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data),
-                      Uint16 (*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data),
-                      Uint16 (*finger_motion_handler)(SDL_TouchFingerEvent *touch_event,
-                                                      void *data),
-                      Uint16 (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
+widget_id gui_event_loop(void *data,
+                         void (*loop_action)(void *data),
+                         widget_id (*key_down_handler)(SDL_Keysym key, void *data),
+                         widget_id (*key_up_handler)(SDL_Keysym key, void *data),
+                         widget_id (*textinput_handler)(const char *text, void *data),
+                         widget_id (*finger_down_handler)(SDL_TouchFingerEvent *touch_event,
                                                           void *data),
-                      Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
+                         widget_id (*finger_up_handler)(SDL_TouchFingerEvent *touch_event,
                                                         void *data),
-                      Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event,
-                                                     void *data))
+                         widget_id (*finger_motion_handler)(SDL_TouchFingerEvent *touch_event,
+                                                            void *data),
+                         widget_id (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
+                                                                void *data),
+                         widget_id (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
+                                                              void *data),
+                         widget_id (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event,
+                                                           void *data))
 {
   Uint16 ID;
   static fc_timeval tv;
diff --git a/client/gui-sdl2/gui_main.h b/client/gui-sdl2/gui_main.h
index dd2d2a6d41..abd87663fe 100644
--- a/client/gui-sdl2/gui_main.h
+++ b/client/gui-sdl2/gui_main.h
@@ -74,6 +74,8 @@ struct theme;
   || ((event).type == SDL_MOUSEBUTTONDOWN                                   \
       && (event).button.button == SDL_BUTTON_LEFT))
 
+typedef Uint16 widget_id;
+
 enum mouse_button_hold_state {
   MB_HOLD_SHORT,
   MB_HOLD_MEDIUM,
@@ -114,20 +116,22 @@ void disable_focus_animation(void);
 extern int MOVE_STEP_X, MOVE_STEP_Y;
 int FilterMouseMotionEvents(void *data, SDL_Event *event);
 
-Uint16 gui_event_loop(void *data, void (*loop_action)(void *data),
-                      Uint16 (*key_down_handler)(SDL_Keysym key, void *data),
-                      Uint16 (*key_up_handler)(SDL_Keysym key, void *data),
-                      Uint16 (*textinput_handler)(const char *text, void *data),
-                      Uint16 (*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data),
-                      Uint16 (*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data),
-                      Uint16 (*finger_motion_handler)(SDL_TouchFingerEvent *touch_event,
-                                                      void *data),
-                      Uint16 (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
+widget_id gui_event_loop(void *data, void (*loop_action)(void *data),
+                         widget_id (*key_down_handler)(SDL_Keysym key, void *data),
+                         widget_id (*key_up_handler)(SDL_Keysym key, void *data),
+                         widget_id (*textinput_handler)(const char *text, void *data),
+                         widget_id (*finger_down_handler)(SDL_TouchFingerEvent *touch_event,
                                                           void *data),
-                      Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
+                         widget_id (*finger_up_handler)(SDL_TouchFingerEvent *touch_event,
                                                         void *data),
-                      Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event,
-                                                     void *data));
+                         widget_id (*finger_motion_handler)(SDL_TouchFingerEvent *touch_event,
+                                                            void *data),
+                         widget_id (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
+                                                                void *data),
+                         widget_id (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
+                                                              void *data),
+                         widget_id (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event,
+                                                           void *data));
 
 unsigned default_font_size(struct theme *act_theme);
 void update_font_from_theme(int theme_font_size);
diff --git a/client/gui-sdl2/repodlgs.c b/client/gui-sdl2/repodlgs.c
index 239cf16694..398888cd02 100644
--- a/client/gui-sdl2/repodlgs.c
+++ b/client/gui-sdl2/repodlgs.c
@@ -1191,17 +1191,17 @@ static int toggle_block_callback(struct widget *pcheckbox)
 /**********************************************************************//**
   User released mouse button while adjusting rates.
 **************************************************************************/
-static Uint16 report_scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
-                                            void *data)
+static widget_id report_scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
+                                               void *data)
 {
-  return (Uint16)ID_SCROLLBAR;
+  return (widget_id)ID_SCROLLBAR;
 }
 
 /**********************************************************************//**
   User moved a mouse while adjusting rates.
 **************************************************************************/
-static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
-                                                 void *data)
+static widget_id report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
+                                                    void *data)
 {
   struct rates_move *motion = (struct rates_move *)data;
   struct widget *tax_label = economy_dlg->end_widget_list->prev->prev;
@@ -1215,7 +1215,7 @@ static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_ev
       && (motion_event->x >= motion->min)
       && (motion_event->x <= motion->max)) {
 
-    /* set up directions */
+    /* Set up directions */
     if (motion_event->xrel > 0) {
       dir = 15;
       inc = 10;
@@ -1224,7 +1224,7 @@ static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_ev
       inc = -10;
     }
 
-    /* make checks */
+    /* Make checks */
     x = motion->horiz_src->size.x;
     if (((x + dir) <= motion->max) && ((x + dir) >= motion->min)) {
       /* src in range */
@@ -1253,7 +1253,7 @@ static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_ev
         }
       }
 
-      /* undraw scrollbars */
+      /* Undraw scrollbars */
       widget_undraw(motion->horiz_src);
       widget_mark_dirty(motion->horiz_src);
 
@@ -1275,14 +1275,14 @@ static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_ev
       fc_snprintf(cbuf, sizeof(cbuf), "%d%%", *motion->dst_rate);
       copy_chars_to_utf8_str(motion->label_dst->string_utf8, cbuf);
 
-      /* redraw label */
+      /* Redraw label */
       widget_redraw(motion->label_src);
       widget_mark_dirty(motion->label_src);
 
       widget_redraw(motion->label_dst);
       widget_mark_dirty(motion->label_dst);
 
-      /* redraw scrollbar */
+      /* Redraw scrollbar */
       if (get_wflags(motion->horiz_src) & WF_RESTORE_BACKGROUND) {
         refresh_widget_background(motion->horiz_src);
       }
diff --git a/client/gui-sdl2/widget.c b/client/gui-sdl2/widget.c
index 540355832b..32b51cac5c 100644
--- a/client/gui-sdl2/widget.c
+++ b/client/gui-sdl2/widget.c
@@ -583,7 +583,7 @@ struct widget *get_widget_pointer_from_main_list(Uint16 id)
 /**********************************************************************//**
   Add Widget to Main widgets list ( begin_widget_list )
 **************************************************************************/
-void add_to_gui_list(Uint16 id, struct widget *gui)
+void add_to_gui_list(widget_id id, struct widget *gui)
 {
   if (begin_main_widget_list != NULL) {
     gui->next = begin_main_widget_list;
diff --git a/client/gui-sdl2/widget.h b/client/gui-sdl2/widget.h
index 3e8ff94d46..5ae9ded5cf 100644
--- a/client/gui-sdl2/widget.h
+++ b/client/gui-sdl2/widget.h
@@ -152,7 +152,7 @@ struct widget {
 
   SDL_Keycode key;              /* key aliased with this widget */
   Uint16 mod;			/* SHIFT, CTRL, ALT, etc */
-  Uint16 id;			/* id in widget list */
+  widget_id id;			/* id in widget list */
 
   int (*action) (struct widget *);	/* default callback action */
 
@@ -192,7 +192,7 @@ enum scan_direction {
   SCAN_BACKWARD
 };
 
-void add_to_gui_list(Uint16 id, struct widget *gui);
+void add_to_gui_list(widget_id id, struct widget *gui);
 void del_widget_pointer_from_gui_list(struct widget *gui);
 void widget_add_as_prev(struct widget *new_widget, struct widget *add_dock);
 
diff --git a/client/gui-sdl2/widget_edit.c b/client/gui-sdl2/widget_edit.c
index 9096c48f6e..d30711456c 100644
--- a/client/gui-sdl2/widget_edit.c
+++ b/client/gui-sdl2/widget_edit.c
@@ -420,20 +420,20 @@ int draw_edit(struct widget *pedit, Sint16 start_x, Sint16 start_y)
   NOTE: This functions can return NULL in 'edit_widget->string_utf8->text' but
         never free 'edit_widget->string_utf8' struct.
 **************************************************************************/
-static Uint16 edit_key_down(SDL_Keysym key, void *data)
+static widget_id edit_key_down(SDL_Keysym key, void *data)
 {
   struct text_edit *edt = (struct text_edit *)data;
   struct utf8_char *input_chain_tmp;
   bool redraw = FALSE;
 
-  /* find which key is pressed */
+  /* Find which key is pressed */
   switch (key.sym) {
     case SDLK_ESCAPE:
-      /* exit from loop without changes */
+      /* Exit from loop without changes */
       return ED_ESC;
     case SDLK_RETURN:
     case SDLK_KP_ENTER:
-      /* exit from loop */
+      /* Exit from loop */
       return ED_RETURN;
       /*
     case SDLK_KP6:
@@ -574,7 +574,7 @@ static Uint16 edit_key_down(SDL_Keysym key, void *data)
     break;
   default:
     break;
-  } /* key pressed switch */
+  } /* Key pressed switch */
 
   if (redraw) {
     redraw_edit_chain(edt);
@@ -586,7 +586,7 @@ static Uint16 edit_key_down(SDL_Keysym key, void *data)
 /**********************************************************************//**
   Handle textinput strings coming to the edit widget
 **************************************************************************/
-static Uint16 edit_textinput(const char *text, void *data)
+static widget_id edit_textinput(const char *text, void *data)
 {
   struct text_edit *edt = (struct text_edit *)data;
   struct utf8_char *input_chain_tmp;
@@ -656,8 +656,8 @@ static Uint16 edit_textinput(const char *text, void *data)
 /**********************************************************************//**
   Handle mouse down events on edit widget.
 **************************************************************************/
-static Uint16 edit_mouse_button_down(SDL_MouseButtonEvent *button_event,
-                                     void *data)
+static widget_id edit_mouse_button_down(SDL_MouseButtonEvent *button_event,
+                                        void *data)
 {
   struct text_edit *edt = (struct text_edit *)data;
 
@@ -666,12 +666,12 @@ static Uint16 edit_mouse_button_down(SDL_MouseButtonEvent *button_event,
           && button_event->x < edt->pwidget->size.x + edt->bg->w
           && button_event->y >= edt->pwidget->size.y
           && button_event->y < edt->pwidget->size.y + edt->bg->h)) {
-      /* exit from loop */
-      return (Uint16)ED_MOUSE;
+      /* Exit from loop */
+      return (widget_id)ED_MOUSE;
     }
   }
 
-  return (Uint16)ID_ERROR;
+  return (widget_id)ID_ERROR;
 }
 
 /**********************************************************************//**
@@ -713,7 +713,7 @@ enum edit_return_codes edit_field(struct widget *edit_widget)
   edt.end_text_chain->next = NULL;
   edt.end_text_chain->prev = NULL;
 
-  /* set font style (if any ) */
+  /* Set font style (if any ) */
   if (!((edit_widget->string_utf8->style & 0x0F) & TTF_STYLE_NORMAL)) {
     TTF_SetFontStyle(edit_widget->string_utf8->font,
                      (edit_widget->string_utf8->style & 0x0F));
@@ -724,7 +724,7 @@ enum edit_return_codes edit_field(struct widget *edit_widget)
                              edt.end_text_chain->chr,
                              edit_widget->string_utf8->fgcol);
 
-  /* create surface for each font in chain and find chain length */
+  /* Create surface for each font in chain and find chain length */
   if (edt.begin_text_chain) {
     input_chain_tmp = edt.begin_text_chain;
 
@@ -766,9 +766,9 @@ enum edit_return_codes edit_field(struct widget *edit_widget)
   set_wstate(edit_widget, FC_WS_PRESSED);
   {
     /* Local loop */
-    Uint16 rety = gui_event_loop((void *)&edt, NULL,
-                                 edit_key_down, NULL, edit_textinput, NULL, NULL, NULL,
-                                 edit_mouse_button_down, NULL, NULL);
+    widget_id rety = gui_event_loop((void *)&edt, NULL,
+                                    edit_key_down, NULL, edit_textinput, NULL, NULL, NULL,
+                                    edit_mouse_button_down, NULL, NULL);
 
     if (edt.begin_text_chain == edt.end_text_chain) {
       edt.begin_text_chain = NULL;
diff --git a/client/gui-sdl2/widget_scrollbar.c b/client/gui-sdl2/widget_scrollbar.c
index a5d0b7282a..d7df7fc628 100644
--- a/client/gui-sdl2/widget_scrollbar.c
+++ b/client/gui-sdl2/widget_scrollbar.c
@@ -954,8 +954,8 @@ static void inside_scroll_up_loop(void *data)
 /**********************************************************************//**
   Handle mouse motion events of the vertical scrollbar event loop.
 **************************************************************************/
-static Uint16 scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
-                                          void *data)
+static widget_id scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
+                                             void *data)
 {
   struct UP_DOWN *motion = (struct UP_DOWN *)data;
   int yrel;
@@ -1042,10 +1042,10 @@ static Uint16 scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
 /**********************************************************************//**
   Callback for scrollbar event loops' mouse up events.
 **************************************************************************/
-static Uint16 scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
-                                     void *data)
+static widget_id scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
+                                        void *data)
 {
-  return (Uint16)ID_SCROLLBAR;
+  return (widget_id)ID_SCROLLBAR;
 }
 
 /**********************************************************************//**
diff --git a/client/gui-sdl2/widget_window.c b/client/gui-sdl2/widget_window.c
index fcf9dd2109..c641e265dc 100644
--- a/client/gui-sdl2/widget_window.c
+++ b/client/gui-sdl2/widget_window.c
@@ -304,8 +304,8 @@ bool resize_window(struct widget *pwindow, SDL_Surface *bcgd,
 /**********************************************************************//**
   Move window as event instructs.
 **************************************************************************/
-static Uint16 move_window_motion(SDL_MouseMotionEvent *motion_event,
-                                 void *data)
+static widget_id move_window_motion(SDL_MouseMotionEvent *motion_event,
+                                    void *data)
 {
   struct move *pmove = (struct move *)data;
   int xrel, yrel;
@@ -334,16 +334,16 @@ static Uint16 move_window_motion(SDL_MouseMotionEvent *motion_event,
 /**********************************************************************//**
   Button up event handler for the window moving event loop.
 **************************************************************************/
-static Uint16 move_window_button_up(SDL_MouseButtonEvent *button_event,
-                                    void *data)
+static widget_id move_window_button_up(SDL_MouseButtonEvent *button_event,
+                                       void *data)
 {
   struct move *pmove = (struct move *)data;
 
   if (pmove && pmove->moved) {
-    return (Uint16)ID_MOVED_WINDOW;
+    return (widget_id)ID_MOVED_WINDOW;
   }
 
-  return (Uint16)ID_WINDOW;
+  return (widget_id)ID_WINDOW;
 }
 
 /**********************************************************************//**
diff --git a/client/gui-sdl3/cma_fe.c b/client/gui-sdl3/cma_fe.c
index ada0848deb..c7f8aa9973 100644
--- a/client/gui-sdl3/cma_fe.c
+++ b/client/gui-sdl3/cma_fe.c
@@ -87,17 +87,17 @@ static int exit_cma_dialog_callback(struct widget *pwidget)
 /**********************************************************************//**
   User released mouse button while in scrollbar.
 **************************************************************************/
-static Uint16 scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
-                                     void *data)
+static widget_id scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
+                                        void *data)
 {
-  return (Uint16)ID_SCROLLBAR;
+  return (widget_id)ID_SCROLLBAR;
 }
 
 /**********************************************************************//**
   User moved mouse while holding scrollbar.
 **************************************************************************/
-static Uint16 scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
-                                          void *data)
+static widget_id scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
+                                             void *data)
 {
   struct hmove *motion = (struct hmove *)data;
   char cbuf[4];
@@ -128,11 +128,11 @@ static Uint16 scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
                 *(int *)motion->pscroll_bar->data.ptr);
     copy_chars_to_utf8_str(motion->pscroll_bar->next->string_utf8, cbuf);
 
-    /* redraw label */
+    /* Redraw label */
     widget_redraw(motion->pscroll_bar->next);
     widget_mark_dirty(motion->pscroll_bar->next);
 
-    /* redraw scrollbar */
+    /* Redraw scrollbar */
     if (get_wflags(motion->pscroll_bar) & WF_RESTORE_BACKGROUND) {
       refresh_widget_background(motion->pscroll_bar);
     }
diff --git a/client/gui-sdl3/gui_main.c b/client/gui-sdl3/gui_main.c
index c7f0ac8d5d..961f421641 100644
--- a/client/gui-sdl3/gui_main.c
+++ b/client/gui-sdl3/gui_main.c
@@ -224,7 +224,7 @@ static bool parse_options(int argc, char **argv)
 /**********************************************************************//**
   Main handler for key presses
 **************************************************************************/
-static Uint16 main_key_down_handler(SDL_KeyboardEvent *key, void *data)
+static widget_id main_key_down_handler(SDL_KeyboardEvent *key, void *data)
 {
   static struct widget *pwidget;
 
@@ -305,7 +305,7 @@ static Uint16 main_key_down_handler(SDL_KeyboardEvent *key, void *data)
 /**********************************************************************//**
   Main key release handler.
 **************************************************************************/
-static Uint16 main_key_up_handler(SDL_KeyboardEvent *key, void *data)
+static widget_id main_key_up_handler(SDL_KeyboardEvent *key, void *data)
 {
   if (selected_widget) {
     unselect_widget_action();
@@ -317,8 +317,8 @@ static Uint16 main_key_up_handler(SDL_KeyboardEvent *key, void *data)
 /**********************************************************************//**
   Main finger down handler.
 **************************************************************************/
-static Uint16 main_finger_down_handler(SDL_TouchFingerEvent *touch_event,
-                                       void *data)
+static widget_id main_finger_down_handler(SDL_TouchFingerEvent *touch_event,
+                                          void *data)
 {
   struct widget *pwidget;
   /* Touch event coordinates are normalized (0...1). */
@@ -346,12 +346,13 @@ static Uint16 main_finger_down_handler(SDL_TouchFingerEvent *touch_event,
 /**********************************************************************//**
   Main finger release handler.
 **************************************************************************/
-static Uint16 main_finger_up_handler(SDL_TouchFingerEvent *touch_event,
-                                     void *data)
+static widget_id main_finger_up_handler(SDL_TouchFingerEvent *touch_event,
+                                        void *data)
 {
   /* Touch event coordinates are normalized (0...1). */
   int x = touch_event->x * main_window_width();
   int y = touch_event->y * main_window_height();
+
   /* Screen wasn't pressed over a widget. */
   if (finger_behavior.finger_down_ticks
       && !find_next_widget_at_pos(NULL, x, y)) {
@@ -370,8 +371,8 @@ static Uint16 main_finger_up_handler(SDL_TouchFingerEvent *touch_event,
 /**********************************************************************//**
   Main mouse click handler.
 **************************************************************************/
-static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event,
-                                             void *data)
+static widget_id main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event,
+                                                void *data)
 {
   struct widget *pwidget;
 
@@ -382,12 +383,12 @@ static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event,
       return widget_pressed_action(pwidget);
     }
   } else {
-    /* no visible widget at this position -> map click */
+    /* No visible widget at this position -> map click */
 #ifdef UNDER_CE
     if (!check_scroll_area(button_event->x, button_event->y)) {
 #endif
     if (!button_behavior.counting) {
-      /* start counting */
+      /* Start counting */
       button_behavior.counting = TRUE;
       button_behavior.button_down_ticks = SDL_GetTicks();
       *button_behavior.event = *button_event;
@@ -406,10 +407,10 @@ static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event,
 /**********************************************************************//**
   Main mouse button release handler.
 **************************************************************************/
-static Uint16 main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event,
-                                           void *data)
+static widget_id main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event,
+                                              void *data)
 {
-  if (button_behavior.button_down_ticks /* button wasn't pressed over a widget */
+  if (button_behavior.button_down_ticks /* Button wasn't pressed over a widget */
       && !find_next_widget_at_pos(NULL, button_event->x, button_event->y)) {
     *button_behavior.event = *button_event;
     button_up_on_map(&button_behavior);
@@ -432,13 +433,13 @@ static Uint16 main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event,
 /**********************************************************************//**
   Main handler for mouse movement handling.
 **************************************************************************/
-static Uint16 main_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
-                                        void *data)
+static widget_id main_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
+                                           void *data)
 {
   static struct widget *pwidget;
   struct tile *ptile;
 
-  /* stop evaluating button hold time when moving to another tile in medium
+  /* Stop evaluating button hold time when moving to another tile in medium
    * hold state or above */
   if (button_behavior.counting && (button_behavior.hold_state >= MB_HOLD_MEDIUM)) {
     ptile = canvas_pos_to_tile(motion_event->x, motion_event->y,
@@ -595,21 +596,23 @@ bool FilterMouseMotionEvents(void *data, SDL_Event *event)
 /**********************************************************************//**
   SDL3-client main loop.
 **************************************************************************/
-Uint16 gui_event_loop(void *data,
-                      void (*loop_action)(void *data),
-                      Uint16 (*key_down_handler)(SDL_KeyboardEvent *key, void *data),
-                      Uint16 (*key_up_handler)(SDL_KeyboardEvent *key, void *data),
-                      Uint16 (*textinput_handler)(const char *text, void *data),
-                      Uint16 (*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data),
-                      Uint16 (*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data),
-                      Uint16 (*finger_motion_handler)(SDL_TouchFingerEvent *touch_event,
-                                                      void *data),
-                      Uint16 (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
+widget_id gui_event_loop(void *data,
+                         void (*loop_action)(void *data),
+                         widget_id (*key_down_handler)(SDL_KeyboardEvent *key, void *data),
+                         widget_id (*key_up_handler)(SDL_KeyboardEvent *key, void *data),
+                         widget_id (*textinput_handler)(const char *text, void *data),
+                         widget_id (*finger_down_handler)(SDL_TouchFingerEvent *touch_event,
                                                           void *data),
-                      Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
+                         widget_id (*finger_up_handler)(SDL_TouchFingerEvent *touch_event,
                                                         void *data),
-                      Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event,
-                                                     void *data))
+                         widget_id (*finger_motion_handler)(SDL_TouchFingerEvent *touch_event,
+                                                            void *data),
+                         widget_id (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
+                                                                void *data),
+                         widget_id (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
+                                                              void *data),
+                         widget_id (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event,
+                                                           void *data))
 {
   Uint16 ID;
   static fc_timeval tv;
diff --git a/client/gui-sdl3/gui_main.h b/client/gui-sdl3/gui_main.h
index b413e6801f..7514490ba0 100644
--- a/client/gui-sdl3/gui_main.h
+++ b/client/gui-sdl3/gui_main.h
@@ -69,6 +69,8 @@ struct theme;
   || ((event).type == SDL_EVENT_MOUSE_BUTTON_DOWN                           \
       && (event).button.button == SDL_BUTTON_LEFT))
 
+typedef Uint16 widget_id;
+
 enum mouse_button_hold_state {
   MB_HOLD_SHORT,
   MB_HOLD_MEDIUM,
@@ -109,20 +111,22 @@ void disable_focus_animation(void);
 extern int MOVE_STEP_X, MOVE_STEP_Y;
 bool FilterMouseMotionEvents(void *data, SDL_Event *event);
 
-Uint16 gui_event_loop(void *data, void (*loop_action)(void *data),
-                      Uint16 (*key_down_handler)(SDL_KeyboardEvent *key, void *data),
-                      Uint16 (*key_up_handler)(SDL_KeyboardEvent *key, void *data),
-                      Uint16 (*textinput_handler)(const char *text, void *data),
-                      Uint16 (*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data),
-                      Uint16 (*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data),
-                      Uint16 (*finger_motion_handler)(SDL_TouchFingerEvent *touch_event,
-                                                      void *data),
-                      Uint16 (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
+widget_id gui_event_loop(void *data, void (*loop_action)(void *data),
+                         widget_id (*key_down_handler)(SDL_KeyboardEvent *key, void *data),
+                         widget_id (*key_up_handler)(SDL_KeyboardEvent *key, void *data),
+                         widget_id (*textinput_handler)(const char *text, void *data),
+                         widget_id (*finger_down_handler)(SDL_TouchFingerEvent *touch_event,
                                                           void *data),
-                      Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
+                         widget_id (*finger_up_handler)(SDL_TouchFingerEvent *touch_event,
                                                         void *data),
-                      Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event,
-                                                     void *data));
+                         widget_id (*finger_motion_handler)(SDL_TouchFingerEvent *touch_event,
+                                                            void *data),
+                         widget_id (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
+                                                                void *data),
+                         widget_id (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
+                                                              void *data),
+                         widget_id (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event,
+                                                           void *data));
 
 unsigned default_font_size(struct theme *act_theme);
 void update_font_from_theme(int theme_font_size);
diff --git a/client/gui-sdl3/repodlgs.c b/client/gui-sdl3/repodlgs.c
index cef62d63cc..404125fae6 100644
--- a/client/gui-sdl3/repodlgs.c
+++ b/client/gui-sdl3/repodlgs.c
@@ -1191,17 +1191,17 @@ static int toggle_block_callback(struct widget *pcheckbox)
 /**********************************************************************//**
   User released mouse button while adjusting rates.
 **************************************************************************/
-static Uint16 report_scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
-                                            void *data)
+static widget_id report_scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
+                                               void *data)
 {
-  return (Uint16)ID_SCROLLBAR;
+  return (widget_id)ID_SCROLLBAR;
 }
 
 /**********************************************************************//**
   User moved a mouse while adjusting rates.
 **************************************************************************/
-static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
-                                                 void *data)
+static widget_id report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
+                                                    void *data)
 {
   struct rates_move *motion = (struct rates_move *)data;
   struct widget *tax_label = economy_dlg->end_widget_list->prev->prev;
@@ -1215,7 +1215,7 @@ static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_ev
       && (motion_event->x >= motion->min)
       && (motion_event->x <= motion->max)) {
 
-    /* set up directions */
+    /* Set up directions */
     if (motion_event->xrel > 0) {
       dir = 15;
       inc = 10;
@@ -1224,7 +1224,7 @@ static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_ev
       inc = -10;
     }
 
-    /* make checks */
+    /* Make checks */
     x = motion->horiz_src->size.x;
     if (((x + dir) <= motion->max) && ((x + dir) >= motion->min)) {
       /* src in range */
@@ -1253,7 +1253,7 @@ static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_ev
         }
       }
 
-      /* undraw scrollbars */
+      /* Undraw scrollbars */
       widget_undraw(motion->horiz_src);
       widget_mark_dirty(motion->horiz_src);
 
@@ -1275,14 +1275,14 @@ static Uint16 report_scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_ev
       fc_snprintf(cbuf, sizeof(cbuf), "%d%%", *motion->dst_rate);
       copy_chars_to_utf8_str(motion->label_dst->string_utf8, cbuf);
 
-      /* redraw label */
+      /* Redraw label */
       widget_redraw(motion->label_src);
       widget_mark_dirty(motion->label_src);
 
       widget_redraw(motion->label_dst);
       widget_mark_dirty(motion->label_dst);
 
-      /* redraw scrollbar */
+      /* Redraw scrollbar */
       if (get_wflags(motion->horiz_src) & WF_RESTORE_BACKGROUND) {
         refresh_widget_background(motion->horiz_src);
       }
diff --git a/client/gui-sdl3/widget.c b/client/gui-sdl3/widget.c
index 754aed6dd3..7902c573d6 100644
--- a/client/gui-sdl3/widget.c
+++ b/client/gui-sdl3/widget.c
@@ -578,7 +578,7 @@ struct widget *get_widget_pointer_from_main_list(Uint16 id)
 /**********************************************************************//**
   Add Widget to Main widgets list ( begin_widget_list )
 **************************************************************************/
-void add_to_gui_list(Uint16 id, struct widget *gui)
+void add_to_gui_list(widget_id id, struct widget *gui)
 {
   if (begin_main_widget_list != NULL) {
     gui->next = begin_main_widget_list;
diff --git a/client/gui-sdl3/widget.h b/client/gui-sdl3/widget.h
index ed935abae1..84fe477573 100644
--- a/client/gui-sdl3/widget.h
+++ b/client/gui-sdl3/widget.h
@@ -152,7 +152,7 @@ struct widget {
 
   SDL_Keycode key;              /* key aliased with this widget */
   Uint16 mod;			/* SHIFT, CTRL, ALT, etc */
-  Uint16 id;			/* id in widget list */
+  widget_id id;			/* id in widget list */
 
   int (*action) (struct widget *);	/* default callback action */
 
@@ -192,7 +192,7 @@ enum scan_direction {
   SCAN_BACKWARD
 };
 
-void add_to_gui_list(Uint16 id, struct widget *gui);
+void add_to_gui_list(widget_id id, struct widget *gui);
 void del_widget_pointer_from_gui_list(struct widget *gui);
 void widget_add_as_prev(struct widget *new_widget, struct widget *add_dock);
 
diff --git a/client/gui-sdl3/widget_edit.c b/client/gui-sdl3/widget_edit.c
index b0a4680dae..ed329a8cec 100644
--- a/client/gui-sdl3/widget_edit.c
+++ b/client/gui-sdl3/widget_edit.c
@@ -416,7 +416,7 @@ int draw_edit(struct widget *pedit, Sint16 start_x, Sint16 start_y)
   NOTE: This functions can return NULL in 'edit_widget->string_utf8->text' but
         never free 'edit_widget->string_utf8' struct.
 **************************************************************************/
-static Uint16 edit_key_down(SDL_KeyboardEvent *key, void *data)
+static widget_id edit_key_down(SDL_KeyboardEvent *key, void *data)
 {
   struct text_edit *edt = (struct text_edit *)data;
   struct utf8_char *input_chain_tmp;
@@ -570,7 +570,7 @@ static Uint16 edit_key_down(SDL_KeyboardEvent *key, void *data)
     break;
   default:
     break;
-  } /* key pressed switch */
+  } /* Key pressed switch */
 
   if (redraw) {
     redraw_edit_chain(edt);
@@ -582,7 +582,7 @@ static Uint16 edit_key_down(SDL_KeyboardEvent *key, void *data)
 /**********************************************************************//**
   Handle textinput strings coming to the edit widget
 **************************************************************************/
-static Uint16 edit_textinput(const char *text, void *data)
+static widget_id edit_textinput(const char *text, void *data)
 {
   struct text_edit *edt = (struct text_edit *)data;
   struct utf8_char *input_chain_tmp;
@@ -652,8 +652,8 @@ static Uint16 edit_textinput(const char *text, void *data)
 /**********************************************************************//**
   Handle mouse down events on edit widget.
 **************************************************************************/
-static Uint16 edit_mouse_button_down(SDL_MouseButtonEvent *button_event,
-                                     void *data)
+static widget_id edit_mouse_button_down(SDL_MouseButtonEvent *button_event,
+                                        void *data)
 {
   struct text_edit *edt = (struct text_edit *)data;
 
@@ -662,12 +662,12 @@ static Uint16 edit_mouse_button_down(SDL_MouseButtonEvent *button_event,
           && button_event->x < edt->pwidget->size.x + edt->bg->w
           && button_event->y >= edt->pwidget->size.y
           && button_event->y < edt->pwidget->size.y + edt->bg->h)) {
-      /* exit from loop */
-      return (Uint16)ED_MOUSE;
+      /* Exit from loop */
+      return (widget_id)ED_MOUSE;
     }
   }
 
-  return (Uint16)ID_ERROR;
+  return (widget_id)ID_ERROR;
 }
 
 /**********************************************************************//**
@@ -709,7 +709,7 @@ enum edit_return_codes edit_field(struct widget *edit_widget)
   edt.end_text_chain->next = NULL;
   edt.end_text_chain->prev = NULL;
 
-  /* set font style (if any ) */
+  /* Set font style (if any ) */
   if (!((edit_widget->string_utf8->style & 0x0F) & TTF_STYLE_NORMAL)) {
     TTF_SetFontStyle(edit_widget->string_utf8->font,
                      (edit_widget->string_utf8->style & 0x0F));
@@ -720,7 +720,7 @@ enum edit_return_codes edit_field(struct widget *edit_widget)
                              edt.end_text_chain->chr, 0,
                              edit_widget->string_utf8->fgcol);
 
-  /* create surface for each font in chain and find chain length */
+  /* Create surface for each font in chain and find chain length */
   if (edt.begin_text_chain) {
     input_chain_tmp = edt.begin_text_chain;
 
@@ -762,9 +762,9 @@ enum edit_return_codes edit_field(struct widget *edit_widget)
   set_wstate(edit_widget, FC_WS_PRESSED);
   {
     /* Local loop */
-    Uint16 rety = gui_event_loop((void *)&edt, NULL,
-                                 edit_key_down, NULL, edit_textinput, NULL, NULL, NULL,
-                                 edit_mouse_button_down, NULL, NULL);
+    widget_id rety = gui_event_loop((void *)&edt, NULL,
+                                    edit_key_down, NULL, edit_textinput, NULL, NULL, NULL,
+                                    edit_mouse_button_down, NULL, NULL);
 
     if (edt.begin_text_chain == edt.end_text_chain) {
       edt.begin_text_chain = NULL;
diff --git a/client/gui-sdl3/widget_scrollbar.c b/client/gui-sdl3/widget_scrollbar.c
index 291ef7dc63..73e6528b40 100644
--- a/client/gui-sdl3/widget_scrollbar.c
+++ b/client/gui-sdl3/widget_scrollbar.c
@@ -950,8 +950,8 @@ static void inside_scroll_up_loop(void *data)
 /**********************************************************************//**
   Handle mouse motion events of the vertical scrollbar event loop.
 **************************************************************************/
-static Uint16 scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
-                                          void *data)
+static widget_id scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
+                                             void *data)
 {
   struct up_down *motion = (struct up_down *)data;
   int yrel;
@@ -1038,10 +1038,10 @@ static Uint16 scroll_mouse_motion_handler(SDL_MouseMotionEvent *motion_event,
 /**********************************************************************//**
   Callback for scrollbar event loops' mouse up events.
 **************************************************************************/
-static Uint16 scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
-                                     void *data)
+static widget_id scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
+                                        void *data)
 {
-  return (Uint16)ID_SCROLLBAR;
+  return (widget_id)ID_SCROLLBAR;
 }
 
 /**********************************************************************//**
diff --git a/client/gui-sdl3/widget_window.c b/client/gui-sdl3/widget_window.c
index 67f21ff2b4..6e7a185375 100644
--- a/client/gui-sdl3/widget_window.c
+++ b/client/gui-sdl3/widget_window.c
@@ -300,8 +300,8 @@ bool resize_window(struct widget *pwindow, SDL_Surface *bcgd,
 /**********************************************************************//**
   Move window as event instructs.
 **************************************************************************/
-static Uint16 move_window_motion(SDL_MouseMotionEvent *motion_event,
-                                 void *data)
+static widget_id move_window_motion(SDL_MouseMotionEvent *motion_event,
+                                    void *data)
 {
   struct move *pmove = (struct move *)data;
   int xrel, yrel;
@@ -330,16 +330,16 @@ static Uint16 move_window_motion(SDL_MouseMotionEvent *motion_event,
 /**********************************************************************//**
   Button up event handler for the window moving event loop.
 **************************************************************************/
-static Uint16 move_window_button_up(SDL_MouseButtonEvent *button_event,
-                                    void *data)
+static widget_id move_window_button_up(SDL_MouseButtonEvent *button_event,
+                                       void *data)
 {
   struct move *pmove = (struct move *)data;
 
   if (pmove && pmove->moved) {
-    return (Uint16)ID_MOVED_WINDOW;
+    return (widget_id)ID_MOVED_WINDOW;
   }
 
-  return (Uint16)ID_WINDOW;
+  return (widget_id)ID_WINDOW;
 }
 
 /**********************************************************************//**
-- 
2.47.2

