office-gobmx/vcl/inc/qt5/QtPainter.hxx
Jan-Marek Glogowski afc828b983 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 3f8d3fd464 ("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>
2022-06-21 17:26:06 +02:00

60 lines
1.8 KiB
C++

/* -*- 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <QtCore/QRectF>
#include <QtGui/QPainter>
#include <QtWidgets/QWidget>
#include "QtFrame.hxx"
#include "QtGraphics.hxx"
class QtPainter final : public QPainter
{
QtGraphicsBackend& m_rGraphics;
QRegion m_aRegion;
public:
QtPainter(QtGraphicsBackend& rGraphics, bool bPrepareBrush = false,
sal_uInt8 nTransparency = 255);
~QtPainter();
void update(int nx, int ny, int nw, int nh)
{
if (m_rGraphics.m_pFrame)
m_aRegion += QRect(nx, ny, nw, nh);
}
void update(const QRect& rRect)
{
if (m_rGraphics.m_pFrame)
m_aRegion += rRect;
}
void update(const QRectF& rRectF) { update(rRectF.toAlignedRect()); }
void update()
{
if (m_rGraphics.m_pFrame)
m_aRegion += m_rGraphics.m_pFrame->GetQWidget()->geometry();
}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */