summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2022-04-20 12:27:53 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2022-04-27 09:53:36 +0200
commitefe333f2b10a738c2f60f3f12c4de7642f504360 (patch)
tree9c5e6e8ad9131cf702c5edd70575c42f023eb3b1
parent1c1427e81c2463fbc40855adfafa360c13108abb (diff)
SalGeometryProvider base for scaling
-rw-r--r--include/vcl/GeometryProvider.hxx69
-rw-r--r--include/vcl/outdev.hxx45
-rw-r--r--include/vcl/virdev.hxx5
-rw-r--r--include/vcl/windowstate.hxx12
-rw-r--r--svtools/source/control/ctrlbox.cxx2
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/android/androidinst.cxx4
-rw-r--r--vcl/headless/CairoCommon.cxx38
-rw-r--r--vcl/headless/SvpGraphicsBackend.cxx3
-rw-r--r--vcl/headless/svpframe.cxx36
-rw-r--r--vcl/headless/svpgdi.cxx25
-rw-r--r--vcl/headless/svpinst.cxx10
-rw-r--r--vcl/headless/svpvd.cxx96
-rw-r--r--vcl/inc/android/androidinst.hxx4
-rw-r--r--vcl/inc/headless/CairoCommon.hxx3
-rw-r--r--vcl/inc/headless/svpframe.hxx9
-rw-r--r--vcl/inc/headless/svpgdi.hxx4
-rw-r--r--vcl/inc/headless/svpinst.hxx6
-rw-r--r--vcl/inc/headless/svpvd.hxx12
-rw-r--r--vcl/inc/image.h31
-rw-r--r--vcl/inc/ios/iosinst.hxx4
-rw-r--r--vcl/inc/osx/salinst.h4
-rw-r--r--vcl/inc/qt5/QtFrame.hxx9
-rw-r--r--vcl/inc/qt5/QtGraphics.hxx8
-rw-r--r--vcl/inc/qt5/QtGraphicsBase.hxx17
-rw-r--r--vcl/inc/qt5/QtGraphics_Controls.hxx6
-rw-r--r--vcl/inc/qt5/QtInstance.hxx6
-rw-r--r--vcl/inc/qt5/QtPainter.hxx6
-rw-r--r--vcl/inc/qt5/QtSvpGraphics.hxx7
-rw-r--r--vcl/inc/qt5/QtTools.hxx3
-rw-r--r--vcl/inc/qt5/QtVirtualDevice.hxx13
-rw-r--r--vcl/inc/qt5/QtWidget.hxx1
-rw-r--r--vcl/inc/salframe.hxx15
-rw-r--r--vcl/inc/salgdi.hxx15
-rw-r--r--vcl/inc/salgeom.hxx27
-rw-r--r--vcl/inc/salinst.hxx7
-rw-r--r--vcl/inc/salprn.hxx2
-rw-r--r--vcl/inc/salvd.hxx37
-rw-r--r--vcl/inc/salvtables.hxx3
-rw-r--r--vcl/inc/salwtype.hxx1
-rw-r--r--vcl/inc/skia/gdiimpl.hxx8
-rw-r--r--vcl/inc/skia/x11/salvd.hxx9
-rw-r--r--vcl/inc/unx/genprn.h2
-rw-r--r--vcl/inc/unx/genpspgraphics.h3
-rw-r--r--vcl/inc/unx/gtk/gtkframe.hxx9
-rw-r--r--vcl/inc/unx/gtk/gtkgdi.hxx3
-rw-r--r--vcl/inc/unx/gtk/gtkinst.hxx6
-rw-r--r--vcl/inc/unx/salframe.h8
-rw-r--r--vcl/inc/unx/salgdi.h4
-rw-r--r--vcl/inc/unx/salinst.h8
-rw-r--r--vcl/inc/unx/salvd.h9
-rw-r--r--vcl/inc/win/salinst.h4
-rw-r--r--vcl/inc/win/salprn.h2
-rw-r--r--vcl/inc/window.h9
-rw-r--r--vcl/inc/windowdev.hxx2
-rw-r--r--vcl/ios/iosinst.cxx4
-rw-r--r--vcl/qt5/QtData.cxx4
-rw-r--r--vcl/qt5/QtFrame.cxx69
-rw-r--r--vcl/qt5/QtGraphics.cxx15
-rw-r--r--vcl/qt5/QtGraphics_Controls.cxx14
-rw-r--r--vcl/qt5/QtGraphics_GDI.cxx26
-rw-r--r--vcl/qt5/QtInstance.cxx13
-rw-r--r--vcl/qt5/QtSvpGraphics.cxx35
-rw-r--r--vcl/qt5/QtTools.cxx17
-rw-r--r--vcl/qt5/QtVirtualDevice.cxx44
-rw-r--r--vcl/qt5/QtWidget.cxx7
-rw-r--r--vcl/skia/gdiimpl.cxx2
-rw-r--r--vcl/skia/x11/salvd.cxx32
-rw-r--r--vcl/source/app/salvtables.cxx11
-rw-r--r--vcl/source/gdi/print.cxx5
-rw-r--r--vcl/source/gdi/virdev.cxx29
-rw-r--r--vcl/source/helper/geometryprovider.cxx32
-rw-r--r--vcl/source/image/Image.cxx8
-rw-r--r--vcl/source/image/ImplImage.cxx71
-rw-r--r--vcl/source/image/ImplImageTree.cxx11
-rw-r--r--vcl/source/outdev/bitmap.cxx10
-rw-r--r--vcl/source/outdev/outdev.cxx23
-rw-r--r--vcl/source/outdev/text.cxx8
-rw-r--r--vcl/source/outdev/wallpaper.cxx2
-rw-r--r--vcl/source/window/mouse.cxx4
-rw-r--r--vcl/source/window/paint.cxx14
-rw-r--r--vcl/source/window/window.cxx109
-rw-r--r--vcl/source/window/winproc.cxx9
-rw-r--r--vcl/unx/generic/app/salinst.cxx8
-rw-r--r--vcl/unx/generic/gdi/salgdi.cxx53
-rw-r--r--vcl/unx/generic/gdi/salvd.cxx32
-rw-r--r--vcl/unx/generic/print/genprnpsp.cxx2
-rw-r--r--vcl/unx/generic/print/genpspgraphics.cxx14
-rw-r--r--vcl/unx/generic/window/salframe.cxx105
-rw-r--r--vcl/unx/gtk3/gtkframe.cxx56
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx10
-rw-r--r--vcl/unx/gtk3/salnativewidgets-gtk.cxx38
-rw-r--r--vcl/unx/kf5/KF5SalFrame.cxx4
-rw-r--r--vcl/unx/kf5/KF5SalFrame.hxx2
-rw-r--r--vcl/unx/kf5/KF5SalInstance.cxx8
-rw-r--r--vcl/unx/kf5/KF5SalInstance.hxx4
96 files changed, 978 insertions, 678 deletions
diff --git a/include/vcl/GeometryProvider.hxx b/include/vcl/GeometryProvider.hxx
new file mode 100644
index 000000000000..bbd7d37e2c3d
--- /dev/null
+++ b/include/vcl/GeometryProvider.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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
+
+#include <vcl/dllapi.h>
+#include <tools/gen.hxx>
+
+namespace vcl
+{
+enum class SGPmetric
+{
+ Width = 1,
+ Height,
+ DPIX,
+ DPIY,
+ ScalePercentage,
+ OffScreen,
+ BitCount,
+};
+
+class VCL_DLLPUBLIC SalGeometryProvider
+{
+public:
+ virtual ~SalGeometryProvider();
+
+ sal_Int32 GetWidth() const { return GetSgpMetric(SGPmetric::Width); }
+ sal_Int32 GetHeight() const { return GetSgpMetric(SGPmetric::Height); }
+ sal_Int32 GetDPIX() const { return GetSgpMetric(SGPmetric::DPIX); }
+ sal_Int32 GetDPIY() const { return GetSgpMetric(SGPmetric::DPIY); }
+ sal_Int32 GetDPIScalePercentage() const { return GetSgpMetric(SGPmetric::ScalePercentage); }
+ float GetDPIScaleFactor() const { return GetSgpMetric(SGPmetric::ScalePercentage) / 100.0f; }
+ bool IsOffScreen() const { return !!GetSgpMetric(SGPmetric::OffScreen); }
+ sal_Int32 GetBitCount() const { return GetSgpMetric(SGPmetric::BitCount); }
+ Size GetSizePixel() const
+ {
+ return Size(GetSgpMetric(SGPmetric::Width), GetSgpMetric(SGPmetric::Height));
+ }
+
+ virtual sal_Int32 GetSgpMetric(SGPmetric eMetric) const = 0;
+};
+
+struct VCL_DLLPUBLIC SalSgpMetrics
+{
+ sal_Int32 m_nWidth = 1;
+ sal_Int32 m_nHeight = 1;
+ sal_Int32 mnDPIX = 96;
+ sal_Int32 mnDPIY = 96;
+ sal_Int32 mnDPIScalePercentage = 100;
+ bool m_bOffScreen = false;
+ sal_Int32 mnBitCount = 32;
+};
+
+class VCL_DLLPUBLIC SalGeometryProviderImpl : public SalGeometryProvider, protected SalSgpMetrics
+{
+public:
+ SalGeometryProviderImpl() = default;
+
+ virtual sal_Int32 GetSgpMetric(SGPmetric eMetric) const override;
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 7dacb68d55ad..4c2277c1830c 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -32,6 +32,7 @@
#include <vcl/devicecoordinate.hxx>
#include <vcl/dllapi.h>
#include <vcl/font.hxx>
+#include <vcl/GeometryProvider.hxx>
#include <vcl/region.hxx>
#include <vcl/rendercontext/AddFontSubstituteFlags.hxx>
#include <vcl/rendercontext/AntialiasingFlags.hxx>
@@ -172,14 +173,16 @@ typedef struct _cairo_surface cairo_surface_t;
* so we need to use virtual inheritance to keep the referencing counting
* OK.
*/
-class SAL_WARN_UNUSED VCL_DLLPUBLIC OutputDevice : public virtual VclReferenceBase
+class SAL_WARN_UNUSED VCL_DLLPUBLIC OutputDevice
+ : public virtual VclReferenceBase
+ , public vcl::SalGeometryProviderImpl
{
friend class Printer;
friend class VirtualDevice;
friend class vcl::Window;
friend class vcl::WindowOutputDevice;
friend class WorkWindow;
- friend void ImplHandleResize( vcl::Window* pWindow, tools::Long nNewWidth, tools::Long nNewHeight );
+ friend void ImplHandleResize(vcl::Window*, sal_Int32 nNewWidth, sal_Int32 nNewHeight);
private:
OutputDevice(const OutputDevice&) = delete;
@@ -213,11 +216,6 @@ private:
tools::Long mnOutOffX;
/// Output offset for device output in pixel (pseudo window offset within window system's frames)
tools::Long mnOutOffY;
- tools::Long mnOutWidth;
- tools::Long mnOutHeight;
- sal_Int32 mnDPIX;
- sal_Int32 mnDPIY;
- sal_Int32 mnDPIScalePercentage; ///< For HiDPI displays, we want to draw elements for a percentage larger
/// font specific text alignment offsets in pixel units
mutable tools::Long mnTextOffX;
mutable tools::Long mnTextOffY;
@@ -316,12 +314,10 @@ public:
virtual bool IsScreenComp() const { return true; }
- virtual sal_uInt16 GetBitCount() const;
-
- Size GetOutputSizePixel() const
- { return Size( mnOutWidth, mnOutHeight ); }
- tools::Long GetOutputWidthPixel() const { return mnOutWidth; }
- tools::Long GetOutputHeightPixel() const { return mnOutHeight; }
+ void SetGeometrySize(sal_Int32, sal_Int32);
+ Size GetOutputSizePixel() const { return GetSizePixel(); }
+ tools::Long GetOutputWidthPixel() const { return m_nWidth; }
+ tools::Long GetOutputHeightPixel() const { return m_nHeight; }
tools::Long GetOutOffXPixel() const { return mnOutOffX; }
tools::Long GetOutOffYPixel() const { return mnOutOffY; }
void SetOutOffXPixel(tools::Long nOutOffX);
@@ -384,32 +380,9 @@ protected:
///@{
public:
-
- /** Get the output device's DPI x-axis value.
-
- @returns x-axis DPI value
- */
- SAL_DLLPRIVATE sal_Int32 GetDPIX() const { return mnDPIX; }
-
- /** Get the output device's DPI y-axis value.
-
- @returns y-axis DPI value
- */
- SAL_DLLPRIVATE sal_Int32 GetDPIY() const { return mnDPIY; }
-
SAL_DLLPRIVATE void SetDPIX( sal_Int32 nDPIX ) { mnDPIX = nDPIX; }
SAL_DLLPRIVATE void SetDPIY( sal_Int32 nDPIY ) { mnDPIY = nDPIY; }
- float GetDPIScaleFactor() const
- {
- return mnDPIScalePercentage / 100.0f;
- }
-
- sal_Int32 GetDPIScalePercentage() const
- {
- return mnDPIScalePercentage;
- }
-
OutDevType GetOutDevType() const { return meOutDevType; }
virtual bool IsVirtual() const;
diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index 459660eb71cd..966afadfe831 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -48,14 +48,13 @@ private:
std::unique_ptr<SalVirtualDevice> mpVirDev;
VclPtr<VirtualDevice> mpPrev;
VclPtr<VirtualDevice> mpNext;
- sal_uInt16 mnBitCount;
bool mbScreenComp;
const DeviceFormat meFormat;
const DeviceFormat meAlphaFormat;
RefDevMode meRefDevMode;
bool mbForceZeroExtleadBug;
- SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, tools::Long nDX, tools::Long nDY, const SystemGraphicsData *pData = nullptr );
+ SAL_DLLPRIVATE void ImplInitVirDev(const OutputDevice* pOutDev, sal_Int32 nDX, sal_Int32 nDY, const SystemGraphicsData *pData = nullptr );
SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
sal_uInt8* pBuffer );
SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
@@ -168,8 +167,6 @@ public:
void SetReferenceDevice( sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
- virtual sal_uInt16 GetBitCount() const override;
-
bool IsVirtual() const override;
bool IsScreenComp() const override { return mbScreenComp; }
diff --git a/include/vcl/windowstate.hxx b/include/vcl/windowstate.hxx
index dcf0f4e9a394..6a9de43d18c9 100644
--- a/include/vcl/windowstate.hxx
+++ b/include/vcl/windowstate.hxx
@@ -30,8 +30,8 @@ private:
WindowStateMask mnValidMask;
int mnX;
int mnY;
- unsigned int mnWidth;
- unsigned int mnHeight;
+ sal_Int32 mnWidth;
+ sal_Int32 mnHeight;
int mnMaximizedX;
int mnMaximizedY;
unsigned int mnMaximizedWidth;
@@ -60,10 +60,10 @@ public:
int GetX() const { return mnX; }
void SetY(int nY) { mnY = nY; }
int GetY() const { return mnY; }
- void SetWidth(unsigned int nWidth) { mnWidth = nWidth; }
- unsigned int GetWidth() const { return mnWidth; }
- void SetHeight(unsigned int nHeight) { mnHeight = nHeight; }
- unsigned int GetHeight() const { return mnHeight; }
+ void SetWidth(sal_Int32 nWidth) { mnWidth = nWidth; }
+ sal_Int32 GetWidth() const { return mnWidth; }
+ void SetHeight(sal_Int32 nHeight) { mnHeight = nHeight; }
+ sal_Int32 GetHeight() const { return mnHeight; }
void SetState(WindowStateState nState) { mnState = nState; }
WindowStateState GetState() const { return mnState; }
void SetMaximizedX(int nRX) { mnMaximizedX = nRX; }
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 411a2dd4961d..ecce7fa8af21 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -355,6 +355,8 @@ IMPL_LINK(FontNameBox, SettingsChangedHdl, VclSimpleEvent&, rEvent, void)
DataChangedEvent* pData = static_cast<DataChangedEvent*>(static_cast<VclWindowEvent&>(rEvent).GetData());
if (pData->GetType() == DataChangedEventType::SETTINGS)
{
+ for (auto &rDev : gFontPreviewVirDevs)
+ rDev.disposeAndClear();
gFontPreviewVirDevs.clear();
gRenderedFontNames.clear();
calcCustomItemSize(*m_xComboBox);
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index a141e22348dd..21a5a8fe672a 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -379,6 +379,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/helper/canvasbitmap \
vcl/source/helper/canvastools \
vcl/source/helper/commandinfoprovider \
+ vcl/source/helper/geometryprovider \
vcl/source/helper/displayconnectiondispatch \
vcl/source/helper/driverblocklist \
vcl/source/helper/errcode \
diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index ca130fb1b19f..5d50531bbd76 100644
--- a/vcl/android/androidinst.cxx
+++ b/vcl/android/androidinst.cxx
@@ -143,12 +143,12 @@ public:
}
};
-SalFrame *AndroidSalInstance::CreateChildFrame( SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle )
+SalFrame *AndroidSalInstance::CreateChildFrame( SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle, vcl::Window& rWin )
{
return new AndroidSalFrame( this, NULL, nStyle );
}
-SalFrame *AndroidSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
+SalFrame *AndroidSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& )
{
return new AndroidSalFrame( this, pParent, nStyle );
}
diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx
index 02c281fea3cb..107f6a0b1948 100644
--- a/vcl/headless/CairoCommon.cxx
+++ b/vcl/headless/CairoCommon.cxx
@@ -431,8 +431,8 @@ void CairoCommon::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed,
basegfx::B2IRange aIntExtents(basegfx::unotools::b2ISurroundingRangeFromB2DRange(rExtents));
sal_Int32 nExtentsLeft(aIntExtents.getMinX()), nExtentsTop(aIntExtents.getMinY());
sal_Int32 nExtentsRight(aIntExtents.getMaxX()), nExtentsBottom(aIntExtents.getMaxY());
- sal_Int32 nWidth = m_aFrameSize.getX();
- sal_Int32 nHeight = m_aFrameSize.getY();
+ sal_Int32 nWidth = cairo_image_surface_get_width(m_pSurface);
+ sal_Int32 nHeight = cairo_image_surface_get_height(m_pSurface);
nExtentsLeft = std::max<sal_Int32>(nExtentsLeft, 0);
nExtentsTop = std::max<sal_Int32>(nExtentsTop, 0);
nExtentsRight = std::min<sal_Int32>(nExtentsRight, nWidth);
@@ -467,11 +467,13 @@ void CairoCommon::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed,
cairo_format_t nFormat = cairo_image_surface_get_format(target_surface);
assert(nFormat == CAIRO_FORMAT_ARGB32
&& "need to implement CAIRO_FORMAT_A1 after all here");
- sal_Int32 nStride = cairo_format_stride_for_width(nFormat, nWidth * m_fScale);
- sal_Int32 nUnscaledExtentsLeft = nExtentsLeft * m_fScale;
- sal_Int32 nUnscaledExtentsRight = nExtentsRight * m_fScale;
- sal_Int32 nUnscaledExtentsTop = nExtentsTop * m_fScale;
- sal_Int32 nUnscaledExtentsBottom = nExtentsBottom * m_fScale;
+ double fScale = 1.0;
+ dl_cairo_surface_get_device_scale(m_pSurface, &fScale, nullptr);
+ sal_Int32 nStride = cairo_format_stride_for_width(nFormat, nWidth * fScale);
+ sal_Int32 nUnscaledExtentsLeft = nExtentsLeft * fScale;
+ sal_Int32 nUnscaledExtentsRight = nExtentsRight * fScale;
+ sal_Int32 nUnscaledExtentsTop = nExtentsTop * fScale;
+ sal_Int32 nUnscaledExtentsBottom = nExtentsBottom * fScale;
// Handle headless size forced to (1,1) by SvpSalFrame::GetSurfaceFrameSize().
int target_surface_width = cairo_image_surface_get_width(target_surface);
@@ -557,15 +559,19 @@ void CairoCommon::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed,
cairo_t* CairoCommon::createTmpCompatibleCairoContext() const
{
+ double fScale = 1.0;
+ dl_cairo_surface_get_device_scale(m_pSurface, &fScale, nullptr);
+ sal_Int32 nWidth = cairo_image_surface_get_width(m_pSurface);
+ sal_Int32 nHeight = cairo_image_surface_get_height(m_pSurface);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
cairo_surface_t* target = cairo_surface_create_similar_image(
m_pSurface,
#else
cairo_surface_t* target = cairo_image_surface_create(
#endif
- CAIRO_FORMAT_ARGB32, m_aFrameSize.getX() * m_fScale, m_aFrameSize.getY() * m_fScale);
+ CAIRO_FORMAT_ARGB32, nWidth * fScale, nHeight * fScale);
- dl_cairo_surface_set_device_scale(target, m_fScale, m_fScale);
+ dl_cairo_surface_set_device_scale(target, fScale, fScale);
return cairo_create(target);
}
@@ -920,10 +926,12 @@ void CairoCommon::copyBitsCairo(const SalTwoRect& rTR, cairo_surface_t* pSourceS
if (pSourceSurface == getSurface())
{
//self copy is a problem, so dup source in that case
+ double fScale = 1.0;
+ dl_cairo_surface_get_device_scale(m_pSurface, &fScale, nullptr);
pCopy
= cairo_surface_create_similar(pSourceSurface, cairo_surface_get_content(getSurface()),
- aTR.mnSrcWidth * m_fScale, aTR.mnSrcHeight * m_fScale);
- dl_cairo_surface_set_device_scale(pCopy, m_fScale, m_fScale);
+ aTR.mnSrcWidth * fScale, aTR.mnSrcHeight * fScale);
+ dl_cairo_surface_set_device_scale(pCopy, fScale, fScale);
cairo_t* cr = cairo_create(pCopy);
cairo_set_source_surface(cr, pSourceSurface, -aTR.mnSrcX, -aTR.mnSrcY);
cairo_rectangle(cr, 0, 0, aTR.mnSrcWidth, aTR.mnSrcHeight);
@@ -1014,12 +1022,14 @@ void CairoCommon::invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, boo
if (nFlags & SalInvert::N50)
{
+ double fScale = 1.0;
+ dl_cairo_surface_get_device_scale(m_pSurface, &fScale, nullptr);
cairo_pattern_t* pattern = create_stipple();
cairo_surface_t* surface = cairo_surface_create_similar(
- m_pSurface, cairo_surface_get_content(m_pSurface), extents.getWidth() * m_fScale,
- extents.getHeight() * m_fScale);
+ m_pSurface, cairo_surface_get_content(m_pSurface), extents.getWidth() * fScale,
+ extents.getHeight() * fScale);
- dl_cairo_surface_set_device_scale(surface, m_fScale, m_fScale);
+ dl_cairo_surface_set_device_scale(surface, fScale, fScale);
cairo_t* stipple_cr = cairo_create(surface);
cairo_set_source_rgb(stipple_cr, 1.0, 1.0, 1.0);
cairo_mask(stipple_cr, pattern);
diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx
index 223b333e9bef..37ffc7b981a6 100644
--- a/vcl/headless/SvpGraphicsBackend.cxx
+++ b/vcl/headless/SvpGraphicsBackend.cxx
@@ -51,7 +51,8 @@ sal_uInt16 SvpGraphicsBackend::GetBitCount() const
tools::Long SvpGraphicsBackend::GetGraphicsWidth() const
{
- return m_rCairoCommon.m_pSurface ? m_rCairoCommon.m_aFrameSize.getX() : 0;
+ assert(m_rCairoCommon.m_pSurface);
+ return cairo_image_surface_get_width(m_rCairoCommon.m_pSurface);
}
void SvpGraphicsBackend::SetLineColor() { m_rCairoCommon.m_aLineColor = SALCOLOR_NONE; }
diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx
index c6c8a08e29c0..01729a876080 100644
--- a/vcl/headless/svpframe.cxx
+++ b/vcl/headless/svpframe.cxx
@@ -21,6 +21,7 @@
#include <o3tl/safeint.hxx>
#include <vcl/syswin.hxx>
#include <sal/log.hxx>
+#include <window.h>
#include <headless/svpframe.hxx>
#include <headless/svpinst.hxx>
@@ -42,7 +43,8 @@ SvpSalFrame* SvpSalFrame::s_pFocusFrame = nullptr;
SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance,
SalFrame* pParent,
- SalFrameStyleFlags nSalFrameStyle ) :
+ SalFrameStyleFlags nSalFrameStyle, vcl::Window& rWin)
+ : SalFrame(rWin),
m_pInstance( pInstance ),
m_pParent( static_cast<SvpSalFrame*>(pParent) ),
m_nStyle( nSalFrameStyle ),
@@ -158,7 +160,7 @@ SalGraphics* SvpSalFrame::AcquireGraphics()
{
SvpSalGraphics* pGraphics = new SvpSalGraphics();
#ifndef IOS
- pGraphics->setSurface(m_pSurface, GetSurfaceFrameSize());
+ pGraphics->setSurface(m_pSurface);
#endif
m_aGraphics.push_back( pGraphics );
return pGraphics;
@@ -254,17 +256,17 @@ void SvpSalFrame::SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth
if( (nFlags & SAL_FRAME_POSSIZE_WIDTH) != 0 )
{
maGeometry.nWidth = nWidth;
- if( m_nMaxWidth > 0 && maGeometry.nWidth > o3tl::make_unsigned(m_nMaxWidth) )
+ if (m_nMaxWidth > 0 && maGeometry.nWidth > m_nMaxWidth)
maGeometry.nWidth = m_nMaxWidth;
- if( m_nMinWidth > 0 && maGeometry.nWidth < o3tl::make_unsigned(m_nMinWidth) )
+ if (m_nMinWidth > 0 && maGeometry.nWidth < m_nMinWidth)
maGeometry.nWidth = m_nMinWidth;
}
if( (nFlags & SAL_FRAME_POSSIZE_HEIGHT) != 0 )
{
maGeometry.nHeight = nHeight;
- if( m_nMaxHeight > 0 && maGeometry.nHeight > o3tl::make_unsigned(m_nMaxHeight) )
+ if (m_nMaxHeight > 0 && maGeometry.nHeight > m_nMaxHeight)
maGeometry.nHeight = m_nMaxHeight;
- if( m_nMinHeight > 0 && maGeometry.nHeight < o3tl::make_unsigned(m_nMinHeight) )
+ if (m_nMinHeight > 0 && maGeometry.nHeight < m_nMinHeight)
maGeometry.nHeight = m_nMinHeight;
}
#ifndef IOS
@@ -281,16 +283,25 @@ void SvpSalFrame::SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth
// update device in existing graphics
for (auto const& graphic : m_aGraphics)
- {
- graphic->setSurface(m_pSurface, aFrameSize);
- }
+ graphic->setSurface(m_pSurface);
}
if( m_bVisible )
m_pInstance->PostEvent( this, nullptr, SalEvent::Resize );
#endif
}
-void SvpSalFrame::GetClientSize( tools::Long& rWidth, tools::Long& rHeight )
+sal_Int32 SvpSalFrame::GetSgpMetric(vcl::SGPmetric eMetric) const
+{
+ switch (eMetric)
+ {
+ case vcl::SGPmetric::Width: return maGeometry.nWidth;
+ case vcl::SGPmetric::Height: return maGeometry.nHeight;
+ default:
+ return GetWindow()->GetOutDev()->GetSgpMetric(eMetric);
+ }
+}
+
+void SvpSalFrame::GetClientSize(sal_Int32& rWidth, sal_Int32& rHeight)
{
rWidth = maGeometry.nWidth;
rHeight = maGeometry.nHeight;
@@ -510,4 +521,9 @@ void SvpSalFrame::EndSetClipRegion()
{
}
+void SvpSalFrame::GetDPI(sal_Int32& rDPIX, sal_Int32& rDPIY)
+{
+ rDPIX = rDPIY = 96;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index c97048dada12..b0185888e77e 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -38,17 +38,32 @@ SvpSalGraphics::~SvpSalGraphics()
ReleaseFonts();
}
-void SvpSalGraphics::setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize)
+void SvpSalGraphics::setSurface(cairo_surface_t* pSurface)
{
m_aCairoCommon.m_pSurface = pSurface;
- m_aCairoCommon.m_aFrameSize = rSize;
- dl_cairo_surface_get_device_scale(pSurface, &m_aCairoCommon.m_fScale, nullptr);
GetImpl()->ResetClipRegion();
}
-void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY )
+sal_Int32 SvpSalGraphics::GetSgpMetric(vcl::SGPmetric eMetric) const
{
- rDPIX = rDPIY = 96;
+ switch (eMetric)
+ {
+ case vcl::SGPmetric::Width: return cairo_image_surface_get_width(m_aCairoCommon.m_pSurface);
+ case vcl::SGPmetric::Height: return cairo_image_surface_get_height(m_aCairoCommon.m_pSurface);
+ case vcl::SGPmetric::DPIX:
+ case vcl::SGPmetric::DPIY:
+ return 96 * GetDPIScaleFactor();
+ case vcl::SGPmetric::ScalePercentage:
+ {
+ double fScale;
+ dl_cairo_surface_get_device_scale(m_aCairoCommon.m_pSurface, &fScale, nullptr);
+ return round(fScale * 100);
+ }
+ case vcl::SGPmetric::OffScreen: return true;
+ case vcl::SGPmetric::BitCount: return 32;
+ default:
+ return -1;
+ }
}
#if ENABLE_CAIRO_CANVAS
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index bf53dc24faf3..aa4ae1214d77 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -216,14 +216,14 @@ bool SvpSalInstance::CheckTimeout( bool bExecuteTimers )
return bRet;
}
-SalFrame* SvpSalInstance::CreateChildFrame( SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle )
+SalFrame* SvpSalInstance::CreateChildFrame(SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle, vcl::Window& rWin)
{
- return new SvpSalFrame( this, nullptr, nStyle );
+ return new SvpSalFrame(this, nullptr, nStyle, rWin);
}
-SalFrame* SvpSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
+SalFrame* SvpSalInstance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin)
{
- return new SvpSalFrame( this, pParent, nStyle );
+ return new SvpSalFrame(this, pParent, nStyle, rWin);
}
void SvpSalInstance::DestroyFrame( SalFrame* pFrame )
@@ -244,7 +244,7 @@ void SvpSalInstance::DestroyObject( SalObject* pObject )
#ifndef IOS
std::unique_ptr<SalVirtualDevice> SvpSalInstance::CreateVirtualDevice(SalGraphics& rGraphics,
- tools::Long &nDX, tools::Long &nDY,
+ sal_Int32 &nDX, sal_Int32 &nDY,
DeviceFormat /*eFormat*/,
const SystemGraphicsData* pGd)
{
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index 76cb53fc1745..2cb14e9d7ee2 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -48,7 +48,7 @@ SvpSalVirtualDevice::~SvpSalVirtualDevice()
SvpSalGraphics* SvpSalVirtualDevice::AddGraphics(SvpSalGraphics* pGraphics)
{
- pGraphics->setSurface(m_pSurface, m_aFrameSize);
+ pGraphics->setSurface(m_pSurface);
m_aGraphics.push_back(pGraphics);
return pGraphics;
}
@@ -64,29 +64,45 @@ void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
delete pGraphics;
}
-bool SvpSalVirtualDevice::SetSize( tools::Long nNewDX, tools::Long nNewDY )
+void SvpSalVirtualDevice::SetScalePercentage(sal_Int32 nScale)
{
- return SetSizeUsingBuffer(nNewDX, nNewDY, nullptr);
+ CreateSurface(0, 0, nullptr, nScale);
}
-void SvpSalVirtualDevice::CreateSurface(tools::Long nNewDX, tools::Long nNewDY, sal_uInt8 *const pBuffer)
+void SvpSalVirtualDevice::CreateSurface(sal_Int32 nNewDX, sal_Int32 nNewDY, sal_uInt8 *const pBuffer, sal_Int32 nScalePercentage)
{
- if (m_pSurface)
- {
- cairo_surface_destroy(m_pSurface);
- }
-
double fXScale, fYScale;
- if (comphelper::LibreOfficeKit::isActive())
- {
- // Force scaling of the painting
- fXScale = fYScale = comphelper::LibreOfficeKit::getDPIScale();
- }
+ if (nScalePercentage > 0)
+ fXScale = fYScale = nScalePercentage / 100.0;
else
+ fXScale = fYScale = GetDPIScaleFactor();
+
+ if (nNewDX <= 0 || nNewDY <= 0)
{
- dl_cairo_surface_get_device_scale(m_pRefSurface, &fXScale, &fYScale);
+ if (nScalePercentage > 0 && m_pSurface)
+ {
+ dl_cairo_surface_set_device_scale(m_pSurface, fXScale, fYScale);
+ return;
+ }
+
+ if (pBuffer && !m_pSurface)
+ {
+ SAL_WARN("vcl", "Trying to set buffer without sizes or surface!");
+ return;
+ }
+
+ if (m_pSurface)
+ {
+ nNewDX = cairo_image_surface_get_width(m_pSurface);
+ nNewDY = cairo_image_surface_get_height(m_pSurface);
+ }
+ else
+ nNewDX = nNewDY = 1;
}
+ if (m_pSurface)
+ cairo_surface_destroy(m_pSurface);
+
if (pBuffer)
{
nNewDX *= fXScale;
@@ -117,39 +133,49 @@ void SvpSalVirtualDevice::CreateSurface(tools::Long nNewDX, tools::Long nNewDY,
SAL_WARN_IF(cairo_surface_status(m_pSurface) != CAIRO_STATUS_SUCCESS, "vcl", "surface of size " << nNewDX << " by " << nNewDY << " creation failed with status of: " << cairo_status_to_string(cairo_surface_status(m_pSurface)));
}
-bool SvpSalVirtualDevice::SetSizeUsingBuffer( tools::Long nNewDX, tools::Long nNewDY,
- sal_uInt8 *const pBuffer)
+bool SvpSalVirtualDevice::SetSizeUsingBuffer(sal_Int32 nNewDX, sal_Int32 nNewDY, sal_uInt8 *const pBuffer, sal_Int32 nScale)
{
- if (nNewDX == 0)
- nNewDX = 1;
- if (nNewDY == 0)
- nNewDY = 1;
-
- if (!m_pSurface || m_aFrameSize.getX() != nNewDX ||
- m_aFrameSize.getY() != nNewDY)
+ FixSetSizeParams(nNewDX, nNewDY, nScale);
+ if (!m_pSurface || cairo_image_surface_get_width(m_pSurface) != nNewDX ||
+ cairo_image_surface_get_height(m_pSurface) != nNewDY)
{
- m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY);
-
if (m_bOwnsSurface)
- CreateSurface(nNewDX, nNewDY, pBuffer);
+ CreateSurface(nNewDX, nNewDY, pBuffer, nScale);
assert(m_pSurface);
// update device in existing graphics
for (auto const& graphic : m_aGraphics)
- graphic->setSurface(m_pSurface, m_aFrameSize);
+ graphic->setSurface(m_pSurface);
}
return true;
}
-tools::Long SvpSalVirtualDevice::GetWidth() const
+sal_Int32 SvpSalVirtualDevice::GetSgpMetric(vcl::SGPmetric eMetric) const
{
- return m_pSurface ? m_aFrameSize.getX() : 0;
-}
-
-tools::Long SvpSalVirtualDevice::GetHeight() const
-{
- return m_pSurface ? m_aFrameSize.getY() : 0;
+ switch (eMetric)
+ {
+ case vcl::SGPmetric::Width: return m_pSurface ? cairo_image_surface_get_width(m_pSurface) : 1;
+ case vcl::SGPmetric::Height: return m_pSurface ? cairo_image_surface_get_height(m_pSurface) : 1;
+ case vcl::SGPmetric::DPIX:
+ case vcl::SGPmetric::DPIY:
+ return 96 * GetSgpMetric(vcl::SGPmetric::ScalePercentage);
+ case vcl::SGPmetric::ScalePercentage:
+ {
+ double fXScale, fYScale;
+ if (m_pSurface)
+ dl_cairo_surface_get_device_scale(m_pSurface, &fXScale, &fYScale);
+ else if (comphelper::LibreOfficeKit::isActive())
+ fXScale = comphelper::LibreOfficeKit::getDPIScale();
+ else
+ fXScale = 1.0;
+ return round(fXScale * 100);
+ }
+ case vcl::SGPmetric::OffScreen: return true;
+ case vcl::SGPmetric::BitCount: return 32;
+ default:
+ return -1;
+ }
}
#endif
diff --git a/vcl/inc/android/androidinst.hxx b/vcl/inc/android/androidinst.hxx
index 771eb4b1ed81..889a49264dca 100644
--- a/vcl/inc/android/androidinst.hxx
+++ b/vcl/inc/android/androidinst.hxx
@@ -37,8 +37,8 @@ public:
// frame management
void GetWorkArea(tools::Rectangle& rRect);
- SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle);
- SalFrame* CreateChildFrame(SystemParentData* pParent, SalFrameStyleFlags nStyle);
+ SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window&);
+ SalFrame* CreateChildFrame(SystemParentData* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin);
// mainloop pieces
virtual bool AnyInput(VclInputFlags nType);
diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx
index e8b1a4927e21..56271a450224 100644
--- a/vcl/inc/headless/CairoCommon.hxx
+++ b/vcl/inc/headless/CairoCommon.hxx
@@ -147,19 +147,16 @@ struct VCL_DLLPUBLIC DamageHandler
struct VCL_DLLPUBLIC CairoCommon
{
cairo_surface_t* m_pSurface;
- basegfx::B2IVector m_aFrameSize;
vcl::Region m_aClipRegion;
Color m_aLineColor;
Color m_aFillColor;
PaintMode m_ePaintMode;
- double m_fScale;
CairoCommon()
: m_pSurface(nullptr)
, m_aLineColor(Color(0x00, 0x00, 0x00))
, m_aFillColor(Color(0xFF, 0xFF, 0XFF))
, m_ePaintMode(PaintMode::Over)
- , m_fScale(1.0)
{
}
diff --git a/vcl/inc/headless/svpframe.hxx b/vcl/inc/headless/svpframe.hxx
index 84dca0c84cdc..a6125543f6f2 100644
--- a/vcl/inc/headless/svpframe.hxx
+++ b/vcl/inc/headless/svpframe.hxx
@@ -57,9 +57,7 @@ class SvpSalFrame : public SalFrame
OUString m_sTitle;
public:
- SvpSalFrame( SvpSalInstance* pInstance,
- SalFrame* pParent,
- SalFrameStyleFlags nSalFrameStyle );
+ SvpSalFrame(SvpSalInstance*, SalFrame* pParent, SalFrameStyleFlags, vcl::Window&);
virtual ~SvpSalFrame() override;
void GetFocus();
@@ -87,7 +85,8 @@ public:
virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight ) override;
virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight ) override;
virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) override;
- virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) override;
+ virtual void GetDPI(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
+ virtual void GetClientSize(sal_Int32& rWidth, sal_Int32& rHeight) override;
virtual void GetWorkArea( tools::Rectangle& rRect ) override;
virtual SalFrame* GetParent() const override;
virtual void SetWindowState( const SalFrameState* pState ) override;
@@ -123,6 +122,8 @@ public:
virtual void SetScreenNumber( unsigned int ) override {}
virtual void SetApplicationID(const OUString &) override {}
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
+
private:
basegfx::B2IVector GetSurfaceFrameSize() const;
};
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index a63e7f289abf..fbfc452eb862 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -47,7 +47,7 @@ class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphicsAutoDelegateToImpl
CairoCommon m_aCairoCommon;
public:
- void setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize);
+ void setSurface(cairo_surface_t* pSurface);
cairo_surface_t* getSurface() const { return m_aCairoCommon.m_pSurface; }
static cairo_user_data_key_t* getDamageKey()
{
@@ -67,7 +67,7 @@ public:
virtual SalGraphicsImpl* GetImpl() const override { return m_pBackend.get(); }
std::unique_ptr<SvpGraphicsBackend> const& getSvpBackend() { return m_pBackend; }
- virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override;
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
virtual void SetTextColor( Color nColor ) override;
virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx
index 874ce672d97a..073dab1017da 100644
--- a/vcl/inc/headless/svpinst.hxx
+++ b/vcl/inc/headless/svpinst.hxx
@@ -120,8 +120,8 @@ public:
bool CheckTimeout( bool bExecuteTimers = true );
// Frame
- virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
- virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
+ virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin ) override;
+ virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& ) override;
virtual void DestroyFrame( SalFrame* pFrame ) override;
// Object (System Child Window)
@@ -134,7 +134,7 @@ public:
// pData allows for using a system dependent graphics or device context
virtual std::unique_ptr<SalVirtualDevice>
CreateVirtualDevice( SalGraphics& rGraphics,
- tools::Long &nDX, tools::Long &nDY,
+ sal_Int32 &nDX, sal_Int32 &nDY,
DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) override;
// Printer
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
index ca9e38cee31a..c4b9e47b814c 100644
--- a/vcl/inc/headless/svpvd.hxx
+++ b/vcl/inc/headless/svpvd.hxx
@@ -37,7 +37,7 @@ class VCL_DLLPUBLIC SvpSalVirtualDevice : public SalVirtualDevice
basegfx::B2IVector m_aFrameSize;
std::vector< SvpSalGraphics* > m_aGraphics;
- void CreateSurface(tools::Long nNewDX, tools::Long nNewDY, sal_uInt8 *const pBuffer);
+ void CreateSurface(sal_Int32 nNewDX, sal_Int32 nNewDY, sal_uInt8 *const pBuffer, sal_Int32 nScale);
protected:
SvpSalGraphics* AddGraphics(SvpSalGraphics* aGraphics);
@@ -50,16 +50,14 @@ public:
virtual SalGraphics* AcquireGraphics() override;
virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
- virtual bool SetSize( tools::Long nNewDX, tools::Long nNewDY ) override;
- virtual bool SetSizeUsingBuffer( tools::Long nNewDX, tools::Long nNewDY,
- sal_uInt8 * pBuffer
+ virtual bool SetSizeUsingBuffer( sal_Int32 nNewDX, sal_Int32 nNewDY,
+ sal_uInt8 * pBuffer, sal_Int32 nScale = 100
) override;
+ virtual void SetScalePercentage(sal_Int32) override;
cairo_surface_t* GetSurface() const { return m_pSurface; }
- // SalGeometryProvider
- virtual tools::Long GetWidth() const override;
- virtual tools::Long GetHeight() const override;
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const;
};
#endif // INCLUDED_VCL_INC_HEADLESS_SVPVD_HXX
diff --git a/vcl/inc/image.h b/vcl/inc/image.h
index 633c38c4a34e..373bb656ce89 100644
--- a/vcl/inc/image.h
+++ b/vcl/inc/image.h
@@ -17,26 +17,25 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_VCL_INC_IMAGE_H
-#define INCLUDED_VCL_INC_IMAGE_H
+#pragma once
#include <vcl/bitmapex.hxx>
+#include <vcl/GeometryProvider.hxx>
-class ImplImage
+class ImplImage final : public vcl::SalGeometryProvider
{
private:
BitmapChecksum maBitmapChecksum;
- /// if non-empty: cached original size of maStockName else Size of maBitmap
- Size maSizePixel;
/// If set - defines the bitmap via images.zip*
- OUString maStockName;
-
+ const OUString maStockName;
+ sal_Int32 m_nScalePercentage;
/// Original bitmap - or cache of a potentially scaled bitmap
- BitmapEx maBitmapEx;
- BitmapEx maDisabledBitmapEx;
+ mutable BitmapEx maBitmapEx;
+ mutable BitmapEx maDisabledBitmapEx;
- bool loadStockAtScale(double fScale, BitmapEx &rBitmapEx);
+ bool loadStockAtScale(BitmapEx* pBitmapEx) const;
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
public:
ImplImage(const BitmapEx& rBitmapEx);
@@ -52,20 +51,12 @@ public:
return maStockName;
}
+ void setScalePercentage(sal_Int32);
+
/// get size in co-ordinates not scaled for HiDPI
- Size getSizePixel();
- /// Legacy - the original bitmap
BitmapEx const & getBitmapEx(bool bDisabled = false);
- /// Taking account of HiDPI scaling
- BitmapEx const & getBitmapExForHiDPI(bool bDisabled = false);
bool isEqual(const ImplImage &ref) const;
- bool isSizeEmpty() const
- {
- return maSizePixel == Size();
- }
};
-#endif // INCLUDED_VCL_INC_IMAGE_H
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/ios/iosinst.hxx b/vcl/inc/ios/iosinst.hxx
index f1269cabe75e..b341dd596e59 100644
--- a/vcl/inc/ios/iosinst.hxx
+++ b/vcl/inc/ios/iosinst.hxx
@@ -43,8 +43,8 @@ public:
CreateClipboard(const css::uno::Sequence<css::uno::Any>& i_rArguments) override;
void GetWorkArea(tools::Rectangle& rRect);
- SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override;
- SalFrame* CreateChildFrame(SystemParentData* pParent, SalFrameStyleFlags nStyle) override;
+ SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window&) override;
+ SalFrame* CreateChildFrame(SystemParentData* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin) override;
};
#endif // INCLUDED_VCL_INC_IOS_IOSINST_HXX
diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h
index 6d707807d38e..007545875369 100644
--- a/vcl/inc/osx/salinst.h
+++ b/vcl/inc/osx/salinst.h
@@ -93,8 +93,8 @@ public:
virtual void AfterAppInit() override;
virtual bool SVMainHook(int *) override;
- virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
- virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
+ virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin ) override;
+ virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& ) override;
virtual void DestroyFrame( SalFrame* pFrame ) override;
virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData,
bool bShow ) override;
diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index 2d7c5718d6cf..c0a145ab89d1 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -129,7 +129,6 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public SalFrame
bool isWindow() const;
QWindow* windowHandle() const;
- QScreen* screen() const;
bool isMinimized() const;
bool isMaximized() const;
void SetWindowStateImpl(Qt::WindowStates eState);
@@ -141,17 +140,20 @@ private Q_SLOTS:
void screenChanged(QScreen*);
public:
- QtFrame(QtFrame* pParent, SalFrameStyleFlags nSalFrameStyle, bool bUseCairo);
+ QtFrame(QtFrame* pParent, SalFrameStyleFlags nSalFrameStyle, vcl::Window&, bool bUseCairo);
virtual ~QtFrame() override;
QWidget* GetQWidget() const { return m_pQWidget; }
QtMainWindow* GetTopLevelWindow() const { return m_pTopLevel; }
QWidget* asChild() const;
qreal devicePixelRatioF() const;
+ QScreen* screen() const;
void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 nExtentsWidth,
sal_Int32 nExtentsHeight) const;
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
+
virtual SalGraphics* AcquireGraphics() override;
virtual void ReleaseGraphics(SalGraphics* pGraphics) override;
@@ -177,7 +179,8 @@ public:
virtual void SetMaxClientSize(tools::Long nWidth, tools::Long nHeight) override;
virtual void SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight,
sal_uInt16 nFlags) override;
- virtual void GetClientSize(tools::Long& rWidth, tools::Long& rHeight) override;
+ virtual void GetDPI(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
+ virtual void GetClientSize(sal_Int32& rWidth, sal_Int32& rHeight) override;
virtual void GetWorkArea(tools::Rectangle& rRect) override;
virtual SalFrame* GetParent() const override;
virtual void SetModal(bool bModal) override;
diff --git a/vcl/inc/qt5/QtGraphics.hxx b/vcl/inc/qt5/QtGraphics.hxx
index fed7c2cb88f0..8f85002ee6e4 100644
--- a/vcl/inc/qt5/QtGraphics.hxx
+++ b/vcl/inc/qt5/QtGraphics.hxx
@@ -29,8 +29,6 @@
#include <QtGui/QPainterPath>
#include <QtGui/QRegion>
-#include "QtGraphicsBase.hxx"
-
namespace vcl::font
{
class PhysicalFontCollection;
@@ -42,7 +40,7 @@ class QtFontFace;
class QtFrame;
class QtPainter;
-class QtGraphicsBackend final : public SalGraphicsImpl, public QtGraphicsBase
+class QtGraphicsBackend final : public SalGraphicsImpl
{
friend class QtPainter;
@@ -164,7 +162,7 @@ private:
void drawScaledImage(const SalTwoRect& rPosAry, const QImage& rImage);
};
-class QtGraphics final : public SalGraphicsAutoDelegateToImpl, public QtGraphicsBase
+class QtGraphics final : public SalGraphicsAutoDelegateToImpl
{
friend class QtBitmap;
@@ -218,7 +216,7 @@ public:
// GDI
- virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
// Text rendering + font support
diff --git a/vcl/inc/qt5/QtGraphicsBase.hxx b/vcl/inc/qt5/QtGraphicsBase.hxx
index 73c39fb5ba80..0c0a0f93b0fa 100644
--- a/vcl/inc/qt5/QtGraphicsBase.hxx
+++ b/vcl/inc/qt5/QtGraphicsBase.hxx
@@ -9,21 +9,10 @@
#pragma once
-#include <QtWidgets/QApplication>
+#include <vcl/GenometryProvider.hxx>
-class QtGraphicsBase
-{
- qreal m_fDPR;
+class QImage;
-public:
- QtGraphicsBase()
- : m_fDPR(qApp ? qApp->devicePixelRatio() : 1.0)
- {
- }
-
- void setDevicePixelRatioF(qreal fDPR) { m_fDPR = fDPR; }
-
- qreal devicePixelRatioF() const { return m_fDPR; }
-};
+static sal_Int32 GetSgpMetric(QImage &rImage, vcl::SGPmetric eMetric) const;
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt5/QtGraphics_Controls.hxx b/vcl/inc/qt5/QtGraphics_Controls.hxx
index 17039f9d6038..dd89713f3334 100644
--- a/vcl/inc/qt5/QtGraphics_Controls.hxx
+++ b/vcl/inc/qt5/QtGraphics_Controls.hxx
@@ -31,16 +31,16 @@
#include <QtWidgets/QStyle>
#include <QtWidgets/QStyleOption>
-class QtGraphicsBase;
+class SalGraphics;
class QtGraphics_Controls final : public vcl::WidgetDrawInterface
{
std::unique_ptr<QImage> m_image;
QRect m_lastPopupRect;
- QtGraphicsBase const& m_rGraphics;
+ SalGraphics const& m_rGraphics;
public:
- QtGraphics_Controls(const QtGraphicsBase& rGraphics);
+ QtGraphics_Controls(const SalGraphics& rGraphics);
QImage* getImage() { return m_image.get(); }
diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx
index df6c4ec5af86..6ac1588597fb 100644
--- a/vcl/inc/qt5/QtInstance.hxx
+++ b/vcl/inc/qt5/QtInstance.hxx
@@ -112,9 +112,9 @@ public:
void RunInMainThread(std::function<void()> func);
- virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override;
+ virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window&) override;
virtual SalFrame* CreateChildFrame(SystemParentData* pParent,
- SalFrameStyleFlags nStyle) override;
+ SalFrameStyleFlags nStyle, vcl::Window&) override;
virtual void DestroyFrame(SalFrame* pFrame) override;
virtual SalObject* CreateObject(SalFrame* pParent, SystemWindowData* pWindowData,
@@ -122,7 +122,7 @@ public:
virtual void DestroyObject(SalObject* pObject) override;
virtual std::unique_ptr<SalVirtualDevice>
- CreateVirtualDevice(SalGraphics& rGraphics, tools::Long& nDX, tools::Long& nDY,
+ CreateVirtualDevice(SalGraphics& rGraphics, sal_Int32& nDX, sal_Int32& nDY,
DeviceFormat eFormat, const SystemGraphicsData* pData = nullptr) override;
virtual SalInfoPrinter* CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
diff --git a/vcl/inc/qt5/QtPainter.hxx b/vcl/inc/qt5/QtPainter.hxx
index 9702a19bdbe4..6d012e996402 100644
--- a/vcl/inc/qt5/QtPainter.hxx
+++ b/vcl/inc/qt5/QtPainter.hxx
@@ -43,19 +43,19 @@ public:
void update(int nx, int ny, int nw, int nh)
{
if (m_rGraphics.m_pFrame)
- m_aRegion += scaledQRect({ nx, ny, nw, nh }, 1 / m_rGraphics.devicePixelRatioF());
+ m_aRegion += scaledQRect({ nx, ny, nw, nh }, 1 / m_rGraphics.m_pFrame->devicePixelRatioF());
}
void update(const QRect& rRect)
{
if (m_rGraphics.m_pFrame)
- m_aRegion += scaledQRect(rRect, 1 / m_rGraphics.devicePixelRatioF());
+ m_aRegion += scaledQRect(rRect, 1 / m_rGraphics.m_pFrame->devicePixelRatioF());
}
void update(const QRectF& rRectF)
{
if (m_rGraphics.m_pFrame)
- update(scaledQRect(rRectF.toAlignedRect(), 1 / m_rGraphics.devicePixelRatioF()));
+ update(scaledQRect(rRectF.toAlignedRect(), 1 / m_rGraphics.m_pFrame->devicePixelRatioF()));
}
void update()
diff --git a/vcl/inc/qt5/QtSvpGraphics.hxx b/vcl/inc/qt5/QtSvpGraphics.hxx
index da3786eee165..35150cd43903 100644
--- a/vcl/inc/qt5/QtSvpGraphics.hxx
+++ b/vcl/inc/qt5/QtSvpGraphics.hxx
@@ -22,13 +22,12 @@
#include <vclpluginapi.h>
#include <headless/svpgdi.hxx>
-#include "QtGraphicsBase.hxx"
-
class QtFrame;
-class VCLPLUG_QT_PUBLIC QtSvpGraphics final : public SvpSalGraphics, public QtGraphicsBase
+class VCLPLUG_QT_PUBLIC QtSvpGraphics final : public SvpSalGraphics
{
QtFrame* const m_pFrame;
+ sal_Int32 m_nScalePercentage;
void handleDamage(const tools::Rectangle&) override;
@@ -46,7 +45,7 @@ public:
int height) const override;
#endif // ENABLE_CAIRO_CANVAS
- virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
virtual OUString getRenderBackendName() const override { return "qt5svp"; }
};
diff --git a/vcl/inc/qt5/QtTools.hxx b/vcl/inc/qt5/QtTools.hxx
index ecaa7075a426..1260d3c193d4 100644
--- a/vcl/inc/qt5/QtTools.hxx
+++ b/vcl/inc/qt5/QtTools.hxx
@@ -30,6 +30,7 @@
#include <tools/color.hxx>
#include <tools/gen.hxx>
#include <vcl/bitmap/BitmapTypes.hxx>
+#include <vcl/GeometryProvider.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
@@ -151,6 +152,8 @@ sal_uInt16 GetMouseModCode(Qt::MouseButtons eButtons);
QImage toQImage(const Image& rImage);
+sal_Int32 GetSgpMetricFromQImage(vcl::SGPmetric eMetric, QImage& rImage);
+
template <typename charT, typename traits>
inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream,
const QString& rString)
diff --git a/vcl/inc/qt5/QtVirtualDevice.hxx b/vcl/inc/qt5/QtVirtualDevice.hxx
index 2481f63d0657..dc5846a57307 100644
--- a/vcl/inc/qt5/QtVirtualDevice.hxx
+++ b/vcl/inc/qt5/QtVirtualDevice.hxx
@@ -34,23 +34,20 @@ class QtVirtualDevice final : public SalVirtualDevice
{
std::vector<QtGraphics*> m_aGraphics;
std::unique_ptr<QImage> m_pImage;
- QSize m_aFrameSize;
- double m_fScale;
public:
- QtVirtualDevice(double fScale);
+ QtVirtualDevice(sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nScale);
// SalVirtualDevice
virtual SalGraphics* AcquireGraphics() override;
virtual void ReleaseGraphics(SalGraphics* pGraphics) override;
- virtual bool SetSize(tools::Long nNewDX, tools::Long nNewDY) override;
- virtual bool SetSizeUsingBuffer(tools::Long nNewDX, tools::Long nNewDY,
- sal_uInt8* pBuffer) override;
+ virtual bool SetSizeUsingBuffer(sal_Int32 nNewDX, sal_Int32 nNewDY,
+ sal_uInt8* pBuffer, sal_Int32 nScale = 100) override;
// SalGeometryProvider
- virtual tools::Long GetWidth() const override;
- virtual tools::Long GetHeight() const override;
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
+ virtual void SetScalePercentage(sal_Int32) override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx
index 8f7f6cc319e1..0207da7c7432 100644
--- a/vcl/inc/qt5/QtWidget.hxx
+++ b/vcl/inc/qt5/QtWidget.hxx
@@ -87,6 +87,7 @@ class QtWidget : public QWidget
void inputMethodEvent(QInputMethodEvent*) override;
QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
static void closePopup();
+ void handleScaleOrResize(QResizeEvent* pEvent, bool bScaleChanged);
public:
QtWidget(QtFrame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx
index ac8840b437c7..f6b2a69c57d1 100644
--- a/vcl/inc/salframe.hxx
+++ b/vcl/inc/salframe.hxx
@@ -113,7 +113,7 @@ struct ImplSVEvent;
/// A SalFrame is a system window (e.g. an X11 window).
class VCL_PLUGIN_PUBLIC SalFrame
: public vcl::DeletionNotifier
- , public SalGeometryProvider
+ , public vcl::SalGeometryProvider
{
private:
// the VCL window corresponding to this frame
@@ -123,15 +123,13 @@ private:
protected:
mutable std::unique_ptr<weld::Window> m_xFrameWeld;
public:
- SalFrame();
+ SalFrame(vcl::Window&);
virtual ~SalFrame() override;
SalFrameGeometry maGeometry = {}; ///< absolute, unmirrored values
- // SalGeometryProvider
- virtual tools::Long GetWidth() const override { return maGeometry.nWidth; }
- virtual tools::Long GetHeight() const override { return maGeometry.nHeight; }
- virtual bool IsOffScreen() const override { return false; }
+ void SetGeometrySize(sal_Int32, sal_Int32);
+ void SetGeometrySize(const Size& rSize) { SetGeometrySize(rSize.getWidth(), rSize.getHeight()); }
// SalGraphics or NULL, but two Graphics for all SalFrames
// must be returned
@@ -159,7 +157,8 @@ public:
virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight ) = 0;
virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight ) = 0;
virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) = 0;
- virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) = 0;
+ virtual void GetDPI(sal_Int32& rDPIX, sal_Int32& rDPIY) = 0;
+ virtual void GetClientSize(sal_Int32& rWidth, sal_Int32& rHeight) = 0;
virtual void GetWorkArea( tools::Rectangle& rRect ) = 0;
virtual SalFrame* GetParent() const = 0;
// Note: x will be mirrored at parent if UI mirroring is active
@@ -293,7 +292,7 @@ public:
// Callbacks (independent part in vcl/source/window/winproc.cxx)
// for default message handling return 0
- void SetCallback( vcl::Window* pWindow, SALFRAMEPROC pProc );
+ void SetCallback(SALFRAMEPROC pProc );
// returns the instance set
vcl::Window* GetWindow() const { return m_pWindow; }
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index eed8ab7160ac..1d532c917977 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -74,7 +74,9 @@ typedef std::map< sal_Ucs, sal_uInt32 > Ucs2UIntMap;
// note: all positions are in pixel and relative to
// the top/left-position of the virtual output area
-class VCL_PLUGIN_PUBLIC SalGraphics : protected vcl::WidgetDrawInterface
+class VCL_PLUGIN_PUBLIC SalGraphics
+ : protected vcl::WidgetDrawInterface
+ , public vcl::SalGeometryProvider
{
public:
SalGraphics();
@@ -108,12 +110,6 @@ public:
// public SalGraphics methods, the interface to the independent vcl part
- // get device resolution
- virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) = 0;
-
- // get the depth of the device
- virtual sal_uInt16 GetBitCount() const = 0;
-
// get the width of the device
virtual tools::Long GetGraphicsWidth() const = 0;
@@ -700,11 +696,6 @@ void SalGraphics::handleDamage(const tools::Rectangle&) {}
class VCL_DLLPUBLIC SalGraphicsAutoDelegateToImpl : public SalGraphics
{
public:
- sal_uInt16 GetBitCount() const override
- {
- return GetImpl()->GetBitCount();
- }
-
tools::Long GetGraphicsWidth() const override
{
return GetImpl()->GetGraphicsWidth();
diff --git a/vcl/inc/salgeom.hxx b/vcl/inc/salgeom.hxx
index 0bc7335c2977..09dad8cc0480 100644
--- a/vcl/inc/salgeom.hxx
+++ b/vcl/inc/salgeom.hxx
@@ -17,19 +17,20 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_VCL_INC_SALGEOM_HXX
-#define INCLUDED_VCL_INC_SALGEOM_HXX
+#pragma once
#include <iostream>
#include <vcl/dllapi.h>
+#include <tools/gen.hxx>
#include <tools/long.hxx>
-struct SalFrameGeometry {
+struct SalFrameGeometry
+{
// screen position of upper left corner of drawable area in pixel
- tools::Long nX, nY;
+ sal_Int32 nX, nY;
// dimensions of the drawable area in pixel
- tools::ULong nWidth, nHeight;
+ sal_Int32 nWidth, nHeight;
// thickness of the decoration in pixel
tools::ULong nLeftDecoration,
nTopDecoration,
@@ -48,26 +49,18 @@ struct SalFrameGeometry {
nBottomDecoration( 0 ),
nDisplayScreenNumber( 0 )
{}
+
+ Size GetSize() const { return Size(nWidth, nHeight); }
+ Point GetPos() const { return Point(nX, nY); }
};
inline std::ostream &operator <<(std::ostream& s, const SalFrameGeometry& rGeom)
{
+ s << rGeom.nDisplayScreenNumber << " ";
s << rGeom.nWidth << "x" << rGeom.nHeight << "@(" << rGeom.nX << "," << rGeom.nY << "):{"
<< rGeom.nLeftDecoration << "," << rGeom.nTopDecoration << "," << rGeom.nRightDecoration << "," << rGeom.nBottomDecoration << "}";
return s;
}
-/// Interface used to share logic on sizing between
-/// SalVirtualDevices and SalFrames
-class VCL_PLUGIN_PUBLIC SalGeometryProvider {
-public:
- virtual ~SalGeometryProvider() {}
- virtual tools::Long GetWidth() const = 0;
- virtual tools::Long GetHeight() const = 0;
- virtual bool IsOffScreen() const = 0;
-};
-
-#endif // INCLUDED_VCL_INC_SALGEOM_HXX
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index 98e962d8c637..ac90a323ca1b 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -95,9 +95,8 @@ public:
virtual bool SVMainHook(int*) { return false; }
// Frame
- // DisplayName for Unix ???
- virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) = 0;
- virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) = 0;
+ virtual SalFrame* CreateChildFrame(SystemParentData* pParent, SalFrameStyleFlags, vcl::Window&) = 0;
+ virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags, vcl::Window&) = 0;
virtual void DestroyFrame( SalFrame* pFrame ) = 0;
// Object (System Child Window)
@@ -112,7 +111,7 @@ public:
// its size; otherwise these remain unchanged.
virtual std::unique_ptr<SalVirtualDevice>
CreateVirtualDevice( SalGraphics& rGraphics,
- tools::Long &rDX, tools::Long &rDY,
+ sal_Int32 &rDX, sal_Int32 &rDY,
DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) = 0;
// Printer
diff --git a/vcl/inc/salprn.hxx b/vcl/inc/salprn.hxx
index d72853b597bf..509e21e6fe5a 100644
--- a/vcl/inc/salprn.hxx
+++ b/vcl/inc/salprn.hxx
@@ -73,7 +73,7 @@ public:
virtual bool SetData( JobSetFlags nFlags, ImplJobSetup* pSetupData ) = 0;
virtual void GetPageInfo( const ImplJobSetup* pSetupData,
- tools::Long& rOutWidth, tools::Long& rOutHeight,
+ sal_Int32& rOutWidth, sal_Int32& rOutHeight,
Point& rPageOffset,
Size& rPaperSize ) = 0;
virtual sal_uInt32 GetCapabilities( const ImplJobSetup* pSetupData, PrinterCapType nType ) = 0;
diff --git a/vcl/inc/salvd.hxx b/vcl/inc/salvd.hxx
index d1035feaebdd..213cc81c3673 100644
--- a/vcl/inc/salvd.hxx
+++ b/vcl/inc/salvd.hxx
@@ -17,42 +17,47 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_VCL_INC_SALVD_HXX
-#define INCLUDED_VCL_INC_SALVD_HXX
+#pragma once
-#include "salgeom.hxx"
+#include <vcl/GeometryProvider.hxx>
+#include <sal/log.hxx>
class SalGraphics;
/// A non-visible drawable/buffer (e.g. an X11 Pixmap).
class VCL_PLUGIN_PUBLIC SalVirtualDevice
- : public SalGeometryProvider
+ : public vcl::SalGeometryProvider
{
public:
SalVirtualDevice() {}
virtual ~SalVirtualDevice() override;
- // SalGeometryProvider
- virtual bool IsOffScreen() const override { return true; }
-
// SalGraphics or NULL, but two Graphics for all SalVirtualDevices
// must be returned
virtual SalGraphics* AcquireGraphics() = 0;
virtual void ReleaseGraphics( SalGraphics* pGraphics ) = 0;
// Set new size, without saving the old contents
- virtual bool SetSize( tools::Long nNewDX, tools::Long nNewDY ) = 0;
+ bool SetSize(sal_Int32 nNewDX, sal_Int32 nNewDY, sal_Int32 nScale = 100)
+ { return SetSizeUsingBuffer(nNewDX, nNewDY, nullptr, nScale); }
+ static inline void FixSetSizeParams(sal_Int32& nDX, sal_Int32& nDY, sal_Int32& nScale);
// Set new size using a buffer at the given address
- virtual bool SetSizeUsingBuffer( tools::Long nNewDX, tools::Long nNewDY,
- sal_uInt8 * /* pBuffer */)
- {
- // Only the headless virtual device has an implementation that uses
- // pBuffer (and bTopDown).
- return SetSize( nNewDX, nNewDY );
- }
+ virtual bool SetSizeUsingBuffer(sal_Int32 nNewDX, sal_Int32 nNewDY, sal_uInt8*, sal_Int32 nScale = 100) = 0;
+
+ virtual void SetScalePercentage(sal_Int32 nScale) = 0;
};
-#endif // INCLUDED_VCL_INC_SALVD_HXX
+void SalVirtualDevice::FixSetSizeParams(sal_Int32& nDX, sal_Int32& nDY, sal_Int32& nScale)
+{
+ SAL_WARN_IF(!(nDX > 0 && nDY > 0 && nScale > 0), "vcl",
+ "Invalid virtual device request (" << nDX << " " << nDY << " " << nScale << ")!");
+ if (nDX == 0)
+ nDX = 1;
+ if (nDY == 0)
+ nDY = 1;
+ if (nScale <= 0)
+ nScale = 100;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 3f574237444b..fd15088c98e9 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -853,8 +853,7 @@ public:
int get_menu_button_width() const override
{
- OutputDevice* pDefault = Application::GetDefaultDevice();
- return 20 * (pDefault ? pDefault->GetDPIScaleFactor() : 1.0);
+ return 20 * m_xComboBox->GetDPIScaleFactor();
}
void CallHandleEventListener(VclWindowEvent& rEvent)
diff --git a/vcl/inc/salwtype.hxx b/vcl/inc/salwtype.hxx
index c9f50cd63982..42a0ede1516a 100644
--- a/vcl/inc/salwtype.hxx
+++ b/vcl/inc/salwtype.hxx
@@ -88,6 +88,7 @@ enum class SalEvent {
LongPress,
ExternalGesture,
Gesture,
+ ScaleChanged,
};
struct SalAbstractMouseEvent
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index b2814b2a6463..32e8223436e0 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -23,7 +23,7 @@
#include <vcl/dllapi.h>
#include <salgdiimpl.hxx>
-#include <salgeom.hxx>
+#include <vcl/GeometryProvider.hxx>
#include <skia/utils.hxx>
@@ -37,7 +37,7 @@ class SkiaSalBitmap;
class VCL_DLLPUBLIC SkiaSalGraphicsImpl : public SalGraphicsImpl
{
public:
- SkiaSalGraphicsImpl(SalGraphics& pParent, SalGeometryProvider* pProvider);
+ SkiaSalGraphicsImpl(SalGraphics& pParent, vcl::SalGeometryProvider* pProvider);
virtual ~SkiaSalGraphicsImpl() override;
virtual void Init() override;
@@ -242,7 +242,7 @@ protected:
tools::Long nHeight, double nTransparency, bool blockAA = false);
void privateCopyBits(const SalTwoRect& rPosAry, SkiaSalGraphicsImpl* src);
- void setProvider(SalGeometryProvider* provider) { mProvider = provider; }
+ void setProvider(vcl::SalGeometryProvider* provider) { mProvider = provider; }
bool isOffscreen() const;
bool isGPU() const { return mIsGPU; }
@@ -341,7 +341,7 @@ protected:
SalGraphics& mParent;
/// Pointer to the SalFrame or SalVirtualDevice
- SalGeometryProvider* mProvider;
+ vcl::SalGeometryProvider* mProvider;
// The Skia surface that is target of all the rendering.
sk_sp<SkSurface> mSurface;
// Note that mSurface may be a proxy surface and not the one from the window context.
diff --git a/vcl/inc/skia/x11/salvd.hxx b/vcl/inc/skia/x11/salvd.hxx
index fec4b8080cc1..b2ce698de77b 100644
--- a/vcl/inc/skia/x11/salvd.hxx
+++ b/vcl/inc/skia/x11/salvd.hxx
@@ -22,14 +22,13 @@ class X11SkiaSalVirtualDevice final : public SalVirtualDevice
int mnHeight;
public:
- X11SkiaSalVirtualDevice(const SalGraphics& rGraphics, tools::Long nDX, tools::Long nDY,
+ X11SkiaSalVirtualDevice(const SalGraphics& rGraphics, sal_Int32 nDX, sal_Int32 nDY,
const SystemGraphicsData* pData,
std::unique_ptr<X11SalGraphics> pNewGraphics);
virtual ~X11SkiaSalVirtualDevice() override;
// SalGeometryProvider
- virtual tools::Long GetWidth() const override { return mnWidth; }
- virtual tools::Long GetHeight() const override { return mnHeight; }
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
SalDisplay* GetDisplay() const { return mpDisplay; }
const SalX11Screen& GetXScreenNumber() const { return mnXScreen; }
@@ -38,7 +37,9 @@ public:
virtual void ReleaseGraphics(SalGraphics* pGraphics) override;
// Set new size, without saving the old contents
- virtual bool SetSize(tools::Long nNewDX, tools::Long nNewDY) override;
+ virtual bool SetSizeUsingBuffer(sal_Int32 nNewDX, sal_Int32 nNewDY, sal_uInt8*, sal_Int32 = 100) override;
+
+ virtual void SetScalePercentage(sal_Int32) override;
};
#endif // INCLUDED_VCL_INC_SKIA_X11_SALVD_H
diff --git a/vcl/inc/unx/genprn.h b/vcl/inc/unx/genprn.h
index 0c92446d5286..7250bac909f3 100644
--- a/vcl/inc/unx/genprn.h
+++ b/vcl/inc/unx/genprn.h
@@ -43,7 +43,7 @@ public:
virtual bool SetPrinterData( ImplJobSetup* pSetupData ) override;
virtual bool SetData( JobSetFlags nFlags, ImplJobSetup* pSetupData ) override;
virtual void GetPageInfo( const ImplJobSetup* pSetupData,
- tools::Long& rOutWidth, tools::Long& rOutHeight,
+ sal_Int32& rOutWidth, sal_Int32& rOutHeight,
Point& rPageOffset,
Size& rPaperSize ) override;
virtual sal_uInt32 GetCapabilities( const ImplJobSetup* pSetupData, PrinterCapType nType ) override;
diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h
index 75c1e4cd0852..0cfccc73f26b 100644
--- a/vcl/inc/unx/genpspgraphics.h
+++ b/vcl/inc/unx/genpspgraphics.h
@@ -78,8 +78,7 @@ public:
return m_pBackend.get();
}
- virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override;
-
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const;
virtual void SetTextColor( Color nColor ) override;
virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index ced3613ad0ca..2942a617d58c 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -422,8 +422,8 @@ public:
#endif
int m_nGrabLevel;
bool m_bSalObjectSetPosSize;
- GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle );
- GtkSalFrame( SystemParentData* pSysData );
+ GtkSalFrame(SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window&);
+ GtkSalFrame(SystemParentData* pSysData, vcl::Window&);
guint m_nMenuExportId;
guint m_nActionGroupExportId;
@@ -489,6 +489,8 @@ public:
virtual ~GtkSalFrame() override;
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
+
// SalGraphics or NULL, but two Graphics for all SalFrames
// must be returned
virtual SalGraphics* AcquireGraphics() override;
@@ -514,7 +516,8 @@ public:
virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight ) override;
virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight ) override;
virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) override;
- virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) override;
+ void GetDPI(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
+ virtual void GetClientSize(sal_Int32& rWidth, sal_Int32& rHeight) override;
virtual void GetWorkArea( tools::Rectangle& rRect ) override;
virtual SalFrame* GetParent() const override;
virtual void SetWindowState( const SalFrameState* pState ) override;
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index c0a032863ea4..2bc63166689a 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -126,8 +126,7 @@ public:
void WidgetQueueDraw() const;
- virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
-
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
virtual OUString getRenderBackendName() const override { return "gtk3svp"; }
GtkStyleContext* createStyleContext(GtkControlPart ePart);
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index eb3199b58eaf..a674fdbe7d68 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -254,8 +254,8 @@ public:
void EnsureInit();
virtual void AfterAppInit() override;
- virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
- virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
+ virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& ) override;
+ virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin ) override;
virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) override;
virtual SalSystem* CreateSalSystem() override;
virtual SalInfoPrinter* CreateInfoPrinter(SalPrinterQueueInfo* pPrinterQueueInfo, ImplJobSetup* pJobSetup) override;
@@ -266,7 +266,7 @@ public:
virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override;
virtual std::unique_ptr<SalVirtualDevice>
CreateVirtualDevice( SalGraphics&,
- tools::Long &nDX, tools::Long &nDY,
+ sal_Int32 &nDX, sal_Int32 &nDY,
DeviceFormat eFormat,
const SystemGraphicsData* = nullptr ) override;
virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override;
diff --git a/vcl/inc/unx/salframe.h b/vcl/inc/unx/salframe.h
index 1107ac9feb71..5de29c198750 100644
--- a/vcl/inc/unx/salframe.h
+++ b/vcl/inc/unx/salframe.h
@@ -160,8 +160,10 @@ class X11SalFrame final : public SalFrame
void askForXEmbedFocus( sal_Int32 i_nTimeCode );
void updateWMClass();
+ sal_Int32 GetDPI() const;
+
public:
- X11SalFrame( SalFrame* pParent, SalFrameStyleFlags nSalFrameStyle, SystemParentData const * pSystemParent = nullptr );
+ X11SalFrame(SalFrame* pParent, SalFrameStyleFlags, SystemParentData const * pSystemParent, vcl::Window&);
virtual ~X11SalFrame() override;
bool Dispatch( XEvent *pEvent );
@@ -200,6 +202,7 @@ public:
bool appendUnicodeSequence( sal_Unicode );
bool endUnicodeSequence();
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
virtual SalGraphics* AcquireGraphics() override;
virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
@@ -219,7 +222,8 @@ public:
virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight ) override;
virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight ) override;
virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) override;
- virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) override;
+ virtual void GetDPI(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
+ virtual void GetClientSize(sal_Int32& rWidth, sal_Int32& rHeight) override;
virtual void GetWorkArea( tools::Rectangle& rRect ) override;
virtual SalFrame* GetParent() const override;
virtual void SetWindowState( const SalFrameState* pState ) override;
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 045a3848e20f..182a7f1acc34 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -110,8 +110,8 @@ public:
void Flush();
- // override all pure virtual methods
- virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override;
+ sal_Int32 GetDPI() const;
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
virtual void SetTextColor( Color nColor ) override;
virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h
index 1f8ccd92b19c..ebb4ec0641dd 100644
--- a/vcl/inc/unx/salinst.h
+++ b/vcl/inc/unx/salinst.h
@@ -44,20 +44,20 @@ public:
explicit X11SalInstance(std::unique_ptr<SalYieldMutex> pMutex);
virtual ~X11SalInstance() override;
- virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
- virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
+ virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin ) override;
+ virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& ) override;
virtual void DestroyFrame( SalFrame* pFrame ) override;
virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) override;
virtual void DestroyObject( SalObject* pObject ) override;
/// Gtk vclplug needs to pass GtkSalGraphics to X11SalVirtualDevice, so create it, and pass as pNewGraphics.
- static std::unique_ptr<SalVirtualDevice> CreateX11VirtualDevice(const SalGraphics& rGraphics, tools::Long &nDX, tools::Long &nDY,
+ static std::unique_ptr<SalVirtualDevice> CreateX11VirtualDevice(const SalGraphics& rGraphics, sal_Int32 &nDX, sal_Int32 &nDY,
DeviceFormat eFormat, const SystemGraphicsData* pData, std::unique_ptr<X11SalGraphics> pNewGraphics);
virtual std::unique_ptr<SalVirtualDevice>
CreateVirtualDevice( SalGraphics& rGraphics,
- tools::Long &nDX, tools::Long &nDY,
+ sal_Int32 &nDX, sal_Int32 &nDY,
DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) override;
virtual void PostPrintersChanged() override;
virtual std::unique_ptr<GenPspGraphics> CreatePrintGraphics() override;
diff --git a/vcl/inc/unx/salvd.h b/vcl/inc/unx/salvd.h
index 922b9d5e271c..78734de87d59 100644
--- a/vcl/inc/unx/salvd.h
+++ b/vcl/inc/unx/salvd.h
@@ -46,7 +46,7 @@ class X11SalVirtualDevice final : public SalVirtualDevice
bool bExternPixmap_;
public:
- X11SalVirtualDevice(const SalGraphics& rGraphics, tools::Long &nDX, tools::Long &nDY,
+ X11SalVirtualDevice(const SalGraphics& rGraphics, sal_Int32 &nDX, sal_Int32 &nDY,
DeviceFormat eFormat, const SystemGraphicsData *pData, std::unique_ptr<X11SalGraphics> pNewGraphics);
virtual ~X11SalVirtualDevice() override;
@@ -67,11 +67,10 @@ public:
virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
/// Set new size, without saving the old contents
- virtual bool SetSize( tools::Long nNewDX, tools::Long nNewDY ) override;
+ virtual bool SetSizeUsingBuffer(sal_Int32 nNewDX, sal_Int32 nNewDY, sal_uInt8*, sal_Int32) override;
- // SalGeometryProvider
- virtual tools::Long GetWidth() const override { return nDX_; }
- virtual tools::Long GetHeight() const override { return nDY_; }
+ virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override;
+ virtual void SetScalePercentage(sal_Int32) override;
};
#endif // INCLUDED_VCL_INC_UNX_SALVD_H
diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h
index c62a68ae0455..8ab5e5d7f313 100644
--- a/vcl/inc/win/salinst.h
+++ b/vcl/inc/win/salinst.h
@@ -43,8 +43,8 @@ public:
WinSalInstance();
virtual ~WinSalInstance() override;
- virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
- virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
+ virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin ) override;
+ virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& ) override;
virtual void DestroyFrame( SalFrame* pFrame ) override;
virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) override;
virtual void DestroyObject( SalObject* pObject ) override;
diff --git a/vcl/inc/win/salprn.h b/vcl/inc/win/salprn.h
index 2d02aa5b0e54..02c52be76380 100644
--- a/vcl/inc/win/salprn.h
+++ b/vcl/inc/win/salprn.h
@@ -64,7 +64,7 @@ public:
virtual bool SetPrinterData( ImplJobSetup* pSetupData ) override;
virtual bool SetData( JobSetFlags nFlags, ImplJobSetup* pSetupData ) override;
virtual void GetPageInfo( const ImplJobSetup* pSetupData,
- tools::Long& rOutWidth, tools::Long& rOutHeight,
+ sal_Int32& rOutWidth, sal_Int32& rOutHeight,
Point& rPageOffset,
Size& rPaperSize ) override;
virtual sal_uInt32 GetCapabilities( const ImplJobSetup* pSetupData, PrinterCapType nType ) override;
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index b0395330e19e..65cf596fe783 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -140,8 +140,6 @@ struct ImplFrameData
std::vector<VclPtr<vcl::Window> > maOwnerDrawList; //< List of system windows with owner draw decoration
std::shared_ptr<vcl::font::PhysicalFontCollection> mxFontCollection; //< Font-List for this frame
std::shared_ptr<ImplFontCache> mxFontCache; //< Font-Cache for this frame
- sal_Int32 mnDPIX; //< Original Screen Resolution
- sal_Int32 mnDPIY; //< Original Screen Resolution
ImplSVEvent * mnFocusId; //< FocusId for PostUserLink
ImplSVEvent * mnMouseMoveId; //< MoveId for PostUserLink
tools::Long mnLastMouseX; //< last x mouse position
@@ -214,11 +212,14 @@ namespace o3tl {
}
-class WindowImpl
+class WindowImpl final
{
+ friend class vcl::Window;
+
private:
WindowImpl(const WindowImpl&) = delete;
WindowImpl& operator=(const WindowImpl&) = delete;
+
public:
WindowImpl( vcl::Window& rWindow, WindowType );
~WindowImpl();
@@ -431,7 +432,7 @@ bool ImplLOKHandleMouseEvent( const VclPtr<vcl::Window>& xWindow, MouseNotifyEve
tools::Long nX, tools::Long nY, sal_uInt64 nMsgTime,
sal_uInt16 nCode, MouseEventModifiers nMode, sal_uInt16 nClicks);
-void ImplHandleResize( vcl::Window* pWindow, tools::Long nNewWidth, tools::Long nNewHeight );
+void ImplHandleResize(vcl::Window* pWindow, sal_Int32 nNewWidth, sal_Int32 nNewHeight);
VCL_DLLPUBLIC void ImplWindowStateFromStr(WindowStateData& rData, std::string_view rStr);
diff --git a/vcl/inc/windowdev.hxx b/vcl/inc/windowdev.hxx
index a3d535646ccf..69d9811e8ab6 100644
--- a/vcl/inc/windowdev.hxx
+++ b/vcl/inc/windowdev.hxx
@@ -23,7 +23,7 @@
namespace vcl
{
-class WindowOutputDevice final : public ::OutputDevice
+class WindowOutputDevice : public ::OutputDevice
{
public:
WindowOutputDevice(vcl::Window& rOwnerWindow);
diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx
index a9fa27e5ea82..b260a01efa26 100644
--- a/vcl/ios/iosinst.cxx
+++ b/vcl/ios/iosinst.cxx
@@ -118,13 +118,13 @@ public:
}
};
-SalFrame *IosSalInstance::CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle )
+SalFrame *IosSalInstance::CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin )
{
pParent = NULL;
return new IosSalFrame( this, NULL, nStyle );
}
-SalFrame *IosSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
+SalFrame *IosSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& )
{
return new IosSalFrame( this, pParent, nStyle );
}
diff --git a/vcl/qt5/QtData.cxx b/vcl/qt5/QtData.cxx
index 7d2d0418e80e..13569721b6cd 100644
--- a/vcl/qt5/QtData.cxx
+++ b/vcl/qt5/QtData.cxx
@@ -327,9 +327,7 @@ bool QtData::ErrorTrapPop(bool /*bIgnoreError*/) { return false; }
bool QtData::noNativeControls()
{
static const bool bNoNative
- = ((nullptr != getenv("SAL_VCL_QT5_NO_NATIVE")) && (nullptr != ImplGetSVData())
- && ImplGetSVData()->maAppData.mxToolkitName
- && ImplGetSVData()->maAppData.mxToolkitName->match("qt5"));
+ = (nullptr != getenv("SAL_VCL_QT5_NO_NATIVE"));
return bNoNative;
}
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 440cd8048d76..282a24f913d3 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -100,8 +100,9 @@ sal_Int32 screenNumber(const QScreen* pScreen)
}
}
-QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
- : m_pTopLevel(nullptr)
+QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin, bool bUseCairo)
+ : SalFrame(rWin)
+ , m_pTopLevel(nullptr)
, m_bUseCairo(bUseCairo)
, m_bNullRegion(true)
, m_bGraphicsInUse(false)
@@ -197,7 +198,31 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
fixICCCMwindowGroup();
}
-void QtFrame::screenChanged(QScreen*) { m_pQWidget->fakeResize(); }
+void QtFrame::screenChanged(QScreen* pScreen)
+{
+ SAL_DEBUG(__func__ << " " << m_pQWidget->size() << " " << pScreen->devicePixelRatio() << " "
+ << GetWidth() << " " << GetHeight());
+
+ maGeometry.nDisplayScreenNumber = screenNumber(pScreen);
+#if 1
+ if (m_pSvpGraphics)
+ {
+// m_pSvpGraphics->setDevicePixelRatioF(devicePixelRatioF());
+ m_pSvpGraphics->ReleaseFonts();
+ }
+ if (m_pQtGraphics)
+ {
+// m_pQtGraphics->setDevicePixelRatioF(devicePixelRatioF());
+ m_pQtGraphics->ReleaseFonts();
+ }
+#endif
+ m_pQWidget->fakeResize();
+ CallCallback(SalEvent::SettingsChanged, nullptr);
+#if 0
+ SalPaintEvent aPaintEvt(0, 0, GetWidth(), GetHeight(), true);
+ CallCallback(SalEvent::Paint, &aPaintEvt);
+#endif
+}
void QtFrame::FillSystemEnvData(SystemEnvData& rData, sal_IntPtr pWindow, QWidget* pWidget)
{
@@ -303,6 +328,8 @@ SalGraphics* QtFrame::AcquireGraphics()
if (m_bGraphicsInUse)
return nullptr;
+ SAL_DEBUG(__func__ << " " << this);
+
m_bGraphicsInUse = true;
if (m_bUseCairo)
@@ -313,8 +340,7 @@ SalGraphics* QtFrame::AcquireGraphics()
m_pSvpGraphics.reset(new QtSvpGraphics(this));
m_pSurface.reset(
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, aSize.width(), aSize.height()));
- m_pSvpGraphics->setSurface(m_pSurface.get(),
- basegfx::B2IVector(aSize.width(), aSize.height()));
+ m_pSvpGraphics->setSurface(m_pSurface.get());
cairo_surface_set_user_data(m_pSurface.get(), QtSvpGraphics::getDamageKey(),
&m_aDamageHandler, nullptr);
}
@@ -624,8 +650,10 @@ void QtFrame::SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, too
asChild()->move(round(nX / devicePixelRatioF()), round(nY / devicePixelRatioF()));
}
-void QtFrame::GetClientSize(tools::Long& rWidth, tools::Long& rHeight)
+void QtFrame::GetClientSize(sal_Int32& rWidth, sal_Int32& rHeight)
{
+ SAL_DEBUG(__func__ << " " << m_pQWidget->width() << " " << m_pQWidget->height() << " "
+ << devicePixelRatioF());
rWidth = round(m_pQWidget->width() * devicePixelRatioF());
rHeight = round(m_pQWidget->height() * devicePixelRatioF());
}
@@ -1509,4 +1537,33 @@ void QtFrame::handleDragLeave()
m_bInDrag = false;
}
+void QtFrame::GetDPI(sal_Int32& rDPIX, sal_Int32& rDPIY)
+{
+ char* pForceDpi;
+ if ((pForceDpi = getenv("SAL_FORCEDPI")))
+ {
+ OString sForceDPI(pForceDpi);
+ rDPIX = rDPIY = sForceDPI.toInt32();
+ return;
+ }
+
+ QScreen* pScreen = screen();
+ if (!pScreen)
+ return;
+
+ rDPIX = pScreen->logicalDotsPerInchX() * pScreen->devicePixelRatio() + 0.5;
+ rDPIY = pScreen->logicalDotsPerInchY() * pScreen->devicePixelRatio() + 0.5;
+}
+
+sal_Int32 QtFrame::GetSgpMetric(vcl::SGPmetric eMetric) const
+{
+ switch (eMetric)
+ {
+ case vcl::SGPmetric::Width: return asChild()->width() * GetDPIScaleFactor();
+ case vcl::SGPmetric::Height: return asChild()->height() * GetDPIScaleFactor();
+ default:
+ return GetWindow()->GetOutDev()->GetSgpMetric(eMetric);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtGraphics.cxx b/vcl/qt5/QtGraphics.cxx
index d809556ce219..3bda88974f1d 100644
--- a/vcl/qt5/QtGraphics.cxx
+++ b/vcl/qt5/QtGraphics.cxx
@@ -42,8 +42,10 @@ QtGraphics::QtGraphics( QtFrame *pFrame, QImage *pQImage )
if (!QtData::noNativeControls())
m_pWidgetDraw.reset(new QtGraphics_Controls(*this));
}
+#if 0
if (m_pFrame)
- setDevicePixelRatioF(m_pFrame->devicePixelRatioF());
+ setScale(m_pFrame->devicePixelRatioF());
+#endif
}
QtGraphics::~QtGraphics() { ReleaseFonts(); }
@@ -103,4 +105,15 @@ void QtGraphics::handleDamage(const tools::Rectangle& rDamagedRegion)
aPainter.update(toQRect(rDamagedRegion));
}
+sal_Int32 QtGraphics::GetSgpMetric(vcl::SGPmetric eMetric) const
+{
+ QImage* pImage = static_cast<QtGraphics_Controls*>(m_pWidgetDraw.get())->getImage();
+ assert(pImage || m_pFrame);
+ if (pImage)
+ return GetSgpMetricFromQImage(eMetric, *pImage);
+ if (m_pFrame)
+ return m_pFrame->GetWindow()->GetOutDev()->GetSgpMetric(eMetric);
+ return -1;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtGraphics_Controls.cxx b/vcl/qt5/QtGraphics_Controls.cxx
index e6e3d820da59..4e0a530a8fe1 100644
--- a/vcl/qt5/QtGraphics_Controls.cxx
+++ b/vcl/qt5/QtGraphics_Controls.cxx
@@ -25,8 +25,8 @@
#include <QtWidgets/QLabel>
#include <QtTools.hxx>
-#include <QtGraphicsBase.hxx>
#include <vcl/decoview.hxx>
+#include <salgdi.hxx>
/**
Conversion function between VCL ControlState together with
@@ -74,7 +74,7 @@ static void lcl_ApplyBackgroundColorToStyleOption(QStyleOption& rOption,
}
}
-QtGraphics_Controls::QtGraphics_Controls(const QtGraphicsBase& rGraphics)
+QtGraphics_Controls::QtGraphics_Controls(const SalGraphics& rGraphics)
: m_rGraphics(rGraphics)
{
}
@@ -268,7 +268,7 @@ bool QtGraphics_Controls::drawNativeControl(ControlType type, ControlPart part,
{
m_image.reset(new QImage(widgetRect.width(), widgetRect.height(),
QImage::Format_ARGB32_Premultiplied));
- m_image->setDevicePixelRatio(m_rGraphics.devicePixelRatioF());
+ m_image->setDevicePixelRatio(m_rGraphics.GetDPIScaleFactor());
}
// Default image color - just once
@@ -1094,14 +1094,14 @@ bool QtGraphics_Controls::hitTestNativeControl(ControlType nType, ControlPart nP
inline int QtGraphics_Controls::downscale(int size, Round eRound)
{
- return static_cast<int>(eRound == Round::Ceil ? ceil(size / m_rGraphics.devicePixelRatioF())
- : floor(size / m_rGraphics.devicePixelRatioF()));
+ return static_cast<int>(eRound == Round::Ceil ? ceil(size / m_rGraphics.GetDPIScaleFactor())
+ : floor(size / m_rGraphics.GetDPIScaleFactor()));
}
inline int QtGraphics_Controls::upscale(int size, Round eRound)
{
- return static_cast<int>(eRound == Round::Ceil ? ceil(size * m_rGraphics.devicePixelRatioF())
- : floor(size * m_rGraphics.devicePixelRatioF()));
+ return static_cast<int>(eRound == Round::Ceil ? ceil(size * m_rGraphics.GetDPIScaleFactor())
+ : floor(size * m_rGraphics.GetDPIScaleFactor()));
}
inline QRect QtGraphics_Controls::downscale(const QRect& rect)
diff --git a/vcl/qt5/QtGraphics_GDI.cxx b/vcl/qt5/QtGraphics_GDI.cxx
index f87de50827df..431f659c1fcf 100644
--- a/vcl/qt5/QtGraphics_GDI.cxx
+++ b/vcl/qt5/QtGraphics_GDI.cxx
@@ -23,6 +23,7 @@
#include <QtPainter.hxx>
#include <sal/log.hxx>
+#include <window.h>
#include <QtGui/QPainter>
#include <QtGui/QScreen>
@@ -736,29 +737,4 @@ bool QtGraphicsBackend::supportsOperation(OutDevSupportType eType) const
}
}
-void QtGraphics::GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY)
-{
- char* pForceDpi;
- if ((pForceDpi = getenv("SAL_FORCEDPI")))
- {
- OString sForceDPI(pForceDpi);
- rDPIX = rDPIY = sForceDPI.toInt32();
- return;
- }
-
- if (!m_pFrame)
- return;
-
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
- QScreen* pScreen = m_pFrame->GetQWidget()->screen();
-#else
- if (!m_pFrame->GetQWidget()->window()->windowHandle())
- return;
-
- QScreen* pScreen = m_pFrame->GetQWidget()->window()->windowHandle()->screen();
-#endif
- rDPIX = pScreen->logicalDotsPerInchX() * pScreen->devicePixelRatio() + 0.5;
- rDPIY = pScreen->logicalDotsPerInchY() * pScreen->devicePixelRatio() + 0.5;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx
index 5522ea15c31a..1234cbc0c9ec 100644
--- a/vcl/qt5/QtInstance.cxx
+++ b/vcl/qt5/QtInstance.cxx
@@ -297,21 +297,21 @@ void QtInstance::localeChanged()
void QtInstance::deleteObjectLater(QObject* pObject) { pObject->deleteLater(); }
-SalFrame* QtInstance::CreateChildFrame(SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle)
+SalFrame* QtInstance::CreateChildFrame(SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle, vcl::Window& rWin)
{
SalFrame* pRet(nullptr);
- RunInMainThread([&, this]() { pRet = new QtFrame(nullptr, nStyle, useCairo()); });
+ RunInMainThread([&, this]() { pRet = new QtFrame(nullptr, nStyle, rWin, useCairo()); });
assert(pRet);
return pRet;
}
-SalFrame* QtInstance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle)
+SalFrame* QtInstance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin)
{
assert(!pParent || dynamic_cast<QtFrame*>(pParent));
SalFrame* pRet(nullptr);
RunInMainThread(
- [&, this]() { pRet = new QtFrame(static_cast<QtFrame*>(pParent), nStyle, useCairo()); });
+ [&, this]() { pRet = new QtFrame(static_cast<QtFrame*>(pParent), nStyle, rWin, useCairo()); });
assert(pRet);
return pRet;
}
@@ -345,7 +345,7 @@ void QtInstance::DestroyObject(SalObject* pObject)
}
std::unique_ptr<SalVirtualDevice>
-QtInstance::CreateVirtualDevice(SalGraphics& rGraphics, tools::Long& nDX, tools::Long& nDY,
+QtInstance::CreateVirtualDevice(SalGraphics& rGraphics, sal_Int32& nDX, sal_Int32& nDY,
DeviceFormat /*eFormat*/, const SystemGraphicsData* pGd)
{
if (m_bUseCairo)
@@ -362,8 +362,7 @@ QtInstance::CreateVirtualDevice(SalGraphics& rGraphics, tools::Long& nDX, tools:
}
else
{
- std::unique_ptr<SalVirtualDevice> pVD(new QtVirtualDevice(/*scale*/ 1));
- pVD->SetSize(nDX, nDY);
+ std::unique_ptr<SalVirtualDevice> pVD(new QtVirtualDevice(nDX, nDY, rGraphics.GetDPIScalePercentage()));
return pVD;
}
}
diff --git a/vcl/qt5/QtSvpGraphics.cxx b/vcl/qt5/QtSvpGraphics.cxx
index 8ae869a1c247..7b49ff3df806 100644
--- a/vcl/qt5/QtSvpGraphics.cxx
+++ b/vcl/qt5/QtSvpGraphics.cxx
@@ -26,11 +26,16 @@
QtSvpGraphics::QtSvpGraphics(QtFrame* pFrame)
: m_pFrame(pFrame)
+ , m_nScalePercentage(-1)
{
if (!QtData::noNativeControls())
m_pWidgetDraw.reset(new QtGraphics_Controls(*this));
+ SAL_DEBUG(__func__ << " " << m_pFrame);
+#if 1
if (m_pFrame)
- setDevicePixelRatioF(m_pFrame->devicePixelRatioF());
+ SAL_DEBUG(__func__ << " " << m_pFrame->devicePixelRatioF());
+// setDevicePixelRatioF(m_pFrame->devicePixelRatioF());
+#endif
}
QtSvpGraphics::~QtSvpGraphics() {}
@@ -93,29 +98,17 @@ void QtSvpGraphics::handleDamage(const tools::Rectangle& rDamagedRegion)
getSvpBackend()->drawBitmapBuffer(aTR, &aBuffer, CAIRO_OPERATOR_OVER);
}
-void QtSvpGraphics::GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY)
+sal_Int32 QtSvpGraphics::GetSgpMetric(vcl::SGPmetric eMetric) const
{
- char* pForceDpi;
- if ((pForceDpi = getenv("SAL_FORCEDPI")))
+ QImage* pImage = static_cast<QtGraphics_Controls*>(m_pWidgetDraw.get())->getImage();
+ if (!pImage)
{
- OString sForceDPI(pForceDpi);
- rDPIX = rDPIY = sForceDPI.toInt32();
- return;
+ if (eMetric == vcl::SGPmetric::ScalePercentage && m_nScalePercentage > 0)
+ return m_nScalePercentage;
+ return SvpSalGraphics::GetSgpMetric(eMetric);
}
-
- if (!m_pFrame)
- return;
-
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
- QScreen* pScreen = m_pFrame->GetQWidget()->screen();
-#else
- if (!m_pFrame->GetQWidget()->window()->windowHandle())
- return;
-
- QScreen* pScreen = m_pFrame->GetQWidget()->window()->windowHandle()->screen();
-#endif
- rDPIX = pScreen->logicalDotsPerInchX() * pScreen->devicePixelRatio() + 0.5;
- rDPIY = pScreen->logicalDotsPerInchY() * pScreen->devicePixelRatio() + 0.5;
+ else
+ return GetSgpMetricFromQImage(eMetric, *pImage);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtTools.cxx b/vcl/qt5/QtTools.cxx
index f9a0a0e0e328..3f5cc301e627 100644
--- a/vcl/qt5/QtTools.cxx
+++ b/vcl/qt5/QtTools.cxx
@@ -119,4 +119,21 @@ QImage toQImage(const Image& rImage)
return aImage;
}
+sal_Int32 GetSgpMetricFromQImage(vcl::SGPmetric eMetric, QImage &rImage)
+{
+ switch (eMetric)
+ {
+ case vcl::SGPmetric::Width: return rImage.width();
+ case vcl::SGPmetric::Height: return rImage.height();
+ case vcl::SGPmetric::ScalePercentage: return round(100 * rImage.devicePixelRatioF());
+ case vcl::SGPmetric::OffScreen: return true;
+ case vcl::SGPmetric::BitCount: return getFormatBits(rImage.format());
+ case vcl::SGPmetric::DPIX:
+ case vcl::SGPmetric::DPIY:
+ return round(96 * rImage.devicePixelRatioF());
+ default:
+ return -1;
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtVirtualDevice.cxx b/vcl/qt5/QtVirtualDevice.cxx
index 7e0dbab873d4..7a67707dd213 100644
--- a/vcl/qt5/QtVirtualDevice.cxx
+++ b/vcl/qt5/QtVirtualDevice.cxx
@@ -24,9 +24,9 @@
#include <QtGui/QImage>
-QtVirtualDevice::QtVirtualDevice(double fScale)
- : m_fScale(fScale)
+QtVirtualDevice::QtVirtualDevice(sal_Int32 nNewDX, sal_Int32 nNewDY, sal_Int32 nScale)
{
+ SetSizeUsingBuffer(nNewDX, nNewDY, nullptr, nScale);
}
SalGraphics* QtVirtualDevice::AcquireGraphics()
@@ -45,25 +45,16 @@ void QtVirtualDevice::ReleaseGraphics(SalGraphics* pGraphics)
delete pGraphics;
}
-bool QtVirtualDevice::SetSize(tools::Long nNewDX, tools::Long nNewDY)
+bool QtVirtualDevice::SetSizeUsingBuffer(sal_Int32 nNewDX, sal_Int32 nNewDY, sal_uInt8* pBuffer, sal_Int32 nScale)
{
- return SetSizeUsingBuffer(nNewDX, nNewDY, nullptr);
-}
-
-bool QtVirtualDevice::SetSizeUsingBuffer(tools::Long nNewDX, tools::Long nNewDY, sal_uInt8* pBuffer)
-{
- if (nNewDX == 0)
- nNewDX = 1;
- if (nNewDY == 0)
- nNewDY = 1;
-
- if (m_pImage && m_aFrameSize.width() == nNewDX && m_aFrameSize.height() == nNewDY)
+ FixSetSizeParams(nNewDX, nNewDY, nScale);
+ SAL_DEBUG(__func__ << " " << nScale);
+ if (!pBuffer && m_pImage && m_pImage->width() == nNewDX && m_pImage->height() == nNewDY && nScale == GetDPIScalePercentage())
return true;
- m_aFrameSize = QSize(nNewDX, nNewDY);
-
- nNewDX *= m_fScale;
- nNewDY *= m_fScale;
+ float fScale = nScale / 100.0;
+ nNewDX *= fScale;
+ nNewDY *= fScale;
if (pBuffer)
m_pImage.reset(new QImage(pBuffer, nNewDX, nNewDY, Qt_DefaultFormat32));
@@ -71,7 +62,7 @@ bool QtVirtualDevice::SetSizeUsingBuffer(tools::Long nNewDX, tools::Long nNewDY,
m_pImage.reset(new QImage(nNewDX, nNewDY, Qt_DefaultFormat32));
m_pImage->fill(Qt::transparent);
- m_pImage->setDevicePixelRatio(m_fScale);
+ m_pImage->setDevicePixelRatio(fScale);
// update device in existing graphics
for (auto pQtGraph : m_aGraphics)
@@ -80,8 +71,19 @@ bool QtVirtualDevice::SetSizeUsingBuffer(tools::Long nNewDX, tools::Long nNewDY,
return true;
}
-tools::Long QtVirtualDevice::GetWidth() const { return m_pImage ? m_aFrameSize.width() : 0; }
+sal_Int32 QtVirtualDevice::GetSgpMetric(vcl::SGPmetric eMetric) const
+{
+ assert(m_pImage);
+ if (!m_pImage)
+ return -1;
+ return ::GetSgpMetricFromQImage(eMetric, *m_pImage);
+}
-tools::Long QtVirtualDevice::GetHeight() const { return m_pImage ? m_aFrameSize.height() : 0; }
+void QtVirtualDevice::SetScalePercentage(sal_Int32 nScale)
+{
+ if (!m_pImage)
+ SetSizeUsingBuffer(1, 1, nullptr);
+ m_pImage->setDevicePixelRatio(nScale / 100.0);
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx
index 04a3af5dac23..a8f2be7a15e6 100644
--- a/vcl/qt5/QtWidget.cxx
+++ b/vcl/qt5/QtWidget.cxx
@@ -39,6 +39,7 @@
#include <QtGui/QPaintEvent>
#include <QtGui/QResizeEvent>
#include <QtGui/QShowEvent>
+#include <QtGui/QScreen>
#include <QtGui/QTextCharFormat>
#include <QtGui/QWheelEvent>
#include <QtWidgets/QMainWindow>
@@ -104,7 +105,7 @@ void QtWidget::resizeEvent(QResizeEvent* pEvent)
= cairo_image_surface_create(CAIRO_FORMAT_ARGB32, nWidth, nHeight);
cairo_surface_set_user_data(pSurface, SvpSalGraphics::getDamageKey(),
&m_rFrame.m_aDamageHandler, nullptr);
- m_rFrame.m_pSvpGraphics->setSurface(pSurface, basegfx::B2IVector(nWidth, nHeight));
+ m_rFrame.m_pSvpGraphics->setSurface(pSurface);
UniqueCairoSurface old_surface(m_rFrame.m_pSurface.release());
m_rFrame.m_pSurface.reset(pSurface);
@@ -201,6 +202,7 @@ void QtWidget::mouseMoveEvent(QMouseEvent* pEvent)
SalMouseEvent aEvent;
FILL_SAME(m_rFrame, width());
+ SAL_DEBUG(this << " " << __func__ << " " << Point(aEvent.mnX, aEvent.mnY));
aEvent.mnButton = 0;
m_rFrame.CallCallback(SalEvent::MouseMove, &aEvent);
@@ -222,6 +224,9 @@ void QtWidget::handleMouseEnterLeaveEvents(const QtFrame& rFrame, QEvent* pQEven
aEvent.mnCode = GetKeyModCode(QGuiApplication::keyboardModifiers())
| GetMouseModCode(QGuiApplication::mouseButtons());
+ SAL_DEBUG(pWidget << " " << __func__ << " " << Point(aEvent.mnX, aEvent.mnY) << " "
+ << QGuiApplication::isLeftToRight());
+
SalEvent nEventType;
if (pQEvent->type() == QEvent::Enter)
nEventType = SalEvent::MouseMove;
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index c253ceb3a2df..7997f81f1ddc 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -257,7 +257,7 @@ public:
}
};
-SkiaSalGraphicsImpl::SkiaSalGraphicsImpl(SalGraphics& rParent, SalGeometryProvider* pProvider)
+SkiaSalGraphicsImpl::SkiaSalGraphicsImpl(SalGraphics& rParent, vcl::SalGeometryProvider* pProvider)
: mParent(rParent)
, mProvider(pProvider)
, mIsGPU(false)
diff --git a/vcl/skia/x11/salvd.cxx b/vcl/skia/x11/salvd.cxx
index 73488b8a10bc..69931f883ae9 100644
--- a/vcl/skia/x11/salvd.cxx
+++ b/vcl/skia/x11/salvd.cxx
@@ -32,8 +32,8 @@ void X11SalGraphics::Init(X11SkiaSalVirtualDevice* pDevice)
mxImpl->Init();
}
-X11SkiaSalVirtualDevice::X11SkiaSalVirtualDevice(const SalGraphics& rGraphics, tools::Long nDX,
- tools::Long nDY, const SystemGraphicsData* pData,
+X11SkiaSalVirtualDevice::X11SkiaSalVirtualDevice(const SalGraphics& rGraphics, sal_Int32 nDX,
+ sal_Int32 nDY, const SystemGraphicsData* pData,
std::unique_ptr<X11SalGraphics> pNewGraphics)
: mpGraphics(std::move(pNewGraphics))
, mbGraphics(false)
@@ -54,6 +54,22 @@ X11SkiaSalVirtualDevice::X11SkiaSalVirtualDevice(const SalGraphics& rGraphics, t
X11SkiaSalVirtualDevice::~X11SkiaSalVirtualDevice() {}
+sal_Int32 X11SkiaSalVirtualDevice::GetSgpMetric(vcl::SGPmetric eMetric) const
+{
+ switch (eMetric)
+ {
+ case vcl::SGPmetric::Width: return mnWidth;
+ case vcl::SGPmetric::Height: return mnHeight;
+ case vcl::SGPmetric::DPIX: return 96;
+ case vcl::SGPmetric::DPIY: return 96;
+ case vcl::SGPmetric::ScalePercentage: return 100;
+ case vcl::SGPmetric::OffScreen: return true;
+ case vcl::SGPmetric::BitCount: return 32;
+ default:
+ return -1;
+ }
+}
+
SalGraphics* X11SkiaSalVirtualDevice::AcquireGraphics()
{
if (mbGraphics)
@@ -67,13 +83,9 @@ SalGraphics* X11SkiaSalVirtualDevice::AcquireGraphics()
void X11SkiaSalVirtualDevice::ReleaseGraphics(SalGraphics*) { mbGraphics = false; }
-bool X11SkiaSalVirtualDevice::SetSize(tools::Long nDX, tools::Long nDY)
+bool X11SkiaSalVirtualDevice::SetSizeUsingBuffer(sal_Int32 nDX, sal_Int32 nDY, sal_uInt8*, sal_Int32 nScale)
{
- if (!nDX)
- nDX = 1;
- if (!nDY)
- nDY = 1;
-
+ FixSetSizeParams(nDX, nDY, nScale);
mnWidth = nDX;
mnHeight = nDY;
if (mpGraphics)
@@ -82,4 +94,8 @@ bool X11SkiaSalVirtualDevice::SetSize(tools::Long nDX, tools::Long nDY)
return true;
}
+void X11SkiaSalVirtualDevice::SetScalePercentage(sal_Int32)
+{
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index a8fdaf2a7978..483dbacd6250 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -85,8 +85,8 @@
#include <salvtables.hxx>
#include <comphelper/lok.hxx>
-SalFrame::SalFrame()
- : m_pWindow(nullptr)
+SalFrame::SalFrame(vcl::Window &rWindow)
+ : m_pWindow(&rWindow)
, m_pProc(nullptr)
{
}
@@ -96,10 +96,11 @@ SalFrame::SalFrame()
SalFrame::~SalFrame() {}
-void SalFrame::SetCallback(vcl::Window* pWindow, SALFRAMEPROC pProc)
+void SalFrame::SetCallback(SALFRAMEPROC pProc)
{
- m_pWindow = pWindow;
m_pProc = pProc;
+ if (!pProc)
+ m_pWindow = nullptr;
}
// default to full-frame flushes
@@ -555,7 +556,7 @@ OUString SalInstanceWidget::strip_mnemonic(const OUString& rLabel) const
VclPtr<VirtualDevice> SalInstanceWidget::create_virtual_device() const
{
// create with (annoying) separate alpha layer that LibreOffice itself uses
- return VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), DeviceFormat::DEFAULT,
+ return VclPtr<VirtualDevice>::Create(*m_xWidget->GetOutDev(), DeviceFormat::DEFAULT,
DeviceFormat::DEFAULT);
}
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index b2113709b724..4abe76b1dd32 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -822,9 +822,10 @@ void Printer::ImplUpdatePageData()
if ( !AcquireGraphics() )
return;
- mpGraphics->GetResolution( mnDPIX, mnDPIY );
+ mnDPIX = mpGraphics->GetDPIX();
+ mnDPIY = mpGraphics->GetDPIY();
mpInfoPrinter->GetPageInfo( &maJobSetup.ImplGetConstData(),
- mnOutWidth, mnOutHeight,
+ m_nWidth, m_nHeight,
maPageOffset,
maPaperSize );
}
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index 1aec06239913..146a4865a7a4 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -123,7 +123,7 @@ void VirtualDevice::ReleaseGraphics( bool bRelease )
}
void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev,
- tools::Long nDX, tools::Long nDY, const SystemGraphicsData *pData )
+ sal_Int32 nDX, sal_Int32 nDY, const SystemGraphicsData *pData )
{
SAL_INFO( "vcl.virdev", "ImplInitVirDev(" << nDX << "," << nDY << ")" );
@@ -165,8 +165,8 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev,
}
mnBitCount = pOutDev->GetBitCount();
- mnOutWidth = nDX;
- mnOutHeight = nDY;
+ m_nWidth = nDX;
+ m_nHeight = nDY;
mbScreenComp = pOutDev->IsScreenComp();
@@ -269,7 +269,7 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra
}
bool bRet;
- tools::Long nNewWidth = rNewSize.Width(), nNewHeight = rNewSize.Height();
+ sal_Int32 nNewWidth = rNewSize.Width(), nNewHeight = rNewSize.Height();
if ( nNewWidth < 1 )
nNewWidth = 1;
@@ -286,8 +286,8 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra
if ( bRet )
{
- mnOutWidth = rNewSize.Width();
- mnOutHeight = rNewSize.Height();
+ m_nWidth = rNewSize.Width();
+ m_nHeight = rNewSize.Height();
Erase();
}
}
@@ -310,12 +310,12 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra
{
tools::Long nWidth;
tools::Long nHeight;
- if ( mnOutWidth < nNewWidth )
- nWidth = mnOutWidth;
+ if ( m_nWidth < nNewWidth )
+ nWidth = m_nWidth;
else
nWidth = nNewWidth;
- if ( mnOutHeight < nNewHeight )
- nHeight = mnOutHeight;
+ if ( m_nHeight < nNewHeight )
+ nHeight = m_nHeight;
else
nHeight = nNewHeight;
SalTwoRect aPosAry(0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight);
@@ -323,8 +323,8 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra
pNewVirDev->ReleaseGraphics( pGraphics );
ReleaseGraphics();
mpVirDev = std::move(pNewVirDev);
- mnOutWidth = rNewSize.Width();
- mnOutHeight = rNewSize.Height();
+ m_nWidth = rNewSize.Width();
+ m_nHeight = rNewSize.Height();
bRet = true;
}
else
@@ -492,11 +492,6 @@ void VirtualDevice::ImplSetReferenceDevice( RefDevMode i_eRefDevMode, sal_Int32
mxFontCache = std::make_shared<ImplFontCache>();
}
-sal_uInt16 VirtualDevice::GetBitCount() const
-{
- return mnBitCount;
-}
-
bool VirtualDevice::UsePolyPolygonForComplexGradient()
{
return true;
diff --git a/vcl/source/helper/geometryprovider.cxx b/vcl/source/helper/geometryprovider.cxx
new file mode 100644
index 000000000000..cfce9d0b280d
--- /dev/null
+++ b/vcl/source/helper/geometryprovider.cxx
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include <vcl/GeometryProvider.hxx>
+
+using namespace vcl;
+
+SalGeometryProvider::~SalGeometryProvider() {}
+
+sal_Int32 SalGeometryProviderImpl::GetSgpMetric(SGPmetric eMetric) const
+{
+ switch (eMetric)
+ {
+ case SGPmetric::Width: return m_nWidth;
+ case SGPmetric::Height: return m_nHeight;
+ case SGPmetric::DPIX: return mnDPIX;
+ case SGPmetric::DPIY: return mnDPIY;
+ case SGPmetric::ScalePercentage: return mnDPIScalePercentage;
+ case SGPmetric::OffScreen: return m_bOffScreen;
+ case SGPmetric::BitCount: return mnBitCount;
+ default:
+ return -1;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx
index e32f7e54df22..1336f561fc3f 100644
--- a/vcl/source/image/Image.cxx
+++ b/vcl/source/image/Image.cxx
@@ -86,7 +86,7 @@ OUString Image::GetStock() const
Size Image::GetSizePixel() const
{
if (mpImplData)
- return mpImplData->getSizePixel();
+ return mpImplData->GetSizePixel();
else
return Size();
}
@@ -118,9 +118,11 @@ void Image::Draw(OutputDevice* pOutDev, const Point& rPos, DrawImageFlags nStyle
if (!mpImplData || (!pOutDev->IsDeviceOutputNecessary() && pOutDev->GetConnectMetaFile() == nullptr))
return;
- Size aOutSize = pSize ? *pSize : pOutDev->PixelToLogic(mpImplData->getSizePixel());
+ Size aOutSize = pSize ? *pSize : pOutDev->PixelToLogic(mpImplData->GetSizePixel());
- BitmapEx aRenderBmp = mpImplData->getBitmapExForHiDPI(bool(nStyle & DrawImageFlags::Disable));
+ mpImplData->setScalePercentage(pOutDev->GetDPIScalePercentage());
+// SAL_DEBUG(__func__ << " " << pOutDev->GetDPIScalePercentage());
+ BitmapEx aRenderBmp = mpImplData->getBitmapEx(bool(nStyle & DrawImageFlags::Disable));
if (!(nStyle & DrawImageFlags::Disable) &&
(nStyle & (DrawImageFlags::ColorTransform | DrawImageFlags::Highlight |
diff --git a/vcl/source/image/ImplImage.cxx b/vcl/source/image/ImplImage.cxx
index a5637c3bb452..6daadd006f62 100644
--- a/vcl/source/image/ImplImage.cxx
+++ b/vcl/source/image/ImplImage.cxx
@@ -20,6 +20,7 @@
#include <sal/log.hxx>
#include <vcl/svapp.hxx>
#include <vcl/bitmapex.hxx>
+#include <vcl/outdev.hxx>
#include <vcl/settings.hxx>
#include <vcl/BitmapFilter.hxx>
#include <vcl/ImageTree.hxx>
@@ -30,7 +31,7 @@
ImplImage::ImplImage(const BitmapEx &rBitmapEx)
: maBitmapChecksum(0)
- , maSizePixel(rBitmapEx.GetSizePixel())
+ , m_nScalePercentage(100)
, maBitmapEx(rBitmapEx)
{
}
@@ -38,25 +39,22 @@ ImplImage::ImplImage(const BitmapEx &rBitmapEx)
ImplImage::ImplImage(const OUString &aStockName)
: maBitmapChecksum(0)
, maStockName(aStockName)
+ , m_nScalePercentage(100)
{
}
-bool ImplImage::loadStockAtScale(double fScale, BitmapEx &rBitmapEx)
+bool ImplImage::loadStockAtScale(BitmapEx* pBitmapEx) const
{
+ assert(pBitmapEx);
BitmapEx aBitmapEx;
-
ImageLoadFlags eScalingFlags = ImageLoadFlags::NONE;
- sal_Int32 nScalePercentage = -1;
if (comphelper::LibreOfficeKit::isActive()) // scale at the surface
- {
- nScalePercentage = fScale * 100.0;
eScalingFlags = ImageLoadFlags::IgnoreScalingFactor;
- }
OUString aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
if (!ImageTree::get().loadImage(maStockName, aIconTheme, aBitmapEx, true,
- nScalePercentage, eScalingFlags))
+ m_nScalePercentage, eScalingFlags))
{
/* If the uno command has parameters, passed in from a toolbar,
* recover from failure by removing the parameters from the file name
@@ -68,48 +66,57 @@ bool ImplImage::loadStockAtScale(double fScale, BitmapEx &rBitmapEx)
OUString aFileName = maStockName.replaceAt(nStart, nEnd - nStart, u"");
if (!ImageTree::get().loadImage(aFileName, aIconTheme, aBitmapEx, true,
- nScalePercentage, eScalingFlags))
+ m_nScalePercentage, eScalingFlags))
{
SAL_WARN("vcl", "Failed to load scaled image from " << maStockName <<
- " and " << aFileName << " at " << fScale);
+ " and " << aFileName << " at " << m_nScalePercentage << "%");
return false;
}
}
else
{
SAL_WARN("vcl", "Failed to load scaled image from " << maStockName <<
- " at " << fScale);
+ " at " << m_nScalePercentage << "%");
return false;
}
}
- rBitmapEx = aBitmapEx;
+ (*pBitmapEx) = aBitmapEx;
return true;
}
-Size ImplImage::getSizePixel()
+sal_Int32 ImplImage::GetSgpMetric(vcl::SGPmetric eMetric) const
{
- Size aRet;
- if (!isSizeEmpty())
- aRet = maSizePixel;
- else if (isStock())
+ if (isStock() && maBitmapEx.IsEmpty())
{
- if (loadStockAtScale(1.0, maBitmapEx))
+ if (loadStockAtScale(const_cast<BitmapEx*>(&maBitmapEx)))
{
assert(maDisabledBitmapEx.IsEmpty());
assert(maBitmapChecksum == 0);
- maSizePixel = maBitmapEx.GetSizePixel();
- aRet = maSizePixel;
}
else
SAL_WARN("vcl", "Failed to load stock icon " << maStockName);
}
- return aRet;
+
+ using namespace vcl;
+ switch (eMetric)
+ {
+ case vcl::SGPmetric::Width: return maBitmapEx.GetSizePixel().getWidth();
+ case vcl::SGPmetric::Height: return maBitmapEx.GetSizePixel().getHeight();
+ case vcl::SGPmetric::DPIX:
+ case vcl::SGPmetric::DPIY:
+ return round(96 * m_nScalePercentage / 100.0);
+ case vcl::SGPmetric::ScalePercentage: return m_nScalePercentage;
+ case vcl::SGPmetric::OffScreen: return true;
+ case vcl::SGPmetric::BitCount: return static_cast<sal_Int32>(maBitmapEx.getPixelFormat());
+ default:
+ return -1;
+ }
}
/// non-HiDPI compatibility method.
BitmapEx const & ImplImage::getBitmapEx(bool bDisabled)
{
- getSizePixel(); // force load, and at unity scale.
+ GetSgpMetric(vcl::SGPmetric::Width); // force load, and at unity scale.
if (bDisabled)
{
// Changed since we last generated this.
@@ -132,23 +139,19 @@ bool ImplImage::isEqual(const ImplImage &ref) const
if (isStock() != ref.isStock())
return false;
if (isStock())
- return maStockName == ref.maStockName;
+ return maStockName == ref.maStockName && m_nScalePercentage == ref.m_nScalePercentage;
else
return maBitmapEx == ref.maBitmapEx;
}
-BitmapEx const & ImplImage::getBitmapExForHiDPI(bool bDisabled)
+void ImplImage::setScalePercentage(sal_Int32 nScale)
{
- if (isStock())
- { // check we have the right bitmap cached.
- // FIXME: DPI scaling should be tied to the outdev really ...
- double fScale = comphelper::LibreOfficeKit::getDPIScale();
- Size aTarget(maSizePixel.Width()*fScale,
- maSizePixel.Height()*fScale);
- if (maBitmapEx.GetSizePixel() != aTarget)
- loadStockAtScale(fScale, maBitmapEx);
- }
- return getBitmapEx(bDisabled);
+ assert(nScale > 0);
+ if (m_nScalePercentage == nScale || !isStock())
+ return;
+ SAL_WARN_IF(!maBitmapEx.IsEmpty(), "vcl", "image scale changed after loading(" << m_nScalePercentage << "% >> " << nScale << "%); invalidaing image!");
+ m_nScalePercentage = nScale;
+ maBitmapEx.SetEmpty();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx
index 827df39a32bc..85e4bf24b1a9 100644
--- a/vcl/source/image/ImplImageTree.cxx
+++ b/vcl/source/image/ImplImageTree.cxx
@@ -74,9 +74,14 @@ sal_Int32 ImageRequestParameters::scalePercentage()
{
sal_Int32 aScalePercentage = 100;
if (!(meFlags & ImageLoadFlags::IgnoreScalingFactor))
- aScalePercentage = Application::GetDefaultDevice()->GetDPIScalePercentage();
- else if (mnScalePercentage > 0)
- aScalePercentage = mnScalePercentage;
+ {
+ if (mnScalePercentage <= 0)
+ SAL_WARN("vcl", "icon requested without percentage!");
+ if (mnScalePercentage > 0)
+ aScalePercentage = mnScalePercentage;
+ else
+ aScalePercentage = Application::GetDefaultDevice()->GetDPIScalePercentage();
+ }
return aScalePercentage;
}
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 53a9f774b71d..2a91066f494d 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -190,7 +190,7 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const
{
assert(mpGraphics);
- if ( nWidth > 0 && nHeight > 0 && nX <= (mnOutWidth + mnOutOffX) && nY <= (mnOutHeight + mnOutOffY))
+ if ( nWidth > 0 && nHeight > 0 && nX <= (m_nWidth + mnOutOffX) && nY <= (m_nHeight + mnOutOffY))
{
tools::Rectangle aRect( Point( nX, nY ), Size( nWidth, nHeight ) );
bool bClipped = false;
@@ -212,16 +212,16 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const
}
// Width outside of draw area?
- if ( (nWidth + nX) > (mnOutWidth + mnOutOffX) )
+ if ( (nWidth + nX) > (m_nWidth + mnOutOffX) )
{
- nWidth = mnOutOffX + mnOutWidth - nX;
+ nWidth = mnOutOffX + m_nWidth - nX;
bClipped = true;
}
// Height outside of draw area?
- if ( (nHeight + nY) > (mnOutHeight + mnOutOffY) )
+ if ( (nHeight + nY) > (m_nHeight + mnOutOffY) )
{
- nHeight = mnOutOffY + mnOutHeight - nY;
+ nHeight = mnOutOffY + m_nHeight - nY;
bClipped = true;
}
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index 0d9248d2fd77..775ff1525bbb 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -74,11 +74,6 @@ OutputDevice::OutputDevice(OutDevType eOutDevType) :
mpExtOutDevData = nullptr;
mnOutOffX = 0;
mnOutOffY = 0;
- mnOutWidth = 0;
- mnOutHeight = 0;
- mnDPIX = 0;
- mnDPIY = 0;
- mnDPIScalePercentage = 100;
mnTextOffX = 0;
mnTextOffY = 0;
mnOutOffOrigX = 0;
@@ -385,16 +380,6 @@ void OutputDevice::SetDrawMode(DrawModeFlags nDrawMode)
mpAlphaVDev->SetDrawMode(nDrawMode);
}
-sal_uInt16 OutputDevice::GetBitCount() const
-{
- // we need a graphics instance
- if ( !mpGraphics && !AcquireGraphics() )
- return 0;
- assert(mpGraphics);
-
- return mpGraphics->GetBitCount();
-}
-
void OutputDevice::SetOutOffXPixel(tools::Long nOutOffX)
{
mnOutOffX = nOutOffX;
@@ -686,17 +671,17 @@ bool OutputDevice::ImplIsAntiparallel() const
void OutputDevice::ReMirror( Point &rPoint ) const
{
- rPoint.setX( mnOutOffX + mnOutWidth - 1 - rPoint.X() + mnOutOffX );
+ rPoint.setX( mnOutOffX + m_nWidth - 1 - rPoint.X() + mnOutOffX );
}
void OutputDevice::ReMirror( tools::Rectangle &rRect ) const
{
tools::Long nWidth = rRect.Right() - rRect.Left();
//long lc_x = rRect.nLeft - mnOutOffX; // normalize
- //lc_x = mnOutWidth - nWidth - 1 - lc_x; // mirror
+ //lc_x = m_nWidth - nWidth - 1 - lc_x; // mirror
//rRect.nLeft = lc_x + mnOutOffX; // re-normalize
- rRect.SetLeft( mnOutOffX + mnOutWidth - nWidth - 1 - rRect.Left() + mnOutOffX );
+ rRect.SetLeft(mnOutOffX + m_nWidth - nWidth - 1 - rRect.Left() + mnOutOffX);
rRect.SetRight( rRect.Left() + nWidth );
}
@@ -794,7 +779,7 @@ com::sun::star::uno::Reference< css::rendering::XCanvas > OutputDevice::ImplGetC
*/
Sequence< Any > aArg{
Any(reinterpret_cast<sal_Int64>(this)),
- Any(css::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight )),
+ Any(css::awt::Rectangle(mnOutOffX, mnOutOffY, m_nWidth, m_nHeight)),
Any(false),
Any(Reference< css::awt::XWindow >()),
GetSystemGfxDataAny()
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 840341502beb..f93d2ba85e7f 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -307,15 +307,15 @@ void OutputDevice::ImplDrawTextDirect( SalLayout& rSalLayout,
auto nOldX = rSalLayout.DrawBase().getX();
if( HasMirroredGraphics() )
{
- tools::Long w = IsVirtual() ? mnOutWidth : mpGraphics->GetGraphicsWidth();
+ tools::Long w = IsVirtual() ? m_nWidth : mpGraphics->GetGraphicsWidth();
auto x = rSalLayout.DrawBase().getX();
rSalLayout.DrawBase().setX( w - 1 - x );
if( !IsRTLEnabled() )
{
OutputDevice *pOutDevRef = this;
// mirror this window back
- tools::Long devX = w-pOutDevRef->mnOutWidth-pOutDevRef->mnOutOffX; // re-mirrored mnOutOffX
- rSalLayout.DrawBase().setX( devX + ( pOutDevRef->mnOutWidth - 1 - (rSalLayout.DrawBase().getX() - devX) ) ) ;
+ tools::Long devX = w - pOutDevRef->m_nWidth - pOutDevRef->mnOutOffX; // re-mirrored mnOutOffX
+ rSalLayout.DrawBase().setX( devX + ( pOutDevRef->m_nWidth - 1 - (rSalLayout.DrawBase().getX() - devX) ) ) ;
}
}
else if( IsRTLEnabled() )
@@ -324,7 +324,7 @@ void OutputDevice::ImplDrawTextDirect( SalLayout& rSalLayout,
// mirror this window back
tools::Long devX = pOutDevRef->mnOutOffX; // re-mirrored mnOutOffX
- rSalLayout.DrawBase().setX( pOutDevRef->mnOutWidth - 1 - (rSalLayout.DrawBase().getX() - devX) + devX );
+ rSalLayout.DrawBase().setX( pOutDevRef->m_nWidth - 1 - (rSalLayout.DrawBase().getX() - devX) + devX );
}
rSalLayout.DrawText( *mpGraphics );
diff --git a/vcl/source/outdev/wallpaper.cxx b/vcl/source/outdev/wallpaper.cxx
index 2cd655c0e80a..6f0c024e38ba 100644
--- a/vcl/source/outdev/wallpaper.cxx
+++ b/vcl/source/outdev/wallpaper.cxx
@@ -103,7 +103,7 @@ void OutputDevice::Erase()
RasterOp eRasterOp = GetRasterOp();
if ( eRasterOp != RasterOp::OverPaint )
SetRasterOp( RasterOp::OverPaint );
- DrawWallpaper( 0, 0, mnOutWidth, mnOutHeight, maBackground );
+ DrawWallpaper(0, 0, m_nWidth, m_nHeight, maBackground);
if ( eRasterOp != RasterOp::OverPaint )
SetRasterOp( eRasterOp );
}
diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx
index 2f85ddbd39d6..a1e56de83a9c 100644
--- a/vcl/source/window/mouse.cxx
+++ b/vcl/source/window/mouse.cxx
@@ -145,8 +145,8 @@ void Window::ImplCallMouseMove( sal_uInt16 nMouseCode, bool bModChanged )
bool bLeave;
// check for MouseLeave
bLeave = ((nX < 0) || (nY < 0) ||
- (nX >= mpWindowImpl->mpFrameWindow->GetOutDev()->mnOutWidth) ||
- (nY >= mpWindowImpl->mpFrameWindow->GetOutDev()->mnOutHeight)) &&
+ (nX >= mpWindowImpl->mpFrameWindow->GetOutDev()->m_nWidth) ||
+ (nY >= mpWindowImpl->mpFrameWindow->GetOutDev()->m_nHeight)) &&
!ImplGetSVData()->mpWinData->mpCaptureWin;
nMode |= MouseEventModifiers::SYNTHETIC;
if ( bModChanged )
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index 40172ade6a9e..74173828d99f 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -1142,7 +1142,7 @@ vcl::Region Window::GetPaintRegion() const
void Window::Invalidate( InvalidateFlags nFlags )
{
- if ( !comphelper::LibreOfficeKit::isActive() && (!GetOutDev()->IsDeviceOutputNecessary() || !GetOutDev()->mnOutWidth || !GetOutDev()->mnOutHeight) )
+ if ( !comphelper::LibreOfficeKit::isActive() && (!GetOutDev()->IsDeviceOutputNecessary() || !GetOutDev()->m_nWidth || !GetOutDev()->m_nHeight) )
return;
ImplInvalidate( nullptr, nFlags );
@@ -1151,7 +1151,7 @@ void Window::Invalidate( InvalidateFlags nFlags )
void Window::Invalidate( const tools::Rectangle& rRect, InvalidateFlags nFlags )
{
- if ( !comphelper::LibreOfficeKit::isActive() && (!GetOutDev()->IsDeviceOutputNecessary() || !GetOutDev()->mnOutWidth || !GetOutDev()->mnOutHeight) )
+ if ( !comphelper::LibreOfficeKit::isActive() && (!GetOutDev()->IsDeviceOutputNecessary() || !GetOutDev()->m_nWidth || !GetOutDev()->m_nHeight) )
return;
OutputDevice *pOutDev = GetOutDev();
@@ -1167,7 +1167,7 @@ void Window::Invalidate( const tools::Rectangle& rRect, InvalidateFlags nFlags )
void Window::Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags )
{
- if ( !comphelper::LibreOfficeKit::isActive() && (!GetOutDev()->IsDeviceOutputNecessary() || !GetOutDev()->mnOutWidth || !GetOutDev()->mnOutHeight) )
+ if ( !comphelper::LibreOfficeKit::isActive() && (!GetOutDev()->IsDeviceOutputNecessary() || !GetOutDev()->m_nWidth || !GetOutDev()->m_nHeight) )
return;
if ( rRegion.IsNull() )
@@ -1232,7 +1232,7 @@ void Window::PixelInvalidate(const tools::Rectangle* pRectangle)
void Window::Validate()
{
- if ( !comphelper::LibreOfficeKit::isActive() && (!GetOutDev()->IsDeviceOutputNecessary() || !GetOutDev()->mnOutWidth || !GetOutDev()->mnOutHeight) )
+ if ( !comphelper::LibreOfficeKit::isActive() && (!GetOutDev()->IsDeviceOutputNecessary() || !GetOutDev()->m_nWidth || !GetOutDev()->m_nHeight) )
return;
ImplValidate();
@@ -1419,7 +1419,7 @@ void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rP
{
tools::Long nDeltaX = pChild->GetOutDev()->mnOutOffX - GetOutDev()->mnOutOffX;
if( bHasMirroredGraphics )
- nDeltaX = GetOutDev()->mnOutWidth - nDeltaX - pChild->GetOutDev()->mnOutWidth;
+ nDeltaX = GetOutDev()->m_nWidth - nDeltaX - pChild->GetOutDev()->m_nWidth;
tools::Long nDeltaY = pChild->GetOutOffYPixel() - GetOutOffYPixel();
@@ -1540,7 +1540,7 @@ void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rP
tools::Long nDeltaX = pChild->GetOutDev()->mnOutOffX - GetOutDev()->mnOutOffX;
if( pOutDev->HasMirroredGraphics() )
- nDeltaX = GetOutDev()->mnOutWidth - nDeltaX - pChild->GetOutDev()->mnOutWidth;
+ nDeltaX = GetOutDev()->m_nWidth - nDeltaX - pChild->GetOutDev()->m_nWidth;
tools::Long nDeltaY = pChild->GetOutOffYPixel() - GetOutOffYPixel();
Point aPos( i_rPos );
Point aDelta( nDeltaX, nDeltaY );
@@ -1624,7 +1624,7 @@ void Window::Erase(vcl::RenderContext& rRenderContext)
RasterOp eRasterOp = GetOutDev()->GetRasterOp();
if (eRasterOp != RasterOp::OverPaint)
GetOutDev()->SetRasterOp(RasterOp::OverPaint);
- rRenderContext.DrawWallpaper(0, 0, GetOutDev()->mnOutWidth, GetOutDev()->mnOutHeight, GetOutDev()->maBackground);
+ rRenderContext.DrawWallpaper(0, 0, GetOutDev()->m_nWidth, GetOutDev()->m_nHeight, GetOutDev()->maBackground);
if (eRasterOp != RasterOp::OverPaint)
rRenderContext.SetRasterOp(eRasterOp);
}
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 180aa4a78dd2..4726fcc375bb 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -532,7 +532,7 @@ void Window::dispose()
}
if (mpWindowImpl->mpFrame) // otherwise exception during init
{
- mpWindowImpl->mpFrame->SetCallback( nullptr, nullptr );
+ mpWindowImpl->mpFrame->SetCallback(nullptr);
pSVData->mpDefInst->DestroyFrame( mpWindowImpl->mpFrame );
}
assert (mpWindowImpl->mpFrameData->mnFocusId == nullptr);
@@ -809,8 +809,6 @@ ImplFrameData::ImplFrameData( vcl::Window *pWindow )
mbInternalDragGestureRecognizer = false;
mbDragging = false;
mbInBufferedPaint = false;
- mnDPIX = 96;
- mnDPIY = 96;
mnTouchPanPosition = -1;
}
@@ -1050,9 +1048,9 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
pParentFrame = pParent->mpWindowImpl->mpFrame;
SalFrame* pFrame;
if ( pSystemParentData )
- pFrame = pSVData->mpDefInst->CreateChildFrame( pSystemParentData, nFrameStyle | SalFrameStyleFlags::PLUG );
+ pFrame = pSVData->mpDefInst->CreateChildFrame(pSystemParentData, nFrameStyle | SalFrameStyleFlags::PLUG, *this);
else
- pFrame = pSVData->mpDefInst->CreateFrame( pParentFrame, nFrameStyle );
+ pFrame = pSVData->mpDefInst->CreateFrame(pParentFrame, nFrameStyle, *this);
if ( !pFrame )
{
// do not abort but throw an exception, may be the current thread terminates anyway (plugin-scenario)
@@ -1061,7 +1059,7 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
Reference< XInterface >() );
}
- pFrame->SetCallback( this, ImplWindowFrameProc );
+ pFrame->SetCallback(ImplWindowFrameProc);
// set window frame data
mpWindowImpl->mpFrameData = new ImplFrameData( this );
@@ -1090,15 +1088,16 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
{
if ( pParent )
{
- mpWindowImpl->mpFrameData->mnDPIX = pParent->mpWindowImpl->mpFrameData->mnDPIX;
- mpWindowImpl->mpFrameData->mnDPIY = pParent->mpWindowImpl->mpFrameData->mnDPIY;
+ GetOutDev()->mnDPIX = pParent->mpWindowImpl->mpFrame->GetDPIX();
+ GetOutDev()->mnDPIY = pParent->mpWindowImpl->mpFrame->GetDPIY();
}
else
{
OutputDevice *pOutDev = GetOutDev();
if ( pOutDev->AcquireGraphics() )
{
- mpWindowImpl->mxOutDev->mpGraphics->GetResolution( mpWindowImpl->mpFrameData->mnDPIX, mpWindowImpl->mpFrameData->mnDPIY );
+ GetOutDev()->mnDPIX = mpWindowImpl->mpFrame->GetDPIX();
+ GetOutDev()->mnDPIY = mpWindowImpl->mpFrame->GetDPIY();
}
}
@@ -1123,7 +1122,7 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
// size directly, because we want resize all Controls to
// the correct size before we display the window
if ( nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_APP) )
- mpWindowImpl->mpFrame->GetClientSize( mpWindowImpl->mxOutDev->mnOutWidth, mpWindowImpl->mxOutDev->mnOutHeight );
+ mpWindowImpl->mpFrame->GetClientSize(GetOutDev()->m_nWidth, GetOutDev()->m_nHeight);
}
else
{
@@ -1147,9 +1146,11 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
}
// setup the scale factor for HiDPI displays
- mpWindowImpl->mxOutDev->mnDPIScalePercentage = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
- mpWindowImpl->mxOutDev->mnDPIX = mpWindowImpl->mpFrameData->mnDPIX;
- mpWindowImpl->mxOutDev->mnDPIY = mpWindowImpl->mpFrameData->mnDPIY;
+#if 0
+ mpWindowImpl->mxOutDev->mnDPIScalePercentage = CountDPIScaleFactor(GetOutDev()->mnDPIY);
+ GetOutDev()->mnDPIX = mnDPIX;
+ mpWindowImpl->mxOutDev->mnDPIY = GetOutDev()->mnDPIY;
+#endif
if (!utl::ConfigManager::IsFuzzing())
{
@@ -1349,19 +1350,17 @@ void Window::ImplInitResolutionSettings()
// recalculate AppFont-resolution and DPI-resolution
if (mpWindowImpl->mbFrame)
{
- GetOutDev()->mnDPIX = mpWindowImpl->mpFrameData->mnDPIX;
- GetOutDev()->mnDPIY = mpWindowImpl->mpFrameData->mnDPIY;
-
// setup the scale factor for HiDPI displays
- GetOutDev()->mnDPIScalePercentage = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
+ GetOutDev()->mnDPIScalePercentage = CountDPIScaleFactor(GetOutDev()->mnDPIY);
const StyleSettings& rStyleSettings = GetOutDev()->mxSettings->GetStyleSettings();
SetPointFont(*GetOutDev(), rStyleSettings.GetAppFont());
}
else if ( mpWindowImpl->mpParent )
{
- GetOutDev()->mnDPIX = mpWindowImpl->mpParent->GetOutDev()->mnDPIX;
- GetOutDev()->mnDPIY = mpWindowImpl->mpParent->GetOutDev()->mnDPIY;
- GetOutDev()->mnDPIScalePercentage = mpWindowImpl->mpParent->GetOutDev()->mnDPIScalePercentage;
+ OutputDevice *pParentOutDev = mpWindowImpl->mpParent->GetOutDev();
+ GetOutDev()->mnDPIX = pParentOutDev->mnDPIX;
+ GetOutDev()->mnDPIY = pParentOutDev->mnDPIY;
+ GetOutDev()->mnDPIScalePercentage = pParentOutDev->mnDPIScalePercentage;
}
// update the recalculated values for logical units
@@ -1380,11 +1379,11 @@ void Window::ImplPointToLogic(vcl::RenderContext const & rRenderContext, vcl::Fo
if (aSize.Width())
{
- aSize.setWidth( aSize.Width() * ( mpWindowImpl->mpFrameData->mnDPIX) );
+ aSize.setWidth( aSize.Width() * ( GetOutDev()->mnDPIX) );
aSize.AdjustWidth(72 / 2 );
aSize.setWidth( aSize.Width() / 72 );
}
- aSize.setHeight( aSize.Height() * ( mpWindowImpl->mpFrameData->mnDPIY) );
+ aSize.setHeight( aSize.Height() * ( GetOutDev()->mnDPIY) );
aSize.AdjustHeight(72/2 );
aSize.setHeight( aSize.Height() / 72 );
@@ -1404,12 +1403,12 @@ void Window::ImplLogicToPoint(vcl::RenderContext const & rRenderContext, vcl::Fo
if (aSize.Width())
{
aSize.setWidth( aSize.Width() * 72 );
- aSize.AdjustWidth(mpWindowImpl->mpFrameData->mnDPIX / 2 );
- aSize.setWidth( aSize.Width() / ( mpWindowImpl->mpFrameData->mnDPIX) );
+ aSize.AdjustWidth(GetOutDev()->mnDPIX / 2 );
+ aSize.setWidth( aSize.Width() / ( GetOutDev()->mnDPIX) );
}
aSize.setHeight( aSize.Height() * 72 );
- aSize.AdjustHeight(mpWindowImpl->mpFrameData->mnDPIY / 2 );
- aSize.setHeight( aSize.Height() / ( mpWindowImpl->mpFrameData->mnDPIY) );
+ aSize.AdjustHeight(GetOutDev()->mnDPIY / 2 );
+ aSize.setHeight( aSize.Height() / ( GetOutDev()->mnDPIY) );
rFont.SetFontSize(aSize);
}
@@ -1448,7 +1447,7 @@ bool Window::ImplUpdatePos()
void Window::ImplUpdateSysObjPos()
{
if ( mpWindowImpl->mpSysObj )
- mpWindowImpl->mpSysObj->SetPosSize( GetOutDev()->mnOutOffX, GetOutDev()->mnOutOffY, GetOutDev()->mnOutWidth, GetOutDev()->mnOutHeight );
+ mpWindowImpl->mpSysObj->SetPosSize( GetOutDev()->mnOutOffX, GetOutDev()->mnOutOffY, GetOutDev()->m_nWidth, GetOutDev()->m_nHeight );
VclPtr< vcl::Window > pChild = mpWindowImpl->mpFirstChild;
while ( pChild )
@@ -1466,8 +1465,8 @@ void Window::ImplPosSizeWindow( tools::Long nX, tools::Long nY,
bool bCopyBits = false;
tools::Long nOldOutOffX = GetOutDev()->mnOutOffX;
tools::Long nOldOutOffY = GetOutDev()->mnOutOffY;
- tools::Long nOldOutWidth = GetOutDev()->mnOutWidth;
- tools::Long nOldOutHeight = GetOutDev()->mnOutHeight;
+ tools::Long nOldOutWidth = GetOutDev()->m_nWidth;
+ tools::Long nOldOutHeight = GetOutDev()->m_nHeight;
std::unique_ptr<vcl::Region> pOverlapRegion;
std::unique_ptr<vcl::Region> pOldRegion;
@@ -1479,7 +1478,7 @@ void Window::ImplPosSizeWindow( tools::Long nX, tools::Long nY,
if ( mpWindowImpl->mbWinRegion )
pOldRegion->Intersect( GetOutDev()->ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
- if ( GetOutDev()->mnOutWidth && GetOutDev()->mnOutHeight && !mpWindowImpl->mbPaintTransparent &&
+ if ( GetOutDev()->m_nWidth && GetOutDev()->m_nHeight && !mpWindowImpl->mbPaintTransparent &&
!mpWindowImpl->mbInitWinClipRegion && !mpWindowImpl->maWinClipRegion.IsEmpty() &&
!HasPaintEvent() )
bCopyBits = true;
@@ -1497,9 +1496,9 @@ void Window::ImplPosSizeWindow( tools::Long nX, tools::Long nY,
if ( nWidth < 0 )
nWidth = 0;
- if ( nWidth != GetOutDev()->mnOutWidth )
+ if ( nWidth != GetOutDev()->m_nWidth )
{
- GetOutDev()->mnOutWidth = nWidth;
+ GetOutDev()->m_nWidth = nWidth;
bNewSize = true;
bCopyBits = false;
}
@@ -1508,9 +1507,9 @@ void Window::ImplPosSizeWindow( tools::Long nX, tools::Long nY,
{
if ( nHeight < 0 )
nHeight = 0;
- if ( nHeight != GetOutDev()->mnOutHeight )
+ if ( nHeight != GetOutDev()->m_nHeight )
{
- GetOutDev()->mnOutHeight = nHeight;
+ GetOutDev()->m_nHeight = nHeight;
bNewSize = true;
bCopyBits = false;
}
@@ -1530,7 +1529,7 @@ void Window::ImplPosSizeWindow( tools::Long nX, tools::Long nY,
// RTL: check if parent is in different coordinates
if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->GetOutDev()->ImplIsAntiparallel() )
{
- nX = mpWindowImpl->mpParent->GetOutDev()->mnOutWidth - GetOutDev()->mnOutWidth - nX;
+ nX = mpWindowImpl->mpParent->GetOutDev()->m_nWidth - GetOutDev()->m_nWidth - nX;
}
/* #i99166# An LTR window in RTL UI that gets sized only would be
expected to not moved its upper left point
@@ -1547,7 +1546,7 @@ void Window::ImplPosSizeWindow( tools::Long nX, tools::Long nY,
else if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->GetOutDev()->ImplIsAntiparallel() )
{
// mirrored window in LTR UI
- nX = mpWindowImpl->mpParent->GetOutDev()->mnOutWidth - GetOutDev()->mnOutWidth - nX;
+ nX = mpWindowImpl->mpParent->GetOutDev()->m_nWidth - GetOutDev()->m_nWidth - nX;
}
// check maPos as well, as it could have been changed for client windows (ImplCallMove())
@@ -1597,8 +1596,8 @@ void Window::ImplPosSizeWindow( tools::Long nX, tools::Long nY,
{
mpWindowImpl->mpClientWindow->ImplPosSizeWindow( mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder,
mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder,
- GetOutDev()->mnOutWidth - mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnRightBorder,
- GetOutDev()->mnOutHeight - mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnBottomBorder,
+ GetOutDev()->m_nWidth - mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnRightBorder,
+ GetOutDev()->m_nHeight - mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnBottomBorder,
PosSizeFlags::X | PosSizeFlags::Y |
PosSizeFlags::Width | PosSizeFlags::Height );
// If we have a client window, then this is the position
@@ -1648,7 +1647,7 @@ void Window::ImplPosSizeWindow( tools::Long nX, tools::Long nY,
}
// invalidate window content ?
- if ( bNewPos || (GetOutDev()->mnOutWidth > nOldOutWidth) || (GetOutDev()->mnOutHeight > nOldOutHeight) )
+ if ( bNewPos || (GetOutDev()->m_nWidth > nOldOutWidth) || (GetOutDev()->m_nHeight > nOldOutHeight) )
{
if ( bNewPos )
{
@@ -1720,7 +1719,7 @@ void Window::ImplPosSizeWindow( tools::Long nX, tools::Long nY,
// invalidate Parent or Overlaps
if ( bNewPos ||
- (GetOutDev()->mnOutWidth < nOldOutWidth) || (GetOutDev()->mnOutHeight < nOldOutHeight) )
+ (GetOutDev()->m_nWidth < nOldOutWidth) || (GetOutDev()->m_nHeight < nOldOutHeight) )
{
vcl::Region aRegion( *pOldRegion );
if ( !mpWindowImpl->mbPaintTransparent )
@@ -1737,7 +1736,7 @@ void Window::ImplPosSizeWindow( tools::Long nX, tools::Long nY,
if ( bUpdateSysObjPos )
ImplUpdateSysObjPos();
if ( bNewSize && mpWindowImpl->mpSysObj )
- mpWindowImpl->mpSysObj->SetPosSize( GetOutDev()->mnOutOffX, GetOutDev()->mnOutOffY, GetOutDev()->mnOutWidth, GetOutDev()->mnOutHeight );
+ mpWindowImpl->mpSysObj->SetPosSize( GetOutDev()->mnOutOffX, GetOutDev()->mnOutOffY, GetOutDev()->m_nWidth, GetOutDev()->m_nHeight );
}
void Window::ImplNewInputContext()
@@ -2370,8 +2369,7 @@ void Window::Show(bool bVisible, ShowFlags nFlags)
// a system resize
if ( mpWindowImpl->mbWaitSystemResize )
{
- tools::Long nOutWidth;
- tools::Long nOutHeight;
+ sal_Int32 nOutWidth, nOutHeight;
mpWindowImpl->mpFrame->GetClientSize( nOutWidth, nOutHeight );
ImplHandleResize( this, nOutWidth, nOutHeight );
}
@@ -2420,8 +2418,8 @@ Size Window::GetSizePixel() const
return Size(0,0);
}
- return Size( GetOutDev()->mnOutWidth + mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder,
- GetOutDev()->mnOutHeight + mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder );
+ return Size( GetOutDev()->m_nWidth + mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder,
+ GetOutDev()->m_nHeight + mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder );
}
void Window::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
@@ -2686,12 +2684,12 @@ void Window::setPosSizePixel( tools::Long nX, tools::Long nY,
// Note: if we're positioning a frame, the coordinates are interpreted
// as being the top-left corner of the window's client area and NOT
// as the position of the border ! (due to limitations of several UNIX window managers)
- tools::Long nOldWidth = pWindow->GetOutDev()->mnOutWidth;
+ tools::Long nOldWidth = pWindow->GetOutDev()->m_nWidth;
if ( !(nFlags & PosSizeFlags::Width) )
- nWidth = pWindow->GetOutDev()->mnOutWidth;
+ nWidth = pWindow->GetOutDev()->m_nWidth;
if ( !(nFlags & PosSizeFlags::Height) )
- nHeight = pWindow->GetOutDev()->mnOutHeight;
+ nHeight = pWindow->GetOutDev()->m_nHeight;
sal_uInt16 nSysFlags=0;
VclPtr<vcl::Window> pParent = GetParent();
@@ -2719,7 +2717,7 @@ void Window::setPosSizePixel( tools::Long nX, tools::Long nY,
}
if( !comphelper::LibreOfficeKit::isActive() &&
!(nFlags & PosSizeFlags::X) && bHasValidSize &&
- pWindow->mpWindowImpl->mpFrame->maGeometry.nWidth )
+ pWindow->mpWindowImpl->mpFrame->GetWidth())
{
// RTL: make sure the old right aligned position is not changed
// system windows will always grow to the right
@@ -2733,12 +2731,12 @@ void Window::setPosSizePixel( tools::Long nX, tools::Long nY,
pWinParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry();
tools::Long myWidth = nOldWidth;
if( !myWidth )
- myWidth = aSysGeometry.nWidth;
+ myWidth = mpWindowImpl->mpFrame->GetWidth();
if( !myWidth )
myWidth = nWidth;
nFlags |= PosSizeFlags::X;
nSysFlags |= SAL_FRAME_POSSIZE_X;
- nX = aParentSysGeometry.nX - aSysGeometry.nLeftDecoration + aParentSysGeometry.nWidth
+ nX = aParentSysGeometry.nX - aSysGeometry.nLeftDecoration + pWinParent->mpWindowImpl->mpFrame->GetWidth()
- myWidth - 1 - aSysGeometry.nX;
}
}
@@ -2778,13 +2776,14 @@ void Window::setPosSizePixel( tools::Long nX, tools::Long nY,
// Adjust resize with the hack of different client size and frame geometries to fix
// native menu bars. Eventually this should be replaced by proper mnTopBorder usage.
- pWindow->mpWindowImpl->mpFrame->GetClientSize(nWidth, nHeight);
+ sal_Int32 nNewWidth, nNewHeight;
+ pWindow->mpWindowImpl->mpFrame->GetClientSize(nNewWidth, nNewHeight);
// Resize should be called directly. If we haven't
// set the correct size, we get a second resize from
// the system with the correct size. This can be happened
// if the size is too small or too large.
- ImplHandleResize( pWindow, nWidth, nHeight );
+ ImplHandleResize(pWindow, nNewWidth, nNewHeight);
}
else
{
@@ -2830,7 +2829,7 @@ tools::Long Window::ImplGetUnmirroredOutOffX()
if ( !ImplIsOverlapWindow() )
offx -= mpWindowImpl->mpParent->GetOutDev()->mnOutOffX;
- offx = mpWindowImpl->mpParent->GetOutDev()->mnOutWidth - GetOutDev()->mnOutWidth - offx;
+ offx = mpWindowImpl->mpParent->GetOutDev()->m_nWidth - GetOutDev()->m_nWidth - offx;
if ( !ImplIsOverlapWindow() )
offx += mpWindowImpl->mpParent->GetOutDev()->mnOutOffX;
@@ -3719,7 +3718,7 @@ Reference< css::rendering::XCanvas > WindowOutputDevice::ImplGetCanvas( bool bSp
// common: first any is VCL pointer to window (for VCL canvas)
Sequence< Any > aArg{
Any(reinterpret_cast<sal_Int64>(this)),
- Any(css::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight )),
+ Any(css::awt::Rectangle( mnOutOffX, mnOutOffY, m_nWidth, m_nHeight )),
Any(mxOwnerWindow->mpWindowImpl->mbAlwaysOnTop),
Any(Reference< css::awt::XWindow >(
mxOwnerWindow->GetComponentInterface(),
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index 1e6d42ddcbff..d58f66293410 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -1854,7 +1854,7 @@ static void KillOwnPopups( vcl::Window const * pWindow )
}
}
-void ImplHandleResize( vcl::Window* pWindow, tools::Long nNewWidth, tools::Long nNewHeight )
+void ImplHandleResize(vcl::Window* pWindow, sal_Int32 nNewWidth, sal_Int32 nNewHeight)
{
const bool bChanged = (nNewWidth != pWindow->GetOutputSizePixel().Width()) || (nNewHeight != pWindow->GetOutDev()->GetOutputHeightPixel());
if (bChanged && pWindow->GetStyle() & (WB_MOVEABLE|WB_SIZEABLE))
@@ -1871,8 +1871,8 @@ void ImplHandleResize( vcl::Window* pWindow, tools::Long nNewWidth, tools::Long
{
if (bChanged)
{
- pWindow->GetOutDev()->mnOutWidth = nNewWidth;
- pWindow->GetOutDev()->mnOutHeight = nNewHeight;
+ pWindow->GetOutDev()->m_nWidth = nNewWidth;
+ pWindow->GetOutDev()->m_nHeight = nNewHeight;
pWindow->ImplGetWindowImpl()->mbWaitSystemResize = false;
if ( pWindow->IsReallyVisible() )
pWindow->ImplSetClipFlag();
@@ -2739,8 +2739,7 @@ bool ImplWindowFrameProc( vcl::Window* _pWindow, SalEvent nEvent, const void* pE
case SalEvent::Resize:
{
- tools::Long nNewWidth;
- tools::Long nNewHeight;
+ sal_Int32 nNewWidth, nNewHeight;
pWindow->ImplGetWindowImpl()->mpFrame->GetClientSize( nNewWidth, nNewHeight );
ImplHandleResize( pWindow, nNewWidth, nNewHeight );
}
diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx
index 502f4c7f7ec2..733429c388ee 100644
--- a/vcl/unx/generic/app/salinst.cxx
+++ b/vcl/unx/generic/app/salinst.cxx
@@ -198,16 +198,16 @@ OUString X11SalInstance::GetConnectionIdentifier()
return pDisplay ? OUString::createFromAscii(pDisplay) : OUString();
}
-SalFrame *X11SalInstance::CreateFrame( SalFrame *pParent, SalFrameStyleFlags nSalFrameStyle )
+SalFrame *X11SalInstance::CreateFrame(SalFrame *pParent, SalFrameStyleFlags nSalFrameStyle, vcl::Window& rWin)
{
- SalFrame *pFrame = new X11SalFrame( pParent, nSalFrameStyle );
+ SalFrame *pFrame = new X11SalFrame(pParent, nSalFrameStyle, nullptr, rWin);
return pFrame;
}
-SalFrame* X11SalInstance::CreateChildFrame( SystemParentData* pParentData, SalFrameStyleFlags nStyle )
+SalFrame* X11SalInstance::CreateChildFrame( SystemParentData* pParentData, SalFrameStyleFlags nStyle, vcl::Window& rWin)
{
- SalFrame* pFrame = new X11SalFrame( nullptr, nStyle, pParentData );
+ SalFrame* pFrame = new X11SalFrame(nullptr, nStyle, pParentData, rWin);
return pFrame;
}
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index d6eecfecb1e8..6d5ad674d3bf 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -317,49 +317,12 @@ bool X11SalGraphics::GetDitherPixmap( Color nColor )
return true;
}
-void X11SalGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) // const
+sal_Int32 X11SalGraphics::GetSgpMetric(vcl::SGPmetric eMetric) const
{
- char* pForceDpi;
- if ((pForceDpi = getenv("SAL_FORCEDPI")))
- {
- OString sForceDPI(pForceDpi);
- rDPIX = rDPIY = sForceDPI.toInt32();
- return;
- }
-
- const SalDisplay *pDisplay = GetDisplay();
- if (!pDisplay)
- {
- SAL_WARN( "vcl", "Null display");
- rDPIX = rDPIY = 96;
- return;
- }
-
- Pair dpi = pDisplay->GetResolution();
- rDPIX = dpi.A();
- rDPIY = dpi.B();
-
- if ( rDPIY > 200 )
- {
- rDPIX = Divide( rDPIX * 200, rDPIY );
- rDPIY = 200;
- }
-
- // #i12705# equalize x- and y-resolution if they are close enough
- if( rDPIX == rDPIY )
- return;
-
- // different x- and y- resolutions are usually artifacts of
- // a wrongly calculated screen size.
-#ifdef DEBUG
- SAL_INFO("vcl.gdi", "Forcing Resolution from "
- << std::hex << rDPIX
- << std::dec << rDPIX
- << " to "
- << std::hex << rDPIY
- << std::dec << rDPIY);
-#endif
- rDPIX = rDPIY; // y-resolution is more trustworthy
+ if (bVirDev_)
+ return m_pVDev->GetSgpMetric(eMetric);
+ else
+ return m_pFrame->GetSgpMetric(eMetric);
}
XRenderPictFormat* X11SalGraphics::GetXRenderFormat() const
@@ -461,12 +424,12 @@ css::uno::Any X11SalGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rS
#endif // ENABLE_CAIRO_CANVAS
-SalGeometryProvider *X11SalGraphics::GetGeometryProvider() const
+vcl::SalGeometryProvider *X11SalGraphics::GetGeometryProvider() const
{
if (m_pFrame)
- return static_cast< SalGeometryProvider * >(m_pFrame);
+ return static_cast<vcl::SalGeometryProvider*>(m_pFrame);
else
- return static_cast< SalGeometryProvider * >(m_pVDev);
+ return static_cast<vcl::SalGeometryProvider*>(m_pVDev);
}
cairo_t* X11SalGraphics::getCairoContext()
diff --git a/vcl/unx/generic/gdi/salvd.cxx b/vcl/unx/generic/gdi/salvd.cxx
index f5e4449c625d..e00e955c779e 100644
--- a/vcl/unx/generic/gdi/salvd.cxx
+++ b/vcl/unx/generic/gdi/salvd.cxx
@@ -35,7 +35,7 @@
#endif
std::unique_ptr<SalVirtualDevice> X11SalInstance::CreateX11VirtualDevice(const SalGraphics& rGraphics,
- tools::Long &nDX, tools::Long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData,
+ sal_Int32 &nDX, sal_Int32 &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData,
std::unique_ptr<X11SalGraphics> pNewGraphics)
{
assert(pNewGraphics);
@@ -48,7 +48,7 @@ std::unique_ptr<SalVirtualDevice> X11SalInstance::CreateX11VirtualDevice(const S
}
std::unique_ptr<SalVirtualDevice> X11SalInstance::CreateVirtualDevice(SalGraphics& rGraphics,
- tools::Long &nDX, tools::Long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData)
+ sal_Int32 &nDX, sal_Int32 &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData)
{
return CreateX11VirtualDevice(rGraphics, nDX, nDY, eFormat, pData, std::make_unique<X11SalGraphics>());
}
@@ -86,7 +86,7 @@ void X11SalGraphics::Init( X11SalVirtualDevice *pDevice, cairo_surface_t* pPreEx
mxImpl->Init();
}
-X11SalVirtualDevice::X11SalVirtualDevice(const SalGraphics& rGraphics, tools::Long &nDX, tools::Long &nDY,
+X11SalVirtualDevice::X11SalVirtualDevice(const SalGraphics& rGraphics, sal_Int32 &nDX, sal_Int32 &nDY,
DeviceFormat /*eFormat*/, const SystemGraphicsData *pData,
std::unique_ptr<X11SalGraphics> pNewGraphics) :
pGraphics_(std::move(pNewGraphics)),
@@ -181,13 +181,12 @@ SalGraphics* X11SalVirtualDevice::AcquireGraphics()
void X11SalVirtualDevice::ReleaseGraphics( SalGraphics* )
{ bGraphics_ = false; }
-bool X11SalVirtualDevice::SetSize( tools::Long nDX, tools::Long nDY )
+bool X11SalVirtualDevice::SetSizeUsingBuffer(sal_Int32 nDX, sal_Int32 nDY, sal_uInt8*, sal_Int32 nScale)
{
if( bExternPixmap_ )
return false;
- if( !nDX ) nDX = 1;
- if( !nDY ) nDY = 1;
+ FixSetSizeParams(nDX, nDY, nScale);
Pixmap h = limitXCreatePixmap( GetXDisplay(),
pDisplay_->GetDrawable( m_nXScreen ),
@@ -219,4 +218,25 @@ bool X11SalVirtualDevice::SetSize( tools::Long nDX, tools::Long nDY )
return true;
}
+sal_Int32 X11SalVirtualDevice::GetSgpMetric(vcl::SGPmetric eMetric) const
+{
+ switch (eMetric)
+ {
+ case vcl::SGPmetric::Width: return nDX_;
+ case vcl::SGPmetric::Height: return nDY_;
+ case vcl::SGPmetric::DPIX: return 96;
+ case vcl::SGPmetric::DPIY: return 96;
+ case vcl::SGPmetric::ScalePercentage: return 100;
+ case vcl::SGPmetric::OffScreen: return true;
+ case vcl::SGPmetric::BitCount: return nDepth_;
+ default:
+ return -1;
+ }
+}
+
+void X11SalVirtualDevice::SetScalePercentage(sal_Int32)
+{
+}
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx
index b84ba0befc4c..022db0da9bdb 100644
--- a/vcl/unx/generic/print/genprnpsp.cxx
+++ b/vcl/unx/generic/print/genprnpsp.cxx
@@ -664,7 +664,7 @@ bool PspSalInfoPrinter::SetData(
void PspSalInfoPrinter::GetPageInfo(
const ImplJobSetup* pJobSetup,
- tools::Long& rOutWidth, tools::Long& rOutHeight,
+ sal_Int32& rOutWidth, sal_Int32& rOutHeight,
Point& rPageOffset,
Size& rPaperSize )
{
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 3e30cb74fce7..2dc660c8a661 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -77,14 +77,16 @@ GenPspGraphics::~GenPspGraphics()
ReleaseFonts();
}
-void GenPspGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY )
+sal_Int32 GenPspGraphics::GetSgpMetric(vcl::SGPmetric eMetric) const
{
- if (m_pJobData != nullptr)
+ assert(m_pJobData);
+ switch (eMetric)
{
- int x = m_pJobData->m_aContext.getRenderResolution();
-
- rDPIX = x;
- rDPIY = x;
+ case vcl::SGPmetric::DPIX: return m_pJobData->m_aContext.getRenderResolution();
+ case vcl::SGPmetric::DPIY: return m_pJobData->m_aContext.getRenderResolution();
+ case vcl::SGPmetric::OffScreen: return true;
+ default:
+ return -1;
}
}
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 8c2d67c70565..6998412e0156 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -41,6 +41,7 @@
#include <unx/saldisp.hxx>
#include <unx/salgdi.h>
#include <unx/salframe.h>
+#include <unx/salunx.h>
#include <unx/wmadaptor.hxx>
#include <unx/salbmp.h>
#include <unx/i18n_ic.hxx>
@@ -790,7 +791,8 @@ void X11SalFrame::Init( SalFrameStyleFlags nSalFrameStyle, SalX11Screen nXScreen
}
X11SalFrame::X11SalFrame( SalFrame *pParent, SalFrameStyleFlags nSalFrameStyle,
- SystemParentData const * pSystemParent ) :
+ SystemParentData const * pSystemParent, vcl::Window& rWin)
+ : SalFrame(rWin),
m_nXScreen( 0 ),
maAlwaysOnTopRaiseTimer( "vcl::X11SalFrame maAlwaysOnTopRaiseTimer" )
{
@@ -1152,6 +1154,8 @@ void X11SalFrame::Show( bool bVisible, bool bNoActivate )
|| ( !bVisible && !bMapped_ ) )
return;
+ SAL_DEBUG(__func__ << " " << bVisible);
+
// HACK: this is a workaround for (at least) kwin
// even though transient frames should be kept above their parent
// this does not necessarily hold true for DOCK type windows
@@ -1407,7 +1411,52 @@ void X11SalFrame::GetWorkArea( tools::Rectangle& rWorkArea )
rWorkArea = pDisplay_->getWMAdaptor()->getWorkArea( 0 );
}
-void X11SalFrame::GetClientSize( tools::Long &rWidth, tools::Long &rHeight )
+void X11SalFrame::GetDPI(sal_Int32 &rDPIX, sal_Int32 &rDPIY)
+{
+ char* pForceDpi;
+ if ((pForceDpi = getenv("SAL_FORCEDPI")))
+ {
+ OString sForceDPI(pForceDpi);
+ rDPIX = rDPIY = sForceDPI.toInt32();
+ return;
+ }
+
+ const SalDisplay *pDisplay = GetDisplay();
+ if (!pDisplay)
+ {
+ SAL_WARN( "vcl", "Null display");
+ rDPIX = rDPIY = 96;
+ return;
+ }
+
+ Pair dpi = pDisplay->GetResolution();
+ rDPIX = dpi.A();
+ rDPIY = dpi.B();
+
+ if ( rDPIY > 200 )
+ {
+ rDPIX = Divide( rDPIX * 200, rDPIY );
+ rDPIY = 200;
+ }
+
+ // #i12705# equalize x- and y-resolution if they are close enough
+ if( rDPIX == rDPIY )
+ return;
+
+ // different x- and y- resolutions are usually artifacts of
+ // a wrongly calculated screen size.
+#ifdef DEBUG
+ SAL_INFO("vcl.gdi", "Forcing Resolution from "
+ << std::hex << rDPIX
+ << std::dec << rDPIX
+ << " to "
+ << std::hex << rDPIY
+ << std::dec << rDPIY);
+#endif
+ rDPIX = rDPIY; // y-resolution is more trustworthy
+}
+
+void X11SalFrame::GetClientSize(sal_Int32 &rWidth, sal_Int32 &rHeight)
{
if( ! bViewable_ )
{
@@ -3697,7 +3746,7 @@ bool X11SalFrame::HandleReparentEvent( XReparentEvent *pEvent )
*/
maGeometry.nX = xp + nLeft;
maGeometry.nY = yp + nTop;
- bResized = w != maGeometry.nWidth || h != maGeometry.nHeight;
+ bResized = w != o3tl::make_unsigned(maGeometry.nWidth) || h != o3tl::make_unsigned(maGeometry.nHeight);
maGeometry.nWidth = w;
maGeometry.nHeight = h;
}
@@ -4089,4 +4138,54 @@ void X11SalFrame::EndSetClipRegion()
}
+sal_Int32 X11SalFrame::GetDPI() const
+{
+ char* pForceDpi;
+ if ((pForceDpi = getenv("SAL_FORCEDPI")))
+ {
+ OString sForceDPI(pForceDpi);
+ return sForceDPI.toInt32();
+ }
+
+ const SalDisplay *pDisplay = GetDisplay();
+ if (!pDisplay)
+ {
+ SAL_WARN( "vcl", "Null display");
+ return 96;
+ }
+
+ Pair dpi = pDisplay->GetResolution();
+ sal_Int32 rDPIX = dpi.A();
+ sal_Int32 rDPIY = dpi.B();
+
+ if (rDPIY > 200)
+ {
+ rDPIX = Divide(rDPIX * 200, rDPIY);
+ rDPIY = 200;
+ }
+
+ // different x- and y- resolutions are usually artifacts of
+ // a wrongly calculated screen size.
+#ifdef DEBUG
+ SAL_INFO("vcl.gdi", "Forcing Resolution from "
+ << std::hex << rDPIX
+ << std::dec << rDPIX
+ << " to "
+ << std::hex << rDPIY
+ << std::dec << rDPIY);
+#endif
+ return rDPIY; // y-resolution is more trustworthy
+}
+
+sal_Int32 X11SalFrame::GetSgpMetric(vcl::SGPmetric eMetric) const
+{
+ switch (eMetric) {
+ case vcl::SGPmetric::DPIX:
+ case vcl::SGPmetric::DPIY:
+ return GetDPI();
+ default:
+ return SalFrame::GetWindow()->GetOutDev()->GetSgpMetric(eMetric);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index 0a2ad6dc0df3..b0740c17dd35 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -467,8 +467,9 @@ bool GtkSalFrame::doKeyCallback( guint state,
return bStopProcessingKey;
}
-GtkSalFrame::GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
- : m_nXScreen( getDisplay()->GetDefaultXScreen() )
+GtkSalFrame::GtkSalFrame(SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin)
+ : SalFrame(rWin)
+ , m_nXScreen(getDisplay()->GetDefaultXScreen())
, m_pHeaderBar(nullptr)
, m_bGraphics(false)
, m_nSetFocusSignalId(0)
@@ -482,8 +483,9 @@ GtkSalFrame::GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
Init( pParent, nStyle );
}
-GtkSalFrame::GtkSalFrame( SystemParentData* pSysData )
- : m_nXScreen( getDisplay()->GetDefaultXScreen() )
+GtkSalFrame::GtkSalFrame(SystemParentData* pSysData, vcl::Window& rWin)
+ : SalFrame(rWin)
+ , m_nXScreen(getDisplay()->GetDefaultXScreen())
, m_pHeaderBar(nullptr)
, m_bGraphics(false)
, m_nSetFocusSignalId(0)
@@ -1466,7 +1468,7 @@ SalGraphics* GtkSalFrame::AcquireGraphics()
AllocateFrame();
TriggerPaintEvent();
}
- m_pGraphics->setSurface(m_pSurface, m_aFrameSize);
+ m_pGraphics->setSurface(m_pSurface);
}
m_bGraphics = true;
return m_pGraphics.get();
@@ -1760,9 +1762,9 @@ void GtkSalFrame::SetMinClientSize( tools::Long nWidth, tools::Long nHeight )
void GtkSalFrame::AllocateFrame()
{
- basegfx::B2IVector aFrameSize( maGeometry.nWidth, maGeometry.nHeight );
- if (m_pSurface && m_aFrameSize.getX() == aFrameSize.getX() &&
- m_aFrameSize.getY() == aFrameSize.getY() )
+ basegfx::B2IVector aFrameSize(GetWidth(), GetHeight());
+ if (m_pSurface && cairo_image_surface_get_width(m_pSurface) == aFrameSize.getX() &&
+ cairo_image_surface_get_height(m_pSurface) == aFrameSize.getY())
return;
if( aFrameSize.getX() == 0 )
@@ -1777,13 +1779,12 @@ void GtkSalFrame::AllocateFrame()
CAIRO_CONTENT_COLOR_ALPHA,
aFrameSize.getX(),
aFrameSize.getY());
- m_aFrameSize = aFrameSize;
cairo_surface_set_user_data(m_pSurface, SvpSalGraphics::getDamageKey(), &m_aDamageHandler, nullptr);
SAL_INFO("vcl.gtk3", "allocated Frame size of " << maGeometry.nWidth << " x " << maGeometry.nHeight);
if (m_pGraphics)
- m_pGraphics->setSurface(m_pSurface, m_aFrameSize);
+ m_pGraphics->setSurface(m_pSurface);
}
void GtkSalFrame::SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags )
@@ -1845,12 +1846,36 @@ void GtkSalFrame::SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth
m_bDefaultPos = false;
}
-void GtkSalFrame::GetClientSize( tools::Long& rWidth, tools::Long& rHeight )
+void GtkSalFrame::GetDPI(sal_Int32& rDPIX, sal_Int32& rDPIY)
+{
+ char* pForceDpi;
+ if ((pForceDpi = getenv("SAL_FORCEDPI")))
+ {
+ OString sForceDPI(pForceDpi);
+ rDPIX = rDPIY = sForceDPI.toInt32();
+ return;
+ }
+
+#if !GTK_CHECK_VERSION(4, 0, 0)
+ GdkScreen* pScreen = gtk_widget_get_screen(m_pWindow);
+ double fResolution = -1.0;
+ g_object_get(pScreen, "resolution", &fResolution, nullptr);
+
+ if (fResolution > 0.0)
+ rDPIX = rDPIY = sal_Int32(fResolution);
+ else
+ rDPIX = rDPIY = 96;
+#else
+ rDPIX = rDPIY = 96;
+#endif
+}
+
+void GtkSalFrame::GetClientSize(sal_Int32& rWidth, sal_Int32& rHeight)
{
if( m_pWindow && !(m_nState & GDK_TOPLEVEL_STATE_MINIMIZED) )
{
- rWidth = maGeometry.nWidth;
- rHeight = maGeometry.nHeight;
+ rWidth = GetWidth();
+ rHeight = GetHeight();
}
else
rWidth = rHeight = 0;
@@ -6014,4 +6039,9 @@ GdkEvent* GtkSalFrame::makeFakeKeyPress(GtkWidget* pWidget)
#endif
}
+sal_Int32 GtkSalFrame::GetSgpMetric(vcl::SGPmetric eMetric) const
+{
+ return GetWindow()->GetOutDev()->GetSgpMetric(eMetric);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index ca8c893d3915..a70e1a88c063 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -261,16 +261,16 @@ GtkInstance::~GtkInstance()
ResetLastSeenCairoFontOptions(nullptr);
}
-SalFrame* GtkInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
+SalFrame* GtkInstance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin)
{
EnsureInit();
- return new GtkSalFrame( pParent, nStyle );
+ return new GtkSalFrame(pParent, nStyle, rWin);
}
-SalFrame* GtkInstance::CreateChildFrame( SystemParentData* pParentData, SalFrameStyleFlags )
+SalFrame* GtkInstance::CreateChildFrame(SystemParentData* pParentData, SalFrameStyleFlags, vcl::Window& rWin)
{
EnsureInit();
- return new GtkSalFrame( pParentData );
+ return new GtkSalFrame(pParentData, rWin);
}
SalObject* GtkInstance::CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow )
@@ -373,7 +373,7 @@ void GtkYieldMutex::ThreadsLeave()
}
std::unique_ptr<SalVirtualDevice> GtkInstance::CreateVirtualDevice( SalGraphics &rG,
- tools::Long &nDX, tools::Long &nDY,
+ sal_Int32 &nDX, sal_Int32 &nDY,
DeviceFormat /*eFormat*/,
const SystemGraphicsData* pGd )
{
diff --git a/vcl/unx/gtk3/salnativewidgets-gtk.cxx b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
index df40af50ef6b..ec94bee4245a 100644
--- a/vcl/unx/gtk3/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
@@ -3026,28 +3026,36 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
#endif
}
-void GtkSalGraphics::GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY)
+sal_Int32 GtkSalGraphics::GetSgpMetric(vcl::SGPmetric eMetric) const
{
- char* pForceDpi;
- if ((pForceDpi = getenv("SAL_FORCEDPI")))
+ switch (eMetric)
{
- OString sForceDPI(pForceDpi);
- rDPIX = rDPIY = sForceDPI.toInt32();
- return;
- }
+ case vcl::SGPmetric::DPIX:
+ case vcl::SGPmetric::DPIY:
+ {
+ char* pForceDpi;
+ if ((pForceDpi = getenv("SAL_FORCEDPI")))
+ {
+ OString sForceDPI(pForceDpi);
+ return sForceDPI.toInt32();
+ }
#if !GTK_CHECK_VERSION(4, 0, 0)
- GdkScreen* pScreen = gtk_widget_get_screen(mpWindow);
- double fResolution = -1.0;
- g_object_get(pScreen, "resolution", &fResolution, nullptr);
+ GdkScreen* pScreen = gtk_widget_get_screen(mpWindow);
+ double fResolution = -1.0;
+ g_object_get(pScreen, "resolution", &fResolution, nullptr);
- if (fResolution > 0.0)
- rDPIX = rDPIY = sal_Int32(fResolution);
- else
- rDPIX = rDPIY = 96;
+ if (fResolution > 0.0)
+ return sal_Int32(fResolution);
+ else
+ return 96;
#else
- rDPIX = rDPIY = 96;
+ return 96;
#endif
+ }
+ default:
+ return SvpSalGraphics::GetSgpMetric(eMetric);
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/KF5SalFrame.cxx b/vcl/unx/kf5/KF5SalFrame.cxx
index f33011837470..d0c47060da27 100644
--- a/vcl/unx/kf5/KF5SalFrame.cxx
+++ b/vcl/unx/kf5/KF5SalFrame.cxx
@@ -43,8 +43,8 @@
#include <optional>
-KF5SalFrame::KF5SalFrame(KF5SalFrame* pParent, SalFrameStyleFlags nState, bool bUseCairo)
- : QtFrame(pParent, nState, bUseCairo)
+KF5SalFrame::KF5SalFrame(KF5SalFrame* pParent, SalFrameStyleFlags nState, vcl::Window& rWin, bool bUseCairo)
+ : QtFrame(pParent, nState, rWin, bUseCairo)
{
}
diff --git a/vcl/unx/kf5/KF5SalFrame.hxx b/vcl/unx/kf5/KF5SalFrame.hxx
index d7c82c375a9d..84dc749fead5 100644
--- a/vcl/unx/kf5/KF5SalFrame.hxx
+++ b/vcl/unx/kf5/KF5SalFrame.hxx
@@ -29,7 +29,7 @@ class QWidget;
class KF5SalFrame : public QtFrame
{
public:
- KF5SalFrame(KF5SalFrame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo);
+ KF5SalFrame(KF5SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin, bool bUseCairo);
virtual void UpdateSettings(AllSettings& rSettings) override;
};
diff --git a/vcl/unx/kf5/KF5SalInstance.cxx b/vcl/unx/kf5/KF5SalInstance.cxx
index 1a7fce697a0b..c521fa79ca3e 100644
--- a/vcl/unx/kf5/KF5SalInstance.cxx
+++ b/vcl/unx/kf5/KF5SalInstance.cxx
@@ -40,21 +40,21 @@ KF5SalInstance::KF5SalInstance(std::unique_ptr<QApplication>& pQApp, bool bUseCa
pSVData->maAppData.mxToolkitName = constructToolkitID(u"kf5");
}
-SalFrame* KF5SalInstance::CreateChildFrame(SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle)
+SalFrame* KF5SalInstance::CreateChildFrame(SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle, vcl::Window& rWin)
{
SalFrame* pRet(nullptr);
- RunInMainThread([&, this]() { pRet = new KF5SalFrame(nullptr, nStyle, useCairo()); });
+ RunInMainThread([&, this]() { pRet = new KF5SalFrame(nullptr, nStyle, rWin, useCairo()); });
assert(pRet);
return pRet;
}
-SalFrame* KF5SalInstance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle)
+SalFrame* KF5SalInstance::CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin)
{
assert(!pParent || dynamic_cast<KF5SalFrame*>(pParent));
SalFrame* pRet(nullptr);
RunInMainThread([&, this]() {
- pRet = new KF5SalFrame(static_cast<KF5SalFrame*>(pParent), nStyle, useCairo());
+ pRet = new KF5SalFrame(static_cast<KF5SalFrame*>(pParent), nStyle, rWin, useCairo());
});
assert(pRet);
return pRet;
diff --git a/vcl/unx/kf5/KF5SalInstance.hxx b/vcl/unx/kf5/KF5SalInstance.hxx
index add3b112af98..f4612418df36 100644
--- a/vcl/unx/kf5/KF5SalInstance.hxx
+++ b/vcl/unx/kf5/KF5SalInstance.hxx
@@ -28,8 +28,8 @@ class KF5SalInstance final : public QtInstance
createPicker(css::uno::Reference<css::uno::XComponentContext> const& context,
QFileDialog::FileMode) override;
- SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override;
- SalFrame* CreateChildFrame(SystemParentData* pParent, SalFrameStyleFlags nStyle) override;
+ SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle, vcl::Window&) override;
+ SalFrame* CreateChildFrame(SystemParentData* pParent, SalFrameStyleFlags nStyle, vcl::Window& rWin) override;
public:
explicit KF5SalInstance(std::unique_ptr<QApplication>& pQApp, bool bUseCairo);