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 <caolanm@redhat.com>
This commit is contained in:
parent
7d506f6bb4
commit
df788fcc30
22 changed files with 86 additions and 41 deletions
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() );
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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: */
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue