[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: [PATCH] Qt 4.4 - Fix alien widgets in Dolphin
From:       "Robert Knight" <robertknight () gmail ! com>
Date:       2008-02-17 22:03:10
Message-ID: 13ed09c00802171403h4b91a12cj61c70eeb8794f280 () mail ! gmail ! com
[Download RAW message or body]

Hi David,

The attached patch attempts to fix this inside KIO by taking the top
level window associated with the passed widget in
JobUiDelegate::setWindow().

The patch does change the semantics of the API slightly since it
becomes possible that JobUiDelegate::window() does not return the same
value passed to JobUiDelegate::setWindow().

QWidget does provide an alternative, effectiveWinId() which goes up
the widget chain and finds the first widget that does have an X11
window associated with it and returns the id of that.  The setWindow()
change is simpler since it only occurs in one place.

Regards,
Robert.

On 15/02/2008, David Faure <faure@kde.org> wrote:
> On Thursday 14 February 2008, Robert Knight wrote:
> > Since the actual call to winId() happens deep inside KIO, perhaps it
> > would be better to put a fix there and only ever get winIds for
> > top-level widgets to prevent applications doing this accidentally.
> > Thoughts?
>
> Yes. We take the winId in several places in KIO, but in every case, the toplevel would
> be fine, it's only about associating dialogs from other processes (e.g. the cookie dialog)
> with the toplevel window that requested the KIO operation.
>
> --
> David Faure, faure@kde.org, sponsored by Trolltech to work on KDE,
> Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
>

["kdelibs_kio_jobuidelegate_always_use_top_level_window.patch" (text/x-patch)]

Index: jobuidelegate.h
===================================================================
--- jobuidelegate.h	(revision 776329)
+++ jobuidelegate.h	(working copy)
@@ -52,8 +52,11 @@
 public:
 
     /**
-     * Associate this job with a window given by @p window.
-     * @param window the window to associate to
+     * Associate this job with a window given by @p window.  If @p window
+	 * is not a top-level window then the job will be associated with the 
+	 * top-level parent of @p window.
+	 *
+     * @param window The window to associate the job with.
      * @see window()
      */
     virtual void setWindow(QWidget *window);
Index: jobuidelegate.cpp
===================================================================
--- jobuidelegate.cpp	(revision 776329)
+++ jobuidelegate.cpp	(working copy)
@@ -49,8 +49,11 @@
     delete d;
 }
 
-void KIO::JobUiDelegate::setWindow(QWidget *window)
+void KIO::JobUiDelegate::setWindow(QWidget *widget)
 {
+	// always associate the job with a top level window 
+	QWidget *window = widget ? widget->window() : 0;
+
     KDialogJobUiDelegate::setWindow(window);
     KIO::Scheduler::registerWindow(window);
 }

["kdelibs_kio_krun_always_use_top_level_window.patch" (text/x-patch)]

Index: krun.cpp
===================================================================
--- krun.cpp	(revision 776329)
+++ krun.cpp	(working copy)
@@ -554,7 +554,7 @@
           data.setSilent( KStartupInfoData::Yes );
       data.setDesktop( KWindowSystem::currentDesktop());
       if( window )
-          data.setLaunchedBy( window->winId());
+          data.setLaunchedBy( window->window()->winId() );
       KStartupInfo::sendStartup( id, data );
   }
   int pid = KProcessRunner::run( proc, binName, id );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic