--- /dev/null
+#! /bin/sh
+patch -p1 -l -f $* < $0
+exit $?
+
+From 07811afb552bfc1e51aea25a39cb52327831198b Mon Sep 17 00:00:00 2001
+From: Andre Heinecke <aheinecke@intevation.de>
+Date: Mon, 30 Apr 2018 11:44:54 +0200
+Subject: [PATCH] Launch Kleopatra config dialog with parent
+
+* src/addin-options.cpp (launch_kleo_config): New.
+(options_window_proc): Use it.
+
+--
+This fixes that the config dialog might be opened in the
+background, or that the assuan communication fails.
+
+Fixes
+GnuPG-Bug-Id: T3946
+---
+ src/addin-options.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 63 insertions(+), 1 deletion(-)
+
+diff --git a/src/addin-options.cpp b/src/addin-options.cpp
+index 32b47eb..6677a30 100644
+--- a/src/addin-options.cpp
++++ b/src/addin-options.cpp
+@@ -27,6 +27,11 @@
+ #include "common.h"
+ #include "engine.h"
+
++#include <string>
++
++#include <gpgme++/context.h>
++#include <gpgme++/data.h>
++
+ /* To avoid writing a dialog template for each language we use gettext
+ for the labels and hope that there is enough space in the dialog to
+ fit the longest translation.. */
+@@ -77,6 +82,63 @@ enable_disable_opts (HWND hDlg)
+ xfree (uiserver);
+ }
+
++static void
++launch_kleo_config (HWND hDlg)
++{
++ char *uiserver = get_uiserver_name ();
++ bool showError = false;
++ if (uiserver)
++ {
++ std::string path (uiserver);
++ xfree (uiserver);
++ if (path.find("kleopatra.exe") != std::string::npos)
++ {
++ size_t dpos;
++ if ((dpos = path.find(" --daemon")) != std::string::npos)
++ {
++ path.erase(dpos, strlen(" --daemon"));
++ }
++ auto ctx = GpgME::Context::createForEngine(GpgME::SpawnEngine);
++ if (!ctx)
++ {
++ log_error ("%s:%s: No spawn engine.",
++ SRCNAME, __func__);
++ }
++ std::string parentWid = std::to_string ((int) (intptr_t) hDlg);
++ const char *argv[] = {path.c_str(),
++ "--config",
++ "--parent-windowid",
++ parentWid.c_str(),
++ NULL };
++ log_debug ("%s:%s: Starting %s %s %s",
++ SRCNAME, __func__, path.c_str(), argv[1], argv[2]);
++ GpgME::Data d(GpgME::Data::null);
++ ctx->spawnAsync(path.c_str(), argv, d, d,
++ d, (GpgME::Context::SpawnFlags) (
++ GpgME::Context::SpawnAllowSetFg |
++ GpgME::Context::SpawnShowWindow));
++ }
++ else
++ {
++ showError = true;
++ }
++ }
++ else
++ {
++ showError = true;
++ }
++
++ if (showError)
++ {
++ MessageBox (NULL,
++ _("Could not find Kleopatra.\n"
++ "Please reinstall Gpg4win with the Kleopatra component enabled."),
++ _("GpgOL"),
++ MB_ICONINFORMATION|MB_OK);
++ }
++
++}
++
+ static INT_PTR CALLBACK
+ options_window_proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+ {
+@@ -149,7 +211,7 @@ options_window_proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+ break;
+ }
+ case IDC_GPG_CONF:
+- engine_start_confdialog (hDlg);
++ launch_kleo_config (hDlg);
+ break;
+ case IDC_GPG_OPTIONS:
+ config_dialog_box (hDlg);
+--
+2.11.0