Update ooo320-m1
[ooovba.git] / applied_patches / 0291-fpicker-kde-modal.diff
blobd8a62729eb0855ea9c84d9eba94310e050ee3806
1 diff --git a/fpicker/source/unx/kde/kdefpmain.cxx b/fpicker/source/unx/kde/kdefpmain.cxx
2 index eedda41..6506cfb 100644
3 --- fpicker/source/unx/kde/kdefpmain.cxx
4 +++ fpicker/source/unx/kde/kdefpmain.cxx
5 @@ -73,6 +73,12 @@
6 // Main
7 //////////////////////////////////////////////////////////////////////////
9 +static KCmdLineOptions sOptions[] =
11 + { "winid <argument>", I18N_NOOP("Window ID to which is the fpicker modal"), "0" },
12 + KCmdLineLastOption
13 +};
15 int main( int argc, char* argv[] )
17 // we fake the name of the application to have "OpenOffice.org" in the
18 @@ -87,12 +93,19 @@ int main( int argc, char* argv[] )
19 ::std::cerr << "kdefilepicker, an implementation of KDE file dialog for OOo." << ::std::endl
20 << "Type 'exit' and press Enter to finish." << ::std::endl;
22 + KCmdLineArgs::addCmdLineOptions( sOptions );
23 KCmdLineArgs::init( argc, argv, &qAboutData );
25 KLocale::setMainCatalogue( "kdialog" );
27 KApplication kApplication;
28 - //ModalityFilter qFilter( /*winid*/ 79691780 );
30 + // Setup the modality
31 + KCmdLineArgs *pArgs = KCmdLineArgs::parsedArgs();
32 + long nWinId = atol( pArgs->getOption( "winid" ) );
33 + pArgs->clear();
35 + ModalityFilter qModalityFilter( nWinId );
37 FileDialog aFileDialog( NULL, QString(), NULL, "kdefiledialog" );
39 diff --git a/fpicker/source/unx/kde/kdemodalityfilter.cxx b/fpicker/source/unx/kde/kdemodalityfilter.cxx
40 index b026f34..075fabe 100644
41 --- fpicker/source/unx/kde/kdemodalityfilter.cxx
42 +++ fpicker/source/unx/kde/kdemodalityfilter.cxx
43 @@ -91,8 +91,6 @@ bool ModalityFilter::eventFilter( QObject *pObject, QEvent *pEvent )
44 if ( pDlg != NULL && m_nWinId != 0 )
46 XSetTransientForHint( qt_xdisplay(), pDlg->winId(), m_nWinId );
47 - NETWinInfo aInfo( qt_xdisplay(), pDlg->winId(), qt_xrootwin(), NET::WMState );
48 - aInfo.setState( NET::Modal, NET::Modal );
49 m_nWinId = 0;
52 diff --git a/fpicker/source/unx/kde_unx/UnxFilePicker.cxx b/fpicker/source/unx/kde_unx/UnxFilePicker.cxx
53 index 9d3da56..4590b74 100644
54 --- fpicker/source/unx/kde_unx/UnxFilePicker.cxx
55 +++ fpicker/source/unx/kde_unx/UnxFilePicker.cxx
56 @@ -127,9 +127,15 @@
57 #include <UnxNotifyThread.hxx>
58 #endif
60 +#include <vcl/svapp.hxx>
61 +#include <vcl/sysdata.hxx>
62 +#include <vcl/syswin.hxx>
63 +#include <vcl/window.hxx>
65 #include <sys/wait.h>
66 #include <unistd.h>
67 #include <fcntl.h>
68 +#include <stdio.h>
70 #include <iostream>
72 @@ -528,7 +533,7 @@ void SAL_CALL UnxFilePicker::setLabel( sal_Int16 nControlId, const ::rtl::OUStri
73 sendCommand( aBuffer.makeStringAndClear() );
76 -rtl::OUString SAL_CALL UnxFilePicker::getLabel(sal_Int16 nControlId)
77 +rtl::OUString SAL_CALL UnxFilePicker::getLabel(sal_Int16 /*nControlId*/)
78 throw ( uno::RuntimeException )
80 // FIXME getLabel() is not yet implemented
81 @@ -784,10 +789,29 @@ void UnxFilePicker::initFilePicker()
83 #endif
85 - // FIXME: window id, etc.
86 + // The executable name
87 const char *pFname = "kdefilepicker";
89 - execlp( pFname, pFname, NULL );
90 + // ID of the main window
91 + const int nIdLen = 20;
92 + char pWinId[nIdLen] = "0";
94 + // TODO pass here the real parent (not possible for system dialogs
95 + // yet), and default to GetDefDialogParent() only when the real parent
96 + // is NULL
97 + Window *pParentWin = Application::GetDefDialogParent();
98 + if ( pParentWin )
99 + {
100 + const SystemEnvData* pSysData = ((SystemWindow *)pParentWin)->GetSystemData();
101 + if ( pSysData )
103 + snprintf( pWinId, nIdLen, "%ld", pSysData->aWindow ); // unx only
104 + pWinId[nIdLen-1] = 0;
108 + // Execute the fpicker implementation
109 + execlp( pFname, pFname, "--winid", pWinId, NULL );
111 // Error, finish the child
112 exit( -1 );