libgnome-desktop API addition request



Hey,
	This is late, I know and its entirely my fault. Elijah has been bugging
me about this for a while but initially I was confused and then I kept
forgetting about it.

	So, Elijah has enabled focus stealing prevention in Metacity for GNOME
2.10 and one of the problems that came up is that in Nautilus when you
double click on an icon, the app launched often doesn't get focused once
its been launched.

	The reason for this is that libgnome-desktop uses a hack to try and
guess the timestamp for the user action which initiated the launch.
Because of the way Nautilus launches the app (in an idle handler),
libgnome-desktop guess wrong and the app doesn't get focus when its
starts up.

	The solution is straightforward - the launching app (e.g. Nautilus)
needs to explicitly let libgnome-desktop know the timestamp of the user
action which caused the launch. So, we want to add a
gnome_desktop_item_set_launch_time().

	The only users of gnome_desktop_item_launch() are the panel, nautilus,
control-center and gsearchtool. We'll be updating each of them to use
the new API ASAP.

	The Nautilus issue is the only obvious example of the problem we're
aware of, but there may be others. Adding and using the API is
definitely the "right thing".

	More details are here:

  http://bugzilla.gnome.org/show_bug.cgi?id=150910

	I think its worthwhile to get this in for 2.8. We understand the
problem here very well and its very, very unlikely to turn out to be the
wrong API. The patch itself is small and unlikely to cause regressions
itself. Also, libgnome-desktop is only used by a very small number of
apps and isn't part of the platform.

	So, approvals anyone ?

Thanks,
Mark.

Index: libgnome/gnome-desktop-item.h
===================================================================
RCS file: /cvs/gnome/gnome-desktop/libgnome-desktop/libgnome/gnome-desktop-item.h,v
retrieving revision 1.49
diff -u -p -r1.49 gnome-desktop-item.h
--- libgnome/gnome-desktop-item.h	28 Nov 2002 11:38:41 -0000	1.49
+++ libgnome/gnome-desktop-item.h	30 Jan 2005 11:46:41 -0000
@@ -286,6 +286,12 @@ void                    gnome_desktop_it
 							      gboolean                    value);
 
 /*
+ * Xserver time of user action that caused the application launch to start.
+ */
+void                    gnome_desktop_item_set_launch_time   (GnomeDesktopItem           *item,
+							      guint32                     timestamp);
+
+/*
  * Clearing attributes
  */
 #define                 gnome_desktop_item_clear_attr(item,attr) \
Index: gnome-desktop-item.c
===================================================================
RCS file: /cvs/gnome/gnome-desktop/libgnome-desktop/gnome-desktop-item.c,v
retrieving revision 1.140
diff -u -p -r1.140 gnome-desktop-item.c
--- gnome-desktop-item.c	24 Dec 2004 08:29:44 -0000	1.140
+++ gnome-desktop-item.c	30 Jan 2005 11:46:41 -0000
@@ -87,6 +87,8 @@ struct _GnomeDesktopItem {
 	char *location;
 
 	time_t mtime;
+
+	guint32 launch_time;
 };
 
 /* If mtime is set to this, set_location won't update mtime,
@@ -418,6 +420,7 @@ gnome_desktop_item_copy (const GnomeDesk
 	retval->modified = item->modified;
 	retval->location = g_strdup (item->location);
 	retval->mtime = item->mtime;
+	retval->launch_time = item->launch_time;
 
 	/* Languages */
 	retval->languages = g_list_copy (item->languages);
@@ -1790,6 +1793,7 @@ ditem_execute (const GnomeDesktopItem *i
 #ifdef HAVE_STARTUP_NOTIFICATION
 		if (sn_context != NULL &&
 		    !sn_launcher_context_get_initiated (sn_context)) {
+			guint32 launch_time;
 
 			/* This means that we always use the first real_argv[0]
 			 * we select for the "binary name", but it's probably
@@ -1801,10 +1805,18 @@ ditem_execute (const GnomeDesktopItem *i
 			sn_launcher_context_set_binary_name (sn_context,
 							     real_argv[0]);
 			
+			if (item->launch_time > 0)
+				launch_time = item->launch_time;
+			else
+				launch_time = gtk_get_current_event_time ();
+
 			sn_launcher_context_initiate (sn_context,
 						      g_get_prgname () ? g_get_prgname () : "unknown",
 						      real_argv[0],
-						      gtk_get_current_event_time ());
+						      launch_time);
+
+			/* Don't allow accidental reuse of same timestamp */
+			((GnomeDesktopItem *)item)->launch_time = 0;
 
 			envp = make_spawn_environment_for_sn_context (sn_context, envp);
 			if (free_me)
@@ -2977,8 +2989,18 @@ gnome_desktop_item_set_boolean (GnomeDes
 	set (item, attr, value ? "true" : "false");
 }
 
+void
+gnome_desktop_item_set_launch_time (GnomeDesktopItem *item,
+				    guint32           timestamp)
+{
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (timestamp > 0);
+
+	item->launch_time = timestamp;
+}
+
 /*
-* Clearing attributes
+ * Clearing attributes
  */
 void
 gnome_desktop_item_clear_section (GnomeDesktopItem *item,





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