You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/01/30 19:06:54 UTC

[7/9] guacamole-server git commit: GUACAMOLE-313: Use mouse timestamps for frames as well as sync.

GUACAMOLE-313: Use mouse timestamps for frames as well as sync.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/7eb4e225
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/7eb4e225
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/7eb4e225

Branch: refs/heads/master
Commit: 7eb4e22515c2e3255e661bf26e27631940d5e231
Parents: a74d6a2
Author: Michael Jumper <mj...@apache.org>
Authored: Mon Nov 27 20:18:20 2017 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Fri Jan 26 16:21:51 2018 -0800

----------------------------------------------------------------------
 src/guacenc/instruction-mouse.c |  9 ++++++++-
 src/guacenc/instruction-sync.c  | 35 +----------------------------------
 src/guacenc/parse.c             | 23 +++++++++++++++++++++++
 src/guacenc/parse.h             | 17 +++++++++++++++++
 4 files changed, 49 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/7eb4e225/src/guacenc/instruction-mouse.c
----------------------------------------------------------------------
diff --git a/src/guacenc/instruction-mouse.c b/src/guacenc/instruction-mouse.c
index ac9fd87..5095245 100644
--- a/src/guacenc/instruction-mouse.c
+++ b/src/guacenc/instruction-mouse.c
@@ -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;
 
-    return 0;
+    /* 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);
 
 }
 

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/7eb4e225/src/guacenc/instruction-sync.c
----------------------------------------------------------------------
diff --git a/src/guacenc/instruction-sync.c b/src/guacenc/instruction-sync.c
index 5dd4844..c27ad14 100644
--- a/src/guacenc/instruction-sync.c
+++ b/src/guacenc/instruction-sync.c
@@ -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 */

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/7eb4e225/src/guacenc/parse.c
----------------------------------------------------------------------
diff --git a/src/guacenc/parse.c b/src/guacenc/parse.c
index 0eea778..8f05d38 100644
--- a/src/guacenc/parse.c
+++ b/src/guacenc/parse.c
@@ -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);
+
+}
+

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/7eb4e225/src/guacenc/parse.h
----------------------------------------------------------------------
diff --git a/src/guacenc/parse.h b/src/guacenc/parse.h
index f888913..b6e5cd5 100644
--- a/src/guacenc/parse.h
+++ b/src/guacenc/parse.h
@@ -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