[git] Pinentry - branch, master, updated. pinentry-0.8.3-12-gf4d14ff

by Andre Heinecke cvs at cvs.gnupg.org
Wed Aug 6 15:07:33 CEST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The standard pinentry collection".

The branch, master has been updated
       via  f4d14ffcf2e04b1938c00a0ef1504e0e932631fd (commit)
       via  47476d2f288a22c29567ae2c179ce0472db4257e (commit)
      from  41d046022e912c76cb424c906064745e732f01f3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f4d14ffcf2e04b1938c00a0ef1504e0e932631fd
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Aug 6 15:05:25 2014 +0200

    Add fallbacks for SetForegroundWindow
    
        If that foreground window fails pinentry-qt now tries to
        attach to the current foreground process and then tries
        to set the foreground window again. If that fails it also
        calls ShowWindow as a last resort.
    
        * qt4/pinentrydialog.cpp (raiseWindow): Add fallbacks in
        case SetForegroundWindow fails.

diff --git a/NEWS b/NEWS
index 2741f5c..5bd874f 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ Noteworthy changes in version 0.8.4 (unreleased)
 
  * Qt4: Raise confirm message windows into foreground
 
+ * Qt4 (Windows): Improve the way pinentry-qt raises itself in
+ the foreground.
+
 Noteworthy changes in version 0.8.3 (2013-04-26)
 ------------------------------------------------
 
diff --git a/qt4/pinentrydialog.cpp b/qt4/pinentrydialog.cpp
index b16a74f..3a6dacc 100644
--- a/qt4/pinentrydialog.cpp
+++ b/qt4/pinentrydialog.cpp
@@ -45,31 +45,50 @@
    versions.  This is the reason why gpg-agent employs its
    AllowSetForegroundWindow callback machinery to ask the supposed to
    be be calling process to allow a pinentry to go into the
-   foreground.  */
-// #ifdef Q_WS_WIN
-// void SetForegroundWindowEx( HWND hWnd )
-// {
-//    //Attach foreground window thread to our thread
-//    const DWORD ForeGroundID = GetWindowThreadProcessId(::GetForegroundWindow(),NULL);
-//    const DWORD CurrentID   = GetCurrentThreadId();
- 
-//    AttachThreadInput ( ForeGroundID, CurrentID, TRUE );
-//    //Do our stuff here
-//    HWND hLastActivePopupWnd = GetLastActivePopup( hWnd );
-//    SetForegroundWindow( hLastActivePopupWnd );
- 
-//    //Detach the attached thread
-//    AttachThreadInput ( ForeGroundID, CurrentID, FALSE );
-// }// End SetForegroundWindowEx
-// #endif
+   foreground.
 
-void raiseWindow( QWidget* w )
-{
+   [ah] This is a Hack to workaround the fact that Foregrounding
+   a Window is so restricted that it AllowSetForegroundWindow
+   does not always work (e.g. when the ForegroundWindow timeout
+   has not expired.
+   */
 #ifdef Q_WS_WIN
-    SetForegroundWindow( w->winId() );
+WINBOOL SetForegroundWindowEx( HWND hWnd )
+{
+   //Attach foreground window thread to our thread
+   const DWORD ForeGroundID = GetWindowThreadProcessId(::GetForegroundWindow(),NULL);
+   const DWORD CurrentID   = GetCurrentThreadId();
+   WINBOOL retval;
+
+   AttachThreadInput ( ForeGroundID, CurrentID, TRUE );
+   //Do our stuff here
+   HWND hLastActivePopupWnd = GetLastActivePopup( hWnd );
+   retval = SetForegroundWindow( hLastActivePopupWnd );
+
+   //Detach the attached thread
+   AttachThreadInput ( ForeGroundID, CurrentID, FALSE );
+   return retval;
+}// End SetForegroundWindowEx
 #endif
+
+void raiseWindow( QWidget* w )
+{
+    /* Maybe Qt will become agressive enough one day that
+     * this is enough on windows too*/
     w->raise();
     w->activateWindow();
+#ifdef Q_WS_WIN
+    /* In the meantime we do our own attention grabbing */
+    if (!SetForegroundWindow (w->winId()) &&
+            !SetForegroundWindowEx (w->winId()))  {
+        OutputDebugString("SetForegroundWindow (ex) failed");
+        /* Yet another fallback which will not work on some
+         * versions and is not recommended by msdn */
+        if (!ShowWindow (w->winId(), SW_SHOWNORMAL)) {
+            OutputDebugString ("ShowWindow failed.");
+        }
+    }
+#endif
 }
 
 QPixmap icon( QStyle::StandardPixmap which )

commit 47476d2f288a22c29567ae2c179ce0472db4257e
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Aug 6 15:01:54 2014 +0200

    Use raiseWindow also for confirm dialogs
    
        This should fix the case that the dialog opened
        in the foreground but a warning / confirm dialog
        opened in the background.
    
        * qt4/pinentryconfirm.cpp, qt4/pinentryconfirm.h (showEvent):
        New overwrite base class method to call raiseWindow.
        * NEWS: Mention this.

diff --git a/NEWS b/NEWS
index fbc3708..2741f5c 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Noteworthy changes in version 0.8.4 (unreleased)
 
  * Qt4: Improved accessiblity
 
+ * Qt4: Raise confirm message windows into foreground
 
 Noteworthy changes in version 0.8.3 (2013-04-26)
 ------------------------------------------------
diff --git a/qt4/pinentryconfirm.cpp b/qt4/pinentryconfirm.cpp
index f7a1d63..dfbd19f 100644
--- a/qt4/pinentryconfirm.cpp
+++ b/qt4/pinentryconfirm.cpp
@@ -18,6 +18,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
 #include "pinentryconfirm.h"
+#include "pinentrydialog.h"
 #include <QAbstractButton>
 
 PinentryConfirm::PinentryConfirm(Icon icon, int timeout, const QString &title,
@@ -31,6 +32,13 @@ PinentryConfirm::PinentryConfirm(Icon icon, int timeout, const QString &title,
     }
     setAccessibleDescription (desc);
     setAccessibleName (title);
+    raiseWindow (this);
+}
+
+void PinentryConfirm::showEvent( QShowEvent* event )
+{
+    QDialog::showEvent( event );
+    raiseWindow( this );
 }
 
 void PinentryConfirm::slotTimeout()
diff --git a/qt4/pinentryconfirm.h b/qt4/pinentryconfirm.h
index 3113750..44fb3ae 100644
--- a/qt4/pinentryconfirm.h
+++ b/qt4/pinentryconfirm.h
@@ -36,6 +36,9 @@ class PinentryConfirm : public QMessageBox
 
     private:
 	QTimer *_timer;
+
+    protected:
+    /* reimp */ void showEvent( QShowEvent* event );
 };
 
 #endif

-----------------------------------------------------------------------

Summary of changes:
 NEWS                    |    4 ++++
 qt4/pinentryconfirm.cpp |    8 +++++++
 qt4/pinentryconfirm.h   |    3 +++
 qt4/pinentrydialog.cpp  |   59 +++++++++++++++++++++++++++++++----------------
 4 files changed, 54 insertions(+), 20 deletions(-)


hooks/post-receive
-- 
The standard pinentry collection
http://git.gnupg.org




More information about the Gnupg-commits mailing list