Fixed keyboard state sync.

This commit is contained in:
Armin Novak 2017-11-20 11:46:32 +01:00
parent feda4e07df
commit 3ce9d6d923
3 changed files with 24 additions and 4 deletions

View File

@ -557,6 +557,7 @@ DWORD fixKeyCode(DWORD keyCode, unichar keyChar, enum APPLE_KEYBOARD_TYPE type)
"keyDown: keyCode: 0x%04X scancode: 0x%04X vkcode: 0x%04X keyFlags: %d name: %s",
keyCode, scancode, vkcode, keyFlags, GetVirtualKeyName(vkcode));
#endif
sync_keyboard_state(instance);
freerdp_input_send_keyboard_event(instance->input, keyFlags, scancode);
}
@ -1340,5 +1341,22 @@ void windows_to_apple_cords(MRDPView* view, NSRect* r)
r->origin.y = [view frame].size.height - (r->origin.y + r->size.height);
}
void sync_keyboard_state(freerdp *instance) {
mfContext* context = (mfContext*)instance->context;
UINT32 flags = 0;
CGEventFlags currentFlags = CGEventSourceFlagsState(kCGEventSourceStateHIDSystemState);
if (context->kbdFlags != currentFlags)
{
if (currentFlags & kCGEventFlagMaskAlphaShift)
flags |= KBD_SYNC_CAPS_LOCK;
if (currentFlags & kCGEventFlagMaskNumericPad)
flags |= KBD_SYNC_NUM_LOCK;
freerdp_input_send_synchronize_event(instance->input, flags);
context->kbdFlags = currentFlags;
}
}
@end

View File

@ -90,7 +90,7 @@ static BOOL mfreerdp_client_new(freerdp* instance, rdpContext* context)
context->instance->PostConnect = mac_post_connect;
context->instance->Authenticate = mac_authenticate;
settings = instance->settings;
settings->AsyncTransport = TRUE;
settings->AsyncTransport = FALSE;
settings->AsyncUpdate = TRUE;
settings->AsyncInput = TRUE;
return TRUE;
@ -128,7 +128,7 @@ static void freerdp_client_mouse_event(rdpContext* cfc, DWORD flags, int x,
if (y >= height)
y = height - 1;
input->MouseEvent(input, flags, x, y);
freerdp_input_send_mouse_event(input, flags, x, y);
}
void mf_scale_mouse_event(void* context, rdpInput* input, UINT16 flags,
@ -153,12 +153,12 @@ void mf_scale_mouse_event(void* context, rdpInput* input, UINT16 flags,
y -= (dh - wh);
}
input->MouseEvent(input, flags, x + mfc->xCurrentScroll, y);
freerdp_input_send_mouse_event(input, flags, x + mfc->xCurrentScroll, y);
}
else
{
y = y * dh / wh + mfc->yCurrentScroll;
input->MouseEvent(input, flags, x * dw / ww + mfc->xCurrentScroll, y);
freerdp_input_send_mouse_event(input, flags, x * dw / ww + mfc->xCurrentScroll, y);
}
}

View File

@ -84,6 +84,8 @@ struct mf_context
int yMinScroll; // minimum vertical scroll value
int yCurrentScroll; // current vertical scroll value
int yMaxScroll; // maximum vertical scroll value
CGEventFlags kbdFlags;
};
#endif /* FREERDP_CLIENT_MAC_FREERDP_H */