[gtk+] broadway: Make /dev/shm names nicer



commit ada20f475d518f120d02bd616c6af22bf31c4ce5
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jan 10 23:59:23 2013 +0100

    broadway: Make /dev/shm names nicer

 demos/gtk-demo/main.c             |    3 +++
 gdk/broadway/TODO.broadway        |    1 +
 gdk/broadway/gdkbroadway-server.c |   12 ++++++++----
 3 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c
index 935b86e..1c04a27 100644
--- a/demos/gtk-demo/main.c
+++ b/demos/gtk-demo/main.c
@@ -56,6 +56,9 @@ get_democodedir (void)
 
 #endif
 
+#undef DEMOCODEDIR
+#define DEMOCODEDIR getenv ("GTK_DEMO_DATA_DIR")
+
 /**
  * demo_find_file:
  * @base: base filename
diff --git a/gdk/broadway/TODO.broadway b/gdk/broadway/TODO.broadway
index 2200bed..a8af758 100644
--- a/gdk/broadway/TODO.broadway
+++ b/gdk/broadway/TODO.broadway
@@ -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
diff --git a/gdk/broadway/gdkbroadway-server.c b/gdk/broadway/gdkbroadway-server.c
index b67f2fe..2e33469 100644
--- a/gdk/broadway/gdkbroadway-server.c
+++ b/gdk/broadway/gdkbroadway-server.c
@@ -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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]