From b74bcd6b39b40a13d09bb2b5d303b1903f1b0a5f Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Wed, 25 Aug 2010 17:54:25 +0200 Subject: fpicker-kde-modal.diff: KDE fpicker should be modal. n#265718. --- fpicker/source/unx/kde/kdefpmain.cxx | 15 +++++++++++++- fpicker/source/unx/kde/kdemodalityfilter.cxx | 2 -- fpicker/source/unx/kde_unx/UnxFilePicker.cxx | 31 +++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/fpicker/source/unx/kde/kdefpmain.cxx b/fpicker/source/unx/kde/kdefpmain.cxx index 30c832bc613b..201c389ddf93 100644 --- a/fpicker/source/unx/kde/kdefpmain.cxx +++ b/fpicker/source/unx/kde/kdefpmain.cxx @@ -40,6 +40,12 @@ // Main ////////////////////////////////////////////////////////////////////////// +static KCmdLineOptions sOptions[] = +{ + { "winid ", I18N_NOOP("Window ID to which is the fpicker modal"), "0" }, + KCmdLineLastOption +}; + int main( int argc, char* argv[] ) { // we fake the name of the application to have "OpenOffice.org" in the @@ -54,12 +60,19 @@ int main( int argc, char* argv[] ) ::std::cerr << "kdefilepicker, an implementation of KDE file dialog for OOo." << ::std::endl << "Type 'exit' and press Enter to finish." << ::std::endl; + KCmdLineArgs::addCmdLineOptions( sOptions ); KCmdLineArgs::init( argc, argv, &qAboutData ); KLocale::setMainCatalogue( "kdialog" ); KApplication kApplication; - //ModalityFilter qFilter( /*winid*/ 79691780 ); + + // Setup the modality + KCmdLineArgs *pArgs = KCmdLineArgs::parsedArgs(); + long nWinId = atol( pArgs->getOption( "winid" ) ); + pArgs->clear(); + + ModalityFilter qModalityFilter( nWinId ); FileDialog aFileDialog( NULL, QString(), NULL, "kdefiledialog" ); diff --git a/fpicker/source/unx/kde/kdemodalityfilter.cxx b/fpicker/source/unx/kde/kdemodalityfilter.cxx index c214bca001e8..cf39da77eb85 100644 --- a/fpicker/source/unx/kde/kdemodalityfilter.cxx +++ b/fpicker/source/unx/kde/kdemodalityfilter.cxx @@ -57,8 +57,6 @@ bool ModalityFilter::eventFilter( QObject *pObject, QEvent *pEvent ) if ( pDlg != NULL && m_nWinId != 0 ) { XSetTransientForHint( qt_xdisplay(), pDlg->winId(), m_nWinId ); - NETWinInfo aInfo( qt_xdisplay(), pDlg->winId(), qt_xrootwin(), NET::WMState ); - aInfo.setState( NET::Modal, NET::Modal ); m_nWinId = 0; } } diff --git a/fpicker/source/unx/kde_unx/UnxFilePicker.cxx b/fpicker/source/unx/kde_unx/UnxFilePicker.cxx index a712e779e6f5..0ae7c4dfd480 100644 --- a/fpicker/source/unx/kde_unx/UnxFilePicker.cxx +++ b/fpicker/source/unx/kde_unx/UnxFilePicker.cxx @@ -46,9 +46,15 @@ #include #include +#include +#include +#include +#include + #include #include #include +#include #include @@ -447,7 +453,7 @@ void SAL_CALL UnxFilePicker::setLabel( sal_Int16 nControlId, const ::rtl::OUStri sendCommand( aBuffer.makeStringAndClear() ); } -rtl::OUString SAL_CALL UnxFilePicker::getLabel(sal_Int16 nControlId) +rtl::OUString SAL_CALL UnxFilePicker::getLabel(sal_Int16 /*nControlId*/) throw ( uno::RuntimeException ) { // FIXME getLabel() is not yet implemented @@ -703,10 +709,29 @@ void UnxFilePicker::initFilePicker() } #endif - // FIXME: window id, etc. + // The executable name const char *pFname = "kdefilepicker"; - execlp( pFname, pFname, NULL ); + // ID of the main window + const int nIdLen = 20; + char pWinId[nIdLen] = "0"; + + // TODO pass here the real parent (not possible for system dialogs + // yet), and default to GetDefDialogParent() only when the real parent + // is NULL + Window *pParentWin = Application::GetDefDialogParent(); + if ( pParentWin ) + { + const SystemEnvData* pSysData = ((SystemWindow *)pParentWin)->GetSystemData(); + if ( pSysData ) + { + snprintf( pWinId, nIdLen, "%ld", pSysData->aWindow ); // unx only + pWinId[nIdLen-1] = 0; + } + } + + // Execute the fpicker implementation + execlp( pFname, pFname, "--winid", pWinId, NULL ); // Error, finish the child exit( -1 ); -- cgit