[maemo-commits] [maemo-commits] r12487 - in projects/haf/trunk/hildon-desktop: . libhildonwm

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Jun 26 17:08:16 EEST 2007
Author: moimart
Date: 2007-06-26 17:08:03 +0300 (Tue, 26 Jun 2007)
New Revision: 12487

Modified:
   projects/haf/trunk/hildon-desktop/ChangeLog
   projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-types.h
   projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-util.c
   projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-util.h
   projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.c
   projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.h
Log:
2007-06-26  Moises Martinez  <moises.martinez at nokia.com>

        * libhildonwm/hd-wm-types.h:
        - Added NET_STARTUP_INFO/BEGIN
        * libhildonwm/hd-wm-util.[ch]:
        - new util function for broadcasting NET_STARTUP_INFO/BEGIN
        * libhildonwm/hd-wm.[ch]:
        - broadcast STARTUP when launching applications.
	* ChangeLog updated.



Modified: projects/haf/trunk/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-desktop/ChangeLog	2007-06-26 13:57:37 UTC (rev 12486)
+++ projects/haf/trunk/hildon-desktop/ChangeLog	2007-06-26 14:08:03 UTC (rev 12487)
@@ -1,5 +1,14 @@
 2007-06-26  Moises Martinez  <moises.martinez at nokia.com>
 
+	* libhildonwm/hd-wm-types.h:
+	- Added NET_STARTUP_INFO/BEGIN
+	* libhildonwm/hd-wm-util.[ch]:
+	- new util function for broadcasting NET_STARTUP_INFO/BEGIN
+	* libhildonwm/hd-wm.[ch]:
+	- broadcast STARTUP when launching applications.
+
+2007-06-26  Moises Martinez  <moises.martinez at nokia.com>
+
 	* libhildonwm/hd-wm.c: Removed launch banner for dummy applications.
 
 2007-06-26  Moises Martinez  <moises.martinez at nokia.com>

Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-types.h
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-types.h	2007-06-26 13:57:37 UTC (rev 12486)
+++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-types.h	2007-06-26 14:08:03 UTC (rev 12487)
@@ -66,6 +66,7 @@
 
   HD_ATOM_UTF8_STRING,
 
+  HD_ATOM_STARTUP_INFO,
   HD_ATOM_STARTUP_INFO_BEGIN,
 
   HD_ATOM_COUNT

Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-util.c
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-util.c	2007-06-26 13:57:37 UTC (rev 12486)
+++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-util.c	2007-06-26 14:08:03 UTC (rev 12487)
@@ -135,6 +135,79 @@
   return TRUE;
 }
 
+void
+hd_wm_util_broadcast_message (Atom info, Atom begin_info, const gchar *message)
+{
+  Window xwindow;
+	
+  {
+    XSetWindowAttributes attrs;
+
+    attrs.override_redirect = True;
+    attrs.event_mask = PropertyChangeMask | StructureNotifyMask;
+
+    xwindow =
+      XCreateWindow (GDK_DISPLAY(),
+                     GDK_ROOT_WINDOW(),
+                     -100, -100, 1, 1,
+                     0,
+                     CopyFromParent,
+                     CopyFromParent,
+                     CopyFromParent,
+                     CWOverrideRedirect | CWEventMask,
+                     &attrs);
+  }
+
+  {
+    XEvent xevent;
+    const char *src;
+    const char *src_end;
+    char *dest;
+    char *dest_end;
+
+    xevent.xclient.type = ClientMessage;
+    xevent.xclient.message_type = begin_info;
+    xevent.xclient.display = GDK_DISPLAY ();
+    xevent.xclient.window = xwindow;
+    xevent.xclient.format = 8;
+
+    src = message;
+    src_end = message + strlen (message) + 1; /* +1 to include nul byte */
+
+    while (src != src_end)
+    {
+      dest = &xevent.xclient.data.b[0];
+      dest_end = dest + 20;
+
+      while (dest != dest_end &&
+             src != src_end)
+      {
+         *dest = *src;
+         ++dest;
+         ++src;
+      }
+
+      gdk_error_trap_push ();
+
+      XSendEvent (GDK_DISPLAY (),
+                  GDK_ROOT_WINDOW (),
+                  False,
+                  PropertyChangeMask,
+                  &xevent);
+      XSync (GDK_DISPLAY (), FALSE);
+
+      if (gdk_error_trap_pop ())
+        g_warning ("Failed to broadcast startup");	      
+      
+      xevent.xclient.message_type = info;
+    }
+  }
+
+  XDestroyWindow (GDK_DISPLAY (), xwindow);
+  XFlush (GDK_DISPLAY ());
+}
+
+
 /* Function to retrieve the size of VmData for a process
  * Returns -1 on failure
  */

Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-util.h
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-util.h	2007-06-26 13:57:37 UTC (rev 12486)
+++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm-util.h	2007-06-26 14:08:03 UTC (rev 12487)
@@ -52,6 +52,11 @@
 			   unsigned long data3,
 			   unsigned long data4);
 
+void
+hd_wm_util_broadcast_message (Atom info, 
+			      Atom begin_info, 
+			      const gchar *message);
+
 gint hd_wm_get_vmdata_for_pid(gint pid);
 
 #endif

Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.c
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.c	2007-06-26 13:57:37 UTC (rev 12486)
+++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.c	2007-06-26 14:08:03 UTC (rev 12487)
@@ -176,6 +176,9 @@
 		                const GValue *value,
 		                GParamSpec *pspec);
 
+static void 
+hd_wm_send_startup_notification_new (HDWM *hdwm, HDWMApplication *app);
+
 struct xwinv
 {
   Window *wins;
@@ -303,6 +306,7 @@
     
     "UTF8_STRING",
 
+    "_NET_STARTUP_INFO",
     "_NET_STARTUP_INFO_BEGIN"
   };
 
@@ -551,11 +555,10 @@
   if (class_hint.res_name)
     XFree(class_hint.res_name);
 
-  if (app && 
-      !hd_wm_application_has_any_windows (app) && 
-      !hd_wm_application_is_dummy (app))
-  {	  
-    g_signal_emit_by_name (hdwm, "application-starting", app);
+  if (app) 
+  {
+    if (!hd_wm_application_is_dummy (app))	  
+      g_signal_emit_by_name (hdwm, "application-starting", app);
   }
 
   return app;
@@ -1289,6 +1292,7 @@
         g_signal_emit_by_name (hdwm,
                                "application-starting",
                                wapp);
+        hd_wm_send_startup_notification_new (hdwm, wapp);
       }
     }
   }
@@ -2131,6 +2135,69 @@
   gdk_window_set_accept_focus (window,focus);
 }
 
+static gchar *
+hd_wm_strip_slashes (const gchar *name)
+{
+  gchar *b = g_strdup (name);
+  char  *s = b;
+
+  while (*s)
+  {
+    if (*s == '/')
+      *s = '|';
+    ++s;	      
+  }	
+
+  return b;
+}
+
+static void 
+hd_wm_send_startup_notification_new (HDWM *hdwm, HDWMApplication *app)
+{
+  static gint sequence_number = 0;	
+  static gboolean have_hostname	= FALSE;
+  static gchar hostbuf[257];	
+  gchar *launcher_name = HD_WM_LAUNCHER_NAME;
+  gchar *launchee_name = hd_wm_strip_slashes (_(hd_wm_application_get_localized_name (app)));
+  gchar *startup_id;
+  gchar *message;
+  gchar *app_name = _(hd_wm_application_get_name (app));
+  gchar *tmp;
+
+  app_name = g_strescape (app_name,"");
+
+  if (!have_hostname)
+  {
+    if (gethostname (hostbuf, sizeof (hostbuf)-1) == 0)
+      have_hostname = TRUE;
+    else
+      hostbuf[0] = '\0';
+  }
+
+  startup_id = 
+    g_strdup_printf ("%s/%s/%d-%d-%s_TIME%lu",
+                     launcher_name, launchee_name,
+		     (gint) getpid (), (gint) sequence_number, hostbuf,
+                     (gulong) GDK_CURRENT_TIME);
+
+  tmp = g_strescape (startup_id,"");
+  g_free (startup_id);
+  startup_id = tmp;
+  
+  message = g_strdup_printf ("new: ID:\"%s\" NAME:\"%s\" SCREEN:%d",
+		             startup_id,
+		             _(hd_wm_application_get_name (app)),
+		             gdk_screen_get_number (gdk_screen_get_default ()));
+
+  hd_wm_util_broadcast_message (hdwm->priv->atoms[HD_ATOM_STARTUP_INFO],
+		  		hdwm->priv->atoms[HD_ATOM_STARTUP_INFO_BEGIN],
+				message);
+
+  g_free (app_name);  
+  g_free (startup_id);
+  g_free (message);
+}
+
 void 
 hd_wm_set_all_menu_button (HDWM *hdwm, GtkWidget *widget)
 {
@@ -2376,7 +2443,7 @@
   if (((XEvent*)xevent)->type == ClientMessage)
   {
     XClientMessageEvent *cev = (XClientMessageEvent *)xevent;
-    
+
     if (cev->message_type == hdwm->priv->atoms[HD_ATOM_HILDON_FROZEN_WINDOW])
     {
       Window   xwin_hung;
@@ -2407,13 +2474,6 @@
       
       return GDK_FILTER_CONTINUE;
     }
-    else
-    if (cev->message_type == hdwm->priv->atoms[HD_ATOM_STARTUP_INFO_BEGIN])
-    {	    
-      g_debug ("-------## ->>>>>>>>>   hello %s      <<<<<<<<<<---",(gchar *)cev->data.l);	    
-
-      return GDK_FILTER_CONTINUE;
-    }
   }
   else
   if (((XEvent*)xevent)->type == KeyPress)

Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.h
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.h	2007-06-26 13:57:37 UTC (rev 12486)
+++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-wm.h	2007-06-26 14:08:03 UTC (rev 12487)
@@ -115,6 +115,8 @@
 #define TN_DEFAULT_FOCUS FALSE
 #endif
 
+#define HD_WM_LAUNCHER_NAME "libhildonwm"
+
 #define HD_TYPE_WM            (hd_wm_get_type ())
 #define HD_WM(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), HD_TYPE_WM, HDWM))
 #define HD_WM_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  HD_TYPE_WM, HDWMClass))


More information about the maemo-commits mailing list