From c62ee2d3497cac9db7fecaf1149987f8964709d6 Mon Sep 17 00:00:00 2001
From: Aaron Bolyard <aaron@commaexcess.com>
Date: Mon, 3 Feb 2014 23:34:26 -0500
Subject: [PATCH] Added LRESULT argument to WindowProc callback

---
 addons/native_dialog/win_dialog.c   | 3 ++-
 include/allegro5/allegro_windows.h  | 4 ++--
 include/allegro5/platform/aintwin.h | 2 +-
 src/win/wwindow.c                   | 9 +++++----
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/addons/native_dialog/win_dialog.c b/addons/native_dialog/win_dialog.c
index 200c5f4..34b9fd3 100644
--- a/addons/native_dialog/win_dialog.c
+++ b/addons/native_dialog/win_dialog.c
@@ -645,9 +645,10 @@ void _al_append_native_text_log(ALLEGRO_NATIVE_DIALOG *textlog)
 }
 
 static bool menu_callback(ALLEGRO_DISPLAY *display, UINT msg, WPARAM wParam, LPARAM lParam,
-                             void *userdata)
+                             LPARAM* result, void *userdata)
 {
    (void) userdata;
+   *result = 0;
 
    if (msg == WM_COMMAND && lParam == 0) {
       const int id = LOWORD(wParam);
diff --git a/include/allegro5/allegro_windows.h b/include/allegro5/allegro_windows.h
index c45250a..9a48762 100644
--- a/include/allegro5/allegro_windows.h
+++ b/include/allegro5/allegro_windows.h
@@ -29,9 +29,9 @@
 
 AL_FUNC(HWND, al_get_win_window_handle,      (ALLEGRO_DISPLAY *));
 AL_FUNC(bool, al_win_add_window_callback,    (ALLEGRO_DISPLAY *,
-   bool (*)(ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM, void *), void *userdata));
+   bool (*)(ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM, LRESULT*, void *), void *userdata));
 AL_FUNC(bool, al_win_remove_window_callback, (ALLEGRO_DISPLAY *,
-   bool (*)(ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM, void *), void *userdata));
+   bool (*)(ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM, LRESULT*, void *), void *userdata));
 
 #ifdef __cplusplus
    }
diff --git a/include/allegro5/platform/aintwin.h b/include/allegro5/platform/aintwin.h
index 8484fef..eadf5b0 100644
--- a/include/allegro5/platform/aintwin.h
+++ b/include/allegro5/platform/aintwin.h
@@ -44,7 +44,7 @@
 /* user defined hooks into the main win32 event loop */
 
 typedef bool (*ALLEGRO_DISPLAY_WIN_CALLBACK_PROC)
-   (ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM, void *);
+   (ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM, LRESULT*, void *);
 
 typedef struct ALLEGRO_DISPLAY_WIN_CALLBACK ALLEGRO_DISPLAY_WIN_CALLBACK;
 
diff --git a/src/win/wwindow.c b/src/win/wwindow.c
index 5ea7efc..6a32ce5 100644
--- a/src/win/wwindow.c
+++ b/src/win/wwindow.c
@@ -421,9 +421,10 @@ static LRESULT CALLBACK window_callback(HWND hWnd, UINT message,
    }
 
    for (i = 0; i < _al_vector_size(&win_display->msg_callbacks); ++i) {
+      LRESULT result;
       ALLEGRO_DISPLAY_WIN_CALLBACK *ptr = _al_vector_ref(&win_display->msg_callbacks, i);
-      if ((ptr->proc)(d, message, wParam, lParam, ptr->userdata))
-         return TRUE;
+      if ((ptr->proc)(d, message, wParam, lParam, &result, ptr->userdata))
+         return result;
    }
 
    switch (message) {
@@ -1290,7 +1291,7 @@ int _al_win_determine_adapter(void)
 /* Function: al_win_add_window_callback
  */
 bool al_win_add_window_callback(ALLEGRO_DISPLAY *display,
-   bool (*callback)(ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM, void *), void *userdata)
+   bool (*callback)(ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM, LRESULT*, void *), void *userdata)
 {
    ALLEGRO_DISPLAY_WIN *win_display = (ALLEGRO_DISPLAY_WIN *) display;
    ALLEGRO_DISPLAY_WIN_CALLBACK *ptr;
@@ -1318,7 +1319,7 @@ bool al_win_add_window_callback(ALLEGRO_DISPLAY *display,
 /* Function: al_win_remove_window_callback
  */
 bool al_win_remove_window_callback(ALLEGRO_DISPLAY *display,
-   bool (*callback)(ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM, void *), void *userdata)
+   bool (*callback)(ALLEGRO_DISPLAY *, UINT, WPARAM, LPARAM, LRESULT*, void *), void *userdata)
 {
    ALLEGRO_DISPLAY_WIN *win_display = (ALLEGRO_DISPLAY_WIN *) display;
    
-- 
1.8.3.msysgit.0

