more fixes from andrey

This commit is contained in:
Russ Cox 2007-01-17 00:26:51 +00:00
parent a25f83e3c5
commit 6fcd59e9ec

View File

@ -335,8 +335,8 @@ static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef
UInt32 class = GetEventClass (event); UInt32 class = GetEventClass (event);
UInt32 kind = GetEventKind (event); UInt32 kind = GetEventKind (event);
static uint32_t mousebuttons = 0; // bitmask of buttons currently down static uint32_t mousebuttons = 0; // bitmask of buttons currently down
static uint32_t mouseX = 0; // current mouse X position static uint32_t mouseX = 0;
static uint32_t mouseY = 0; // current mouse Y position static uint32_t mouseY = 0;
if(class == kEventClassKeyboard) { if(class == kEventClassKeyboard) {
char macCharCodes; char macCharCodes;
@ -353,31 +353,56 @@ static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef
case kEventRawKeyModifiersChanged: case kEventRawKeyModifiersChanged:
if (macKeyModifiers == (controlKey | optionKey)) leave_full_screen(); if (macKeyModifiers == (controlKey | optionKey)) leave_full_screen();
if(macKeyModifiers & optionKey) { switch(macKeyModifiers & (optionKey | cmdKey)) {
case (optionKey | cmdKey):
/* due to chording we need to handle the case when both
* modifier keys are pressed at the same time.
* currently it's only 2-3 snarf and the 3-2 noop
*/
altPressed = true; altPressed = true;
if(mousebuttons & 1) { if(mousebuttons & 1 || mousebuttons & 2 || mousebuttons & 4) {
mousebuttons |= 2; /* set button 2 */
mousebuttons |= 4; /* set button 3 */
button2 = true;
button3 = true;
sendbuttons(mousebuttons, mouseX, mouseY);
}
break;
case optionKey:
altPressed = true;
if(mousebuttons & 1 || mousebuttons & 4) {
mousebuttons |= 2; /* set button 2 */ mousebuttons |= 2; /* set button 2 */
button2 = true; button2 = true;
sendbuttons(mousebuttons, mouseX, mouseY); sendbuttons(mousebuttons, mouseX, mouseY);
} }
} else if(macKeyModifiers & cmdKey) { break;
if(mousebuttons & 1) { case cmdKey:
if(mousebuttons & 1 || mousebuttons & 2) {
mousebuttons |= 4; /* set button 3 */ mousebuttons |= 4; /* set button 3 */
button3 = true; button3 = true;
sendbuttons(mousebuttons, mouseX, mouseY); sendbuttons(mousebuttons, mouseX, mouseY);
} }
} else if(altPressed) { break;
kbdputc(kbdq, Kalt); case 0:
altPressed = false; default:
} else if(button2) { if(button2 || button3) {
if(button2) {
mousebuttons &= ~2; /* clear button 2 */ mousebuttons &= ~2; /* clear button 2 */
button2 = false; button2 = false;
sendbuttons(mousebuttons, mouseX, mouseY); altPressed = false;
} else if(button3) { }
if(button3) {
mousebuttons &= ~4; /* clear button 3 */ mousebuttons &= ~4; /* clear button 3 */
button3 = false; button3 = false;
}
sendbuttons(mousebuttons, mouseX, mouseY); sendbuttons(mousebuttons, mouseX, mouseY);
} }
if(altPressed) {
kbdputc(kbdq, Kalt);
altPressed = false;
}
break;
}
break; break;
case kEventRawKeyDown: case kEventRawKeyDown:
case kEventRawKeyRepeat: case kEventRawKeyRepeat: