diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-07-20 08:19:52 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-08-02 08:13:15 +0200 |
commit | b6b26421a1029b18b48b69dbdac4bb70fb622604 (patch) | |
tree | 97b9ab25fef28063a3de4e3a67544d2ea13a70e0 /vcl/inc | |
parent | d66ffef8558785f19908c8e526211b8225fa9125 (diff) |
split Point/Size/Rectangle into AbsoluteScreenPixel* types
to attempt to make it obvious in code what kind of coordinate
system we are dealing with.
The idea is that by doing this, the compile-time type checking
will flush out inconsistencies between different code.
I started with vcl::Window::OutputToAbsoluteScreenPixel
and worked outwards from there.
Change-Id: Ia967d7a0bb38886695f3a761b85c8b9340ddb1c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154676
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/android/androidinst.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/headless/svpdummies.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/headless/svpframe.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/osx/salframe.h | 2 | ||||
-rw-r--r-- | vcl/inc/osx/salsys.h | 2 | ||||
-rw-r--r-- | vcl/inc/qt5/QtFrame.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/qt5/QtSystem.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/qt5/QtTools.hxx | 5 | ||||
-rw-r--r-- | vcl/inc/salframe.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/salsys.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/salvtables.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/salwtype.hxx | 6 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkdata.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkframe.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtksys.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/saldisp.hxx | 8 | ||||
-rw-r--r-- | vcl/inc/unx/salframe.h | 8 | ||||
-rw-r--r-- | vcl/inc/unx/wmadaptor.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/unx/x11/x11sys.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/win/salframe.h | 2 | ||||
-rw-r--r-- | vcl/inc/win/salsys.h | 6 |
21 files changed, 37 insertions, 33 deletions
diff --git a/vcl/inc/android/androidinst.hxx b/vcl/inc/android/androidinst.hxx index 771eb4b1ed81..58ebdbb2531a 100644 --- a/vcl/inc/android/androidinst.hxx +++ b/vcl/inc/android/androidinst.hxx @@ -36,7 +36,7 @@ public: virtual SalSystem* CreateSalSystem(); // frame management - void GetWorkArea(tools::Rectangle& rRect); + void GetWorkArea(AbsoluteScreenPixelRectangle& rRect); SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle); SalFrame* CreateChildFrame(SystemParentData* pParent, SalFrameStyleFlags nStyle); diff --git a/vcl/inc/headless/svpdummies.hxx b/vcl/inc/headless/svpdummies.hxx index d3cbc9df957d..92958f8d5529 100644 --- a/vcl/inc/headless/svpdummies.hxx +++ b/vcl/inc/headless/svpdummies.hxx @@ -52,7 +52,7 @@ public: virtual ~SvpSalSystem() override; // get info about the display virtual unsigned int GetDisplayScreenCount() override; - virtual tools::Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override; + virtual AbsoluteScreenPixelRectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override; virtual int ShowNativeDialog( const OUString& rTitle, const OUString& rMessage, diff --git a/vcl/inc/headless/svpframe.hxx b/vcl/inc/headless/svpframe.hxx index 1d8d11926e2f..3789e44745e7 100644 --- a/vcl/inc/headless/svpframe.hxx +++ b/vcl/inc/headless/svpframe.hxx @@ -88,7 +88,7 @@ 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 GetWorkArea( tools::Rectangle& rRect ) override; + virtual void GetWorkArea( AbsoluteScreenPixelRectangle& rRect ) override; virtual SalFrame* GetParent() const override; virtual void SetWindowState(const vcl::WindowData*) override; virtual bool GetWindowState(vcl::WindowData*) override; diff --git a/vcl/inc/osx/salframe.h b/vcl/inc/osx/salframe.h index 87ab09868edd..21a4b963717d 100644 --- a/vcl/inc/osx/salframe.h +++ b/vcl/inc/osx/salframe.h @@ -123,7 +123,7 @@ public: 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 GetWorkArea( tools::Rectangle& rRect ) override; + virtual void GetWorkArea( AbsoluteScreenPixelRectangle& rRect ) override; virtual SalFrame* GetParent() const override; virtual void SetWindowState(const vcl::WindowData*) override; virtual bool GetWindowState(vcl::WindowData*) override; diff --git a/vcl/inc/osx/salsys.h b/vcl/inc/osx/salsys.h index b0bc98578b35..4b8b077088c7 100644 --- a/vcl/inc/osx/salsys.h +++ b/vcl/inc/osx/salsys.h @@ -33,7 +33,7 @@ public: // get info about the display virtual unsigned int GetDisplayScreenCount() override; - virtual tools::Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override; + virtual AbsoluteScreenPixelRectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override; virtual int ShowNativeMessageBox( const OUString& rTitle, const OUString& rMessage) override; diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx index 90195f55a543..02146343e10d 100644 --- a/vcl/inc/qt5/QtFrame.hxx +++ b/vcl/inc/qt5/QtFrame.hxx @@ -175,7 +175,7 @@ public: 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 GetWorkArea(tools::Rectangle& rRect) override; + virtual void GetWorkArea(AbsoluteScreenPixelRectangle& rRect) override; virtual SalFrame* GetParent() const override; virtual void SetModal(bool bModal) override; virtual bool GetModal() const override; diff --git a/vcl/inc/qt5/QtSystem.hxx b/vcl/inc/qt5/QtSystem.hxx index 6992e381c4c4..760520f42a41 100644 --- a/vcl/inc/qt5/QtSystem.hxx +++ b/vcl/inc/qt5/QtSystem.hxx @@ -15,7 +15,8 @@ class QtSystem final : public SalGenericSystem { public: virtual unsigned int GetDisplayScreenCount() override; - virtual tools::Rectangle GetDisplayScreenPosSizePixel(unsigned int nScreen) override; + virtual AbsoluteScreenPixelRectangle + GetDisplayScreenPosSizePixel(unsigned int nScreen) override; virtual int ShowNativeDialog(const OUString& rTitle, const OUString& rMessage, const std::vector<OUString>& rButtons) override; }; diff --git a/vcl/inc/qt5/QtTools.hxx b/vcl/inc/qt5/QtTools.hxx index 9b4239ac826f..9a5d0da00ee4 100644 --- a/vcl/inc/qt5/QtTools.hxx +++ b/vcl/inc/qt5/QtTools.hxx @@ -62,6 +62,11 @@ inline QRect toQRect(const tools::Rectangle& rRect, const qreal fScale) return QRect(floor(rRect.Left() * fScale), floor(rRect.Top() * fScale), ceil(rRect.GetWidth() * fScale), ceil(rRect.GetHeight() * fScale)); } +inline QRect toQRect(const AbsoluteScreenPixelRectangle& rRect, const qreal fScale) +{ + return QRect(floor(rRect.Left() * fScale), floor(rRect.Top() * fScale), + ceil(rRect.GetWidth() * fScale), ceil(rRect.GetHeight() * fScale)); +} inline QRect scaledQRect(const QRect& rRect, const qreal fScale) { diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx index 0c3b170ca239..f25f8de92777 100644 --- a/vcl/inc/salframe.hxx +++ b/vcl/inc/salframe.hxx @@ -158,7 +158,7 @@ public: virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) = 0; static OUString DumpSetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags); virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) = 0; - virtual void GetWorkArea( tools::Rectangle& rRect ) = 0; + virtual void GetWorkArea( AbsoluteScreenPixelRectangle& rRect ) = 0; virtual SalFrame* GetParent() const = 0; // Note: x will be mirrored at parent if UI mirroring is active SalFrameGeometry GetGeometry() const; diff --git a/vcl/inc/salsys.hxx b/vcl/inc/salsys.hxx index a5950441d348..d7cf10edb149 100644 --- a/vcl/inc/salsys.hxx +++ b/vcl/inc/salsys.hxx @@ -55,7 +55,7 @@ public: else position relative to whole display size: size of the screen */ - virtual tools::Rectangle GetDisplayScreenPosSizePixel(unsigned int nScreen) = 0; + virtual AbsoluteScreenPixelRectangle GetDisplayScreenPosSizePixel(unsigned int nScreen) = 0; /* Shows a native message box with the specified title, message and button combination. diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index e0c61a5c15ef..fa4f3550280b 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -478,7 +478,7 @@ public: virtual Point get_position() const override; - virtual tools::Rectangle get_monitor_workarea() const override; + virtual AbsoluteScreenPixelRectangle get_monitor_workarea() const override; virtual void set_centered_on_parent(bool /*bTrackGeometryRequests*/) override; @@ -1330,7 +1330,7 @@ public: virtual a11yrelationset get_accessible_relation_set() override; - virtual Point get_accessible_location_on_screen() override; + virtual AbsoluteScreenPixelPoint get_accessible_location_on_screen() override; virtual void enable_drag_source(rtl::Reference<TransferDataContainer>& rHelper, sal_uInt8 eDNDConstants) override; diff --git a/vcl/inc/salwtype.hxx b/vcl/inc/salwtype.hxx index 9e43d16d4135..fd2b938d3a2c 100644 --- a/vcl/inc/salwtype.hxx +++ b/vcl/inc/salwtype.hxx @@ -23,6 +23,7 @@ #include <i18nlangtag/lang.h> #include <rtl/ref.hxx> #include <rtl/ustring.hxx> +#include <tools/gen.hxx> #include <tools/solar.h> #include <tools/long.hxx> #include <vcl/GestureEventPan.hxx> @@ -222,10 +223,7 @@ struct SalSurroundingTextSelectionChangeEvent struct SalQueryCharPositionEvent { sal_uLong mnCharPos; // The index of character in a composition. - tools::Long mnCursorBoundX; // The cursor bounds corresponding to the character specified by mnCharPos - X - tools::Long mnCursorBoundY; // The cursor bounds corresponding to the character specified by mnCharPos - Y - tools::Long mnCursorBoundWidth; // The cursor bounds corresponding to the character specified by mnCharPos - Width - tools::Long mnCursorBoundHeight; // The cursor bounds corresponding to the character specified by mnCharPos - Height + AbsoluteScreenPixelRectangle maCursorBound; // The cursor bounds corresponding to the character specified by mnCharPos - X bool mbValid; // The data is valid or not. bool mbVertical; // The text is vertical or not. }; diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx index cd03de599887..04c1485963f5 100644 --- a/vcl/inc/unx/gtk/gtkdata.hxx +++ b/vcl/inc/unx/gtk/gtkdata.hxx @@ -337,7 +337,7 @@ public: virtual int CaptureMouse( SalFrame* pFrame ); SalX11Screen GetDefaultXScreen() { return m_pSys->GetDisplayDefaultXScreen(); } - Size GetScreenSize( int nDisplayScreen ); + AbsoluteScreenPixelSize GetScreenSize( int nDisplayScreen ); void startupNotificationCompleted() { m_bStartupCompleted = true; } diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index 62878279d577..be9a6a2dda83 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -534,7 +534,7 @@ 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 GetWorkArea( tools::Rectangle& rRect ) override; + virtual void GetWorkArea( AbsoluteScreenPixelRectangle& rRect ) override; virtual SalFrame* GetParent() const override; virtual void SetWindowState(const vcl::WindowData*) override; virtual bool GetWindowState(vcl::WindowData*) override; diff --git a/vcl/inc/unx/gtk/gtksys.hxx b/vcl/inc/unx/gtk/gtksys.hxx index 31a1bead7bea..d7e5bcaf5aa4 100644 --- a/vcl/inc/unx/gtk/gtksys.hxx +++ b/vcl/inc/unx/gtk/gtksys.hxx @@ -28,7 +28,7 @@ public: virtual unsigned int GetDisplayScreenCount() override; virtual unsigned int GetDisplayBuiltInScreen() override; - virtual tools::Rectangle GetDisplayScreenPosSizePixel (unsigned int nScreen) override; + virtual AbsoluteScreenPixelRectangle GetDisplayScreenPosSizePixel(unsigned int nScreen) override; virtual int ShowNativeDialog (const OUString& rTitle, const OUString& rMessage, const std::vector< OUString >& rButtons) override; diff --git a/vcl/inc/unx/saldisp.hxx b/vcl/inc/unx/saldisp.hxx index 800f6af75bc5..6cdd13b97494 100644 --- a/vcl/inc/unx/saldisp.hxx +++ b/vcl/inc/unx/saldisp.hxx @@ -212,7 +212,7 @@ public: ::Window m_aRoot; ::Window m_aRefWindow; - Size m_aSize; + AbsoluteScreenPixelSize m_aSize; SalVisual m_aVisual; SalColormap m_aColormap; GC m_aMonoGC; @@ -265,7 +265,7 @@ protected: std::unique_ptr<vcl_sal::WMAdaptor> m_pWMAdaptor; bool m_bXinerama; - std::vector< tools::Rectangle > m_aXineramaScreens; + std::vector< AbsoluteScreenPixelRectangle > m_aXineramaScreens; std::vector< int > m_aXineramaScreenIndexMap; std::list<SalObject*> m_aSalObjects; @@ -325,7 +325,7 @@ public: ::Window GetDrawable( SalX11Screen nXScreen ) const { return getDataForScreen( nXScreen ).m_aRefWindow; } Display *GetDisplay() const { return pDisp_; } const SalX11Screen& GetDefaultXScreen() const { return m_nXDefaultScreen; } - const Size& GetScreenSize( SalX11Screen nXScreen ) const { return getDataForScreen( nXScreen ).m_aSize; } + const AbsoluteScreenPixelSize& GetScreenSize( SalX11Screen nXScreen ) const { return getDataForScreen( nXScreen ).m_aSize; } srv_vendor_t GetServerVendor() const { return meServerVendor; } bool IsDisplay() const { return !!pXLib_; } const SalColormap& GetColormap( SalX11Screen nXScreen ) const { return getDataForScreen(nXScreen).m_aColormap; } @@ -341,7 +341,7 @@ public: { mpKbdExtension = pKbdExtension; } ::vcl_sal::WMAdaptor* getWMAdaptor() const { return m_pWMAdaptor.get(); } bool IsXinerama() const { return m_bXinerama; } - const std::vector< tools::Rectangle >& GetXineramaScreens() const { return m_aXineramaScreens; } + const std::vector< AbsoluteScreenPixelRectangle >& GetXineramaScreens() const { return m_aXineramaScreens; } ::Window GetRootWindow( SalX11Screen nXScreen ) const { return getDataForScreen( nXScreen ).m_aRoot; } unsigned int GetXScreenCount() const { return m_aScreens.size(); } diff --git a/vcl/inc/unx/salframe.h b/vcl/inc/unx/salframe.h index c14c3254c489..efd1a9016d1b 100644 --- a/vcl/inc/unx/salframe.h +++ b/vcl/inc/unx/salframe.h @@ -93,7 +93,7 @@ class X11SalFrame final : public SalFrame X11ShowState nShowState_; // show state int nWidth_; // client width int nHeight_; // client height - tools::Rectangle maRestorePosSize; + AbsoluteScreenPixelRectangle maRestorePosSize; SalFrameStyleFlags nStyle_; SalExtStyle mnExtStyle; bool bAlwaysOnTop_; @@ -133,10 +133,10 @@ class X11SalFrame final : public SalFrame bool mPendingSizeEvent; - void GetPosSize( tools::Rectangle &rPosSize ); + void GetPosSize( AbsoluteScreenPixelRectangle &rPosSize ); void SetSize ( const Size &rSize ); void Center(); - void SetPosSize( const tools::Rectangle &rPosSize ); + void SetPosSize( const AbsoluteScreenPixelRectangle &rPosSize ); void Minimize(); void Maximize(); void Restore(); @@ -222,7 +222,7 @@ 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 GetWorkArea( tools::Rectangle& rRect ) override; + virtual void GetWorkArea( AbsoluteScreenPixelRectangle& rRect ) override; virtual SalFrame* GetParent() const override; virtual void SetWindowState(const vcl::WindowData*) override; virtual bool GetWindowState(vcl::WindowData*) override; diff --git a/vcl/inc/unx/wmadaptor.hxx b/vcl/inc/unx/wmadaptor.hxx index e76ba4d36938..c800a2270e27 100644 --- a/vcl/inc/unx/wmadaptor.hxx +++ b/vcl/inc/unx/wmadaptor.hxx @@ -131,7 +131,7 @@ protected: Atom m_aWMAtoms[ NetAtomMax]; int m_nDesktops; bool m_bEqualWorkAreas; - ::std::vector< tools::Rectangle > + ::std::vector< AbsoluteScreenPixelRectangle > m_aWMWorkAreas; bool m_bEnableAlwaysOnTopWorks; bool m_bLegacyPartialFullscreen; @@ -178,7 +178,7 @@ public: /* * gets the specified workarea */ - const tools::Rectangle& getWorkArea( int n ) const + const AbsoluteScreenPixelRectangle& getWorkArea( int n ) const { return m_aWMWorkAreas[n]; } /* diff --git a/vcl/inc/unx/x11/x11sys.hxx b/vcl/inc/unx/x11/x11sys.hxx index 50c30ac10062..4f43d0052e7b 100644 --- a/vcl/inc/unx/x11/x11sys.hxx +++ b/vcl/inc/unx/x11/x11sys.hxx @@ -32,7 +32,7 @@ public: // override pure virtual methods virtual unsigned int GetDisplayScreenCount() override; virtual unsigned int GetDisplayBuiltInScreen() override; - virtual tools::Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override; + virtual AbsoluteScreenPixelRectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override; virtual int ShowNativeDialog( const OUString& rTitle, const OUString& rMessage, const std::vector< OUString >& rButtons ) override; diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h index 564872e65d2c..66da5e3a976f 100644 --- a/vcl/inc/win/salframe.h +++ b/vcl/inc/win/salframe.h @@ -107,7 +107,7 @@ 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 GetWorkArea( tools::Rectangle& rRect ) override; + virtual void GetWorkArea( AbsoluteScreenPixelRectangle& rRect ) override; virtual SalFrame* GetParent() const override; virtual void SetWindowState(const vcl::WindowData*) override; virtual bool GetWindowState(vcl::WindowData*) override; diff --git a/vcl/inc/win/salsys.h b/vcl/inc/win/salsys.h index 03f627b5abb2..cf1a6ecb4419 100644 --- a/vcl/inc/win/salsys.h +++ b/vcl/inc/win/salsys.h @@ -31,11 +31,11 @@ public: struct DisplayMonitor { OUString m_aName; - tools::Rectangle m_aArea; + AbsoluteScreenPixelRectangle m_aArea; DisplayMonitor() {} DisplayMonitor( const OUString& rName, - const tools::Rectangle& rArea ) + const AbsoluteScreenPixelRectangle& rArea ) : m_aName( rName ), m_aArea( rArea ) { @@ -51,7 +51,7 @@ public: virtual unsigned int GetDisplayScreenCount() override; virtual unsigned int GetDisplayBuiltInScreen() override; - virtual tools::Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override; + virtual AbsoluteScreenPixelRectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) override; virtual int ShowNativeMessageBox( const OUString& rTitle, const OUString& rMessage) override; bool initMonitors(); |