Mingw-32 compile issue with new 4/5 mousebutton hooks (fltk-1.4)

15 views
Skip to first unread message

imacarthur

unread,
Oct 7, 2024, 6:15:23 AM10/7/24
to fltk.coredev
On the head of fltk-1.4, building with mingw32 seems to be currently breaking, over the new support for mouse buttons 4 and 5, I think.

The same repo., compiled with mingw64 seems to be fine (ditto MSVC).

The crux seems to be that the version of winuser.h shipped with mingw32 looks to be pretty old, and in any case appears to be missing the definition of GET_XBUTTON_WPARAM.

Here's the console output:

Consolidate compiler generated dependencies of target fltk
[ 13%] Building CXX object src/CMakeFiles/fltk.dir/Fl_win32.cxx.obj
d:/Tools/Ian/fltk-1.4/src/Fl_win32.cxx: In function 'LRESULT WndProc(HWND, UINT, WPARAM, LPARAM)':
d:/Tools/Ian/fltk-1.4/src/Fl_win32.cxx:1355:23: error: 'GET_XBUTTON_WPARAM' was not declared in this scope
 1355 |         int xbutton = GET_XBUTTON_WPARAM(wParam) == XBUTTON1 ? 4 : 5;
      |                       ^~~~~~~~~~~~~~~~~~
d:/Tools/Ian/fltk-1.4/src/Fl_win32.cxx:1360:23: error: 'GET_XBUTTON_WPARAM' was not declared in this scope
 1360 |         int xbutton = GET_XBUTTON_WPARAM(wParam) == XBUTTON1 ? 4 : 5;
      |                       ^~~~~~~~~~~~~~~~~~
d:/Tools/Ian/fltk-1.4/src/Fl_win32.cxx:1365:23: error: 'GET_XBUTTON_WPARAM' was not declared in this scope
 1365 |         int xbutton = GET_XBUTTON_WPARAM(wParam) == XBUTTON1 ? 4 : 5;
      |                       ^~~~~~~~~~~~~~~~~~
make[2]: *** [src/CMakeFiles/fltk.dir/Fl_win32.cxx.obj] Error 1
make[1]: *** [src/CMakeFiles/fltk.dir/all] Error 2
make: *** [all] Error 2


This was with gcc version 9.2.0 (MinGW.org GCC Build-2)  but I tried another (older) mingw32 also (MinGW.org GCC-6.3.0-1) and it is the same (the winuser.h files seem to be similarly "out of date".)

The actual definition of GET_XBUTTON_WPARAM seems to be:

#define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))

So I wonder if we can just call HIWORD(wParam) in our code instead (perhaps with suitable explanatory comment) to duck this issue with winuser,h being out of date?


imm

unread,
Oct 7, 2024, 6:51:09 AM10/7/24
to fltkc...@googlegroups.com
On Mon, 7 Oct 2024 at 11:15, imacarthur wrote:
> The actual definition of GET_XBUTTON_WPARAM seems to be:
>
> #define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
>
> So I wonder if we can just call HIWORD(wParam) in our code instead (perhaps with suitable explanatory comment) to duck this issue with winuser,h being out of date?

FWIW, I tried this and it appears to work OK (in that the code
compiles with mingw32, and still OK with mingw64, MSVC.)
(That said, I don't have a 5 button mouse so I don't actually know if
any of this _works_ at all!)

I'm reluctant to push that change though, in case there's some better
way to get to the right result...

Albrecht Schlosser

unread,
Oct 7, 2024, 11:27:27 AM10/7/24
to fltkc...@googlegroups.com
On 10/7/24 12:15 imacarthur wrote:
> On the head of fltk-1.4, building with mingw32 seems to be currently
> breaking, over the new support for mouse buttons 4 and 5, I think.

Thanks, Ian, for the report.

> The same repo., compiled with mingw64 seems to be fine (ditto MSVC).
>
> The crux seems to be that the version of winuser.h shipped with
> mingw32 looks to be pretty old, and in any case appears to be missing
> the definition of GET_XBUTTON_WPARAM.

That's bad. I assume I didn't test with mingw32  :-(

> The actual definition of GET_XBUTTON_WPARAM seems to be:
>
> #define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
>
> So I wonder if we can just call HIWORD(wParam) in our code instead
> (perhaps with suitable explanatory comment) to duck this issue with
> winuser,h being out of date?

Since GET_XBUTTON_WPARAM is a macro, would it make sense to define it
ourselves if it is not defined, something like

#ifndef GET_XBUTTON_WPARAM
#define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
#endif

Can you please test if this fixes it in your constellation?

I'll check if I can reproduce the issue on my VM with mingw32...

Albrecht Schlosser

unread,
Oct 7, 2024, 11:46:36 AM10/7/24
to fltkc...@googlegroups.com
Tested with my MinGW installation, and I could reproduce the issue.
This diff fixes it (and works well at runtime):
```
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 06e9d5eee..adaf598c6 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -90,6 +90,12 @@ void fl_cleanup_dc_list(void);
 # include <wchar.h>
 #endif

+// old versions of MinGW lack definition of GET_XBUTTON_WPARAM:
+
+#ifndef GET_XBUTTON_WPARAM
+#define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
+#endif
+
 static bool is_dpi_aware = false;

 extern bool fl_clipboard_notify_empty(void);
```

Ian, can you confirm, and would you like me to commit it?

imm

unread,
Oct 7, 2024, 11:57:19 AM10/7/24
to fltkc...@googlegroups.com
Yes, confirmed; patch works for me here, too.

Go ahead with the commit!

Cheers...

Albrecht Schlosser

unread,
Oct 7, 2024, 12:17:46 PM10/7/24
to fltkc...@googlegroups.com
On 10/7/24 18:05 imm wrote:
This diff fixes it (and works well at runtime):
```

diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 06e9d5eee..adaf598c6 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -90,6 +90,12 @@ void fl_cleanup_dc_list(void);
 # include <wchar.h>
 #endif

+// old versions of MinGW lack definition of GET_XBUTTON_WPARAM:
+
+#ifndef GET_XBUTTON_WPARAM
+#define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
+#endif
+
 static bool is_dpi_aware = false;

 extern bool fl_clipboard_notify_empty(void);

```

Ian, can you confirm, and would you like me to commit it?
Yes, confirmed; patch works for me here, too.

Go ahead with the commit!

Thanks, done in commit 475bfa92308b52d6fc307f376d617697f8d95ae2.
Cheers...

Have a nice day...

Reply all
Reply to author
Forward
0 new messages