vcl: Get Toolkit from SalInstance, not SystemEnvData
SystemEnvData holds data specific to a single frame/object, but the toolkit used is specific to the SalInstance/vcl plugin. Instead of having a SystemEnvData::toolkit member that needs to be set for each object, introduce a SalInstance::GetToolkit getter and a corresponding Application::GetToolkit that calls it. Change-Id: I052f122e991bec745af88d3f43847e4d77fb4ba4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201536 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
This commit is contained in:
@@ -880,7 +880,7 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
|
||||
// tdf#124027: the position of embedded window is identical w/ the position
|
||||
// of media object in all other vclplugs (kf5, gen), in gtk3 w/o gtksink it
|
||||
// needs to be translated
|
||||
if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
|
||||
if (Application::GetToolkit() == Toolkit::Gtk)
|
||||
{
|
||||
Point aPoint = pParentWindow->GetPosPixel();
|
||||
maArea.X = aPoint.getX();
|
||||
@@ -892,7 +892,7 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
|
||||
GstElement *pVideosink = static_cast<GstElement*>(pParentWindow->CreateGStreamerSink());
|
||||
if (pVideosink)
|
||||
{
|
||||
if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
|
||||
if (Application::GetToolkit() == Toolkit::Gtk)
|
||||
mbUseGtkSink = true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -443,9 +443,8 @@ void MediaWindowImpl::onURLChanged()
|
||||
const Size aSize(mpChildWindow->GetSizePixel());
|
||||
|
||||
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::Gtk)
|
||||
if (Application::GetToolkit() != Toolkit::Gtk)
|
||||
nParentWindowHandle = mpChildWindow->GetParentWindowHandle();
|
||||
uno::Sequence<uno::Any> aArgs{
|
||||
uno::Any(nParentWindowHandle),
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
enum class Toolkit
|
||||
{
|
||||
Invalid,
|
||||
Gen,
|
||||
Gtk,
|
||||
Qt
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <tools/long.hxx>
|
||||
#include <vcl/dllapi.h>
|
||||
#include <vcl/IDialogRenderable.hxx>
|
||||
#include <vcl/Toolkit.hxx>
|
||||
#include <vcl/inputtypes.hxx>
|
||||
#include <i18nlangtag/lang.h>
|
||||
#include <o3tl/typed_flags_set.hxx>
|
||||
@@ -960,6 +961,9 @@ public:
|
||||
*/
|
||||
static OUString GetDisplayName();
|
||||
|
||||
/** Get the toolkit. */
|
||||
static Toolkit GetToolkit();
|
||||
|
||||
/** Get the toolkit's name. e.g. gtk3
|
||||
|
||||
@returns The toolkit name.
|
||||
|
||||
@@ -51,8 +51,6 @@ typedef struct CGContext *CGContextRef;
|
||||
|
||||
struct VCL_DLLPUBLIC SystemEnvData
|
||||
{
|
||||
enum class Toolkit { Invalid, Gen, Gtk, Qt };
|
||||
Toolkit toolkit; // the toolkit in use
|
||||
#if defined(_WIN32)
|
||||
HWND hWnd; // the window hwnd
|
||||
#elif defined( MACOSX )
|
||||
@@ -87,16 +85,15 @@ public:
|
||||
#endif
|
||||
|
||||
SystemEnvData()
|
||||
: toolkit(Toolkit::Invalid)
|
||||
#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)
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <sfx2/printer.hxx>
|
||||
#include <vcl/cursor.hxx>
|
||||
#include <vcl/settings.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
#include <o3tl/unit_conversion.hxx>
|
||||
#include <osl/diagnose.h>
|
||||
#include <tools/UnitConversion.hxx>
|
||||
@@ -1823,7 +1824,7 @@ void ScGridWindow::DrawHiddenIndicator( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW n
|
||||
aLineInfo.SetDistance(15);
|
||||
// round caps except when running VCL_PLUGIN=gen due to a performance issue
|
||||
// https://bugs.documentfoundation.org/show_bug.cgi?id=128258#c14
|
||||
if (mrViewData.GetActiveWin()->GetSystemData()->toolkit != SystemEnvData::Toolkit::Gen)
|
||||
if (Application::GetToolkit() != Toolkit::Gen)
|
||||
aLineInfo.SetLineCap(css::drawing::LineCap_ROUND);
|
||||
aLineInfo.SetDotLen(1);
|
||||
for (int i=nX1; i<nX2; i++) {
|
||||
|
||||
@@ -417,7 +417,7 @@ namespace dlgprov
|
||||
}
|
||||
|
||||
// create a peer
|
||||
Reference< XToolkit> xToolkit( Toolkit::create( m_xContext ), UNO_QUERY_THROW );
|
||||
Reference< XToolkit> xToolkit(css::awt::Toolkit::create(m_xContext), UNO_QUERY_THROW);
|
||||
xDialogControl->createPeer( xToolkit, xPeer );
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <sal/log.hxx>
|
||||
#include <utility>
|
||||
#include <vcl/canvastools.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
#include <vcl/syschild.hxx>
|
||||
#include <vcl/sysdata.hxx>
|
||||
#include <vcl/window.hxx>
|
||||
@@ -459,9 +460,8 @@ namespace slideshow::internal
|
||||
if( mxPlayer.is() )
|
||||
{
|
||||
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::Gtk)
|
||||
if (Application::GetToolkit() != Toolkit::Gtk)
|
||||
nParentWindowHandle = mpMediaWindow->GetParentWindowHandle();
|
||||
|
||||
aAWTRect.X = aAWTRect.Y = 0;
|
||||
|
||||
@@ -369,7 +369,7 @@ IMPL_LINK(QuickFindPanel, SearchFindsListRender, weld::TreeView::render_args, aP
|
||||
}
|
||||
|
||||
// adjust for scrollbar when not using gtk
|
||||
if (m_pWrtShell->GetWin()->GetSystemData()->toolkit != SystemEnvData::Toolkit::Gtk)
|
||||
if (Application::GetToolkit() != Toolkit::Gtk)
|
||||
{
|
||||
tools::Long nScrollBarThickness
|
||||
= Application::GetSettings().GetStyleSettings().GetScrollBarSize();
|
||||
|
||||
@@ -205,6 +205,8 @@ public:
|
||||
virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget>
|
||||
ImplCreateDropTarget(const SystemEnvData& rSysEnv) override;
|
||||
|
||||
virtual Toolkit GetToolkit() const override;
|
||||
|
||||
// for qt font options
|
||||
virtual const cairo_font_options_t* GetCairoFontOptions() override;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <o3tl/sorted_vector.hxx>
|
||||
#include <rtl/ref.hxx>
|
||||
#include <vcl/ColorDialog.hxx>
|
||||
#include <vcl/Toolkit.hxx>
|
||||
#include <vcl/dllapi.h>
|
||||
#include <vcl/salgtype.hxx>
|
||||
#include <vcl/vclenum.hxx>
|
||||
@@ -221,6 +222,7 @@ public:
|
||||
|
||||
/// get information about underlying versions
|
||||
virtual OUString getOSVersion() { return u"-"_ustr; }
|
||||
virtual Toolkit GetToolkit() const { return Toolkit::Invalid; }
|
||||
const OUString& GetToolkitName() { return m_sToolkitName; };
|
||||
|
||||
virtual const cairo_font_options_t* GetCairoFontOptions() { return nullptr; }
|
||||
|
||||
@@ -285,6 +285,8 @@ public:
|
||||
CreateColorChooserDialog(weld::Window* pParent, vcl::ColorPickerMode eMode) override;
|
||||
virtual weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow) override;
|
||||
|
||||
virtual Toolkit GetToolkit() const override;
|
||||
|
||||
virtual const cairo_font_options_t* GetCairoFontOptions() override;
|
||||
const cairo_font_options_t* GetLastSeenCairoFontOptions() const;
|
||||
void ResetLastSeenCairoFontOptions(const cairo_font_options_t* pOptions);
|
||||
|
||||
@@ -89,6 +89,8 @@ public:
|
||||
ImplCreateDropTarget(const SystemEnvData& rSysEnv) override;
|
||||
virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override;
|
||||
|
||||
virtual Toolkit GetToolkit() const override;
|
||||
|
||||
/** Get the DisplayConnection. It allows to send display events to the application. */
|
||||
static rtl::Reference<X11DisplayConnectionDispatch> GetDisplayConnection();
|
||||
|
||||
|
||||
@@ -161,7 +161,6 @@ void QtFrame::screenChanged(QScreen*) { m_pQWidget->fakeResize(); }
|
||||
void QtFrame::FillSystemEnvData(SystemEnvData& rData, QWidget* pWidget, QtFrame* pFrame)
|
||||
{
|
||||
assert(rData.platform == SystemEnvData::Platform::Invalid);
|
||||
assert(rData.toolkit == SystemEnvData::Toolkit::Invalid);
|
||||
if (QGuiApplication::platformName() == "wayland")
|
||||
rData.platform = SystemEnvData::Platform::Wayland;
|
||||
else if (QGuiApplication::platformName() == "xcb")
|
||||
@@ -176,7 +175,6 @@ void QtFrame::FillSystemEnvData(SystemEnvData& rData, QWidget* pWidget, QtFrame*
|
||||
std::abort();
|
||||
}
|
||||
|
||||
rData.toolkit = SystemEnvData::Toolkit::Qt;
|
||||
rData.pSalFrame = pFrame;
|
||||
rData.pWidget = pWidget;
|
||||
}
|
||||
|
||||
@@ -693,6 +693,8 @@ QtInstance::ImplCreateDropTarget(const SystemEnvData& rSysEnv)
|
||||
return pDropTarget;
|
||||
}
|
||||
|
||||
Toolkit QtInstance::GetToolkit() const { return Toolkit::Qt; }
|
||||
|
||||
const cairo_font_options_t* QtInstance::GetCairoFontOptions()
|
||||
{
|
||||
static cairo_font_options_t* gOptions = cairo_font_options_create();
|
||||
|
||||
@@ -1420,6 +1420,8 @@ Help* Application::GetHelp()
|
||||
return ImplGetSVData()->maAppData.mpHelp;
|
||||
}
|
||||
|
||||
Toolkit Application::GetToolkit() { return GetSalInstance()->GetToolkit(); }
|
||||
|
||||
const OUString & Application::GetToolkitName()
|
||||
{
|
||||
return GetSalInstance()->GetToolkitName();
|
||||
|
||||
@@ -220,6 +220,8 @@ std::shared_ptr<SalBitmap> X11SalInstance::CreateSalBitmap()
|
||||
return std::make_shared<SvpSalBitmap>();
|
||||
}
|
||||
|
||||
Toolkit X11SalInstance::GetToolkit() const { return Toolkit::Gen; }
|
||||
|
||||
rtl::Reference<X11DisplayConnectionDispatch> X11SalInstance::GetDisplayConnection()
|
||||
{
|
||||
ImplSVData* pSVData = ImplGetSVData();
|
||||
|
||||
@@ -846,7 +846,6 @@ const SystemEnvData& X11SalFrame::GetSystemData() const
|
||||
pFrame->maSystemChildData.pWidget = nullptr;
|
||||
pFrame->maSystemChildData.pVisual = GetDisplay()->GetVisual( m_nXScreen ).GetVisual();
|
||||
pFrame->maSystemChildData.nScreen = m_nXScreen.getXScreen();
|
||||
pFrame->maSystemChildData.toolkit = SystemEnvData::Toolkit::Gen;
|
||||
pFrame->maSystemChildData.platform = SystemEnvData::Platform::Xcb;
|
||||
return maSystemChildData;
|
||||
}
|
||||
|
||||
@@ -229,7 +229,6 @@ X11SalObject::X11SalObject()
|
||||
maSystemChildData.pSalFrame = nullptr;
|
||||
maSystemChildData.pWidget = nullptr;
|
||||
maSystemChildData.pVisual = nullptr;
|
||||
maSystemChildData.toolkit = SystemEnvData::Toolkit::Gen;
|
||||
maSystemChildData.platform = SystemEnvData::Platform::Xcb;
|
||||
|
||||
std::list<SalObject*>& rObjects = vcl_sal::getSalDisplay()->getSalObjects();
|
||||
|
||||
@@ -1251,7 +1251,6 @@ void GtkSalFrame::InitCommon()
|
||||
m_aSystemData.pSalFrame = this;
|
||||
m_aSystemData.pWidget = m_pWindow;
|
||||
m_aSystemData.nScreen = m_nXScreen.getXScreen();
|
||||
m_aSystemData.toolkit = SystemEnvData::Toolkit::Gtk;
|
||||
|
||||
#if defined(GDK_WINDOWING_X11)
|
||||
GdkDisplay *pDisplay = getGdkDisplay();
|
||||
|
||||
@@ -545,6 +545,8 @@ std::unique_ptr<GenPspGraphics> GtkInstance::CreatePrintGraphics()
|
||||
return SvpSalInstance::CreatePrintGraphics();
|
||||
}
|
||||
|
||||
Toolkit GtkInstance::GetToolkit() const { return Toolkit::Gtk; }
|
||||
|
||||
const cairo_font_options_t* GtkInstance::GetCairoFontOptions()
|
||||
{
|
||||
#if !GTK_CHECK_VERSION(4, 0, 0)
|
||||
|
||||
@@ -63,7 +63,6 @@ void GtkSalObjectBase::Init()
|
||||
m_aSystemData.pSalFrame = nullptr;
|
||||
m_aSystemData.pWidget = m_pSocket;
|
||||
m_aSystemData.nScreen = m_pParent->getXScreenNumber().getXScreen();
|
||||
m_aSystemData.toolkit = SystemEnvData::Toolkit::Gtk;
|
||||
#if !GTK_CHECK_VERSION(4, 0, 0)
|
||||
GdkScreen* pScreen = gtk_widget_get_screen(m_pParent->getWindow());
|
||||
GdkVisual* pVisual = gdk_screen_get_system_visual(pScreen);
|
||||
|
||||
Reference in New Issue
Block a user