Skip to content

Commit

Permalink
On X11, set all meta bits for arrow key events synthesized from mouse…
Browse files Browse the repository at this point in the history
… wheel

events to distingusih them from real arrow key events.  This is an attempt
at compatibility with the Mac.  The same approach might also be appropriate
on Windows.

Minor clean ups and added commentary.
  • Loading branch information
eliotmiranda committed Nov 7, 2018
1 parent fe517ee commit d964e74
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
12 changes: 4 additions & 8 deletions platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m
Expand Up @@ -41,11 +41,9 @@ Some of this code was funded via a grant from the European Smalltalk User Group
#import "sqSqueakOSXScreenAndWindow.h"
#import "sqMacHostWindow.h"
#import "sqSqueakOSXInfoPlistInterface.h"
#if defined(i386) || defined(__i386) || defined(__i386__)
#else
//Crashlytics code commented out; usefuil to those that use it...
//#import <Fabric/Fabric.h>
//#import <Crashlytics/Crashlytics.h>
#endif

#ifndef USE_CORE_GRAPHICS
# import "sqSqueakOSXOpenGLView.h"
Expand All @@ -71,13 +69,11 @@ - (void)applicationWillFinishLaunching:(NSNotification *)aNotification {
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

#if defined(i386) || defined(__i386) || defined(__i386__)
#else

//Crashlytics code commented out; usefuil to those that use it...
// [Crashlytics startWithAPIKey:@"add501476623fc20212a60334cd537d16dfd566f"];
//[Fabric with:@[[Crashlytics class]]];
#endif


@autoreleasepool {
gDelegateApp = self;
self.squeakApplication = [self makeApplicationInstance];
Expand Down
3 changes: 3 additions & 0 deletions platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m
Expand Up @@ -282,6 +282,9 @@ - (void) fakeMouseWheelKeyboardEventsKeyCode: (int) keyCode ascii: (int) ascii w
evt.charCode = keyCode;
evt.utf32Code = 0;
evt.reserved1 = 0;
/* Set every meta bit to distinguish the fake event from a real right/left
* arrow.
*/
evt.modifiers = (CtrlKeyBit | OptionKeyBit | CommandKeyBit | ShiftKeyBit);
evt.windowIndex = windowIndex;
[self pushEventToQueue:(sqInputEvent *) &evt];
Expand Down
7 changes: 5 additions & 2 deletions platforms/unix/vm-display-X11/sqUnixX11.c
Expand Up @@ -3684,8 +3684,11 @@ static void handleEvent(XEvent *evt)
break;
case 4: case 5: case 6: case 7: /* mouse wheel */
{
int keyCode= mouseWheel2Squeak[evt->xbutton.button - 4];
int modifiers= modifierState ^ CtrlKeyBit;
int keyCode = mouseWheel2Squeak[evt->xbutton.button - 4];
/* Set every meta bit to distinguish the fake event from a real
* right/left arrow.
*/
int modifiers = modifierState | CtrlKeyBit | OptionKeyBit | CommandKeyBit | ShiftKeyBit);
recordKeyboardEvent(keyCode, EventKeyDown, modifiers, keyCode);
recordKeyboardEvent(keyCode, EventKeyChar, modifiers, keyCode);
recordKeyboardEvent(keyCode, EventKeyUp, modifiers, keyCode);
Expand Down
13 changes: 10 additions & 3 deletions platforms/win32/vm/sqWin32Window.c
Expand Up @@ -258,15 +258,22 @@ LRESULT CALLBACK MainWndProcW(HWND hwnd,
/* RvL 1999-04-19 00:23
MOUSE WHEELING START */
if( WM_MOUSEWHEEL == message || g_WM_MOUSEWHEEL == message ) {
/* Record mouse wheel msgs as CTRL-Up/Down */
/* Record mouse wheel msgs as CTRL-Up/Down.
* N.B. On iOS & X11 we also handle horizonal mouse wheel events.
* Should the same happen here?
*/
short zDelta = (short) HIWORD(wParam);
if(inputSemaphoreIndex) {
sqKeyboardEvent *evt = (sqKeyboardEvent*) sqNextEventPut();
evt->type = EventTypeKeyboard;
evt->timeStamp = lastMessage->time;
evt->charCode = (zDelta > 0) ? 30 : 31;
evt->pressCode = EventKeyChar;
/* N.B. on iOS & X11 all meta bits are set to distinguish mouse wheel
* events from real arrow key events. Should the same happen here?
*/
evt->modifiers = CtrlKeyBit;
/* It would be good if this were set in the SqueakVM also, no? */
#ifdef PharoVM
evt->utf32Code = evt->charCode;
#else
Expand Down Expand Up @@ -873,7 +880,7 @@ sqInt ioIsWindowObscured(void) {

/* Check whether any windows in front of this window overlap */
hwnd = stWindow;
while(hwnd = GetNextWindow(hwnd, GW_HWNDPREV)) {
while ((hwnd = GetNextWindow(hwnd, GW_HWNDPREV))) {

if(!IsWindowVisible(hwnd)) continue; /* skip invisible windows */

Expand Down Expand Up @@ -2570,7 +2577,7 @@ sqInt ioShowDisplay(sqInt dispBits, sqInt width, sqInt height, sqInt depth,

if(lines == 0) {
printLastError(TEXT("SetDIBitsToDevice failed"));
warnPrintf(TEXT("width=%") TEXT(PRIdSQINT) TEXT(",height=%") TEXT(PRIdSQINT) TEXT(",bits=%") TEXT(PRIXSQINT) TEXT(",dc=%") TEXT(PRIXSQINT) TEXT("\n"),
warnPrintf(TEXT("width=%" PRIdSQINT ",height=%" PRIdSQINT ",bits=%" PRIXSQINT ",dc=%" PRIXSQPTR "\n"),

This comment has been minimized.

Copy link
@nicolas-cellier-aka-nice

nicolas-cellier-aka-nice Jun 10, 2019

Contributor

Err, isn't it a regression?
The TEXT macro must not be used with TEXT(string1 string2) but rather TEXT(string1) TEXT(string2), otherwise it will mix byte and wide string.

This comment has been minimized.

Copy link
@krono

krono Jun 10, 2019

Member

It is.

This comment has been minimized.

Copy link
@nicolas-cellier-aka-nice

nicolas-cellier-aka-nice Jun 12, 2019

Contributor

Never mind, it's already fixed

width, height, dispBits,(usqIntptr_t)dc);
}
/* reverse the image bits if necessary */
Expand Down

0 comments on commit d964e74

Please sign in to comment.