[KPhotoAlbum] Problems with focus stealing prevention

Robert Krawitz rlk at alum.mit.edu
Sat Aug 25 19:12:55 CEST 2018

With focus stealing prevention set to Extreme, I'm seeing a few
problems with kpa:

1) The viewer widget does not get raised or activated, and stays under
the thumbnail view.

2) The annotation dialog, when launched from the thumbnail view,
likewise does not get raised or activated.

This appears to be, in both cases, because the widget in question does
not set its parent, so the window manager does not recognize the
relationship and allow the window in question to be raised or

I can make the annotation dialog receive focus with the following
change, but that also results in the viewer getting buried:

diff --git a/MainWindow/Window.cpp b/MainWindow/Window.cpp
index 78c791da..2b0d1e86 100644
--- a/MainWindow/Window.cpp
+++ b/MainWindow/Window.cpp
@@ -478,7 +478,7 @@ void MainWindow::Window::createAnnotationDialog()
     if ( !m_annotationDialog.isNull() )
-    m_annotationDialog = new AnnotationDialog::Dialog( nullptr );
+    m_annotationDialog = new AnnotationDialog::Dialog( this );
     connect(m_annotationDialog.data(), &AnnotationDialog::Dialog::imageRotated, this, &Window::slotImageRotated);
I could probably do something similar with the viewer, but there's
this comment, which dates to 2004 in ViewerWidget.cpp:

// Notice the parent is zero to allow other windows to come on top of it.

I'm not quite sure the reasoning behind this.

As for why I like extreme focus stealing prevention: there are some
cases where LibreOffice manages to grab focus even at High focus
stealing prevention.

Robert Krawitz                                     <rlk at alum.mit.edu>

***  MIT Engineers   A Proud Tradition   http://mitathletics.com  ***
Member of the League for Programming Freedom  --  http://ProgFree.org
Project lead for Gutenprint   --    http://gimp-print.sourceforge.net

"Linux doesn't dictate how I work, I dictate how Linux works."
--Eric Crampton

More information about the KPhotoAlbum mailing list