summaryrefslogtreecommitdiff
path: root/src/wayland
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2017-06-21 13:42:23 +0800
committerJonas Ådahl <jadahl@gmail.com>2017-08-29 11:49:01 +0800
commit34e7134db223d68c491c120f40725f1beeaf5f73 (patch)
treecd6df948cb14dee32d14892b396ee035b2b5530c /src/wayland
parent12710dc6448f9a5bb2b3bcba406f4ce74ef204e8 (diff)
downloadmutter-34e7134db223d68c491c120f40725f1beeaf5f73.tar.gz
wayland/xdg-foreign: Move out ID generation helper to util.c
It'll be used to generate ID in the same way in other places later. https://bugzilla.gnome.org/show_bug.cgi?id=784199
Diffstat (limited to 'src/wayland')
-rw-r--r--src/wayland/meta-wayland-xdg-foreign.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/wayland/meta-wayland-xdg-foreign.c b/src/wayland/meta-wayland-xdg-foreign.c
index 9e193426a..faf373ee8 100644
--- a/src/wayland/meta-wayland-xdg-foreign.c
+++ b/src/wayland/meta-wayland-xdg-foreign.c
@@ -28,6 +28,7 @@
#include <wayland-server.h>
+#include "core/util-private.h"
#include "wayland/meta-wayland-private.h"
#include "wayland/meta-wayland-versions.h"
#include "wayland/meta-wayland-xdg-shell.h"
@@ -80,21 +81,6 @@ xdg_exporter_destroy (struct wl_client *client,
wl_resource_destroy (resource);
}
-static char *
-generate_handle (MetaWaylandXdgForeign *foreign)
-{
- char *handle = g_new0 (char, META_XDG_FOREIGN_HANDLE_LENGTH + 1);
- int i;
-
- /*
- * Generate a random string of printable ASCII characters.
- */
- for (i = 0; i < META_XDG_FOREIGN_HANDLE_LENGTH; i++)
- handle[i] = (char) g_rand_int_range (foreign->rand, 32, 127);
-
- return handle;
-}
-
static void
xdg_exported_destroy (struct wl_client *client,
struct wl_resource *resource)
@@ -195,7 +181,8 @@ xdg_exporter_export (struct wl_client *client,
while (TRUE)
{
- handle = generate_handle (foreign);
+ handle = meta_generate_random_id (foreign->rand,
+ META_XDG_FOREIGN_HANDLE_LENGTH);
if (!g_hash_table_contains (foreign->exported_surfaces, handle))
{