summaryrefslogtreecommitdiff
path: root/vcl/inc/qt5
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2022-05-28 23:47:21 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2022-06-21 17:26:06 +0200
commitafc828b9833b7a612369e95606ba56d41ef2c369 (patch)
treeb60ec391ff6f93f85eb4f88d756c2f70b79b674c /vcl/inc/qt5
parentdbaf5f6fad2ec10f69cf46f9cb697b8760c2a01f (diff)
VCL expect correct frame size for native menubars
... and renove the wrong framesize hack in the Qt backend This wastes a few additional pixels in the frame backing store, actually covered by the real native menu bar, to get rid of all the hacks and eventually fix quite a bunch of bugs in Qt (and maybe other backends). This seems to work correct with Qt using either QPainter or Cairo as the painting backend. It's much simpler then my previous failed attempts to fix the Qt related bugs. I would like to convert every implementation to my interpretation of the API (at least I now documented the API). It looks like Win and Mac will just work, because Win has no native menu bar and Mac uses a global menu, so always returns the size of 0. And Gtk also seems to work, if it also lies about the menu bar size being zero. That just seems consequent, if the frame size is reduced by the menubar size. This fixes at least: tdf#64438 - Dockable panels in LibreOffice not dockable using KDE Works. tdf#130893 - XWindow::SetPosSize resizing based on XWindow::GetPosSize shrinks the window The document macro from tdf#130841 now doesn't resize the window. This is just fixed for Qt. tdf#134704 - KDE5 - unable to dock sidebar by dragging frame not fixed, because the sidebar window is now a dialog, which is not dockable. FWIW the same has happend the Navigator (F5), which also renders it non-dockable. No idea, if this is intentional. tdf#137471 - CMIS dialog advances beyond lower right corner of the screen So commit 3f8d3fd4649ef09e86c735617383a4bda0425540 ("tdf#137471 Qt return frame pos + client area size") was really not enought as a fix (at least it didn't break anything). The whole parent-based repositioning is wrong and it really depends on the correct frame size, so I'm keeping this as fixed by this patch. Change-Id: I7faeace61b456c2b0f42c7a826f58018b70d46ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135082 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/inc/qt5')
-rw-r--r--vcl/inc/qt5/QtFrame.hxx3
-rw-r--r--vcl/inc/qt5/QtMenu.hxx6
-rw-r--r--vcl/inc/qt5/QtPainter.hxx18
-rw-r--r--vcl/inc/qt5/QtTools.hxx5
4 files changed, 15 insertions, 17 deletions
diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index 963572ca819b..40954f66d744 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -131,7 +131,6 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public SalFrame
bool isMinimized() const;
bool isMaximized() const;
void SetWindowStateImpl(Qt::WindowStates eState);
- int menuBarOffset() const;
void fixICCCMwindowGroup();
@@ -146,6 +145,8 @@ public:
QtMainWindow* GetTopLevelWindow() const { return m_pTopLevel; }
QWidget* asChild() const;
qreal devicePixelRatioF() const;
+ QPoint mapToParent(const QPoint&) const;
+ QPoint mapFromParent(const QPoint&) const;
void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 nExtentsWidth,
sal_Int32 nExtentsHeight) const;
diff --git a/vcl/inc/qt5/QtMenu.hxx b/vcl/inc/qt5/QtMenu.hxx
index a1b77687ce86..6bb0dbcab4ec 100644
--- a/vcl/inc/qt5/QtMenu.hxx
+++ b/vcl/inc/qt5/QtMenu.hxx
@@ -69,14 +69,15 @@ private:
public:
QtMenu(bool bMenuBar);
- virtual bool VisibleMenuBar() override; // must return TRUE to actually DISPLAY native menu bars
+ virtual bool HasNativeMenuBar() override;
+ virtual int GetMenuBarHeight() const override;
+ virtual void ShowMenuBar(bool bVisible) override;
virtual void InsertItem(SalMenuItem* pSalMenuItem, unsigned nPos) override;
virtual void RemoveItem(unsigned nPos) override;
virtual void SetSubMenu(SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos) override;
virtual void SetFrame(const SalFrame* pFrame) override;
const QtFrame* GetFrame() const;
- virtual void ShowMenuBar(bool bVisible) override;
virtual bool ShowNativePopupMenu(FloatingWindow* pWin, const tools::Rectangle& rRect,
FloatWinPopupFlags nFlags) override;
QtMenu* GetTopLevel();
@@ -95,7 +96,6 @@ public:
virtual bool AddMenuBarButton(const SalMenuButtonItem&) override;
virtual void RemoveMenuBarButton(sal_uInt16 nId) override;
virtual tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId, SalFrame*) override;
- virtual int GetMenuBarHeight() const override;
void SetMenu(Menu* pMenu) { mpVCLMenu = pMenu; }
Menu* GetMenu() { return mpVCLMenu; }
diff --git a/vcl/inc/qt5/QtPainter.hxx b/vcl/inc/qt5/QtPainter.hxx
index 9702a19bdbe4..755a51f606ef 100644
--- a/vcl/inc/qt5/QtPainter.hxx
+++ b/vcl/inc/qt5/QtPainter.hxx
@@ -34,34 +34,26 @@ class QtPainter final : public QPainter
public:
QtPainter(QtGraphicsBackend& rGraphics, bool bPrepareBrush = false,
sal_uInt8 nTransparency = 255);
- ~QtPainter()
- {
- if (m_rGraphics.m_pFrame && !m_aRegion.isEmpty())
- m_rGraphics.m_pFrame->GetQWidget()->update(m_aRegion);
- }
+ ~QtPainter();
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 += QRect(nx, ny, nw, nh);
}
void update(const QRect& rRect)
{
if (m_rGraphics.m_pFrame)
- m_aRegion += scaledQRect(rRect, 1 / m_rGraphics.devicePixelRatioF());
+ m_aRegion += rRect;
}
- void update(const QRectF& rRectF)
- {
- if (m_rGraphics.m_pFrame)
- update(scaledQRect(rRectF.toAlignedRect(), 1 / m_rGraphics.devicePixelRatioF()));
- }
+ void update(const QRectF& rRectF) { update(rRectF.toAlignedRect()); }
void update()
{
if (m_rGraphics.m_pFrame)
- m_aRegion += m_rGraphics.m_pFrame->GetQWidget()->rect();
+ m_aRegion += m_rGraphics.m_pFrame->GetQWidget()->geometry();
}
};
diff --git a/vcl/inc/qt5/QtTools.hxx b/vcl/inc/qt5/QtTools.hxx
index 534fe74de772..669b5bef6df0 100644
--- a/vcl/inc/qt5/QtTools.hxx
+++ b/vcl/inc/qt5/QtTools.hxx
@@ -69,6 +69,11 @@ inline QRect scaledQRect(const QRect& rRect, const qreal fScale)
ceil(rRect.height() * fScale));
}
+inline QSize scaledQSize(const QSize& rSize, const qreal fScale)
+{
+ return QSize(ceil(rSize.width() * fScale), ceil(rSize.height() * fScale));
+}
+
inline tools::Rectangle toRectangle(const QRect& rRect)
{
return tools::Rectangle(rRect.left(), rRect.top(), rRect.right(), rRect.bottom());