[gimp] Bug 677776 - filter popup windows get hidden behind main image window



commit 0b56aa0d133a9743dca74701a54f21cf9c609f7d
Author: Michael Natterer <mitch gimp org>
Date:   Wed Nov 7 23:44:35 2012 +0100

    Bug 677776 - filter popup windows get hidden behind main image window
    
    On OSX, call [NSApp activateIgnoringOtherApps] when a plug-in dialog
    is shown, so the plug-in process becomes the active app, and the
    dialog gets focussed.
    
    In order to avoid doing this in GimpDialog (which is also used in
    the core), do it in gimp_ui_init() which all interactive plug-ins
    call, and when gimp_temp_proc_run() is called interactively, to
    catch repeated activation of an already running plug-in.
    
    Also, set GimpDialog's initial position to GTK_WIN_POS_CENTER,
    or they will pop up in the top left corner.
    
    Inspired by patches from Simone Karin Lehmann and Daniel Sabo.

 libgimp/Makefile.am         |   20 ++++++++++++++------
 libgimp/gimp.c              |   15 +++++++++++++--
 libgimp/gimpui.c            |    8 ++++++++
 libgimpwidgets/gimpdialog.c |    4 ++++
 4 files changed, 39 insertions(+), 8 deletions(-)
---
diff --git a/libgimp/Makefile.am b/libgimp/Makefile.am
index d99d0cd..94ff4c9 100644
--- a/libgimp/Makefile.am
+++ b/libgimp/Makefile.am
@@ -11,6 +11,11 @@ if PLATFORM_WIN32
 no_undefined = -no-undefined
 endif
 
+if PLATFORM_OSX
+xobjective_c = "-xobjective-c"
+framework_cocoa = -framework Cocoa
+endif
+
 if OS_WIN32
 gimp_def = gimp.def
 gimpui_def = gimpui.def
@@ -62,10 +67,11 @@ AM_CPPFLAGS = \
 	-DGIMP_COMPILATION
 
 INCLUDES = \
-	-I$(top_srcdir)   \
-	$(GTK_CFLAGS)     \
-	$(GEGL_CFLAGS)    \
-	-I$(includedir)
+	-I$(top_srcdir)	\
+	$(GTK_CFLAGS)	\
+	$(GEGL_CFLAGS)	\
+	-I$(includedir)	\
+	$(xobjective_c)
 
 lib_LTLIBRARIES = libgimp- GIMP_API_VERSION@.la libgimpui- GIMP_API_VERSION@.la
 
@@ -364,7 +370,8 @@ gimpinclude_HEADERS = \
 libgimp_ GIMP_API_VERSION@_la_LDFLAGS = \
 	-version-info $(LT_VERSION_INFO)	\
 	$(no_undefined)				\
-	$(libgimp_export_symbols)
+	$(libgimp_export_symbols)		\
+	$(framework_cocoa)
 
 libgimp_ GIMP_API_VERSION@_la_LIBADD = \
 	$(libgimpconfig)	\
@@ -384,7 +391,8 @@ libgimp_ GIMP_API_VERSION@_la_DEPENDENCIES = \
 libgimpui_ GIMP_API_VERSION@_la_LDFLAGS = \
 	-version-info $(LT_VERSION_INFO)	\
 	$(no_undefined)				\
-	$(libgimpui_export_symbols)
+	$(libgimpui_export_symbols)		\
+	$(framework_cocoa)
 
 libgimpui_ GIMP_API_VERSION@_la_LIBADD = \
 	$(libgimp)		\
diff --git a/libgimp/gimp.c b/libgimp/gimp.c
index 9a8bc5d..5066761 100644
--- a/libgimp/gimp.c
+++ b/libgimp/gimp.c
@@ -49,7 +49,7 @@
 #define WAIT_ANY -1
 #endif
 
-#include <glib-object.h>
+#include <gtk/gtk.h> /* need GDK_WINDOWING_FOO defines */
 
 #ifndef G_OS_WIN32
 #include "libgimpbase/gimpsignal.h"
@@ -82,6 +82,10 @@
 
 #endif /* USE_POSIX_SHM */
 
+#ifdef GDK_WINDOWING_QUARTZ
+#include <Cocoa/Cocoa.h>
+#endif
+
 #if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
 #  define STRICT
 #  define _WIN32_WINNT 0x0601
@@ -2002,7 +2006,6 @@ gimp_proc_run (GPProcRun *proc_run)
     }
 }
 
-
 static void
 gimp_temp_proc_run (GPProcRun *proc_run)
 {
@@ -2014,6 +2017,14 @@ gimp_temp_proc_run (GPProcRun *proc_run)
       GimpParam    *return_vals;
       gint          n_return_vals;
 
+#ifdef GDK_WINDOWING_QUARTZ
+      if (proc_run->params &&
+          proc_run->params[0].data.d_int32 == GIMP_RUN_INTERACTIVE)
+        {
+          [NSApp activateIgnoringOtherApps:YES];
+        }
+#endif
+
       (* run_proc) (proc_run->name,
                     proc_run->nparams,
                     (GimpParam *) proc_run->params,
diff --git a/libgimp/gimpui.c b/libgimp/gimpui.c
index 947423a..f529d84 100644
--- a/libgimp/gimpui.c
+++ b/libgimp/gimpui.c
@@ -28,6 +28,10 @@
 #include <gdk/gdkx.h>
 #endif
 
+#ifdef GDK_WINDOWING_QUARTZ
+#include <Cocoa/Cocoa.h>
+#endif
+
 #include "gimp.h"
 #include "gimpui.h"
 
@@ -143,6 +147,10 @@ gimp_ui_init (const gchar *prog_name,
 
   gimp_dialogs_show_help_button (gimp_show_help_button ());
 
+#ifdef GDK_WINDOWING_QUARTZ
+  [NSApp activateIgnoringOtherApps:YES];
+#endif
+
   gimp_ui_initialized = TRUE;
 }
 
diff --git a/libgimpwidgets/gimpdialog.c b/libgimpwidgets/gimpdialog.c
index 076a4a3..1a257d8 100644
--- a/libgimpwidgets/gimpdialog.c
+++ b/libgimpwidgets/gimpdialog.c
@@ -149,6 +149,10 @@ gimp_dialog_class_init (GimpDialogClass *klass)
 static void
 gimp_dialog_init (GimpDialog *dialog)
 {
+#ifdef GDK_WINDOWING_QUARTZ
+  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
+#endif
+
   g_signal_connect (dialog, "response",
                     G_CALLBACK (gimp_dialog_response),
                     NULL);



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