X11rdp: input delay motion

This commit is contained in:
Jay Sorg 2013-08-16 22:23:09 -07:00
parent fa40106a69
commit ee98f1cdd4

View File

@ -44,6 +44,12 @@ keyboard and mouse stuff
#define DEBUG_OUT_INPUT(arg) ErrorF arg #define DEBUG_OUT_INPUT(arg) ErrorF arg
#endif #endif
#define LOG_LEVEL 1
#define LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern ScreenPtr g_pScreen; /* in rdpmain.c */ extern ScreenPtr g_pScreen; /* in rdpmain.c */
extern DeviceIntPtr g_pointer; /* in rdpmain.c */ extern DeviceIntPtr g_pointer; /* in rdpmain.c */
extern DeviceIntPtr g_keyboard; /* in rdpmain.c */ extern DeviceIntPtr g_keyboard; /* in rdpmain.c */
@ -59,6 +65,12 @@ static int g_tab_down = 0;
above *_down vars */ above *_down vars */
static int g_scroll_lock_down = 0; static int g_scroll_lock_down = 0;
static OsTimerPtr g_timer = 0;
static int g_x = 0;
static int g_y = 0;
static int g_timer_schedualed = 0;
static int g_delay_motion = 1;
#define MIN_KEY_CODE 8 #define MIN_KEY_CODE 8
#define MAX_KEY_CODE 255 #define MAX_KEY_CODE 255
#define NO_OF_KEYS ((MAX_KEY_CODE - MIN_KEY_CODE) + 1) #define NO_OF_KEYS ((MAX_KEY_CODE - MIN_KEY_CODE) + 1)
@ -779,6 +791,7 @@ rdpEnqueueButton(int type, int buttons)
EventListPtr rdp_events; EventListPtr rdp_events;
xEvent *pev; xEvent *pev;
LLOGLN(10, ("rdpEnqueueButton:"));
i = GetEventList(&rdp_events); i = GetEventList(&rdp_events);
n = GetPointerEvents(rdp_events, g_pointer, type, buttons, 0, 0, 0, 0); n = GetPointerEvents(rdp_events, g_pointer, type, buttons, 0, 0, 0, 0);
@ -808,6 +821,16 @@ rdpEnqueueKey(int type, int scancode)
} }
} }
/******************************************************************************/
static CARD32
rdpDeferredInputCallback(OsTimerPtr timer, CARD32 now, pointer arg)
{
LLOGLN(10, ("rdpDeferredInputCallback"));
g_timer_schedualed = 0;
rdpEnqueueMotion(g_x, g_y);
return 0;
}
/******************************************************************************/ /******************************************************************************/
void void
PtrAddEvent(int buttonMask, int x, int y) PtrAddEvent(int buttonMask, int x, int y)
@ -815,29 +838,49 @@ PtrAddEvent(int buttonMask, int x, int y)
int i; int i;
int type; int type;
int buttons; int buttons;
int send_now;
rdpEnqueueMotion(x, y); LLOGLN(10, ("PtrAddEvent:"));
send_now = (buttonMask ^ g_old_button_mask) || (g_delay_motion == 0);
for (i = 0; i < 5; i++) LLOGLN(10, ("PtrAddEvent: send_now %d", send_now));
if (send_now)
{ {
if ((buttonMask ^ g_old_button_mask) & (1 << i)) if (g_timer_schedualed)
{ {
if (buttonMask & (1 << i)) g_timer_schedualed = 0;
TimerCancel(g_timer);
}
rdpEnqueueMotion(x, y);
for (i = 0; i < 5; i++)
{
if ((buttonMask ^ g_old_button_mask) & (1 << i))
{ {
type = ButtonPress; if (buttonMask & (1 << i))
buttons = i + 1; {
rdpEnqueueButton(type, buttons); type = ButtonPress;
} buttons = i + 1;
else rdpEnqueueButton(type, buttons);
{ }
type = ButtonRelease; else
buttons = i + 1; {
rdpEnqueueButton(type, buttons); type = ButtonRelease;
buttons = i + 1;
rdpEnqueueButton(type, buttons);
}
} }
} }
g_old_button_mask = buttonMask;
}
else
{
g_x = x;
g_y = y;
if (!g_timer_schedualed)
{
g_timer_schedualed = 1;
g_timer = TimerSet(g_timer, 0, 60, rdpDeferredInputCallback, 0);
}
} }
g_old_button_mask = buttonMask;
} }
/******************************************************************************/ /******************************************************************************/