gimp r25263 - in trunk: . app/core app/gui app/plug-in libgimp libgimpbase



Author: neo
Date: Thu Mar 27 16:30:29 2008
New Revision: 25263
URL: http://svn.gnome.org/viewvc/gimp?rev=25263&view=rev

Log:
2008-03-27  Sven Neumann  <sven gimp org>

	Properly pass the focus from the core to plug-in dialogs:

	* libgimpbase/gimpprotocol.[ch]: added a user_time member to the
	GimpConfig struct. Bumped the protocol version to 0x0012.

	* app/core/gimp-gui.[ch]
	* app/gui/gui-vtable.c: added gimp_get_user_time() to get the
	timestamp of the last user interaction.

	* app/plug-in/gimppluginmanager-call.c
	(gimp_plug_in_manager_call_run): pass the timestamp to in the
	GimpConfig message.

	* libgimp/gimp.[ch]:
	* libgimp/gimp.def: added method to access the timestamp as set
	in the config message.

	* libgimp/gimpui.c (gimp_ui_init): construct a fake startup ID and
	set the DESKTOP_STARTUP_ID environment variable.


Modified:
   trunk/ChangeLog
   trunk/app/core/gimp-gui.c
   trunk/app/core/gimp-gui.h
   trunk/app/gui/gui-vtable.c
   trunk/app/plug-in/gimppluginmanager-call.c
   trunk/libgimp/gimp.c
   trunk/libgimp/gimp.def
   trunk/libgimp/gimp.h
   trunk/libgimp/gimpui.c
   trunk/libgimpbase/gimpprotocol.c
   trunk/libgimpbase/gimpprotocol.h

Modified: trunk/app/core/gimp-gui.c
==============================================================================
--- trunk/app/core/gimp-gui.c	(original)
+++ trunk/app/core/gimp-gui.c	Thu Mar 27 16:30:29 2008
@@ -50,6 +50,7 @@
   gimp->gui.help                = NULL;
   gimp->gui.get_program_class   = NULL;
   gimp->gui.get_display_name    = NULL;
+  gimp->gui.get_user_time       = NULL;
   gimp->gui.get_theme_dir       = NULL;
   gimp->gui.display_get_by_id   = NULL;
   gimp->gui.display_get_id      = NULL;
@@ -226,6 +227,27 @@
   return NULL;
 }
 
+/**
+ * gimp_get_user_time:
+ * @gimp:
+ *
+ * Returns the timestamp of the last user interaction. The timestamp is
+ * taken from events caused by user interaction such as key presses or
+ * pointer movements. See gdk_x11_display_get_user_time().
+ *
+ * Return value: the timestamp of the last user interaction
+ */
+guint32
+gimp_get_user_time (Gimp *gimp)
+{
+  g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0);
+
+  if (gimp->gui.get_user_time)
+    return gimp->gui.get_user_time (gimp);
+
+  return 0;
+}
+
 const gchar *
 gimp_get_theme_dir (Gimp *gimp)
 {

Modified: trunk/app/core/gimp-gui.h
==============================================================================
--- trunk/app/core/gimp-gui.h	(original)
+++ trunk/app/core/gimp-gui.h	Thu Mar 27 16:30:29 2008
@@ -45,6 +45,8 @@
   gchar        * (* get_display_name)    (Gimp                *gimp,
                                           gint                 display_ID,
                                           gint                *monitor_number);
+  guint32        (* get_user_time)       (Gimp                *gimp);
+
   const gchar  * (* get_theme_dir)       (Gimp                *gimp);
 
   GimpObject   * (* get_empty_display)   (Gimp                *gimp);
@@ -136,6 +138,7 @@
 gchar        * gimp_get_display_name     (Gimp                *gimp,
                                           gint                 display_ID,
                                           gint                *monitor_number);
+guint32        gimp_get_user_time        (Gimp                *gimp);
 const gchar  * gimp_get_theme_dir        (Gimp                *gimp);
 
 gboolean       gimp_pdb_dialog_new       (Gimp                *gimp,

Modified: trunk/app/gui/gui-vtable.c
==============================================================================
--- trunk/app/gui/gui-vtable.c	(original)
+++ trunk/app/gui/gui-vtable.c	Thu Mar 27 16:30:29 2008
@@ -88,6 +88,7 @@
 static gchar        * gui_get_display_name     (Gimp                *gimp,
                                                 gint                 display_ID,
                                                 gint                *monitor_number);
+static guint32        gui_get_user_time        (Gimp                *gimp);
 static const gchar  * gui_get_theme_dir        (Gimp                *gimp);
 static GimpObject   * gui_get_empty_display    (Gimp                *gimp);
 static GimpObject   * gui_display_get_by_ID    (Gimp                *gimp,
@@ -144,6 +145,7 @@
   gimp->gui.help                = gui_help;
   gimp->gui.get_program_class   = gui_get_program_class;
   gimp->gui.get_display_name    = gui_get_display_name;
+  gimp->gui.get_user_time       = gui_get_user_time;
   gimp->gui.get_theme_dir       = gui_get_theme_dir;
   gimp->gui.get_empty_display   = gui_get_empty_display;
   gimp->gui.display_get_by_id   = gui_display_get_by_ID;
@@ -255,6 +257,15 @@
   return NULL;
 }
 
+static guint32
+gui_get_user_time (Gimp *gimp)
+{
+#ifdef GDK_WINDOWING_X11
+  return gdk_x11_display_get_user_time (gdk_display_get_default ());
+#endif
+  return 0;
+}
+
 static const gchar *
 gui_get_theme_dir (Gimp *gimp)
 {

Modified: trunk/app/plug-in/gimppluginmanager-call.c
==============================================================================
--- trunk/app/plug-in/gimppluginmanager-call.c	(original)
+++ trunk/app/plug-in/gimppluginmanager-call.c	Thu Mar 27 16:30:29 2008
@@ -197,6 +197,7 @@
       config.display_name     = gimp_get_display_name (manager->gimp,
                                                        display_ID, &monitor);
       config.monitor_number   = monitor;
+      config.timestamp        = gimp_get_user_time (manager->gimp);
 
       proc_run.name    = GIMP_PROCEDURE (procedure)->original_name;
       proc_run.nparams = args->n_values;

Modified: trunk/libgimp/gimp.c
==============================================================================
--- trunk/libgimp/gimp.c	(original)
+++ trunk/libgimp/gimp.c	Thu Mar 27 16:30:29 2008
@@ -179,6 +179,7 @@
 static gchar         *_wm_class          = NULL;
 static gchar         *_display_name      = NULL;
 static gint           _monitor_number    = 0;
+static guint32        _timestamp         = 0;
 static const gchar   *progname           = NULL;
 
 static gchar          write_buffer[WRITE_BUFFER_SIZE];
@@ -1222,6 +1223,7 @@
  * gimp_display_name:
  *
  * Returns the display to be used for plug-in windows.
+ *
  * This is a constant value given at plug-in configuration time.
  *
  * Return value: the display name
@@ -1247,6 +1249,22 @@
 }
 
 /**
+ * gimp_user_time:
+ *
+ * Returns the timestamp of the user interaction that should be set on
+ * the plug-in window. This is handled transparently. Plug-in authors
+ * do not have to care about this. This is a constant value given at
+ * plug-in configuration time.
+ *
+ * Return value: timestamp for plug-in window
+ **/
+guint32
+gimp_user_time (void)
+{
+  return _timestamp;
+}
+
+/**
  * gimp_get_progname:
  *
  * Returns the plug-in's executable name.
@@ -1712,6 +1730,7 @@
   _wm_class         = g_strdup (config->wm_class);
   _display_name     = g_strdup (config->display_name);
   _monitor_number   = config->monitor_number;
+  _timestamp        = config->timestamp;
 
   if (config->app_name)
     g_set_application_name (config->app_name);

Modified: trunk/libgimp/gimp.def
==============================================================================
--- trunk/libgimp/gimp.def	(original)
+++ trunk/libgimp/gimp.def	Thu Mar 27 16:30:29 2008
@@ -619,6 +619,7 @@
 	gimp_tile_width
 	gimp_transform_2d
 	gimp_uninstall_temp_proc
+	gimp_user_time
 	gimp_vectors_bezier_stroke_conicto
 	gimp_vectors_bezier_stroke_cubicto
 	gimp_vectors_bezier_stroke_lineto

Modified: trunk/libgimp/gimp.h
==============================================================================
--- trunk/libgimp/gimp.h	(original)
+++ trunk/libgimp/gimp.h	Thu Mar 27 16:30:29 2008
@@ -321,6 +321,7 @@
 const gchar  * gimp_wm_class            (void) G_GNUC_CONST;
 const gchar  * gimp_display_name        (void) G_GNUC_CONST;
 gint           gimp_monitor_number      (void) G_GNUC_CONST;
+guint32        gimp_user_time           (void) G_GNUC_CONST;
 
 const gchar  * gimp_get_progname        (void) G_GNUC_CONST;
 

Modified: trunk/libgimp/gimpui.c
==============================================================================
--- trunk/libgimp/gimpui.c	(original)
+++ trunk/libgimp/gimpui.c	Thu Mar 27 16:30:29 2008
@@ -65,9 +65,9 @@
 gimp_ui_init (const gchar *prog_name,
               gboolean     preview)
 {
+  GdkScreen   *screen;
   const gchar *display_name;
   gchar       *themerc;
-  GdkScreen   *screen;
 
   g_return_if_fail (prog_name != NULL);
 
@@ -87,6 +87,17 @@
 #endif
     }
 
+  if (gimp_user_time ())
+    {
+      /* Construct a fake startup ID as we only want to pass the
+       * interaction timestamp, see _gdk_windowing_set_default_display().
+       */
+      gchar *startup_id = g_strdup_printf ("_TIME%u", gimp_user_time ());
+
+      g_setenv ("DESKTOP_STARTUP_ID", startup_id, TRUE);
+      g_free (startup_id);
+    }
+
   gtk_init (NULL, NULL);
 
   themerc = gimp_personal_rc_file ("themerc");

Modified: trunk/libgimpbase/gimpprotocol.c
==============================================================================
--- trunk/libgimpbase/gimpprotocol.c	(original)
+++ trunk/libgimpbase/gimpprotocol.c	Thu Mar 27 16:30:29 2008
@@ -541,6 +541,9 @@
                                (guint32 *) &config->monitor_number, 1,
                                user_data))
     goto cleanup;
+  if (! _gimp_wire_read_int32 (channel,
+                               &config->timestamp, 1, user_data))
+    goto cleanup;
 
   msg->data = config;
   return;
@@ -633,6 +636,10 @@
                                 (const guint32 *) &config->monitor_number, 1,
                                 user_data))
     return;
+  if (! _gimp_wire_write_int32 (channel,
+                                (const guint32 *) &config->timestamp, 1,
+                                user_data))
+    return;
 }
 
 static void

Modified: trunk/libgimpbase/gimpprotocol.h
==============================================================================
--- trunk/libgimpbase/gimpprotocol.h	(original)
+++ trunk/libgimpbase/gimpprotocol.h	Thu Mar 27 16:30:29 2008
@@ -27,7 +27,7 @@
 
 /* Increment every time the protocol changes
  */
-#define GIMP_PROTOCOL_VERSION  0x0011
+#define GIMP_PROTOCOL_VERSION  0x0012
 
 
 enum
@@ -82,6 +82,7 @@
   gchar   *wm_class;
   gchar   *display_name;
   gint32   monitor_number;
+  guint32  timestamp;
 };
 
 struct _GPTileReq



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