# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1627072016 0 # Node ID 156ad91481eba4045bb9090668a30e51c37e821e # Parent d17e3fb76bdec621e3b8e5e0291bf64822e360b9 WARNING: Standardize button press and release button parameter values. This may break existing code using 3rd mouse button press/release events. The motion callback and OS/2 had been passing the 3rd mouse button as value 4. Other platforms were passing it as value 3. Since button/press and release events only have a single button values 1,2,3 were unique... but OS/2 was passing the mask value instead, making these not work cross platform. I decided to make the button press/release and motion events all function the same. Passing the mask values instead of button numbers. This change will only affect button 3 on button press or release events on Windows, Mac and GTK. OS/2 already functioned this way, iOS and Android do not support button 3. diff -r d17e3fb76bde -r 156ad91481eb gtk/dw.c --- a/gtk/dw.c Fri Jul 23 19:42:06 2021 +0000 +++ b/gtk/dw.c Fri Jul 23 20:26:56 2021 +0000 @@ -1296,12 +1296,12 @@ if(work.window) { int (*buttonfunc)(HWND, int, int, int, void *) = work.func; - int mybutton = event->button; + int mybutton = DW_BUTTON1_MASK; if(event->button == 3) - mybutton = 2; + mybutton = DW_BUTTON2_MASK; else if(event->button == 2) - mybutton = 3; + mybutton = DW_BUTTON3_MASK; retval = buttonfunc(work.window, event->x, event->y, mybutton, work.data); } @@ -1317,12 +1317,12 @@ if(work.window) { int (*buttonfunc)(HWND, int, int, int, void *) = work.func; - int mybutton = event->button; + int mybutton = DW_BUTTON1_MASK; if(event->button == 3) - mybutton = 2; + mybutton = DW_BUTTON2_MASK; else if(event->button == 2) - mybutton = 3; + mybutton = DW_BUTTON3_MASK; retval = buttonfunc(work.window, event->x, event->y, mybutton, work.data); } diff -r d17e3fb76bde -r 156ad91481eb gtk3/dw.c --- a/gtk3/dw.c Fri Jul 23 19:42:06 2021 +0000 +++ b/gtk3/dw.c Fri Jul 23 20:26:56 2021 +0000 @@ -1360,12 +1360,12 @@ if(work.window) { int (*buttonfunc)(HWND, int, int, int, void *) = work.func; - int mybutton = event->button; + int mybutton = DW_BUTTON1_MASK; if(event->button == 3) - mybutton = 2; + mybutton = DW_BUTTON2_MASK; else if(event->button == 2) - mybutton = 3; + mybutton = DW_BUTTON3_MASK; retval = buttonfunc(work.window, event->x, event->y, mybutton, work.data); } @@ -1380,12 +1380,12 @@ if(work.window) { int (*buttonfunc)(HWND, int, int, int, void *) = work.func; - int mybutton = event->button; + int mybutton = DW_BUTTON3_MASK; if(event->button == 3) - mybutton = 2; + mybutton = DW_BUTTON2_MASK; else if(event->button == 2) - mybutton = 3; + mybutton = DW_BUTTON3_MASK; retval = buttonfunc(work.window, event->x, event->y, mybutton, work.data); } diff -r d17e3fb76bde -r 156ad91481eb gtk4/dw.c --- a/gtk4/dw.c Fri Jul 23 19:42:06 2021 +0000 +++ b/gtk4/dw.c Fri Jul 23 20:26:56 2021 +0000 @@ -717,9 +717,9 @@ int mybutton = gtk_gesture_single_get_current_button(gesture); if(mybutton == 3) - mybutton = 2; + mybutton = DW_BUTTON2_MASK; else if(mybutton == 2) - mybutton = 3; + mybutton = DW_BUTTON3_MASK; retval = buttonfunc(work.window, (int)x, (int)y, mybutton, work.data); } @@ -737,9 +737,9 @@ int mybutton = gtk_gesture_single_get_current_button(gesture); if(mybutton == 3) - mybutton = 2; + mybutton = DW_BUTTON2_MASK; else if(mybutton == 2) - mybutton = 3; + mybutton = DW_BUTTON3_MASK; retval = buttonfunc(work.window, (int)x, (int)y, mybutton, work.data); } diff -r d17e3fb76bde -r 156ad91481eb mac/dw.m --- a/mac/dw.m Fri Jul 23 19:42:06 2021 +0000 +++ b/mac/dw.m Fri Jul 23 20:26:56 2021 +0000 @@ -623,7 +623,7 @@ { int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; NSPoint p = [NSEvent mouseLocation]; - int button = 1; + int button = DW_BUTTON1_MASK; if([event isMemberOfClass:[NSEvent class]]) { @@ -634,15 +634,15 @@ if(type == DWEventTypeRightMouseDown || type == DWEventTypeRightMouseUp) { - button = 2; + button = DW_BUTTON2_MASK; } else if(type == DWEventTypeOtherMouseDown || type == DWEventTypeOtherMouseUp) { - button = 3; + button = DW_BUTTON3_MASK; } else if([event modifierFlags] & DWEventModifierFlagControl) { - button = 2; + button = DW_BUTTON2_MASK; } } diff -r d17e3fb76bde -r 156ad91481eb win/dw.c --- a/win/dw.c Fri Jul 23 19:42:06 2021 +0000 +++ b/win/dw.c Fri Jul 23 20:26:56 2021 +0000 @@ -2320,13 +2320,13 @@ switch(origmsg) { case WM_LBUTTONDOWN: - button = 1; + button = DW_BUTTON1_MASK; break; case WM_RBUTTONDOWN: - button = 2; + button = DW_BUTTON2_MASK; break; case WM_MBUTTONDOWN: - button = 3; + button = DW_BUTTON3_MASK; break; } if(taskbar) @@ -2355,13 +2355,13 @@ switch(origmsg) { case WM_LBUTTONUP: - button = 1; + button = DW_BUTTON1_MASK; break; case WM_RBUTTONUP: - button = 2; + button = DW_BUTTON2_MASK; break; case WM_MBUTTONUP: - button = 3; + button = DW_BUTTON3_MASK; break; } if(taskbar)