broadway: Make /dev/shm names nicer

This commit is contained in:
Alexander Larsson 2013-01-10 23:59:23 +01:00
parent da8ff82df5
commit ada20f475d
3 changed files with 12 additions and 4 deletions

View File

@ -56,6 +56,9 @@ get_democodedir (void)
#endif
#undef DEMOCODEDIR
#define DEMOCODEDIR getenv ("GTK_DEMO_DATA_DIR")
/**
* demo_find_file:
* @base: base filename

View File

@ -8,3 +8,4 @@ Send reset events on client disconnect (button up, normal state. Maybe grab stat
rgba suport
shift-select in gedit doesn't work
backdrop mode
clean up /dev/shm on abrupt client exit

View File

@ -504,9 +504,9 @@ _gdk_broadway_server_window_translate (GdkBroadwayServer *server,
static char
make_valid_fs_char (char c)
{
if (c == 0 || c == '/')
return c + 1;
return c;
char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890";
return chars[c % sizeof (chars)];
}
/* name must have at least space for 34 bytes */
@ -520,7 +520,11 @@ create_random_shm (char *name)
{
o = 0;
name[o++] = '/';
for (i = 0; i < 32/4; i++)
name[o++] = 'b';
name[o++] = 'd';
name[o++] = 'w';
name[o++] = '-';
for (i = 0; i < 32/4 - 1; i++)
{
r = g_random_int ();
name[o++] = make_valid_fs_char ((r >> 0) & 0xff);