avmedia/source/gstreamer/gstplayer.cxx            |   11 +++++----
 avmedia/source/viewer/mediawindow_impl.cxx        |    8 +++++-
 include/vcl/sysdata.hxx                           |   26 +++++++++++-----------
 slideshow/source/engine/shapes/viewmediashape.cxx |    9 +++++--
 toolkit/source/awt/vclxsystemdependentwindow.cxx  |    2 -
 toolkit/source/awt/vclxtopwindow.cxx              |    2 -
 vcl/inc/salframe.hxx                              |    4 +++
 vcl/inc/unx/gtk/gtkframe.hxx                      |    4 ++-
 vcl/qt5/Qt5FilePicker.cxx                         |    2 -
 vcl/source/opengl/x11/context.cxx                 |    4 +--
 vcl/source/window/syschild.cxx                    |   15 +++++++++++-
 vcl/unx/generic/app/i18n_ic.cxx                   |    4 +--
 vcl/unx/generic/app/saldisp.cxx                   |    2 -
 vcl/unx/generic/gdi/cairo_xlib_cairo.cxx          |    4 +--
 vcl/unx/generic/gdi/cairo_xlib_cairo.hxx          |    3 +-
 vcl/unx/generic/gdi/salgdi.cxx                    |    2 -
 vcl/unx/generic/gdi/salgdi2.cxx                   |    2 -
 vcl/unx/generic/window/salobj.cxx                 |    6 ++---
 vcl/unx/gtk3/gtk3gtkdata.cxx                      |    2 -
 vcl/unx/gtk3/gtk3gtkframe.cxx                     |   10 +++++++-
 vcl/unx/gtk3/gtk3gtkobject.cxx                    |    3 +-
 vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx    |    2 -
 22 files changed, 86 insertions(+), 41 deletions(-)

New commits:
commit df788fcc308bbf8950ad8a22a1f8290681b64f0d
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue Jan 26 10:03:37 2021 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed Jan 27 10:18:50 2021 +0100

    tdf#139609 avoid fetching unnecessary xid under gtk3
    
    because of the side effects
    
    using a bare GtkGrid as m_pSocket in vcl/unx/gtk3/gtk3gtkobject.cxx
    is perhaps a poor choice, getting its xid causes poor side effects
    wrt events belonging to its child widgets getting delivered to
    the SalFrame widget, so duplicate scrolling after showing a opengl
    slide and/or showing a video and lots of flickering
    
    we're (generally at least) not using the xid under gtk3 so don't set it
    unless it's explicitly asked for. Happily the gtk Player::createPlayerWindow
    doesn't use its arg[0] xid in any case, so don't bother setting it for
    that backend.
    
    Change-Id: I1c59a607a332635091782c3b49de10647558f301
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109941
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/avmedia/source/gstreamer/gstplayer.cxx 
b/avmedia/source/gstreamer/gstplayer.cxx
index 5d8d625ddf08..c15bd1adf6ea 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -880,11 +880,14 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL 
Player::createPlayerWindow( co
         g_object_set(G_OBJECT(mpPlaybin), "video-sink", pVideosink, nullptr);
         g_object_set(G_OBJECT(mpPlaybin), "force-aspect-ratio", FALSE, 
nullptr);
 
-        mnWindowID = pEnvData->GetWindowHandle();
-        mpDisplay = pEnvData->pDisplay;
-        SAL_INFO( "avmedia.gstreamer", AVVERSION "set window id to " << 
static_cast<int>(mnWindowID) << " XOverlay " << mpXOverlay);
+        if (!mbUseGtkSink)
+        {
+            mnWindowID = 
pEnvData->GetWindowHandle(pParentWindow->ImplGetFrame());
+            mpDisplay = pEnvData->pDisplay;
+            SAL_INFO( "avmedia.gstreamer", AVVERSION "set window id to " << 
static_cast<int>(mnWindowID) << " XOverlay " << mpXOverlay);
+        }
         gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
-        if ( mpXOverlay != nullptr )
+        if (!mbUseGtkSink && mpXOverlay)
             gst_video_overlay_set_window_handle( mpXOverlay, mnWindowID );
     }
 
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx 
b/avmedia/source/viewer/mediawindow_impl.cxx
index 50110cfd1748..316263c9a7b2 100644
--- a/avmedia/source/viewer/mediawindow_impl.cxx
+++ b/avmedia/source/viewer/mediawindow_impl.cxx
@@ -34,6 +34,7 @@
 #include <unotools/securityoptions.hxx>
 #include <vcl/bitmapex.hxx>
 #include <vcl/svapp.hxx>
+#include <vcl/sysdata.hxx>
 #include <vcl/commandevent.hxx>
 #include <vcl/event.hxx>
 #include <vcl/ptrstyle.hxx>
@@ -420,7 +421,12 @@ void MediaWindowImpl::onURLChanged()
         const Point aPoint;
         const Size aSize(mpChildWindow->GetSizePixel());
 
-        aArgs[0] <<= mpChildWindow->GetParentWindowHandle();
+        sal_IntPtr nParentWindowHandle(0);
+        const SystemEnvData* pEnvData = mpChildWindow->GetSystemData();
+        // tdf#139609 gtk doesn't need the handle, and fetching it is 
undesirable
+        if (!pEnvData || pEnvData->toolkit != SystemEnvData::Toolkit::Gtk3)
+            nParentWindowHandle = mpChildWindow->GetParentWindowHandle();
+        aArgs[0] <<= nParentWindowHandle;
         aArgs[1] <<= awt::Rectangle(aPoint.X(), aPoint.Y(), aSize.Width(), 
aSize.Height());
         aArgs[2] <<= reinterpret_cast<sal_IntPtr>(mpChildWindow.get());
 
diff --git a/include/vcl/sysdata.hxx b/include/vcl/sysdata.hxx
index ed93b524d699..63b7c810de3d 100644
--- a/include/vcl/sysdata.hxx
+++ b/include/vcl/sysdata.hxx
@@ -21,6 +21,9 @@
 #define INCLUDED_VCL_SYSDATA_HXX
 
 #include <sal/types.h>
+#include <vcl/dllapi.h>
+
+class SalFrame;
 
 #ifdef MACOSX
 // predeclare the native classes to avoid header/include problems
@@ -45,8 +48,10 @@ typedef struct CGContext *CGContextRef;
 #include <postwin.h>
 #endif
 
-struct SystemEnvData
+struct VCL_DLLPUBLIC SystemEnvData
 {
+    enum class Toolkit { Gen, Gtk3, Qt5 };
+    Toolkit             toolkit;        // the toolkit in use
 #if defined(_WIN32)
     HWND                hWnd;           // the window hwnd
 #elif defined( MACOSX )
@@ -57,18 +62,16 @@ struct SystemEnvData
 #elif defined( IOS )
     // Nothing
 #elif defined( UNX )
-    enum class Toolkit { Gtk3, Qt5, Gen };
     enum class Platform { Wayland, Xcb };
 
     void*               pDisplay;       // the relevant display connection
-    void*               pSalFrame;      // contains a salframe, if object has 
one
+    SalFrame*           pSalFrame;      // contains a salframe, if object has 
one
     void*               pWidget;        // the corresponding widget
     void*               pVisual;        // the visual in use
     int                 nScreen;        // the current screen of the window
     // note: this is a "long" in Xlib *but* in the protocol it's only 32-bit
     // however, the GTK3 vclplug wants to store pointers in here!
     sal_IntPtr          aShellWindow;   // the window of the frame's shell
-    Toolkit             toolkit;        // the toolkit in use
     Platform            platform;       // the windowing system in use
 private:
     sal_uIntPtr         aWindow;        // the window of the object
@@ -79,29 +82,28 @@ public:
         aWindow = nWindow;
     }
 
-    sal_uIntPtr GetWindowHandle() const
-    {
-        return aWindow;
-    }
+    // SalFrame can be any SalFrame, just needed to determine which backend to 
use
+    // to resolve the window handle
+    sal_uIntPtr GetWindowHandle(const SalFrame* pReference) const;
 
 #endif
 
     SystemEnvData()
+        : toolkit(Toolkit::Gen)
 #if defined(_WIN32)
-        : hWnd(nullptr)
+        , hWnd(nullptr)
 #elif defined( MACOSX )
-        : mpNSView(nullptr)
+        , mpNSView(nullptr)
         , mbOpenGL(false)
 #elif defined( ANDROID )
 #elif defined( IOS )
 #elif defined( UNX )
-        : pDisplay(nullptr)
+        , pDisplay(nullptr)
         , pSalFrame(nullptr)
         , pWidget(nullptr)
         , pVisual(nullptr)
         , nScreen(0)
         , aShellWindow(0)
-        , toolkit(Toolkit())
         , platform(Platform())
         , aWindow(0)
 #endif
diff --git a/slideshow/source/engine/shapes/viewmediashape.cxx 
b/slideshow/source/engine/shapes/viewmediashape.cxx
index 950dacc22184..fdcfde36aa8f 100644
--- a/slideshow/source/engine/shapes/viewmediashape.cxx
+++ b/slideshow/source/engine/shapes/viewmediashape.cxx
@@ -24,6 +24,7 @@
 #include <sal/log.hxx>
 #include <vcl/canvastools.hxx>
 #include <vcl/syschild.hxx>
+#include <vcl/sysdata.hxx>
 #include <vcl/window.hxx>
 #include <vcl/graph.hxx>
 
@@ -432,9 +433,13 @@ namespace slideshow::internal
 
                         if( mxPlayer.is() )
                         {
-                            aArgs[ 0 ] <<=
-                                sal::static_int_cast< sal_IntPtr >( 
mpMediaWindow->GetParentWindowHandle() );
+                            sal_IntPtr nParentWindowHandle(0);
+                            const SystemEnvData* pEnvData = 
mpMediaWindow->GetSystemData();
+                            // tdf#139609 gtk doesn't need the handle, and 
fetching it is undesirable
+                            if (!pEnvData || pEnvData->toolkit != 
SystemEnvData::Toolkit::Gtk3)
+                                nParentWindowHandle = 
mpMediaWindow->GetParentWindowHandle();
 
+                            aArgs[ 0 ] <<= nParentWindowHandle;
                             aAWTRect.X = aAWTRect.Y = 0;
                             aArgs[ 1 ] <<= aAWTRect;
                             aArgs[ 2 ] <<= reinterpret_cast< sal_IntPtr >( 
mpMediaWindow.get() );
diff --git a/toolkit/source/awt/vclxsystemdependentwindow.cxx 
b/toolkit/source/awt/vclxsystemdependentwindow.cxx
index 371945627573..37d7f86d9d58 100644
--- a/toolkit/source/awt/vclxsystemdependentwindow.cxx
+++ b/toolkit/source/awt/vclxsystemdependentwindow.cxx
@@ -102,7 +102,7 @@ css::uno::Any VCLXSystemDependentWindow::getWindowHandle( 
const css::uno::Sequen
             {
                 css::awt::SystemDependentXWindow aSD;
                 aSD.DisplayPointer = sal::static_int_cast< sal_Int64 
>(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay));
-                aSD.WindowHandle = pSysData->GetWindowHandle();
+                aSD.WindowHandle = 
pSysData->GetWindowHandle(pWindow->ImplGetFrame());
                 aRet <<= aSD;
             }
 #endif
diff --git a/toolkit/source/awt/vclxtopwindow.cxx 
b/toolkit/source/awt/vclxtopwindow.cxx
index b0d070fb85a8..965312e6954b 100644
--- a/toolkit/source/awt/vclxtopwindow.cxx
+++ b/toolkit/source/awt/vclxtopwindow.cxx
@@ -79,7 +79,7 @@ css::uno::Any VCLXTopWindow::getWindowHandle( const 
css::uno::Sequence< sal_Int8
             {
                 css::awt::SystemDependentXWindow aSD;
                 aSD.DisplayPointer = sal::static_int_cast< sal_Int64 
>(reinterpret_cast< sal_IntPtr >(pSysData->pDisplay));
-                aSD.WindowHandle = pSysData->GetWindowHandle();
+                aSD.WindowHandle = 
pSysData->GetWindowHandle(pWindow->ImplGetFrame());
                 aRet <<= aSD;
             }
 #endif
diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx
index d55a40b1a93b..f79ae07ce9a8 100644
--- a/vcl/inc/salframe.hxx
+++ b/vcl/inc/salframe.hxx
@@ -215,6 +215,10 @@ public:
     virtual const SystemEnvData*
                             GetSystemData() const = 0;
 
+    // tdf#139609 SystemEnvData::GetWindowHandle() calls this to on-demand 
fill the aWindow
+    // member of SystemEnvData for backends that want to defer doing that
+    virtual void            ResolveWindowHandle(SystemEnvData& /*rData*/) 
const {};
+
     // get current modifier, button mask and mouse position
     struct SalPointerState
     {
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index ab4ea230bcf8..b62f5b2e786e 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -456,6 +456,8 @@ public:
     // returns system data (most prominent: window handle)
     virtual const SystemEnvData*    GetSystemData() const override;
 
+    virtual void                ResolveWindowHandle(SystemEnvData& rData) 
const override;
+
     // get current modifier and button mask
     virtual SalPointerState     GetPointerState() override;
 
@@ -497,7 +499,7 @@ public:
 
     static GtkSalFrame         *getFromWindow( GtkWidget *pWindow );
 
-    sal_uIntPtr                 GetNativeWindowHandle(GtkWidget *pWidget);
+    sal_uIntPtr                 GetNativeWindowHandle(GtkWidget *pWidget) 
const;
 
     //Call the usual SalFrame Callback, but catch uno exceptions and delegate
     //to GtkSalData to rethrow them after the gsignal is processed when its 
safe
diff --git a/vcl/qt5/Qt5FilePicker.cxx b/vcl/qt5/Qt5FilePicker.cxx
index a0d89f2fca1b..18e24580107e 100644
--- a/vcl/qt5/Qt5FilePicker.cxx
+++ b/vcl/qt5/Qt5FilePicker.cxx
@@ -844,7 +844,7 @@ void SAL_CALL Qt5FilePicker::initialize(const 
uno::Sequence<uno::Any>& args)
     const auto it
         = std::find_if(pFrames.begin(), pFrames.end(), [&aWindowHandle](auto 
pFrame) -> bool {
               const SystemEnvData* pData = pFrame->GetSystemData();
-              return pData && tools::Long(pData->GetWindowHandle()) == 
aWindowHandle;
+              return pData && tools::Long(pData->GetWindowHandle(pFrame)) == 
aWindowHandle;
           });
     if (it != pFrames.end())
         m_pParentWidget = static_cast<Qt5Frame*>(*it)->asChild();
diff --git a/vcl/source/opengl/x11/context.cxx 
b/vcl/source/opengl/x11/context.cxx
index 6371d66b4e6e..f1fc19e5a824 100644
--- a/vcl/source/opengl/x11/context.cxx
+++ b/vcl/source/opengl/x11/context.cxx
@@ -227,7 +227,7 @@ SystemWindowData 
X11OpenGLContext::generateWinData(vcl::Window* pParent, bool /*
     const SystemEnvData* sysData(pParent->GetSystemData());
 
     Display *dpy = static_cast<Display*>(sysData->pDisplay);
-    Window win = sysData->GetWindowHandle();
+    Window win = sysData->GetWindowHandle(pParent->ImplGetFrame());
 
     if( dpy == nullptr || !glXQueryExtension( dpy, nullptr, nullptr ) )
         return aWinData;
@@ -472,7 +472,7 @@ void X11OpenGLContext::initWindow()
     InitChildWindow(m_pChildWindow.get());
 
     m_aGLWin.dpy = static_cast<Display*>(pChildSysData->pDisplay);
-    m_aGLWin.win = pChildSysData->GetWindowHandle();
+    m_aGLWin.win = 
pChildSysData->GetWindowHandle(m_pChildWindow->ImplGetFrame());
     m_aGLWin.screen = pChildSysData->nScreen;
 
     Visual* pVisual = static_cast<Visual*>(pChildSysData->pVisual);
diff --git a/vcl/source/window/syschild.cxx b/vcl/source/window/syschild.cxx
index 967b3a29c91b..7e72d1044f06 100644
--- a/vcl/source/window/syschild.cxx
+++ b/vcl/source/window/syschild.cxx
@@ -23,6 +23,7 @@
 #include <vcl/syschild.hxx>
 
 #include <window.h>
+#include <salframe.hxx>
 #include <salinst.hxx>
 #include <salobj.hxx>
 #include <svdata.hxx>
@@ -173,7 +174,7 @@ sal_IntPtr SystemChildWindow::GetParentWindowHandle() const
 #elif defined IOS
     // Nothing
 #elif defined UNX
-    nRet = GetSystemData()->GetWindowHandle();
+    nRet = GetSystemData()->GetWindowHandle(ImplGetFrame());
 #endif
 
     return nRet;
@@ -184,4 +185,16 @@ void* SystemChildWindow::CreateGStreamerSink()
     return ImplGetSVData()->mpDefInst->CreateGStreamerSink(this);
 }
 
+#if defined( MACOSX )
+#elif defined( ANDROID )
+#elif defined( IOS )
+#elif defined( UNX )
+sal_uIntPtr SystemEnvData::GetWindowHandle(const SalFrame* pReference) const
+{
+    if (!aWindow && pReference)
+        pReference->ResolveWindowHandle(const_cast<SystemEnvData&>(*this));
+    return aWindow;
+}
+#endif
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/app/i18n_ic.cxx b/vcl/unx/generic/app/i18n_ic.cxx
index ce4faa918d8c..32390a888864 100644
--- a/vcl/unx/generic/app/i18n_ic.cxx
+++ b/vcl/unx/generic/app/i18n_ic.cxx
@@ -164,7 +164,7 @@ SalI18N_InputContext::SalI18N_InputContext ( SalFrame 
*pFrame ) :
     {
         const SystemEnvData* pEnv = pFrame->GetSystemData();
         ::Window  aClientWindow = pEnv->aShellWindow;
-        ::Window  aFocusWindow  = pEnv->GetWindowHandle();
+        ::Window  aFocusWindow  = pEnv->GetWindowHandle(pFrame);
 
         // for status callbacks and commit string callbacks
 #define PREEDIT_BUFSZ 16
@@ -548,7 +548,7 @@ SalI18N_InputContext::SetICFocus( SalFrame* pFocusFrame )
 
     const SystemEnvData* pEnv   = pFocusFrame->GetSystemData();
     ::Window  aClientWindow  = pEnv->aShellWindow;
-    ::Window  aFocusWindow   = pEnv->GetWindowHandle();
+    ::Window  aFocusWindow   = pEnv->GetWindowHandle(pFocusFrame);
 
     XSetICValues( maContext,
                   XNFocusWindow,       aFocusWindow,
diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx
index dc843f34ab67..b736d0a09249 100644
--- a/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -1849,7 +1849,7 @@ int SalDisplay::CaptureMouse( SalFrame *pCapture )
     if( !pEnv || !*pEnv )
     {
         int ret = XGrabPointer( GetDisplay(),
-                                
static_cast<::Window>(pEnvData->GetWindowHandle()),
+                                
static_cast<::Window>(pEnvData->GetWindowHandle(pCapture)),
                                 False,
                                 PointerMotionMask| 
ButtonPressMask|ButtonReleaseMask,
                                 GrabModeAsync,
diff --git a/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx 
b/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx
index 762564fbdab0..238224007f22 100644
--- a/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx
+++ b/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx
@@ -68,9 +68,9 @@ namespace cairo
         pRenderFormat(pSysDat.pXRenderFormat)
     {}
 
-    X11SysData::X11SysData( const SystemEnvData& pSysDat ) :
+    X11SysData::X11SysData( const SystemEnvData& pSysDat, const SalFrame* 
pReference ) :
         pDisplay(pSysDat.pDisplay),
-        hDrawable(pSysDat.GetWindowHandle()),
+        hDrawable(pSysDat.GetWindowHandle(pReference)),
         pVisual(pSysDat.pVisual),
         nScreen(pSysDat.nScreen),
         pRenderFormat(nullptr)
diff --git a/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx 
b/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx
index 398522c1594d..9b0dfb01b759 100644
--- a/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx
+++ b/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx
@@ -25,6 +25,7 @@
 #include <vcl/salgtype.hxx>
 
 struct BitmapSystemData;
+class SalFrame;
 struct SystemEnvData;
 struct SystemGraphicsData;
 
@@ -35,7 +36,7 @@ namespace cairo {
     {
         X11SysData();
         explicit X11SysData( const SystemGraphicsData& );
-        explicit X11SysData( const SystemEnvData& );
+        explicit X11SysData( const SystemEnvData&, const SalFrame* pReference 
);
 
         void*   pDisplay;       // the relevant display connection
         Drawable hDrawable;     // a drawable
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 41a0f7dfa9b4..ef99f1d4274e 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -517,7 +517,7 @@ namespace
         if( !pSysData )
             return cairo::X11SysData();
         else
-            return cairo::X11SysData(*pSysData);
+            return cairo::X11SysData(*pSysData, rWindow.ImplGetFrame());
     }
 
     cairo::X11SysData getSysData( const VirtualDevice& rVirDev )
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index 03ce5331bc58..d688f00fa743 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -51,7 +51,7 @@ void X11SalGraphics::YieldGraphicsExpose()
         for (auto pSalFrame : 
vcl_sal::getSalDisplay(GetGenericUnixSalData())->getFrames() )
         {
             const SystemEnvData* pEnvData = pSalFrame->GetSystemData();
-            if( Drawable(pEnvData->GetWindowHandle()) == aWindow )
+            if( Drawable(pEnvData->GetWindowHandle(pSalFrame)) == aWindow )
             {
                 pFrame = pSalFrame;
                 break;
diff --git a/vcl/unx/generic/window/salobj.cxx 
b/vcl/unx/generic/window/salobj.cxx
index a39c041a95ae..c24e138e5d6f 100644
--- a/vcl/unx/generic/window/salobj.cxx
+++ b/vcl/unx/generic/window/salobj.cxx
@@ -62,7 +62,7 @@ X11SalObject* X11SalObject::CreateObject( SalFrame* pParent, 
SystemWindowData* p
     SalDisplay* pSalDisp        = 
vcl_sal::getSalDisplay(GetGenericUnixSalData());
     const SystemEnvData* pEnv   = pParent->GetSystemData();
     Display* pDisp              = pSalDisp->GetDisplay();
-    ::Window aObjectParent      = 
static_cast<::Window>(pEnv->GetWindowHandle());
+    ::Window aObjectParent      = 
static_cast<::Window>(pEnv->GetWindowHandle(pParent));
     pObject->maParentWin = aObjectParent;
 
     // find out on which screen that window is
@@ -332,7 +332,7 @@ X11SalObject::SetPosSize( tools::Long nX, tools::Long nY, 
tools::Long nWidth, to
 void
 X11SalObject::Show( bool bVisible )
 {
-    if (!maSystemChildData.GetWindowHandle())
+    if (!maSystemChildData.GetWindowHandle(mpParent))
         return;
 
     if ( bVisible ) {
@@ -353,7 +353,7 @@ void X11SalObject::GrabFocus()
 {
     if( mbVisible )
          XSetInputFocus( static_cast<Display*>(maSystemChildData.pDisplay),
-                         maSystemChildData.GetWindowHandle(),
+                         maSystemChildData.GetWindowHandle(mpParent),
                          RevertToNone,
                          CurrentTime );
 }
diff --git a/vcl/unx/gtk3/gtk3gtkdata.cxx b/vcl/unx/gtk3/gtk3gtkdata.cxx
index 952fb503306d..1e46fd69b8bc 100644
--- a/vcl/unx/gtk3/gtk3gtkdata.cxx
+++ b/vcl/unx/gtk3/gtk3gtkdata.cxx
@@ -782,7 +782,7 @@ GtkWidget* 
GtkSalDisplay::findGtkWidgetForNativeHandle(sal_uIntPtr hWindow) cons
     for (auto pSalFrame : m_aFrames )
     {
         const SystemEnvData* pEnvData = pSalFrame->GetSystemData();
-        if (pEnvData->GetWindowHandle() == hWindow)
+        if (pEnvData->GetWindowHandle(pSalFrame) == hWindow)
             return GTK_WIDGET(pEnvData->pWidget);
     }
     return nullptr;
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 771cc0538581..7d40fd5a241b 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -2312,6 +2312,14 @@ const SystemEnvData* GtkSalFrame::GetSystemData() const
     return &m_aSystemData;
 }
 
+void GtkSalFrame::ResolveWindowHandle(SystemEnvData& rData) const
+{
+    if (!rData.pWidget)
+        return;
+    SAL_WARN("vcl.gtk3", "its undesirable to need the NativeWindowHandle, see 
tdf#139609");
+    
rData.SetWindowHandle(GetNativeWindowHandle(static_cast<GtkWidget*>(rData.pWidget)));
+}
+
 void GtkSalFrame::SetParent( SalFrame* pNewParent )
 {
     GtkWindow* pWindow = GTK_IS_WINDOW(m_pWindow) ? GTK_WINDOW(m_pWindow) : 
nullptr;
@@ -4473,7 +4481,7 @@ Size GtkSalDisplay::GetScreenSize( int nDisplayScreen )
     return Size( aRect.GetWidth(), aRect.GetHeight() );
 }
 
-sal_uIntPtr GtkSalFrame::GetNativeWindowHandle(GtkWidget *pWidget)
+sal_uIntPtr GtkSalFrame::GetNativeWindowHandle(GtkWidget *pWidget) const
 {
     (void) this;                // Silence loplugin:staticmethods
     GdkDisplay *pDisplay = getGdkDisplay();
diff --git a/vcl/unx/gtk3/gtk3gtkobject.cxx b/vcl/unx/gtk3/gtk3gtkobject.cxx
index afff5fa2291e..5dc67655568b 100644
--- a/vcl/unx/gtk3/gtk3gtkobject.cxx
+++ b/vcl/unx/gtk3/gtk3gtkobject.cxx
@@ -65,7 +65,8 @@ void GtkSalObjectBase::Init()
     gtk_widget_realize( m_pSocket );
 
     // system data
-    m_aSystemData.SetWindowHandle(m_pParent->GetNativeWindowHandle(m_pSocket));
+    // tdf#139609 deliberately defer using 
m_pParent->GetNativeWindowHandle(m_pSocket)) to set m_aSystemData.aWindow
+    // unless its explicitly needed
     m_aSystemData.aShellWindow  = reinterpret_cast<sal_IntPtr>(this);
     m_aSystemData.pSalFrame     = nullptr;
     m_aSystemData.pWidget       = m_pSocket;
diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx 
b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx
index 30d1f64afefc..4bccf1e24d72 100644
--- a/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx
+++ b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx
@@ -197,7 +197,7 @@ std::function<void()> 
Gtk3KDE5FilePickerIpc::blockMainWindow()
     if (!pSysData)
         return {};
 
-    sendCommand(Commands::SetWinId, pSysData->GetWindowHandle());
+    sendCommand(Commands::SetWinId, 
pSysData->GetWindowHandle(pParentWin->ImplGetFrame()));
 
     auto* pMainWindow = static_cast<GtkWidget*>(pSysData->pWidget);
     if (!pMainWindow)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to