GUACAMOLE-313: Use mouse timestamps for frames as well as sync.
This commit is contained in:
parent
a74d6a2aaf
commit
7eb4e22515
@ -21,6 +21,7 @@
|
||||
#include "cursor.h"
|
||||
#include "display.h"
|
||||
#include "log.h"
|
||||
#include "parse.h"
|
||||
|
||||
#include <guacamole/client.h>
|
||||
|
||||
@ -43,7 +44,13 @@ int guacenc_handle_mouse(guacenc_display* display, int argc, char** argv) {
|
||||
cursor->x = x;
|
||||
cursor->y = y;
|
||||
|
||||
/* If no timestamp provided, nothing further to do */
|
||||
if (argc < 3)
|
||||
return 0;
|
||||
|
||||
/* Leverage timestamp to render frame */
|
||||
guac_timestamp timestamp = guacenc_parse_timestamp(argv[2]);
|
||||
return guacenc_display_sync(display, timestamp);
|
||||
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "config.h"
|
||||
#include "display.h"
|
||||
#include "log.h"
|
||||
#include "parse.h"
|
||||
|
||||
#include <guacamole/client.h>
|
||||
#include <guacamole/timestamp.h>
|
||||
@ -27,40 +28,6 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* Parses a guac_timestamp from the given string. The string is assumed to
|
||||
* consist solely of decimal digits with an optional leading minus sign. If the
|
||||
* given string contains other characters, the behavior of this function is
|
||||
* undefined.
|
||||
*
|
||||
* @param str
|
||||
* The string to parse, which must contain only decimal digits and an
|
||||
* optional leading minus sign.
|
||||
*
|
||||
* @return
|
||||
* A guac_timestamp having the same value as the provided string.
|
||||
*/
|
||||
static guac_timestamp guacenc_parse_timestamp(const char* str) {
|
||||
|
||||
int sign = 1;
|
||||
int64_t num = 0;
|
||||
|
||||
for (; *str != '\0'; str++) {
|
||||
|
||||
/* Flip sign for each '-' encountered */
|
||||
if (*str == '-')
|
||||
sign = -sign;
|
||||
|
||||
/* If not '-', assume the character is a digit */
|
||||
else
|
||||
num = num * 10 + (*str - '0');
|
||||
|
||||
}
|
||||
|
||||
return (guac_timestamp) (num * sign);
|
||||
|
||||
}
|
||||
|
||||
int guacenc_handle_sync(guacenc_display* display, int argc, char** argv) {
|
||||
|
||||
/* Verify argument count */
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <guacamole/timestamp.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
@ -67,3 +69,24 @@ int guacenc_parse_dimensions(char* arg, int* width, int* height) {
|
||||
|
||||
}
|
||||
|
||||
guac_timestamp guacenc_parse_timestamp(const char* str) {
|
||||
|
||||
int sign = 1;
|
||||
int64_t num = 0;
|
||||
|
||||
for (; *str != '\0'; str++) {
|
||||
|
||||
/* Flip sign for each '-' encountered */
|
||||
if (*str == '-')
|
||||
sign = -sign;
|
||||
|
||||
/* If not '-', assume the character is a digit */
|
||||
else
|
||||
num = num * 10 + (*str - '0');
|
||||
|
||||
}
|
||||
|
||||
return (guac_timestamp) (num * sign);
|
||||
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <guacamole/timestamp.h>
|
||||
|
||||
/**
|
||||
* Parses a string into a single integer. Only positive integers are accepted.
|
||||
* The input string may be modified during parsing. A value will be stored in
|
||||
@ -63,6 +65,21 @@ int guacenc_parse_int(char* arg, int* i);
|
||||
*/
|
||||
int guacenc_parse_dimensions(char* arg, int* width, int* height);
|
||||
|
||||
/**
|
||||
* Parses a guac_timestamp from the given string. The string is assumed to
|
||||
* consist solely of decimal digits with an optional leading minus sign. If the
|
||||
* given string contains other characters, the behavior of this function is
|
||||
* undefined.
|
||||
*
|
||||
* @param str
|
||||
* The string to parse, which must contain only decimal digits and an
|
||||
* optional leading minus sign.
|
||||
*
|
||||
* @return
|
||||
* A guac_timestamp having the same value as the provided string.
|
||||
*/
|
||||
guac_timestamp guacenc_parse_timestamp(const char* str);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user