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



commit f3de4b4a24e0e50c7a31829c5ad170e3d3ee5edf
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.
    (cherry picked from commit 0b56aa0d133a9743dca74701a54f21cf9c609f7d)

 libgimp/Makefile.am         |   14 +++++++++++---
 libgimp/gimp.c              |   15 +++++++++++++--
 libgimp/gimpui.c            |    8 ++++++++
 libgimpwidgets/gimpdialog.c |    4 ++++
 4 files changed, 36 insertions(+), 5 deletions(-)
---
diff --git a/libgimp/Makefile.am b/libgimp/Makefile.am
index 6e72896..4ff021f5 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
@@ -64,7 +69,8 @@ AM_CPPFLAGS = \
 INCLUDES = \
 	-I$(top_srcdir)	\
 	$(GTK_CFLAGS)	\
-	-I$(includedir)
+	-I$(includedir)	\
+	$(xobjective_c)
 
 lib_LTLIBRARIES = libgimp-2.0.la libgimpui-2.0.la
 
@@ -361,7 +367,8 @@ gimpinclude_HEADERS = \
 libgimp_2_0_la_LDFLAGS = \
 	-version-info $(LT_VERSION_INFO)	\
 	$(no_undefined)				\
-	$(libgimp_export_symbols)
+	$(libgimp_export_symbols)		\
+	$(framework_cocoa)
 
 libgimp_2_0_la_LIBADD = \
 	$(libgimpconfig)	\
@@ -380,7 +387,8 @@ libgimp_2_0_la_DEPENDENCIES = \
 libgimpui_2_0_la_LDFLAGS = \
 	-version-info $(LT_VERSION_INFO)	\
 	$(no_undefined)				\
-	$(libgimpui_export_symbols)
+	$(libgimpui_export_symbols)		\
+	$(framework_cocoa)
 
 libgimpui_2_0_la_LIBADD = \
 	$(libgimp)		\
diff --git a/libgimp/gimp.c b/libgimp/gimp.c
index 2d38a0e..b4fdb47 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
@@ -2003,7 +2007,6 @@ gimp_proc_run (GPProcRun *proc_run)
     }
 }
 
-
 static void
 gimp_temp_proc_run (GPProcRun *proc_run)
 {
@@ -2015,6 +2018,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 c98e15a..a9b532a 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 "libgimpmodule/gimpmodule.h"
 
 #include "gimp.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]