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
This commit is contained in:
Jonas Ådahl
2017-06-21 13:42:23 +08:00
parent 12710dc644
commit 34e7134db2
3 changed files with 22 additions and 16 deletions

View File

@ -34,4 +34,7 @@ void meta_set_syncing (gboolean setting);
void meta_set_replace_current_wm (gboolean setting);
void meta_set_is_wayland_compositor (gboolean setting);
char * meta_generate_random_id (GRand *rand,
int length);
#endif

View File

@ -994,5 +994,21 @@ meta_get_locale_direction (void)
}
}
char *
meta_generate_random_id (GRand *rand,
int length)
{
char *id;
int i;
/* Generate a random string of printable ASCII characters. */
id = g_new0 (char, length + 1);
for (i = 0; i < length; i++)
id[i] = (char) g_rand_int_range (rand, 32, 127);
return id;
}
/* eof util.c */