diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx index d63b8e809bf7..b78d478a9afa 100644 --- a/avmedia/source/gstreamer/gstplayer.cxx +++ b/avmedia/source/gstreamer/gstplayer.cxx @@ -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(pParentWindow->CreateGStreamerSink()); if (pVideosink) { - if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk) + if (Application::GetToolkit() == Toolkit::Gtk) mbUseGtkSink = true; } else diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx index cfb3807c78cc..cbade003166c 100644 --- a/avmedia/source/viewer/mediawindow_impl.cxx +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -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 aArgs{ uno::Any(nParentWindowHandle), diff --git a/include/vcl/Toolkit.hxx b/include/vcl/Toolkit.hxx new file mode 100644 index 000000000000..58e15167194b --- /dev/null +++ b/include/vcl/Toolkit.hxx @@ -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: */ diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index 8348bd3b8292..e7014161c6d3 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -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. diff --git a/include/vcl/sysdata.hxx b/include/vcl/sysdata.hxx index 2ec5bd65a8d8..7d89098143fb 100644 --- a/include/vcl/sysdata.hxx +++ b/include/vcl/sysdata.hxx @@ -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) diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 94100b7c6d94..6f436985efa0 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -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 xToolkit( Toolkit::create( m_xContext ), UNO_QUERY_THROW ); + Reference< XToolkit> xToolkit(css::awt::Toolkit::create(m_xContext), UNO_QUERY_THROW); xDialogControl->createPeer( xToolkit, xPeer ); } diff --git a/slideshow/source/engine/shapes/viewmediashape.cxx b/slideshow/source/engine/shapes/viewmediashape.cxx index f50350b53ed4..00bb635afce3 100644 --- a/slideshow/source/engine/shapes/viewmediashape.cxx +++ b/slideshow/source/engine/shapes/viewmediashape.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -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; diff --git a/sw/source/uibase/sidebar/QuickFindPanel.cxx b/sw/source/uibase/sidebar/QuickFindPanel.cxx index c22dde94b0ac..16ae8b891ab4 100644 --- a/sw/source/uibase/sidebar/QuickFindPanel.cxx +++ b/sw/source/uibase/sidebar/QuickFindPanel.cxx @@ -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(); diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx index fd4f34379a7b..448399944987 100644 --- a/vcl/inc/qt5/QtInstance.hxx +++ b/vcl/inc/qt5/QtInstance.hxx @@ -205,6 +205,8 @@ public: virtual css::uno::Reference ImplCreateDropTarget(const SystemEnvData& rSysEnv) override; + virtual Toolkit GetToolkit() const override; + // for qt font options virtual const cairo_font_options_t* GetCairoFontOptions() override; diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx index 729a5d008591..5187ecdd4dcd 100644 --- a/vcl/inc/salinst.hxx +++ b/vcl/inc/salinst.hxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -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; } diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index 48b8e6846d1b..92e374903b85 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -285,6 +285,8 @@ public: CreateColorChooserDialog(weld::Window* pParent, vcl::ColorPickerMode eMode) override; virtual weld::Window* GetFrameWeld(const css::uno::Reference& 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); diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h index ba550ef2c647..c7161cefa206 100644 --- a/vcl/inc/unx/salinst.h +++ b/vcl/inc/unx/salinst.h @@ -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 GetDisplayConnection(); diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index 5ab4c1e20319..3afb7785a4ae 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -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; } diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx index ef9ae0225a03..8a08bef03b08 100644 --- a/vcl/qt5/QtInstance.cxx +++ b/vcl/qt5/QtInstance.cxx @@ -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(); diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index eed49952d45e..1ed02ccd4fd7 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -1420,6 +1420,8 @@ Help* Application::GetHelp() return ImplGetSVData()->maAppData.mpHelp; } +Toolkit Application::GetToolkit() { return GetSalInstance()->GetToolkit(); } + const OUString & Application::GetToolkitName() { return GetSalInstance()->GetToolkitName(); diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx index 372d470c624f..deed1041c859 100644 --- a/vcl/unx/generic/app/salinst.cxx +++ b/vcl/unx/generic/app/salinst.cxx @@ -220,6 +220,8 @@ std::shared_ptr X11SalInstance::CreateSalBitmap() return std::make_shared(); } +Toolkit X11SalInstance::GetToolkit() const { return Toolkit::Gen; } + rtl::Reference X11SalInstance::GetDisplayConnection() { ImplSVData* pSVData = ImplGetSVData(); diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index 91dde4cebea3..5b5fb1af242e 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -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; } diff --git a/vcl/unx/generic/window/salobj.cxx b/vcl/unx/generic/window/salobj.cxx index dc03316e8524..c3f42f711e5e 100644 --- a/vcl/unx/generic/window/salobj.cxx +++ b/vcl/unx/generic/window/salobj.cxx @@ -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& rObjects = vcl_sal::getSalDisplay()->getSalObjects(); diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx index 177ee38a5dcc..0e3b2f0cf7b1 100644 --- a/vcl/unx/gtk3/gtkframe.cxx +++ b/vcl/unx/gtk3/gtkframe.cxx @@ -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(); diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 4a06f74e36f3..d98e306e9a13 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -545,6 +545,8 @@ std::unique_ptr 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) diff --git a/vcl/unx/gtk3/gtkobject.cxx b/vcl/unx/gtk3/gtkobject.cxx index dfc0355b6635..c16e85b65c92 100644 --- a/vcl/unx/gtk3/gtkobject.cxx +++ b/vcl/unx/gtk3/gtkobject.cxx @@ -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);