mirror of
https://github.com/0intro/conterm
synced 2024-11-22 05:41:28 +03:00
fixes from Andrey
This commit is contained in:
parent
e8b1d5b0dd
commit
a25f83e3c5
@ -64,6 +64,8 @@ static PasteboardRef appleclip;
|
|||||||
static _Rect winRect;
|
static _Rect winRect;
|
||||||
|
|
||||||
Boolean altPressed = false;
|
Boolean altPressed = false;
|
||||||
|
Boolean button2 = false;
|
||||||
|
Boolean button3 = false;
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -242,7 +244,7 @@ static inline int convert_key(UInt32 key, UInt32 charcode)
|
|||||||
case QZ_RIGHT: return Kright;
|
case QZ_RIGHT: return Kright;
|
||||||
case QZ_KP_MULTIPLY: return '*';
|
case QZ_KP_MULTIPLY: return '*';
|
||||||
case QZ_KP_DIVIDE: return '/';
|
case QZ_KP_DIVIDE: return '/';
|
||||||
case QZ_KP_ENTER: return '\b';
|
case QZ_KP_ENTER: return '\n';
|
||||||
case QZ_KP_PERIOD: return '.';
|
case QZ_KP_PERIOD: return '.';
|
||||||
case QZ_KP0: return '0';
|
case QZ_KP0: return '0';
|
||||||
case QZ_KP1: return '1';
|
case QZ_KP1: return '1';
|
||||||
@ -332,7 +334,9 @@ static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef
|
|||||||
result = CallNextEventHandler(nextHandler, event);
|
result = CallNextEventHandler(nextHandler, event);
|
||||||
UInt32 class = GetEventClass (event);
|
UInt32 class = GetEventClass (event);
|
||||||
UInt32 kind = GetEventKind (event);
|
UInt32 kind = GetEventKind (event);
|
||||||
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 mouseY = 0; // current mouse Y position
|
||||||
|
|
||||||
if(class == kEventClassKeyboard) {
|
if(class == kEventClassKeyboard) {
|
||||||
char macCharCodes;
|
char macCharCodes;
|
||||||
@ -351,9 +355,28 @@ static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef
|
|||||||
|
|
||||||
if(macKeyModifiers & optionKey) {
|
if(macKeyModifiers & optionKey) {
|
||||||
altPressed = true;
|
altPressed = true;
|
||||||
|
if(mousebuttons & 1) {
|
||||||
|
mousebuttons |= 2; /* set button 2 */
|
||||||
|
button2 = true;
|
||||||
|
sendbuttons(mousebuttons, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
} else if(macKeyModifiers & cmdKey) {
|
||||||
|
if(mousebuttons & 1) {
|
||||||
|
mousebuttons |= 4; /* set button 3 */
|
||||||
|
button3 = true;
|
||||||
|
sendbuttons(mousebuttons, mouseX, mouseY);
|
||||||
|
}
|
||||||
} else if(altPressed) {
|
} else if(altPressed) {
|
||||||
kbdputc(kbdq, Kalt);
|
kbdputc(kbdq, Kalt);
|
||||||
altPressed = false;
|
altPressed = false;
|
||||||
|
} else if(button2) {
|
||||||
|
mousebuttons &= ~2; /* clear button 2 */
|
||||||
|
button2 = false;
|
||||||
|
sendbuttons(mousebuttons, mouseX, mouseY);
|
||||||
|
} else if(button3) {
|
||||||
|
mousebuttons &= ~4; /* clear button 3 */
|
||||||
|
button3 = false;
|
||||||
|
sendbuttons(mousebuttons, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kEventRawKeyDown:
|
case kEventRawKeyDown:
|
||||||
@ -380,9 +403,9 @@ static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef
|
|||||||
int32_t wheeldelta;
|
int32_t wheeldelta;
|
||||||
GetEventParameter(event,kEventParamMouseWheelDelta,typeSInt32,
|
GetEventParameter(event,kEventParamMouseWheelDelta,typeSInt32,
|
||||||
0,sizeof(wheeldelta), 0, &wheeldelta);
|
0,sizeof(wheeldelta), 0, &wheeldelta);
|
||||||
sendbuttons(wheeldelta>0 ? 8 : 16,
|
mouseX = mousePos.h - winRect.left;
|
||||||
mousePos.h - winRect.left,
|
mouseY = mousePos.v - winRect.top;
|
||||||
mousePos.v - winRect.top);
|
sendbuttons(wheeldelta>0 ? 8 : 16, mouseX, mouseY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kEventMouseUp:
|
case kEventMouseUp:
|
||||||
@ -392,8 +415,8 @@ static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef
|
|||||||
uint32_t modifiers;
|
uint32_t modifiers;
|
||||||
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32,
|
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32,
|
||||||
0, sizeof(modifiers), 0, &modifiers);
|
0, sizeof(modifiers), 0, &modifiers);
|
||||||
GetEventParameter(event, kEventParamMouseChord,
|
GetEventParameter(event, kEventParamMouseChord, typeUInt32,
|
||||||
typeUInt32, 0, sizeof buttons, 0, &buttons);
|
0, sizeof buttons, 0, &buttons);
|
||||||
/* simulate other buttons via alt/apple key. like x11 */
|
/* simulate other buttons via alt/apple key. like x11 */
|
||||||
if(modifiers & optionKey) {
|
if(modifiers & optionKey) {
|
||||||
mousebuttons = ((buttons & 1) ? 2 : 0);
|
mousebuttons = ((buttons & 1) ? 2 : 0);
|
||||||
@ -409,9 +432,9 @@ static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef
|
|||||||
} /* Fallthrough */
|
} /* Fallthrough */
|
||||||
case kEventMouseMoved:
|
case kEventMouseMoved:
|
||||||
case kEventMouseDragged:
|
case kEventMouseDragged:
|
||||||
sendbuttons(mousebuttons,
|
mouseX = mousePos.h - winRect.left;
|
||||||
mousePos.h - winRect.left,
|
mouseY = mousePos.v - winRect.top;
|
||||||
mousePos.v - winRect.top);
|
sendbuttons(mousebuttons, mouseX, mouseY);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = eventNotHandledErr;
|
result = eventNotHandledErr;
|
||||||
|
Loading…
Reference in New Issue
Block a user