vcl/inc/unx/gtk/gtkdata.hxx | 2 + vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx | 33 ++++++++++++++++++++++++++++++- vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx | 2 - vcl/unx/gtk/gtkdata.cxx | 12 +++++++++++ vcl/unx/gtk3/gtk3gtkdata.cxx | 12 +++++++++++ 5 files changed, 59 insertions(+), 2 deletions(-)
New commits: commit 7f20ca352840c5b877f7aebdf021b5ea65835560 Author: Caolán McNamara <[email protected]> Date: Fri Sep 1 09:27:48 2017 +0100 Use FPicker parentwindow argument to set file picker parent the secret argument of xParentWindow already exists here we use XSystemDependentWindowPeer and getWindowHandle to get the window handle (which is a bit spurious in the wayland case but close enough) and then look up all our toplevel frames for a matching one in order to get the associated widget to use a a parent window If the fpicker was still in fpicker we could get the vcl::Window for the xParentWindow and get the frame directly from that but that necessitates linking to toolkit, so do it this way instead Change-Id: Ia6f51e6d2016587c1f314d7a0b1f9a20269facd0 Reviewed-on: https://gerrit.libreoffice.org/41808 Tested-by: Jenkins <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx index 249bc1add2bf..60a0940d9439 100644 --- a/vcl/inc/unx/gtk/gtkdata.hxx +++ b/vcl/inc/unx/gtk/gtkdata.hxx @@ -147,6 +147,8 @@ public: GtkSalSystem* getSystem() const { return m_pSys; } + GtkWidget* findGtkWidgetForNativeHandle(sal_uIntPtr hWindow) const; + virtual void deregisterFrame( SalFrame* pFrame ) override; GdkCursor *getCursor( PointerStyle ePointerStyle ); #if GTK_CHECK_VERSION(3,0,0) diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx index f487bed1670e..2c648a6b9c67 100644 --- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx +++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx @@ -25,19 +25,24 @@ #include <config_gio.h> +#include <com/sun/star/awt/SystemDependentXWindow.hpp> #include <com/sun/star/awt/Toolkit.hpp> +#include <com/sun/star/awt/XSystemDependentWindowPeer.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/lang/SystemDependent.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <osl/diagnose.h> #include <osl/process.h> +#include <rtl/process.h> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/ui/dialogs/ControlActions.hpp> #include <com/sun/star/uno/Any.hxx> #include <comphelper/string.hxx> +#include "unx/gtk/gtkdata.hxx" #include "unx/gtk/gtkinst.hxx" #include <vcl/svapp.hxx> @@ -78,6 +83,7 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext SalGtkPicker( xContext ), SalGtkFilePicker_Base( m_rbHelperMtx ), m_pFilterList( nullptr ), + m_pParentWidget ( nullptr ), m_pVBox ( nullptr ), mnHID_FolderChange( 0 ), mnHID_SelectionChange( 0 ), @@ -891,7 +897,12 @@ sal_Int16 SAL_CALL SalGtkFilePicker::execute() frame::Desktop::create(m_xContext), UNO_QUERY_THROW ); - GtkWindow *pParent = RunDialog::GetTransientFor(); + GtkWindow *pParent = GTK_WINDOW(m_pParentWidget); + if (!pParent) + { + SAL_WARN( "vcl.gtk", "no parent widget set"); + pParent = RunDialog::GetTransientFor(); + } if (pParent) gtk_window_set_transient_for(GTK_WINDOW(m_pDialog), pParent); RunDialog* pRunDialog = new RunDialog(m_pDialog, xToolkit, xDesktop); @@ -1559,6 +1570,26 @@ void SAL_CALL SalGtkFilePicker::initialize( const uno::Sequence<uno::Any>& aArgu sal_Int16 templateId = -1; aAny >>= templateId; + css::uno::Reference<css::awt::XWindow> xParentWindow; + if (aArguments.getLength() > 1) + { + aArguments[1] >>= xParentWindow; + } + + if (xParentWindow.is()) + { + css::uno::Reference<css::awt::XSystemDependentWindowPeer> xSysDepWin(xParentWindow, css::uno::UNO_QUERY); + if (xSysDepWin.is()) + { + css::uno::Sequence<sal_Int8> aProcessIdent(16); + rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8*>(aProcessIdent.getArray())); + aAny = xSysDepWin->getWindowHandle(aProcessIdent, css::lang::SystemDependent::SYSTEM_XWINDOW); + css::awt::SystemDependentXWindow tmp; + aAny >>= tmp; + m_pParentWidget = GetGtkSalData()->GetGtkDisplay()->findGtkWidgetForNativeHandle(tmp.WindowHandle); + } + } + GtkFileChooserAction eAction = GTK_FILE_CHOOSER_ACTION_OPEN; const gchar *first_button_text = GTK_STOCK_OPEN; diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx index 03ee6f5e7346..e03ff2928720 100644 --- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx +++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx @@ -152,8 +152,8 @@ class SalGtkFilePicker : public SalGtkPicker, public SalGtkFilePicker_Base m_xListener; OUString msPlayLabel; FilterList *m_pFilterList; + GtkWidget *m_pParentWidget; GtkWidget *m_pVBox; - GtkWidget *m_pFilterExpander; GtkWidget *m_pFilterView; GtkListStore *m_pFilterStore; diff --git a/vcl/unx/gtk/gtkdata.cxx b/vcl/unx/gtk/gtkdata.cxx index afc0aa8c7dce..4eb6b6c2de8f 100644 --- a/vcl/unx/gtk/gtkdata.cxx +++ b/vcl/unx/gtk/gtkdata.cxx @@ -877,6 +877,18 @@ void GtkSalDisplay::PostUserEvent() GetGtkSalData()->PostUserEvent(); } +GtkWidget* GtkSalDisplay::findGtkWidgetForNativeHandle(sal_uIntPtr hWindow) const +{ + for (auto it = m_aFrames.begin(); it != m_aFrames.end(); ++it) + { + SalFrame* pFrame = *it; + const SystemEnvData* pEnvData = pFrame->GetSystemData(); + if (pEnvData->aWindow == hWindow) + return GTK_WIDGET(pEnvData->pWidget); + } + return nullptr; +} + void GtkSalDisplay::deregisterFrame( SalFrame* pFrame ) { if( m_pCapture == pFrame ) diff --git a/vcl/unx/gtk3/gtk3gtkdata.cxx b/vcl/unx/gtk3/gtk3gtkdata.cxx index 5308d57be70f..29937ef036b2 100644 --- a/vcl/unx/gtk3/gtk3gtkdata.cxx +++ b/vcl/unx/gtk3/gtk3gtkdata.cxx @@ -839,6 +839,18 @@ void GtkSalDisplay::PostUserEvent() GetGtkSalData()->PostUserEvent(); } +GtkWidget* GtkSalDisplay::findGtkWidgetForNativeHandle(sal_uIntPtr hWindow) const +{ + for (auto it = m_aFrames.begin(); it != m_aFrames.end(); ++it) + { + SalFrame* pFrame = *it; + const SystemEnvData* pEnvData = pFrame->GetSystemData(); + if (pEnvData->aWindow == hWindow) + return GTK_WIDGET(pEnvData->pWidget); + } + return nullptr; +} + void GtkSalDisplay::deregisterFrame( SalFrame* pFrame ) { if( m_pCapture == pFrame )
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
