Opened 18 months ago

Last modified 6 months ago

#99 accepted defect

Strange set key behavior

Reported by: HoraK-FDF@… Owned by: Thomas Bernard
Priority: major Milestone: 2.8
Component: GrafX2 Version: 2.6
Keywords: Cc:



the version I'm using is from the download page.

If i try to set keys it displays a wrong key but the desired key works as intended for example:

if press Up it shows Shift+PgDn?, that kind of behavior is true for many other keys:
Left -> Alt+Shift+' '
Right -> Alt+Shift+PgDn?

... greetings HoraK-FDF

Change History (13)

comment:1 Changed 18 months ago by Thomas Bernard

thanks for the report, I will check that.

comment:2 Changed 18 months ago by Thomas Bernard

Owner: changed from pulkomandy to Thomas Bernard
Status: newaccepted

comment:3 Changed 18 months ago by HoraK-FDF@…

It does not happen with

comment:4 Changed 18 months ago by Thomas Bernard

OK I think that is because we use MOD_SHIFT/MOD_ALT_/MOD_CTRL which are defined in WinUser.h :

#define MOD_ALT         0x0001
#define MOD_CONTROL     0x0002
#define MOD_SHIFT       0x0004

it conflicts with our own definitions in global.h

Up has win32 keycode 0x26 which is 0x4 (SHIFT) + 0x22 (Page Down)

comment:6 Changed 18 months ago by Thomas Bernard

safe and long term solution is to rename MOD_SHIFT, etc. to a private name such as GFX2_MOD_SHIFT, etc.

comment:7 Changed 18 months ago by yrizoud@…

<windows.h> pollutes the global namespace a lot, I think it would be better to minimize the number of .C files that include it.

comment:8 Changed 18 months ago by Thomas Bernard

@yrizoud: here is what I propose to do :

  1. merge as a quick fix for v2.6
  1. wait v2.7wip to apply the patch

which rename MOD_* to GFX2_MOD_* so there is no more clash

comment:9 Changed 18 months ago by yrizoud@…

Yes I agree with both changes as a short- and long-term fix for these modifiers. But I still think that (microsoft's) windows.h is going to collide with more stuff in the future.
The current coding conventions helps avoid a lot of conflicts (T_Struct for most structs, capitalized Function() etc. but (from a quick look at MS docs in search of examples) you can easily collide common names such as #define INPUT (reserved by a typdefed struct) or if you try to call a parameter or local variable "mouse_event" (reserved by an obsolete function)

comment:10 Changed 18 months ago by PulkoMandy

For Haiku I moved all the platform specific code to haiku.cpp as it is written in C++.
I would recommend doing the same for other platform specific parts: define our API, and move its implementation to a specific file. This would avoid including windows.h anywhere outside this specific file.

comment:11 Changed 18 months ago by Thomas Bernard

I have created a specific ticket for <windows.h> name pollution :

comment:12 Changed 18 months ago by Thomas Bernard

comment:13 Changed 6 months ago by PulkoMandy

Milestone: 2.8
Note: See TracTickets for help on using tickets.