[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2023-08-14 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtWidget.hxx |2 +
 vcl/qt5/QtWidget.cxx |   55 ++-
 2 files changed, 56 insertions(+), 1 deletion(-)

New commits:
commit efadd5210e56ba67f1b040dff4972fead6a56131
Author: Michael Weghorn 
AuthorDate: Mon Aug 14 08:10:21 2023 +0200
Commit: Michael Weghorn 
CommitDate: Mon Aug 14 10:07:46 2023 +0200

qt: Implement pinch/zoom gesture handling

Subscribe to receive pinch gestures by calling
`QWidget::grabGesture(Qt::PinchGesture)` and
forward that as the corresponding `SalGestureZoomEvent`.

From looking at what values the gtk implementation uses,
`1 + pPinchGesture->totalScaleFactor()` seems to be a
proper choice for the
`SalGestureZoomEvent::mfScaleDelta` value.

With this in place, zooming in and out of a Writer
document with a two-finger zoom gesture works for
me with the Qt-based VCL plugins in Writer on my laptop
that has a touch screen.
(It seems to be a bit more smooth with qt5/kf5 than
with qt6, where doing several zoom gestures after
each other sometimes requires to wait a bit before
doing another gesture in order for that one to be
processed properly.)

Qt documentation for gestures: [1]

Corresponding commit for gtk VCL plugins:

commit f2bd19f6720239db228cd4388be8e928505c51b6
Author: Povilas Kanapickas 
Date:   Thu Aug 25 00:18:30 2022 +0300

vcl: implement touchpad zoom gesture support on gtk backend

[1] https://doc.qt.io/qt-6/gestures-overview.html

Change-Id: I288943d923463fee44314969648e03dca84c483f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155649
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx
index e61357198027..ca0165401e15 100644
--- a/vcl/inc/qt5/QtWidget.hxx
+++ b/vcl/inc/qt5/QtWidget.hxx
@@ -20,6 +20,7 @@
 #pragma once
 
 #include 
+#include 
 #include 
 #include 
 
@@ -45,6 +46,7 @@ class QtWidget : public QWidget
 static void commitText(QtFrame&, const QString& aText);
 static void deleteReplacementText(QtFrame& rFrame, int nReplacementStart,
   int nReplacementLength);
+static bool handleGestureEvent(QtFrame& rFrame, QGestureEvent* 
pGestureEvent);
 static bool handleKeyEvent(QtFrame&, const QWidget&, QKeyEvent*);
 static void handleMouseEnterLeaveEvents(const QtFrame&, QEvent*);
 static void fillSalAbstractMouseEvent(const QtFrame& rFrame, const 
QInputEvent* pQEvent,
diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx
index 83ada7866f2b..5e7d1d56c464 100644
--- a/vcl/qt5/QtWidget.cxx
+++ b/vcl/qt5/QtWidget.cxx
@@ -516,6 +516,52 @@ void QtWidget::deleteReplacementText(QtFrame& rFrame, int 
nReplacementStart, int
 rFrame.CallCallback(SalEvent::DeleteSurroundingTextRequest, );
 }
 
+bool QtWidget::handleGestureEvent(QtFrame& rFrame, QGestureEvent* 
pGestureEvent)
+{
+if (QGesture* pGesture = pGestureEvent->gesture(Qt::PinchGesture))
+{
+if (!pGesture->hasHotSpot())
+{
+pGestureEvent->ignore();
+return false;
+}
+
+GestureEventZoomType eType = GestureEventZoomType::Begin;
+switch (pGesture->state())
+{
+case Qt::GestureStarted:
+eType = GestureEventZoomType::Begin;
+break;
+case Qt::GestureUpdated:
+eType = GestureEventZoomType::Update;
+break;
+case Qt::GestureFinished:
+eType = GestureEventZoomType::End;
+break;
+case Qt::NoGesture:
+case Qt::GestureCanceled:
+default:
+SAL_WARN("vcl.qt", "Unhandled pinch gesture state: " << 
pGesture->state());
+pGestureEvent->ignore();
+return false;
+}
+
+QPinchGesture* pPinchGesture = static_cast(pGesture);
+const QPointF aHotspot = pGesture->hotSpot();
+SalGestureZoomEvent aEvent;
+aEvent.meEventType = eType;
+aEvent.mnX = aHotspot.x();
+aEvent.mnY = aHotspot.y();
+aEvent.mfScaleDelta = 1 + pPinchGesture->totalScaleFactor();
+rFrame.CallCallback(SalEvent::GestureZoom, );
+pGestureEvent->accept();
+return true;
+}
+
+pGestureEvent->ignore();
+return false;
+}
+
 bool QtWidget::handleKeyEvent(QtFrame& rFrame, const QWidget& rWidget, 
QKeyEvent* pEvent)
 {
 const bool bIsKeyPressed
@@ -632,7 +678,12 @@ bool QtWidget::handleKeyEvent(QtFrame& rFrame, const 
QWidget& rWidget, QKeyEvent
 
 bool QtWidget::handleEvent(QtFrame& rFrame, QWidget& rWidget, QEvent* pEvent)
 {
-if (pEvent->type() == QEvent::ShortcutOverride)
+if (pEvent->type() == QEvent::Gesture)
+{
+QGestureEvent* pGestureEvent = static_cast(pEvent);
+return handleGestureEvent(rFrame, 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2023-08-01 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtMenu.hxx |8 
 vcl/qt5/QtMenu.cxx |   48 
 2 files changed, 56 insertions(+)

New commits:
commit 2ef9880f97de6629ddef12eb788123ab4be1ec83
Author: Michael Weghorn 
AuthorDate: Sun Jul 30 01:59:31 2023 +0200
Commit: Michael Weghorn 
CommitDate: Tue Aug 1 08:21:22 2023 +0200

tdf#156376 qt: Open help for focused native menu entry on F1

In order to allow have pressing F1 (`QKeySequence::HelpContents`)
open the corresponding help entry for the currently selected
menu entry, connect to the signal that gets emitted when
a menu entry is selected (`QAction::hovered`) and remember
its help ID. Register the F1 shortcut for the menu
and connect its `activated`/`activatedAmbiguously`
signal with a slot that opens the help for the current/
last selected menu entry.

Change-Id: I24eec4806e5a202052a49c239e4836b92c9f0228
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155055
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtMenu.hxx b/vcl/inc/qt5/QtMenu.hxx
index 3e43272b6212..bd704507f69c 100644
--- a/vcl/inc/qt5/QtMenu.hxx
+++ b/vcl/inc/qt5/QtMenu.hxx
@@ -53,6 +53,9 @@ private:
 QMenu* mpQMenu;
 QButtonGroup* m_pButtonGroup;
 
+// help ID of currently/last selected item
+static OUString m_sCurrentHelpId;
+
 void DoFullMenuUpdate(Menu* pMenuBar);
 static void NativeItemText(OUString& rItemText);
 
@@ -64,6 +67,9 @@ private:
 bool validateQMenuBar() const;
 QPushButton* ImplAddMenuBarButton(const QIcon& rIcon, const QString& 
rToolTip, int nId);
 void ImplRemoveMenuBarButton(int nId);
+void connectHelpShortcut(QMenu* pMenu);
+// set slots that handle signals relevent for help menu
+void connectHelpSignalSlots(QMenu* pMenu, QtMenuItem* pSalMenuItem);
 
 public:
 QtMenu(bool bMenuBar);
@@ -102,6 +108,8 @@ public:
 QtMenuItem* GetItemAtPos(unsigned nPos) { return maItems[nPos]; }
 
 private slots:
+static void slotShowHelp();
+static void slotMenuHovered(QtMenuItem* pItem);
 static void slotMenuTriggered(QtMenuItem* pQItem);
 static void slotMenuAboutToShow(QtMenuItem* pQItem);
 static void slotMenuAboutToHide(QtMenuItem* pQItem);
diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx
index b976fa3f5739..b1e62bc09475 100644
--- a/vcl/qt5/QtMenu.cxx
+++ b/vcl/qt5/QtMenu.cxx
@@ -24,6 +24,11 @@
 #include 
 #include 
 #include 
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+#include 
+#else
+#include 
+#endif
 #include 
 
 #include 
@@ -48,6 +53,8 @@ static inline void lcl_force_menubar_layout_update(QMenuBar& 
rMenuBar)
 rMenuBar.adjustSize();
 }
 
+OUString QtMenu::m_sCurrentHelpId = u"";
+
 QtMenu::QtMenu(bool bMenuBar)
 : mpVCLMenu(nullptr)
 , mpParentSalMenu(nullptr)
@@ -77,6 +84,7 @@ void QtMenu::InsertMenuItem(QtMenuItem* pSalMenuItem, 
unsigned nPos)
 if (validateQMenuBar())
 {
 QMenu* pQMenu = new QMenu(toQString(aText), nullptr);
+connectHelpSignalSlots(pQMenu, pSalMenuItem);
 pSalMenuItem->mpMenu.reset(pQMenu);
 
 if ((nPos != MENU_APPEND)
@@ -108,12 +116,14 @@ void QtMenu::InsertMenuItem(QtMenuItem* pSalMenuItem, 
unsigned nPos)
 // no QMenu set, instantiate own one
 mpOwnedQMenu.reset(new QMenu);
 mpQMenu = mpOwnedQMenu.get();
+connectHelpSignalSlots(mpQMenu, pSalMenuItem);
 }
 
 if (pSalMenuItem->mpSubMenu)
 {
 // submenu
 QMenu* pQMenu = new QMenu(toQString(aText), nullptr);
+connectHelpSignalSlots(pQMenu, pSalMenuItem);
 pSalMenuItem->mpMenu.reset(pQMenu);
 
 if ((nPos != MENU_APPEND)
@@ -183,6 +193,8 @@ void QtMenu::InsertMenuItem(QtMenuItem* pSalMenuItem, 
unsigned nPos)
 
 connect(pAction, ::triggered, this,
 [pSalMenuItem] { slotMenuTriggered(pSalMenuItem); });
+connect(pAction, ::hovered, this,
+[pSalMenuItem] { slotMenuHovered(pSalMenuItem); });
 }
 }
 }
@@ -618,6 +630,22 @@ const QtFrame* QtMenu::GetFrame() const
 return pMenu ? pMenu->mpFrame : nullptr;
 }
 
+void QtMenu::slotMenuHovered(QtMenuItem* pItem)
+{
+const OUString sHelpId = 
pItem->mpParentMenu->GetMenu()->GetHelpId(pItem->mnId);
+m_sCurrentHelpId = sHelpId;
+}
+
+void QtMenu::slotShowHelp()
+{
+SolarMutexGuard aGuard;
+Help* pHelp = Application::GetHelp();
+if (pHelp && !m_sCurrentHelpId.isEmpty())
+{
+pHelp->Start(m_sCurrentHelpId);
+}
+}
+
 void QtMenu::slotMenuTriggered(QtMenuItem* pQItem)
 {
 if (!pQItem)
@@ -772,6 +800,26 @@ void QtMenu::ImplRemoveMenuBarButton(int nId)
 lcl_force_menubar_layout_update(*mpQMenuBar);
 }
 
+void QtMenu::connectHelpShortcut(QMenu* pMenu)
+{
+assert(pMenu);
+QKeySequence 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/unx

2023-05-09 Thread Caolán McNamara (via logerrit)
 vcl/inc/qt5/QtFrame.hxx |2 
 vcl/inc/unx/gtk/gtkframe.hxx|2 
 vcl/inc/unx/salframe.h  |2 
 vcl/inc/unx/screensaverinhibitor.hxx|   28 ++--
 vcl/qt5/QtFrame.cxx |8 +-
 vcl/unx/generic/window/salframe.cxx |4 -
 vcl/unx/generic/window/screensaverinhibitor.cxx |   75 ++--
 vcl/unx/gtk3/gtkframe.cxx   |   15 +---
 8 files changed, 66 insertions(+), 70 deletions(-)

New commits:
commit 796fb57d7b2e2ea05795dc49c4438c25adc26fd4
Author: Caolán McNamara 
AuthorDate: Mon May 8 11:17:00 2023 +0100
Commit: Caolán McNamara 
CommitDate: Tue May 9 11:20:29 2023 +0200

Related: tdf#142176 rearrange screensaver inhibiter to be more generic

and for not-x11 I see gtk just uses 0 for xid (which is called
window_system_id there now)

Change-Id: I9248bcceaa2d21d34133dea80697776df0aa8c6c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151560
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index 963572ca819b..b927d366765d 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -102,7 +102,7 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public 
SalFrame
 QRect m_aRestoreGeometry;
 
 #if CHECK_ANY_QT_USING_X11
-ScreenSaverInhibitor m_ScreenSaverInhibitor;
+SessionManagerInhibitor m_SessionManagerInhibitor;
 ModKeyFlags m_nKeyModifiers;
 #endif
 
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 00bbd26379ae..1a83a7fc39d3 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -202,7 +202,7 @@ class GtkSalFrame final : public SalFrame
 boolm_bGraphics;
 ModKeyFlags m_nKeyModifiers;
 PointerStylem_ePointerStyle;
-ScreenSaverInhibitorm_ScreenSaverInhibitor;
+SessionManagerInhibitor m_SessionManagerInhibitor;
 gulong  m_nSetFocusSignalId;
 boolm_bFullscreen;
 boolm_bDefaultPos;
diff --git a/vcl/inc/unx/salframe.h b/vcl/inc/unx/salframe.h
index 3bbf9729c971..d8a177d9a867 100644
--- a/vcl/inc/unx/salframe.h
+++ b/vcl/inc/unx/salframe.h
@@ -105,7 +105,7 @@ class X11SalFrame final : public SalFrame
 int m_nWorkArea;
 boolm_bSetFocusOnMap;
 
-ScreenSaverInhibitor maScreenSaverInhibitor;
+SessionManagerInhibitor maSessionManagerInhibitor;
 tools::Rectangle   maPaintRegion;
 
 Timer   maAlwaysOnTopRaiseTimer;
diff --git a/vcl/inc/unx/screensaverinhibitor.hxx 
b/vcl/inc/unx/screensaverinhibitor.hxx
index 4ddbb53f9c12..6cfa3e2fd700 100644
--- a/vcl/inc/unx/screensaverinhibitor.hxx
+++ b/vcl/inc/unx/screensaverinhibitor.hxx
@@ -19,17 +19,25 @@
 #include 
 #include 
 
-class VCL_PLUGIN_PUBLIC ScreenSaverInhibitor
+enum ApplicationInhibitFlags
+{
+APPLICATION_INHIBIT_LOGOUT = (1 << 0),
+APPLICATION_INHIBIT_SWITCH = (1 << 1),
+APPLICATION_INHIBIT_SUSPEND = (1 << 2),
+APPLICATION_INHIBIT_IDLE = (1 << 3) // Inhibit the session being marked as 
idle
+};
+
+class VCL_PLUGIN_PUBLIC SessionManagerInhibitor
 {
 public:
-void inhibit(bool bInhibit, std::u16string_view sReason, bool bIsX11,
- const std::optional& xid, 
std::optional pDisplay);
+void inhibit(bool bInhibit, std::u16string_view sReason, 
ApplicationInhibitFlags eType,
+ unsigned int window_system_id, std::optional 
pDisplay);
 
 private:
 // These are all used as guint, however this header may be included
 // in kde/tde/etc backends, where we would ideally avoid having
 // any glib dependencies, hence the direct use of unsigned int.
-std::optional mnFDOCookie; // FDO ScreenSaver Inhibit
+std::optional mnFDOSSCookie; // FDO ScreenSaver Inhibit
 std::optional mnFDOPMCookie; // FDO PowerManagement Inhibit
 std::optional mnGSMCookie;
 std::optional mnMSMCookie;
@@ -49,18 +57,20 @@ private:
 // all encompassing standard, hence we should just try all of them.
 //
 // The current APIs we have: (note: the list of supported environments is 
incomplete)
-// FDO: org.freedesktop.ScreenSaver::Inhibit - appears to be supported 
only by KDE?
+// FDSSO: org.freedesktop.ScreenSaver::Inhibit - appears to be supported 
only by KDE?
 // FDOPM: org.freedesktop.PowerManagement.Inhibit::Inhibit - XFCE, (KDE) ?
 //(KDE: doesn't inhibit screensaver, but does inhibit 
PowerManagement)
 // GSM: org.gnome.SessionManager::Inhibit - gnome 3
 // MSM: org.mate.Sessionmanager::Inhibit - Mate <= 1.10, is identical to 
GSM
 //   (This is replaced by the GSM interface from Mate 1.12 onwards)
 //
-// Note: the Uninhibit call has 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2023-04-22 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtAccessibleWidget.hxx |   19 +++
 vcl/qt5/QtAccessibleWidget.cxx |  212 -
 2 files changed, 183 insertions(+), 48 deletions(-)

New commits:
commit 84183c84d86456e3c311b35150b1fc9b63a85561
Author: Michael Weghorn 
AuthorDate: Sat Apr 22 09:22:38 2023 +0300
Commit: Michael Weghorn 
CommitDate: Sat Apr 22 11:33:32 2023 +0200

qt a11y: Implement QAccessibleSelectionInterface added in Qt 6.5

This adds an implementation of the
`QAccessibleSelectionInterface` that was added
in Qt 6.5 in commit [1]

commit 9d16d5e2245c26e5746fd7609300b84a2a983457
Author: Michael Weghorn 
Date:   Tue Oct 11 15:23:54 2022 +0200

a11y: Add new QAccessibleSelectionInterface

, s.a. QTBUG-105909 [2].

The `QAccessibleSelectionInterface` is currently still marked as
preliminary in Qt, so changes to the API *might* still happen
and require an update of the implementation here as well).

Quoting from the commit message of the above commit:

> This interface is marked \preliminary until:
>
> 1. There is a working a11y bridge for macOS/VoiceOver
> 2. There is a working a11y bridge for Windows/UI Automation
> 3. There is a working a11y bridge for linux/AT-SPI
> 4. There is at least one implementation (e.g. QAccessibleTable)
>that implements it successfully (second candidate:
>Qt Quick TableView [...])

The AT-SPI bridge (point 3 from above) has been implemented in [3]

commit ece2feee0317b582a56a0bfc783f11fe67d3edee
Author: Michael Weghorn 
Date:   Tue Oct 11 15:24:04 2022 +0200

a11y atspi: Bridge newly introduced QAccessibleSelectionInterface

, an implementation for `QAccessibleTable` (point 4 from above) was
added in [4]

commit 092bbc9ad30c6cd7389053dc4b332cc762693676
Author: Michael Weghorn 
Date:   Wed Oct 12 07:07:48 2022 +0200

a11y: Implement QAccessibleSelectionInterface for item views

. The Qt Gerrit changes for the macOS implementation (point 1 from
above) and the Windows/UIA implementation (point 2 from above)
are currently still awaiting review: [5] [6]

To avoid duplication, just call the newly added methods
`QtAccessibleWidget::selectedItemCount` and
`QtAccessibleWidget::selectedItem` from the
`QAccessibleTableInterface` methods
`QtAccessibleWidget::selectedCellCount` and
and `QtAccessibleWidget::selectedCells`, and
therefore implement the former also for Qt < 6.5.

Sample use of the interface from Accerciser's IPython
console (with 18 cells selected in Calc and the spreadsheet
object selected in Accerciser's a11y object tree; screencast
attached to QTBUG-105909 [2]):

In [10]: acc.get_interfaces()
Out[10]: ['Accessible', 'Component', 'Selection', 'Table']
In [11]: sel = acc.querySelection()
In [12]: sel.nSelectedChildren
Out[12]: 18
In [13]: sel.getSelectedChild(0).name
Out[13]: 'B1'
In [14]: sel.deselectSelectedChild(1)
Out[14]: True
In [15]: sel.deselectChild(1)
Out[15]: True
In [16]: sel.selectChild(0)
Out[16]: True
In [17]: sel.clearSelection()
Out[17]: True
In [18]: sel.selectAll()
Out[18]: True

[1] 
https://code.qt.io/cgit/qt/qtbase.git/commit/?id=9d16d5e2245c26e5746fd7609300b84a2a983457
[2] https://bugreports.qt.io/browse/QTBUG-105909
[3] 
https://code.qt.io/cgit/qt/qtbase.git/commit/?id=ece2feee0317b582a56a0bfc783f11fe67d3edee
[4] 
https://code.qt.io/cgit/qt/qtbase.git/commit/?id=092bbc9ad30c6cd7389053dc4b332cc762693676
[5] https://codereview.qt-project.org/c/qt/qtbase/+/451353
[6] https://codereview.qt-project.org/c/qt/qtbase/+/451646

Change-Id: Iac3c050448183610af3bd3b10a56e82d7d52cb91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138750
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtAccessibleWidget.hxx 
b/vcl/inc/qt5/QtAccessibleWidget.hxx
index 7e7625041c4f..d6d27c9cfcbd 100644
--- a/vcl/inc/qt5/QtAccessibleWidget.hxx
+++ b/vcl/inc/qt5/QtAccessibleWidget.hxx
@@ -40,6 +40,9 @@ class QtAccessibleWidget final : public QAccessibleInterface,
  public QAccessibleActionInterface,
  public QAccessibleTextInterface,
  public QAccessibleEditableTextInterface,
+#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
+ public QAccessibleSelectionInterface,
+#endif
  public QAccessibleTableCellInterface,
  public QAccessibleTableInterface,
  public QAccessibleValueInterface
@@ -147,6 +150,22 @@ public:
 virtual int 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2023-02-10 Thread Rafael Lima (via logerrit)
 vcl/inc/qt5/QtGraphics_Controls.hxx |3 ++-
 vcl/qt5/QtGraphics_Controls.cxx |   30 --
 2 files changed, 30 insertions(+), 3 deletions(-)

New commits:
commit 5c96e813bed3293605f8d746f188cc051d1e5949
Author: Rafael Lima 
AuthorDate: Thu Feb 2 15:27:37 2023 +
Commit: Michael Weghorn 
CommitDate: Fri Feb 10 08:04:40 2023 +

tdf#150451 Fix borders in Editbox controls (kf5)

The bounding rectangle calculated for an Editbox in
QtGraphics_Controls::getNativeControlRegion was not
always enough to accommodate content and the borders.

The KDE Breeze does not draw any borders if the total
height of the bounding rectangle is smaller than the
minimum size needed for content + frame at top and bottom,
s. Style::drawFrameLineEditPrimitive in the Breeze
style [1].

Therefore, ensure a minimum height of that size.
The Breeze style also considers the type of the
passed widget when retrieving the frame width using
QStyle::pixelMetric [2], so pass a dummy `QLineEdit`
in order to get the actual frame width of 6
that the Breeze style uses for line edits, rather
than the default value of 2 that is returned when not
passing any widget.

Just do that for the minimum size calculation for now
and not everywhere, because the handling for edit boxes
here in the qt VCL plugins and in the calling code
currently does all kinds of "interesting" things like doing
extra size adjustments or passing the content rect where the
bounding rect would be expected,...

Ideally this should be cleaned up in the callers and all
platform integrations in a follow-up commit
to adhere to what the doc in vcl/inc/WidgetDrawInterface.hxx
says, but this here keeps it working with existing code for now.

(s.a. discussion in the Gerrit change for more details)

Tested using various scaling factors: 1, 1.25, 1.5, 1.75 and 2.0.

[1] 
https://invent.kde.org/plasma/breeze/-/blob/144ea45018d28758db07afd987d97318d56c4981/kstyle/breezestyle.cpp#L3527
[2] 
https://invent.kde.org/plasma/breeze/-/blob/144ea45018d28758db07afd987d97318d56c4981/kstyle/breezestyle.cpp#L555

Co-authored-by: Michael Weghorn 

Change-Id: If8cb4794c7f3ce1be4d1ee421c9c27ad5adf5da2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146516
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtGraphics_Controls.hxx 
b/vcl/inc/qt5/QtGraphics_Controls.hxx
index 17039f9d6038..dd1865e34008 100644
--- a/vcl/inc/qt5/QtGraphics_Controls.hxx
+++ b/vcl/inc/qt5/QtGraphics_Controls.hxx
@@ -59,7 +59,8 @@ public:
 tools::Rectangle& rNativeContentRegion) 
override;
 
 private:
-static int pixelMetric(QStyle::PixelMetric metric, const QStyleOption* 
option = nullptr);
+static int pixelMetric(QStyle::PixelMetric metric, const QStyleOption* 
option = nullptr,
+   const QWidget* pWidget = nullptr);
 static QSize sizeFromContents(QStyle::ContentsType type, const 
QStyleOption* option,
   const QSize& contentsSize);
 static QRect subControlRect(QStyle::ComplexControl control, const 
QStyleOptionComplex* option,
diff --git a/vcl/qt5/QtGraphics_Controls.cxx b/vcl/qt5/QtGraphics_Controls.cxx
index e08b84719e61..f2e48f655149 100644
--- a/vcl/qt5/QtGraphics_Controls.cxx
+++ b/vcl/qt5/QtGraphics_Controls.cxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -129,9 +130,10 @@ bool 
QtGraphics_Controls::isNativeControlSupported(ControlType type, ControlPart
 return false;
 }
 
-inline int QtGraphics_Controls::pixelMetric(QStyle::PixelMetric metric, const 
QStyleOption* option)
+inline int QtGraphics_Controls::pixelMetric(QStyle::PixelMetric metric, const 
QStyleOption* option,
+const QWidget* pWidget)
 {
-return QApplication::style()->pixelMetric(metric, option);
+return QApplication::style()->pixelMetric(metric, option, pWidget);
 }
 
 inline QSize QtGraphics_Controls::sizeFromContents(QStyle::ContentsType type,
@@ -759,6 +761,30 @@ bool 
QtGraphics_Controls::getNativeControlRegion(ControlType type, ControlPart p
 int nRight = qMax(nLine, upscale(fo.rect.right() - 
aSubRect.right(), Round::Ceil));
 int nBottom = qMax(nLine, upscale(fo.rect.bottom() - 
aSubRect.bottom(), Round::Ceil));
 boundingRect.adjust(nLeft, nTop, nRight, nBottom);
+
+// tdf#150451: ensure a minimium size that fits text content + 
frame at top and bottom.
+// Themes may use the widget type for determining the actual frame 
width to use,
+// so pass a dummy QLineEdit
+//
+// NOTE: This is currently only done here for the minimum size 
calculation and
+// not above because the handling for edit 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win

2022-09-11 Thread Khaled Hosny (via logerrit)
 vcl/inc/sft.hxx |   35 +--
 vcl/qt5/QtGraphics_Text.cxx |  127 +++-
 vcl/quartz/salgdicommon.cxx |   25 +
 vcl/source/fontsubset/sft.cxx   |  101 ++
 vcl/unx/generic/fontmanager/fontmanager.cxx |   19 
 vcl/win/gdi/salfont.cxx |   72 +--
 6 files changed, 146 insertions(+), 233 deletions(-)

New commits:
commit 4286e745bccc7393ecd8b06346306d13d23316b5
Author: Khaled Hosny 
AuthorDate: Sun Sep 11 01:23:16 2022 +0200
Commit: خالد حسني 
CommitDate: Sun Sep 11 09:51:53 2022 +0200

vcl: Add a PhysicalFontFace-backed TrueTypeFont

This is mainly to be able to get the font table data from the
PhysicalFontFace so that an actual font file or full font data are not
required (since they are not always available, e.g. with CoreText fonts).

This is slightly based on QtTrueTypeFont that this code replaces.

Change-Id: I6926706dfc6765076100ac0314a30f9ff970ddb6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139760
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 75af2af8044e..88fa729fe6b8 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -50,6 +50,8 @@
 #include 
 #include 
 
+#include "font/PhysicalFontFace.hxx"
+
 namespace vcl
 {
 
@@ -450,6 +452,7 @@ constexpr sal_uInt32 T_CFF  = 0x43464620;
 
 class AbstractTrueTypeFont;
 class TrueTypeFont;
+class TrueTypeFace;
 
 /**
  * @defgroup sft Sun Font Tools Exported Functions
@@ -664,7 +667,7 @@ class TrueTypeFont;
  * @ingroup sft
  *
  */
-VCL_DLLPUBLIC void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo 
*info);
+VCL_DLLPUBLIC void GetTTGlobalFontInfo(AbstractTrueTypeFont *ttf, 
TTGlobalFontInfo *info);
 
 /**
  * Returns part of the head table info, normally collected by 
GetTTGlobalFontInfo.
@@ -736,6 +739,8 @@ public:
 AbstractTrueTypeFont(const char* fileName = nullptr, const FontCharMapRef 
xCharMap = nullptr);
 virtual ~AbstractTrueTypeFont();
 
+SFErrCodes initialize();
+
 std::string const & fileName() const { return m_sFileName; }
 sal_uInt32 glyphCount() const { return m_nGlyphs; }
 sal_uInt32 glyphOffset(sal_uInt32 glyphID) const;
@@ -746,6 +751,12 @@ public:
 
 virtual bool hasTable(sal_uInt32 ord) const = 0;
 virtual const sal_uInt8* table(sal_uInt32 ord, sal_uInt32& size) const = 0;
+
+char*psname;
+char*family;
+sal_Unicode *ufamily;
+char*subfamily;
+sal_Unicode *usubfamily;
 };
 
 class TrueTypeFont final : public AbstractTrueTypeFont
@@ -761,13 +772,6 @@ class TrueTypeFont final : public AbstractTrueTypeFont
 public:
 sal_Int32   fsize;
 sal_uInt8   *ptr;
-
-char*psname;
-char*family;
-sal_Unicode *ufamily;
-char*subfamily;
-sal_Unicode *usubfamily;
-
 sal_uInt32  ntables;
 
 TrueTypeFont(const char* pFileName = nullptr, const FontCharMapRef 
xCharMap = nullptr);
@@ -792,6 +796,21 @@ const sal_uInt8* TrueTypeFont::table(sal_uInt32 ord, 
sal_uInt32& size) const
 return rTable.pData;
 }
 
+class VCL_DLLPUBLIC TrueTypeFace final : public AbstractTrueTypeFont
+{
+const font::PhysicalFontFace& m_rFace;
+mutable std::array m_aTableList;
+
+static sal_uInt32 TableTag(sal_uInt32);
+
+public:
+TrueTypeFace(const font::PhysicalFontFace&);
+~TrueTypeFace() override;
+
+bool hasTable(sal_uInt32) const override;
+const sal_uInt8* table(sal_uInt32, sal_uInt32&) const override;
+};
+
 } // namespace vcl
 
 #endif // INCLUDED_VCL_INC_SFT_HXX
diff --git a/vcl/qt5/QtGraphics_Text.cxx b/vcl/qt5/QtGraphics_Text.cxx
index c8c59bc48cc3..69828ea82cc0 100644
--- a/vcl/qt5/QtGraphics_Text.cxx
+++ b/vcl/qt5/QtGraphics_Text.cxx
@@ -137,94 +137,7 @@ bool 
QtGraphics::AddTempDevFont(vcl::font::PhysicalFontCollection*, const OUStri
 return false;
 }
 
-namespace
-{
-class QtTrueTypeFont : public vcl::AbstractTrueTypeFont
-{
-const QRawFont& m_aRawFont;
-mutable QByteArray m_aFontTable[vcl::NUM_TAGS];
-
-public:
-QtTrueTypeFont(const QtFontFace& aFontFace, const QRawFont& aRawFont);
-
-bool hasTable(sal_uInt32 ord) const override;
-const sal_uInt8* table(sal_uInt32 ord, sal_uInt32& size) const override;
-};
-
-QtTrueTypeFont::QtTrueTypeFont(const QtFontFace& aFontFace, const QRawFont& 
aRawFont)
-: vcl::AbstractTrueTypeFont(nullptr, aFontFace.GetFontCharMap())
-, m_aRawFont(aRawFont)
-{
-indexGlyphData();
-}
-
-const char* vclFontTableAsChar(sal_uInt32 ord)
-{
-switch (ord)
-{
-case vcl::O_maxp:
-return "maxp";
-case vcl::O_glyf:
-return "glyf";
-case vcl::O_head:
-return "head";
-case vcl::O_loca:
-return "loca";
-case vcl::O_name:
-return "name";
-

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win

2022-09-05 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/PhysicalFontFace.hxx  |6 ++-
 vcl/inc/qt5/QtFontFace.hxx |6 ---
 vcl/inc/quartz/salgdi.h|4 --
 vcl/inc/unx/freetype_glyphcache.hxx|9 -
 vcl/inc/win/salgdi.h   |8 -
 vcl/qt5/QtFontFace.cxx |   27 -
 vcl/quartz/AquaGraphicsBackend.cxx |1 
 vcl/quartz/salgdi.cxx  |   33 -
 vcl/source/font/PhysicalFontFace.cxx   |   21 +
 vcl/unx/generic/gdi/freetypetextrender.cxx |2 -
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |   25 
 vcl/unx/generic/print/genpspgraphics.cxx   |2 -
 vcl/win/gdi/salfont.cxx|   39 +
 vcl/win/gdi/winlayout.cxx  |1 
 14 files changed, 30 insertions(+), 154 deletions(-)

New commits:
commit 28c8cddd4218905bca05778dcdbae5911132a096
Author: Khaled Hosny 
AuthorDate: Mon Sep 5 06:34:52 2022 +0200
Commit: خالد حسني 
CommitDate: Mon Sep 5 09:55:11 2022 +0200

vcl: Consolidate PhysicalFontFace::GetFontCapabilities()

All subclasses are doing the same thing in slightly different ways, so
move it to the base class that we can now access font tables there.

Change-Id: I1f8827dbc345aa852e1f74cb4615593289c8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139395
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/inc/font/PhysicalFontFace.hxx 
b/vcl/inc/font/PhysicalFontFace.hxx
index ee65766fadbd..396178c5e40d 100644
--- a/vcl/inc/font/PhysicalFontFace.hxx
+++ b/vcl/inc/font/PhysicalFontFace.hxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -40,7 +41,6 @@ class FontSelectPattern;
 
 namespace vcl
 {
-struct FontCapabilities;
 class PhysicalFontFamily;
 }
 
@@ -76,7 +76,7 @@ public:
 
 virtual sal_IntPtr GetFontId() const = 0;
 virtual FontCharMapRef GetFontCharMap() const;
-virtual bool GetFontCapabilities(vcl::FontCapabilities&) const = 0;
+virtual bool GetFontCapabilities(vcl::FontCapabilities&) const;
 
 bool IsBetterMatch(const vcl::font::FontSelectPattern&, FontMatchStatus&) 
const;
 sal_Int32 CompareIgnoreSize(const PhysicalFontFace&) const;
@@ -91,6 +91,8 @@ public:
 protected:
 mutable hb_face_t* mpHbFace;
 mutable FontCharMapRef mxCharMap;
+mutable vcl::FontCapabilities maFontCapabilities;
+mutable bool mbFontCapabilitiesRead;
 
 explicit PhysicalFontFace(const FontAttributes&);
 };
diff --git a/vcl/inc/qt5/QtFontFace.hxx b/vcl/inc/qt5/QtFontFace.hxx
index 3db0c8a6eb5b..06260468cbdc 100644
--- a/vcl/inc/qt5/QtFontFace.hxx
+++ b/vcl/inc/qt5/QtFontFace.hxx
@@ -25,8 +25,6 @@
 #include 
 
 #include 
-#include 
-#include 
 
 #include 
 #include 
@@ -52,8 +50,6 @@ public:
 
 QFont CreateFont() const;
 
-bool GetFontCapabilities(vcl::FontCapabilities&) const override;
-
 rtl::Reference
 CreateFontInstance(const vcl::font::FontSelectPattern& rFSD) const 
override;
 
@@ -67,8 +63,6 @@ private:
 
 const QString m_aFontId;
 const FontIdType m_eFontIdType;
-mutable vcl::FontCapabilities m_aFontCapabilities;
-mutable bool m_bFontCapabilitiesRead;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index cbdffdeecc19..732587a09551 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -69,16 +69,12 @@ public:
 int GetFontTable( uint32_t nTagCode, unsigned 
char* ) const;
 int GetFontTable( const char pTagName[5], 
unsigned char* ) const;
 
-bool GetFontCapabilities(vcl::FontCapabilities&) const override;
-
 rtl::Reference CreateFontInstance(const 
vcl::font::FontSelectPattern&) const override;
 
 virtual hb_blob_t*  GetHbTable(hb_tag_t nTag) const override;
 
 private:
 const sal_IntPtrmnFontId;
-mutable vcl::FontCapabilities   maFontCapabilities;
-mutable boolmbFontCapabilitiesRead;
 };
 
 class CoreTextStyle final : public LogicalFontInstance
diff --git a/vcl/inc/unx/freetype_glyphcache.hxx 
b/vcl/inc/unx/freetype_glyphcache.hxx
index b77978061d09..a5876344a055 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -72,8 +72,6 @@ public:
 
 void  AnnounceFont( vcl::font::PhysicalFontCollection* );
 
-bool GetFontCapabilities(vcl::FontCapabilities&) const;
-
 private:
 friend class FreetypeManager;
 explicit FreetypeFontInfo(FontAttributes , FreetypeFontFile* const 
pFontFile,
@@ -100,17 +98,10 @@ public:
 virtual rtl::Reference CreateFontInstance(const 
vcl::font::FontSelectPattern&) const override;
 virtual sal_IntPtr  GetFontId() const override { return 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win

2022-09-04 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/PhysicalFontFace.hxx  |3 +
 vcl/inc/qt5/QtFontFace.hxx |3 -
 vcl/inc/quartz/salgdi.h|3 -
 vcl/inc/unx/freetype_glyphcache.hxx|5 --
 vcl/inc/unx/glyphcache.hxx |1 
 vcl/inc/win/salgdi.h   |   20 ---
 vcl/qt5/QtFontFace.cxx |   24 -
 vcl/quartz/salgdi.cxx  |   41 ---
 vcl/source/font/PhysicalFontFace.cxx   |   24 +
 vcl/unx/generic/gdi/freetypetextrender.cxx |2 -
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |   33 --
 vcl/unx/generic/print/genpspgraphics.cxx   |2 -
 vcl/win/gdi/salfont.cxx|   44 -
 13 files changed, 30 insertions(+), 175 deletions(-)

New commits:
commit ca7d6be2d64a48e61db7a1c614d6325151817f59
Author: Khaled Hosny 
AuthorDate: Sun Sep 4 20:39:22 2022 +0200
Commit: خالد حسني 
CommitDate: Mon Sep 5 06:09:11 2022 +0200

vcl: Consolidate PhysicalFontFace::GetFontCharMap()

All subclasses are doing the same thing in slightly different ways, so
move it to the base class that we can now access font tables there.

Also drop unused PhysicalFontFace::HasChar().

Change-Id: I77022b4dc3688de2788c18966f39f407a6abb730
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139340
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/inc/font/PhysicalFontFace.hxx 
b/vcl/inc/font/PhysicalFontFace.hxx
index d4851ba507be..52acaacf08ec 100644
--- a/vcl/inc/font/PhysicalFontFace.hxx
+++ b/vcl/inc/font/PhysicalFontFace.hxx
@@ -73,7 +73,7 @@ public:
 virtual rtl::Reference CreateFontInstance(const 
vcl::font::FontSelectPattern&) const = 0;
 
 virtual sal_IntPtr  GetFontId() const = 0;
-virtual FontCharMapRef GetFontCharMap() const = 0;
+virtual FontCharMapRef  GetFontCharMap() const;
 virtual bool GetFontCapabilities(vcl::FontCapabilities&) const = 0;
 
 boolIsBetterMatch( const 
vcl::font::FontSelectPattern&, FontMatchStatus& ) const;
@@ -84,6 +84,7 @@ public:
 
 protected:
 mutable hb_face_t*  mpHbFace;
+mutable FontCharMapRef  mxCharMap;
 
 explicit PhysicalFontFace(const FontAttributes&);
 };
diff --git a/vcl/inc/qt5/QtFontFace.hxx b/vcl/inc/qt5/QtFontFace.hxx
index eb4846ef772d..3db0c8a6eb5b 100644
--- a/vcl/inc/qt5/QtFontFace.hxx
+++ b/vcl/inc/qt5/QtFontFace.hxx
@@ -52,9 +52,7 @@ public:
 
 QFont CreateFont() const;
 
-FontCharMapRef GetFontCharMap() const override;
 bool GetFontCapabilities(vcl::FontCapabilities&) const override;
-bool HasChar(sal_uInt32 cChar) const;
 
 rtl::Reference
 CreateFontInstance(const vcl::font::FontSelectPattern& rFSD) const 
override;
@@ -69,7 +67,6 @@ private:
 
 const QString m_aFontId;
 const FontIdType m_eFontIdType;
-mutable FontCharMapRef m_xCharMap;
 mutable vcl::FontCapabilities m_aFontCapabilities;
 mutable bool m_bFontCapabilitiesRead;
 };
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 9fc3e6b2d74c..cbdffdeecc19 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -69,9 +69,7 @@ public:
 int GetFontTable( uint32_t nTagCode, unsigned 
char* ) const;
 int GetFontTable( const char pTagName[5], 
unsigned char* ) const;
 
-FontCharMapRef GetFontCharMap() const override;
 bool GetFontCapabilities(vcl::FontCapabilities&) const override;
-boolHasChar( sal_uInt32 cChar ) const;
 
 rtl::Reference CreateFontInstance(const 
vcl::font::FontSelectPattern&) const override;
 
@@ -79,7 +77,6 @@ public:
 
 private:
 const sal_IntPtrmnFontId;
-mutable FontCharMapRef  mxCharMap;
 mutable vcl::FontCapabilities   maFontCapabilities;
 mutable boolmbFontCapabilitiesRead;
 };
diff --git a/vcl/inc/unx/freetype_glyphcache.hxx 
b/vcl/inc/unx/freetype_glyphcache.hxx
index c3ca90591f59..b77978061d09 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -27,8 +27,6 @@
 
 #include 
 
-class CmapResult;
-
 // FreetypeFontFile has the responsibility that a font file is only mapped 
once.
 // (#86621#) the old directly ft-managed solution caused it to be mapped
 // in up to nTTC*nSizes*nOrientation*nSynthetic times
@@ -74,7 +72,6 @@ public:
 
 void  AnnounceFont( vcl::font::PhysicalFontCollection* );
 
-const FontCharMapRef & GetFontCharMap() const;
 bool GetFontCapabilities(vcl::FontCapabilities&) const;
 
 private:
@@ -90,7 +87,6 @@ private:
 sal_IntPtr  mnFontId;
 FontAttributes  maDevFontAttributes;
 
-mutable FontCharMapRef mxFontCharMap;
 };
 
 class FreetypeFontFace : public vcl::font::PhysicalFontFace
@@ -104,7 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win

2022-09-03 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/PhysicalFontFace.hxx  |9 ++
 vcl/inc/fontinstance.hxx   |   17 
 vcl/inc/qt5/QtFont.hxx |2 
 vcl/inc/qt5/QtFontFace.hxx |3 
 vcl/inc/quartz/salgdi.h|4 -
 vcl/inc/unx/freetype_glyphcache.hxx|5 +
 vcl/inc/win/salgdi.h   |7 +
 vcl/inc/win/winlayout.hxx  |2 
 vcl/qt5/QtFont.cxx |   21 -
 vcl/qt5/QtFontFace.cxx |   16 
 vcl/quartz/ctfonts.cxx |   15 +--
 vcl/source/font/PhysicalFontFace.cxx   |   19 +
 vcl/source/font/fontinstance.cxx   |6 -
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |   18 
 vcl/unx/generic/glyphs/glyphcache.cxx  |   24 --
 vcl/win/gdi/salfont.cxx|   94 ++---
 vcl/win/gdi/winlayout.cxx  |   94 -
 17 files changed, 177 insertions(+), 179 deletions(-)

New commits:
commit dc92a4d973086ce8a6a5f75ba0f4d4c9ca05537a
Author: Khaled Hosny 
AuthorDate: Sat Sep 3 03:14:08 2022 +0200
Commit: خالد حسني 
CommitDate: Sun Sep 4 02:10:17 2022 +0200

vcl: Create hb_face_t in PhysicalFontFace

The two map to each other, and we want to access hb_face_t to provide
some functionality scattered currently in platform-specific
implementations.

Change-Id: Ib3842752ec240b8254db828dba95a6a0ad65f16a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139275
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/inc/font/PhysicalFontFace.hxx 
b/vcl/inc/font/PhysicalFontFace.hxx
index bd3093562a06..d4851ba507be 100644
--- a/vcl/inc/font/PhysicalFontFace.hxx
+++ b/vcl/inc/font/PhysicalFontFace.hxx
@@ -29,6 +29,8 @@
 
 #include 
 
+#include 
+
 class LogicalFontInstance;
 struct FontMatchStatus;
 namespace vcl::font
@@ -66,6 +68,8 @@ public:
 class VCL_PLUGIN_PUBLIC PhysicalFontFace : public FontAttributes, public 
salhelper::SimpleReferenceObject
 {
 public:
+~PhysicalFontFace();
+
 virtual rtl::Reference CreateFontInstance(const 
vcl::font::FontSelectPattern&) const = 0;
 
 virtual sal_IntPtr  GetFontId() const = 0;
@@ -75,7 +79,12 @@ public:
 boolIsBetterMatch( const 
vcl::font::FontSelectPattern&, FontMatchStatus& ) const;
 sal_Int32   CompareIgnoreSize( const PhysicalFontFace& ) const;
 
+virtual hb_face_t*  GetHbFace() const;
+virtual hb_blob_t*  GetHbTable(hb_tag_t) const { assert(false); return 
nullptr; }
+
 protected:
+mutable hb_face_t*  mpHbFace;
+
 explicit PhysicalFontFace(const FontAttributes&);
 };
 
diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx
index 5cb05b1d3804..2b382009e263 100644
--- a/vcl/inc/fontinstance.hxx
+++ b/vcl/inc/fontinstance.hxx
@@ -103,16 +103,14 @@ public: // TODO: make data members private
 int GetKashidaWidth() const;
 
 void GetScale(double* nXScale, double* nYScale) const;
-static inline void DecodeOpenTypeTag(const uint32_t nTableTag, char* 
pTagName);
 
 protected:
 explicit LogicalFontInstance(const vcl::font::PhysicalFontFace&, const 
vcl::font::FontSelectPattern&);
 
 virtual bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) 
const = 0;
 
-// Takes ownership of pHbFace.
-static hb_font_t* InitHbFont(hb_face_t* pHbFace);
-virtual hb_font_t* ImplInitHbFont() { assert(false); return 
hb_font_get_empty(); }
+hb_font_t* InitHbFont();
+virtual void ImplInitHbFont(hb_font_t*) { }
 
 private:
 struct MapEntry
@@ -142,17 +140,8 @@ private:
 inline hb_font_t* LogicalFontInstance::GetHbFont()
 {
 if (!m_pHbFont)
-m_pHbFont = ImplInitHbFont();
+m_pHbFont = InitHbFont();
 return m_pHbFont;
 }
 
-inline void LogicalFontInstance::DecodeOpenTypeTag(const uint32_t nTableTag, 
char* pTagName)
-{
-pTagName[0] = static_cast(nTableTag >> 24);
-pTagName[1] = static_cast(nTableTag >> 16);
-pTagName[2] = static_cast(nTableTag >> 8);
-pTagName[3] = static_cast(nTableTag);
-pTagName[4] = 0;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt5/QtFont.hxx b/vcl/inc/qt5/QtFont.hxx
index 237523e2d10a..2ba6f49e557f 100644
--- a/vcl/inc/qt5/QtFont.hxx
+++ b/vcl/inc/qt5/QtFont.hxx
@@ -35,8 +35,6 @@ class QtFont final : public QFont, public LogicalFontInstance
 bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const 
override;
 bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const 
override;
 
-virtual hb_font_t* ImplInitHbFont() override;
-
 explicit QtFont(const vcl::font::PhysicalFontFace&, const 
vcl::font::FontSelectPattern&);
 };
 
diff --git a/vcl/inc/qt5/QtFontFace.hxx b/vcl/inc/qt5/QtFontFace.hxx
index 2df5ab7eb009..eb4846ef772d 100644
--- 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-08-16 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtXAccessible.hxx  |5 +
 vcl/qt5/QtAccessibleWidget.cxx |7 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

New commits:
commit f2371a7d9b306ce217689bd69c920c9f780f1ee3
Author: Michael Weghorn 
AuthorDate: Tue Aug 16 14:13:20 2022 +0200
Commit: Michael Weghorn 
CommitDate: Tue Aug 16 22:29:15 2022 +0200

qt a11y: Clear QtXAccessible's ref to XAccessible once passed on

The `QtXAccessible` only needs to hold a reference to
the `XAccessible` in order to pass it to the
`QtAccessibleWidget` ctor in `QtAccessibleWidget::customFactory`
(which gets called via `QAccessible::queryAccessibleInterface`).

After that has happened, the `QtAccessibleWidget` holds
its own reference in its `m_xAccessible` member and is the
only class in the context of the qt a11y bridge that needs
access to the `XAccessible`, so drop the reference
in the `QtXAccessible` to avoid any references being
held even after `QtAccessibleEventListener::disposing`
has been called, s.a.
Change-Id I077dffe6ca3e887707d1f578e947ccf3c2c2a492
"qt a11y: Clear XAccessible reference when disposing" for
some more context.

Change-Id: Ief80b2939e4c509fc4bc68e67500dbad66498506
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138365
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtXAccessible.hxx b/vcl/inc/qt5/QtXAccessible.hxx
index 4f4285e8065b..ddb7849b641c 100644
--- a/vcl/inc/qt5/QtXAccessible.hxx
+++ b/vcl/inc/qt5/QtXAccessible.hxx
@@ -28,6 +28,11 @@ class QtXAccessible : public QObject
 
 public:
 QtXAccessible(css::uno::Reference 
xAccessible);
+
+/** Reference to the XAccessible.
+  * This is cleared once it has been passed to the QtAccessibleWidget,
+  * which then keeps an own reference and takes care of all required
+  * access to the XAccessible for the Qt a11y bridge. */
 css::uno::Reference m_xAccessible;
 };
 
diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx
index 83733e04c285..09d01c6e496f 100644
--- a/vcl/qt5/QtAccessibleWidget.cxx
+++ b/vcl/qt5/QtAccessibleWidget.cxx
@@ -749,7 +749,12 @@ QAccessibleInterface* 
QtAccessibleWidget::customFactory(const QString& classname
 {
 QtXAccessible* pXAccessible = static_cast(object);
 if (pXAccessible && pXAccessible->m_xAccessible.is())
-return new QtAccessibleWidget(pXAccessible->m_xAccessible, object);
+{
+QtAccessibleWidget* pRet = new 
QtAccessibleWidget(pXAccessible->m_xAccessible, object);
+// clear the reference in the QtXAccessible, no longer needed now 
that the QtAccessibleWidget holds one
+pXAccessible->m_xAccessible.clear();
+return pRet;
+}
 }
 
 return nullptr;


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-08-16 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtAccessibleWidget.hxx|4 
 vcl/qt5/QtAccessibleEventListener.cxx |6 +-
 vcl/qt5/QtAccessibleWidget.cxx|2 ++
 3 files changed, 11 insertions(+), 1 deletion(-)

New commits:
commit a65719ec67523cdfc294aeeda527b51ba4d2e17c
Author: Michael Weghorn 
AuthorDate: Tue Aug 16 12:35:56 2022 +0200
Commit: Michael Weghorn 
CommitDate: Tue Aug 16 22:28:16 2022 +0200

qt a11y: Clear XAccessible reference when disposing

The `XEventListener::disposing` doc
(in `./udkapi/com/sun/star/lang/XEventListener.idl`) says:

> /** gets called when the broadcaster is about to be disposed.
>
> All listeners and all other objects, which reference the
> broadcaster should release the reference to the source.
> No method should be invoked anymore on this object (
> including XComponent::removeEventListener() ).
> 
>
> This method is called for every listener registration
> of derived listener interfaced, not only for registrations
> at XComponent. 
>  */

Therefore, clear the `XAccessible` reference held in
the associated `QtAccessibleWidget`
in `QtAccessibleEventListener::disposing`.

This also implies that `QtAccessibleWidget::isValid()`
(overriding the `QAccessibleInterface` method)
will return `false` from that point on.

Change-Id: I077dffe6ca3e887707d1f578e947ccf3c2c2a492
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138364
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtAccessibleWidget.hxx 
b/vcl/inc/qt5/QtAccessibleWidget.hxx
index fdd97b0b407d..0ca17b394123 100644
--- a/vcl/inc/qt5/QtAccessibleWidget.hxx
+++ b/vcl/inc/qt5/QtAccessibleWidget.hxx
@@ -50,6 +50,10 @@ class QtAccessibleWidget final : public QObject,
 public:
 QtAccessibleWidget(const 
css::uno::Reference xAccessible,
QObject* pObject);
+
+void invalidate();
+
+// QAccessibleInterface
 QWindow* window() const override;
 int childCount() const override;
 int indexOfChild(const QAccessibleInterface* child) const override;
diff --git a/vcl/qt5/QtAccessibleEventListener.cxx 
b/vcl/qt5/QtAccessibleEventListener.cxx
index ee562a4eca38..53256181ea4e 100644
--- a/vcl/qt5/QtAccessibleEventListener.cxx
+++ b/vcl/qt5/QtAccessibleEventListener.cxx
@@ -353,6 +353,10 @@ void QtAccessibleEventListener::notifyEvent(const 
css::accessibility::Accessible
 }
 }
 
-void QtAccessibleEventListener::disposing(const EventObject& /* Source */) {}
+void QtAccessibleEventListener::disposing(const EventObject& /* Source */)
+{
+assert(m_pAccessibleWidget);
+m_pAccessibleWidget->invalidate();
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx
index d6370877f449..83733e04c285 100644
--- a/vcl/qt5/QtAccessibleWidget.cxx
+++ b/vcl/qt5/QtAccessibleWidget.cxx
@@ -73,6 +73,8 @@ QtAccessibleWidget::QtAccessibleWidget(const 
Reference xAccessible,
 }
 }
 
+void QtAccessibleWidget::invalidate() { m_xAccessible.clear(); }
+
 Reference QtAccessibleWidget::getAccessibleContextImpl() 
const
 {
 Reference xAc;


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-08-16 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtAccessibleEventListener.hxx |5 +
 vcl/qt5/QtAccessibleEventListener.cxx |6 ++
 vcl/qt5/QtAccessibleWidget.cxx|3 +--
 3 files changed, 4 insertions(+), 10 deletions(-)

New commits:
commit 48baddac8f175e628a854f78304a19238e25d529
Author: Michael Weghorn 
AuthorDate: Tue Aug 16 11:54:20 2022 +0200
Commit: Michael Weghorn 
CommitDate: Tue Aug 16 22:27:49 2022 +0200

qt a11y: Drop QtAccessibleEventListener's XAccessible reference

`QtAccessibleEventListener` was holding a reference
to the `XAccessible` but not making use of it.

The `QtAccessibleWidget` class that actually
operates on the `XAccessible` is holding its own reference
in its `m_xAccessible` member, so there's no need for
the corresponding `QtAccessibleEventListener` to
hold another one.

Change-Id: I5b838e55d8285b4e52287dc8c9c70e06e45ab317
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138363
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtAccessibleEventListener.hxx 
b/vcl/inc/qt5/QtAccessibleEventListener.hxx
index 1103dc9da598..f6c7c4866ec0 100644
--- a/vcl/inc/qt5/QtAccessibleEventListener.hxx
+++ b/vcl/inc/qt5/QtAccessibleEventListener.hxx
@@ -21,9 +21,7 @@ class QtAccessibleEventListener final
 : public cppu::WeakImplHelper
 {
 public:
-QtAccessibleEventListener(
-const css::uno::Reference xAccessible,
-QtAccessibleWidget* pAccessibleWidget);
+explicit QtAccessibleEventListener(QtAccessibleWidget* pAccessibleWidget);
 
 virtual void SAL_CALL
 notifyEvent(const css::accessibility::AccessibleEventObject& aEvent) 
override;
@@ -31,7 +29,6 @@ public:
 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) 
override;
 
 private:
-css::uno::Reference m_xAccessible;
 QtAccessibleWidget* m_pAccessibleWidget;
 
 static void HandleStateChangedEvent(QAccessibleInterface* 
pQAccessibleInterface,
diff --git a/vcl/qt5/QtAccessibleEventListener.cxx 
b/vcl/qt5/QtAccessibleEventListener.cxx
index d109e4b5c844..ee562a4eca38 100644
--- a/vcl/qt5/QtAccessibleEventListener.cxx
+++ b/vcl/qt5/QtAccessibleEventListener.cxx
@@ -35,10 +35,8 @@ using namespace css::accessibility;
 using namespace css::lang;
 using namespace css::uno;
 
-QtAccessibleEventListener::QtAccessibleEventListener(const 
Reference xAccessible,
- QtAccessibleWidget* 
pAccessibleWidget)
-: m_xAccessible(xAccessible)
-, m_pAccessibleWidget(pAccessibleWidget)
+QtAccessibleEventListener::QtAccessibleEventListener(QtAccessibleWidget* 
pAccessibleWidget)
+: m_pAccessibleWidget(pAccessibleWidget)
 {
 }
 
diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx
index 7fa4cd297778..d6370877f449 100644
--- a/vcl/qt5/QtAccessibleWidget.cxx
+++ b/vcl/qt5/QtAccessibleWidget.cxx
@@ -68,8 +68,7 @@ QtAccessibleWidget::QtAccessibleWidget(const 
Reference xAccessible,
 Reference xBroadcaster(xContext, UNO_QUERY);
 if (xBroadcaster.is())
 {
-Reference xListener(
-new QtAccessibleEventListener(xAccessible, this));
+Reference xListener(new 
QtAccessibleEventListener(this));
 xBroadcaster->addAccessibleEventListener(xListener);
 }
 }


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-07-02 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtAccessibleWidget.hxx |9 +
 vcl/qt5/QtAccessibleWidget.cxx |   21 ++---
 2 files changed, 23 insertions(+), 7 deletions(-)

New commits:
commit 3a9d36d49d1fc7bd0b461d0ef1d1cc5a6c3a76dd
Author: Michael Weghorn 
AuthorDate: Sat Jul 2 14:11:34 2022 +0200
Commit: Michael Weghorn 
CommitDate: Sat Jul 2 16:25:07 2022 +0200

qt a11y: Only return actually supported a11y interfaces

Let `QtAccessibleWidget::interface_cast` only
return a pointer to self if the underlying accessible
(`m_xAccessible`)'s context implements the `XAccessible...`
interface needed to have the corresponding `QAccessible...Interface`
methods do anything useful (s.a. the checks at the beginning of
the implementations of the corresponding
`QAccessible...Interface` methods).

This way, the other interfaces (or their AT-SPI equivalents)
are no longer advertised as supported.
(See the corresponding handling of the "GetInterfaces"
AT-SPI method inside of the Qt library [1].)

While at it, also add/adjust the comments indicating what
methods override those from `QAccessibleTable{,Cell}Interface`.

I ran into this when clicking through the LO a11y hierarchy
in the Accerciser tree view and seeing the following warning
in the terminal from which I had started Accerciser, after
clicking on an item that was in no way related to any table
in the first place:

> (accerciser:192270): dbind-WARNING **: 14:05:51.582: 
atspi_dbus_get_property: expected a variant when fetching Caption from 
interface org.a11y.atspi.Table; got (so)

With this change in place, unsupported interfaces are
grayed out in Accerciser's "Interface Viewer" as
expected, rather than being shown as active, but not
displaying any useful data.

[1] 
https://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/accessible/linux/atspiadaptor.cpp?h=6.3.0#n1408

Change-Id: I1edbd451514253392e6b0a9caa6ffef2f789b55c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136782
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtAccessibleWidget.hxx 
b/vcl/inc/qt5/QtAccessibleWidget.hxx
index 102b5658fb28..fdd97b0b407d 100644
--- a/vcl/inc/qt5/QtAccessibleWidget.hxx
+++ b/vcl/inc/qt5/QtAccessibleWidget.hxx
@@ -153,6 +153,15 @@ private:
 css::uno::Reference m_xAccessible;
 css::uno::Reference 
getAccessibleContextImpl() const;
 css::uno::Reference 
getAccessibleTableForParent() const;
+
+template  bool accessibleProvidesInterface() const
+{
+css::uno::Reference xContext
+= getAccessibleContextImpl();
+css::uno::Reference xInterface(xContext, 
css::uno::UNO_QUERY);
+return xInterface.is();
+}
+
 QObject* m_pObject;
 };
 
diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx
index 5e66459ce054..88616a555efd 100644
--- a/vcl/qt5/QtAccessibleWidget.cxx
+++ b/vcl/qt5/QtAccessibleWidget.cxx
@@ -734,17 +734,23 @@ QColor QtAccessibleWidget::backgroundColor() const
 
 void* QtAccessibleWidget::interface_cast(QAccessible::InterfaceType t)
 {
-if (t == QAccessible::ActionInterface)
+if (t == QAccessible::ActionInterface && 
accessibleProvidesInterface())
 return static_cast(this);
-if (t == QAccessible::TextInterface)
+if (t == QAccessible::TextInterface && 
accessibleProvidesInterface())
 return static_cast(this);
-if (t == QAccessible::EditableTextInterface)
+if (t == QAccessible::EditableTextInterface
+&& accessibleProvidesInterface())
 return static_cast(this);
-if (t == QAccessible::ValueInterface)
+if (t == QAccessible::ValueInterface && 
accessibleProvidesInterface())
 return static_cast(this);
 if (t == QAccessible::TableCellInterface)
-return static_cast(this);
-if (t == QAccessible::TableInterface)
+{
+// parent must be a table
+Reference xTable = getAccessibleTableForParent();
+if (xTable.is())
+return static_cast(this);
+}
+if (t == QAccessible::TableInterface && 
accessibleProvidesInterface())
 return static_cast(this);
 return nullptr;
 }
@@ -1164,7 +1170,7 @@ void QtAccessibleWidget::setCurrentValue(const QVariant& 
value)
 xValue->setCurrentValue(Any(value.toDouble()));
 }
 
-// QAccessibleTable
+// QAccessibleTableInterface
 QAccessibleInterface* QtAccessibleWidget::caption() const
 {
 Reference xAc = getAccessibleContextImpl();
@@ -1386,6 +1392,7 @@ bool QtAccessibleWidget::unselectRow(int row)
 return xTableSelection->unselectRow(row);
 }
 
+// QAccessibleTableCellInterface
 QList QtAccessibleWidget::columnHeaderCells() const
 {
 SAL_WARN("vcl.qt", "Unsupported 
QAccessibleTableCellInterface::columnHeaderCells");


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-06-18 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtFrame.hxx  |6 ++
 vcl/qt5/QtFrame.cxx  |4 
 vcl/qt5/QtX11Support.cxx |   12 +++-
 3 files changed, 17 insertions(+), 5 deletions(-)

New commits:
commit e4d23c27288b99c3ed3cfa332ff308b31c01f97d
Author: Michael Weghorn 
AuthorDate: Sat Jun 18 21:11:28 2022 +0200
Commit: Michael Weghorn 
CommitDate: Sun Jun 19 02:09:29 2022 +0200

qt: Fix qt6 build after fbc61e06584ff8e6d9240f8b67be8dc28ecab5b9

Failed like this:

In file included from 
/home/michi/development/git/libreoffice/vcl/qt6/QtX11Support.cxx:10:

/home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtX11Support.cxx:15:10: 
fatal error: QtX11Extras/QX11Info: No such file or directory
   15 | #include 
  |  ^~
compilation terminated.
make[1]: *** 
[/home/michi/development/git/libreoffice/solenv/gbuild/LinkTarget.mk:334: 
/home/michi/development/git/libreoffice/workdir/CxxObject/vcl/qt6/QtX11Support.o]
 Error 1
make[1]: *** Waiting for unfinished jobs
In file included from 
/home/michi/development/git/libreoffice/vcl/qt6/QtFrame.cxx:10:
/home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtFrame.cxx: In 
member function ‘virtual void QtFrame::StartPresentation(bool)’:

/home/michi/development/git/libreoffice/vcl/qt6/../qt5/QtFrame.cxx:746:5: 
error: ‘m_ScreenSaverInhibitor’ was not declared in this scope
  746 | m_ScreenSaverInhibitor.inhibit(bStart, u"presentation", 
bIsX11, aRootWindow, aDisplay);
  | ^~
make[1]: *** 
[/home/michi/development/git/libreoffice/solenv/gbuild/LinkTarget.mk:334: 
/home/michi/development/git/libreoffice/workdir/CxxObject/vcl/qt6/QtFrame.o] 
Error 1
make: *** [Makefile:288: build] Error 2

As mentioned in [1], `QX11Info` has been removed in Qt 6.

The `ScreenSaverInhibitor` related code (except for the `QX11Info` part)
can be used for Qt 6 as well, so adapt the checks in
the header accordingly.

[1] https://www.qt.io/blog/qt-extras-modules-in-qt-6

Co-authored-by: Jan-Marek Glogowski 

Change-Id: Ifd546b4f4210aaf7f09ebaa8c36d2a031763d492
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136091
Reviewed-by: Jan-Marek Glogowski 
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index 562c7d3ba89a..963572ca819b 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -33,7 +33,7 @@
 
 #include 
 
-#if CHECK_QT5_USING_X11
+#if CHECK_ANY_QT_USING_X11
 #include 
 // any better way to get rid of the X11 / Qt type clashes?
 #undef Bool
@@ -101,10 +101,8 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public 
SalFrame
 sal_uInt32 m_nRestoreScreen;
 QRect m_aRestoreGeometry;
 
-#if CHECK_QT5_USING_X11
-ScreenSaverInhibitor m_ScreenSaverInhibitor;
-#endif
 #if CHECK_ANY_QT_USING_X11
+ScreenSaverInhibitor m_ScreenSaverInhibitor;
 ModKeyFlags m_nKeyModifiers;
 #endif
 
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 006ad4a8bfc1..9ccfd8ec5147 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -728,6 +728,7 @@ void QtFrame::ShowFullScreen(bool bFullScreen, sal_Int32 
nScreen)
 
 void QtFrame::StartPresentation(bool bStart)
 {
+#if CHECK_ANY_QT_USING_X11
 // meh - so there's no Qt platform independent solution
 // 
https://forum.qt.io/topic/38504/solved-qdialog-in-fullscreen-disable-os-screensaver
 assert(m_aSystemData.platform != SystemEnvData::Platform::Invalid);
@@ -744,6 +745,9 @@ void QtFrame::StartPresentation(bool bStart)
 #endif
 
 m_ScreenSaverInhibitor.inhibit(bStart, u"presentation", bIsX11, 
aRootWindow, aDisplay);
+#else
+Q_UNUSED(bStart)
+#endif
 }
 
 void QtFrame::SetAlwaysOnTop(bool bOnTop)
diff --git a/vcl/qt5/QtX11Support.cxx b/vcl/qt5/QtX11Support.cxx
index 93f3085ffab3..d6f372fdadf5 100644
--- a/vcl/qt5/QtX11Support.cxx
+++ b/vcl/qt5/QtX11Support.cxx
@@ -12,11 +12,14 @@
 #include 
 
 #include 
-#include 
 
 #include 
 #include 
 
+#if CHECK_QT5_USING_X11
+#include 
+#endif
+
 #if QT5_HAVE_XCB_ICCCM
 #include 
 #endif
@@ -41,16 +44,19 @@ xcb_atom_t QtX11Support::lookupAtom(xcb_connection_t* 
pConn, const char* const s
 
 void QtX11Support::fetchAtoms()
 {
+#if CHECK_QT5_USING_X11
 if (m_bDidAtomLookups)
 return;
 m_bDidAtomLookups = true;
 
 xcb_connection_t* pXcbConn = QX11Info::connection();
 m_nWindowGroupAtom = lookupAtom(pXcbConn, m_sWindowGroupName);
+#endif
 }
 
 void QtX11Support::setApplicationID(const xcb_window_t nWinId, 
std::u16string_view rWMClass)
 {
+#if CHECK_QT5_USING_X11
 OString aResClass = OUStringToOString(rWMClass, RTL_TEXTENCODING_ASCII_US);
 const char* pResClass
 = !aResClass.isEmpty() ? aResClass.getStr() : 
SalGenericSystem::getFrameClassName();
@@ -65,6 +71,10 @@ void 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-06-17 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtAccessibleEventListener.hxx |3 
 vcl/qt5/QtAccessibleEventListener.cxx |  115 +-
 2 files changed, 116 insertions(+), 2 deletions(-)

New commits:
commit 8c3e8af0e60865ec6d38e2117efdb4ed2f10a20c
Author: Michael Weghorn 
AuthorDate: Fri Jun 17 17:29:19 2022 +0200
Commit: Michael Weghorn 
CommitDate: Fri Jun 17 19:30:29 2022 +0200

qt a11y: Forward STATE_CHANGED event as such

Handle `AccessibleEventId::STATE_CHANGED` by
sending a corresponding `QAccessibleStateChangeEvent`.

The previous way of sending a `QAccessible::ForegroundChanged`
event looked rather arbitrary and had no effect in practice,
since that type of event is currently ignored in Qt's AT-SPI adapter
anyway.

At this point in time, the Qt library doesn't forward
changes of all states to the AT-SPI layer. Most notably,
it ignores changes to the focused state.
(Qt itself uses events of type `QAccessible::Focus`
instead of `QAccessibleStateChangeEvent` with the `focused`
state set to notify about focus changes, but that's not exactly the
same, and e.g. causes Orca to ignore some focus changes).
I have submitted a change to Qt to implement
forwarding of `QAccessibleStateChangeEvent`s for the
focused state to the AT-SPI layer, currently awaiting
review. [1]

With that Qt change in place, Orca still ignored these
events in LibreOffice message dialogs, since those
use a11y role `ALERT`, which wasn't previously considered
when trying to retrieve a potential dialog that an
a11y object belonged to.
The corresponding Orca merge request [2] has just been merged.

With these two in place, Orca now announces the focused
button when switching focus using the tab key
e.g. in the "Save document?" dialog when using the qt6 VCL plugin.
(Most other things in the LO UI are still usually not announced.)

For some reason, forwarding changes to state `AccessibleStateType::ACTIVE`
resulted in Orca becoming unresponsive (stop talking) quite quickly.
That needs further analysis, so that state change isn't forwarded
to Qt for now.

[1] https://codereview.qt-project.org/c/qt/qtbase/+/416510
[2] https://gitlab.gnome.org/GNOME/orca/-/merge_requests/127

Change-Id: I81c9a0f5ec8c74f95943d3073bba5b304f995d31
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136057
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtAccessibleEventListener.hxx 
b/vcl/inc/qt5/QtAccessibleEventListener.hxx
index a73f6d31f2f8..1103dc9da598 100644
--- a/vcl/inc/qt5/QtAccessibleEventListener.hxx
+++ b/vcl/inc/qt5/QtAccessibleEventListener.hxx
@@ -33,6 +33,9 @@ public:
 private:
 css::uno::Reference m_xAccessible;
 QtAccessibleWidget* m_pAccessibleWidget;
+
+static void HandleStateChangedEvent(QAccessibleInterface* 
pQAccessibleInterface,
+const 
css::accessibility::AccessibleEventObject& rEvent);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtAccessibleEventListener.cxx 
b/vcl/qt5/QtAccessibleEventListener.cxx
index 515584351c74..ee9acc651599 100644
--- a/vcl/qt5/QtAccessibleEventListener.cxx
+++ b/vcl/qt5/QtAccessibleEventListener.cxx
@@ -23,6 +23,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -41,6 +42,117 @@ QtAccessibleEventListener::QtAccessibleEventListener(const 
Reference>= nState;
+// States in 'QAccessibleStateChangeEvent' indicate what states have 
changed, so if e.g.
+// an object loses focus (not just if it gains it), 'focus' state needs to 
be set to 'true',
+// so retrieve the old/previous value from the event if necessary.
+if (nState == AccessibleStateType::INVALID)
+rEvent.OldValue >>= nState;
+
+switch (nState)
+{
+case AccessibleStateType::ACTIVE:
+// ignore for now, since it somehow causes Orca to become 
unresponsive quite quickly
+// TODO: analyze further and fix root cause
+/*
+aState.active = true;
+break;
+*/
+return;
+case AccessibleStateType::BUSY:
+aState.busy = true;
+break;
+case AccessibleStateType::CHECKED:
+aState.checked = true;
+break;
+case AccessibleStateType::COLLAPSE:
+aState.collapsed = true;
+break;
+case AccessibleStateType::DEFAULT:
+aState.defaultButton = true;
+break;
+case AccessibleStateType::ENABLED:
+aState.disabled = true;
+break;
+case AccessibleStateType::EDITABLE:
+aState.editable = true;
+break;
+case AccessibleStateType::EXPANDABLE:
+aState.expandable = true;
+break;
+case AccessibleStateType::EXPANDED:
+   

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-06-17 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtWidget.hxx |   24 +++-
 vcl/qt5/QtWidget.cxx |   25 -
 2 files changed, 15 insertions(+), 34 deletions(-)

New commits:
commit 393c9f736b10d1ea82979e9c2c43c8f91ba5831d
Author: Jan-Marek Glogowski 
AuthorDate: Tue Apr 19 16:00:31 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Fri Jun 17 17:27:16 2022 +0200

Qt use QEvent::type to handle the event correctly

No need for an extra function parameter.

Change-Id: Iedb949b45ad3f161121110e2db2132b6c3cb706e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135894
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx
index e644e7f70cd9..e61357198027 100644
--- a/vcl/inc/qt5/QtWidget.hxx
+++ b/vcl/inc/qt5/QtWidget.hxx
@@ -42,17 +42,10 @@ class QtWidget : public QWidget
 int m_nDeltaX;
 int m_nDeltaY;
 
-enum class ButtonKeyState
-{
-Pressed,
-Released
-};
-
 static void commitText(QtFrame&, const QString& aText);
 static void deleteReplacementText(QtFrame& rFrame, int nReplacementStart,
   int nReplacementLength);
-static bool handleKeyEvent(QtFrame&, const QWidget&, QKeyEvent*, const 
ButtonKeyState);
-static void handleMouseButtonEvent(const QtFrame&, const QMouseEvent*, 
const ButtonKeyState);
+static bool handleKeyEvent(QtFrame&, const QWidget&, QKeyEvent*);
 static void handleMouseEnterLeaveEvents(const QtFrame&, QEvent*);
 static void fillSalAbstractMouseEvent(const QtFrame& rFrame, const 
QInputEvent* pQEvent,
   const QPoint& rPos, Qt::MouseButtons 
eButtons, int nWidth,
@@ -101,23 +94,12 @@ public:
 // key events might be propagated further down => call base on false
 static inline bool handleKeyReleaseEvent(QtFrame&, const QWidget&, 
QKeyEvent*);
 // mouse events are always accepted
-static inline void handleMousePressEvent(const QtFrame&, const 
QMouseEvent*);
-static inline void handleMouseReleaseEvent(const QtFrame&, const 
QMouseEvent*);
+static void handleMouseButtonEvent(const QtFrame&, const QMouseEvent*);
 };
 
 bool QtWidget::handleKeyReleaseEvent(QtFrame& rFrame, const QWidget& rWidget, 
QKeyEvent* pEvent)
 {
-return handleKeyEvent(rFrame, rWidget, pEvent, ButtonKeyState::Released);
-}
-
-void QtWidget::handleMousePressEvent(const QtFrame& rFrame, const QMouseEvent* 
pEvent)
-{
-handleMouseButtonEvent(rFrame, pEvent, ButtonKeyState::Pressed);
-}
-
-void QtWidget::handleMouseReleaseEvent(const QtFrame& rFrame, const 
QMouseEvent* pEvent)
-{
-handleMouseButtonEvent(rFrame, pEvent, ButtonKeyState::Released);
+return handleKeyEvent(rFrame, rWidget, pEvent);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx
index 5c6fc002ac22..e26e1e3aee1f 100644
--- a/vcl/qt5/QtWidget.cxx
+++ b/vcl/qt5/QtWidget.cxx
@@ -153,8 +153,7 @@ void QtWidget::fillSalAbstractMouseEvent(const QtFrame& 
rFrame, const QInputEven
 #define FILL_SAME(rFrame, nWidth)  
\
 fillSalAbstractMouseEvent(rFrame, pEvent, pEvent->pos(), 
pEvent->buttons(), nWidth, aEvent)
 
-void QtWidget::handleMouseButtonEvent(const QtFrame& rFrame, const 
QMouseEvent* pEvent,
-  const ButtonKeyState eState)
+void QtWidget::handleMouseButtonEvent(const QtFrame& rFrame, const 
QMouseEvent* pEvent)
 {
 SalMouseEvent aEvent;
 FILL_SAME(rFrame, rFrame.GetQWidget()->width());
@@ -175,7 +174,7 @@ void QtWidget::handleMouseButtonEvent(const QtFrame& 
rFrame, const QMouseEvent*
 }
 
 SalEvent nEventType;
-if (eState == ButtonKeyState::Pressed)
+if (pEvent->type() == QEvent::MouseButtonPress)
 nEventType = SalEvent::MouseButtonDown;
 else
 nEventType = SalEvent::MouseButtonUp;
@@ -184,13 +183,13 @@ void QtWidget::handleMouseButtonEvent(const QtFrame& 
rFrame, const QMouseEvent*
 
 void QtWidget::mousePressEvent(QMouseEvent* pEvent)
 {
-handleMousePressEvent(m_rFrame, pEvent);
+handleMouseButtonEvent(m_rFrame, pEvent);
 if (m_rFrame.isPopup()
 && !geometry().translated(geometry().topLeft() * 
-1).contains(pEvent->pos()))
 closePopup();
 }
 
-void QtWidget::mouseReleaseEvent(QMouseEvent* pEvent) { 
handleMouseReleaseEvent(m_rFrame, pEvent); }
+void QtWidget::mouseReleaseEvent(QMouseEvent* pEvent) { 
handleMouseButtonEvent(m_rFrame, pEvent); }
 
 void QtWidget::mouseMoveEvent(QMouseEvent* pEvent)
 {
@@ -514,11 +513,12 @@ void QtWidget::deleteReplacementText(QtFrame& rFrame, int 
nReplacementStart, int
 rFrame.CallCallback(SalEvent::DeleteSurroundingTextRequest, );
 }
 
-bool QtWidget::handleKeyEvent(QtFrame& rFrame, const QWidget& rWidget, 
QKeyEvent* pEvent,
-  const ButtonKeyState eState)
+bool 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-05-28 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtWidget.hxx |2 ++
 vcl/qt5/QtWidget.cxx |   39 +--
 2 files changed, 39 insertions(+), 2 deletions(-)

New commits:
commit 217ca9c79d75912df3fb735def4b64b0a7284e30
Author: Michael Weghorn 
AuthorDate: Sat May 28 10:51:53 2022 +0200
Commit: Michael Weghorn 
CommitDate: Sat May 28 16:09:00 2022 +0200

tdf#149255 qt: Implement deletion/"swallowing" for IM replacement

This implements deletion of the text specified by the
`replacementStart()` and `replacementLength()` of the
`QInputMethodEvent*` received in `QtWidget::inputMethodEvent`.

Quoting from the `QInputMethodEvent` doc [1]:

> When receiving an input method event, the text widget has to performs
> the following steps:
>
> 1. If the widget has selected text, the selected text should
>get removed.
> 2. Remove the text starting at replacementStart() with length
>replacementLength() and replace it by the commitString().
> [...]

This implementation is sufficient for the scenario described in tdf#149255,
but I didn't test any more complex scenarios, like one where text is 
selected.
(My current knowledge of input methods is too limited to be able to do
more extensive testing without first spending time to get deeper into
the topic.)

The gtk3 implementation in
`GtkSalFrame::IMHandler::signalIMDeleteSurrounding`
was very helpful to get an impression of what needs to be done.

Since the documentation for `QInputMethodEvent::replacementLength()`
talks about "number of characters", I suspect that conversion
to UTF-16 code units is needed just the same way as it is for the
gtk3 case and this therefore calls
`SalFrame::CalcDeleteSurroundingSelection` the same way.
However, this part is untested, since it is not relevant
for the tested scenario (where each of the characters is represented
in a single UTF-16 code unit).

[1] https://doc.qt.io/qt-5/qinputmethodevent.html

Change-Id: I2a34e58067e253c39dbd87905943134bdfa4ea27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134855
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx
index 8f7f6cc319e1..e644e7f70cd9 100644
--- a/vcl/inc/qt5/QtWidget.hxx
+++ b/vcl/inc/qt5/QtWidget.hxx
@@ -49,6 +49,8 @@ class QtWidget : public QWidget
 };
 
 static void commitText(QtFrame&, const QString& aText);
+static void deleteReplacementText(QtFrame& rFrame, int nReplacementStart,
+  int nReplacementLength);
 static bool handleKeyEvent(QtFrame&, const QWidget&, QKeyEvent*, const 
ButtonKeyState);
 static void handleMouseButtonEvent(const QtFrame&, const QMouseEvent*, 
const ButtonKeyState);
 static void handleMouseEnterLeaveEvents(const QtFrame&, QEvent*);
diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx
index a9484f0b2531..74adcc4e974c 100644
--- a/vcl/qt5/QtWidget.cxx
+++ b/vcl/qt5/QtWidget.cxx
@@ -493,6 +493,33 @@ void QtWidget::commitText(QtFrame& rFrame, const QString& 
aText)
 rFrame.CallCallback(SalEvent::EndExtTextInput, nullptr);
 }
 
+void QtWidget::deleteReplacementText(QtFrame& rFrame, int nReplacementStart, 
int nReplacementLength)
+{
+// get the surrounding text
+SolarMutexGuard aGuard;
+SalSurroundingTextRequestEvent aSurroundingTextEvt;
+aSurroundingTextEvt.maText.clear();
+aSurroundingTextEvt.mnStart = aSurroundingTextEvt.mnEnd = 0;
+rFrame.CallCallback(SalEvent::SurroundingTextRequest, 
);
+
+// Turn nReplacementStart, nReplacementLength into a UTF-16 selection
+const Selection aSelection = SalFrame::CalcDeleteSurroundingSelection(
+aSurroundingTextEvt.maText, aSurroundingTextEvt.mnStart, 
nReplacementStart,
+nReplacementLength);
+
+const Selection aInvalid(SAL_MAX_UINT32, SAL_MAX_UINT32);
+if (aSelection == aInvalid)
+{
+SAL_WARN("vcl.qt", "Invalid selection when deleting IM replacement 
text");
+return;
+}
+
+SalSurroundingTextSelectionChangeEvent aEvt;
+aEvt.mnStart = aSelection.Min();
+aEvt.mnEnd = aSelection.Max();
+rFrame.CallCallback(SalEvent::DeleteSurroundingTextRequest, );
+}
+
 bool QtWidget::handleKeyEvent(QtFrame& rFrame, const QWidget& rWidget, 
QKeyEvent* pEvent,
   const ButtonKeyState eState)
 {
@@ -724,8 +751,16 @@ static ExtTextInputAttr 
lcl_MapUnderlineStyle(QTextCharFormat::UnderlineStyle us
 
 void QtWidget::inputMethodEvent(QInputMethodEvent* pEvent)
 {
-if (!pEvent->commitString().isEmpty())
-commitText(m_rFrame, pEvent->commitString());
+const bool bHasCommitText = !pEvent->commitString().isEmpty();
+const int nReplacementLength = pEvent->replacementLength();
+
+if (nReplacementLength > 0 || bHasCommitText)
+{
+if 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-05-28 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtMenu.hxx |   15 +++
 vcl/qt5/QtMenu.cxx |  190 +
 vcl/qt5/QtWidget.cxx   |3 
 3 files changed, 191 insertions(+), 17 deletions(-)

New commits:
commit 9ea767cb568cef1b142190d2adb0e301baa382e2
Author: Jan-Marek Glogowski 
AuthorDate: Thu May 26 13:48:38 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Sat May 28 15:37:31 2022 +0200

tdf#132350 Qt implement SalMenu button interface

This turned out much more complicated then expected:

1. The QMenuBar needs explicit adjustSize() calls to position a
   changed corner widget (or a resize...).
2. The adjustSize() results in a temporary, minimal QMenuBar
   layout, so GetMenuBarButtonRectPixel needs to account for the
   extra space itself, instead of just a mapTo call.
3. I didn't know, that you can't add shown widgets to a layout,
   but must call show() after add / insert, otherwise they are
   ignored in the layout (but show up as the layout items) and
   are painted in strange positions.

This also includes the transparency flags for our QtWidget, so the
updater "bubble window" is properly alpha-masked / shaped.

And this maybe has too many asserts...

Change-Id: I86a708175e9f9be786f5dc1810ae0197a0d3fc39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135021
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/QtMenu.hxx b/vcl/inc/qt5/QtMenu.hxx
index 11f3f00c5aa6..a1b77687ce86 100644
--- a/vcl/inc/qt5/QtMenu.hxx
+++ b/vcl/inc/qt5/QtMenu.hxx
@@ -16,11 +16,13 @@
 #include 
 
 class MenuItemList;
+class QAbstractButton;
 class QAction;
 class QActionGroup;
-class QPushButton;
+class QButtonGroup;
 class QMenu;
 class QMenuBar;
+class QPushButton;
 class QtMenuItem;
 class QtFrame;
 
@@ -49,6 +51,7 @@ private:
 std::unique_ptr mpOwnedQMenu;
 // pointer to QMenu owned by the corresponding QtMenuItem or self (-> 
mpOwnedQMenu)
 QMenu* mpQMenu;
+QButtonGroup* m_pButtonGroup;
 
 void DoFullMenuUpdate(Menu* pMenuBar);
 static void NativeItemText(OUString& rItemText);
@@ -58,7 +61,10 @@ private:
 void ReinitializeActionGroup(unsigned nPos);
 void ResetAllActionGroups();
 void UpdateActionGroupItem(const QtMenuItem* pSalMenuItem);
-bool validateQMenuBar();
+bool validateQMenuBar() const;
+QPushButton* ImplAddMenuBarButton(const QIcon& rIcon, const QString& 
rToolTip, int nId);
+void ImplRemoveMenuBarButton(int nId);
+void adjustButtonSizes();
 
 public:
 QtMenu(bool bMenuBar);
@@ -86,6 +92,10 @@ public:
 const vcl::KeyCode& rKeyCode, const OUString& 
rKeyName) override;
 virtual void GetSystemMenuData(SystemMenuData* pData) override;
 virtual void ShowCloseButton(bool bShow) override;
+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; }
@@ -97,6 +107,7 @@ private slots:
 static void slotMenuAboutToShow(QtMenuItem* pQItem);
 static void slotMenuAboutToHide(QtMenuItem* pQItem);
 void slotCloseDocument();
+void slotMenuBarButtonClicked(QAbstractButton*);
 };
 
 class QtMenuItem : public SalMenuItem
diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx
index fd38a038..ccd2eb431f7e 100644
--- a/vcl/qt5/QtMenu.cxx
+++ b/vcl/qt5/QtMenu.cxx
@@ -20,8 +20,11 @@
 #include 
 #endif
 
+#include 
+#include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -33,6 +36,18 @@
 #include 
 #include 
 
+// LO SalMenuButtonItem::mnId is sal_uInt16, so we go with -2, as -1 has a 
special meaning as automatic id
+constexpr int CLOSE_BUTTON_ID = -2;
+const QString gButtonGroupKey("QtMenu::ButtonGroup");
+
+static inline void lcl_force_menubar_layout_update(QMenuBar& rMenuBar)
+{
+// just exists as a function to not comment it everywhere: forces 
reposition of the
+// corner widget after its layout changes, which will otherwise just 
happen on resize.
+// it unfortunatly has additional side effects; see 
QtMenu::GetMenuBarButtonRectPixel.
+rMenuBar.adjustSize();
+}
+
 QtMenu::QtMenu(bool bMenuBar)
 : mpVCLMenu(nullptr)
 , mpParentSalMenu(nullptr)
@@ -40,6 +55,7 @@ QtMenu::QtMenu(bool bMenuBar)
 , mbMenuBar(bMenuBar)
 , mpQMenuBar(nullptr)
 , mpQMenu(nullptr)
+, m_pButtonGroup(nullptr)
 {
 }
 
@@ -430,9 +446,19 @@ void QtMenu::SetFrame(const SalFrame* pFrame)
 mpQMenuBar = new QMenuBar();
 pMainWindow->setMenuBar(mpQMenuBar);
 
-QPushButton* pButton = 
static_cast(mpQMenuBar->cornerWidget(Qt::TopRightCorner));
-if (pButton)
-connect(pButton, 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-05-25 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtObject.hxx |   25 ++
 vcl/qt5/QtObject.cxx |   65 ++-
 2 files changed, 57 insertions(+), 33 deletions(-)

New commits:
commit 4366e0605214260e55a937173b0c2e02225dc843
Author: Jan-Marek Glogowski 
AuthorDate: Tue May 24 11:34:59 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Wed May 25 13:53:46 2022 +0200

tdf#148864 Qt switch QtObjectWindow to QWidget

... and therefore rename it to QtObjectWidget

Replacement of the QWidget with QWindow originally happened in
commit 56b19f9a814ae5a39ed760ee542d715493cd0bf3 ("tdf#121247,
tdf#121266 KDE5: Add basic support for OpenGL"), but that
unfortunately has a very sparce commit message with no reason
for this change. Then the code was further complicated in commit
25edbded9946801effd117b9c46de0f8b4bc5632 ("tdf#125517 Qt5
implement a minimal Qt5ObjectWindow") and a few follow up fixes
to restore input and focus handling.

But appearingly all this QWindow handling isn't necessary and just
returning to a QWidget based class fixes the problems with the
video overlay (AKA QWidget::winId()) and video playback for good.

The OpenGL Impress transition (Fade) mentioned in the original
tdf#121266 bug still works.

This also adds the previously missing SolarMutexGuard to all the
overridden QtObjectWidget functions, which call the SalObject's
Callback function. I accidently triggered a DBG_TESTSOLARMUTEX
crashing Impress while debugging this.

Change-Id: Ia22cabfd4f3585dc7fa3f9f18a913c5bd1987dd8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134864
Reviewed-by: Michael Weghorn 
Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtObject.hxx b/vcl/inc/qt5/QtObject.hxx
index 328946e4388e..bc5a8e584b8f 100644
--- a/vcl/inc/qt5/QtObject.hxx
+++ b/vcl/inc/qt5/QtObject.hxx
@@ -24,10 +24,11 @@
 
 #include 
 #include 
-#include 
+#include 
 
 class QtFrame;
-class QWidget;
+class QtObjectWidget;
+class QWindow;
 
 class QtObject final : public QObject, public SalObject
 {
@@ -35,17 +36,18 @@ class QtObject final : public QObject, public SalObject
 
 SystemEnvData m_aSystemData;
 QtFrame* m_pParent;
-QWidget* m_pQWidget; // main widget, container
-QWindow* m_pQWindow; // contained window, used for opengl rendering
+QtObjectWidget* m_pQWidget;
 QRegion m_pRegion;
+bool m_bForwardKey;
 
 public:
 QtObject(QtFrame* pParent, bool bShow);
 ~QtObject() override;
 
 QtFrame* frame() const { return m_pParent; }
-QWidget* widget() const { return m_pQWidget; }
-QWindow* windowHandle() const { return m_pQWindow; }
+inline QWidget* widget() const;
+QWindow* windowHandle() const;
+bool forwardKey() const { return m_bForwardKey; }
 
 virtual void ResetClipRegion() override;
 virtual void BeginSetClipRegion(sal_uInt32 nRects) override;
@@ -60,22 +62,25 @@ public:
 virtual void SetForwardKey(bool bEnable) override;
 
 virtual const SystemEnvData* GetSystemData() const override { return 
_aSystemData; }
+
+virtual void Reparent(SalFrame* pFrame) override;
 };
 
-class QtObjectWindow final : public QWindow
+class QtObjectWidget final : public QWidget
 {
 QtObject& m_rParent;
 
-bool event(QEvent*) override;
 void focusInEvent(QFocusEvent*) override;
 void focusOutEvent(QFocusEvent*) override;
 void mousePressEvent(QMouseEvent*) override;
 void mouseReleaseEvent(QMouseEvent*) override;
-// keyPressEvent(QKeyEvent*) is handled via event(QEvent*); see comment in 
QtWidget::event
+void keyPressEvent(QKeyEvent*) override;
 void keyReleaseEvent(QKeyEvent*) override;
 
 public:
-explicit QtObjectWindow(QtObject& rParent);
+explicit QtObjectWidget(QtObject& rParent);
 };
 
+QWidget* QtObject::widget() const { return m_pQWidget; }
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtObject.cxx b/vcl/qt5/QtObject.cxx
index 569586a0dc98..fbdc8e9b625e 100644
--- a/vcl/qt5/QtObject.cxx
+++ b/vcl/qt5/QtObject.cxx
@@ -24,20 +24,18 @@
 #include 
 
 #include 
+#include 
+#include 
 
 QtObject::QtObject(QtFrame* pParent, bool bShow)
 : m_pParent(pParent)
 , m_pQWidget(nullptr)
-, m_pQWindow(nullptr)
+, m_bForwardKey(false)
 {
 if (!m_pParent || !pParent->GetQWidget())
 return;
 
-m_pQWindow = new QtObjectWindow(*this);
-m_pQWidget = QWidget::createWindowContainer(m_pQWindow, 
pParent->GetQWidget());
-m_pQWidget->setAttribute(Qt::WA_NoSystemBackground);
-connect(m_pQWidget, ::destroyed, this, [this]() { m_pQWidget = 
nullptr; });
-
+m_pQWidget = new QtObjectWidget(*this);
 if (bShow)
 m_pQWidget->show();
 
@@ -53,6 +51,11 @@ QtObject::~QtObject()
 }
 }
 
+QWindow* QtObject::windowHandle() const
+{
+return m_pQWidget ? m_pQWidget->windowHandle() : nullptr;
+}
+
 void QtObject::ResetClipRegion()
 {
 if 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-04-21 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtInstance.hxx |6 ++
 vcl/inc/qt5/QtWidget.hxx   |1 +
 vcl/qt5/QtInstance.cxx |7 +++
 vcl/qt5/QtWidget.cxx   |   15 +++
 4 files changed, 25 insertions(+), 4 deletions(-)

New commits:
commit 347622a98f512dae709f938a85498dcdcf9f225a
Author: Jan-Marek Glogowski 
AuthorDate: Thu Apr 21 10:56:42 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Thu Apr 21 14:02:20 2022 +0200

tdf#148699 Qt track the active / shown popup

I have no idea, if there can be multiple active popups in LO in
some way. There can be multiple FloatingWindow and gtk does count
them in m_nFloats... There is a whole lot going on in gtk3 related
to isFloatGrabWindow(), with "funny" comments like:

// FIXME: find out who the hell steals the focus from our frame

So this goes with some "optimistic" approach: there is just one
active popup, so we can track it in QtInstance. It WFM...

Change-Id: I9778587696e1ad9e641dba4f102e2e921266eee6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133249
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx
index 2d246c0bd92d..df6c4ec5af86 100644
--- a/vcl/inc/qt5/QtInstance.hxx
+++ b/vcl/inc/qt5/QtInstance.hxx
@@ -35,6 +35,7 @@
 
 #include "QtFilePicker.hxx"
 
+class QtFrame;
 class QtTimer;
 
 class QApplication;
@@ -67,6 +68,8 @@ class VCLPLUG_QT_PUBLIC QtInstance : public QObject,
 Timer m_aUpdateStyleTimer;
 bool m_bUpdateFonts;
 
+QtFrame* m_pActivePopup;
+
 DECL_DLLPRIVATE_LINK(updateStyleHdl, Timer*, void);
 void AfterAppInit() override;
 
@@ -177,6 +180,9 @@ public:
 
 bool DoExecute(int& nExitCode) override;
 void DoQuit() override;
+
+QtFrame* activePopup() const { return m_pActivePopup; }
+void setActivePopup(QtFrame*);
 };
 
 inline QtInstance* GetQtInstance() { return 
static_cast(GetSalInstance()); }
diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx
index 4a40589b16ba..8f7f6cc319e1 100644
--- a/vcl/inc/qt5/QtWidget.hxx
+++ b/vcl/inc/qt5/QtWidget.hxx
@@ -73,6 +73,7 @@ class QtWidget : public QWidget
 virtual void paintEvent(QPaintEvent*) override;
 virtual void resizeEvent(QResizeEvent*) override;
 virtual void showEvent(QShowEvent*) override;
+virtual void hideEvent(QHideEvent*) override;
 virtual void wheelEvent(QWheelEvent*) override;
 virtual void closeEvent(QCloseEvent*) override;
 virtual void changeEvent(QEvent*) override;
diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx
index a52f6529c3bc..5522ea15c31a 100644
--- a/vcl/qt5/QtInstance.cxx
+++ b/vcl/qt5/QtInstance.cxx
@@ -225,6 +225,7 @@ QtInstance::QtInstance(std::unique_ptr& 
pQApp, bool bUseCairo)
 , m_pQApplication(std::move(pQApp))
 , m_aUpdateStyleTimer("vcl::qt5 m_aUpdateStyleTimer")
 , m_bUpdateFonts(false)
+, m_pActivePopup(nullptr)
 {
 ImplSVData* pSVData = ImplGetSVData();
 const OUString sToolkit = "qt" + OUString::number(QT_VERSION_MAJOR);
@@ -740,6 +741,12 @@ void QtInstance::DoQuit()
 QApplication::quit();
 }
 
+void QtInstance::setActivePopup(QtFrame* pFrame)
+{
+assert(!pFrame || pFrame->isPopup());
+m_pActivePopup = pFrame;
+}
+
 extern "C" {
 VCLPLUG_QT_PUBLIC SalInstance* create_SalInstance()
 {
diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx
index 235e85103d50..04a3af5dac23 100644
--- a/vcl/qt5/QtWidget.cxx
+++ b/vcl/qt5/QtWidget.cxx
@@ -316,9 +316,17 @@ void QtWidget::showEvent(QShowEvent*)
 // sequence from QtFrame::SetModal, if the frame was already set visible,
 // resulting in a hidden / unmapped window
 SalPaintEvent aPaintEvt(0, 0, aSize.width(), aSize.height());
+if (m_rFrame.isPopup())
+GetQtInstance()->setActivePopup(_rFrame);
 m_rFrame.CallCallback(SalEvent::Paint, );
 }
 
+void QtWidget::hideEvent(QHideEvent*)
+{
+if (m_rFrame.isPopup() && GetQtInstance()->activePopup() == _rFrame)
+GetQtInstance()->setActivePopup(nullptr);
+}
+
 void QtWidget::closeEvent(QCloseEvent* /*pEvent*/)
 {
 m_rFrame.CallCallback(SalEvent::Close, nullptr);
@@ -627,11 +635,10 @@ bool QtWidget::handleEvent(QtFrame& rFrame, QWidget& 
rWidget, QEvent* pEvent)
 }
 else if (pEvent->type() == QEvent::ToolTip)
 {
-// Qt's POV on focus is wrong for our fake popup windows, so check 
LO's state.
+// Qt's POV on the active popup is wrong due to our fake popup, so 
check LO's state.
 // Otherwise Qt will continue handling ToolTip events from the 
"parent" window.
-const vcl::Window* pFocusWin = Application::GetFocusWindow();
-if (!rFrame.m_aTooltipText.isEmpty() && pFocusWin
-&& pFocusWin->GetFrameWindow() == rFrame.GetWindow())
+const QtFrame* pPopupFrame = GetQtInstance()->activePopup();
+if (!rFrame.m_aTooltipText.isEmpty() && (!pPopupFrame || pPopupFrame 
== ))
 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-04-20 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtWidget.hxx |4 
 vcl/qt5/QtWidget.cxx |9 -
 2 files changed, 12 insertions(+), 1 deletion(-)

New commits:
commit 5d56255c22c79b72c1cedb48cfe0a200f89bdc66
Author: Michael Weghorn 
AuthorDate: Thu Apr 21 05:37:30 2022 +0200
Commit: Michael Weghorn 
CommitDate: Thu Apr 21 06:41:29 2022 +0200

qt6: Fix build (QtWidget::enterEvent)

In Qt 6, `QWidget::enterEvent` takes a
`QEnterEvent*` param.

An override for `QtWidget` was added in

commit dc886bc6de2c0061a840bea2426663c3be2ecd26
Date:   Tue Apr 19 16:03:56 2022 +0200

tdf#140463 Qt handle mouse enter+leave events

Change-Id: I47579ce6686da321533afcef2e4436e315901059
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133235
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx
index 2ebe83fcbae1..4a40589b16ba 100644
--- a/vcl/inc/qt5/QtWidget.hxx
+++ b/vcl/inc/qt5/QtWidget.hxx
@@ -77,7 +77,11 @@ class QtWidget : public QWidget
 virtual void closeEvent(QCloseEvent*) override;
 virtual void changeEvent(QEvent*) override;
 virtual void leaveEvent(QEvent*) override;
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+virtual void enterEvent(QEnterEvent*) override;
+#else
 virtual void enterEvent(QEvent*) override;
+#endif
 
 void inputMethodEvent(QInputMethodEvent*) override;
 QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx
index 2ac27548ac6a..235e85103d50 100644
--- a/vcl/qt5/QtWidget.cxx
+++ b/vcl/qt5/QtWidget.cxx
@@ -233,7 +233,14 @@ void QtWidget::handleMouseEnterLeaveEvents(const QtFrame& 
rFrame, QEvent* pQEven
 
 void QtWidget::leaveEvent(QEvent* pEvent) { 
handleMouseEnterLeaveEvents(m_rFrame, pEvent); }
 
-void QtWidget::enterEvent(QEvent* pEvent) { 
handleMouseEnterLeaveEvents(m_rFrame, pEvent); }
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+void QtWidget::enterEvent(QEnterEvent* pEvent)
+#else
+void QtWidget::enterEvent(QEvent* pEvent)
+#endif
+{
+handleMouseEnterLeaveEvents(m_rFrame, pEvent);
+}
 
 void QtWidget::wheelEvent(QWheelEvent* pEvent)
 {


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-04-20 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtWidget.hxx |3 +++
 vcl/qt5/QtWidget.cxx |   28 
 2 files changed, 31 insertions(+)

New commits:
commit dc886bc6de2c0061a840bea2426663c3be2ecd26
Author: Jan-Marek Glogowski 
AuthorDate: Tue Apr 19 16:03:56 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Wed Apr 20 19:37:41 2022 +0200

tdf#140463 Qt handle mouse enter+leave events

Currently just implemented for the QtWidget, but still as a static
function, so it may be used for QtObject at some point too.

But there is no (mouse) enter or leave event function in QWindow,
so no way to handle these there. And since we can't modify the
returned QWidget from QWidget::createWindowContainer, the only way
would be to expand the static QtWidget::handleEvent used by
QtObjectWindow::event ... if it's actually needed at some point.

Change-Id: If9009e5dfca508acd1e702df1a17eb8ad7c29690
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133190
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx
index 878c8b1229ce..2ebe83fcbae1 100644
--- a/vcl/inc/qt5/QtWidget.hxx
+++ b/vcl/inc/qt5/QtWidget.hxx
@@ -51,6 +51,7 @@ class QtWidget : public QWidget
 static void commitText(QtFrame&, const QString& aText);
 static bool handleKeyEvent(QtFrame&, const QWidget&, QKeyEvent*, const 
ButtonKeyState);
 static void handleMouseButtonEvent(const QtFrame&, const QMouseEvent*, 
const ButtonKeyState);
+static void handleMouseEnterLeaveEvents(const QtFrame&, QEvent*);
 static void fillSalAbstractMouseEvent(const QtFrame& rFrame, const 
QInputEvent* pQEvent,
   const QPoint& rPos, Qt::MouseButtons 
eButtons, int nWidth,
   SalAbstractMouseEvent& aSalEvent);
@@ -75,6 +76,8 @@ class QtWidget : public QWidget
 virtual void wheelEvent(QWheelEvent*) override;
 virtual void closeEvent(QCloseEvent*) override;
 virtual void changeEvent(QEvent*) override;
+virtual void leaveEvent(QEvent*) override;
+virtual void enterEvent(QEvent*) override;
 
 void inputMethodEvent(QInputMethodEvent*) override;
 QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx
index 33320c577f94..2ac27548ac6a 100644
--- a/vcl/qt5/QtWidget.cxx
+++ b/vcl/qt5/QtWidget.cxx
@@ -207,6 +207,34 @@ void QtWidget::mouseMoveEvent(QMouseEvent* pEvent)
 pEvent->accept();
 }
 
+void QtWidget::handleMouseEnterLeaveEvents(const QtFrame& rFrame, QEvent* 
pQEvent)
+{
+const qreal fRatio = rFrame.devicePixelRatioF();
+const QWidget* pWidget = rFrame.GetQWidget();
+const Point aPos = toPoint(pWidget->mapFromGlobal(QCursor::pos()) * 
fRatio);
+
+SalMouseEvent aEvent;
+aEvent.mnX
+= QGuiApplication::isLeftToRight() ? aPos.X() : round(pWidget->width() 
* fRatio) - aPos.X();
+aEvent.mnY = aPos.Y();
+aEvent.mnTime = 0;
+aEvent.mnButton = 0;
+aEvent.mnCode = GetKeyModCode(QGuiApplication::keyboardModifiers())
+| GetMouseModCode(QGuiApplication::mouseButtons());
+
+SalEvent nEventType;
+if (pQEvent->type() == QEvent::Enter)
+nEventType = SalEvent::MouseMove;
+else
+nEventType = SalEvent::MouseLeave;
+rFrame.CallCallback(nEventType, );
+pQEvent->accept();
+}
+
+void QtWidget::leaveEvent(QEvent* pEvent) { 
handleMouseEnterLeaveEvents(m_rFrame, pEvent); }
+
+void QtWidget::enterEvent(QEvent* pEvent) { 
handleMouseEnterLeaveEvents(m_rFrame, pEvent); }
+
 void QtWidget::wheelEvent(QWheelEvent* pEvent)
 {
 SalWheelMouseEvent aEvent;


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-04-12 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtFrame.hxx  |3 +++
 vcl/inc/qt5/QtWidget.hxx |2 +-
 vcl/qt5/QtFrame.cxx  |8 +++-
 vcl/qt5/QtWidget.cxx |   19 ++-
 4 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit af6dd54d53eee0d0de1164bff0a77c6b433b3935
Author: Jan-Marek Glogowski 
AuthorDate: Tue Apr 12 00:29:56 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Tue Apr 12 14:09:00 2022 +0200

tdf#148115 Qt handle tooltips via event loop

Instead of calling QToolTip::showText directly from LO, this
defers showing the tooltip to the QEvent processing, which takes
the tooltip timeouts into account. So tooltips are shown with
a slight delay, therefore they happen less fast on mouse move,
reducing / avoiding artifacts of fast changing windows.

This unfortunately comes with yet an other hack in the area of
our fake popup windows...

New handling is based on the code of the Qt Tool Tips example.

Change-Id: I42634ad36dd12171c30f52f07a02a88d3c48a718
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132841
Reviewed-by: Michael Weghorn 
Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index a873cec76ad6..2d7c5718d6cf 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -110,6 +110,9 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public 
SalFrame
 
 LanguageType m_nInputLanguage;
 
+OUString m_aTooltipText;
+QRect m_aTooltipArea;
+
 void SetDefaultPos();
 Size CalcDefaultSize();
 void SetDefaultSize();
diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx
index 575cef11014f..878c8b1229ce 100644
--- a/vcl/inc/qt5/QtWidget.hxx
+++ b/vcl/inc/qt5/QtWidget.hxx
@@ -87,7 +87,7 @@ public:
 void endExtTextInput();
 void fakeResize();
 
-static bool handleEvent(QtFrame&, const QWidget&, QEvent*);
+static bool handleEvent(QtFrame&, QWidget&, QEvent*);
 // key events might be propagated further down => call base on false
 static inline bool handleKeyReleaseEvent(QtFrame&, const QWidget&, 
QKeyEvent*);
 // mouse events are always accepted
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 91361311d60e..440cd8048d76 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -173,7 +173,12 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 m_pTopLevel->setFocusProxy(m_pQWidget);
 }
 else
+{
 m_pQWidget = new QtWidget(*this, aWinFlags);
+// from Qt's POV the popup window doesn't have the input focus, so we 
must force tooltips...
+if (isPopup())
+m_pQWidget->setAttribute(Qt::WA_AlwaysShowToolTips);
+}
 
 QWindow* pChildWindow = windowHandle();
 connect(pChildWindow, ::screenChanged, this, 
::screenChanged);
@@ -859,7 +864,8 @@ bool QtFrame::ShowTooltip(const OUString& rText, const 
tools::Rectangle& rHelpAr
 QRect aHelpArea(toQRect(rHelpArea));
 if (QGuiApplication::isRightToLeft())
 aHelpArea.moveLeft(maGeometry.nWidth - aHelpArea.width() - 
aHelpArea.left() - 1);
-QToolTip::showText(QCursor::pos(), toQString(rText), m_pQWidget, 
aHelpArea);
+m_aTooltipText = rText;
+m_aTooltipArea = aHelpArea;
 return true;
 }
 
diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx
index 612682ae987f..33320c577f94 100644
--- a/vcl/qt5/QtWidget.cxx
+++ b/vcl/qt5/QtWidget.cxx
@@ -42,6 +42,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -562,7 +563,7 @@ bool QtWidget::handleKeyEvent(QtFrame& rFrame, const 
QWidget& rWidget, QKeyEvent
 return bStopProcessingKey;
 }
 
-bool QtWidget::handleEvent(QtFrame& rFrame, const QWidget& rWidget, QEvent* 
pEvent)
+bool QtWidget::handleEvent(QtFrame& rFrame, QWidget& rWidget, QEvent* pEvent)
 {
 if (pEvent->type() == QEvent::ShortcutOverride)
 {
@@ -589,6 +590,22 @@ bool QtWidget::handleEvent(QtFrame& rFrame, const QWidget& 
rWidget, QEvent* pEve
ButtonKeyState::Pressed))
 return true;
 }
+else if (pEvent->type() == QEvent::ToolTip)
+{
+// Qt's POV on focus is wrong for our fake popup windows, so check 
LO's state.
+// Otherwise Qt will continue handling ToolTip events from the 
"parent" window.
+const vcl::Window* pFocusWin = Application::GetFocusWindow();
+if (!rFrame.m_aTooltipText.isEmpty() && pFocusWin
+&& pFocusWin->GetFrameWindow() == rFrame.GetWindow())
+QToolTip::showText(QCursor::pos(), 
toQString(rFrame.m_aTooltipText), ,
+   rFrame.m_aTooltipArea);
+else
+{
+QToolTip::hideText();
+pEvent->ignore();
+}
+return true;
+}
 return false;
 }
 


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-04-08 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtFrame.hxx  |6 +-
 vcl/inc/qt5/QtWidget.hxx |1 +
 vcl/qt5/QtFrame.cxx  |   19 +--
 vcl/qt5/QtWidget.cxx |6 ++
 4 files changed, 25 insertions(+), 7 deletions(-)

New commits:
commit 881cfbf77567194f5016a961d1c3db869734d68b
Author: Jan-Marek Glogowski 
AuthorDate: Thu Apr 7 01:07:43 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Fri Apr 8 17:55:58 2022 +0200

tdf#141578 Qt handle QtFrame screen changes

LO doesn't provide any way to notify screen changes / scaling
factors of a window and in fact doesn't really handle scaling
factors in VCL. The QWidget doesn't receive a resize event,
because it's size doesn't change, just the scaling factor.
So we trigger a faked resize on QWindow::screenChanged signal.

Change-Id: I6928c4c62d1c0995c70fea0088cff17849bcd1d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132650
Reviewed-by: Michael Weghorn 
Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index c6edaa58304d..a873cec76ad6 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -25,6 +25,7 @@
 #include 
 
 #include "QtTools.hxx"
+#include "QtWidget.hxx"
 
 #include 
 #include 
@@ -70,7 +71,7 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public 
SalFrame
 
 friend class QtWidget;
 
-QWidget* m_pQWidget;
+QtWidget* m_pQWidget;
 QtMainWindow* m_pTopLevel;
 
 const bool m_bUseCairo;
@@ -133,6 +134,9 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public 
SalFrame
 
 void fixICCCMwindowGroup();
 
+private Q_SLOTS:
+void screenChanged(QScreen*);
+
 public:
 QtFrame(QtFrame* pParent, SalFrameStyleFlags nSalFrameStyle, bool 
bUseCairo);
 virtual ~QtFrame() override;
diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx
index e2a22d3c9f18..575cef11014f 100644
--- a/vcl/inc/qt5/QtWidget.hxx
+++ b/vcl/inc/qt5/QtWidget.hxx
@@ -85,6 +85,7 @@ public:
 
 QtFrame& frame() const { return m_rFrame; }
 void endExtTextInput();
+void fakeResize();
 
 static bool handleEvent(QtFrame&, const QWidget&, QEvent*);
 // key events might be propagated further down => call base on false
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index b8f649e64b78..91361311d60e 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -176,10 +175,12 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 else
 m_pQWidget = new QtWidget(*this, aWinFlags);
 
+QWindow* pChildWindow = windowHandle();
+connect(pChildWindow, ::screenChanged, this, 
::screenChanged);
+
 if (pParent && !(pParent->m_nStyle & SalFrameStyleFlags::PLUG))
 {
 QWindow* pParentWindow = pParent->windowHandle();
-QWindow* pChildWindow = windowHandle();
 if (pParentWindow && pChildWindow && (pParentWindow != pChildWindow))
 pChildWindow->setTransientParent(pParentWindow);
 }
@@ -191,6 +192,8 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 fixICCCMwindowGroup();
 }
 
+void QtFrame::screenChanged(QScreen*) { m_pQWidget->fakeResize(); }
+
 void QtFrame::FillSystemEnvData(SystemEnvData& rData, sal_IntPtr pWindow, 
QWidget* pWidget)
 {
 if (QGuiApplication::platformName() == "wayland")
@@ -343,7 +346,12 @@ bool QtFrame::PostEvent(std::unique_ptr pData)
 return true;
 }
 
-QWidget* QtFrame::asChild() const { return m_pTopLevel ? m_pTopLevel : 
m_pQWidget; }
+QWidget* QtFrame::asChild() const
+{
+if (m_pTopLevel)
+return m_pTopLevel;
+return m_pQWidget;
+}
 
 qreal QtFrame::devicePixelRatioF() const { return 
asChild()->devicePixelRatioF(); }
 
@@ -868,9 +876,8 @@ void QtFrame::SetInputContext(SalInputContext* pContext)
 
 void QtFrame::EndExtTextInput(EndExtTextInputFlags /*nFlags*/)
 {
-QtWidget* pQtWidget = static_cast(m_pQWidget);
-if (pQtWidget)
-pQtWidget->endExtTextInput();
+if (m_pQWidget)
+m_pQWidget->endExtTextInput();
 }
 
 OUString QtFrame::GetKeyName(sal_uInt16 nKeyCode)
diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx
index cd47492808cc..612682ae987f 100644
--- a/vcl/qt5/QtWidget.cxx
+++ b/vcl/qt5/QtWidget.cxx
@@ -134,6 +134,12 @@ void QtWidget::resizeEvent(QResizeEvent* pEvent)
 m_rFrame.CallCallback(SalEvent::Resize, nullptr);
 }
 
+void QtWidget::fakeResize()
+{
+QResizeEvent aEvent(size(), QSize());
+resizeEvent();
+}
+
 void QtWidget::fillSalAbstractMouseEvent(const QtFrame& rFrame, const 
QInputEvent* pQEvent,
  const QPoint& rPos, Qt::MouseButtons 
eButtons, int nWidth,
  SalAbstractMouseEvent& aSalEvent)


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-04-07 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtWidget.hxx |3 +++
 vcl/qt5/QtFrame.cxx  |5 +++--
 vcl/qt5/QtWidget.cxx |   18 +-
 3 files changed, 19 insertions(+), 7 deletions(-)

New commits:
commit e81385277c091dabb1f6542a94229d7dcc77289b
Author: Jan-Marek Glogowski 
AuthorDate: Wed Apr 6 18:59:10 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Thu Apr 7 15:04:22 2022 +0200

tdf#143135 Qt break recursive IM QueryCursorRect

To reproduce the Impress crash, you need an IM, e.g. fcitx / ibus.
This is triggered by having an active input, like double-clicking
one of a presentations text fields, then leaving the window and
switching back to it.

This results in a stack exhaustion in a few seconds. The backtrace
is basically:

QWidget::setFocus
QtFrame::ToTop
sd::Window::GrabFocus
ImplHandleExtTextInputPos
QtWidget::inputMethodQuery
QInputMethod::cursorRectangle
QWidget::setFocus
QApplication::setActiveWindow
QtInstance::DoYield
main

I scratched my head over the longer backtrace for while, but there
seems to be no good way to prevent this from LO's POV. The only
alternative from the Qt VCL plugin is QtFrame::ToTop. That code
is less ugly (no mutable or cached result), but QtWidget::
inputMethodQuery is earlier in the backtrace.

Change-Id: Ief3a8e44bca295cc676e75050d52d70a1da98a88
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132643
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx
index 801cd290ff88..e2a22d3c9f18 100644
--- a/vcl/inc/qt5/QtWidget.hxx
+++ b/vcl/inc/qt5/QtWidget.hxx
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include 
 #include 
 #include 
 
@@ -36,6 +37,8 @@ class QtWidget : public QWidget
 
 QtFrame& m_rFrame;
 bool m_bNonEmptyIMPreeditSeen;
+mutable bool m_bInInputMethodQueryCursorRectangle;
+mutable QRect m_aImCursorRectangle;
 int m_nDeltaX;
 int m_nDeltaY;
 
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 2e396fa8ce07..b8f649e64b78 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -799,8 +799,9 @@ void QtFrame::ToTop(SalFrameToTop nFlags)
 pWidget->activateWindow();
 else if ((nFlags & SalFrameToTop::GrabFocus) || (nFlags & 
SalFrameToTop::GrabFocusOnly))
 {
-pWidget->activateWindow();
-pWidget->setFocus();
+if (!(nFlags & SalFrameToTop::GrabFocusOnly))
+pWidget->activateWindow();
+pWidget->setFocus(Qt::OtherFocusReason);
 }
 }
 
diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx
index 6362a1353d54..cd47492808cc 100644
--- a/vcl/qt5/QtWidget.cxx
+++ b/vcl/qt5/QtWidget.cxx
@@ -625,6 +625,7 @@ QtWidget::QtWidget(QtFrame& rFrame, Qt::WindowFlags f)
 : QWidget(Q_NULLPTR, f)
 , m_rFrame(rFrame)
 , m_bNonEmptyIMPreeditSeen(false)
+, m_bInInputMethodQueryCursorRectangle(false)
 , m_nDeltaX(0)
 , m_nDeltaY(0)
 {
@@ -800,11 +801,18 @@ QVariant QtWidget::inputMethodQuery(Qt::InputMethodQuery 
property) const
 }
 case Qt::ImCursorRectangle:
 {
-const qreal fRatio = m_rFrame.devicePixelRatioF();
-SalExtTextInputPosEvent aPosEvent;
-m_rFrame.CallCallback(SalEvent::ExtTextInputPos, );
-return QVariant(QRect(aPosEvent.mnX / fRatio, aPosEvent.mnY / 
fRatio,
-  aPosEvent.mnWidth / fRatio, 
aPosEvent.mnHeight / fRatio));
+if (!m_bInInputMethodQueryCursorRectangle)
+{
+m_bInInputMethodQueryCursorRectangle = true;
+SalExtTextInputPosEvent aPosEvent;
+m_rFrame.CallCallback(SalEvent::ExtTextInputPos, );
+const qreal fRatio = m_rFrame.devicePixelRatioF();
+m_aImCursorRectangle.setRect(aPosEvent.mnX / fRatio, 
aPosEvent.mnY / fRatio,
+ aPosEvent.mnWidth / fRatio,
+ aPosEvent.mnHeight / fRatio);
+m_bInInputMethodQueryCursorRectangle = false;
+}
+return QVariant(m_aImCursorRectangle);
 }
 case Qt::ImAnchorPosition:
 {


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-04-06 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/QtTransferable.hxx |2 +-
 vcl/qt5/QtTransferable.cxx |   25 +
 2 files changed, 18 insertions(+), 9 deletions(-)

New commits:
commit 5b3227fac58dcbd588e2389e205679cd77842bac
Author: Michael Weghorn 
AuthorDate: Wed Apr 6 13:51:59 2022 +0200
Commit: Michael Weghorn 
CommitDate: Thu Apr 7 06:36:35 2022 +0200

tdf#147285 qt: Prefer "text/plain;charset=utf-8" over "text/plain"

If there were no data for MIME type "text/plain;charset=utf-16"
in the clipboard, but "text/plain" was provided, it was previously
assumed that this would be encoded in the locale's encoding, and
corresponding conversion using that encoding happened to provide
"text/plain;charset=utf-16" ourselves.

"text/plain;charset=utf-8" data was simply ignored, but using
it (if present) and preferring it over "text/plain"
is more reliable (and e.g. avoids incorrect paste of Chinese
characters from Firefox into Impress when using the qt5/qt6/kf5
VCL plugins on Wayland), so use it if present.

Rename the "m_bConvertFromLocale" member to better fit
the new meaning.

(An alternative solution to adding our own handling for
"text/plain;charset=utf-8" and making assumptions for the
encoding of "text/plain" data would be to let Qt handle
this and just call `QMimeData::text()` for the
`m_bProvideUTF16FromOtherEncoding=true` case
in `QtTransferable::getTransferData`.
Since qtbase commit 589a01ff6b1eacf81e74a5fc4801572135214f43
("QMimeData: Prefer UTF-8 when multiple charsets are available",
contained in Qt >= 5.13), that one handles MIME type
"text/plain;charset=utf-8" in addition to "text/plain".)

[1] 
https://code.qt.io/cgit/qt/qtbase.git/commit/?id=589a01ff6b1eacf81e74a5fc4801572135214f43

Change-Id: I89f33216bf6be02a347d245b2359273af2eb530a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132631
Reviewed-by: Jan-Marek Glogowski 
Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtTransferable.hxx b/vcl/inc/qt5/QtTransferable.hxx
index f2997089c037..5f1533dd5968 100644
--- a/vcl/inc/qt5/QtTransferable.hxx
+++ b/vcl/inc/qt5/QtTransferable.hxx
@@ -35,7 +35,7 @@ class QtTransferable : public 
cppu::WeakImplHelper m_aMimeTypeSeq;
 
 public:
diff --git a/vcl/qt5/QtTransferable.cxx b/vcl/qt5/QtTransferable.cxx
index 4f42f93a238b..ed31a54d769e 100644
--- a/vcl/qt5/QtTransferable.cxx
+++ b/vcl/qt5/QtTransferable.cxx
@@ -42,7 +42,7 @@ static bool lcl_textMimeInfo(const OUString& rMimeString, 
bool& bHaveNoCharset,
 
 QtTransferable::QtTransferable(const QMimeData* pMimeData)
 : m_pMimeData(pMimeData)
-, m_bConvertFromLocale(false)
+, m_bProvideUTF16FromOtherEncoding(false)
 {
 assert(pMimeData);
 }
@@ -62,7 +62,7 @@ css::uno::Sequence SAL_CALL 
QtTransferable::getTr
 QStringList aFormatList(m_pMimeData->formats());
 // we might add the UTF-16 mime text variant later
 const int nMimeTypeSeqSize = aFormatList.size() + 1;
-bool bHaveNoCharset = false, bHaveUTF16 = false;
+bool bHaveNoCharset = false, bHaveUTF16 = false, bHaveUTF8 = false;
 css::uno::Sequence 
aMimeTypeSeq(nMimeTypeSeqSize);
 auto pMimeTypeSeq = aMimeTypeSeq.getArray();
 
@@ -85,6 +85,7 @@ css::uno::Sequence SAL_CALL 
QtTransferable::getTr
 {
 bHaveNoCharset |= bIsNoCharset;
 bHaveUTF16 |= bIsUTF16;
+bHaveUTF8 |= bIsUTF8;
 if (bIsUTF16)
 aFlavor.DataType = cppu::UnoType::get();
 else
@@ -99,8 +100,8 @@ css::uno::Sequence SAL_CALL 
QtTransferable::getTr
 nMimeTypeCount++;
 }
 
-m_bConvertFromLocale = bHaveNoCharset && !bHaveUTF16;
-if (m_bConvertFromLocale)
+m_bProvideUTF16FromOtherEncoding = (bHaveNoCharset || bHaveUTF8) && 
!bHaveUTF16;
+if (m_bProvideUTF16FromOtherEncoding)
 {
 aFlavor.MimeType = "text/plain;charset=utf-16";
 aFlavor.DataType = cppu::UnoType::get();
@@ -133,11 +134,19 @@ css::uno::Any SAL_CALL 
QtTransferable::getTransferData(const css::datatransfer::
 if (rFlavor.MimeType == "text/plain;charset=utf-16")
 {
 OUString aString;
-if (m_bConvertFromLocale)
+if (m_bProvideUTF16FromOtherEncoding)
 {
-QByteArray 
aByteData(m_pMimeData->data(QStringLiteral("text/plain")));
-aString = OUString(reinterpret_cast(aByteData.data()), aByteData.size(),
-   osl_getThreadTextEncoding());
+if (m_pMimeData->hasFormat("text/plain;charset=utf-8"))
+{
+QByteArray 
aByteData(m_pMimeData->data(QStringLiteral("text/plain;charset=utf-8")));
+aString = OUString::fromUtf8(reinterpret_cast(aByteData.data()));
+}
+else
+{
+QByteArray 
aByteData(m_pMimeData->data(QStringLiteral("text/plain")));
+aString = 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-04-06 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtMenu.hxx |1 -
 vcl/qt5/QtMenu.cxx |4 
 2 files changed, 5 deletions(-)

New commits:
commit 4a537cf77affc4f1f2e2e5be9ff0b1ff11724509
Author: Jan-Marek Glogowski 
AuthorDate: Wed Apr 6 16:42:24 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Wed Apr 6 17:39:10 2022 +0200

Qt drop unused QtMenu::mpCloseButton

Change-Id: I988cabf4c07d5efd298c53b696f6d114f4f594bd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132637
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/QtMenu.hxx b/vcl/inc/qt5/QtMenu.hxx
index f39be7e8d506..11f3f00c5aa6 100644
--- a/vcl/inc/qt5/QtMenu.hxx
+++ b/vcl/inc/qt5/QtMenu.hxx
@@ -49,7 +49,6 @@ private:
 std::unique_ptr mpOwnedQMenu;
 // pointer to QMenu owned by the corresponding QtMenuItem or self (-> 
mpOwnedQMenu)
 QMenu* mpQMenu;
-QPushButton* mpCloseButton;
 
 void DoFullMenuUpdate(Menu* pMenuBar);
 static void NativeItemText(OUString& rItemText);
diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx
index 71b81c22ba3e..50cb1d057431 100644
--- a/vcl/qt5/QtMenu.cxx
+++ b/vcl/qt5/QtMenu.cxx
@@ -40,7 +40,6 @@ QtMenu::QtMenu(bool bMenuBar)
 , mbMenuBar(bMenuBar)
 , mpQMenuBar(nullptr)
 , mpQMenu(nullptr)
-, mpCloseButton(nullptr)
 {
 }
 
@@ -430,8 +429,6 @@ void QtMenu::SetFrame(const SalFrame* pFrame)
 
 mpQMenuBar = new QMenuBar();
 pMainWindow->setMenuBar(mpQMenuBar);
-
-mpCloseButton = nullptr;
 mpQMenu = nullptr;
 
 DoFullMenuUpdate(mpVCLMenu);
@@ -665,7 +662,6 @@ void QtMenu::ShowCloseButton(bool bShow)
 pButton->setToolTip(toQString(VclResId(SV_HELPTEXT_CLOSEDOCUMENT)));
 mpQMenuBar->setCornerWidget(pButton, Qt::TopRightCorner);
 connect(pButton, ::clicked, this, 
::slotCloseDocument);
-mpCloseButton = pButton;
 }
 
 if (bShow)


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-04-06 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtMenu.hxx |2 +-
 vcl/qt5/QtMenu.cxx |   38 --
 2 files changed, 21 insertions(+), 19 deletions(-)

New commits:
commit 9c4ef8ce3183e27ca174475cf4a8d15cc0368f60
Author: Jan-Marek Glogowski 
AuthorDate: Tue Apr 5 16:49:38 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Wed Apr 6 11:27:35 2022 +0200

tdf#145954 Qt unshare QMenubar usage

The Qt code was sharing the menu bar from the top level frame, but
LO expects independent menu bars per SetFrame calls. So instead of
showing the new bar and then hiding the old one, this was always
show and hiding the same menu bar, resulting in a hidden menu bar.

As a result of unsharing, LO now must check that its menu bar
pointer is still valid for usage. The QMainWindows takes ownership
when a QMenuBar is assigned and destroy old ones.

Change-Id: I2c6b12199a1e17a5d9f88686a4b27b1413beda47
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132581
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/QtMenu.hxx b/vcl/inc/qt5/QtMenu.hxx
index 55275ae6e099..f39be7e8d506 100644
--- a/vcl/inc/qt5/QtMenu.hxx
+++ b/vcl/inc/qt5/QtMenu.hxx
@@ -50,7 +50,6 @@ private:
 // pointer to QMenu owned by the corresponding QtMenuItem or self (-> 
mpOwnedQMenu)
 QMenu* mpQMenu;
 QPushButton* mpCloseButton;
-QMetaObject::Connection maCloseButtonConnection;
 
 void DoFullMenuUpdate(Menu* pMenuBar);
 static void NativeItemText(OUString& rItemText);
@@ -60,6 +59,7 @@ private:
 void ReinitializeActionGroup(unsigned nPos);
 void ResetAllActionGroups();
 void UpdateActionGroupItem(const QtMenuItem* pSalMenuItem);
+bool validateQMenuBar();
 
 public:
 QtMenu(bool bMenuBar);
diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx
index d9279fb9389a..71b81c22ba3e 100644
--- a/vcl/qt5/QtMenu.cxx
+++ b/vcl/qt5/QtMenu.cxx
@@ -59,7 +59,7 @@ void QtMenu::InsertMenuItem(QtMenuItem* pSalMenuItem, 
unsigned nPos)
 if (mbMenuBar)
 {
 // top-level menu
-if (mpQMenuBar)
+if (validateQMenuBar())
 {
 QMenu* pQMenu = new QMenu(toQString(aText), nullptr);
 pSalMenuItem->mpMenu.reset(pQMenu);
@@ -428,20 +428,10 @@ void QtMenu::SetFrame(const SalFrame* pFrame)
 if (!pMainWindow)
 return;
 
-mpQMenuBar = pMainWindow->menuBar();
-if (mpQMenuBar)
-{
-mpQMenuBar->clear();
-QPushButton* pButton
-= 
static_cast(mpQMenuBar->cornerWidget(Qt::TopRightCorner));
-if (pButton && ((mpCloseButton != pButton) || 
!maCloseButtonConnection))
-{
-maCloseButtonConnection
-= connect(pButton, ::clicked, this, 
::slotCloseDocument);
-mpCloseButton = pButton;
-}
-}
+mpQMenuBar = new QMenuBar();
+pMainWindow->setMenuBar(mpQMenuBar);
 
+mpCloseButton = nullptr;
 mpQMenu = nullptr;
 
 DoFullMenuUpdate(mpVCLMenu);
@@ -565,9 +555,22 @@ QtMenu* QtMenu::GetTopLevel()
 return pMenu;
 }
 
+bool QtMenu::validateQMenuBar()
+{
+if (!mpQMenuBar)
+return false;
+assert(mpFrame);
+QtMainWindow* pMainWindow = mpFrame->GetTopLevelWindow();
+assert(pMainWindow);
+const bool bValid = mpQMenuBar == pMainWindow->menuBar();
+if (!bValid)
+mpQMenuBar = nullptr;
+return bValid;
+}
+
 void QtMenu::ShowMenuBar(bool bVisible)
 {
-if (mpQMenuBar)
+if (validateQMenuBar())
 mpQMenuBar->setVisible(bVisible);
 }
 
@@ -643,7 +646,7 @@ void QtMenu::slotCloseDocument()
 
 void QtMenu::ShowCloseButton(bool bShow)
 {
-if (!mpQMenuBar)
+if (!validateQMenuBar())
 return;
 
 QPushButton* pButton = 
static_cast(mpQMenuBar->cornerWidget(Qt::TopRightCorner));
@@ -661,8 +664,7 @@ void QtMenu::ShowCloseButton(bool bShow)
 pButton->setFocusPolicy(Qt::NoFocus);
 pButton->setToolTip(toQString(VclResId(SV_HELPTEXT_CLOSEDOCUMENT)));
 mpQMenuBar->setCornerWidget(pButton, Qt::TopRightCorner);
-maCloseButtonConnection
-= connect(pButton, ::clicked, this, 
::slotCloseDocument);
+connect(pButton, ::clicked, this, 
::slotCloseDocument);
 mpCloseButton = pButton;
 }
 


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-04-06 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtFrame.hxx |1 
 vcl/qt5/QtFrame.cxx |   77 ++--
 vcl/qt5/QtWidget.cxx|8 +---
 3 files changed, 13 insertions(+), 73 deletions(-)

New commits:
commit fbf739198aa7f02975d531521c6525073783c7f1
Author: Jan-Marek Glogowski 
AuthorDate: Mon Apr 4 18:02:28 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Wed Apr 6 09:52:11 2022 +0200

tdf#144585 Qt fix Wayland LO fake popups

So Michael Weghorn was somehow reminded of an abandoned
commit from me ("Qt5 rework parent handling") archived in
https://gerrit.libreoffice.org/c/core/+/73463.

The bug introducing the new QWidget parenting, tdf#145363, was
resolved in a better way by explicitly setting parents for the
modal dialogs, so LO doesn't break Qt anymore. The actual problem
is, that an additional modal dialog needs to be stacked to the
previous modal dialog; no "parallel" modal dialogs are allowed,
which my original fix tried to enforce by reparenting.

Then there is the problem with Qt::Popup's focus grabbing on show,
which breaks LO's editable ComboBox. So LO's popup / FLOAT windows
are mapped to Qt::ToolTip, which are automatically advertised as
tooltips via accessibility. For X11 / xcb, Qt:Window with the
Qt::BypassWindowManagerHint works well enough as an alternative,
but WASM and Wayland don't seem to implement it correctly, so this
just handles popups as Qt::ToolTip on all platforms.

This reverts commit b00a68a8e19370e106cd76258a3c1825f43613ee
("tdf#145363 Qt reparent modal dialogs on show").
In addition the popup widgets are switched back to Qt::ToolTip.

Change-Id: If726771b4e9cc3f639f21cf502b3ec5985873643
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132526
Reviewed-by: Jan-Marek Glogowski 
Reviewed-by: Michael Weghorn 
Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index 9aa31504bcd3..c6edaa58304d 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -132,7 +132,6 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public 
SalFrame
 int menuBarOffset() const;
 
 void fixICCCMwindowGroup();
-void modalReparent(bool bVisible);
 
 public:
 QtFrame(QtFrame* pParent, SalFrameStyleFlags nSalFrameStyle, bool 
bUseCairo);
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 6c2e4757f84a..2e396fa8ce07 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -147,15 +147,14 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 aWinFlags = Qt::Tool | Qt::FramelessWindowHint;
 else if (nStyle & SalFrameStyleFlags::TOOLTIP)
 aWinFlags = Qt::ToolTip;
-// Can't use Qt::Popup, because it grabs the input focus and generates
-// a focus-out event, reaching the combo box. This used to map to
-// Qt::ToolTip, which doesn't feel that correct...
+// Can't use Qt::Popup, because it grabs the input focus and generates 
a focus-out event,
+// instantly auto-closing the LO's editable ComboBox popup.
+// On X11, the alternative Qt::Window | Qt::FramelessWindowHint | 
Qt::BypassWindowManagerHint
+// seems to work well enough, but at least on Wayland and WASM, this 
results in problems.
+// So while using Qt::ToolTip, the popups are wrongly advertised via 
accessibility, at least
+// the GUI seems to work on all platforms... what a mess.
 else if (isPopup())
-#ifdef EMSCRIPTEN
 aWinFlags = Qt::ToolTip | Qt::FramelessWindowHint;
-#else
-aWinFlags = Qt::Window | Qt::FramelessWindowHint | 
Qt::BypassWindowManagerHint;
-#endif
 else if (nStyle & SalFrameStyleFlags::TOOLWINDOW)
 aWinFlags = Qt::Tool;
 // top level windows can't be transient in Qt, so make them dialogs, 
if they have a parent. At least
@@ -170,7 +169,7 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 if (aWinFlags == Qt::Window)
 {
 m_pTopLevel = new QtMainWindow(*this, aWinFlags);
-m_pQWidget = new QtWidget(*this, aWinFlags);
+m_pQWidget = new QtWidget(*this);
 m_pTopLevel->setCentralWidget(m_pQWidget);
 m_pTopLevel->setFocusProxy(m_pQWidget);
 }
@@ -425,42 +424,6 @@ void QtFrame::DrawMenuBar() { /* not needed */}
 
 void QtFrame::SetExtendedFrameStyle(SalExtStyle /*nExtStyle*/) { /* not needed 
*/}
 
-void QtFrame::modalReparent(bool bVisible)
-{
-#ifndef NDEBUG
-auto* pSalInst(GetQtInstance());
-assert(pSalInst);
-assert(pSalInst->IsMainThread());
-assert(!asChild()->isVisible());
-assert(asChild()->isModal());
-#endif
-
-if (!bVisible)
-{
-QWidget* pNewParent = m_pParent ? m_pParent->asChild() : nullptr;
-if (pNewParent != m_pQWidget->parent())
-m_pQWidget->setParent(pNewParent, 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2022-01-16 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtInstance.hxx |8 
 vcl/qt5/QtInstance.cxx |   36 
 2 files changed, 44 insertions(+)

New commits:
commit ced4cde59eb51e4364daf69520a184b55c2c54db
Author: Jan-Marek Glogowski 
AuthorDate: Sun Jan 16 10:14:47 2022 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Sun Jan 16 14:42:31 2022 +0100

Qt notify LO of many QScreen related events

LO just has a single display event, SalEvent::DisplayChanged, Qt
has a multitude. So this will generate multiple LO notifications.
I don't see any reasonable way to prevent that. Doesn't seem a
problem here.

Change-Id: I2f11e53765869a4ca292a1d337347e4e7470e3c2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128474
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx
index 24629a36af8c..1511996c0ce0 100644
--- a/vcl/inc/qt5/QtInstance.hxx
+++ b/vcl/inc/qt5/QtInstance.hxx
@@ -75,6 +75,12 @@ private Q_SLOTS:
 static void deleteObjectLater(QObject* pObject);
 static void localeChanged();
 
+void orientationChanged(Qt::ScreenOrientation);
+void primaryScreenChanged(QScreen*);
+void screenAdded(QScreen*);
+void screenRemoved(QScreen*);
+void virtualGeometryChanged(const QRect&);
+
 Q_SIGNALS:
 bool ImplYieldSignal(bool bWait, bool bHandleAllCurrentEvents);
 void deleteObjectLaterSignal(QObject* pObject);
@@ -86,6 +92,8 @@ protected:
 bool useCairo() const { return m_bUseCairo; }
 // encodes cairo usage and Qt platform name into the ToolkitName
 OUString constructToolkitID(std::u16string_view sTKname);
+void connectQScreenSignals(const QScreen*);
+void notifyDisplayChanged();
 
 public:
 explicit QtInstance(std::unique_ptr& pQApp, bool bUseCairo = 
false);
diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx
index bb7e98c051cd..9629532f824b 100644
--- a/vcl/qt5/QtInstance.cxx
+++ b/vcl/qt5/QtInstance.cxx
@@ -40,6 +40,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -250,6 +251,12 @@ QtInstance::QtInstance(std::unique_ptr& 
pQApp, bool bUseCairo)
 connect(QGuiApplication::inputMethod(), ::localeChanged, this,
 ::localeChanged);
 
+for (const QScreen* pCurScreen : QApplication::screens())
+connectQScreenSignals(pCurScreen);
+connect(qApp, ::primaryScreenChanged, this, 
::primaryScreenChanged);
+connect(qApp, ::screenAdded, this, 
::screenAdded);
+connect(qApp, ::screenRemoved, this, 
::screenRemoved);
+
 #ifndef EMSCRIPTEN
 m_bSupportsOpenGL = true;
 #endif
@@ -604,6 +611,35 @@ void* QtInstance::CreateGStreamerSink(const 
SystemChildWindow* pWindow)
 #endif
 }
 
+void QtInstance::connectQScreenSignals(const QScreen* pScreen)
+{
+connect(pScreen, ::orientationChanged, this, 
::orientationChanged);
+connect(pScreen, ::virtualGeometryChanged, this, 
::virtualGeometryChanged);
+}
+
+void QtInstance::notifyDisplayChanged()
+{
+SolarMutexGuard aGuard;
+SalFrame* pAnyFrame = anyFrame();
+if (pAnyFrame)
+pAnyFrame->CallCallback(SalEvent::DisplayChanged, nullptr);
+}
+
+void QtInstance::orientationChanged(Qt::ScreenOrientation) { 
notifyDisplayChanged(); }
+
+void QtInstance::primaryScreenChanged(QScreen*) { notifyDisplayChanged(); }
+
+void QtInstance::screenAdded(QScreen* pScreen)
+{
+connectQScreenSignals(pScreen);
+if (QApplication::screens().size() == 1)
+notifyDisplayChanged();
+}
+
+void QtInstance::screenRemoved(QScreen*) { notifyDisplayChanged(); }
+
+void QtInstance::virtualGeometryChanged(const QRect&) { 
notifyDisplayChanged(); }
+
 void QtInstance::AllocFakeCmdlineArgs(std::unique_ptr& rFakeArgv,
   std::unique_ptr& rFakeArgc,
   std::vector& 
rFakeArgvFreeable)


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-12-21 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtFrame.hxx |1 +
 vcl/qt5/QtFrame.cxx |   20 ++--
 2 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit ca28826a087245686d7fca3ffc8ca1f03307924d
Author: Jan-Marek Glogowski 
AuthorDate: Mon Dec 20 13:32:52 2021 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Tue Dec 21 13:35:49 2021 +0100

tdf#131467 Qt set default position on first resize

Setting the position in Show() is too late, because LO will try
to set the mouse pointer to the default button, if configured.
That obviously needs the window position.
And also take the menubar offset into account.

Change-Id: Ia280539c082ff6f675966869fb6643a41a17d696
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127154
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index 61d175cf2625..9aa31504bcd3 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -129,6 +129,7 @@ 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();
 void modalReparent(bool bVisible);
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 15795b3e84e6..19d9c826f625 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -469,7 +469,6 @@ void QtFrame::Show(bool bVisible, bool bNoActivate)
 
 // show
 SetDefaultSize();
-SetDefaultPos();
 
 pSalInst->RunInMainThread([this, bNoActivate]() {
 QWidget* const pChild = asChild();
@@ -503,6 +502,14 @@ void QtFrame::SetMaxClientSize(tools::Long nWidth, 
tools::Long nHeight)
 }
 }
 
+int QtFrame::menuBarOffset() const
+{
+QtMainWindow* pTopLevel = m_pParent->GetTopLevelWindow();
+if (pTopLevel && pTopLevel->menuBar() && pTopLevel->menuBar()->isVisible())
+return round(pTopLevel->menuBar()->geometry().height() * 
devicePixelRatioF());
+return 0;
+}
+
 void QtFrame::SetDefaultPos()
 {
 if (!m_bDefaultPos)
@@ -515,6 +522,7 @@ void QtFrame::SetDefaultPos()
 QWidget* const pParentWin = m_pParent->asChild()->window();
 QWidget* const pChildWin = asChild()->window();
 QPoint aPos = (pParentWin->rect().center() - 
pChildWin->rect().center()) * fRatio;
+aPos.ry() -= menuBarOffset();
 SetPosSize(aPos.x(), aPos.y(), 0, 0, SAL_FRAME_POSSIZE_X | 
SAL_FRAME_POSSIZE_Y);
 assert(!m_bDefaultPos);
 }
@@ -603,7 +611,11 @@ void QtFrame::SetPosSize(tools::Long nX, tools::Long nY, 
tools::Long nWidth, too
 }
 
 if (!(nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y)))
+{
+if (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT))
+SetDefaultPos();
 return;
+}
 
 if (m_pParent)
 {
@@ -612,11 +624,7 @@ void QtFrame::SetPosSize(tools::Long nX, tools::Long nY, 
tools::Long nWidth, too
 nX = aParentGeometry.nX + aParentGeometry.nWidth - nX - 
maGeometry.nWidth - 1;
 else
 nX += aParentGeometry.nX;
-nY += aParentGeometry.nY;
-
-QtMainWindow* pTopLevel = m_pParent->GetTopLevelWindow();
-if (pTopLevel && pTopLevel->menuBar() && 
pTopLevel->menuBar()->isVisible())
-nY += round(pTopLevel->menuBar()->geometry().height() * 
devicePixelRatioF());
+nY += aParentGeometry.nY + menuBarOffset();
 }
 
 if (!(nFlags & SAL_FRAME_POSSIZE_X))


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-12-01 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtFrame.hxx |7 +++
 vcl/inc/qt5/QtTools.hxx |6 ++
 vcl/qt5/QtFrame.cxx |   13 ++---
 vcl/qt5/QtWidget.cxx|   10 ++
 4 files changed, 21 insertions(+), 15 deletions(-)

New commits:
commit 4437071c3f7c0b51881b0b1a5d5a68bdd100328b
Author: Jan-Marek Glogowski 
AuthorDate: Wed Dec 1 08:53:25 2021 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Wed Dec 1 13:30:41 2021 +0100

Qt fix non-X11 build and introduce CHECK_* macros

Explicitly uses ANY, so it's hopefully easier to read then QT,
QT5 and QT6 in the otherwise same macro names.

Change-Id: Ie9bbbc858f5f9db5c8b429c7b0d8a897ac6159fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126168
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index c3c9cdb9f309..61d175cf2625 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -32,7 +32,7 @@
 
 #include 
 
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11
+#if CHECK_QT5_USING_X11
 #include 
 // any better way to get rid of the X11 / Qt type clashes?
 #undef Bool
@@ -100,11 +100,10 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public 
SalFrame
 sal_uInt32 m_nRestoreScreen;
 QRect m_aRestoreGeometry;
 
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11
+#if CHECK_QT5_USING_X11
 ScreenSaverInhibitor m_ScreenSaverInhibitor;
 #endif
-#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11)  
\
-|| (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT6_USING_X11)
+#if CHECK_ANY_QT_USING_X11
 ModKeyFlags m_nKeyModifiers;
 #endif
 
diff --git a/vcl/inc/qt5/QtTools.hxx b/vcl/inc/qt5/QtTools.hxx
index 7221a8ce8dc6..ecaa7075a426 100644
--- a/vcl/inc/qt5/QtTools.hxx
+++ b/vcl/inc/qt5/QtTools.hxx
@@ -179,4 +179,10 @@ inline std::basic_ostream& 
operator<<(std::basic_ostream= QT_VERSION_CHECK(6, 0, 0) && 
QT6_USING_X11)
+
+#define CHECK_ANY_QT_USING_X11 CHECK_QT5_USING_X11 || CHECK_QT6_USING_X11
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 5b8a6fad6d96..ea1dee4fe916 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -51,7 +51,7 @@
 #include 
 #include 
 
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11
+#if CHECK_QT5_USING_X11
 #include 
 #include 
 #if QT5_HAVE_XCB_ICCCM
@@ -68,7 +68,7 @@
 #include 
 #include 
 
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11 && 
QT5_HAVE_XCB_ICCCM
+#if CHECK_QT5_USING_X11 && QT5_HAVE_XCB_ICCCM
 static bool g_bNeedsWmHintsWindowGroup = true;
 static xcb_atom_t g_aXcbClientLeaderAtom = 0;
 #endif
@@ -115,8 +115,7 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 , m_bDefaultPos(true)
 , m_bFullScreen(false)
 , m_bFullScreenSpanAll(false)
-#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11)  
\
-|| (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT6_USING_X11)
+#if CHECK_ANY_QT_USING_X11
 , m_nKeyModifiers(ModKeyFlags::NONE)
 #endif
 , m_nInputLanguage(LANGUAGE_DONTKNOW)
@@ -211,7 +210,7 @@ void QtFrame::FillSystemEnvData(SystemEnvData& rData, 
sal_IntPtr pWindow, QWidge
 
 void QtFrame::fixICCCMwindowGroup()
 {
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11 && 
QT5_HAVE_XCB_ICCCM
+#if CHECK_QT5_USING_X11 && QT5_HAVE_XCB_ICCCM
 // older Qt5 just sets WM_CLIENT_LEADER, but not the 
XCB_ICCCM_WM_HINT_WINDOW_GROUP
 // see Qt commit 0de4b326d8 ("xcb: fix issue with dialogs hidden by other 
windows")
 // or QTBUG-46626. So LO has to set this itself to help some WMs.
@@ -795,7 +794,7 @@ void QtFrame::StartPresentation(bool bStart)
 {
 // meh - so there's no Qt platform independent solution
 // 
https://forum.qt.io/topic/38504/solved-qdialog-in-fullscreen-disable-os-screensaver
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11
+#if CHECK_QT5_USING_X11
 std::optional aRootWindow;
 std::optional aDisplay;
 
@@ -1319,7 +1318,7 @@ void QtFrame::SetScreenNumber(unsigned int nScreen)
 
 void QtFrame::SetApplicationID(const OUString& rWMClass)
 {
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11
+#if CHECK_QT5_USING_X11
 if (m_aSystemData.platform != SystemEnvData::Platform::Xcb || !m_pTopLevel)
 return;
 
diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx
index 85bcd814b03a..3078a7133764 100644
--- a/vcl/qt5/QtWidget.cxx
+++ b/vcl/qt5/QtWidget.cxx
@@ -54,8 +54,7 @@
 #include 
 #include 
 
-#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11)  
\
-|| (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT6_USING_X11)
+#if CHECK_ANY_QT_USING_X11
 #define XK_MISCELLANY
 #include 
 #endif
@@ -462,8 +461,7 @@ bool QtWidget::handleKeyEvent(QtFrame& rFrame, const 
QWidget& rWidget, QKeyEvent
 aModEvt.mbDown = eState == 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-11-17 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtFrame.hxx |1 +
 vcl/qt5/QtFrame.cxx |   10 --
 vcl/qt5/QtObject.cxx|2 --
 3 files changed, 9 insertions(+), 4 deletions(-)

New commits:
commit f3bd9ef889d1834f7b1feb49197a58e679826c00
Author: Jan-Marek Glogowski 
AuthorDate: Wed Nov 17 13:26:09 2021 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Wed Nov 17 16:51:42 2021 +0100

Qt resolve native winId() on demand

As for gtk3 in commit ac9789dbb36f45dcc1caf7dd2951353b1574c8ea
("tdf#139609 avoid fetching unnecessary xid under gtk3").

Change-Id: I82b2c22437e5ab957706c25fcc118b28abb07242
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125395
Reviewed-by: Michael Weghorn 
Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index 965ecbaba0e1..c3c9cdb9f309 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -210,6 +210,7 @@ public:
 
 virtual void SetScreenNumber(unsigned int) override;
 virtual void SetApplicationID(const OUString&) override;
+virtual void ResolveWindowHandle(SystemEnvData& rData) const override;
 
 inline bool CallCallback(SalEvent nEvent, const void* pEvent) const;
 
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index ce504c10b8db..5b8a6fad6d96 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -184,8 +184,6 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 }
 
 FillSystemEnvData(m_aSystemData, reinterpret_cast(this), 
m_pQWidget);
-if (m_aSystemData.platform != SystemEnvData::Platform::Wayland)
-m_aSystemData.SetWindowHandle(m_pQWidget->winId());
 
 SetIcon(SV_ICON_ID_OFFICE);
 
@@ -1344,6 +1342,14 @@ void QtFrame::SetApplicationID(const OUString& rWMClass)
 #endif
 }
 
+void QtFrame::ResolveWindowHandle(SystemEnvData& rData) const
+{
+if (!rData.pWidget)
+return;
+if (rData.platform != SystemEnvData::Platform::Wayland)
+rData.SetWindowHandle(static_cast(rData.pWidget)->winId());
+}
+
 // Drag'n'drop foo
 
 void QtFrame::registerDragSource(QtDragSource* pDragSource)
diff --git a/vcl/qt5/QtObject.cxx b/vcl/qt5/QtObject.cxx
index b8c30af2d340..569586a0dc98 100644
--- a/vcl/qt5/QtObject.cxx
+++ b/vcl/qt5/QtObject.cxx
@@ -42,8 +42,6 @@ QtObject::QtObject(QtFrame* pParent, bool bShow)
 m_pQWidget->show();
 
 QtFrame::FillSystemEnvData(m_aSystemData, 
reinterpret_cast(this), m_pQWidget);
-if (m_aSystemData.platform != SystemEnvData::Platform::Wayland)
-m_aSystemData.SetWindowHandle(m_pQWidget->winId());
 }
 
 QtObject::~QtObject()


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-11-17 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtFrame.hxx |1 
 vcl/qt5/QtFrame.cxx |   51 +---
 vcl/qt5/QtObject.cxx|   25 ++-
 3 files changed, 27 insertions(+), 50 deletions(-)

New commits:
commit 76611452da46aec18ba14954671beee4f6dacf49
Author: Jan-Marek Glogowski 
AuthorDate: Wed Nov 17 13:03:23 2021 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Wed Nov 17 16:51:14 2021 +0100

Qt refactor SystemEnvData setup

Change-Id: I900d1079c9a832a9b5170e58ce4e7a8b81d7d01b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125393
Reviewed-by: Michael Weghorn 
Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index a338b106eaeb..965ecbaba0e1 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -215,6 +215,7 @@ public:
 
 void setInputLanguage(LanguageType);
 inline bool isPopup() const;
+static void FillSystemEnvData(SystemEnvData&, sal_IntPtr pWindow, QWidget* 
pWidget);
 };
 
 inline bool QtFrame::CallCallback(SalEvent nEvent, const void* pEvent) const
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index db91e48a256c..ce504c10b8db 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -183,39 +183,34 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 pChildWindow->setTransientParent(pParentWindow);
 }
 
-// Calling 'QWidget::winId()' implicitly enables native windows to be used
-// rather than "alien widgets" that are unknown to the windowing system,
-// s. https://doc.qt.io/qt-5/qwidget.html#native-widgets-vs-alien-widgets
-// Avoid this on Wayland due to problems with missing 'mouseMoveEvent's,
-// s. tdf#122293/QTBUG-75766
-const bool bWayland = QGuiApplication::platformName() == "wayland";
-if (!bWayland)
+FillSystemEnvData(m_aSystemData, reinterpret_cast(this), 
m_pQWidget);
+if (m_aSystemData.platform != SystemEnvData::Platform::Wayland)
 m_aSystemData.SetWindowHandle(m_pQWidget->winId());
-else
-{
-// TODO implement as needed for Wayland,
-// s.a. commit c0d4f3ad3307c which did this for gtk3
-// QPlatformNativeInterface* native = 
QGuiApplication::platformNativeInterface();
-// m_aSystemData.pDisplay = native->nativeResourceForWindow("display", 
nullptr);
-// m_aSystemData.aWindow = reinterpret_cast(
-// native->nativeResourceForWindow("surface", 
m_pQWidget->windowHandle()));
-}
-
-m_aSystemData.aShellWindow = reinterpret_cast(this);
-//m_aSystemData.pSalFrame = this;
-m_aSystemData.pWidget = m_pQWidget;
-//m_aSystemData.nScreen = m_nXScreen.getXScreen();
-m_aSystemData.toolkit = SystemEnvData::Toolkit::Qt;
-if (!bWayland)
-m_aSystemData.platform = SystemEnvData::Platform::Xcb;
-else
-m_aSystemData.platform = SystemEnvData::Platform::Wayland;
 
 SetIcon(SV_ICON_ID_OFFICE);
 
 fixICCCMwindowGroup();
 }
 
+void QtFrame::FillSystemEnvData(SystemEnvData& rData, sal_IntPtr pWindow, 
QWidget* pWidget)
+{
+if (QGuiApplication::platformName() == "wayland")
+rData.platform = SystemEnvData::Platform::Wayland;
+else if (QGuiApplication::platformName() == "xcb")
+rData.platform = SystemEnvData::Platform::Xcb;
+else
+{
+// maybe add a SystemEnvData::Platform::Unsupported to avoid special 
cases and not abort?
+SAL_WARN("vcl.qt",
+ "Unsupported qt VCL platform: " << 
toOUString(QGuiApplication::platformName()));
+std::abort();
+}
+
+rData.toolkit = SystemEnvData::Toolkit::Qt;
+rData.aShellWindow = pWindow;
+rData.pWidget = pWidget;
+}
+
 void QtFrame::fixICCCMwindowGroup()
 {
 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11 && 
QT5_HAVE_XCB_ICCCM
@@ -226,7 +221,7 @@ void QtFrame::fixICCCMwindowGroup()
 return;
 g_bNeedsWmHintsWindowGroup = false;
 
-if (QGuiApplication::platformName() != "xcb")
+if (m_aSystemData.platform != SystemEnvData::Platform::Xcb)
 return;
 if (QVersionNumber::fromString(qVersion()) >= QVersionNumber(5, 12))
 return;
@@ -1327,7 +1322,7 @@ void QtFrame::SetScreenNumber(unsigned int nScreen)
 void QtFrame::SetApplicationID(const OUString& rWMClass)
 {
 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11
-if (QGuiApplication::platformName() != "xcb" || !m_pTopLevel)
+if (m_aSystemData.platform != SystemEnvData::Platform::Xcb || !m_pTopLevel)
 return;
 
 OString aResClass = OUStringToOString(rWMClass, RTL_TEXTENCODING_ASCII_US);
diff --git a/vcl/qt5/QtObject.cxx b/vcl/qt5/QtObject.cxx
index 155a78da8ce1..b8c30af2d340 100644
--- a/vcl/qt5/QtObject.cxx
+++ b/vcl/qt5/QtObject.cxx
@@ -41,28 +41,9 @@ QtObject::QtObject(QtFrame* pParent, bool bShow)
 if (bShow)
 m_pQWidget->show();
 
-m_aSystemData.aShellWindow = reinterpret_cast(this);
-//m_aSystemData.pSalFrame 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-11-01 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtFilePicker.hxx |   18 ++---
 vcl/qt5/QtFilePicker.cxx |   57 +--
 2 files changed, 59 insertions(+), 16 deletions(-)

New commits:
commit fa9b28c781d4d3e97f7dcf150a0e22e70289c228
Author: Jan-Marek Glogowski 
AuthorDate: Sun Oct 31 11:03:36 2021 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Mon Nov 1 12:18:58 2021 +0100

Qt picker: implement XAsynchronousExecutableDialog

FWIW: most places still call FileDialogHelper::Execute instead of
StartExecuteModal. I tested with "Insert >> Text from File...".

Change-Id: I303cc89c97c8fc17015ab7831e6a324ef16a6a0b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124512
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/QtFilePicker.hxx b/vcl/inc/qt5/QtFilePicker.hxx
index c1a95f5c64a0..20ee52e83ea0 100644
--- a/vcl/inc/qt5/QtFilePicker.hxx
+++ b/vcl/inc/qt5/QtFilePicker.hxx
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -48,10 +49,10 @@ class QGridLayout;
 class QLabel;
 class QWidget;
 
-typedef ::cppu::WeakComponentImplHelper
+typedef ::cppu::WeakComponentImplHelper<
+css::frame::XTerminateListener, css::lang::XInitialization, 
css::lang::XServiceInfo,
+css::ui::dialogs::XFilePicker3, css::ui::dialogs::XFilePickerControlAccess,
+css::ui::dialogs::XAsynchronousExecutableDialog, 
css::ui::dialogs::XFolderPicker2>
 QtFilePicker_Base;
 
 class VCLPLUG_QT_PUBLIC QtFilePicker : public QObject, public QtFilePicker_Base
@@ -62,6 +63,7 @@ private:
 css::uno::Reference m_context;
 
 css::uno::Reference m_xListener;
+css::uno::Reference 
m_xClosedListener;
 
 osl::Mutex m_aHelperMutex; ///< mutex used by the WeakComponentImplHelper
 
@@ -112,6 +114,11 @@ public:
 virtual void SAL_CALL setTitle(const OUString& rTitle) override;
 virtual sal_Int16 SAL_CALL execute() override;
 
+// XAsynchronousExecutableDialog functions
+virtual void SAL_CALL setDialogTitle(const OUString&) override;
+virtual void SAL_CALL
+startExecuteModal(const 
css::uno::Reference&) override;
+
 // XFilePicker functions
 virtual void SAL_CALL setMultiSelectionMode(sal_Bool bMode) override;
 virtual void SAL_CALL setDefaultName(const OUString& rName) override;
@@ -164,6 +171,8 @@ private:
 static void handleSetListValue(QComboBox* pQComboBox, sal_Int16 nAction,
const css::uno::Any& rValue);
 
+void prepareExecute();
+
 private Q_SLOTS:
 // emit XFilePickerListener controlStateChanged event
 void filterSelected(const QString&);
@@ -171,6 +180,7 @@ private Q_SLOTS:
 void currentChanged(const QString&);
 // (un)set automatic file extension
 virtual void updateAutomaticFileExtension();
+void finished(int);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtFilePicker.cxx b/vcl/qt5/QtFilePicker.cxx
index ca80b61ef101..3fae63fca74f 100644
--- a/vcl/qt5/QtFilePicker.cxx
+++ b/vcl/qt5/QtFilePicker.cxx
@@ -116,6 +116,8 @@ 
QtFilePicker::QtFilePicker(css::uno::Reference cons
 // update automatic file extension when filter is changed
 connect(m_pFileDialog.get(), SIGNAL(filterSelected(const QString&)), this,
 SLOT(updateAutomaticFileExtension()));
+
+connect(m_pFileDialog.get(), SIGNAL(finished(int)), this, 
SLOT(finished(int)));
 }
 
 QtFilePicker::~QtFilePicker()
@@ -152,18 +154,8 @@ void SAL_CALL QtFilePicker::setTitle(const OUString& title)
 [this, ]() { m_pFileDialog->setWindowTitle(toQString(title)); });
 }
 
-sal_Int16 SAL_CALL QtFilePicker::execute()
+void QtFilePicker::prepareExecute()
 {
-SolarMutexGuard g;
-auto* pSalInst(static_cast(GetSalData()->m_pInstance));
-assert(pSalInst);
-if (!pSalInst->IsMainThread())
-{
-sal_uInt16 ret;
-pSalInst->RunInMainThread([, this]() { ret = execute(); });
-return ret;
-}
-
 QWidget* pTransientParent = m_pParentWidget;
 if (!pTransientParent)
 {
@@ -191,15 +183,56 @@ sal_Int16 SAL_CALL QtFilePicker::execute()
 m_pFileDialog->setParent(pTransientParent, m_pFileDialog->windowFlags());
 m_pFileDialog->show();
 xDesktop->addTerminateListener(this);
-int result = m_pFileDialog->exec();
+}
+
+void QtFilePicker::finished(int nResult)
+{
+uno::Reference 
xDesktop(css::frame::Desktop::create(m_context),
+  UNO_QUERY_THROW);
 xDesktop->removeTerminateListener(this);
 m_pFileDialog->setParent(nullptr, m_pFileDialog->windowFlags());
 
+if (m_xClosedListener.is())
+{
+const sal_Int16 nRet = (QFileDialog::Rejected == nResult) ? 
ExecutableDialogResults::CANCEL
+  : 
ExecutableDialogResults::OK;
+css::ui::dialogs::DialogClosedEvent aEvent(*this, nRet);
+

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-10-31 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/QtFrame.hxx |1 
 vcl/qt5/QtFrame.cxx |   80 ++--
 vcl/qt5/QtWidget.cxx|6 +++
 3 files changed, 77 insertions(+), 10 deletions(-)

New commits:
commit b00a68a8e19370e106cd76258a3c1825f43613ee
Author: Jan-Marek Glogowski 
AuthorDate: Sun Oct 31 02:33:46 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Sun Oct 31 21:04:33 2021 +0100

tdf#145363 Qt reparent modal dialogs on show

Simply said, one can't have two modal dialogs open at the same
parent in Qt. All modal windows must open as a stack, each
parented to the previous one. This is kind of logical.

Unexpectedly Qt totally breaks, if you open two modal dialogs on
the same window. This happens, because the existing paragraph
style dialog and the "sub" "list style" dialog are both children
of their Writer window.

I'm not sure the additionally introduced QWidget-based parent
handling is strictly needed. It seems Ok.

So for every visibility and modality change, we reparent the
Qt widget, either on top of the modal stack or restore the
original LO-based parent. The LO hierachy is never changed!

Change-Id: Id209c9aa67774440089dc50a6648ac293950087a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124500
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index 23c92d7e1da3..a338b106eaeb 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -132,6 +132,7 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public 
SalFrame
 void SetWindowStateImpl(Qt::WindowStates eState);
 
 void fixICCCMwindowGroup();
+void modalReparent(bool bVisible);
 
 public:
 QtFrame(QtFrame* pParent, SalFrameStyleFlags nSalFrameStyle, bool 
bUseCairo);
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 73bdad874552..1ae4016d589d 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -417,24 +417,71 @@ void QtFrame::DrawMenuBar() { /* not needed */}
 
 void QtFrame::SetExtendedFrameStyle(SalExtStyle /*nExtStyle*/) { /* not needed 
*/}
 
+void QtFrame::modalReparent(bool bVisible)
+{
+#ifndef NDEBUG
+auto* pSalInst(static_cast(GetSalData()->m_pInstance));
+assert(pSalInst);
+assert(pSalInst->IsMainThread());
+assert(!asChild()->isVisible());
+assert(asChild()->isModal());
+#endif
+
+if (!bVisible)
+{
+m_pQWidget->setParent(m_pParent ? m_pParent->asChild() : nullptr,
+  m_pQWidget->windowFlags());
+return;
+}
+
+if (!QGuiApplication::modalWindow())
+return;
+
+QtInstance* pInst = static_cast(GetSalData()->m_pInstance);
+for (auto* pFrame : pInst->getFrames())
+{
+QWidget* pQWidget = static_cast(pFrame)->asChild();
+if (pQWidget->windowHandle() == QGuiApplication::modalWindow())
+{
+m_pQWidget->setParent(pQWidget, m_pQWidget->windowFlags());
+break;
+}
+}
+}
+
 void QtFrame::Show(bool bVisible, bool bNoActivate)
 {
 assert(m_pQWidget);
 if (bVisible == asChild()->isVisible())
 return;
 
+auto* pSalInst(static_cast(GetSalData()->m_pInstance));
+assert(pSalInst);
+
+if (!bVisible) // hide
+{
+pSalInst->RunInMainThread([this]() {
+asChild()->hide();
+if (m_pQWidget->isModal())
+modalReparent(false);
+});
+return;
+}
+
+// show
 SetDefaultSize();
 SetDefaultPos();
 
-auto* pSalInst(static_cast(GetSalData()->m_pInstance));
-assert(pSalInst);
-pSalInst->RunInMainThread([this, bVisible, bNoActivate]() {
-asChild()->setVisible(bVisible);
-asChild()->raise();
+pSalInst->RunInMainThread([this, bNoActivate]() {
+QWidget* const pChild = asChild();
+if (m_pQWidget->isModal())
+modalReparent(true);
+pChild->show();
+pChild->raise();
 if (!bNoActivate && !isPopup())
 {
-asChild()->activateWindow();
-asChild()->setFocus();
+pChild->activateWindow();
+pChild->setFocus();
 }
 });
 }
@@ -610,7 +657,7 @@ SalFrame* QtFrame::GetParent() const { return m_pParent; }
 
 void QtFrame::SetModal(bool bModal)
 {
-if (!isWindow())
+if (!isWindow() || asChild()->isModal() == bModal)
 return;
 
 auto* pSalInst(static_cast(GetSalData()->m_pInstance));
@@ -622,12 +669,20 @@ void QtFrame::SetModal(bool bModal)
 
 // modality change is only effective if the window is hidden
 if (bWasVisible)
+{
 pChild->hide();
+if (!bModal)
+modalReparent(false);
+}
 
 pChild->setWindowModality(bModal ? Qt::WindowModal : Qt::NonModal);
 
 if (bWasVisible)
+{
+if (bModal)
+modalReparent(true);
 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-09-21 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/Qt5AccessibleWidget.hxx |   18 +
 vcl/qt5/Qt5AccessibleWidget.cxx |  111 
 2 files changed, 129 insertions(+)

New commits:
commit 6735a37747a3443ebd1c29c870a5eb26990350f2
Author: Michael Weghorn 
AuthorDate: Tue Sep 21 14:47:51 2021 +0200
Commit: Michael Weghorn 
CommitDate: Tue Sep 21 21:37:40 2021 +0200

qt5 a11y: Implement QAccessibleTableCellInterface

Let 'Qt5AccessibleWidget' derive from 'QAccessibleTableCellInterface'
and implement the most important methods.
This is e.g. one of the steps needed to make Orca announce
the focused cell in Calc.

Since there's no specific XInterface for table cells
make use of the fact that a table cell's parent is a table
and query information from there, similar to how the following
commit does for winaccessibility:

commit 97a88e30e2e084ab860635ff4e0a03442d8a12af
Author: Michael Weghorn 
Date:   Wed Sep 8 14:37:53 2021 +0100

tdf#100086 tdf#124832 wina11y: Implement IAccessibleTableCell

Change-Id: I160bc04f3e4fcf7b77723540aba6945b8fdf36ae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122395
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/Qt5AccessibleWidget.hxx 
b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
index 54c967bf0ab1..54dab2e672f5 100644
--- a/vcl/inc/qt5/Qt5AccessibleWidget.hxx
+++ b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -27,6 +28,11 @@
 
 #include 
 
+namespace com::sun::star::accessibility
+{
+class XAccessibleTable;
+}
+
 class Qt5Frame;
 class Qt5Widget;
 
@@ -35,6 +41,7 @@ class Qt5AccessibleWidget final : public QObject,
   public QAccessibleActionInterface,
   public QAccessibleTextInterface,
   public QAccessibleEditableTextInterface,
+  public QAccessibleTableCellInterface,
   public QAccessibleTableInterface,
   public QAccessibleValueInterface
 {
@@ -129,12 +136,23 @@ public:
 virtual bool unselectColumn(int column) override;
 virtual bool unselectRow(int row) override;
 
+// QAccessibleTableCellInterface
+virtual QList columnHeaderCells() const override;
+virtual int columnIndex() const override;
+virtual bool isSelected() const override;
+virtual int columnExtent() const override;
+virtual QList rowHeaderCells() const override;
+virtual int rowExtent() const override;
+virtual int rowIndex() const override;
+virtual QAccessibleInterface* table() const override;
+
 // Factory
 static QAccessibleInterface* customFactory(const QString& classname, 
QObject* object);
 
 private:
 css::uno::Reference m_xAccessible;
 css::uno::Reference 
getAccessibleContextImpl() const;
+css::uno::Reference 
getAccessibleTableForParent() const;
 QObject* m_pObject;
 };
 
diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx
index f49bb59ce0b4..f7d833407a75 100644
--- a/vcl/qt5/Qt5AccessibleWidget.cxx
+++ b/vcl/qt5/Qt5AccessibleWidget.cxx
@@ -100,6 +100,24 @@ Reference 
Qt5AccessibleWidget::getAccessibleContextImpl() co
 return xAc;
 }
 
+css::uno::Reference
+Qt5AccessibleWidget::getAccessibleTableForParent() const
+{
+Reference xAcc = getAccessibleContextImpl();
+if (!xAcc.is())
+return nullptr;
+
+Reference xParent = xAcc->getAccessibleParent();
+if (!xParent.is())
+return nullptr;
+
+Reference xParentContext = 
xParent->getAccessibleContext();
+if (!xParentContext.is())
+return nullptr;
+
+return Reference(xParentContext, UNO_QUERY);
+}
+
 QWindow* Qt5AccessibleWidget::window() const { return nullptr; }
 
 int Qt5AccessibleWidget::childCount() const
@@ -725,6 +743,8 @@ void* 
Qt5AccessibleWidget::interface_cast(QAccessible::InterfaceType t)
 return static_cast(this);
 if (t == QAccessible::ValueInterface)
 return static_cast(this);
+if (t == QAccessible::TableCellInterface)
+return static_cast(this);
 if (t == QAccessible::TableInterface)
 return static_cast(this);
 return nullptr;
@@ -1343,4 +1363,95 @@ bool Qt5AccessibleWidget::unselectRow(int row)
 return xTableSelection->unselectRow(row);
 }
 
+QList Qt5AccessibleWidget::columnHeaderCells() const
+{
+SAL_WARN("vcl.qt5", "Unsupported 
QAccessibleTableCellInterface::columnHeaderCells");
+return QList();
+}
+
+int Qt5AccessibleWidget::columnIndex() const
+{
+Reference xAcc = getAccessibleContextImpl();
+if (!xAcc.is())
+return -1;
+
+Reference xTable = getAccessibleTableForParent();
+if (!xTable.is())
+return -1;
+
+const sal_Int32 nIndexInParent = xAcc->getAccessibleIndexInParent();
+

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-09-21 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/Qt5AccessibleWidget.hxx |3 ---
 vcl/qt5/Qt5AccessibleWidget.cxx |4 
 2 files changed, 7 deletions(-)

New commits:
commit 0ae1c36f319b0c84d5e592f44738e67945eab3a1
Author: Michael Weghorn 
AuthorDate: Tue Sep 21 14:35:04 2021 +0200
Commit: Michael Weghorn 
CommitDate: Tue Sep 21 21:37:06 2021 +0200

qt5 a11y: Drop Qt5AccessibleWidget::{text,value}Interface

They're unused and at first glance look like they might
be overriding the non-virtual methods
from 'QAccessibleInterface' with the same name that
do something more useful (calling 'interface_cast'
with the corresponding 'QAccessible::InterfaceType'
param).

Change-Id: I9258a5f9386f9a7d23bb35cfa33e55a169eb753e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122394
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/Qt5AccessibleWidget.hxx 
b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
index aacaba9a80c8..54c967bf0ab1 100644
--- a/vcl/inc/qt5/Qt5AccessibleWidget.hxx
+++ b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
@@ -74,9 +74,6 @@ public:
 void doAction(const QString& actionName) override;
 QStringList keyBindingsForAction(const QString& actionName) const override;
 
-static QAccessibleValueInterface* valueInterface();
-static QAccessibleTextInterface* textInterface();
-
 // QAccessibleTextInterface
 void addSelection(int startOffset, int endOffset) override;
 QString attributes(int offset, int* startOffset, int* endOffset) const 
override;
diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx
index 65d5faafb918..f49bb59ce0b4 100644
--- a/vcl/qt5/Qt5AccessibleWidget.cxx
+++ b/vcl/qt5/Qt5AccessibleWidget.cxx
@@ -826,10 +826,6 @@ QStringList 
Qt5AccessibleWidget::keyBindingsForAction(const QString& actionName)
 return keyBindings;
 }
 
-QAccessibleValueInterface* Qt5AccessibleWidget::valueInterface() { return 
nullptr; }
-
-QAccessibleTextInterface* Qt5AccessibleWidget::textInterface() { return 
nullptr; }
-
 // QAccessibleTextInterface
 void Qt5AccessibleWidget::addSelection(int /* startOffset */, int /* endOffset 
*/)
 {


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-08-20 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Instance.hxx |3 +++
 vcl/qt5/Qt5Instance.cxx |8 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 0f7fed9249e988ca34c5401d746887822b4aa9ce
Author: Jan-Marek Glogowski 
AuthorDate: Thu Aug 19 20:18:47 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Fri Aug 20 09:56:01 2021 +0200

tdf#143957 Qt5 always create an OpenGLContext

Nothing checks the result and a lot of code just uses it.

Change-Id: I1a672e98d42673fd684538ead831622f6a14e9f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120761
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 41b9aca894d0..dc347021b9bb 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -133,7 +133,10 @@ public:
 virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override;
 virtual bool AnyInput(VclInputFlags nType) override;
 
+// so we fall back to the default abort, instead of duplicating it...
+#ifndef EMSCRIPTEN
 virtual OpenGLContext* CreateOpenGLContext() override;
+#endif
 
 virtual OUString GetConnectionIdentifier() override;
 
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index bf8d52961960..432af5e6f718 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -245,6 +245,10 @@ Qt5Instance::Qt5Instance(std::unique_ptr& 
pQApp, bool bUseCairo)
 
 connect(QGuiApplication::inputMethod(), ::localeChanged, this,
 ::localeChanged);
+
+#ifdef EMSCRIPTEN
+m_bSupportsOpenGL = false;
+#endif
 }
 
 Qt5Instance::~Qt5Instance()
@@ -432,7 +436,9 @@ OUString Qt5Instance::GetConnectionIdentifier() { return 
OUString(); }
 
 void Qt5Instance::AddToRecentDocumentList(const OUString&, const OUString&, 
const OUString&) {}
 
-OpenGLContext* Qt5Instance::CreateOpenGLContext() { return nullptr; }
+#ifndef EMSCRIPTEN
+OpenGLContext* Qt5Instance::CreateOpenGLContext() { return new 
Qt5OpenGLContext; }
+#endif
 
 bool Qt5Instance::IsMainThread() const
 {


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-07-30 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx  |7 +++
 vcl/inc/qt5/Qt5Widget.hxx |1 +
 vcl/qt5/Qt5Frame.cxx  |   10 ++
 vcl/qt5/Qt5Widget.cxx |   24 +---
 4 files changed, 31 insertions(+), 11 deletions(-)

New commits:
commit 9dcf5816c90e9819861332f11e014ef7b78e2fe7
Author: Jan-Marek Glogowski 
AuthorDate: Fri Jul 30 05:25:37 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Fri Jul 30 20:24:39 2021 +0200

tdf#143580 Qt5 don't use Qt::Popup for FLOAT wins

Main problem is, that Qt::Popup grabs the focus and therefore
generates a focus-out event for the combobox, which then closes
the just shown popup window. The grab happens inside QWidget
private code and there is no way around it. But instead of
"faking" Qt::Tooltip, this uses Qt::Widget with additional flags.

Regression from commit 7e6fee830116823b9cd8e46d6962df4ea2bc1ea6
("Qt5 fix Qt::Popup window handling").

Change-Id: Ia1f8e33d98f7ec36cf1ebc350886121dfaadd658
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119691
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index ed82c2a7a8fb..01b93ad3b825 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -210,6 +210,7 @@ public:
 inline bool CallCallback(SalEvent nEvent, const void* pEvent) const;
 
 void setInputLanguage(LanguageType);
+inline bool isPopup() const;
 };
 
 inline bool Qt5Frame::CallCallback(SalEvent nEvent, const void* pEvent) const
@@ -218,4 +219,10 @@ inline bool Qt5Frame::CallCallback(SalEvent nEvent, const 
void* pEvent) const
 return SalFrame::CallCallback(nEvent, pEvent);
 }
 
+inline bool Qt5Frame::isPopup() const
+{
+return ((m_nStyle & SalFrameStyleFlags::FLOAT)
+&& !(m_nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION));
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 7bf7ead6ae9a..60db1a306efd 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -75,6 +75,7 @@ class Qt5Widget : public QWidget
 
 void inputMethodEvent(QInputMethodEvent*) override;
 QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
+static void closePopup();
 
 public:
 Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 02032d149d29..a4c78d1b71a7 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -146,9 +146,11 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 aWinFlags |= Qt::Tool | Qt::FramelessWindowHint;
 else if (nStyle & SalFrameStyleFlags::TOOLTIP)
 aWinFlags |= Qt::ToolTip;
-else if ((nStyle & SalFrameStyleFlags::FLOAT)
- && !(nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION))
-aWinFlags |= Qt::Popup;
+// Can't use Qt::Popup, because it grabs the input focus and generates
+// a focus-out event, reaking the compbo box. This used to map to
+// Qt::ToolTip, which doesn't feel that correct...
+else if (isPopup())
+aWinFlags = Qt::Widget | Qt::FramelessWindowHint | 
Qt::BypassWindowManagerHint;
 else if (nStyle & SalFrameStyleFlags::TOOLWINDOW)
 aWinFlags |= Qt::Tool;
 // top level windows can't be transient in Qt, so make them dialogs, 
if they have a parent. At least
@@ -426,7 +428,7 @@ void Qt5Frame::Show(bool bVisible, bool bNoActivate)
 pSalInst->RunInMainThread([this, bVisible, bNoActivate]() {
 asChild()->setVisible(bVisible);
 asChild()->raise();
-if (!bNoActivate)
+if (!bNoActivate && !isPopup())
 {
 asChild()->activateWindow();
 asChild()->setFocus();
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index ebb11cef51ff..864701340ad3 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -179,11 +180,10 @@ void Qt5Widget::handleMouseButtonEvent(const Qt5Frame& 
rFrame, const QMouseEvent
 
 void Qt5Widget::mousePressEvent(QMouseEvent* pEvent)
 {
-if ((windowFlags() & Qt::Popup)
-&& !geometry().translated(geometry().topLeft() * 
-1).contains(pEvent->pos()))
-close();
-else
-handleMousePressEvent(m_rFrame, pEvent);
+handleMousePressEvent(m_rFrame, pEvent);
+if (m_rFrame.isPopup()
+|| !geometry().translated(geometry().topLeft() * 
-1).contains(pEvent->pos()))
+closePopup();
 }
 
 void Qt5Widget::mouseReleaseEvent(QMouseEvent* pEvent)
@@ -593,10 +593,21 @@ void Qt5Widget::keyReleaseEvent(QKeyEvent* pEvent)
 
 void Qt5Widget::focusInEvent(QFocusEvent*) { 
m_rFrame.CallCallback(SalEvent::GetFocus, nullptr); }
 
+void Qt5Widget::closePopup()
+{
+VclPtr pFirstFloat = 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-07-20 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx |1 
 vcl/qt5/Qt5Frame.cxx |3 +
 vcl/qt5/Qt5Widget.cxx|   81 +++
 3 files changed, 85 insertions(+)

New commits:
commit 862fdb98ca271b60a831cd5420fd16d5f9c1c747
Author: Jan-Marek Glogowski 
AuthorDate: Mon Jul 19 15:17:53 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Tue Jul 20 15:20:14 2021 +0200

tdf#143298 Qt5 send SalEvent::KeyModChange events

I originally omitted this in the Qt implementation, as I couldn't
find any non-working use case.

The implementation got a bit hacky, because Qt doesn't have a non-
native way to identify different L/R modifier keys, so we must
process the X11/xkb keycode ourself, which obviously won't work on
Wayland... but most times this is not relevant, so the default
modifier notification may be good enough.

P.S. it's basically the same code then X11 and Gtk...

Change-Id: I37fbfde4a33a966b6017f3e0c280e2c7ea91e4db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119235
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index f90936528399..ed82c2a7a8fb 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -102,6 +102,7 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public 
SalFrame
 
 #if QT5_USING_X11
 ScreenSaverInhibitor m_ScreenSaverInhibitor;
+ModKeyFlags m_nKeyModifiers;
 #endif
 
 LanguageType m_nInputLanguage;
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 6dc54d9408e3..322f293828cd 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -113,6 +113,9 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 , m_bDefaultPos(true)
 , m_bFullScreen(false)
 , m_bFullScreenSpanAll(false)
+#if QT5_USING_X11
+, m_nKeyModifiers(ModKeyFlags::NONE)
+#endif
 , m_nInputLanguage(LANGUAGE_DONTKNOW)
 {
 Qt5Instance* pInst = static_cast(GetSalData()->m_pInstance);
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index a2bf8fe6472d..2e97132f5e75 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -52,6 +52,11 @@
 #include 
 #include 
 
+#if QT5_USING_X11
+#define XK_MISCELLANY
+#include 
+#endif
+
 using namespace com::sun::star;
 
 void Qt5Widget::paintEvent(QPaintEvent* pEvent)
@@ -444,6 +449,82 @@ bool Qt5Widget::handleKeyEvent(Qt5Frame& rFrame, const 
QWidget& rWidget, QKeyEve
 return true;
 }
 
+if (nCode == 0)
+{
+sal_uInt16 nModCode = GetKeyModCode(pEvent->modifiers());
+SalKeyModEvent aModEvt;
+aModEvt.mbDown = eState == ButtonKeyState::Pressed;
+aModEvt.mnModKeyCode = ModKeyFlags::NONE;
+
+#if QT5_USING_X11
+if (QGuiApplication::platformName() == "xcb")
+{
+// pressing just the ctrl key leads to a keysym of XK_Control but
+// the event state does not contain ControlMask. In the release
+// event it's the other way round: it does contain the Control 
mask.
+// The modifier mode therefore has to be adapted manually.
+ModKeyFlags nExtModMask = ModKeyFlags::NONE;
+sal_uInt16 nModMask = 0;
+switch (pEvent->nativeVirtualKey())
+{
+case XK_Control_L:
+nExtModMask = ModKeyFlags::LeftMod1;
+nModMask = KEY_MOD1;
+break;
+case XK_Control_R:
+nExtModMask = ModKeyFlags::RightMod1;
+nModMask = KEY_MOD1;
+break;
+case XK_Alt_L:
+nExtModMask = ModKeyFlags::LeftMod2;
+nModMask = KEY_MOD2;
+break;
+case XK_Alt_R:
+nExtModMask = ModKeyFlags::RightMod2;
+nModMask = KEY_MOD2;
+break;
+case XK_Shift_L:
+nExtModMask = ModKeyFlags::LeftShift;
+nModMask = KEY_SHIFT;
+break;
+case XK_Shift_R:
+nExtModMask = ModKeyFlags::RightShift;
+nModMask = KEY_SHIFT;
+break;
+// Map Meta/Super keys to MOD3 modifier on all Unix systems
+// except macOS
+case XK_Meta_L:
+case XK_Super_L:
+nExtModMask = ModKeyFlags::LeftMod3;
+nModMask = KEY_MOD3;
+break;
+case XK_Meta_R:
+case XK_Super_R:
+nExtModMask = ModKeyFlags::RightMod3;
+nModMask = KEY_MOD3;
+break;
+}
+
+if (eState == ButtonKeyState::Released)
+{
+aModEvt.mnModKeyCode = 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-07-20 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx |1 -
 vcl/qt5/Qt5Frame.cxx |8 ++--
 2 files changed, 2 insertions(+), 7 deletions(-)

New commits:
commit ec77a2ed0283cb3446f6e352fc329afd3dfb785c
Author: Jan-Marek Glogowski 
AuthorDate: Mon Jul 19 23:28:47 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Tue Jul 20 15:03:07 2021 +0200

tdf#143334 Qt5 don't reset buffer on style change

This bug was "unveiled" by commit
963f252cd1ea9c268a6ced68a3454b10cbee1a89 ("Qt5/KF5 get rid
of unneeded own grahics handling"). I'm not sure why I ever came
up with that code. Eventually we would need a paint event, but at
least changing the theme correctly updated LO UI, so that seems
to be handled correctly.

Change-Id: I528b551180be184427eb2977e2b7da073ce6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119237
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 62877e15e89a..f90936528399 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -83,7 +83,6 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public 
SalFrame
 bool m_bNullRegion;
 
 bool m_bGraphicsInUse;
-bool m_bGraphicsInvalid;
 SalFrameStyleFlags m_nStyle;
 Qt5Frame* m_pParent;
 PointerStyle m_ePointerStyle;
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 36ce1222cb5e..6dc54d9408e3 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -105,7 +105,6 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 , m_bUseCairo(bUseCairo)
 , m_bNullRegion(true)
 , m_bGraphicsInUse(false)
-, m_bGraphicsInvalid(false)
 , m_ePointerStyle(PointerStyle::Arrow)
 , m_pDragSource(nullptr)
 , m_pDropTarget(nullptr)
@@ -296,7 +295,7 @@ SalGraphics* Qt5Frame::AcquireGraphics()
 
 if (m_bUseCairo)
 {
-if (!m_pSvpGraphics || m_bGraphicsInvalid)
+if (!m_pSvpGraphics)
 {
 QSize aSize = m_pQWidget->size() * devicePixelRatioF();
 m_pSvpGraphics.reset(new Qt5SvpGraphics(this));
@@ -306,20 +305,18 @@ SalGraphics* Qt5Frame::AcquireGraphics()
basegfx::B2IVector(aSize.width(), 
aSize.height()));
 cairo_surface_set_user_data(m_pSurface.get(), 
Qt5SvpGraphics::getDamageKey(),
 _aDamageHandler, nullptr);
-m_bGraphicsInvalid = false;
 }
 return m_pSvpGraphics.get();
 }
 else
 {
-if (!m_pQt5Graphics || m_bGraphicsInvalid)
+if (!m_pQt5Graphics)
 {
 m_pQt5Graphics.reset(new Qt5Graphics(this));
 m_pQImage.reset(
 new QImage(m_pQWidget->size() * devicePixelRatioF(), 
Qt5_DefaultFormat32));
 m_pQImage->fill(Qt::transparent);
 m_pQt5Graphics->ChangeQImage(m_pQImage.get());
-m_bGraphicsInvalid = false;
 }
 return m_pQt5Graphics.get();
 }
@@ -1153,7 +1150,6 @@ void Qt5Frame::UpdateSettings(AllSettings& rSettings)
 style.SetShadowColor(toColor(pal.color(QPalette::Disabled, 
QPalette::WindowText)));
 style.SetDarkShadowColor(toColor(pal.color(QPalette::Inactive, 
QPalette::WindowText)));
 
-m_bGraphicsInvalid = true;
 rSettings.SetStyleSettings(style);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/unx

2021-04-14 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Instance.hxx|2 ++
 vcl/qt5/Qt5Instance.cxx|   16 
 vcl/unx/kf5/KF5SalInstance.cxx |2 +-
 3 files changed, 15 insertions(+), 5 deletions(-)

New commits:
commit dbdc0475097210ec88f1e867b4464fdcd17a5d37
Author: Jan-Marek Glogowski 
AuthorDate: Sun Apr 11 14:05:59 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Wed Apr 14 14:35:38 2021 +0200

Qt add additional info to ToolkitName

Adds the used font backend and the QPA platform name, so we don't
need to ask / verify all time (and less chance of wrong info).

Examples:
- qt5 (qfont+xcb) => QFont text rendering + X11 backend
- kf5 (cairo+wayland) => Cairo text rendering + Wayland backend

Change-Id: I1102dd6d83b0ed48318ac5c31c8ca09d4fdd73eb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113945
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 5dc2db898d29..111e86f0878a 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -84,6 +84,8 @@ protected:
 createPicker(css::uno::Reference const& 
context,
  QFileDialog::FileMode);
 bool useCairo() const { return m_bUseCairo; }
+// encodes cairo usage and Qt platform name into the ToolkitName
+OUString constructToolkitID(std::u16string_view sTKname);
 
 public:
 explicit Qt5Instance(std::unique_ptr& pQApp, bool bUseCairo 
= false);
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 5afbd8722418..3ea129b8aeea 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -196,6 +196,17 @@ void Qt5Instance::RunInMainThread(std::function 
func)
 }
 }
 
+OUString Qt5Instance::constructToolkitID(std::u16string_view sTKname)
+{
+OUString sID(sTKname + OUStringLiteral(u" ("));
+if (m_bUseCairo)
+sID += OUStringLiteral(u"cairo+");
+else
+sID += OUStringLiteral(u"qfont+");
+sID += toOUString(QGuiApplication::platformName()) + OUStringLiteral(u")");
+return sID;
+}
+
 Qt5Instance::Qt5Instance(std::unique_ptr& pQApp, bool bUseCairo)
 : SalGenericInstance(std::make_unique())
 , m_bUseCairo(bUseCairo)
@@ -206,10 +217,7 @@ Qt5Instance::Qt5Instance(std::unique_ptr& 
pQApp, bool bUseCairo)
 , m_bUpdateFonts(false)
 {
 ImplSVData* pSVData = ImplGetSVData();
-if (bUseCairo)
-pSVData->maAppData.mxToolkitName = OUString("qt5+cairo");
-else
-pSVData->maAppData.mxToolkitName = OUString("qt5");
+pSVData->maAppData.mxToolkitName = constructToolkitID(u"qt5");
 
 // this one needs to be blocking, so that the handling in main thread
 // is processed before the thread emitting the signal continues
diff --git a/vcl/unx/kf5/KF5SalInstance.cxx b/vcl/unx/kf5/KF5SalInstance.cxx
index 1335d4123a2e..608b5dccc4dc 100644
--- a/vcl/unx/kf5/KF5SalInstance.cxx
+++ b/vcl/unx/kf5/KF5SalInstance.cxx
@@ -37,7 +37,7 @@ KF5SalInstance::KF5SalInstance(std::unique_ptr& 
pQApp, bool bUseCa
 : Qt5Instance(pQApp, bUseCairo)
 {
 ImplSVData* pSVData = ImplGetSVData();
-pSVData->maAppData.mxToolkitName = OUString("kf5");
+pSVData->maAppData.mxToolkitName = constructToolkitID(u"kf5");
 }
 
 SalFrame* KF5SalInstance::CreateChildFrame(SystemParentData* /*pParent*/, 
SalFrameStyleFlags nStyle)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/unx

2021-04-11 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx   |7 +--
 vcl/inc/qt5/Qt5Instance.hxx|1 +
 vcl/qt5/Qt5Frame.cxx   |   28 +++-
 vcl/unx/kf5/KF5SalFrame.cxx|   24 
 vcl/unx/kf5/KF5SalFrame.hxx|6 --
 vcl/unx/kf5/KF5SalInstance.cxx |   13 +++--
 vcl/unx/kf5/KF5SalInstance.hxx |1 +
 7 files changed, 21 insertions(+), 59 deletions(-)

New commits:
commit 963f252cd1ea9c268a6ced68a3454b10cbee1a89
Author: Jan-Marek Glogowski 
AuthorDate: Sun Apr 11 17:40:26 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Sun Apr 11 21:13:50 2021 +0200

Qt5/KF5 get rid of unneeded own grahics handling

This was hiding tdf#141623, when I decided to implement the override
to run the kf5 VCL plugin with the qfont text rendering.

Change-Id: Id1fcd363bd77a756cb27e3a171c872ce792da5ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113956
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index c07fda54ec40..828f212babfb 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -77,11 +77,7 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public 
SalFrame
 std::unique_ptr m_pQImage;
 std::unique_ptr m_pQt5Graphics;
 UniqueCairoSurface m_pSurface;
-std::unique_ptr m_pOurSvpGraphics;
-// in base class, this ptr is the same as m_pOurSvpGraphic
-// in derived class, it can point to a derivative
-// of Qt5SvpGraphics (which the derived class then owns)
-Qt5SvpGraphics* m_pSvpGraphics;
+std::unique_ptr m_pSvpGraphics;
 DamageHandler m_aDamageHandler;
 QRegion m_aRegion;
 bool m_bNullRegion;
@@ -146,7 +142,6 @@ public:
 void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 
nExtentsWidth,
 sal_Int32 nExtentsHeight) const;
 
-void InitQt5SvpGraphics(Qt5SvpGraphics* pQt5SvpGraphics);
 virtual SalGraphics* AcquireGraphics() override;
 virtual void ReleaseGraphics(SalGraphics* pGraphics) override;
 
diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 8cfa9ac960f1..5dc2db898d29 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -83,6 +83,7 @@ protected:
 virtual rtl::Reference
 createPicker(css::uno::Reference const& 
context,
  QFileDialog::FileMode);
+bool useCairo() const { return m_bUseCairo; }
 
 public:
 explicit Qt5Instance(std::unique_ptr& pQApp, bool bUseCairo 
= false);
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 68f7a8120460..97cc7e938446 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -103,7 +103,6 @@ sal_Int32 screenNumber(const QScreen* pScreen)
 Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool 
bUseCairo)
 : m_pTopLevel(nullptr)
 , m_bUseCairo(bUseCairo)
-, m_pSvpGraphics(nullptr)
 , m_bNullRegion(true)
 , m_bGraphicsInUse(false)
 , m_bGraphicsInvalid(false)
@@ -288,17 +287,6 @@ void Qt5Frame::Damage(sal_Int32 nExtentsX, sal_Int32 
nExtentsY, sal_Int32 nExten
1 / devicePixelRatioF()));
 }
 
-void Qt5Frame::InitQt5SvpGraphics(Qt5SvpGraphics* pQt5SvpGraphics)
-{
-QSize aSize = m_pQWidget->size() * devicePixelRatioF();
-m_pSvpGraphics = pQt5SvpGraphics;
-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()));
-cairo_surface_set_user_data(m_pSurface.get(), 
Qt5SvpGraphics::getDamageKey(), _aDamageHandler,
-nullptr);
-}
-
 SalGraphics* Qt5Frame::AcquireGraphics()
 {
 if (m_bGraphicsInUse)
@@ -308,13 +296,19 @@ SalGraphics* Qt5Frame::AcquireGraphics()
 
 if (m_bUseCairo)
 {
-if (!m_pOurSvpGraphics || m_bGraphicsInvalid)
+if (!m_pSvpGraphics || m_bGraphicsInvalid)
 {
-m_pOurSvpGraphics.reset(new Qt5SvpGraphics(this));
-InitQt5SvpGraphics(m_pOurSvpGraphics.get());
+QSize aSize = m_pQWidget->size() * devicePixelRatioF();
+m_pSvpGraphics.reset(new Qt5SvpGraphics(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()));
+cairo_surface_set_user_data(m_pSurface.get(), 
Qt5SvpGraphics::getDamageKey(),
+_aDamageHandler, nullptr);
 m_bGraphicsInvalid = false;
 }
-return m_pOurSvpGraphics.get();
+return m_pSvpGraphics.get();
 }
 else
 {
@@ -335,7 +329,7 @@ void Qt5Frame::ReleaseGraphics(SalGraphics* pSalGraph)
 {
 (void)pSalGraph;
 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-04-07 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/qt5/Qt5Graphics.hxx |  207 ++---
 vcl/inc/qt5/Qt5GraphicsBase.hxx |3 
 vcl/inc/qt5/Qt5Painter.hxx  |5 
 vcl/inc/salgdi.hxx  |   15 ++
 vcl/inc/salgdiimpl.hxx  |   15 ++
 vcl/qt5/Qt5Bitmap.cxx   |2 
 vcl/qt5/Qt5Graphics.cxx |   26 
 vcl/qt5/Qt5Graphics_GDI.cxx |  220 
 vcl/qt5/Qt5Graphics_Text.cxx|2 
 vcl/qt5/Qt5Painter.cxx  |2 
 10 files changed, 302 insertions(+), 195 deletions(-)

New commits:
commit 33da78c21f4243a3e469fb7df79ed1745df70078
Author: Tomaž Vajngerl 
AuthorDate: Wed Apr 7 21:27:11 2021 +0900
Commit: Tomaž Vajngerl 
CommitDate: Wed Apr 7 17:46:14 2021 +0200

vcl: move graphic handling into Qt5GraphicsBackend

This is an effort to make SalGraphicsImpl mandatory for all
backends.
This introduces Qt5GraphicsBackend: a subclass of SalGraphicsImpl,
which now handles graphic rendering.

Change-Id: I42aece59d0c692ca1dd33e30f31c5bcceab02008
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113734
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/inc/qt5/Qt5Graphics.hxx b/vcl/inc/qt5/Qt5Graphics.hxx
index e90731179d53..011d3384e804 100644
--- a/vcl/inc/qt5/Qt5Graphics.hxx
+++ b/vcl/inc/qt5/Qt5Graphics.hxx
@@ -37,9 +37,8 @@ class Qt5FontFace;
 class Qt5Frame;
 class Qt5Painter;
 
-class Qt5Graphics final : public SalGraphics, public Qt5GraphicsBase
+class Qt5GraphicsBackend final : public SalGraphicsImpl, public Qt5GraphicsBase
 {
-friend class Qt5Bitmap;
 friend class Qt5Painter;
 
 Qt5Frame* m_pFrame;
@@ -50,6 +49,124 @@ class Qt5Graphics final : public SalGraphics, public 
Qt5GraphicsBase
 Color m_aFillColor;
 QPainter::CompositionMode m_eCompositionMode;
 
+public:
+Qt5GraphicsBackend(Qt5Frame* pFrame, QImage* pQImage);
+~Qt5GraphicsBackend() override;
+
+void Init() override {}
+
+QImage* getQImage() { return m_pQImage; }
+
+void setQImage(QImage* pQImage) { m_pQImage = pQImage; }
+
+void freeResources() override {}
+
+OUString getRenderBackendName() const override { return "qt5"; }
+
+bool setClipRegion(vcl::Region const& rRegion) override;
+void ResetClipRegion() override;
+
+sal_uInt16 GetBitCount() const override;
+
+tools::Long GetGraphicsWidth() const override;
+
+void SetLineColor() override;
+void SetLineColor(Color nColor) override;
+void SetFillColor() override;
+void SetFillColor(Color nColor) override;
+void SetXORMode(bool bSet, bool bInvertOnly) override;
+void SetROPLineColor(SalROPColor nROPColor) override;
+void SetROPFillColor(SalROPColor nROPColor) override;
+
+void drawPixel(tools::Long nX, tools::Long nY) override;
+void drawPixel(tools::Long nX, tools::Long nY, Color nColor) override;
+
+void drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, 
tools::Long nY2) override;
+void drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth, 
tools::Long nHeight) override;
+void drawPolyLine(sal_uInt32 nPoints, const Point* pPointArray) override;
+void drawPolygon(sal_uInt32 nPoints, const Point* pPointArray) override;
+void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPoints,
+ const Point** pPointArray) override;
+
+bool drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice,
+ const basegfx::B2DPolyPolygon&, double fTransparency) 
override;
+
+bool drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, const 
basegfx::B2DPolygon&,
+  double fTransparency, double fLineWidth, const 
std::vector* pStroke,
+  basegfx::B2DLineJoin, css::drawing::LineCap, double 
fMiterMinimumAngle,
+  bool bPixelSnapHairline) override;
+
+bool drawPolyLineBezier(sal_uInt32 nPoints, const Point* pPointArray,
+const PolyFlags* pFlagArray) override;
+
+bool drawPolygonBezier(sal_uInt32 nPoints, const Point* pPointArray,
+   const PolyFlags* pFlagArray) override;
+
+bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32* pPoints,
+   const Point* const* pPointArray,
+   const PolyFlags* const* pFlagArray) override;
+
+void copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, 
tools::Long nSrcY,
+  tools::Long nSrcWidth, tools::Long nSrcHeight, bool 
bWindowInvalidate) override;
+
+void copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) 
override;
+
+void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) 
override;
+
+void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
+const SalBitmap& rMaskBitmap) override;
+
+void drawMask(const SalTwoRect& rPosAry, const SalBitmap& 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2021-04-05 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/qt5/Qt5Bitmap.hxx   |4 -
 vcl/qt5/Qt5Bitmap.cxx   |  135 
 vcl/qt5/Qt5Graphics_GDI.cxx |   22 +--
 3 files changed, 18 insertions(+), 143 deletions(-)

New commits:
commit 615ceb107e9faf01b568b0a2440a3f09c8f88ca6
Author: Tomaž Vajngerl 
AuthorDate: Tue Apr 6 10:21:01 2021 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Apr 6 06:35:11 2021 +0200

vcl: remove 4-bit bitmap support from qt5 backend

We removed 4-bit support for bitmaps, but the qt5 backend still has
(special) support this bitmap format, which now can safely be
removed and make the backend a lot simpler.

Change-Id: I12309909a9ee3079cef7c4e59154ac48151e18d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113619
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/inc/qt5/Qt5Bitmap.hxx b/vcl/inc/qt5/Qt5Bitmap.hxx
index 8ff4297e43f0..201742ef39cd 100644
--- a/vcl/inc/qt5/Qt5Bitmap.hxx
+++ b/vcl/inc/qt5/Qt5Bitmap.hxx
@@ -29,11 +29,7 @@ class Qt5Bitmap final : public SalBitmap
 {
 std::unique_ptr m_pImage;
 BitmapPalette m_aPalette;
-
-// for 4bit support
-std::unique_ptr m_pBuffer;
 Size m_aSize;
-sal_uInt32 m_nScanline;
 
 public:
 Qt5Bitmap();
diff --git a/vcl/qt5/Qt5Bitmap.cxx b/vcl/qt5/Qt5Bitmap.cxx
index fd7932f879bd..a9ea1f707431 100644
--- a/vcl/qt5/Qt5Bitmap.cxx
+++ b/vcl/qt5/Qt5Bitmap.cxx
@@ -41,33 +41,11 @@ bool Qt5Bitmap::Create(const Size& rSize, sal_uInt16 
nBitCount, const BitmapPale
 
 if (nBitCount == 1)
 assert(2 >= rPal.GetEntryCount());
-if (nBitCount == 4)
-assert(16 >= rPal.GetEntryCount());
 if (nBitCount == 8)
 assert(256 >= rPal.GetEntryCount());
 
-if (nBitCount == 4)
-{
-m_pImage.reset();
-m_aSize = rSize;
-bool bFail = o3tl::checked_multiply(rSize.Width(), 
nBitCount, m_nScanline);
-if (bFail)
-{
-SAL_WARN("vcl.gdi", "checked multiply failed");
-return false;
-}
-m_nScanline = AlignedWidth4Bytes(m_nScanline);
-sal_uInt8* pBuffer = nullptr;
-if (0 != m_nScanline && 0 != rSize.Height())
-pBuffer = new sal_uInt8[m_nScanline * rSize.Height()];
-m_pBuffer.reset(pBuffer);
-}
-else
-{
-m_pImage.reset(new QImage(toQSize(rSize), getBitFormat(nBitCount)));
-m_pImage->fill(Qt::transparent);
-m_pBuffer.reset();
-}
+m_pImage.reset(new QImage(toQSize(rSize), getBitFormat(nBitCount)));
+m_pImage->fill(Qt::transparent);
 m_aPalette = rPal;
 
 auto count = rPal.GetEntryCount();
@@ -84,25 +62,7 @@ bool Qt5Bitmap::Create(const Size& rSize, sal_uInt16 
nBitCount, const BitmapPale
 bool Qt5Bitmap::Create(const SalBitmap& rSalBmp)
 {
 const Qt5Bitmap* pBitmap = static_cast();
-if (pBitmap->m_pImage)
-{
-m_pImage.reset(new QImage(*pBitmap->m_pImage));
-m_pBuffer.reset();
-}
-else
-{
-m_aSize = pBitmap->m_aSize;
-m_nScanline = pBitmap->m_nScanline;
-sal_uInt8* pBuffer = nullptr;
-if (0 != m_nScanline && 0 != m_aSize.Height())
-{
-sal_uInt32 nSize = m_nScanline * m_aSize.Height();
-pBuffer = new sal_uInt8[nSize];
-memcpy(pBuffer, pBitmap->m_pBuffer.get(), nSize);
-}
-m_pBuffer.reset(pBuffer);
-m_pImage.reset();
-}
+m_pImage.reset(new QImage(*pBitmap->m_pImage));
 m_aPalette = pBitmap->m_aPalette;
 return true;
 }
@@ -113,64 +73,16 @@ bool Qt5Bitmap::Create(const SalBitmap& rSalBmp, 
SalGraphics* pSalGraphics)
 Qt5Graphics* pGraphics = static_cast(pSalGraphics);
 QImage* pImage = pGraphics->m_pQImage;
 m_pImage.reset(new 
QImage(pBitmap->m_pImage->convertToFormat(pImage->format(;
-m_pBuffer.reset();
 return true;
 }
 
 bool Qt5Bitmap::Create(const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount)
 {
-assert((nNewBitCount == 1 || nNewBitCount == 4 || nNewBitCount == 8 || 
nNewBitCount == 24
-|| nNewBitCount == 32)
+assert((nNewBitCount == 1 || nNewBitCount == 8 || nNewBitCount == 24 || 
nNewBitCount == 32)
&& "Unsupported BitCount!");
 
 const Qt5Bitmap* pBitmap = static_cast();
-if (pBitmap->m_pBuffer)
-{
-if (nNewBitCount != 32)
-return false;
-
-// convert 4bit indexed palette to 32bit ARGB
-m_pImage.reset(new QImage(pBitmap->m_aSize.Width(), 
pBitmap->m_aSize.Height(),
-  getBitFormat(nNewBitCount)));
-m_pImage->fill(Qt::transparent);
-
-// prepare a whole palette
-const BitmapPalette& rPal = pBitmap->m_aPalette;
-QVector colorTable(16);
-int i = 0, maxEntry = pBitmap->m_aPalette.GetEntryCount();
-assert(maxEntry <= 16 && maxEntry >= 0);
-for (; i < maxEntry; ++i)
-colorTable[i] = qRgb(rPal[i].GetRed(), rPal[i].GetGreen(), 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/unx

2021-03-03 Thread Noel (via logerrit)
 vcl/inc/qt5/Qt5Instance.hxx|2 +-
 vcl/qt5/Qt5Instance.cxx|4 ++--
 vcl/unx/kf5/KF5SalInstance.cxx |4 ++--
 vcl/unx/kf5/KF5SalInstance.hxx |5 +++--
 4 files changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 9b56b718f6921b1160733e56f5cfc0d12c4146ab
Author: Noel 
AuthorDate: Mon Mar 1 20:36:56 2021 +0200
Commit: Noel Grandin 
CommitDate: Wed Mar 3 11:09:15 2021 +0100

loplugin:refcounting in vcl

Change-Id: I92e9db7abdfe5912335fd94e42422e8556d71091
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111769
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index cd9c51826a90..8cfa9ac960f1 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -80,7 +80,7 @@ Q_SIGNALS:
 void deleteObjectLaterSignal(QObject* pObject);
 
 protected:
-virtual Qt5FilePicker*
+virtual rtl::Reference
 createPicker(css::uno::Reference const& 
context,
  QFileDialog::FileMode);
 
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 97eff04fe77a..5afbd8722418 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -437,14 +437,14 @@ void Qt5Instance::ProcessEvent(SalUserEvent aEvent)
 aEvent.m_pFrame->CallCallback(aEvent.m_nEvent, aEvent.m_pData);
 }
 
-Qt5FilePicker*
+rtl::Reference
 Qt5Instance::createPicker(css::uno::Reference 
const& context,
   QFileDialog::FileMode eMode)
 {
 if (!IsMainThread())
 {
 SolarMutexGuard g;
-Qt5FilePicker* pPicker;
+rtl::Reference pPicker;
 RunInMainThread([&, this]() { pPicker = createPicker(context, eMode); 
});
 assert(pPicker);
 return pPicker;
diff --git a/vcl/unx/kf5/KF5SalInstance.cxx b/vcl/unx/kf5/KF5SalInstance.cxx
index 5b95ff8df572..4c1a87730e51 100644
--- a/vcl/unx/kf5/KF5SalInstance.cxx
+++ b/vcl/unx/kf5/KF5SalInstance.cxx
@@ -57,14 +57,14 @@ bool KF5SalInstance::hasNativeFileSelection() const
 return Qt5Instance::hasNativeFileSelection();
 }
 
-Qt5FilePicker*
+rtl::Reference
 KF5SalInstance::createPicker(css::uno::Reference 
const& context,
  QFileDialog::FileMode eMode)
 {
 if (!IsMainThread())
 {
 SolarMutexGuard g;
-Qt5FilePicker* pPicker;
+rtl::Reference pPicker;
 RunInMainThread([&, this]() { pPicker = createPicker(context, eMode); 
});
 assert(pPicker);
 return pPicker;
diff --git a/vcl/unx/kf5/KF5SalInstance.hxx b/vcl/unx/kf5/KF5SalInstance.hxx
index 5dd306da5231..b462e147003d 100644
--- a/vcl/unx/kf5/KF5SalInstance.hxx
+++ b/vcl/unx/kf5/KF5SalInstance.hxx
@@ -24,8 +24,9 @@
 class KF5SalInstance final : public Qt5Instance
 {
 bool hasNativeFileSelection() const override;
-Qt5FilePicker* 
createPicker(css::uno::Reference const& context,
-QFileDialog::FileMode) override;
+rtl::Reference
+createPicker(css::uno::Reference const& 
context,
+ QFileDialog::FileMode) override;
 
 SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) 
override;
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2020-11-22 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx|4 
 vcl/inc/qt5/Qt5Instance.hxx |1 +
 vcl/qt5/Qt5Frame.cxx|   11 ---
 vcl/qt5/Qt5Instance.cxx |   16 
 4 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit 9d96088c2832b681ae079b29cbc977231674ad52
Author: Jan-Marek Glogowski 
AuthorDate: Sun Nov 22 14:53:14 2020 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Sun Nov 22 17:01:07 2020 +0100

Qt5 report input method language

This is in the spirit of tdf#108151, based on the information Qt
provides for the IM setting. I don't know how correct it is,
especially looking at Caolans comment 3 in that bug report
regarding the assumed validity of GtkIMContextInfo. OTOH it seems
to work well enough for my simple tests.

Some BG info: while the QInputMethod object is a global one, it's
"bound" to the focused window. So you'll get change events, when
you change the input window, with the correct IM settings for the
new one, be it a real window or just the menu bar.

To prevent unneeded flushes of buffers and language lookup, this
caches the current IM language of a window.

The language is not affected just by changing keyboard mappings,
which the bug reporter requested! It just works with a configured
input method, like fcitx or ibus (which can have keyboard mappings
too, which work correctly).

Change-Id: Ia9133edf4d1ce77d29adbfe57c180db15db0a560
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106354
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 54a721e03730..c07fda54ec40 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -109,6 +109,8 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public 
SalFrame
 ScreenSaverInhibitor m_ScreenSaverInhibitor;
 #endif
 
+LanguageType m_nInputLanguage;
+
 void SetDefaultPos();
 Size CalcDefaultSize();
 void SetDefaultSize();
@@ -211,6 +213,8 @@ public:
 virtual void SetApplicationID(const OUString&) override;
 
 inline bool CallCallback(SalEvent nEvent, const void* pEvent) const;
+
+void setInputLanguage(LanguageType);
 };
 
 inline bool Qt5Frame::CallCallback(SalEvent nEvent, const void* pEvent) const
diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index d73a59de51c1..cd9c51826a90 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -73,6 +73,7 @@ class VCLPLUG_QT5_PUBLIC Qt5Instance : public QObject,
 private Q_SLOTS:
 bool ImplYield(bool bWait, bool bHandleAllCurrentEvents);
 static void deleteObjectLater(QObject* pObject);
+static void localeChanged();
 
 Q_SIGNALS:
 bool ImplYieldSignal(bool bWait, bool bHandleAllCurrentEvents);
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 06984b983a79..ad541db4f70c 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -116,6 +116,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 , m_bDefaultPos(true)
 , m_bFullScreen(false)
 , m_bFullScreenSpanAll(false)
+, m_nInputLanguage(LANGUAGE_DONTKNOW)
 {
 Qt5Instance* pInst = static_cast(GetSalData()->m_pInstance);
 pInst->insertFrame(this);
@@ -995,10 +996,14 @@ bool Qt5Frame::MapUnicodeToKeyCode(sal_Unicode 
/*aUnicode*/, LanguageType /*aLan
 return false;
 }
 
-LanguageType Qt5Frame::GetInputLanguage()
+LanguageType Qt5Frame::GetInputLanguage() { return m_nInputLanguage; }
+
+void Qt5Frame::setInputLanguage(LanguageType nInputLanguage)
 {
-// fallback
-return LANGUAGE_DONTKNOW;
+if (nInputLanguage == m_nInputLanguage)
+return;
+m_nInputLanguage = nInputLanguage;
+CallCallback(SalEvent::InputLanguageChange, nullptr);
 }
 
 static Color toColor(const QColor& rColor)
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index ca1f914dd707..97eff04fe77a 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -229,6 +229,9 @@ Qt5Instance::Qt5Instance(std::unique_ptr& 
pQApp, bool bUseCairo)
 connect(dispatcher, ::awake, this, [this]() { 
m_bSleeping = false; });
 connect(dispatcher, ::aboutToBlock, this,
 [this]() { m_bSleeping = true; });
+
+connect(QGuiApplication::inputMethod(), ::localeChanged, this,
+::localeChanged);
 }
 
 Qt5Instance::~Qt5Instance()
@@ -248,6 +251,19 @@ void Qt5Instance::AfterAppInit()
 : 
Qt::LeftToRight);
 }
 
+void Qt5Instance::localeChanged()
+{
+SolarMutexGuard aGuard;
+const vcl::Window* pFocusWindow = Application::GetFocusWindow();
+SalFrame* const pFocusFrame = pFocusWindow ? pFocusWindow->ImplGetFrame() 
: nullptr;
+if (!pFocusFrame)
+return;
+
+const LanguageTag aTag(
+

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2020-10-22 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5FontFace.hxx |5 -
 vcl/qt5/Qt5FontFace.cxx |   42 ++
 2 files changed, 38 insertions(+), 9 deletions(-)

New commits:
commit 90dd969e7db5aaa76117547d7892f3a9dc1db46f
Author: Jan-Marek Glogowski 
AuthorDate: Thu Oct 22 11:56:45 2020 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Thu Oct 22 15:53:24 2020 +0200

tdf#136915 correctly create QFont from Qt5FontFace

Store the origin of the Qt5FontFace and therefore the type of the
font ID and use either QFont::fromString or QFontDatabase::font to
generate the correct QFont instance.

Interestingly the QFont::fromString worked with the minimal font
string, ignoring the font style, but now fails with error messages
when including the point size. Guess Qt supports partial font
strings, as long as they match the segment types from the start.

Change-Id: I6b30423a5ae9abd8ee50d6087a3ec61d85f6320f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104652
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5FontFace.hxx b/vcl/inc/qt5/Qt5FontFace.hxx
index 9c893d4f88c8..e5b05e5b6f50 100644
--- a/vcl/inc/qt5/Qt5FontFace.hxx
+++ b/vcl/inc/qt5/Qt5FontFace.hxx
@@ -56,10 +56,13 @@ public:
 CreateFontInstance(const FontSelectPattern& rFSD) const override;
 
 private:
+typedef enum { Font, FontDB } FontIdType;
+
 Qt5FontFace(const Qt5FontFace&);
-Qt5FontFace(const FontAttributes& rFA, const QString& rFontID);
+Qt5FontFace(const FontAttributes&, const QString& rFontID, const 
FontIdType);
 
 const QString m_aFontId;
+const FontIdType m_eFontIdType;
 mutable FontCharMapRef m_xCharMap;
 mutable vcl::FontCapabilities m_aFontCapabilities;
 mutable bool m_bFontCapabilitiesRead;
diff --git a/vcl/qt5/Qt5FontFace.cxx b/vcl/qt5/Qt5FontFace.cxx
index ce349099030a..e8f13c412e91 100644
--- a/vcl/qt5/Qt5FontFace.cxx
+++ b/vcl/qt5/Qt5FontFace.cxx
@@ -41,6 +41,7 @@ using namespace vcl;
 Qt5FontFace::Qt5FontFace(const Qt5FontFace& rSrc)
 : PhysicalFontFace(rSrc)
 , m_aFontId(rSrc.m_aFontId)
+, m_eFontIdType(rSrc.m_eFontIdType)
 {
 if (rSrc.m_xCharMap.is())
 m_xCharMap = rSrc.m_xCharMap;
@@ -123,13 +124,14 @@ Qt5FontFace* Qt5FontFace::fromQFont(const QFont& rFont)
 {
 FontAttributes aFA;
 fillAttributesFromQFont(rFont, aFA);
-return new Qt5FontFace(aFA, rFont.toString());
+return new Qt5FontFace(aFA, rFont.toString(), FontIdType::Font);
 }
 
 Qt5FontFace* Qt5FontFace::fromQFontDatabase(const QString& aFamily, const 
QString& aStyle)
 {
 QFontDatabase aFDB;
 FontAttributes aFA;
+
 aFA.SetFamilyName(toOUString(aFamily));
 if (IsStarSymbol(aFA.GetFamilyName()))
 aFA.SetSymbolFlag(true);
@@ -137,12 +139,21 @@ Qt5FontFace* Qt5FontFace::fromQFontDatabase(const 
QString& aFamily, const QStrin
 aFA.SetPitch(aFDB.isFixedPitch(aFamily, aStyle) ? PITCH_FIXED : 
PITCH_VARIABLE);
 aFA.SetWeight(Qt5FontFace::toFontWeight(aFDB.weight(aFamily, aStyle)));
 aFA.SetItalic(aFDB.italic(aFamily, aStyle) ? ITALIC_NORMAL : ITALIC_NONE);
-return new Qt5FontFace(aFA, aFamily + "," + aStyle);
+
+int nPointSize = 0;
+QList aPointList = aFDB.pointSizes(aFamily, aStyle);
+if (!aPointList.empty())
+nPointSize = aPointList[0];
+
+return new Qt5FontFace(aFA, aFamily + "," + aStyle + "," + 
QString::number(nPointSize),
+   FontIdType::FontDB);
 }
 
-Qt5FontFace::Qt5FontFace(const FontAttributes& rFA, const QString& rFontID)
+Qt5FontFace::Qt5FontFace(const FontAttributes& rFA, const QString& rFontID,
+ const FontIdType eFontIdType)
 : PhysicalFontFace(rFA)
 , m_aFontId(rFontID)
+, m_eFontIdType(eFontIdType)
 , m_bFontCapabilitiesRead(false)
 {
 }
@@ -152,7 +163,24 @@ sal_IntPtr Qt5FontFace::GetFontId() const { return 
reinterpret_cast(
 QFont Qt5FontFace::CreateFont() const
 {
 QFont aFont;
-aFont.fromString(m_aFontId);
+switch (m_eFontIdType)
+{
+case FontDB:
+{
+QFontDatabase aFDB;
+QStringList aStrList = m_aFontId.split(",");
+if (3 == aStrList.size())
+aFont = aFDB.font(aStrList[0], aStrList[1], 
aStrList[2].toInt());
+else
+SAL_WARN("vcl.qt5", "Invalid QFontDatabase font ID " << 
m_aFontId);
+break;
+}
+case Font:
+bool bRet = aFont.fromString(m_aFontId);
+SAL_WARN_IF(!bRet, "vcl.qt5", "Failed to create QFont from ID: " 
<< m_aFontId);
+Q_UNUSED(bRet);
+break;
+}
 return aFont;
 }
 
@@ -167,8 +195,7 @@ FontCharMapRef Qt5FontFace::GetFontCharMap() const
 if (m_xCharMap.is())
 return m_xCharMap;
 
-QFont aFont;
-aFont.fromString(m_aFontId);
+QFont aFont = CreateFont();
 QRawFont aRawFont(QRawFont::fromFont(aFont));
 QByteArray 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2020-09-27 Thread Julien Nabet (via logerrit)
 vcl/inc/qt5/Qt5VirtualDevice.hxx |4 ++--
 vcl/qt5/Qt5VirtualDevice.cxx |4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

New commits:
commit 2a81fc0ee9478758f7a919519f922f0d4cb5f279
Author: Julien Nabet 
AuthorDate: Sun Sep 27 12:48:02 2020 +0200
Commit: Julien Nabet 
CommitDate: Sun Sep 27 16:17:04 2020 +0200

Replace list by vector in vcl/Qt5VirtualDevice

Change-Id: I137019c15d3ee2886ad1bd53e671a89990891481
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103506
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/inc/qt5/Qt5VirtualDevice.hxx b/vcl/inc/qt5/Qt5VirtualDevice.hxx
index 89251c96d783..ad0dc3c3c804 100644
--- a/vcl/inc/qt5/Qt5VirtualDevice.hxx
+++ b/vcl/inc/qt5/Qt5VirtualDevice.hxx
@@ -22,7 +22,7 @@
 #include 
 
 #include 
-#include 
+#include 
 
 #include 
 
@@ -32,7 +32,7 @@ enum class DeviceFormat;
 
 class Qt5VirtualDevice final : public SalVirtualDevice
 {
-std::list m_aGraphics;
+std::vector m_aGraphics;
 std::unique_ptr m_pImage;
 DeviceFormat m_eFormat;
 QSize m_aFrameSize;
diff --git a/vcl/qt5/Qt5VirtualDevice.cxx b/vcl/qt5/Qt5VirtualDevice.cxx
index f1c7d9606c8f..10b2066ccbf6 100644
--- a/vcl/qt5/Qt5VirtualDevice.cxx
+++ b/vcl/qt5/Qt5VirtualDevice.cxx
@@ -40,7 +40,9 @@ SalGraphics* Qt5VirtualDevice::AcquireGraphics()
 
 void Qt5VirtualDevice::ReleaseGraphics(SalGraphics* pGraphics)
 {
-m_aGraphics.remove(dynamic_cast(pGraphics));
+m_aGraphics.erase(
+std::remove(m_aGraphics.begin(), m_aGraphics.end(), 
dynamic_cast(pGraphics)),
+m_aGraphics.end());
 delete pGraphics;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2020-09-17 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/Qt5Graphics_Controls.hxx |6 +-
 vcl/qt5/Qt5Graphics_Controls.cxx |  100 +--
 2 files changed, 53 insertions(+), 53 deletions(-)

New commits:
commit 007e6063931bd87d6ce15deb65b9adc823f74ce0
Author: Michael Weghorn 
AuthorDate: Thu Sep 17 11:45:45 2020 +0200
Commit: Michael Weghorn 
CommitDate: Thu Sep 17 17:16:09 2020 +0200

qt5: Pass QStyleOption by reference instead of pointer

Change-Id: I12c88016740d94d4f2fcf0e1f83658dd2c3922a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102912
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/Qt5Graphics_Controls.hxx 
b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
index b9034fd8ea03..515cae7be70b 100644
--- a/vcl/inc/qt5/Qt5Graphics_Controls.hxx
+++ b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
@@ -66,13 +66,13 @@ private:
 QStyle::SubControl subControl);
 static QRect subElementRect(QStyle::SubElement element, const 
QStyleOption* option);
 
-void draw(QStyle::ControlElement element, QStyleOption* option, QImage* 
image,
+void draw(QStyle::ControlElement element, QStyleOption& rOption, QImage* 
image,
   const Color& rBackgroundColor, QStyle::State const state = 
QStyle::State_None,
   QRect rect = QRect());
-void draw(QStyle::PrimitiveElement element, QStyleOption* option, QImage* 
image,
+void draw(QStyle::PrimitiveElement element, QStyleOption& rOption, QImage* 
image,
   const Color& rBackgroundColor, QStyle::State const state = 
QStyle::State_None,
   QRect rect = QRect());
-void draw(QStyle::ComplexControl element, QStyleOptionComplex* option, 
QImage* image,
+void draw(QStyle::ComplexControl element, QStyleOptionComplex& rOption, 
QImage* image,
   const Color& rBackgroundColor, QStyle::State const state = 
QStyle::State_None);
 void drawFrame(QStyle::PrimitiveElement element, QImage* image, const 
Color& rBackGroundColor,
QStyle::State const& state, bool bClip = true,
diff --git a/vcl/qt5/Qt5Graphics_Controls.cxx b/vcl/qt5/Qt5Graphics_Controls.cxx
index 361050929d77..732c25e241cb 100644
--- a/vcl/qt5/Qt5Graphics_Controls.cxx
+++ b/vcl/qt5/Qt5Graphics_Controls.cxx
@@ -63,14 +63,14 @@ static QStyle::State vclStateValue2StateFlag(ControlState 
nControlState,
 return nState;
 }
 
-static void lcl_ApplyBackgroundColorToStyleOption(QStyleOption* pOption,
+static void lcl_ApplyBackgroundColorToStyleOption(QStyleOption& rOption,
   const Color& 
rBackgroundColor)
 {
 if (rBackgroundColor != COL_AUTO)
 {
 QColor aColor = toQColor(rBackgroundColor);
 for (QPalette::ColorRole role : { QPalette::Window, QPalette::Button, 
QPalette::Base })
-pOption->palette.setColor(role, aColor);
+rOption.palette.setColor(role, aColor);
 }
 }
 
@@ -154,49 +154,49 @@ inline QRect 
Qt5Graphics_Controls::subElementRect(QStyle::SubElement element,
 return QApplication::style()->subElementRect(element, option);
 }
 
-void Qt5Graphics_Controls::draw(QStyle::ControlElement element, QStyleOption* 
option, QImage* image,
-const Color& rBackgroundColor, QStyle::State 
const state,
-QRect rect)
+void Qt5Graphics_Controls::draw(QStyle::ControlElement element, QStyleOption& 
rOption,
+QImage* image, const Color& rBackgroundColor,
+QStyle::State const state, QRect rect)
 {
 const QRect& targetRect = !rect.isNull() ? rect : image->rect();
 
-option->state |= state;
-option->rect = downscale(targetRect);
+rOption.state |= state;
+rOption.rect = downscale(targetRect);
 
-lcl_ApplyBackgroundColorToStyleOption(option, rBackgroundColor);
+lcl_ApplyBackgroundColorToStyleOption(rOption, rBackgroundColor);
 
 QPainter painter(image);
-QApplication::style()->drawControl(element, option, );
+QApplication::style()->drawControl(element, , );
 }
 
-void Qt5Graphics_Controls::draw(QStyle::PrimitiveElement element, 
QStyleOption* option,
+void Qt5Graphics_Controls::draw(QStyle::PrimitiveElement element, 
QStyleOption& rOption,
 QImage* image, const Color& rBackgroundColor,
 QStyle::State const state, QRect rect)
 {
 const QRect& targetRect = !rect.isNull() ? rect : image->rect();
 
-option->state |= state;
-option->rect = downscale(targetRect);
+rOption.state |= state;
+rOption.rect = downscale(targetRect);
 
-lcl_ApplyBackgroundColorToStyleOption(option, rBackgroundColor);
+lcl_ApplyBackgroundColorToStyleOption(rOption, rBackgroundColor);
 
 QPainter painter(image);
-QApplication::style()->drawPrimitive(element, option, );
+QApplication::style()->drawPrimitive(element, , );
 }
 
-void 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2020-09-17 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/Qt5Graphics_Controls.hxx |   12 ++--
 vcl/qt5/Qt5Graphics_Controls.cxx |  101 +--
 2 files changed, 69 insertions(+), 44 deletions(-)

New commits:
commit 391f17a5fbcf9cd918efa10321219f87409d2412
Author: Michael Weghorn 
AuthorDate: Thu Sep 17 09:42:38 2020 +0200
Commit: Michael Weghorn 
CommitDate: Thu Sep 17 17:15:38 2020 +0200

tdf#136094 qt5: Handle bg color in drawNativeControl

This adds handling for the background color when
drawing controls in the qt5 VCL plugin, as was done
in the following commit for the gtk3 VCL plugin:

commit 2c9052802ea411dffbf5906c4914611fcbfbc6a5
Author: Michael Weghorn 
Date:   Mon Aug 24 17:18:03 2020 +0200

tdf#136094 Handle background color in drawNativeControl

For some reason, the proper background color is not passed
to 'Qt5Graphics_Controls::drawNativeControl' for the
multiline edit in the sample document ('rBackgroundColor
is 'COL_AUTO' instead), while it works as expected for the
gtk3 case. Setting a color inside
'Qt5Graphics_Controls::drawNativeControl' for testing purposes
made that one show up, so the problem is elsewhere.
I'll create a separate bug report to keep track of this and
reference it in tdf#136094.

Change-Id: I4df0d803c017422e0a2f5c05c6b4d2d8a8fa68c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102911
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/Qt5Graphics_Controls.hxx 
b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
index 325e5c351046..b9034fd8ea03 100644
--- a/vcl/inc/qt5/Qt5Graphics_Controls.hxx
+++ b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
@@ -67,13 +67,15 @@ private:
 static QRect subElementRect(QStyle::SubElement element, const 
QStyleOption* option);
 
 void draw(QStyle::ControlElement element, QStyleOption* option, QImage* 
image,
-  QStyle::State const state = QStyle::State_None, QRect rect = 
QRect());
+  const Color& rBackgroundColor, QStyle::State const state = 
QStyle::State_None,
+  QRect rect = QRect());
 void draw(QStyle::PrimitiveElement element, QStyleOption* option, QImage* 
image,
-  QStyle::State const state = QStyle::State_None, QRect rect = 
QRect());
+  const Color& rBackgroundColor, QStyle::State const state = 
QStyle::State_None,
+  QRect rect = QRect());
 void draw(QStyle::ComplexControl element, QStyleOptionComplex* option, 
QImage* image,
-  QStyle::State const state = QStyle::State_None);
-void drawFrame(QStyle::PrimitiveElement element, QImage* image, 
QStyle::State const& state,
-   bool bClip = true,
+  const Color& rBackgroundColor, QStyle::State const state = 
QStyle::State_None);
+void drawFrame(QStyle::PrimitiveElement element, QImage* image, const 
Color& rBackGroundColor,
+   QStyle::State const& state, bool bClip = true,
QStyle::PixelMetric eLineMetric = 
QStyle::PM_DefaultFrameWidth);
 
 static void fillQStyleOptionTab(const ImplControlValue& value, 
QStyleOptionTab& sot);
diff --git a/vcl/qt5/Qt5Graphics_Controls.cxx b/vcl/qt5/Qt5Graphics_Controls.cxx
index dce9c1687e42..361050929d77 100644
--- a/vcl/qt5/Qt5Graphics_Controls.cxx
+++ b/vcl/qt5/Qt5Graphics_Controls.cxx
@@ -63,6 +63,17 @@ static QStyle::State vclStateValue2StateFlag(ControlState 
nControlState,
 return nState;
 }
 
+static void lcl_ApplyBackgroundColorToStyleOption(QStyleOption* pOption,
+  const Color& 
rBackgroundColor)
+{
+if (rBackgroundColor != COL_AUTO)
+{
+QColor aColor = toQColor(rBackgroundColor);
+for (QPalette::ColorRole role : { QPalette::Window, QPalette::Button, 
QPalette::Base })
+pOption->palette.setColor(role, aColor);
+}
+}
+
 Qt5Graphics_Controls::Qt5Graphics_Controls(const Qt5GraphicsBase& rGraphics)
 : m_rGraphics(rGraphics)
 {
@@ -144,44 +155,53 @@ inline QRect 
Qt5Graphics_Controls::subElementRect(QStyle::SubElement element,
 }
 
 void Qt5Graphics_Controls::draw(QStyle::ControlElement element, QStyleOption* 
option, QImage* image,
-QStyle::State const state, QRect rect)
+const Color& rBackgroundColor, QStyle::State 
const state,
+QRect rect)
 {
 const QRect& targetRect = !rect.isNull() ? rect : image->rect();
 
 option->state |= state;
 option->rect = downscale(targetRect);
 
+lcl_ApplyBackgroundColorToStyleOption(option, rBackgroundColor);
+
 QPainter painter(image);
 QApplication::style()->drawControl(element, option, );
 }
 
 void Qt5Graphics_Controls::draw(QStyle::PrimitiveElement element, 
QStyleOption* option,
-QImage* image, QStyle::State const state, 
QRect rect)
+  

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/win

2020-09-14 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/salgdi.hxx  |   14 
 vcl/inc/sft.hxx |2 
 vcl/qt5/Qt5Graphics_Text.cxx|   63 ++--
 vcl/quartz/salgdicommon.cxx |  123 
 vcl/source/gdi/salgdilayout.cxx |  108 +++
 vcl/win/gdi/salfont.cxx |   69 ++
 6 files changed, 152 insertions(+), 227 deletions(-)

New commits:
commit bdde33ea94b77f50ca58b82bed86d6fcde77749c
Author: Jan-Marek Glogowski 
AuthorDate: Sun Sep 13 15:01:22 2020 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Tue Sep 15 06:43:42 2020 +0200

WIN OSX Qt5 unify CreateFontSubset code

This is basically just some refactoring. Most interestingly the
MacOS used to work with 257 glyphs. I couldn't find any
explaination for the 256 glyph limit. Sadly the PrintFontManager
is out of scope. That needs more inspection.

Change-Id: Ibfa0e905f5efeb7d4a609884d64b4ed2615a9d3d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102688
Reviewed-by: Jan-Marek Glogowski 
Tested-by: Jenkins

diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 9d86421e4e10..3a8fb1700862 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -57,6 +57,7 @@ namespace basegfx {
 namespace vcl
 {
 class AbstractTrueTypeFont;
+typedef struct TTGlobalFontInfo_ TTGlobalFontInfo;
 }
 
 typedef sal_Unicode sal_Ucs; // TODO: use sal_UCS4 instead of sal_Unicode
@@ -622,6 +623,19 @@ protected:
 static void GetGlyphWidths(const vcl::AbstractTrueTypeFont& rTTF,
const PhysicalFontFace& rFontFace, bool 
bVertical,
std::vector& rWidths, Ucs2UIntMap& 
rUnicodeEnc);
+
+static bool CreateTTFfontSubset(vcl::AbstractTrueTypeFont& aTTF, const 
OString& rSysPath,
+const bool bVertical, const sal_GlyphId* 
pGlyphIds,
+const sal_uInt8* pEncoding, sal_Int32* 
pGlyphWidths,
+int nGlyphCount);
+
+static bool CreateCFFfontSubset(const unsigned char* pFontBytes, int 
nByteLength,
+const OString& rSysPath, const 
sal_GlyphId* pGlyphIds,
+const sal_uInt8* pEncoding, sal_Int32* 
pGlyphWidths,
+int nGlyphCount, FontSubsetInfo& rInfo);
+
+static void FillFontSubsetInfo(const vcl::TTGlobalFontInfo& rTTInfo, const 
OUString& pPSName,
+   FontSubsetInfo& rInfo);
 };
 
 bool SalGraphics::IsNativeControlSupported(ControlType eType, ControlPart 
ePart)
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 86cb718809b3..8711364ed46f 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -144,7 +144,7 @@ namespace vcl
 
 /** Return value of GetTTGlobalFontInfo() */
 
-typedef struct {
+typedef struct TTGlobalFontInfo_ {
 char *family; /**< family name 
*/
 sal_Unicode *ufamily; /**< family name UCS2
 */
 char *subfamily;  /**< subfamily name  
*/
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 351bb3023213..de39fc7009b8 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -219,7 +219,6 @@ bool Qt5Graphics::CreateFontSubset(const OUString& rToFile, 
const PhysicalFontFa
const sal_GlyphId* pGlyphIds, const 
sal_uInt8* pEncoding,
sal_Int32* pGlyphWidths, int nGlyphCount, 
FontSubsetInfo& rInfo)
 {
-// prepare the requested file name for writing the font-subset file
 OUString aSysPath;
 if (osl_File_E_None != osl_getSystemPathFromFileURL(rToFile.pData, 
))
 return false;
@@ -228,23 +227,16 @@ bool Qt5Graphics::CreateFontSubset(const OUString& 
rToFile, const PhysicalFontFa
 const Qt5FontFace* pQt5FontFace = static_cast(pFontFace);
 const QFont aFont = pQt5FontFace->CreateFont();
 const QRawFont aRawFont(QRawFont::fromFont(aFont));
-const QFontInfo aFontInfo(aFont);
 const OString aToFile(OUStringToOString(aSysPath, 
osl_getThreadTextEncoding()));
-const int nOrigGlyphCount = nGlyphCount;
 
+// handle CFF-subsetting
 QByteArray aCFFtable = aRawFont.fontTable("CFF ");
 if (!aCFFtable.isEmpty())
-{
-FILE* pOutFile = fopen(aToFile.getStr(), "wb");
-rInfo.LoadFont(FontType::CFF_FONT, reinterpret_cast(aCFFtable.data()),
-   aCFFtable.size());
-bool bRet = rInfo.CreateFontSubset(FontType::TYPE1_PFB, pOutFile, 
nullptr, pGlyphIds,
-   pEncoding, nGlyphCount, 
pGlyphWidths);
-fclose(pOutFile);
-return bRet;
-}
+return SalGraphics::CreateCFFfontSubset(
+

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/win

2020-09-14 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/sft.hxx   |   16 ++--
 vcl/qt5/Qt5Graphics_Text.cxx  |   12 +++-
 vcl/quartz/salgdi.cxx |3 ++-
 vcl/source/fontsubset/sft.cxx |   17 ++---
 vcl/win/gdi/salfont.cxx   |   10 +-
 5 files changed, 34 insertions(+), 24 deletions(-)

New commits:
commit 2967e7a87986b59fe48119749525d4084ac6a568
Author: Jan-Marek Glogowski 
AuthorDate: Fri Sep 11 22:31:51 2020 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Tue Sep 15 06:42:56 2020 +0200

Forward existing FontCharMap from PhysicalFontFace

Since removed code in the previous commit is primary used in
CreateFontSubset and GetGlyphWidths, you have a high chance, that
the CMAP was already used for displaying a font, so it's already
decoded and can be forwarded. Also the lookup should be faster in
general this way.

Change-Id: Icf4d8a1a84ff6ccdaccb7e870abe5df3837f9541
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102686
Reviewed-by: Jan-Marek Glogowski 
Tested-by: Jenkins

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index bcbf74b07aa1..86cb718809b3 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -470,11 +470,13 @@ class TrueTypeFont;
  * @param  nLen- size of memory buffer
  * @param  facenum - logical font number within a TTC file. This value is 
ignored
  *   for TrueType fonts
- * @param  ttf - array of TrueTypeFonts
+ * @param  ttf - returns the opened TrueTypeFont
+ * @param  xCharMap  - optional parsed character map
  * @return value of SFErrCodes enum
  * @ingroup sft
  */
-SFErrCodes VCL_DLLPUBLIC OpenTTFontBuffer(const void* pBuffer, sal_uInt32 
nLen, sal_uInt32 facenum, TrueTypeFont** ttf);
+SFErrCodes VCL_DLLPUBLIC OpenTTFontBuffer(const void* pBuffer, sal_uInt32 
nLen, sal_uInt32 facenum,
+  TrueTypeFont** ttf, const 
FontCharMapRef xCharMap = nullptr);
 #if !defined(_WIN32)
 /**
  * TrueTypeFont constructor.
@@ -483,11 +485,13 @@ class TrueTypeFont;
  * @param  fname   - name of TrueType font file
  * @param  facenum - logical font number within a TTC file. This value is 
ignored
  *   for TrueType fonts
- * @param  ttf - array of TrueTypeFonts
+ * @param  ttf - returns the opened TrueTypeFont
+ * @param  xCharMap  - optional parsed character map
  * @return value of SFErrCodes enum
  * @ingroup sft
  */
-SFErrCodes VCL_DLLPUBLIC OpenTTFontFile(const char *fname, sal_uInt32 
facenum, TrueTypeFont** ttf);
+SFErrCodes VCL_DLLPUBLIC OpenTTFontFile(const char *fname, sal_uInt32 
facenum, TrueTypeFont** ttf,
+const FontCharMapRef xCharMap = 
nullptr);
 #endif
 
 bool VCL_DLLPUBLIC getTTCoverage(
@@ -728,7 +732,7 @@ protected:
 SFErrCodes indexGlyphData();
 
 public:
-AbstractTrueTypeFont(const char* fileName = nullptr);
+AbstractTrueTypeFont(const char* fileName = nullptr, const FontCharMapRef 
xCharMap = nullptr);
 virtual ~AbstractTrueTypeFont();
 
 const char* fileName() const { return m_pFileName; }
@@ -765,7 +769,7 @@ public:
 
 sal_uInt32  ntables;
 
-TrueTypeFont(const char* pFileName = nullptr);
+TrueTypeFont(const char* pFileName = nullptr, const FontCharMapRef 
xCharMap = nullptr);
 ~TrueTypeFont() override;
 
 SFErrCodes open(sal_uInt32 facenum);
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 0fe602d1ce3f..0b823858a9bb 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -137,14 +137,15 @@ class Qt5TrueTypeFont : public vcl::AbstractTrueTypeFont
 mutable QByteArray m_aFontTable[vcl::NUM_TAGS];
 
 public:
-Qt5TrueTypeFont(const QRawFont& aRawFont);
+Qt5TrueTypeFont(const Qt5FontFace& aFontFace, const QRawFont& aRawFont);
 
 bool hasTable(sal_uInt32 ord) const override;
 const sal_uInt8* table(sal_uInt32 ord, sal_uInt32& size) const override;
 };
 
-Qt5TrueTypeFont::Qt5TrueTypeFont(const QRawFont& aRawFont)
-: m_aRawFont(aRawFont)
+Qt5TrueTypeFont::Qt5TrueTypeFont(const Qt5FontFace& aFontFace, const QRawFont& 
aRawFont)
+: vcl::AbstractTrueTypeFont(nullptr, aFontFace.GetFontCharMap())
+, m_aRawFont(aRawFont)
 {
 indexGlyphData();
 }
@@ -224,7 +225,8 @@ bool Qt5Graphics::CreateFontSubset(const OUString& rToFile, 
const PhysicalFontFa
 return false;
 
 // get the raw-bytes from the font to be subset
-const QFont aFont = static_cast(pFontFace)->CreateFont();
+const Qt5FontFace* pQt5FontFace = static_cast(pFontFace);
+const QFont aFont = pQt5FontFace->CreateFont();
 const QRawFont aRawFont(QRawFont::fromFont(aFont));
 const QFontInfo aFontInfo(aFont);
 const OString aToFile(OUStringToOString(aSysPath, 
osl_getThreadTextEncoding()));
@@ -249,7 +251,7 @@ bool Qt5Graphics::CreateFontSubset(const OUString& rToFile, 
const PhysicalFontFa
 rInfo.m_nAscent = aRawFont.ascent();
 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/source vcl/unx

2020-09-14 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/PhysicalFontFace.hxx   |8 +++
 vcl/inc/qt5/Qt5FontFace.hxx|4 -
 vcl/inc/quartz/salgdi.h|4 -
 vcl/inc/unx/freetype_glyphcache.hxx|   13 -
 vcl/inc/win/salgdi.h   |4 -
 vcl/qt5/Qt5FontFace.cxx|2 
 vcl/qt5/Qt5Graphics_Text.cxx   |5 --
 vcl/source/gdi/pdfbuildin_fonts.cxx|   56 +
 vcl/source/gdi/pdfbuildin_fonts.hxx|5 +-
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |   11 +++-
 10 files changed, 79 insertions(+), 33 deletions(-)

New commits:
commit fb50c96b4207f7effb9e656ae9c8ec8d25d625ca
Author: Jan-Marek Glogowski 
AuthorDate: Mon Sep 7 23:56:20 2020 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Tue Sep 15 06:41:41 2020 +0200

VCL register common functions in PhysicalFontFace

This makes GetFontCapabilities and GetFontChatMap members of the
PhysicalFontFace. These are implemented in all the real font face
classes anyway. Also provide dummies for the PDF buildin fonts.

Change-Id: Icb8cb14480ce1e020977b8f69892095d787982ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102683
Reviewed-by: Jan-Marek Glogowski 
Tested-by: Jenkins

diff --git a/vcl/inc/PhysicalFontFace.hxx b/vcl/inc/PhysicalFontFace.hxx
index 23af5be9169e..b6c0be37d99c 100644
--- a/vcl/inc/PhysicalFontFace.hxx
+++ b/vcl/inc/PhysicalFontFace.hxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "fontattributes.hxx"
 
@@ -31,6 +32,11 @@ struct FontMatchStatus;
 class FontSelectPattern;
 class PhysicalFontFamily;
 
+namespace vcl
+{
+struct FontCapabilities;
+}
+
 struct FontMatchStatus
 {
 public:
@@ -59,6 +65,8 @@ public:
 int GetHeight() const   { return mnHeight; }
 int GetWidth() const{ return mnWidth; }
 virtual sal_IntPtr  GetFontId() const = 0;
+virtual FontCharMapRef GetFontCharMap() const = 0;
+virtual bool GetFontCapabilities(vcl::FontCapabilities&) const = 0;
 
 boolIsBetterMatch( const FontSelectPattern&, 
FontMatchStatus& ) const;
 sal_Int32   CompareWithSize( const PhysicalFontFace& ) const;
diff --git a/vcl/inc/qt5/Qt5FontFace.hxx b/vcl/inc/qt5/Qt5FontFace.hxx
index f9853af0f8c9..9c893d4f88c8 100644
--- a/vcl/inc/qt5/Qt5FontFace.hxx
+++ b/vcl/inc/qt5/Qt5FontFace.hxx
@@ -48,8 +48,8 @@ public:
 QFont CreateFont() const;
 int GetFontTable(const char pTagName[5], unsigned char*) const;
 
-const FontCharMapRef& GetFontCharMap() const;
-bool GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const;
+FontCharMapRef GetFontCharMap() const override;
+bool GetFontCapabilities(vcl::FontCapabilities&) const override;
 bool HasChar(sal_uInt32 cChar) const;
 
 rtl::Reference
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index a5c74c17705c..8058b68378b6 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -67,8 +67,8 @@ public:
 int GetFontTable( uint32_t nTagCode, unsigned 
char* ) const;
 int GetFontTable( const char pTagName[5], 
unsigned char* ) const;
 
-FontCharMapRef  GetFontCharMap() const;
-boolGetFontCapabilities(vcl::FontCapabilities 
) const;
+FontCharMapRef GetFontCharMap() const override;
+bool GetFontCapabilities(vcl::FontCapabilities&) const override;
 boolHasChar( sal_uInt32 cChar ) const;
 
 rtl::Reference CreateFontInstance(const 
FontSelectPattern&) const override;
diff --git a/vcl/inc/unx/freetype_glyphcache.hxx 
b/vcl/inc/unx/freetype_glyphcache.hxx
index c375ba2ff5d4..4586c6fd2e6d 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -72,7 +72,8 @@ public:
 
 void  AnnounceFont( PhysicalFontCollection* );
 
-const FontCharMapRef& GetFontCharMap();
+FontCharMapRef GetFontCharMap() const;
+bool GetFontCapabilities(vcl::FontCapabilities&) const;
 
 private:
 friend class FreetypeManager;
@@ -87,7 +88,7 @@ private:
 sal_IntPtr  mnFontId;
 FontAttributes  maDevFontAttributes;
 
-FontCharMapRef  mxFontCharMap;
+mutable FontCharMapRef mxFontCharMap;
 };
 
 class FreetypeFontFace : public PhysicalFontFace
@@ -100,8 +101,16 @@ public:
 
 virtual rtl::Reference CreateFontInstance( const 
FontSelectPattern& ) const override;
 virtual sal_IntPtr  GetFontId() const override { return 
mpFreetypeFontInfo->GetFontId(); }
+
+FontCharMapRef GetFontCharMap() const override { return 
mpFreetypeFontInfo->GetFontCharMap(); }
+inline bool GetFontCapabilities(vcl::FontCapabilities&) const override;
 };
 
+bool FreetypeFontFace::GetFontCapabilities(vcl::FontCapabilities& 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/source

2020-09-11 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/sft.hxx   |   16 
 vcl/qt5/Qt5Graphics_Text.cxx  |7 ++-
 vcl/source/fontsubset/sft.cxx |   26 +-
 3 files changed, 39 insertions(+), 10 deletions(-)

New commits:
commit e9b9044f7b7b44b45dd582885cad0b0a7d44f88b
Author: Jan-Marek Glogowski 
AuthorDate: Mon Sep 7 23:59:13 2020 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Fri Sep 11 19:42:09 2020 +0200

tdf#125234 Qt5 set glpyh font bounding box

Not sure if this is strictly needed, and obviously it will be
"wrong" for a sub font containing just some of the glyphs, but
since other backends also do this, follow suit.

Change-Id: Ib83542b685b38d800d09b7a19780f9ac619c7ad0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102487
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 2aef3a67d2e5..89853335db54 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -674,6 +674,22 @@ class TrueTypeFont;
  */
 VCL_DLLPUBLIC void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo 
*info);
 
+/**
+ * Returns part of the head table info, normally collected by 
GetTTGlobalFontInfo.
+ *
+ * Just implemented separate, because this info not available via Qt API.
+ *
+ * @param ttf pointer to a AbstractTrueTypeFont structure
+ * @param xMinglobal glyph bounding box min X
+ * @param yMinglobal glyph bounding box min Y
+ * @param xMaxglobal glyph bounding box max X
+ * @param yMaxglobal glyph bounding box max Y
+ * @param macStyleencoded Mac style flags of the font
+ * @returntrue, if table data could be decoded
+ * @ingroup sft
+ */
+VCL_DLLPUBLIC bool GetTTGlobalFontHeadInfo(AbstractTrueTypeFont *ttf, int& 
xMin, int& yMin, int& xMax, int& yMax, sal_uInt16& macStyle);
+
 /**
  * Returns fonts metrics.
  * @see TTGlobalFontInfo
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index a42d35ae6391..c533ad1d599a 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -238,6 +238,12 @@ bool Qt5Graphics::CreateFontSubset(const OUString& 
rToFile, const PhysicalFontFa
 rInfo.m_nAscent = aRawFont.ascent();
 rInfo.m_nDescent = aRawFont.descent();
 
+Qt5TrueTypeFont aTTF(aRawFont);
+int nXmin, nYmin, nXmax, nYmax;
+sal_uInt16 nMacStyleFlags;
+if (GetTTGlobalFontHeadInfo(, nXmin, nYmin, nXmax, nYmax, 
nMacStyleFlags))
+rInfo.m_aFontBBox = tools::Rectangle(Point(nXmin, nYmin), Point(nXmax, 
nYmax));
+
 sal_uInt16 aShortIDs[nGlyphCount + 1];
 sal_uInt8 aTempEncs[nGlyphCount + 1];
 
@@ -278,7 +284,6 @@ bool Qt5Graphics::CreateFontSubset(const OUString& rToFile, 
const PhysicalFontFa
 pGlyphWidths[i] = pGlyphMetrics[i];
 
 // write subset into destination file
-Qt5TrueTypeFont aTTF(aRawFont);
 vcl::SFErrCodes nRC
 = vcl::CreateTTFromTTGlyphs(, aToFile.getStr(), aShortIDs, 
aTempEncs, nGlyphCount);
 return (nRC == vcl::SFErrCodes::Ok);
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 30a6e37d1745..6eabe8480608 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -2364,6 +2364,22 @@ void GetTTFontMetrics(const uint8_t *pHhea, size_t nHhea,
 }
 }
 
+bool GetTTGlobalFontHeadInfo(AbstractTrueTypeFont *ttf, int& xMin, int& yMin, 
int& xMax, int& yMax, sal_uInt16& macStyle)
+{
+sal_uInt32 table_size;
+const sal_uInt8* table = ttf->table(O_head, table_size);
+if (table_size < 46)
+return false;
+
+const int UPEm = ttf->unitsPerEm();
+xMin = XUnits(UPEm, GetInt16(table, HEAD_xMin_offset));
+yMin = XUnits(UPEm, GetInt16(table, HEAD_yMin_offset));
+xMax = XUnits(UPEm, GetInt16(table, HEAD_xMax_offset));
+yMax = XUnits(UPEm, GetInt16(table, HEAD_yMax_offset));
+macStyle = GetUInt16(table, HEAD_macStyle_offset);
+return true;
+}
+
 void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info)
 {
 int UPEm = ttf->unitsPerEm();
@@ -2406,15 +2422,7 @@ void GetTTGlobalFontInfo(TrueTypeFont *ttf, 
TTGlobalFontInfo *info)
 info->italicAngle = GetInt32(table, POST_italicAngle_offset);
 }
 
-table = ttf->table(O_head, table_size);  /* 'head' tables is always 
there */
-if (table_size >= 46)
-{
-info->xMin = XUnits(UPEm, GetInt16(table, HEAD_xMin_offset));
-info->yMin = XUnits(UPEm, GetInt16(table, HEAD_yMin_offset));
-info->xMax = XUnits(UPEm, GetInt16(table, HEAD_xMax_offset));
-info->yMax = XUnits(UPEm, GetInt16(table, HEAD_yMax_offset));
-info->macStyle = GetUInt16(table, HEAD_macStyle_offset);
-}
+GetTTGlobalFontHeadInfo(ttf, info->xMin, info->yMin, info->xMax, 
info->yMax, info->macStyle);
 
 table  = ttf->table(O_hhea, table_size);
 if (table_size >= 10)
___
Libreoffice-commits mailing list

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2020-09-07 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/Qt5AccessibleWidget.hxx |4 +++-
 vcl/qt5/Qt5AccessibleWidget.cxx |9 +
 2 files changed, 8 insertions(+), 5 deletions(-)

New commits:
commit 4461d49c6cfce22c2c96185b0a1d07bfe9709268
Author: Michael Weghorn 
AuthorDate: Mon Sep 7 20:08:57 2020 +0200
Commit: Michael Weghorn 
CommitDate: Mon Sep 7 21:15:05 2020 +0200

tdf#136323 qt5: Remember accessible object

'QAccessibleCache::insert' from the Qt library has a
'Q_ASSERT' checking that the corresponding 'QObject' for
which the 'QAccessibleInterface' provides information
is actually the same as the object passed as a parameter:

QAccessible::Id QAccessibleCache::insert(QObject *object, 
QAccessibleInterface *iface) const
{
// ...
QObject *obj = iface->object();
->  Q_ASSERT(object == obj);

However, 'Qt5AccessibleWidget::object' so far was always returning
'nullptr', triggering this assert when using a Qt version
not built with 'QT_NO_DEBUG'.

To fix this, remember and return the object as needed.

Change-Id: I4015b4c37aa8a073b02465df580a7235884e6cf3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102196
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/Qt5AccessibleWidget.hxx 
b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
index 2cd4840c6dfa..aacaba9a80c8 100644
--- a/vcl/inc/qt5/Qt5AccessibleWidget.hxx
+++ b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
@@ -41,7 +41,8 @@ class Qt5AccessibleWidget final : public QObject,
 Q_OBJECT
 
 public:
-Qt5AccessibleWidget(const 
css::uno::Reference xAccessible);
+Qt5AccessibleWidget(const 
css::uno::Reference xAccessible,
+QObject* pObject);
 QWindow* window() const override;
 int childCount() const override;
 int indexOfChild(const QAccessibleInterface* child) const override;
@@ -137,6 +138,7 @@ public:
 private:
 css::uno::Reference m_xAccessible;
 css::uno::Reference 
getAccessibleContextImpl() const;
+QObject* m_pObject;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx
index ccca1cd2072f..9933444d9092 100644
--- a/vcl/qt5/Qt5AccessibleWidget.cxx
+++ b/vcl/qt5/Qt5AccessibleWidget.cxx
@@ -59,8 +59,9 @@ using namespace css::accessibility;
 using namespace css::beans;
 using namespace css::uno;
 
-Qt5AccessibleWidget::Qt5AccessibleWidget(const Reference 
xAccessible)
+Qt5AccessibleWidget::Qt5AccessibleWidget(const Reference 
xAccessible, QObject* pObject)
 : m_xAccessible(xAccessible)
+, m_pObject(pObject)
 {
 Reference xContext = 
xAccessible->getAccessibleContext();
 Reference xBroadcaster(xContext, UNO_QUERY);
@@ -699,7 +700,7 @@ bool Qt5AccessibleWidget::isValid() const
 return xAc.is();
 }
 
-QObject* Qt5AccessibleWidget::object() const { return nullptr; }
+QObject* Qt5AccessibleWidget::object() const { return m_pObject; }
 
 void Qt5AccessibleWidget::setText(QAccessible::Text /* t */, const QString& /* 
text */) {}
 
@@ -722,13 +723,13 @@ QAccessibleInterface* 
Qt5AccessibleWidget::customFactory(const QString& classnam
 vcl::Window* pWindow = pWidget->frame().GetWindow();
 
 if (pWindow)
-return new Qt5AccessibleWidget(pWindow->GetAccessible());
+return new Qt5AccessibleWidget(pWindow->GetAccessible(), object);
 }
 if (classname == QLatin1String("Qt5XAccessible") && object)
 {
 Qt5XAccessible* pXAccessible = dynamic_cast(object);
 if (pXAccessible && pXAccessible->m_xAccessible.is())
-return new Qt5AccessibleWidget(pXAccessible->m_xAccessible);
+return new Qt5AccessibleWidget(pXAccessible->m_xAccessible, 
object);
 }
 
 return nullptr;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/source

2020-08-15 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5FontFace.hxx|1 
 vcl/inc/sft.hxx|   50 +++-
 vcl/qt5/Qt5FontFace.cxx|7 +
 vcl/qt5/Qt5Graphics_Text.cxx   |  160 +++--
 vcl/source/fontsubset/sft.cxx  |   53 +++--
 vcl/source/fontsubset/ttcr.cxx |2 
 vcl/source/fontsubset/ttcr.hxx |2 
 7 files changed, 226 insertions(+), 49 deletions(-)

New commits:
commit 5a888c5fd295f9b98dee9ce930e653cb63a02857
Author: Jan-Marek Glogowski 
AuthorDate: Fri Aug 14 05:53:26 2020 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Sat Aug 15 13:18:43 2020 +0200

tdf#125234 Qt5 implement CreateFontSubset

This abstracts the just refactored vcl::TrueTypeFont class, so the
Qt5 backend can provide it's own QRawFont based font table access.

Change-Id: Ic71bc95bc8fe39bc7a32086d4adc78cfa00d15be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100718
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5FontFace.hxx b/vcl/inc/qt5/Qt5FontFace.hxx
index 585f4aaa87bf..f9853af0f8c9 100644
--- a/vcl/inc/qt5/Qt5FontFace.hxx
+++ b/vcl/inc/qt5/Qt5FontFace.hxx
@@ -45,6 +45,7 @@ public:
 
 sal_IntPtr GetFontId() const override;
 
+QFont CreateFont() const;
 int GetFontTable(const char pTagName[5], unsigned char*) const;
 
 const FontCharMapRef& GetFontCharMap() const;
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 6bcf40f03824..2aef3a67d2e5 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -447,6 +447,7 @@ constexpr sal_uInt32 T_fpgm = 0x6670676D;
 constexpr sal_uInt32 T_gsub = 0x47535542;
 constexpr sal_uInt32 T_CFF  = 0x43464620;
 
+class AbstractTrueTypeFont;
 class TrueTypeFont;
 
 /**
@@ -512,7 +513,7 @@ class TrueTypeFont;
  * @ingroup sft
  *
  */
-int GetTTGlyphPoints(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint 
**pointArray);
+int GetTTGlyphPoints(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, 
ControlPoint **pointArray);
 
 /**
  * Extracts raw glyph data from the 'glyf' table and returns it in an allocated
@@ -526,7 +527,7 @@ class TrueTypeFont;
  * @ingroup sft
  *
  */
-GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID);
+GlyphData *GetTTRawGlyphData(AbstractTrueTypeFont *ttf, sal_uInt32 
glyphID);
 
 /**
  * For a specified glyph adds all component glyphs IDs to the list and
@@ -543,7 +544,7 @@ class TrueTypeFont;
  * @ingroup sft
  *
  */
-int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, 
std::vector< sal_uInt32 >& glyphlist);
+int GetTTGlyphComponents(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, 
std::vector< sal_uInt32 >& glyphlist);
 
 /**
  * Extracts all Name Records from the font and stores them in an allocated
@@ -556,7 +557,7 @@ class TrueTypeFont;
  * @ingroup sft
  */
 
-int GetTTNameRecords(TrueTypeFont const *ttf, NameRecord **nr);
+int GetTTNameRecords(AbstractTrueTypeFont const *ttf, NameRecord **nr);
 
 /**
  * Deallocates previously allocated array of NameRecords.
@@ -604,7 +605,7 @@ class TrueTypeFont;
  * @ingroup sft
  *
  */
-VCL_DLLPUBLIC SFErrCodes CreateTTFromTTGlyphs(TrueTypeFont  *ttf,
+VCL_DLLPUBLIC SFErrCodes CreateTTFromTTGlyphs(AbstractTrueTypeFont  *ttf,
   const char*fname,
   sal_uInt16 const *glyphArray,
   sal_uInt8 const *encoding,
@@ -647,7 +648,7 @@ class TrueTypeFont;
  * @ingroup sft
  *
  */
-VCL_DLLPUBLIC std::unique_ptr 
GetTTSimpleGlyphMetrics(TrueTypeFont const *ttf, const sal_uInt16 *glyphArray, 
int nGlyphs, bool vertical);
+VCL_DLLPUBLIC std::unique_ptr 
GetTTSimpleGlyphMetrics(AbstractTrueTypeFont const *ttf, const sal_uInt16 
*glyphArray, int nGlyphs, bool vertical);
 
 #if defined(_WIN32) || defined(MACOSX) || defined(IOS)
 /**
@@ -709,7 +710,7 @@ constexpr int O_gsub = 15;   /* 'GSUB' */
 constexpr int O_CFF = 16;   /* 'CFF' */
 constexpr int NUM_TAGS = 17;
 
-class TrueTypeFont final
+class VCL_DLLPUBLIC AbstractTrueTypeFont
 {
 char* m_pFileName;
 sal_uInt32 m_nGlyphs;
@@ -718,6 +719,26 @@ class TrueTypeFont final
 sal_uInt32 m_nVertMetrics; /* if not 0 => font has vertical metrics 
information */
 sal_uInt32 m_nUnitsPerEm;
 
+protected:
+SFErrCodes indexGlyphData();
+
+public:
+AbstractTrueTypeFont(const char* fileName = nullptr);
+virtual ~AbstractTrueTypeFont();
+
+const char* fileName() const { return m_pFileName; }
+sal_uInt32 glyphCount() const { return m_nGlyphs; }
+sal_uInt32 glyphOffset(sal_uInt32 glyphID) const { return 
m_pGlyphOffsets[glyphID]; }
+sal_uInt32 horzMetricCount() const { return m_nHorzMetrics; }
+sal_uInt32 vertMetricCount() const { return m_nVertMetrics; }
+sal_uInt32 unitsPerEm() const { return m_nUnitsPerEm; }
+
+virtual bool hasTable(sal_uInt32 ord) const = 0;
+virtual const sal_uInt8* table(sal_uInt32 ord, sal_uInt32& size) const = 0;
+};
+
+class 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2020-07-03 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Instance.hxx |7 ---
 vcl/inc/qt5/Qt5Timer.hxx|2 ++
 vcl/qt5/Qt5Instance.cxx |   43 +--
 3 files changed, 31 insertions(+), 21 deletions(-)

New commits:
commit 47c098e5760537e8c43a92c9dbe16ace3902a19d
Author: Jan-Marek Glogowski 
AuthorDate: Sun Jun 2 21:08:25 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Fri Jul 3 15:58:54 2020 +0200

Qt5 better / working wakeup handling

Report some of the stuff we can in AnyInput. And instead of
posting an event, just use QAbstractEventDispatcher::wakeUp().

Change-Id: I020a71eca7208030ddbfcd2b16d9bc4ceff315e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/73676
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 361eca0fc519..232606c48062 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -35,6 +35,8 @@
 
 #include "Qt5FilePicker.hxx"
 
+class Qt5Timer;
+
 class QApplication;
 class SalYieldMutex;
 class SalFrame;
@@ -52,8 +54,9 @@ class VCLPLUG_QT5_PUBLIC Qt5Instance : public QObject,
 Q_OBJECT
 
 osl::Condition m_aWaitingYieldCond;
-int m_postUserEventId;
 const bool m_bUseCairo;
+Qt5Timer* m_pTimer;
+bool m_bSleeping;
 std::unordered_map> 
m_aClipboards;
 
 std::unique_ptr m_pQApplication;
@@ -69,12 +72,10 @@ class VCLPLUG_QT5_PUBLIC Qt5Instance : public QObject,
 
 private Q_SLOTS:
 bool ImplYield(bool bWait, bool bHandleAllCurrentEvents);
-void ImplRunInMain();
 static void deleteObjectLater(QObject* pObject);
 
 Q_SIGNALS:
 bool ImplYieldSignal(bool bWait, bool bHandleAllCurrentEvents);
-void ImplRunInMainSignal();
 void deleteObjectLaterSignal(QObject* pObject);
 
 protected:
diff --git a/vcl/inc/qt5/Qt5Timer.hxx b/vcl/inc/qt5/Qt5Timer.hxx
index 20b2a4c70cf7..99878e67ad6b 100644
--- a/vcl/inc/qt5/Qt5Timer.hxx
+++ b/vcl/inc/qt5/Qt5Timer.hxx
@@ -40,6 +40,8 @@ Q_SIGNALS:
 public:
 Qt5Timer();
 
+int remainingTime() const { return m_aTimer.remainingTime(); }
+
 virtual void Start(sal_uInt64 nMS) override;
 virtual void Stop() override;
 };
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 06b959b9163e..1868042cdb6d 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -187,10 +187,8 @@ void Qt5Instance::RunInMainThread(std::function 
func)
 pMutex->m_isWakeUpMain = true;
 pMutex->m_InMainCondition.notify_all();
 }
-// wake up main thread in case it is blocked on event queue
-// TriggerUserEventProcessing() appears to be insufficient in case the
-// main thread does QEventLoop::WaitForMoreEvents
-Q_EMIT ImplRunInMainSignal();
+
+TriggerUserEventProcessing();
 {
 std::unique_lock g(pMutex->m_RunInMainMutex);
 pMutex->m_ResultCondition.wait(g, [pMutex]() { return 
pMutex->m_isResultReady; });
@@ -198,16 +196,11 @@ void Qt5Instance::RunInMainThread(std::function 
func)
 }
 }
 
-void Qt5Instance::ImplRunInMain()
-{
-SolarMutexGuard g; // trigger the dispatch code in Qt5YieldMutex::doAcquire
-(void)this; // suppress unhelpful [loplugin:staticmethods]; can't be static
-}
-
 Qt5Instance::Qt5Instance(std::unique_ptr& pQApp, bool bUseCairo)
 : SalGenericInstance(std::make_unique())
-, m_postUserEventId(-1)
 , m_bUseCairo(bUseCairo)
+, m_pTimer(nullptr)
+, m_bSleeping(false)
 , m_pQApplication(std::move(pQApp))
 , m_aUpdateStyleTimer("vcl::qt5 m_aUpdateStyleTimer")
 , m_bUpdateFonts(false)
@@ -218,14 +211,10 @@ Qt5Instance::Qt5Instance(std::unique_ptr& 
pQApp, bool bUseCairo)
 else
 pSVData->maAppData.mxToolkitName = OUString("qt5");
 
-m_postUserEventId = QEvent::registerEventType();
-
 // this one needs to be blocking, so that the handling in main thread
 // is processed before the thread emitting the signal continues
 connect(this, SIGNAL(ImplYieldSignal(bool, bool)), this, 
SLOT(ImplYield(bool, bool)),
 Qt::BlockingQueuedConnection);
-connect(this, ::ImplRunInMainSignal, this, 
::ImplRunInMain,
-Qt::QueuedConnection); // no Blocking!
 
 // this one needs to be queued non-blocking
 // in order to have this event arriving to correct event processing loop
@@ -235,6 +224,11 @@ Qt5Instance::Qt5Instance(std::unique_ptr& 
pQApp, bool bUseCairo)
 
 m_aUpdateStyleTimer.SetTimeout(50);
 m_aUpdateStyleTimer.SetInvokeHandler(LINK(this, Qt5Instance, 
updateStyleHdl));
+
+QAbstractEventDispatcher* dispatcher = 
QAbstractEventDispatcher::instance(qApp->thread());
+connect(dispatcher, ::awake, this, [this]() { 
m_bSleeping = false; });
+connect(dispatcher, ::aboutToBlock, this,
+[this]() { m_bSleeping = true; });
 }
 
 Qt5Instance::~Qt5Instance()
@@ -333,7 +327,11 @@ std::unique_ptr 
Qt5Instance::CreateMenuItem(const SalItemParams& rI
 return 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2020-06-28 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Widget.hxx |5 +
 vcl/qt5/Qt5Widget.cxx |   46 +-
 2 files changed, 26 insertions(+), 25 deletions(-)

New commits:
commit a3634fe80fa5578774df07a2dc327de730f11348
Author: Jan-Marek Glogowski 
AuthorDate: Sun Jun 28 03:00:50 2020 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Sun Jun 28 12:52:30 2020 +0200

Qt5 refactor mouse event fill code

Adds Qt5Widget::fillSalAbstractMouseEvent to set the common
Sal*MouseEvent members. While the member functions of QMouseEvent
and QWheelEvent have the same name, they aren't shared via
QInputEvent, so this uses a small FILL_SAME macro for less code,

Change-Id: I3e5aa52b1bf2774251d97534ce0106a27ef5899b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97343
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 159794b2d2a3..7bf7ead6ae9a 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -25,8 +25,10 @@
 #include 
 #include 
 
+class QInputEvent;
 class Qt5Frame;
 class Qt5Object;
+struct SalAbstractMouseEvent;
 
 class Qt5Widget : public QWidget
 {
@@ -46,6 +48,9 @@ class Qt5Widget : public QWidget
 static void commitText(Qt5Frame&, const QString& aText);
 static bool handleKeyEvent(Qt5Frame&, const QWidget&, QKeyEvent*, const 
ButtonKeyState);
 static void handleMouseButtonEvent(const Qt5Frame&, const QMouseEvent*, 
const ButtonKeyState);
+static void fillSalAbstractMouseEvent(const Qt5Frame& rFrame, const 
QInputEvent* pQEvent,
+  const QPoint& rPos, Qt::MouseButtons 
eButtons, int nWidth,
+  SalAbstractMouseEvent& aSalEvent);
 
 virtual bool event(QEvent*) override;
 
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 0ef305f42949..2d3951ad8203 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -127,10 +127,28 @@ void Qt5Widget::resizeEvent(QResizeEvent* pEvent)
 m_rFrame.CallCallback(SalEvent::Resize, nullptr);
 }
 
+void Qt5Widget::fillSalAbstractMouseEvent(const Qt5Frame& rFrame, const 
QInputEvent* pQEvent,
+  const QPoint& rPos, Qt::MouseButtons 
eButtons, int nWidth,
+  SalAbstractMouseEvent& aSalEvent)
+{
+const qreal fRatio = rFrame.devicePixelRatioF();
+const Point aPos = toPoint(rPos * fRatio);
+
+aSalEvent.mnX = QGuiApplication::isLeftToRight() ? aPos.X() : round(nWidth 
* fRatio) - aPos.X();
+aSalEvent.mnY = aPos.Y();
+aSalEvent.mnTime = pQEvent->timestamp();
+aSalEvent.mnCode = GetKeyModCode(pQEvent->modifiers()) | 
GetMouseModCode(eButtons);
+}
+
+#define FILL_SAME(rFrame, nWidth)  
\
+fillSalAbstractMouseEvent(rFrame, pEvent, pEvent->pos(), 
pEvent->buttons(), nWidth, aEvent)
+
 void Qt5Widget::handleMouseButtonEvent(const Qt5Frame& rFrame, const 
QMouseEvent* pEvent,
const ButtonKeyState eState)
 {
 SalMouseEvent aEvent;
+FILL_SAME(rFrame, rFrame.GetQWidget()->width());
+
 switch (pEvent->button())
 {
 case Qt::LeftButton:
@@ -146,16 +164,6 @@ void Qt5Widget::handleMouseButtonEvent(const Qt5Frame& 
rFrame, const QMouseEvent
 return;
 }
 
-const qreal fRatio = rFrame.devicePixelRatioF();
-const Point aPos = toPoint(pEvent->pos() * fRatio);
-
-aEvent.mnX = QGuiApplication::isLeftToRight()
- ? aPos.X()
- : round(rFrame.GetQWidget()->width() * fRatio) - aPos.X();
-aEvent.mnY = aPos.Y();
-aEvent.mnTime = pEvent->timestamp();
-aEvent.mnCode = GetKeyModCode(pEvent->modifiers()) | 
GetMouseModCode(pEvent->buttons());
-
 SalEvent nEventType;
 if (eState == ButtonKeyState::Pressed)
 nEventType = SalEvent::MouseButtonDown;
@@ -173,14 +181,9 @@ void Qt5Widget::mouseReleaseEvent(QMouseEvent* pEvent)
 
 void Qt5Widget::mouseMoveEvent(QMouseEvent* pEvent)
 {
-const qreal fRatio = m_rFrame.devicePixelRatioF();
-const Point aPos = toPoint(pEvent->pos() * fRatio);
-
 SalMouseEvent aEvent;
-aEvent.mnX = QGuiApplication::isLeftToRight() ? aPos.X() : round(width() * 
fRatio) - aPos.X();
-aEvent.mnY = aPos.Y();
-aEvent.mnTime = pEvent->timestamp();
-aEvent.mnCode = GetKeyModCode(pEvent->modifiers()) | 
GetMouseModCode(pEvent->buttons());
+FILL_SAME(m_rFrame, width());
+
 aEvent.mnButton = 0;
 
 m_rFrame.CallCallback(SalEvent::MouseMove, );
@@ -189,15 +192,8 @@ void Qt5Widget::mouseMoveEvent(QMouseEvent* pEvent)
 
 void Qt5Widget::wheelEvent(QWheelEvent* pEvent)
 {
-const Point aPos = toPoint(pEvent->pos() * m_rFrame.devicePixelRatioF());
-
 SalWheelMouseEvent aEvent;
-aEvent.mnX = QGuiApplication::isLeftToRight()
- ? aPos.X()

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2020-03-25 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Clipboard.hxx |6 ++
 vcl/qt5/Qt5Clipboard.cxx |   23 +++
 2 files changed, 25 insertions(+), 4 deletions(-)

New commits:
commit 313081c0703c66918e95640c74cd57312a1e8bba
Author: Jan-Marek Glogowski 
AuthorDate: Wed Mar 25 18:33:29 2020 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Wed Mar 25 22:15:50 2020 +0100

tdf#131533 Qt5 defer dropping clipboard ownership

This is maybe a Qt bug. Calling QClipboard::setMimeData from
Qt5Clipboard::setContents after a previous call to
QClipboard::clear results in a clipboard ownership failure.
In a terminal you'll see: "QXcbClipboard::setMimeData: Cannot set
X11 selection owner".

Calling Application::Reschedule() after the clear() doesn't help.

The result is a de-sync between the LO's clipboard state and the
real clipboard state, which will lead to a crash on LO shutdown.

I'm not sure this fix is correct. Maybe this could also be handled
by some X11 flush operation. But it's the only working solution I
could find: don't clear, if LO re-claims the ownership later.

I tried to reproduce the ownership error by modifying the Qt
fridgemagnets example, adding some QClipboard::clear and
QClipboard::setMimeData calls to the drop handling, but couldn't
reproduce. Maybe the dynamic Qt5MimeData object is also involved.

Change-Id: I32b6575a78a4b10a2e2b7b189303ab3a40dc69ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90990
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Clipboard.hxx b/vcl/inc/qt5/Qt5Clipboard.hxx
index 122184b44942..b99534f59039 100644
--- a/vcl/inc/qt5/Qt5Clipboard.hxx
+++ b/vcl/inc/qt5/Qt5Clipboard.hxx
@@ -41,6 +41,8 @@ class Qt5Clipboard final
 // has to be set, if LO changes the QClipboard itself, so it won't 
instantly lose
 // ownership by it's self-triggered QClipboard::changed handler
 bool m_bOwnClipboardChange;
+// true, if LO really wants to give up clipboard ownership
+bool m_bDoClear;
 
 // if not empty, this holds the setContents provided XTransferable or a 
Qt5ClipboardTransferable
 css::uno::Reference m_aContents;
@@ -55,6 +57,10 @@ class Qt5Clipboard final
 
 private Q_SLOTS:
 void handleChanged(QClipboard::Mode mode);
+void handleClearClipboard();
+
+signals:
+void clearClipboard();
 
 public:
 // factory function to construct only valid Qt5Clipboard objects by name
diff --git a/vcl/qt5/Qt5Clipboard.cxx b/vcl/qt5/Qt5Clipboard.cxx
index cadedbfd327e..8720cfe44310 100644
--- a/vcl/qt5/Qt5Clipboard.cxx
+++ b/vcl/qt5/Qt5Clipboard.cxx
@@ -30,11 +30,16 @@ Qt5Clipboard::Qt5Clipboard(const OUString& aModeString, 
const QClipboard::Mode a
 , m_aClipboardName(aModeString)
 , m_aClipboardMode(aMode)
 , m_bOwnClipboardChange(false)
+, m_bDoClear(false)
 {
 assert(isSupported(m_aClipboardMode));
 // DirectConnection guarantees the changed slot runs in the same thread as 
the QClipboard
 connect(QApplication::clipboard(), ::changed, this, 
::handleChanged,
 Qt::DirectConnection);
+
+// explicitly queue an event, so we can eventually ignore it
+connect(this, ::clearClipboard, this, 
::handleClearClipboard,
+Qt::QueuedConnection);
 }
 
 css::uno::Reference Qt5Clipboard::create(const OUString& 
aModeString)
@@ -98,6 +103,13 @@ css::uno::Reference 
Qt5Clipboard::getContents(
 return m_aContents;
 }
 
+void Qt5Clipboard::handleClearClipboard()
+{
+if (!m_bDoClear)
+return;
+QApplication::clipboard()->clear(m_aClipboardMode);
+}
+
 void Qt5Clipboard::setContents(
 const css::uno::Reference& xTrans,
 const css::uno::Reference& 
xClipboardOwner)
@@ -110,15 +122,18 @@ void Qt5Clipboard::setContents(
 m_aContents = xTrans;
 m_aOwner = xClipboardOwner;
 
-m_bOwnClipboardChange = true;
-if (m_aContents.is())
+m_bDoClear = !m_aContents.is();
+if (!m_bDoClear)
+{
+m_bOwnClipboardChange = true;
 QApplication::clipboard()->setMimeData(new Qt5MimeData(m_aContents), 
m_aClipboardMode);
+m_bOwnClipboardChange = false;
+}
 else
 {
 assert(!m_aOwner.is());
-QApplication::clipboard()->clear(m_aClipboardMode);
+Q_EMIT clearClipboard();
 }
-m_bOwnClipboardChange = false;
 
 aGuard.clear();
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2020-03-09 Thread Luca Carlon (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx |1 
 vcl/inc/qt5/Qt5Graphics.hxx  |4 
 vcl/inc/qt5/Qt5GraphicsBase.hxx  |   30 
 vcl/inc/qt5/Qt5Graphics_Controls.hxx |   40 --
 vcl/inc/qt5/Qt5Painter.hxx   |   10 +
 vcl/inc/qt5/Qt5SvpGraphics.hxx   |4 
 vcl/inc/qt5/Qt5Tools.hxx |   12 +
 vcl/qt5/Qt5Frame.cxx |   60 ++---
 vcl/qt5/Qt5Graphics.cxx  |8 -
 vcl/qt5/Qt5Graphics_Controls.cxx |  220 +++
 vcl/qt5/Qt5Instance.cxx  |4 
 vcl/qt5/Qt5MainWindow.cxx|5 
 vcl/qt5/Qt5SvpGraphics.cxx   |4 
 vcl/qt5/Qt5System.cxx|2 
 vcl/qt5/Qt5Widget.cxx|   55 +---
 15 files changed, 323 insertions(+), 136 deletions(-)

New commits:
commit 358991e3b0a49bb201c2f1e4be900ee99aac9aa8
Author: Luca Carlon 
AuthorDate: Sat Feb 29 13:39:29 2020 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Mon Mar 9 14:19:49 2020 +0100

tdf#127687 Qt5 introduce basic HiDPI scaling

For tdf#124292, Qt's own HiDPI scaling was explicitly disabled,
but it turns out, you can't really scale QStyle painting then.

This patch series had a 2nd approach also used by Gtk+ currently,
which relied on the scaling of ths Cairo surface, which works
surprisingly good, but has to lie about the real DPI value, so
nothing is scaled twice. Also all icons are then scaled instead
of rendered with the proper resolution.

When HiDPI support in Qt is enabled, and the application is
started using QT_SCALE_FACTOR=1.25, Qt simply lowers the reported
resolution, keeps the logical DPI value of 96 and changes the
devicePixelRatio to the specified value. But LO still expects
the real DPI values and sizes, so we have to multiply a lot of
rectangles, sizes and positions.

The current result is far from perfect, which you can see with
the various graphics glitches, but it at least doesn't crash
anymore in the ControlType::Editbox sizing code.

The main problem is all the up and downscaling in the
getNativeControlRegion code, so LO knows the size of the widgets
for the correct layouting, since there seem to be no API to
get the scaled values from Qt / QStyle.

Change-Id: I687b1df6ef27724ce68326d256e9addccd72e759
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86239
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 5a88221565a3..0caf1bc3ef49 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -141,6 +141,7 @@ public:
 QWidget* GetQWidget() const { return m_pQWidget; }
 Qt5MainWindow* GetTopLevelWindow() const { return m_pTopLevel; }
 QWidget* asChild() const;
+qreal devicePixelRatioF() const;
 
 void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 
nExtentsWidth,
 sal_Int32 nExtentsHeight) const;
diff --git a/vcl/inc/qt5/Qt5Graphics.hxx b/vcl/inc/qt5/Qt5Graphics.hxx
index c36d22267fd2..0a66271c34e5 100644
--- a/vcl/inc/qt5/Qt5Graphics.hxx
+++ b/vcl/inc/qt5/Qt5Graphics.hxx
@@ -27,6 +27,8 @@
 #include 
 #include 
 
+#include "Qt5GraphicsBase.hxx"
+
 class PhysicalFontCollection;
 class QImage;
 class QPushButton;
@@ -35,7 +37,7 @@ class Qt5FontFace;
 class Qt5Frame;
 class Qt5Painter;
 
-class Qt5Graphics final : public SalGraphics
+class Qt5Graphics final : public SalGraphics, public Qt5GraphicsBase
 {
 friend class Qt5Bitmap;
 friend class Qt5Painter;
diff --git a/vcl/inc/qt5/Qt5GraphicsBase.hxx b/vcl/inc/qt5/Qt5GraphicsBase.hxx
new file mode 100644
index ..ef7955186a6e
--- /dev/null
+++ b/vcl/inc/qt5/Qt5GraphicsBase.hxx
@@ -0,0 +1,30 @@
+/* -*- 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 
+
+class Qt5GraphicsBase
+{
+qreal m_fDPR;
+
+protected:
+Qt5GraphicsBase()
+: m_fDPR(qApp ? qApp->devicePixelRatio() : 1.0)
+{
+}
+
+void setDevicePixelRatioF(qreal fDPR) { m_fDPR = fDPR; }
+
+public:
+qreal devicePixelRatioF() const { return m_fDPR; }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt5/Qt5Graphics_Controls.hxx 
b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
index f70804cea844..04503c7bdf17 100644
--- a/vcl/inc/qt5/Qt5Graphics_Controls.hxx
+++ b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
@@ -31,13 +31,16 @@
 #include 
 #include 
 
+class Qt5GraphicsBase;
+
 class Qt5Graphics_Controls final : public vcl::WidgetDrawInterface
 {
 std::unique_ptr m_image;
 QRect m_lastPopupRect;
+Qt5GraphicsBase const& m_rGraphics;

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/unx

2020-03-02 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5FontFace.hxx |7 ++
 vcl/qt5/Qt5Font.cxx |   69 ++---
 vcl/qt5/Qt5FontFace.cxx |  104 
 vcl/unx/kf5/KF5SalFrame.cxx |   42 +
 4 files changed, 122 insertions(+), 100 deletions(-)

New commits:
commit 63ea1e811a3b3806b6b2408d759a449f4e086eb3
Author: Jan-Marek Glogowski 
AuthorDate: Mon Mar 2 10:04:24 2020 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Mon Mar 2 13:26:44 2020 +0100

Qt5 unify font attribute conversions

Adds conversion functions for VCLs FontWeight, FontWidth and
FontItalic to Qt5FontFace and remove the partial "switch"
tables from KF5SalFrame.

And correctly handle the FontWidth in Qt5Font as the stretch
value, so the default font in qt5 gets the correct stretch and
doesn't look bold.

Change-Id: I698986416dff13e6dfaf9dfa7f95851b89e9137d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89813
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5FontFace.hxx b/vcl/inc/qt5/Qt5FontFace.hxx
index 1785e0d4dff9..585f4aaa87bf 100644
--- a/vcl/inc/qt5/Qt5FontFace.hxx
+++ b/vcl/inc/qt5/Qt5FontFace.hxx
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include 
 #include 
 
 #include 
@@ -26,10 +27,10 @@
 #include 
 
 #include 
+#include 
 
 class FontAttributes;
 class FontSelectPattern;
-class QFont;
 
 class Qt5FontFace final : public PhysicalFontFace
 {
@@ -38,6 +39,10 @@ public:
 static Qt5FontFace* fromQFontDatabase(const QString& aFamily, const 
QString& aStyle);
 static void fillAttributesFromQFont(const QFont& rFont, FontAttributes& 
rFA);
 
+VCLPLUG_QT5_PUBLIC static FontWeight toFontWeight(const int nWeight);
+VCLPLUG_QT5_PUBLIC static FontWidth toFontWidth(const int nStretch);
+VCLPLUG_QT5_PUBLIC static FontItalic toFontItalic(const QFont::Style 
eStyle);
+
 sal_IntPtr GetFontId() const override;
 
 int GetFontTable(const char pTagName[5], unsigned char*) const;
diff --git a/vcl/qt5/Qt5Font.cxx b/vcl/qt5/Qt5Font.cxx
index ee9d339266b2..832508038b4d 100644
--- a/vcl/qt5/Qt5Font.cxx
+++ b/vcl/qt5/Qt5Font.cxx
@@ -23,7 +23,7 @@
 #include 
 #include 
 
-static QFont::Weight GetQFontWeight(FontWeight eWeight)
+static QFont::Weight toWeight(FontWeight eWeight)
 {
 switch (eWeight)
 {
@@ -57,27 +57,66 @@ static QFont::Weight GetQFontWeight(FontWeight eWeight)
 return QFont::Normal;
 }
 
-Qt5Font::Qt5Font(const PhysicalFontFace& rPFF, const FontSelectPattern& rFSP)
-: LogicalFontInstance(rPFF, rFSP)
+static int toStretch(FontWidth eWidthType)
 {
-setFamily(toQString(rPFF.GetFamilyName()));
-setWeight(GetQFontWeight(rPFF.GetWeight()));
-setPixelSize(rFSP.mnHeight);
-switch (rFSP.GetItalic())
+switch (eWidthType)
+{
+case WIDTH_DONTKNOW:
+return QFont::AnyStretch;
+case WIDTH_ULTRA_CONDENSED:
+return QFont::UltraCondensed;
+case WIDTH_EXTRA_CONDENSED:
+return QFont::ExtraCondensed;
+case WIDTH_CONDENSED:
+return QFont::Condensed;
+case WIDTH_SEMI_CONDENSED:
+return QFont::SemiCondensed;
+case WIDTH_NORMAL:
+return QFont::Unstretched;
+case WIDTH_SEMI_EXPANDED:
+return QFont::SemiExpanded;
+case WIDTH_EXPANDED:
+return QFont::Expanded;
+case WIDTH_EXTRA_EXPANDED:
+return QFont::ExtraExpanded;
+case WIDTH_ULTRA_EXPANDED:
+return QFont::UltraExpanded;
+case FontWidth_FORCE_EQUAL_SIZE:
+assert(false && "FontWidth_FORCE_EQUAL_SIZE not implementable for 
QFont");
+}
+
+// so we would get enum not handled warning
+return QFont::AnyStretch;
+}
+
+static QFont::Style toStyle(FontItalic eItalic)
+{
+switch (eItalic)
 {
 case ITALIC_DONTKNOW:
-case FontItalic_FORCE_EQUAL_SIZE:
-break;
+[[fallthrough]];
 case ITALIC_NONE:
-setStyle(Style::StyleNormal);
-break;
+return QFont::Style::StyleNormal;
 case ITALIC_OBLIQUE:
-setStyle(Style::StyleOblique);
-break;
+return QFont::Style::StyleOblique;
 case ITALIC_NORMAL:
-setStyle(Style::StyleItalic);
-break;
+return QFont::Style::StyleItalic;
+case FontItalic_FORCE_EQUAL_SIZE:
+assert(false && "FontItalic_FORCE_EQUAL_SIZE not implementable for 
QFont");
 }
+
+// so we would get enum not handled warning
+return QFont::Style::StyleNormal;
+}
+
+Qt5Font::Qt5Font(const PhysicalFontFace& rPFF, const FontSelectPattern& rFSP)
+: LogicalFontInstance(rPFF, rFSP)
+{
+setFamily(toQString(rPFF.GetFamilyName()));
+setWeight(toWeight(rPFF.GetWeight()));
+setPixelSize(rFSP.mnHeight);
+setStretch(toStretch(rPFF.GetWidthType()));
+

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2020-03-02 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx |2 
 vcl/inc/qt5/Qt5Graphics.hxx  |2 
 vcl/inc/qt5/Qt5Graphics_Controls.hxx |   22 
 vcl/qt5/Qt5Frame.cxx |   19 ---
 vcl/qt5/Qt5Graphics.cxx  |1 
 vcl/qt5/Qt5Graphics_Controls.cxx |  174 ---
 6 files changed, 107 insertions(+), 113 deletions(-)

New commits:
commit 7c6c9951d3be0af11099f78462f7dfc8772df963
Author: Jan-Marek Glogowski 
AuthorDate: Sat Feb 29 12:43:32 2020 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Mon Mar 2 13:02:24 2020 +0100

Qt5 some refactoring for HiDPI merge

This is a preparatory patch for merging the initial fix for
tdf#127687, the Qt5 HiDPI scaling support, and generally to make
the style handling code a little bit more readable.

It includes:
* Moving all lcl_ Qt5Graphics_Controls functions into the class as
  private functions without lcl_ prefix.
* Add three additional helpers - pixelMetric, sizeFromContents and
  subControlRect - to cut down boilerplate QApplication::style()->
  prefixes for the style calls everywhere.
* Drop the superfluous Qt5Frame::TriggerPaintEvent functions.
* Drop the single, broken maGeometry.nTopDecoration filling.
* Split some very long lines of nested call code by using some
  intermediate variables.
* Move a Qt5Data include from hxx into cpp

Change-Id: Iae1bfafd14c4163447f3d55e2307f0f617e68a0e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89751
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index b5eea5b15b1e..5a88221565a3 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -132,8 +132,6 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public 
SalFrame
 bool isMaximized() const;
 void SetWindowStateImpl(Qt::WindowStates eState);
 
-void TriggerPaintEvent();
-void TriggerPaintEvent(QRect aRect);
 void fixICCCMwindowGroup();
 
 public:
diff --git a/vcl/inc/qt5/Qt5Graphics.hxx b/vcl/inc/qt5/Qt5Graphics.hxx
index a17421b2f65d..c36d22267fd2 100644
--- a/vcl/inc/qt5/Qt5Graphics.hxx
+++ b/vcl/inc/qt5/Qt5Graphics.hxx
@@ -27,8 +27,6 @@
 #include 
 #include 
 
-#include "Qt5Data.hxx"
-
 class PhysicalFontCollection;
 class QImage;
 class QPushButton;
diff --git a/vcl/inc/qt5/Qt5Graphics_Controls.hxx 
b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
index da1af4dc066b..f70804cea844 100644
--- a/vcl/inc/qt5/Qt5Graphics_Controls.hxx
+++ b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
@@ -28,6 +28,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 class Qt5Graphics_Controls final : public vcl::WidgetDrawInterface
 {
@@ -51,6 +53,26 @@ public:
 const ImplControlValue& aValue, const 
OUString& aCaption,
 tools::Rectangle& rNativeBoundingRegion,
 tools::Rectangle& rNativeContentRegion) 
override;
+
+private:
+static int pixelMetric(QStyle::PixelMetric metric, const QStyleOption* 
option = nullptr);
+static QSize sizeFromContents(QStyle::ContentsType type, const 
QStyleOption* option,
+  const QSize& contentsSize);
+static QRect subControlRect(QStyle::ComplexControl control, const 
QStyleOptionComplex* option,
+QStyle::SubControl subControl);
+
+static void draw(QStyle::ControlElement element, QStyleOption* option, 
QImage* image,
+ QStyle::State const state = QStyle::State_None, QRect 
rect = QRect());
+static void draw(QStyle::PrimitiveElement element, QStyleOption* option, 
QImage* image,
+ QStyle::State const state = QStyle::State_None, QRect 
rect = QRect());
+static void draw(QStyle::ComplexControl element, QStyleOptionComplex* 
option, QImage* image,
+ QStyle::State const state = QStyle::State_None);
+static void drawFrame(QStyle::PrimitiveElement element, QImage* image,
+  QStyle::State const& state, bool bClip = true,
+  QStyle::PixelMetric eLineMetric = 
QStyle::PM_DefaultFrameWidth);
+
+static void fillQStyleOptionTab(const ImplControlValue& value, 
QStyleOptionTab& sot);
+static void fullQStyleOptionTabWidgetFrame(QStyleOptionTabWidgetFrame& 
option);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 2f6738485fb0..8f1594240f46 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -287,19 +287,6 @@ void Qt5Frame::Damage(sal_Int32 nExtentsX, sal_Int32 
nExtentsY, sal_Int32 nExten
 m_pQWidget->update(nExtentsX, nExtentsY, nExtentsWidth, nExtentsHeight);
 }
 
-void Qt5Frame::TriggerPaintEvent()
-{
-QSize aSize(m_pQWidget->size());
-SalPaintEvent aPaintEvt(0, 0, aSize.width(), aSize.height(), true);
-

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2020-02-12 Thread Michael Weghorn (via logerrit)
 vcl/inc/qt5/Qt5Menu.hxx |   16 
 vcl/qt5/Qt5Menu.cxx |   34 --
 2 files changed, 48 insertions(+), 2 deletions(-)

New commits:
commit 1e0b16f8695498e4eea7c2208aabf7e7664ce749
Author: Michael Weghorn 
AuthorDate: Wed Feb 12 08:07:42 2020 +0100
Commit: Michael Weghorn 
CommitDate: Wed Feb 12 09:18:21 2020 +0100

tdf#128921 tdf#130341 tdf#122053 qt5: Native PopupMenus

This implements native PopupMenus for the qt5 VCL plugin,
which not only gives them the native look and feel, but also
makes context menus faster (tdf#128921), accessible (e.g. to the
Orca screen reader, tdf#122053), and makes them work for a case
in Base's relationship dialog where entries in the non-native context
menu were not selectable/clickable (tdf#130341).

For now, this always shows the popup menu at cursor position, which
can be changed by taking the Rectangle passed to
'Qt5Menu::ShowNativePopupMenu' into account if there should be any
need.

Change-Id: Ie52cbc682acacb92716ff51e8bf7f1ab07d34cf0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88512
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index efcfb8eeb81c..2e5434f4db74 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -24,6 +24,17 @@ class QMenuBar;
 class Qt5MenuItem;
 class Qt5Frame;
 
+/*
+ * Qt5Menu can represent
+ * (1) the top-level menu of a menubar, in which case 'mbMenuBar' is true and
+ * 'mpQMenuBar' refers to the corresponding QMenuBar
+ * (2) another kind of menu (like a PopupMenu), in which case the 
corresponding QMenu
+ * object is instantiated and owned by this Qt5Menu (held in 
'mpOwnedQMenu').
+ * (3) a "submenu" in an existing menu (like (1)), in which case the 
corresponding
+ * QMenu object is owned by the corresponding Qt5MenuItem.
+ *
+ * For (2) and (3), member 'mpQMenu' points to the corresponding QMenu object.
+ */
 class Qt5Menu : public QObject, public SalMenu
 {
 Q_OBJECT
@@ -34,6 +45,9 @@ private:
 Qt5Frame* mpFrame;
 bool mbMenuBar;
 QMenuBar* mpQMenuBar;
+// self-created QMenu that this Qt5Menu represents, if applicable (s. 
comment for class)
+std::unique_ptr mpOwnedQMenu;
+// pointer to QMenu owned by the corresponding Qt5MenuItem or self (-> 
mpOwnedQMenu)
 QMenu* mpQMenu;
 QPushButton* mpCloseButton;
 QMetaObject::Connection maCloseButtonConnection;
@@ -58,6 +72,8 @@ public:
 virtual void SetFrame(const SalFrame* pFrame) override;
 const Qt5Frame* GetFrame() const;
 virtual void ShowMenuBar(bool bVisible) override;
+virtual bool ShowNativePopupMenu(FloatingWindow* pWin, const 
tools::Rectangle& rRect,
+ FloatWinPopupFlags nFlags) override;
 Qt5Menu* GetTopLevel();
 virtual void SetItemBits(unsigned nPos, MenuItemBits nBits) override;
 virtual void CheckItem(unsigned nPos, bool bCheck) override;
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index b2e752faedaa..98615247035a 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -24,6 +24,9 @@
 #include 
 #include 
 
+#include 
+#include 
+
 Qt5Menu::Qt5Menu(bool bMenuBar)
 : mpVCLMenu(nullptr)
 , mpParentSalMenu(nullptr)
@@ -77,8 +80,15 @@ void Qt5Menu::InsertMenuItem(Qt5MenuItem* pSalMenuItem, 
unsigned nPos)
 [pSalMenuItem] { slotMenuAboutToHide(pSalMenuItem); });
 }
 }
-else if (mpQMenu)
+else
 {
+if (!mpQMenu)
+{
+// no QMenu set, instantiate own one
+mpOwnedQMenu.reset(new QMenu);
+mpQMenu = mpOwnedQMenu.get();
+}
+
 if (pSalMenuItem->mpSubMenu)
 {
 // submenu
@@ -148,7 +158,9 @@ void Qt5Menu::InsertMenuItem(Qt5MenuItem* pSalMenuItem, 
unsigned nPos)
 
 UpdateActionGroupItem(pSalMenuItem);
 
-
pAction->setShortcut(toQString(nAccelKey.GetName(GetFrame()->GetWindow(;
+const Qt5Frame* pFrame = GetFrame();
+if (pFrame)
+
pAction->setShortcut(toQString(nAccelKey.GetName(pFrame->GetWindow(;
 
 connect(pAction, ::triggered, this,
 [pSalMenuItem] { slotMenuTriggered(pSalMenuItem); });
@@ -442,6 +454,11 @@ void Qt5Menu::DoFullMenuUpdate(Menu* pMenuBar)
 Qt5MenuItem* pSalMenuItem = GetItemAtPos(nItem);
 InsertMenuItem(pSalMenuItem, nItem);
 SetItemImage(nItem, pSalMenuItem, pSalMenuItem->maImage);
+const bool bShowDisabled
+= bool(pMenuBar->GetMenuFlags() & 
MenuFlags::AlwaysShowDisabledEntries)
+  || !bool(pMenuBar->GetMenuFlags() & 
MenuFlags::HideDisabledEntries);
+const bool bVisible = bShowDisabled || 
mpVCLMenu->IsItemEnabled(pSalMenuItem->mnId);
+pSalMenuItem->getAction()->setVisible(bVisible);
 
   

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/skia vcl/source

2020-02-07 Thread Andrea Gelmini (via logerrit)
 0 files changed

New commits:
commit a092262a573d185171b00d2848cc25c14ad33b6e
Author: Andrea Gelmini 
AuthorDate: Fri Feb 7 22:06:01 2020 +0100
Commit: Julien Nabet 
CommitDate: Fri Feb 7 23:28:24 2020 +0100

Removed executable permission on files

Change-Id: I33964ea73b905e9ad4cc22f662b01be07cc96eca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88250
Reviewed-by: Julien Nabet 
Tested-by: Julien Nabet 

diff --git a/vcl/inc/qt5/Qt5Graphics.hxx b/vcl/inc/qt5/Qt5Graphics.hxx
old mode 100755
new mode 100644
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
old mode 100755
new mode 100644
diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx
old mode 100755
new mode 100644
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
old mode 100755
new mode 100644
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx 
b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
old mode 100755
new mode 100644
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-12-09 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5FilePicker.hxx |   21 ++---
 vcl/qt5/Qt5FilePicker.cxx |   89 --
 2 files changed, 82 insertions(+), 28 deletions(-)

New commits:
commit d79a41a02cd46c50cab08ba1a5d5b213b6843251
Author: Jan-Marek Glogowski 
AuthorDate: Wed Jun 5 14:04:24 2019 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Mon Dec 9 15:32:17 2019 +0100

tdf#129071 Qt5 set file picker parent widget

If the XInitialization::initialize has a parent option, use that
system window ID to find the parent Qt5Frame and set this as the
parent of the file picker. This way the file picker doesn't show
up as a separate window in the KDE task bar and get the proper
icon. Just setting it transient to the parent is not enough.

This also includes the terminate listener handling, so an open
file picker won't prevent LO to shut down gracefully (which is
handled independent from the document modified state).

Change-Id: I62aef532e739e7fea9fe8a4b4e6c0e205faae1d9
Reviewed-on: https://gerrit.libreoffice.org/74544
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5FilePicker.hxx b/vcl/inc/qt5/Qt5FilePicker.hxx
index f88395c6acce..5fef2aaeae43 100644
--- a/vcl/inc/qt5/Qt5FilePicker.hxx
+++ b/vcl/inc/qt5/Qt5FilePicker.hxx
@@ -23,8 +23,9 @@
 
 #include 
 
-#include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -33,8 +34,6 @@
 #include 
 #include 
 
-#include 
-
 #include 
 #include 
 #include 
@@ -48,9 +47,10 @@ class QGridLayout;
 class QLabel;
 class QWidget;
 
-typedef ::cppu::WeakComponentImplHelper<
-css::ui::dialogs::XFilePicker3, css::ui::dialogs::XFilePickerControlAccess,
-css::ui::dialogs::XFolderPicker2, css::lang::XInitialization, 
css::lang::XServiceInfo>
+typedef ::cppu::WeakComponentImplHelper
 Qt5FilePicker_Base;
 
 class VCLPLUG_QT5_PUBLIC Qt5FilePicker : public QObject, public 
Qt5FilePicker_Base
@@ -75,6 +75,8 @@ private:
 
 const bool m_bIsFolderPicker;
 
+QWidget* m_pParentWidget;
+
 protected:
 std::unique_ptr m_pFileDialog; ///< the file picker dialog
 QWidget* m_pExtraControls; ///< widget to contain extra custom controls
@@ -132,8 +134,7 @@ public:
 virtual void SAL_CALL initialize(const css::uno::Sequence& 
rArguments) override;
 
 // XEventListener
-/// @throws css::uno::RuntimeException
-virtual void disposing(const css::lang::EventObject& rEvent);
+void SAL_CALL disposing(const css::lang::EventObject& rEvent) override;
 using cppu::WeakComponentImplHelperBase::disposing;
 
 // XServiceInfo
@@ -145,6 +146,10 @@ public:
 virtual OUString SAL_CALL getDirectory() override;
 virtual void SAL_CALL setDescription(const OUString& rDescription) 
override;
 
+// XTerminateListener
+void SAL_CALL queryTermination(const css::lang::EventObject& aEvent) 
override;
+void SAL_CALL notifyTermination(const css::lang::EventObject& aEvent) 
override;
+
 protected:
 virtual void addCustomControl(sal_Int16 controlId);
 void setCustomControlWidgetLayout(QGridLayout* pLayout) { m_pLayout = 
pLayout; }
diff --git a/vcl/qt5/Qt5FilePicker.cxx b/vcl/qt5/Qt5FilePicker.cxx
index 10c25052fd8a..d37c28b33c11 100644
--- a/vcl/qt5/Qt5FilePicker.cxx
+++ b/vcl/qt5/Qt5FilePicker.cxx
@@ -25,8 +25,15 @@
 #include 
 #include 
 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -80,6 +88,7 @@ 
Qt5FilePicker::Qt5FilePicker(css::uno::Reference co
 : Qt5FilePicker_Base(m_aHelperMutex)
 , m_context(context)
 , m_bIsFolderPicker(eMode == QFileDialog::Directory)
+, m_pParentWidget(nullptr)
 , m_pFileDialog(new QFileDialog(nullptr, {}, QDir::homePath()))
 , m_pExtraControls(new QWidget())
 {
@@ -155,17 +164,16 @@ sal_Int16 SAL_CALL Qt5FilePicker::execute()
 return ret;
 }
 
-vcl::Window* pWindow = ::Application::GetActiveTopWindow();
-QWidget* pTransientParent = nullptr;
-QWindow* pTransientWindow = nullptr;
-if (pWindow)
+QWidget* pTransientParent = m_pParentWidget;
+if (!pTransientParent)
 {
-Qt5Frame* pFrame = dynamic_cast(pWindow->ImplGetFrame());
-assert(pFrame);
-if (pFrame)
+vcl::Window* pWindow = ::Application::GetActiveTopWindow();
+if (pWindow)
 {
-pTransientParent = pFrame->GetQWidget();
-pTransientWindow = pTransientParent->window()->windowHandle();
+Qt5Frame* pFrame = 
dynamic_cast(pWindow->ImplGetFrame());
+assert(pFrame);
+if (pFrame)
+pTransientParent = pFrame->asChild();
 }
 }
 
@@ -174,16 +182,19 @@ sal_Int16 SAL_CALL Qt5FilePicker::execute()
 if (!m_aCurrentFilter.isEmpty())
 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-12-06 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5MainWindow.hxx |3 +--
 vcl/qt5/Qt5Frame.cxx  |   10 ++
 vcl/qt5/Qt5MainWindow.cxx |4 ++--
 3 files changed, 9 insertions(+), 8 deletions(-)

New commits:
commit d8e3a08f06dcfea02c3f2f2a8578486381d77df7
Author: Jan-Marek Glogowski 
AuthorDate: Tue Dec 3 08:20:21 2019 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Fri Dec 6 12:58:13 2019 +0100

tdf#129071 Qt5 handle windows with parents as dialogs

This is the main fix for this bug. Qt Xcb is a little picky here.
It won't tell the window manager about the transient state, using
WM_TRANSIENT_FOR, for all Qt::WindowTypes. The QPA internal list
(see isTransient function) doesn't include the Qt::Window, which
is qt5 VCL's primary used window type.

This has two consequences:
1. LO dialogs show up in the plasma task manager as seperate
   windows.
2. LO has to handle the transient state itself, instead of relying
   on the window manager. This results in flickering, because LO
   can just push a transient window to the top again, after the
   parent window was activated and therefore drawn in front.

So this just declares all windows with parents to be dialogs.
Almost everything else should be a top-level window anyway. If
not, there is SalFrameStyleFlags::DIALOG to create a parent-less
dialog window.

Change-Id: I89a6d46fd09e4f1d1d2904e152a26733eb266079
Reviewed-on: https://gerrit.libreoffice.org/84298
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5MainWindow.hxx b/vcl/inc/qt5/Qt5MainWindow.hxx
index a0836170f644..f1e91b489532 100644
--- a/vcl/inc/qt5/Qt5MainWindow.hxx
+++ b/vcl/inc/qt5/Qt5MainWindow.hxx
@@ -34,8 +34,7 @@ class Qt5MainWindow : public QMainWindow
 void moveEvent(QMoveEvent*) override;
 
 public:
-Qt5MainWindow(Qt5Frame& rFrame, QWidget* parent = Q_NULLPTR,
-  Qt::WindowFlags f = Qt::WindowFlags());
+Qt5MainWindow(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 070e17a742a9..ed5f306d7ab0 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -139,18 +139,20 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 else if ((nStyle & SalFrameStyleFlags::FLOAT)
  && !(nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION))
 aWinFlags |= Qt::Popup;
-else if (nStyle & SalFrameStyleFlags::DIALOG && pParent)
-aWinFlags |= Qt::Dialog;
 else if (nStyle & SalFrameStyleFlags::TOOLWINDOW)
 aWinFlags |= Qt::Tool;
+// top level windows can't be transient in Qt, so make them dialogs, 
if they have a parent. At least
+// the plasma shell relies on this setting to skip dialogs in the 
window list. And Qt Xcb will just
+// set transient for the types Dialog, Sheet, Tool, SplashScreen, 
ToolTip, Drawer and Popup.
+else if (nStyle & SalFrameStyleFlags::DIALOG || m_pParent)
+aWinFlags |= Qt::Dialog;
 else
 aWinFlags |= Qt::Window;
 }
 
 if (aWinFlags == Qt::Window)
 {
-QWidget* pParentWidget = m_pParent ? m_pParent->asChild() : nullptr;
-m_pTopLevel = new Qt5MainWindow(*this, pParentWidget, aWinFlags);
+m_pTopLevel = new Qt5MainWindow(*this, aWinFlags);
 m_pQWidget = new Qt5Widget(*this, aWinFlags);
 m_pTopLevel->setCentralWidget(m_pQWidget);
 m_pTopLevel->setFocusProxy(m_pQWidget);
diff --git a/vcl/qt5/Qt5MainWindow.cxx b/vcl/qt5/Qt5MainWindow.cxx
index a78097fb66c3..a2a0d6cea86f 100644
--- a/vcl/qt5/Qt5MainWindow.cxx
+++ b/vcl/qt5/Qt5MainWindow.cxx
@@ -15,8 +15,8 @@
 #include 
 #include 
 
-Qt5MainWindow::Qt5MainWindow(Qt5Frame& rFrame, QWidget* parent, 
Qt::WindowFlags f)
-: QMainWindow(parent, f)
+Qt5MainWindow::Qt5MainWindow(Qt5Frame& rFrame, Qt::WindowFlags f)
+: QMainWindow(nullptr, f)
 , m_rFrame(rFrame)
 {
 QAccessible::installFactory(Qt5AccessibleWidget::customFactory);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/unx

2019-12-04 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5FilePicker.hxx |   32 
 vcl/qt5/Qt5FilePicker.cxx |   36 +---
 vcl/unx/kf5/KF5FilePicker.cxx |5 +
 vcl/unx/kf5/KF5FilePicker.hxx |6 ++
 4 files changed, 32 insertions(+), 47 deletions(-)

New commits:
commit f33b6e915fdc29cff25cc93784a04df866ad6bc3
Author: Jan-Marek Glogowski 
AuthorDate: Wed Dec 4 17:09:40 2019 +
Commit: Michael Weghorn 
CommitDate: Thu Dec 5 08:44:52 2019 +0100

Qt5 hide more Qt5FilePicker details

* Make most members private
* Drop some unused members
* Rename some single-char variables for easier reading
* Spread some constness
* Finalize the KF5FilePicker class
* Test the native picker setting of the QFilePicker, instead of an
  additional bool member

This is just some refactoring. While not strictly needed, it helps
keeping the following patches fixing tdf#129071 more compact.

Change-Id: I15ffe4de848a9498d7f61f99bcf031257da7cb08
Reviewed-on: https://gerrit.libreoffice.org/84456
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/qt5/Qt5FilePicker.hxx b/vcl/inc/qt5/Qt5FilePicker.hxx
index 35ca687f8dcb..6fb116875dd4 100644
--- a/vcl/inc/qt5/Qt5FilePicker.hxx
+++ b/vcl/inc/qt5/Qt5FilePicker.hxx
@@ -60,39 +60,31 @@ class VCLPLUG_QT5_PUBLIC Qt5FilePicker : public QObject, 
public Qt5FilePicker_Ba
 private:
 css::uno::Reference m_context;
 
-// whether to show (i.e. not remove) the file extension in the filter 
title,
-// e.g. whether to use "ODF Text Document (*.odt)" or just
-// "ODF Text Document" as filter title
-// (non-native QFileDialog e.g. adds that information by itself anyway)
-bool m_bShowFileExtensionInFilterTitle;
-
-protected:
 css::uno::Reference m_xListener;
 
-std::unique_ptr m_pFileDialog; ///< the non-native file 
picker dialog
-
 osl::Mutex m_aHelperMutex; ///< mutex used by the WeakComponentImplHelper
 
-QStringList m_aNamedFilterList; ///< to keep the original sequence
 QHash m_aTitleToFilterMap;
 // to retrieve the filename extension for a given filter
 QHash m_aNamedFilterToExtensionMap;
-QString m_aCurrentFilter;
 
-QWidget* m_pExtraControls; ///< widget to contain extra custom controls
 QGridLayout* m_pLayout; ///< layout for extra custom controls
-QLabel* m_pFilenameLabel; ///< label to display the filename
-QLabel* m_pFilterLabel; ///< label to display the filter
 QHash m_aCustomWidgetsMap; ///< map of SAL control 
ID's to widget
 
-bool m_bIsFolderPicker;
+const bool m_bIsFolderPicker;
+
+protected:
+QStringList m_aNamedFilterList; ///< to keep the original sequence
+QString m_aCurrentFilter;
+
+std::unique_ptr m_pFileDialog; ///< the file picker dialog
+QWidget* m_pExtraControls; ///< widget to contain extra custom controls
 
 public:
 // use non-native file dialog by default; there's no easy way to add 
custom widgets
 // in a generic way in the native one
 explicit Qt5FilePicker(css::uno::Reference 
const& context,
-   QFileDialog::FileMode, bool 
bShowFileExtensionInFilterTitle = false,
-   bool bUseNativeDialog = false);
+   QFileDialog::FileMode, bool bUseNative = false);
 virtual ~Qt5FilePicker() override;
 
 // XFilePickerNotifier
@@ -155,9 +147,6 @@ public:
 virtual void SAL_CALL setDescription(const OUString& rDescription) 
override;
 
 protected:
-static css::uno::Any handleGetListValue(const QComboBox* pWidget, 
sal_Int16 nControlAction);
-static void handleSetListValue(QComboBox* pQComboBox, sal_Int16 nAction,
-   const css::uno::Any& rValue);
 virtual void addCustomControl(sal_Int16 controlId);
 void setCustomControlWidgetLayout(QGridLayout* pLayout) { m_pLayout = 
pLayout; }
 
@@ -166,6 +155,9 @@ private:
 Qt5FilePicker& operator=(const Qt5FilePicker&) = delete;
 
 static QString getResString(const char* pRedId);
+static css::uno::Any handleGetListValue(const QComboBox* pWidget, 
sal_Int16 nControlAction);
+static void handleSetListValue(QComboBox* pQComboBox, sal_Int16 nAction,
+   const css::uno::Any& rValue);
 
 private Q_SLOTS:
 // emit XFilePickerListener controlStateChanged event
diff --git a/vcl/qt5/Qt5FilePicker.cxx b/vcl/qt5/Qt5FilePicker.cxx
index 730d7f142df0..10c25052fd8a 100644
--- a/vcl/qt5/Qt5FilePicker.cxx
+++ b/vcl/qt5/Qt5FilePicker.cxx
@@ -76,16 +76,14 @@ uno::Sequence 
FilePicker_getSupportedServiceNames()
 }
 
 Qt5FilePicker::Qt5FilePicker(css::uno::Reference 
const& context,
- QFileDialog::FileMode eMode, bool 
bShowFileExtensionInFilterTitle,
- bool bUseNativeDialog)
+ QFileDialog::FileMode eMode, bool bUseNative)
 : 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-10-07 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Clipboard.hxx |4 +++-
 vcl/qt5/Qt5Clipboard.cxx |   16 +---
 2 files changed, 12 insertions(+), 8 deletions(-)

New commits:
commit 29e12fe99d38ce2a35b946f6a851940e347713dd
Author: Jan-Marek Glogowski 
AuthorDate: Wed Oct 2 13:31:46 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Mon Oct 7 16:02:31 2019 +0200

tdf#112368 Qt5 don't lose ownership in flushClipboard

I didn't know that flushClipboard is called for simple text edit
fields for C'n'P operations, and not just on LO shutdown. This way
the simple text is actually secured in the clipboard instandly, as
there aren't complex mime-types to generate and secure.

As a result we also need to protect flushClipboard from loosing
ownership, which wasn't needed for the shutdown-only case, as this
would give up ownership anyway.

Change-Id: Ib3cd4979228fc645a27c658abb3df38ccf8c8956
Reviewed-on: https://gerrit.libreoffice.org/80042
Reviewed-by: Ilmari Lauhakangas 
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Clipboard.hxx b/vcl/inc/qt5/Qt5Clipboard.hxx
index 56d109b2e528..122184b44942 100644
--- a/vcl/inc/qt5/Qt5Clipboard.hxx
+++ b/vcl/inc/qt5/Qt5Clipboard.hxx
@@ -38,7 +38,9 @@ class Qt5Clipboard final
 osl::Mutex m_aMutex;
 const OUString m_aClipboardName;
 const QClipboard::Mode m_aClipboardMode;
-bool m_bInSetContents;
+// has to be set, if LO changes the QClipboard itself, so it won't 
instantly lose
+// ownership by it's self-triggered QClipboard::changed handler
+bool m_bOwnClipboardChange;
 
 // if not empty, this holds the setContents provided XTransferable or a 
Qt5ClipboardTransferable
 css::uno::Reference m_aContents;
diff --git a/vcl/qt5/Qt5Clipboard.cxx b/vcl/qt5/Qt5Clipboard.cxx
index 4b31864bf2bd..cadedbfd327e 100644
--- a/vcl/qt5/Qt5Clipboard.cxx
+++ b/vcl/qt5/Qt5Clipboard.cxx
@@ -29,7 +29,7 @@ Qt5Clipboard::Qt5Clipboard(const OUString& aModeString, const 
QClipboard::Mode a
 XServiceInfo>(m_aMutex)
 , m_aClipboardName(aModeString)
 , m_aClipboardMode(aMode)
-, m_bInSetContents(false)
+, m_bOwnClipboardChange(false)
 {
 assert(isSupported(m_aClipboardMode));
 // DirectConnection guarantees the changed slot runs in the same thread as 
the QClipboard
@@ -66,7 +66,11 @@ void Qt5Clipboard::flushClipboard()
 
 QMimeData* pMimeCopy = nullptr;
 if (pQt5MimeData && pQt5MimeData->deepCopy())
+{
+m_bOwnClipboardChange = true;
 pClipboard->setMimeData(pMimeCopy, m_aClipboardMode);
+m_bOwnClipboardChange = false;
+}
 });
 }
 
@@ -106,9 +110,7 @@ void Qt5Clipboard::setContents(
 m_aContents = xTrans;
 m_aOwner = xClipboardOwner;
 
-// these QApplication::clipboard() calls will trigger QClipboard::changed 
/ handleChanged.
-// we need to prevent freeing the contents, so tell handleChanged about us 
setting it
-m_bInSetContents = true;
+m_bOwnClipboardChange = true;
 if (m_aContents.is())
 QApplication::clipboard()->setMimeData(new Qt5MimeData(m_aContents), 
m_aClipboardMode);
 else
@@ -116,7 +118,7 @@ void Qt5Clipboard::setContents(
 assert(!m_aOwner.is());
 QApplication::clipboard()->clear(m_aClipboardMode);
 }
-m_bInSetContents = false;
+m_bOwnClipboardChange = false;
 
 aGuard.clear();
 
@@ -136,7 +138,7 @@ void Qt5Clipboard::handleChanged(QClipboard::Mode aMode)
 css::uno::Reference 
xOldOwner(m_aOwner);
 css::uno::Reference 
xOldContents(m_aContents);
 // ownership change from LO POV is handled in setContents
-if (!m_bInSetContents)
+if (!m_bOwnClipboardChange)
 {
 m_aContents.clear();
 m_aOwner.clear();
@@ -149,7 +151,7 @@ void Qt5Clipboard::handleChanged(QClipboard::Mode aMode)
 
 aGuard.clear();
 
-if (!m_bInSetContents && xOldOwner.is())
+if (!m_bOwnClipboardChange && xOldOwner.is())
 xOldOwner->lostOwnership(this, xOldContents);
 for (auto const& listener : aListeners)
 listener->changedContents(aEv);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-10-02 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Clipboard.hxx |1 +
 vcl/qt5/Qt5Clipboard.cxx |   17 +++--
 2 files changed, 12 insertions(+), 6 deletions(-)

New commits:
commit c386f07ce195c2167f1b56d23cfd95292634e2de
Author: Jan-Marek Glogowski 
AuthorDate: Tue Oct 1 20:02:25 2019 +0200
Commit: Katarina Behrens 
CommitDate: Wed Oct 2 11:10:40 2019 +0200

tdf#112368 Qt5 handle owned, non-LO clipboard content

LO can actually create clipboard content, which is not backed by
an XTransferable, for example when copying / selecting the text
of the file name in the QFileDialog. So the ownership check in
Qt5Clipboard::handleChanged is wrong and we just have to prevent
freeing the content in handleChanged while changing the handle
from Qt5Clipboard::setContents.

This patch simply sets a boolean member, while the QClipboard is
changed by LO, to handle this case.

Change-Id: Icc41c32c1f9807e7adff7a9ae16a6c6cacc83f1b
Reviewed-on: https://gerrit.libreoffice.org/79992
Reviewed-by: Michael Weghorn 
Reviewed-by: Katarina Behrens 
Tested-by: Jenkins

diff --git a/vcl/inc/qt5/Qt5Clipboard.hxx b/vcl/inc/qt5/Qt5Clipboard.hxx
index 93ad36a0e672..56d109b2e528 100644
--- a/vcl/inc/qt5/Qt5Clipboard.hxx
+++ b/vcl/inc/qt5/Qt5Clipboard.hxx
@@ -38,6 +38,7 @@ class Qt5Clipboard final
 osl::Mutex m_aMutex;
 const OUString m_aClipboardName;
 const QClipboard::Mode m_aClipboardMode;
+bool m_bInSetContents;
 
 // if not empty, this holds the setContents provided XTransferable or a 
Qt5ClipboardTransferable
 css::uno::Reference m_aContents;
diff --git a/vcl/qt5/Qt5Clipboard.cxx b/vcl/qt5/Qt5Clipboard.cxx
index db018c82150f..4b31864bf2bd 100644
--- a/vcl/qt5/Qt5Clipboard.cxx
+++ b/vcl/qt5/Qt5Clipboard.cxx
@@ -29,6 +29,7 @@ Qt5Clipboard::Qt5Clipboard(const OUString& aModeString, const 
QClipboard::Mode a
 XServiceInfo>(m_aMutex)
 , m_aClipboardName(aModeString)
 , m_aClipboardMode(aMode)
+, m_bInSetContents(false)
 {
 assert(isSupported(m_aClipboardMode));
 // DirectConnection guarantees the changed slot runs in the same thread as 
the QClipboard
@@ -73,8 +74,10 @@ css::uno::Reference 
Qt5Clipboard::getContents(
 {
 osl::MutexGuard aGuard(m_aMutex);
 
-// if we're the owner, we have the XTransferable from setContents
-if (isOwner(m_aClipboardMode))
+// if we're the owner, we might have the XTransferable from setContents. 
but
+// maybe a non-LO clipboard change from within LO, like some C'n'P in the
+// QFileDialog, might have invalidated m_aContents, so we need to check it 
too.
+if (isOwner(m_aClipboardMode) && m_aContents.is())
 return m_aContents;
 
 // check if we can still use the shared Qt5ClipboardTransferable
@@ -103,7 +106,9 @@ void Qt5Clipboard::setContents(
 m_aContents = xTrans;
 m_aOwner = xClipboardOwner;
 
-// these will trigger QClipboard::changed / handleChanged
+// these QApplication::clipboard() calls will trigger QClipboard::changed 
/ handleChanged.
+// we need to prevent freeing the contents, so tell handleChanged about us 
setting it
+m_bInSetContents = true;
 if (m_aContents.is())
 QApplication::clipboard()->setMimeData(new Qt5MimeData(m_aContents), 
m_aClipboardMode);
 else
@@ -111,6 +116,7 @@ void Qt5Clipboard::setContents(
 assert(!m_aOwner.is());
 QApplication::clipboard()->clear(m_aClipboardMode);
 }
+m_bInSetContents = false;
 
 aGuard.clear();
 
@@ -130,8 +136,7 @@ void Qt5Clipboard::handleChanged(QClipboard::Mode aMode)
 css::uno::Reference 
xOldOwner(m_aOwner);
 css::uno::Reference 
xOldContents(m_aContents);
 // ownership change from LO POV is handled in setContents
-const bool bLostOwnership = !isOwner(m_aClipboardMode);
-if (bLostOwnership)
+if (!m_bInSetContents)
 {
 m_aContents.clear();
 m_aOwner.clear();
@@ -144,7 +149,7 @@ void Qt5Clipboard::handleChanged(QClipboard::Mode aMode)
 
 aGuard.clear();
 
-if (bLostOwnership && xOldOwner.is())
+if (!m_bInSetContents && xOldOwner.is())
 xOldOwner->lostOwnership(this, xOldContents);
 for (auto const& listener : aListeners)
 listener->changedContents(aEv);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win

2019-08-27 Thread Khaled Hosny (via logerrit)
 vcl/inc/impfontmetricdata.hxx  |5 +---
 vcl/inc/sft.hxx|4 +--
 vcl/qt5/Qt5Graphics_Text.cxx   |8 --
 vcl/quartz/ctfonts.cxx |   18 ---
 vcl/source/font/fontmetric.cxx |   22 ++
 vcl/source/fontsubset/sft.cxx  |   30 -
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |   10 
 vcl/win/gdi/salfont.cxx|   10 
 8 files changed, 40 insertions(+), 67 deletions(-)

New commits:
commit 60d4be99383b6fe13ca55572c43fd022bdc73ce8
Author: Khaled Hosny 
AuthorDate: Sun Aug 25 14:12:15 2019 +0200
Commit: Khaled Hosny 
CommitDate: Tue Aug 27 20:38:19 2019 +0200

Consolidate ImplCalcLineSpacing()

Move getting UPEM and font tables to the functions and use HarfBuzz API
to get them. In the future we might stop reading the tables ourselves
and use HarfBuzz metrics API instead.

Change-Id: I3f4511628fd33200bae94cdcd96479ba3e6d2fba
Reviewed-on: https://gerrit.libreoffice.org/78081
Tested-by: Jenkins
Reviewed-by: Khaled Hosny 

diff --git a/vcl/inc/impfontmetricdata.hxx b/vcl/inc/impfontmetricdata.hxx
index 73beb59722db..6250c9155436 100644
--- a/vcl/inc/impfontmetricdata.hxx
+++ b/vcl/inc/impfontmetricdata.hxx
@@ -32,6 +32,7 @@ typedef tools::SvRef 
ImplFontMetricDataRef;
 
 class OutputDevice;
 class FontSelectPattern;
+class LogicalFontInstance;
 
 class VCL_DLLPUBLIC ImplFontMetricData : public FontAttributes, public 
SvRefBase
 {
@@ -92,9 +93,7 @@ public:
 voidImplInitTextLineSize( const OutputDevice* pDev );
 voidImplInitAboveTextLineSize();
 voidImplInitFlags( const OutputDevice* pDev );
-voidImplCalcLineSpacing(const std::vector& rHhea,
-const std::vector& rOS_2,
-int nUPEM);
+voidImplCalcLineSpacing(LogicalFontInstance *pFontInstance);
 
 private:
 boolShouldUseWinMetrics(const vcl::TTGlobalFontInfo& rInfo);
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index fbf570b27adb..aa81dcd151cb 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -419,8 +419,8 @@ namespace vcl
  * @ingroup sft
  *
  */
- void GetTTFontMetrics(const std::vector& hhea,
-   const std::vector& os2,
+ void GetTTFontMetrics(const uint8_t *pHhea, size_t nHhea,
+   const uint8_t *pOs2, size_t nOs2,
TTGlobalFontInfo *info);
 
 /**
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 38723f3dd623..85b51b82b1eb 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -59,13 +59,7 @@ void Qt5Graphics::GetFontMetric(ImplFontMetricDataRef& rFMD, 
int nFallbackLevel)
 QRawFont aRawFont(QRawFont::fromFont(*m_pTextStyle[nFallbackLevel]));
 Qt5FontFace::fillAttributesFromQFont(*m_pTextStyle[nFallbackLevel], *rFMD);
 
-QByteArray aHheaTable = aRawFont.fontTable("hhea");
-std::vector rHhea(aHheaTable.data(), aHheaTable.data() + 
aHheaTable.size());
-
-QByteArray aOs2Table = aRawFont.fontTable("OS/2");
-std::vector rOS2(aOs2Table.data(), aOs2Table.data() + 
aOs2Table.size());
-
-rFMD->ImplCalcLineSpacing(rHhea, rOS2, aRawFont.unitsPerEm());
+rFMD->ImplCalcLineSpacing(m_pTextStyle[nFallbackLevel].get());
 
 rFMD->SetSlant(0);
 rFMD->SetWidth(aRawFont.averageCharWidth());
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx
index 06a25965653f..252720a0aa4e 100644
--- a/vcl/quartz/ctfonts.cxx
+++ b/vcl/quartz/ctfonts.cxx
@@ -110,24 +110,8 @@ void CoreTextStyle::GetFontMetric( ImplFontMetricDataRef 
const & rxFontMetric )
 // get the matching CoreText font handle
 // TODO: is it worth it to cache the CTFontRef in SetFont() and reuse it 
here?
 CTFontRef aCTFontRef = static_cast(CFDictionaryGetValue( 
mpStyleDict, kCTFontAttributeName ));
-const CoreTextFontFace* mpFontData = static_cast(GetFontFace());
 
-int nBufSize = 0;
-
-nBufSize = mpFontData->GetFontTable("hhea", nullptr);
-uint8_t* pHheaBuf = new uint8_t[nBufSize];
-nBufSize = mpFontData->GetFontTable("hhea", pHheaBuf);
-std::vector rHhea(pHheaBuf, pHheaBuf + nBufSize);
-
-nBufSize = mpFontData->GetFontTable("OS/2", nullptr);
-uint8_t* pOS2Buf = new uint8_t[nBufSize];
-nBufSize = mpFontData->GetFontTable("OS/2", pOS2Buf);
-std::vector rOS2(pOS2Buf, pOS2Buf + nBufSize);
-
-rxFontMetric->ImplCalcLineSpacing(rHhea, rOS2, 
CTFontGetUnitsPerEm(aCTFontRef));
-
-delete[] pHheaBuf;
-delete[] pOS2Buf;
+rxFontMetric->ImplCalcLineSpacing(this);
 
 // since ImplFontMetricData::mnWidth is only used for stretching/squeezing 
fonts
 // setting this width to the pixel height of the fontsize is good enough
diff --git a/vcl/source/font/fontmetric.cxx 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-08-23 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Tools.hxx|3 +++
 vcl/inc/qt5/Qt5Widget.hxx   |2 +-
 vcl/qt5/Qt5AccessibleWidget.cxx |2 +-
 vcl/qt5/Qt5DragAndDrop.cxx  |   28 ++--
 vcl/qt5/Qt5Frame.cxx|   11 ---
 vcl/qt5/Qt5Tools.cxx|2 --
 vcl/qt5/Qt5Widget.cxx   |6 +++---
 7 files changed, 22 insertions(+), 32 deletions(-)

New commits:
commit 51c663b49deea46145eef185bf4e551f2c213428
Author: Jan-Marek Glogowski 
AuthorDate: Thu Aug 15 10:35:33 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Fri Aug 23 23:15:25 2019 +0200

Qt5 some minor code cleanups

Change-Id: I1ee81de7ef03447991e12dcf01aef7858408dc40
Reviewed-on: https://gerrit.libreoffice.org/77975
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Tools.hxx b/vcl/inc/qt5/Qt5Tools.hxx
index 697b703e28f4..54257de86241 100644
--- a/vcl/inc/qt5/Qt5Tools.hxx
+++ b/vcl/inc/qt5/Qt5Tools.hxx
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include 
 #include 
 #include 
 #include 
@@ -62,6 +63,8 @@ inline QSize toQSize(const Size& rSize) { return 
QSize(rSize.Width(), rSize.Heig
 
 inline Size toSize(const QSize& rSize) { return Size(rSize.width(), 
rSize.height()); }
 
+inline Point toPoint(const QPoint& rPoint) { return Point(rPoint.x(), 
rPoint.y()); }
+
 inline QColor toQColor(const Color& rColor)
 {
 return QColor(rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue(),
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index a69c86876a44..457fc8b78612 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -74,7 +74,7 @@ class Qt5Widget : public QWidget
 public:
 Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
 
-Qt5Frame& getFrame() const { return m_rFrame; }
+Qt5Frame& frame() const { return m_rFrame; }
 void endExtTextInput();
 
 static bool handleEvent(Qt5Frame&, const QWidget&, QEvent*);
diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx
index 6ee5eedb6414..6a828865036e 100644
--- a/vcl/qt5/Qt5AccessibleWidget.cxx
+++ b/vcl/qt5/Qt5AccessibleWidget.cxx
@@ -718,7 +718,7 @@ QAccessibleInterface* 
Qt5AccessibleWidget::customFactory(const QString& classnam
 if (classname == QLatin1String("Qt5Widget") && object && 
object->isWidgetType())
 {
 Qt5Widget* pWidget = static_cast(object);
-vcl::Window* pWindow = pWidget->getFrame().GetWindow();
+vcl::Window* pWindow = pWidget->frame().GetWindow();
 
 if (pWindow)
 return new Qt5AccessibleWidget(pWindow->GetAccessible());
diff --git a/vcl/qt5/Qt5DragAndDrop.cxx b/vcl/qt5/Qt5DragAndDrop.cxx
index 3f57f3bc303e..615b5d1f7e2a 100644
--- a/vcl/qt5/Qt5DragAndDrop.cxx
+++ b/vcl/qt5/Qt5DragAndDrop.cxx
@@ -78,16 +78,16 @@ void Qt5DragSource::startDrag(
 
 void Qt5DragSource::fire_dragEnd(sal_Int8 nAction, bool bDropSuccessful)
 {
-if (m_xListener.is())
-{
-datatransfer::dnd::DragSourceDropEvent aEv;
-aEv.DropAction = nAction;
-aEv.DropSuccess = bDropSuccessful;
+if (!m_xListener.is())
+return;
 
-auto xListener = m_xListener;
-m_xListener.clear();
-xListener->dragDropEnd(aEv);
-}
+datatransfer::dnd::DragSourceDropEvent aEv;
+aEv.DropAction = nAction;
+aEv.DropSuccess = bDropSuccessful;
+
+auto xListener = m_xListener;
+m_xListener.clear();
+xListener->dragDropEnd(aEv);
 }
 
 OUString SAL_CALL Qt5DragSource::getImplementationName()
@@ -128,11 +128,7 @@ css::uno::Sequence SAL_CALL 
Qt5DropTarget::getSupportedServiceNames()
 return { "com.sun.star.datatransfer.dnd.Qt5DropTarget" };
 }
 
-Qt5DropTarget::~Qt5DropTarget()
-{
-//if (m_pFrame)
-//m_pFrame->deregisterDropTarget(this);
-}
+Qt5DropTarget::~Qt5DropTarget() {}
 
 void Qt5DropTarget::deinitialize()
 {
@@ -213,9 +209,7 @@ void Qt5DropTarget::fire_dragOver(const 
css::datatransfer::dnd::DropTargetDragEn
 aGuard.clear();
 
 for (auto const& listener : aListeners)
-{
 listener->dragOver(dtde);
-}
 }
 
 void Qt5DropTarget::fire_drop(const 
css::datatransfer::dnd::DropTargetDropEvent& dtde)
@@ -228,9 +222,7 @@ void Qt5DropTarget::fire_drop(const 
css::datatransfer::dnd::DropTargetDropEvent&
 aGuard.clear();
 
 for (auto const& listener : aListeners)
-{
 listener->drop(dtde);
-}
 }
 
 void Qt5DropTarget::fire_dragExit(const 
css::datatransfer::dnd::DropTargetEvent& dte)
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index cd850e6c3c0f..a18af04b5cbd 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -1053,8 +1053,7 @@ void Qt5Frame::Beep() { QApplication::beep(); }
 SalFrame::SalPointerState Qt5Frame::GetPointerState()
 {
 SalPointerState aState;
-QPoint pos = QCursor::pos();
-aState.maPos = Point(pos.x(), pos.y());
+aState.maPos = toPoint(QCursor::pos());
 aState.mnState = 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/unx

2019-08-22 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5DragAndDrop.hxx  |   21 +
 vcl/inc/qt5/Qt5Frame.hxx|   10 +-
 vcl/inc/qt5/Qt5Tools.hxx|3 
 vcl/inc/qt5/Qt5Transferable.hxx |2 
 vcl/inc/qt5/Qt5Widget.hxx   |2 
 vcl/qt5/Qt5DragAndDrop.cxx  |   93 
 vcl/qt5/Qt5Frame.cxx|  153 
 vcl/qt5/Qt5Tools.cxx|   12 +++
 vcl/qt5/Qt5Widget.cxx   |   32 +---
 vcl/unx/kf5/KF5SalFrame.hxx |4 -
 10 files changed, 174 insertions(+), 158 deletions(-)

New commits:
commit 3355be0616c24c5e44b71e7623c4191ed9c69074
Author: Jan-Marek Glogowski 
AuthorDate: Thu Aug 8 17:59:20 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Thu Aug 22 14:29:03 2019 +0200

tdf#126560 Qt5 fix D'n'D key-modifier handling

The patch has still one problem: the key-modifier state isn't
reflected by the cursor, unless the user moves the mouse. There is
an upstream Qt bug, reported in 2016-09 against Qt 5.6.1! It is
supposed to be fixed in Qt 5.12, according to the bug report at
https://bugreports.qt.io/browse/QTBUG-56218, which is still open.

I thought about adding a configure test, but I couldn't imagine
any realistic way to write it. And after Michael Weghorn found the
bug is actually not fixed, as claimed in one of the comments, I
decided to drop the warning.

Change-Id: Ice8ebc4ea149282b4c1551e755efe3d4856cf782
Reviewed-on: https://gerrit.libreoffice.org/77174
Reviewed-by: Michael Weghorn 
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5DragAndDrop.hxx b/vcl/inc/qt5/Qt5DragAndDrop.hxx
index dcd6cb5e4048..0ec9ce5bbcb2 100644
--- a/vcl/inc/qt5/Qt5DragAndDrop.hxx
+++ b/vcl/inc/qt5/Qt5DragAndDrop.hxx
@@ -25,7 +25,6 @@ class Qt5DragSource
 osl::Mutex m_aMutex;
 Qt5Frame* m_pFrame;
 css::uno::Reference 
m_xListener;
-css::uno::Reference m_xTrans;
 
 public:
 Qt5DragSource()
@@ -55,17 +54,7 @@ public:
 
 css::uno::Sequence SAL_CALL getSupportedServiceNames() override;
 
-void dragFailed();
-void fire_dragEnd(sal_Int8 nAction);
-
-static Qt5DragSource* m_ActiveDragSource;
-static bool m_bDropSuccessSet;
-static bool m_bDropSuccess;
-
-css::uno::Reference const& 
GetTransferable() const
-{
-return m_xTrans;
-}
+void fire_dragEnd(sal_Int8 nAction, bool bSuccessful);
 };
 
 class Qt5DropTarget
@@ -76,11 +65,11 @@ class Qt5DropTarget
 {
 osl::Mutex m_aMutex;
 Qt5Frame* m_pFrame;
-sal_Int8 mnDragAction;
-sal_Int8 mnDropAction;
+sal_Int8 m_nDropAction;
 bool m_bActive;
 sal_Int8 m_nDefaultActions;
 
std::vector> 
m_aListeners;
+bool m_bDropSuccessful;
 
 public:
 Qt5DropTarget();
@@ -115,10 +104,12 @@ public:
 css::uno::Sequence SAL_CALL getSupportedServiceNames() override;
 
 void fire_dragEnter(const 
css::datatransfer::dnd::DropTargetDragEnterEvent& dtde);
+void fire_dragExit(const css::datatransfer::dnd::DropTargetEvent& dte);
 void fire_dragOver(const css::datatransfer::dnd::DropTargetDragEnterEvent& 
dtde);
 void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde);
 
-sal_Int8 proposedDragAction() const { return mnDragAction; }
+sal_Int8 proposedDropAction() const { return m_nDropAction; }
+bool dropSuccessful() const { return m_bDropSuccessful; }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 4c94b846bc93..e296ce92db29 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -56,6 +56,8 @@ class Qt5MainWindow;
 class Qt5Menu;
 class Qt5SvpGraphics;
 
+class QDragMoveEvent;
+class QDropEvent;
 class QImage;
 class QMimeData;
 class QPaintDevice;
@@ -159,10 +161,10 @@ public:
 virtual void deregisterDragSource(Qt5DragSource const* pDragSource);
 virtual void registerDropTarget(Qt5DropTarget* pDropTarget);
 virtual void deregisterDropTarget(Qt5DropTarget const* pDropTarget);
-void draggingStarted(const int x, const int y, Qt::DropActions eActions,
- Qt::KeyboardModifiers eKeyMod, const QMimeData* 
pQMimeData);
-void dropping(const int x, const int y, Qt::KeyboardModifiers eKeyMod,
-  const QMimeData* pQMimeData);
+
+void handleDragLeave();
+void handleDragMove(QDragMoveEvent* pEvent);
+void handleDrop(QDropEvent* pEvent);
 
 virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle) override;
 virtual void Show(bool bVisible, bool bNoActivate = false) override;
diff --git a/vcl/inc/qt5/Qt5Tools.hxx b/vcl/inc/qt5/Qt5Tools.hxx
index 6b1fb1adcc7e..697b703e28f4 100644
--- a/vcl/inc/qt5/Qt5Tools.hxx
+++ b/vcl/inc/qt5/Qt5Tools.hxx
@@ -70,6 +70,7 @@ inline QColor toQColor(const Color& rColor)
 
 Qt::DropActions toQtDropActions(sal_Int8 dragOperation);
 sal_Int8 toVclDropActions(Qt::DropActions dragOperation);

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-07-12 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Graphics_Controls.hxx |3 --
 vcl/qt5/Qt5Graphics_Controls.cxx |   36 ++-
 2 files changed, 7 insertions(+), 32 deletions(-)

New commits:
commit 77eb3a7ff88c30d6145a3aa6d454d08ed93206df
Author: Jan-Marek Glogowski 
AuthorDate: Thu Jul 11 02:22:16 2019 +
Commit: Katarina Behrens 
CommitDate: Fri Jul 12 12:09:10 2019 +0200

Qt5 drop special QPushButton handling

Basically reverts commit 3f0dbdd61df ("Draw button focus so that
it doesn't obscure the actual button") and declares qt5 doesn't
support an extra native focus for a button.

LO's own "ant" focus is prevented by Qt5Data::Qt5Data():

pSVData->maNWFData.mbNoFocusRects = true;
pSVData->maNWFData.mbNoFocusRectsForFlatButtons = true;

Change-Id: Ifdce615cac92f69b008780cf986cdfd0915ccd14
Reviewed-on: https://gerrit.libreoffice.org/75415
Tested-by: Jenkins
Reviewed-by: Katarina Behrens 

diff --git a/vcl/inc/qt5/Qt5Graphics_Controls.hxx 
b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
index 50d1de3b1cec..2676fa6413a4 100644
--- a/vcl/inc/qt5/Qt5Graphics_Controls.hxx
+++ b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
@@ -31,12 +31,9 @@
 
 class VCLPLUG_QT5_PUBLIC Qt5Graphics_Controls final : public 
vcl::WidgetDrawInterface
 {
-std::unique_ptr m_focusedButton;
 std::unique_ptr m_image;
 QRect m_lastPopupRect;
 
-void initStyles();
-
 public:
 Qt5Graphics_Controls();
 
diff --git a/vcl/qt5/Qt5Graphics_Controls.cxx b/vcl/qt5/Qt5Graphics_Controls.cxx
index 491c12e657ba..bee5c33dc0e2 100644
--- a/vcl/qt5/Qt5Graphics_Controls.cxx
+++ b/vcl/qt5/Qt5Graphics_Controls.cxx
@@ -21,7 +21,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -65,7 +64,7 @@ static QStyle::State vclStateValue2StateFlag(ControlState 
nControlState,
 return nState;
 }
 
-Qt5Graphics_Controls::Qt5Graphics_Controls() { initStyles(); }
+Qt5Graphics_Controls::Qt5Graphics_Controls() {}
 
 bool Qt5Graphics_Controls::isNativeControlSupported(ControlType type, 
ControlPart part)
 {
@@ -78,8 +77,9 @@ bool 
Qt5Graphics_Controls::isNativeControlSupported(ControlType type, ControlPar
 
 case ControlType::Radiobutton:
 case ControlType::Checkbox:
-case ControlType::Pushbutton:
 return (part == ControlPart::Entire) || (part == 
ControlPart::Focus);
+case ControlType::Pushbutton:
+return (part == ControlPart::Entire);
 
 case ControlType::ListHeader:
 return (part == ControlPart::Button);
@@ -250,21 +250,10 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType 
type, ControlPart part,
 
 if (type == ControlType::Pushbutton)
 {
-if (part == ControlPart::Entire)
-{
-QStyleOptionButton option;
-draw(QStyle::CE_PushButton, , m_image.get(),
- vclStateValue2StateFlag(nControlState, value));
-}
-else if (part == ControlPart::Focus)
-{
-QStyleOptionButton option;
-option.state = QStyle::State_HasFocus;
-option.rect = m_image->rect();
-QPainter painter(m_image.get());
-m_focusedButton->style()->drawControl(QStyle::CE_PushButton, 
, ,
-  m_focusedButton.get());
-}
+assert(part == ControlPart::Entire);
+QStyleOptionButton option;
+draw(QStyle::CE_PushButton, , m_image.get(),
+ vclStateValue2StateFlag(nControlState, value));
 }
 else if (type == ControlType::Menubar)
 {
@@ -1038,15 +1027,4 @@ bool 
Qt5Graphics_Controls::hitTestNativeControl(ControlType nType, ControlPart n
 return false;
 }
 
-void Qt5Graphics_Controls::initStyles()
-{
-// button focus
-m_focusedButton.reset(new QPushButton());
-QString aHighlightColor = 
QApplication::palette().color(QPalette::Highlight).name();
-QString focusStyleSheet("background-color: rgb(0,0,0,0%); border: 1px; 
border-radius: 2px; "
-"border-color: %1; border-style:solid;");
-focusStyleSheet.replace("%1", aHighlightColor);
-m_focusedButton->setStyleSheet(focusStyleSheet);
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-06-24 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx |2 -
 vcl/qt5/Qt5Frame.cxx |   48 +--
 2 files changed, 19 insertions(+), 31 deletions(-)

New commits:
commit bbbc820d7920a31669cb7e9aaeb5beb072eae175
Author: Jan-Marek Glogowski 
AuthorDate: Mon Jun 24 06:37:45 2019 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Mon Jun 24 08:15:46 2019 +0200

Qt5 don't assert broken height or width

At least maths element docking window has a floating height of zero.
So the original gtk comment about broken values is still true.

And the initial SalFrameGeometry is ok, so no need to initialize it.
And set default size and position on show, if not explicitly set.

Change-Id: Ibe4969a164b50b666745ce010f5100af4b3ff2f6
Reviewed-on: https://gerrit.libreoffice.org/74614
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 5b1bc1025445..4c94b846bc93 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -109,7 +109,7 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public 
SalFrame
 ScreenSaverInhibitor m_ScreenSaverInhibitor;
 #endif
 
-void Center();
+void SetDefaultPos();
 Size CalcDefaultSize();
 void SetDefaultSize();
 
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 7559b42d0f86..0bfd51c515da 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -163,21 +163,6 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 pChildWindow->setTransientParent(pParentWindow);
 }
 
-// fake an initial geometry, gets updated via configure event or SetPosSize
-if (m_bDefaultPos || m_bDefaultSize)
-{
-maGeometry.nDisplayScreenNumber = 0;
-Size aDefSize = CalcDefaultSize();
-maGeometry.nX = 0;
-maGeometry.nY = 0;
-maGeometry.nWidth = aDefSize.Width();
-maGeometry.nHeight = aDefSize.Height();
-maGeometry.nTopDecoration = 0;
-maGeometry.nBottomDecoration = 0;
-maGeometry.nLeftDecoration = 0;
-maGeometry.nRightDecoration = 0;
-}
-
 m_aSystemData.nSize = sizeof(SystemEnvData);
 
 // Calling 'QWidget::winId()' implicitly enables native windows to be used
@@ -370,6 +355,7 @@ void Qt5Frame::Show(bool bVisible, bool /*bNoActivate*/)
 assert(m_pQWidget);
 
 SetDefaultSize();
+SetDefaultPos();
 
 auto* pSalInst(static_cast(GetSalData()->m_pInstance));
 assert(pSalInst);
@@ -388,15 +374,22 @@ void Qt5Frame::SetMaxClientSize(long nWidth, long nHeight)
 asChild()->setMaximumSize(nWidth, nHeight);
 }
 
-void Qt5Frame::Center()
+void Qt5Frame::SetDefaultPos()
 {
+if (!m_bDefaultPos)
+return;
+
+// center on parent
 if (m_pParent)
 {
-QWidget* pWindow = m_pParent->GetQWidget()->window();
+QWidget* const pWindow = m_pParent->GetQWidget()->window();
 QWidget* const pWidget = asChild();
-pWidget->move(pWindow->frameGeometry().topLeft() + 
pWindow->rect().center()
-  - pWidget->rect().center());
+QPoint aPos = pWindow->rect().center() - pWidget->rect().center();
+SetPosSize(aPos.x(), aPos.y(), 0, 0, SAL_FRAME_POSSIZE_X | 
SAL_FRAME_POSSIZE_Y);
+assert(!m_bDefaultPos);
 }
+else
+m_bDefaultPos = false;
 }
 
 Size Qt5Frame::CalcDefaultSize()
@@ -443,31 +436,30 @@ void Qt5Frame::SetPosSize(long nX, long nY, long nWidth, 
long nHeight, sal_uInt1
 
 if (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT))
 {
-m_bDefaultSize = false;
 if (isChild(false) || !m_pQWidget->isMaximized())
 {
 if (!(nFlags & SAL_FRAME_POSSIZE_WIDTH))
 nWidth = maGeometry.nWidth;
 else if (!(nFlags & SAL_FRAME_POSSIZE_HEIGHT))
 nHeight = maGeometry.nHeight;
-assert(nWidth > 0 && nHeight > 0);
 
 if (nWidth > 0 && nHeight > 0)
 {
+m_bDefaultSize = false;
 if (m_nStyle & SalFrameStyleFlags::SIZEABLE)
 asChild()->resize(nWidth, nHeight);
 else
 asChild()->setFixedSize(nWidth, nHeight);
+}
 
-// assume the resize happened
-// needed for calculations and will eventually be corrected by 
events
+// assume the resize happened
+// needed for calculations and will eventually be corrected by 
events
+if (nWidth > 0)
 maGeometry.nWidth = nWidth;
+if (nHeight > 0)
 maGeometry.nHeight = nHeight;
-}
 }
 }
-else
-SetDefaultSize();
 
 if (nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y))
 {
@@ -498,10 +490,6 @@ void Qt5Frame::SetPosSize(long nX, long nY, long nWidth, 
long nHeight, sal_uInt1
 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-06-22 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5MainWindow.hxx |3 +
 vcl/inc/salframe.hxx  |3 +
 vcl/qt5/Qt5Frame.cxx  |   83 +-
 vcl/qt5/Qt5MainWindow.cxx |   11 -
 vcl/qt5/Qt5Widget.cxx |   35 ++---
 5 files changed, 84 insertions(+), 51 deletions(-)

New commits:
commit 337b592a721bef2c54cbe8c4927e5cc5a68c2138
Author: Jan-Marek Glogowski 
AuthorDate: Fri Jun 21 04:09:02 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Sat Jun 22 16:22:37 2019 +0200

tdf#123779 Qt5 correctly fill Qt5Frame::maGeometry

The tooltip in the bug is actually not one, but the VCL implementation
of Gtk's popover widget triggered by SalFrame::ShowPopover. This has
no Qt equivalent, so we currently rely on the crude VCL version.

But for this maGeometry must contain the correct information, AKA the
absolute, unmirrored, paintable system geometry of the frame. Then the
window can be positioned correctly.

The patch gets rid of most of the code initially copied from gtk, when
this VCL backend was in a very early state.

Change-Id: Id44e4dc2aac41f1f01d51c4d8107892e644ef243
Reviewed-on: https://gerrit.libreoffice.org/74546
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5MainWindow.hxx b/vcl/inc/qt5/Qt5MainWindow.hxx
index a2a7e184c291..a0836170f644 100644
--- a/vcl/inc/qt5/Qt5MainWindow.hxx
+++ b/vcl/inc/qt5/Qt5MainWindow.hxx
@@ -28,9 +28,10 @@ class Qt5MainWindow : public QMainWindow
 {
 Q_OBJECT
 
-Qt5Frame* m_pFrame;
+Qt5Frame& m_rFrame;
 
 virtual void closeEvent(QCloseEvent* pEvent) override;
+void moveEvent(QMoveEvent*) override;
 
 public:
 Qt5MainWindow(Qt5Frame& rFrame, QWidget* parent = Q_NULLPTR,
diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx
index 86ad6da98b6e..19293b913621 100644
--- a/vcl/inc/salframe.hxx
+++ b/vcl/inc/salframe.hxx
@@ -124,7 +124,7 @@ public:
 SalFrame();
 virtual ~SalFrame() override;
 
-SalFrameGeometrymaGeometry;
+SalFrameGeometrymaGeometry; ///< absolute, unmirrored values
 
 // SalGeometryProvider
 virtual long GetWidth() const override { return maGeometry.nWidth; }
@@ -165,6 +165,7 @@ public:
 const SalFrameGeometry& GetUnmirroredGeometry() const { return maGeometry; 
}
 
 virtual voidSetWindowState( const SalFrameState* pState ) = 0;
+// return the absolute, unmirrored system frame state
 // if this returns false the structure is uninitialised
 [[nodiscard]]
 virtual boolGetWindowState( SalFrameState* pState ) = 0;
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 0e0b9efae5b1..dbdc51ea9465 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -171,8 +171,8 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 {
 maGeometry.nDisplayScreenNumber = 0;
 Size aDefSize = CalcDefaultSize();
-maGeometry.nX = -1;
-maGeometry.nY = -1;
+maGeometry.nX = 0;
+maGeometry.nY = 0;
 maGeometry.nWidth = aDefSize.Width();
 maGeometry.nHeight = aDefSize.Height();
 maGeometry.nTopDecoration = 0;
@@ -372,8 +372,7 @@ void Qt5Frame::Show(bool bVisible, bool /*bNoActivate*/)
 {
 assert(m_pQWidget);
 
-if (m_bDefaultSize)
-SetDefaultSize();
+SetDefaultSize();
 
 auto* pSalInst(static_cast(GetSalData()->m_pInstance));
 assert(pSalInst);
@@ -431,9 +430,13 @@ Size Qt5Frame::CalcDefaultSize()
 
 void Qt5Frame::SetDefaultSize()
 {
+if (!m_bDefaultSize)
+return;
+
 Size aDefSize = CalcDefaultSize();
 SetPosSize(0, 0, aDefSize.Width(), aDefSize.Height(),
SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT);
+assert(!m_bDefaultSize);
 }
 
 void Qt5Frame::SetPosSize(long nX, long nY, long nWidth, long nHeight, 
sal_uInt16 nFlags)
@@ -441,38 +444,57 @@ void Qt5Frame::SetPosSize(long nX, long nY, long nWidth, 
long nHeight, sal_uInt1
 if (!isWindow() || isChild(true, false))
 return;
 
-if ((nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT))
-&& (nWidth > 0 && nHeight > 0) // sometimes stupid things happen
-)
+if (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT))
 {
 m_bDefaultSize = false;
 if (isChild(false) || !m_pQWidget->isMaximized())
 {
-if (m_nStyle & SalFrameStyleFlags::SIZEABLE)
-asChild()->resize(nWidth, nHeight);
-else
-asChild()->setFixedSize(nWidth, nHeight);
+if (!(nFlags & SAL_FRAME_POSSIZE_WIDTH))
+nWidth = maGeometry.nWidth;
+else if (!(nFlags & SAL_FRAME_POSSIZE_HEIGHT))
+nHeight = maGeometry.nHeight;
+assert(nWidth > 0 && nHeight > 0);
+
+if (nWidth > 0 && nHeight > 0)
+

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-06-21 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Object.hxx |3 +--
 vcl/qt5/Qt5Object.cxx |   10 ++
 2 files changed, 11 insertions(+), 2 deletions(-)

New commits:
commit f0c9b93e5bc7976dea5de4a49be87cc9892941a7
Author: Jan-Marek Glogowski 
AuthorDate: Fri Jun 21 01:49:59 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Fri Jun 21 12:43:13 2019 +0200

tdf#126020 Qt5 delete orphan Qt5ObjectWindows

The Qt5ObjectWindow is "adopted" by Qt5Frame's QWidget, which
is needed for the correct display. But since the Qt5Object is
itself a child of the Qt5Frame, it'll be deleted before the
Qt5Frame, which keeps the Qt5ObjectWindows alive.
But the Qt5ObjectWindows child relies on the Qt5Object parent,
so reap it, when the real parent is destructed.

And just in case the Qt5Frame will delete the QWidget with the
child while the Qt5Object is still alive, update the pointer to
the child on its destruction.

Change-Id: I563ddc2294b7b1651f56abdde75319c7455dd9b7
Reviewed-on: https://gerrit.libreoffice.org/74482
Tested-by: Jenkins
Reviewed-by: Aleksei Nikiforov 

diff --git a/vcl/inc/qt5/Qt5Object.hxx b/vcl/inc/qt5/Qt5Object.hxx
index 6bfdd81b0327..c6dce6e944be 100644
--- a/vcl/inc/qt5/Qt5Object.hxx
+++ b/vcl/inc/qt5/Qt5Object.hxx
@@ -33,8 +33,6 @@ class Qt5Object : public QObject, public SalObject
 {
 Q_OBJECT
 
-friend class Qt5OpenGLContext;
-
 SystemEnvData m_aSystemData;
 Qt5Frame* m_pParent;
 QWidget* m_pQWidget; // main widget, container
@@ -43,6 +41,7 @@ class Qt5Object : public QObject, public SalObject
 
 public:
 Qt5Object(Qt5Frame* pParent, bool bShow);
+~Qt5Object() override;
 
 Qt5Frame* frame() const { return m_pParent; }
 QWidget* widget() const { return m_pQWidget; }
diff --git a/vcl/qt5/Qt5Object.cxx b/vcl/qt5/Qt5Object.cxx
index 6c5238f012dc..961622eeb893 100644
--- a/vcl/qt5/Qt5Object.cxx
+++ b/vcl/qt5/Qt5Object.cxx
@@ -36,6 +36,7 @@ Qt5Object::Qt5Object(Qt5Frame* pParent, bool bShow)
 m_pQWindow = new Qt5ObjectWindow(*this);
 m_pQWidget = QWidget::createWindowContainer(m_pQWindow, 
pParent->GetQWidget());
 m_pQWidget->setAttribute(Qt::WA_NoSystemBackground);
+connect(m_pQWidget, ::destroyed, this, [this]() { m_pQWidget = 
nullptr; });
 
 if (bShow)
 m_pQWidget->show();
@@ -65,6 +66,15 @@ Qt5Object::Qt5Object(Qt5Frame* pParent, bool bShow)
 }
 }
 
+Qt5Object::~Qt5Object()
+{
+if (m_pQWidget)
+{
+m_pQWidget->setParent(nullptr);
+delete m_pQWidget;
+}
+}
+
 void Qt5Object::ResetClipRegion()
 {
 if (m_pQWidget)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-06-15 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Instance.hxx |1 +
 vcl/qt5/Qt5Instance.cxx |6 ++
 2 files changed, 7 insertions(+)

New commits:
commit 045de7a51f402062f23a3deeb15a199fd039a6f2
Author: Jan-Marek Glogowski 
AuthorDate: Sat Jun 15 11:55:08 2019 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Sat Jun 15 14:54:39 2019 +0200

tdf#125934 Qt5 set the desktop file name

This is a preliminary fix, so LO on Wayland has an application
icon at all. As the result, the start center icon will appear as
the application icon on Wayland for all windows.

For the proper, per QWindow fix, we need some QtCore and QtWayland
changes, to allow setting the appId per QWindow and eventually a
Waylnad XDG shell spec update, to officially allow a top level
window to change its appId.

Change-Id: Icefcfc992836e0c657237984d7d88561b26b06a2
Reviewed-on: https://gerrit.libreoffice.org/74097
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 6c4afd328ee2..2411cdb7f52c 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -65,6 +65,7 @@ class VCLPLUG_QT5_PUBLIC Qt5Instance : public QObject,
 bool m_bUpdateFonts;
 
 DECL_LINK(updateStyleHdl, Timer*, void);
+void AfterAppInit() override;
 
 private Q_SLOTS:
 bool ImplYield(bool bWait, bool bHandleAllCurrentEvents);
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index df6b90363524..7961d5be0209 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -241,6 +241,12 @@ Qt5Instance::~Qt5Instance()
 m_pQApplication.reset();
 }
 
+void Qt5Instance::AfterAppInit()
+{
+// sets the default application icon on Wayland
+
QGuiApplication::setDesktopFileName(QStringLiteral("libreoffice-startcenter.desktop"));
+}
+
 void Qt5Instance::deleteObjectLater(QObject* pObject) { 
pObject->deleteLater(); }
 
 SalFrame* Qt5Instance::CreateChildFrame(SystemParentData* /*pParent*/, 
SalFrameStyleFlags nStyle)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-06-13 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Clipboard.hxx|   56 ++
 vcl/inc/qt5/Qt5Transferable.hxx |   90 --
 vcl/qt5/Qt5Clipboard.cxx|  338 +++---
 vcl/qt5/Qt5Instance.cxx |   13 -
 vcl/qt5/Qt5Transferable.cxx |  355 +---
 5 files changed, 513 insertions(+), 339 deletions(-)

New commits:
commit bcca1cf28cbd6c961d59bd8b8a8e58184dfc3823
Author: Jan-Marek Glogowski 
AuthorDate: Fri May 31 16:40:34 2019 +
Commit: Thorsten Behrens 
CommitDate: Thu Jun 13 23:18:58 2019 +0200

tdf#122239 Qt5 implement lazy clipboard handling

This changes the Qt5Clipboard to a lazy loading one, which will
just deliver data on read requests. This fixes not only the
PRIMARY selection problems with Writer, but will generally speed
up C'n'P, inside LO, because the data has not to be copied or
transferred via QMimeData.

This is mainly done by implementing the "mirror" interface of the
Qt5Transferable, the Qt5MimeData using the retrieveData override.

To prevent clipboard loss on shutdown, this sets a deep copied
QMimeData of the current XTransferable, to make it persistent.

This code explicitly doesn't use any of the QMimeData convenience
functions and relies completely on LO's string handling, so we
won't mix in eventual Qt bugs; all bugs are ours...

Change-Id: I43d92a95df8fcac88dc41b00021cea0b5f040413
Reviewed-on: https://gerrit.libreoffice.org/73288
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 
Reviewed-by: Thorsten Behrens 

diff --git a/vcl/inc/qt5/Qt5Clipboard.hxx b/vcl/inc/qt5/Qt5Clipboard.hxx
index 2c2bb93f5016..93ad36a0e672 100644
--- a/vcl/inc/qt5/Qt5Clipboard.hxx
+++ b/vcl/inc/qt5/Qt5Clipboard.hxx
@@ -20,7 +20,14 @@
 
 #include 
 
-class Qt5Clipboard
+/**
+ * This implementation has two main functions, which handle the clipboard 
content:
+ * the XClipboard::setContent function and the QClipboard::change signal 
handler.
+ *
+ * The first just sets the respective clipboard to the expected content from 
LO,
+ * the latter will handle any reported changes.
+ **/
+class Qt5Clipboard final
 : public QObject,
   public 
cppu::WeakComponentImplHelper m_aContents;
+// the owner of the current contents, which must be informed on content 
change
 css::uno::Reference 
m_aOwner;
 
std::vector>
 m_aListeners;
-OUString m_aClipboardName;
-QClipboard::Mode m_aClipboardMode;
-// custom MIME type to detect whether clipboard content was added by self 
or externally
-const QString m_sMimeTypeUuid = "application/x-libreoffice-clipboard-uuid";
-const QByteArray m_aUuid;
+
+static bool isOwner(const QClipboard::Mode aMode);
+static bool isSupported(const QClipboard::Mode aMode);
+
+explicit Qt5Clipboard(const OUString& aModeString, const QClipboard::Mode 
aMode);
 
 private Q_SLOTS:
-void handleClipboardChange(QClipboard::Mode mode);
+void handleChanged(QClipboard::Mode mode);
 
 public:
-explicit Qt5Clipboard(const OUString& aModeString);
-virtual ~Qt5Clipboard() override;
-
-/*
- * XServiceInfo
- */
+// factory function to construct only valid Qt5Clipboard objects by name
+static css::uno::Reference create(const OUString& 
aModeString);
 
+// XServiceInfo
 virtual OUString SAL_CALL getImplementationName() override;
 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) 
override;
 virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() 
override;
 
-/*
- * XClipboard
- */
-
+// XClipboard
 virtual css::uno::Reference SAL_CALL 
getContents() override;
-
 virtual void SAL_CALL setContents(
 const css::uno::Reference& xTrans,
 const 
css::uno::Reference& 
xClipboardOwner)
 override;
-
 virtual OUString SAL_CALL getName() override;
 
-/*
- * XClipboardEx
- */
-
+// XClipboardEx
 virtual sal_Int8 SAL_CALL getRenderingCapabilities() override;
 
-/*
- * XFlushableClipboard
- */
+// XFlushableClipboard
 virtual void SAL_CALL flushClipboard() override;
 
-/*
- * XClipboardNotifier
- */
+// XClipboardNotifier
 virtual void SAL_CALL addClipboardListener(
 const 
css::uno::Reference& listener)
 override;
-
 virtual void SAL_CALL removeClipboardListener(
 const 
css::uno::Reference& listener)
 override;
diff --git a/vcl/inc/qt5/Qt5Transferable.hxx b/vcl/inc/qt5/Qt5Transferable.hxx
index edc14904f769..f36216eed121 100644
--- a/vcl/inc/qt5/Qt5Transferable.hxx
+++ b/vcl/inc/qt5/Qt5Transferable.hxx
@@ -13,44 +13,110 @@
 #include 
 #include 
 
+#include 
+#include 
 #include 
 
 /**
- * Abstract XTransferable used for clipboard and D'n'D transfers
+ * Qt5Transferable classes are used to read QMimeData via the XTransferable
+ * interface. All the functionality is already implemented in the 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/source

2019-06-12 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx   |3 ---
 vcl/inc/qt5/Qt5Object.hxx  |2 ++
 vcl/inc/salobj.hxx |7 ---
 vcl/qt5/Qt5Frame.cxx   |   13 +
 vcl/qt5/Qt5Object.cxx  |   12 
 vcl/source/window/syschild.cxx |6 --
 6 files changed, 23 insertions(+), 20 deletions(-)

New commits:
commit 2dc6bdd1d5789ace0500cad90f5d2eb930888bb9
Author: Jan-Marek Glogowski 
AuthorDate: Wed Jun 5 17:39:45 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Wed Jun 12 23:22:56 2019 +0200

tdf#125692 SalObject always holds a SystemChildWindow

Let's just face reality and store it as a VclPtr.

And this is needed, because Qt, like VCL, uses deferred deletion,
and has no way to filter events to QObjects out of its event queue
easily. This way the qt5 plugin can report focus changes for
SalObjects without a crash, which happens when you close a
presentation with a video by click.

And in addition it reverts the workaround introduced in commit
e770bacc85a0 ("Qt5 workaround modal change after show bug"), as it
seems this bug is a use-after-free error, introduced by LO.
Thanks Michael Weghorn for catching that!

Maybe someone should also rename SalObject...

Change-Id: I0bc64ea64f95dfc7a838799c4a04de183adfefcf
Reviewed-on: https://gerrit.libreoffice.org/73567
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 3b590bd8e28c..c70171869aa8 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -111,9 +111,6 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public 
SalFrame
 void TriggerPaintEvent();
 void TriggerPaintEvent(QRect aRect);
 
-private:
-void setVisible(bool);
-
 Q_SIGNALS:
 void tooltipRequest(const OUString& rTooltip);
 
diff --git a/vcl/inc/qt5/Qt5Object.hxx b/vcl/inc/qt5/Qt5Object.hxx
index e27d549ca51d..6bfdd81b0327 100644
--- a/vcl/inc/qt5/Qt5Object.hxx
+++ b/vcl/inc/qt5/Qt5Object.hxx
@@ -66,6 +66,8 @@ class Qt5ObjectWindow : public QWindow
 Qt5Object& m_rParent;
 
 bool event(QEvent*) override;
+void focusInEvent(QFocusEvent*) override;
+void focusOutEvent(QFocusEvent*) override;
 void mousePressEvent(QMouseEvent*) override;
 void mouseReleaseEvent(QMouseEvent*) override;
 // keyPressEvent(QKeyEvent*) is handled via event(QEvent*); see comment in 
Qt5Widget::event
diff --git a/vcl/inc/salobj.hxx b/vcl/inc/salobj.hxx
index 56ca04985a7d..83024fec339d 100644
--- a/vcl/inc/salobj.hxx
+++ b/vcl/inc/salobj.hxx
@@ -21,16 +21,17 @@
 #define INCLUDED_VCL_INC_SALOBJ_HXX
 
 #include 
+#include 
 #include 
 #include "salwtype.hxx"
 
 struct SystemEnvData;
 
-typedef void (*SALOBJECTPROC)( void* pInst, SalObjEvent nEvent );
+typedef void (*SALOBJECTPROC)(SystemChildWindow* pInst, SalObjEvent nEvent);
 
 class VCL_PLUGIN_PUBLIC SalObject
 {
-void*   m_pInst;
+VclPtr m_pInst;
 SALOBJECTPROC   m_pCallback;
 boolm_bMouseTransparent:1,
 m_bEraseBackground:1;
@@ -54,7 +55,7 @@ public:
 
 virtual const SystemEnvData*GetSystemData() const = 0;
 
-voidSetCallback( void* pInst, SALOBJECTPROC 
pProc )
+voidSetCallback( SystemChildWindow* pInst, 
SALOBJECTPROC pProc )
 { m_pInst = pInst; m_pCallback = 
pProc; }
 voidCallCallback( SalObjEvent nEvent )
 { if (m_pCallback) m_pCallback( 
m_pInst, nEvent ); }
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 8e63a35cc5c8..270885249298 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -362,8 +362,6 @@ void Qt5Frame::DrawMenuBar() { /* not needed */}
 
 void Qt5Frame::SetExtendedFrameStyle(SalExtStyle /*nExtStyle*/) { /* not 
needed */}
 
-void Qt5Frame::setVisible(bool bVisible) { asChild()->setVisible(bVisible); }
-
 void Qt5Frame::Show(bool bVisible, bool /*bNoActivate*/)
 {
 assert(m_pQWidget);
@@ -373,7 +371,7 @@ void Qt5Frame::Show(bool bVisible, bool /*bNoActivate*/)
 
 auto* pSalInst(static_cast(GetSalData()->m_pInstance));
 assert(pSalInst);
-pSalInst->RunInMainThread([this, bVisible]() { setVisible(bVisible); });
+pSalInst->RunInMainThread([this, bVisible]() { 
asChild()->setVisible(bVisible); });
 }
 
 void Qt5Frame::SetMinClientSize(long nWidth, long nHeight)
@@ -514,16 +512,7 @@ void Qt5Frame::SetModal(bool bModal)
 
 // modality change is only effective if the window is hidden
 if (bWasVisible)
-{
 pChild->hide();
-if (QGuiApplication::platformName() == "xcb")
-{
-SAL_WARN("vcl.qt5", "SetModal called after Show - apply 
delay");
-// give QXcbConnection some time to recover 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-06-12 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Object.hxx|   20 -
 vcl/inc/qt5/Qt5Widget.hxx|   45 +-
 vcl/qt5/Qt5Object.cxx|   35 +--
 vcl/qt5/Qt5OpenGLContext.cxx |3 +-
 vcl/qt5/Qt5Widget.cxx|   63 +--
 5 files changed, 122 insertions(+), 44 deletions(-)

New commits:
commit 25edbded9946801effd117b9c46de0f8b4bc5632
Author: Jan-Marek Glogowski 
AuthorDate: Thu May 30 13:39:11 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Wed Jun 12 23:22:06 2019 +0200

tdf#125517 Qt5 implement a minimal Qt5ObjectWindow

Since we can't use an input and visual transparent widget, like a
GtkGrid, we have to implement input forwarding in the QWindow.

Using a Qt5Widget directly results in other problems on Qt 5.12+,
like these warnings (depending on the tested Qt::WA_* flags):
* Attempted flush to non-raster surface QWidgetWindow(0xa386c10,
  name="QWidgetClassWindow") of type QSurface::OpenGLSurface
  (consider using Qt::WA_PaintOnScreen to exclude from
  backingstore sync)
* QWidget::paintEngine: Should no longer be called

So the current QWidget::createWindowContainer has to stay and key
and mouse handling must be implemented as in Qt5Widget. And the
QWindow is strangely not accessible through the windowHandle() of
the container QWwidget.

As a result this patch is mostly boilerplate code, publishing the
Qt5Widget mouse and key handling as static functions.

Change-Id: I5be5f5fa1379c6bdefab0f96604251801c252b38
Reviewed-on: https://gerrit.libreoffice.org/73566
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Object.hxx b/vcl/inc/qt5/Qt5Object.hxx
index 88cd8baa78da..e27d549ca51d 100644
--- a/vcl/inc/qt5/Qt5Object.hxx
+++ b/vcl/inc/qt5/Qt5Object.hxx
@@ -24,10 +24,10 @@
 
 #include 
 #include 
+#include 
 
 class Qt5Frame;
 class QWidget;
-class QWindow;
 
 class Qt5Object : public QObject, public SalObject
 {
@@ -44,6 +44,10 @@ class Qt5Object : public QObject, public SalObject
 public:
 Qt5Object(Qt5Frame* pParent, bool bShow);
 
+Qt5Frame* frame() const { return m_pParent; }
+QWidget* widget() const { return m_pQWidget; }
+QWindow* windowHandle() const { return m_pQWindow; }
+
 virtual void ResetClipRegion() override;
 virtual void BeginSetClipRegion(sal_uInt32 nRects) override;
 virtual void UnionClipRegion(long nX, long nY, long nWidth, long nHeight) 
override;
@@ -57,4 +61,18 @@ public:
 virtual const SystemEnvData* GetSystemData() const override { return 
_aSystemData; }
 };
 
+class Qt5ObjectWindow : public QWindow
+{
+Qt5Object& m_rParent;
+
+bool event(QEvent*) override;
+void mousePressEvent(QMouseEvent*) override;
+void mouseReleaseEvent(QMouseEvent*) override;
+// keyPressEvent(QKeyEvent*) is handled via event(QEvent*); see comment in 
Qt5Widget::event
+void keyReleaseEvent(QKeyEvent*) override;
+
+public:
+explicit Qt5ObjectWindow(Qt5Object& rParent);
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index ce4e068cbbec..8ead4b3ec945 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -27,17 +27,6 @@
 
 class Qt5Frame;
 class Qt5Object;
-class QEvent;
-class QFocusEvent;
-class QInputMethodEvent;
-class QKeyEvent;
-class QMouseEvent;
-class QMoveEvent;
-class QPaintEvent;
-class QResizeEvent;
-class QShowEvent;
-class QWheelEvent;
-class QVariant;
 
 class Qt5Widget : public QWidget
 {
@@ -48,9 +37,15 @@ class Qt5Widget : public QWidget
 int m_nDeltaX;
 int m_nDeltaY;
 
-bool handleKeyEvent(QKeyEvent*, bool);
-void handleMouseButtonEvent(QMouseEvent*, bool);
-void commitText(const QString& aText) const;
+enum class ButtonKeyState
+{
+Pressed,
+Released
+};
+
+static void commitText(Qt5Frame&, const QString& aText);
+static bool handleKeyEvent(Qt5Frame&, const QWidget&, QKeyEvent*, const 
ButtonKeyState);
+static void handleMouseButtonEvent(const Qt5Frame&, QMouseEvent*, const 
ButtonKeyState);
 
 virtual bool event(QEvent*) override;
 
@@ -84,6 +79,28 @@ public:
 Qt5Frame& getFrame() const { return m_rFrame; }
 void startDrag(sal_Int8 nSourceActions);
 void endExtTextInput();
+
+static bool handleEvent(Qt5Frame&, const QWidget&, QEvent*);
+// key events might be propagated further down => call base on false
+static inline bool handleKeyReleaseEvent(Qt5Frame&, const QWidget&, 
QKeyEvent*);
+// mouse events are always accepted
+static inline void handleMousePressEvent(const Qt5Frame&, QMouseEvent*);
+static inline void handleMouseReleaseEvent(const Qt5Frame&, QMouseEvent*);
 };
 
+bool Qt5Widget::handleKeyReleaseEvent(Qt5Frame& rFrame, const QWidget& 
rWidget, QKeyEvent* pEvent)
+{
+return handleKeyEvent(rFrame, 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-06-06 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Widget.hxx |2 ++
 vcl/qt5/Qt5Widget.cxx |   33 +++--
 2 files changed, 25 insertions(+), 10 deletions(-)

New commits:
commit 1d959beba1cfef5fde035a4a74ee4611e7a04869
Author: Jan-Marek Glogowski 
AuthorDate: Thu Jun 6 01:01:11 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Thu Jun 6 20:24:34 2019 +0200

tdf#125201 fix QWheelEvent angleDelta() handling

Comming back to my initial, known broken implementation from
2017-11 (see commit 1426437be053 ("QT5 implement some mouse
handling")), which just works with mouse scroll wheels.

This just fixes angleDelta() based scrolling. An additional
patch might be needed, if some driver just uses pixelDelta()
values, but Qt explicitly states: "On X11 the pixelDelta()
value is driver specific and unreliable, use angleDelta()
instead.", so we'll do just that for now.

Change-Id: I1be5f9392ed475aea7ab4d965a07e1e3c2574fe7
Reviewed-on: https://gerrit.libreoffice.org/73614
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 6398fa7db55c..ce4e068cbbec 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -45,6 +45,8 @@ class Qt5Widget : public QWidget
 
 Qt5Frame& m_rFrame;
 bool m_bNonEmptyIMPreeditSeen;
+int m_nDeltaX;
+int m_nDeltaY;
 
 bool handleKeyEvent(QKeyEvent*, bool);
 void handleMouseButtonEvent(QMouseEvent*, bool);
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 63eb68577da1..4b378cd44cb2 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -179,20 +179,31 @@ void Qt5Widget::wheelEvent(QWheelEvent* pEvent)
 aEvent.mnY = pEvent->pos().y();
 aEvent.mnCode = GetKeyModCode(pEvent->modifiers()) | 
GetMouseModCode(pEvent->buttons());
 
-int nDelta = pEvent->angleDelta().x();
-aEvent.mbHorz = true;
-if (!nDelta)
+// mouse wheel ticks are 120, which we map to 3 lines.
+// we have to accumulate for touch scroll to keep track of the absolute 
delta.
+
+int nDelta = pEvent->angleDelta().y(), lines;
+aEvent.mbHorz = nDelta == 0;
+if (aEvent.mbHorz)
+{
+nDelta = pEvent->angleDelta().x();
+if (!nDelta)
+return;
+
+m_nDeltaX += nDelta;
+lines = m_nDeltaX / 40;
+m_nDeltaX = m_nDeltaX % 40;
+}
+else
 {
-nDelta = pEvent->angleDelta().y();
-aEvent.mbHorz = false;
+m_nDeltaY += nDelta;
+lines = m_nDeltaY / 40;
+m_nDeltaY = m_nDeltaY % 40;
 }
-if (!nDelta)
-return;
-nDelta /= 8;
 
 aEvent.mnDelta = nDelta;
-aEvent.mnNotchDelta = nDelta > 0 ? 1 : -1;
-aEvent.mnScrollLines = 3;
+aEvent.mnNotchDelta = nDelta < 0 ? -1 : 1;
+aEvent.mnScrollLines = std::abs(lines);
 
 m_rFrame.CallCallback(SalEvent::WheelMouse, );
 pEvent->accept();
@@ -479,6 +490,8 @@ Qt5Widget::Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f)
 : QWidget(Q_NULLPTR, f)
 , m_rFrame(rFrame)
 , m_bNonEmptyIMPreeditSeen(false)
+, m_nDeltaX(0)
+, m_nDeltaY(0)
 {
 create();
 setMouseTracking(true);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-06-06 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Widget.hxx |1 
 vcl/qt5/Qt5Widget.cxx |   50 --
 2 files changed, 32 insertions(+), 19 deletions(-)

New commits:
commit 7140da917bbe80ad39610fdac28f03859f089461
Author: Jan-Marek Glogowski 
AuthorDate: Sat Jun 1 19:46:16 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Thu Jun 6 17:40:36 2019 +0200

tdf#124118 Qt5 post non-code keys via ExtTextInput

Originally I tried to implement the gtk3 way by shoving all key
input in some way through the QInputMethod. But that turned out
to be impossible, because all the nice input event filtering is
privately hidden in the platform abstraction. And it took me
much longer to realize that gtk3 is doing this.

Still the delivered code point in the KeyEvent is correct, so
this simply uses ExtTextInput events for non-code key events,
if LO has enabled input method support for a frame.

Change-Id: Ia9bb6baf013cf790deecb9675f8309e32294e982
Reviewed-on: https://gerrit.libreoffice.org/73322
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index af48dbe5e4f5..6398fa7db55c 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -48,6 +48,7 @@ class Qt5Widget : public QWidget
 
 bool handleKeyEvent(QKeyEvent*, bool);
 void handleMouseButtonEvent(QMouseEvent*, bool);
+void commitText(const QString& aText) const;
 
 virtual bool event(QEvent*) override;
 
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index a6b3d29e69a8..63eb68577da1 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -394,13 +394,35 @@ static sal_uInt16 GetKeyCode(int keyval, 
Qt::KeyboardModifiers modifiers)
 return nCode;
 }
 
+void Qt5Widget::commitText(const QString& aText) const
+{
+SalExtTextInputEvent aInputEvent;
+aInputEvent.mpTextAttr = nullptr;
+aInputEvent.mnCursorFlags = 0;
+aInputEvent.maText = toOUString(aText);
+aInputEvent.mnCursorPos = aInputEvent.maText.getLength();
+
+SolarMutexGuard aGuard;
+vcl::DeletionListener aDel(_rFrame);
+m_rFrame.CallCallback(SalEvent::ExtTextInput, );
+if (!aDel.isDeleted())
+m_rFrame.CallCallback(SalEvent::EndExtTextInput, nullptr);
+}
+
 bool Qt5Widget::handleKeyEvent(QKeyEvent* pEvent, bool bDown)
 {
-SalKeyEvent aEvent;
+sal_uInt16 nCode = GetKeyCode(pEvent->key(), pEvent->modifiers());
+if (bDown && nCode == 0 && !pEvent->text().isEmpty()
+&& testAttribute(Qt::WA_InputMethodEnabled))
+{
+commitText(pEvent->text());
+return true;
+}
 
+SalKeyEvent aEvent;
 aEvent.mnCharCode = (pEvent->text().isEmpty() ? 0 : 
pEvent->text().at(0).unicode());
 aEvent.mnRepeat = 0;
-aEvent.mnCode = GetKeyCode(pEvent->key(), pEvent->modifiers());
+aEvent.mnCode = nCode;
 aEvent.mnCode |= GetKeyModCode(pEvent->modifiers());
 
 QGuiApplication::inputMethod()->update(Qt::ImCursorRectangle);
@@ -483,24 +505,13 @@ static ExtTextInputAttr 
lcl_MapUndrelineStyle(QTextCharFormat::UnderlineStyle us
 
 void Qt5Widget::inputMethodEvent(QInputMethodEvent* pEvent)
 {
-SolarMutexGuard aGuard;
-SalExtTextInputEvent aInputEvent;
-aInputEvent.mpTextAttr = nullptr;
-aInputEvent.mnCursorFlags = 0;
-
-vcl::DeletionListener aDel(_rFrame);
-
 if (!pEvent->commitString().isEmpty())
-{
-aInputEvent.maText = toOUString(pEvent->commitString());
-aInputEvent.mnCursorPos = aInputEvent.maText.getLength();
-if (!aDel.isDeleted())
-m_rFrame.CallCallback(SalEvent::ExtTextInput, );
-if (!aDel.isDeleted())
-m_rFrame.CallCallback(SalEvent::EndExtTextInput, nullptr);
-}
+commitText(pEvent->commitString());
 else
 {
+SalExtTextInputEvent aInputEvent;
+aInputEvent.mpTextAttr = nullptr;
+aInputEvent.mnCursorFlags = 0;
 aInputEvent.maText = toOUString(pEvent->preeditString());
 aInputEvent.mnCursorPos = 0;
 
@@ -549,8 +560,9 @@ void Qt5Widget::inputMethodEvent(QInputMethodEvent* pEvent)
 const bool bIsEmpty = aInputEvent.maText.isEmpty();
 if (m_bNonEmptyIMPreeditSeen || !bIsEmpty)
 {
-if (!aDel.isDeleted())
-m_rFrame.CallCallback(SalEvent::ExtTextInput, );
+SolarMutexGuard aGuard;
+vcl::DeletionListener aDel(_rFrame);
+m_rFrame.CallCallback(SalEvent::ExtTextInput, );
 if (!aDel.isDeleted() && bIsEmpty)
 m_rFrame.CallCallback(SalEvent::EndExtTextInput, nullptr);
 m_bNonEmptyIMPreeditSeen = !bIsEmpty;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/unx

2019-06-05 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Instance.hxx  |5 +
 vcl/qt5/Qt5Instance.cxx  |   18 --
 vcl/unx/kde5/KDE5SalInstance.cxx |   25 +++--
 vcl/unx/kde5/KDE5SalInstance.hxx |   20 ++--
 4 files changed, 34 insertions(+), 34 deletions(-)

New commits:
commit ca69a1e17782d88580f2449e0252be52c26cae42
Author: Jan-Marek Glogowski 
AuthorDate: Sun Jun 2 20:17:49 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Wed Jun 5 13:21:36 2019 +0200

Qt5/KDE5 always use either Qt5 or KDE5 pickers

And use RunInMain for both SalInstances and for both picker types,
as there is no reason to assume just the file and not the folder
picker can be called from the non-GUI thread.

Little drawback is the inclusion of Qt5FilePicker header in the
Qt5Instance header, as Qt's enums aren't forward-declarable.

Change-Id: Ie170d247a76134df9aff835393c71c9d6e907d32
Reviewed-on: https://gerrit.libreoffice.org/73416
Reviewed-by: Michael Weghorn 
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 52b45b12d2b8..c87f3c93c1ac 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -33,6 +33,8 @@
 #include 
 #include 
 
+#include "Qt5FilePicker.hxx"
+
 class QApplication;
 class SalYieldMutex;
 class SalFrame;
@@ -74,6 +76,9 @@ Q_SIGNALS:
 void ImplRunInMainSignal();
 void deleteObjectLaterSignal(QObject* pObject);
 
+protected:
+virtual Qt5FilePicker* createPicker(QFileDialog::FileMode);
+
 public:
 explicit Qt5Instance(std::unique_ptr& pQApp, bool bUseCairo 
= false);
 virtual ~Qt5Instance() override;
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 0358ecd548a6..52eab795682e 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -394,18 +394,32 @@ void Qt5Instance::ProcessEvent(SalUserEvent aEvent)
 aEvent.m_pFrame->CallCallback(aEvent.m_nEvent, aEvent.m_pData);
 }
 
+Qt5FilePicker* Qt5Instance::createPicker(QFileDialog::FileMode eMode)
+{
+if (!IsMainThread())
+{
+SolarMutexGuard g;
+Qt5FilePicker* pPicker;
+RunInMainThread(std::function([&, this]() { pPicker = 
createPicker(eMode); }));
+assert(pPicker);
+return pPicker;
+}
+
+return new Qt5FilePicker(eMode);
+}
+
 css::uno::Reference
 Qt5Instance::createFilePicker(const 
css::uno::Reference&)
 {
 return css::uno::Reference(
-new Qt5FilePicker(QFileDialog::ExistingFile));
+createPicker(QFileDialog::ExistingFile));
 }
 
 css::uno::Reference
 Qt5Instance::createFolderPicker(const 
css::uno::Reference&)
 {
 return css::uno::Reference(
-new Qt5FilePicker(QFileDialog::Directory));
+createPicker(QFileDialog::Directory));
 }
 
 css::uno::Reference
diff --git a/vcl/unx/kde5/KDE5SalInstance.cxx b/vcl/unx/kde5/KDE5SalInstance.cxx
index 63ce689518f5..e2bd75277d23 100644
--- a/vcl/unx/kde5/KDE5SalInstance.cxx
+++ b/vcl/unx/kde5/KDE5SalInstance.cxx
@@ -50,34 +50,23 @@ SalFrame* KDE5SalInstance::CreateFrame(SalFrame* pParent, 
SalFrameStyleFlags nSt
 return pRet;
 }
 
-uno::Reference
-KDE5SalInstance::createFilePicker(const 
uno::Reference& xMSF)
+Qt5FilePicker* KDE5SalInstance::createPicker(QFileDialog::FileMode eMode)
 {
 if (!IsMainThread())
 {
 SolarMutexGuard g;
-uno::Reference xRet;
-RunInMainThread(
-std::function([, this, xMSF]() { xRet = 
this->createFilePicker(xMSF); }));
-assert(xRet);
-return xRet;
+Qt5FilePicker* pPicker;
+RunInMainThread(std::function([&, this]() { pPicker = 
createPicker(eMode); }));
+assert(pPicker);
+return pPicker;
 }
 
 // In order to insert custom controls, KDE5FilePicker currently relies on 
KFileWidget
 // being used in the native file picker, which is only the case for KDE 
Plasma.
 // Therefore, return the plain qt5 one in order to not lose custom 
controls.
 if (Application::GetDesktopEnvironment() == "KDE5")
-{
-return uno::Reference(
-new KDE5FilePicker(QFileDialog::ExistingFile));
-}
-return Qt5Instance::createFilePicker(xMSF);
-}
-
-uno::Reference
-KDE5SalInstance::createFolderPicker(const 
uno::Reference& /*xMSF*/)
-{
-return uno::Reference(new 
KDE5FilePicker(QFileDialog::Directory));
+return new KDE5FilePicker(eMode);
+return Qt5Instance::createPicker(eMode);
 }
 
 extern "C" {
diff --git a/vcl/unx/kde5/KDE5SalInstance.hxx b/vcl/unx/kde5/KDE5SalInstance.hxx
index 11276be3f4ec..53993a5ecc34 100644
--- a/vcl/unx/kde5/KDE5SalInstance.hxx
+++ b/vcl/unx/kde5/KDE5SalInstance.hxx
@@ -21,23 +21,15 @@
 
 #include 
 
-class QApplication;
-
-class KDE5SalInstance : public Qt5Instance
+class KDE5SalInstance final : public Qt5Instance
 {
-public:
-explicit KDE5SalInstance(std::unique_ptr& pQApp);
-
-virtual bool 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-06-03 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx |1 
 vcl/qt5/Qt5Frame.cxx |  123 ++-
 2 files changed, 28 insertions(+), 96 deletions(-)

New commits:
commit d8d8cdecdb760500b06cacef3d17c8e05332967d
Author: Jan-Marek Glogowski 
AuthorDate: Sun Jun 2 15:38:25 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Tue Jun 4 02:25:33 2019 +0200

Qt5 introduce Qt5Frame::asChild() helper

Just a little refactoring.

Gets rid of the common used idom in the code:
  m_pTopLevel ? m_pTopLevel : m_pQWidget

Change-Id: I3e96687d9d02c0b1a5537c6b6cea53e1ca3a2067
Reviewed-on: https://gerrit.libreoffice.org/73414
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 16743edc0fc6..3b590bd8e28c 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -123,6 +123,7 @@ public:
 
 QWidget* GetQWidget() const { return m_pQWidget; }
 Qt5MainWindow* GetTopLevelWindow() const { return m_pTopLevel; }
+QWidget* asChild() const;
 
 void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 
nExtentsWidth,
 sal_Int32 nExtentsHeight) const;
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index a4ad672bab16..a9ffbf7756aa 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -140,13 +140,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 
 if (aWinFlags == Qt::Window)
 {
-QWidget* pParentWidget = nullptr;
-if (m_pParent)
-{
-pParentWidget
-= (m_pParent->m_pTopLevel) ? m_pParent->m_pTopLevel : 
m_pParent->m_pQWidget;
-}
-
+QWidget* pParentWidget = m_pParent ? m_pParent->asChild() : nullptr;
 m_pTopLevel = new Qt5MainWindow(*this, pParentWidget, aWinFlags);
 m_pQWidget = new Qt5Widget(*this, aWinFlags);
 m_pTopLevel->setCentralWidget(m_pQWidget);
@@ -160,8 +154,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 if (pParent && !(pParent->m_nStyle & SalFrameStyleFlags::PLUG))
 {
 QWindow* pParentWindow = 
pParent->GetQWidget()->window()->windowHandle();
-QWindow* pChildWindow = (m_pTopLevel ? 
m_pTopLevel->window()->windowHandle()
- : 
m_pQWidget->window()->windowHandle());
+QWindow* pChildWindow = asChild()->window()->windowHandle();
 if (pParentWindow && pChildWindow && (pParentWindow != pChildWindow))
 pChildWindow->setTransientParent(pParentWindow);
 }
@@ -218,10 +211,7 @@ Qt5Frame::~Qt5Frame()
 {
 Qt5Instance* pInst = static_cast(GetSalData()->m_pInstance);
 pInst->eraseFrame(this);
-if (m_pTopLevel)
-delete m_pTopLevel;
-else
-delete m_pQWidget;
+delete asChild();
 m_aSystemData.aShellWindow = 0;
 }
 
@@ -303,60 +293,31 @@ bool Qt5Frame::PostEvent(std::unique_ptr 
pData)
 return true;
 }
 
-bool Qt5Frame::isWindow() const
-{
-if (m_pTopLevel)
-return m_pTopLevel->isWindow();
-else
-return m_pQWidget->isWindow();
-}
+QWidget* Qt5Frame::asChild() const { return m_pTopLevel ? m_pTopLevel : 
m_pQWidget; }
+
+bool Qt5Frame::isWindow() const { return asChild()->isWindow(); }
 
 QWindow* Qt5Frame::windowHandle() const
 {
 // set attribute 'Qt::WA_NativeWindow' first to make sure a window handle 
actually exists
-if (m_pTopLevel)
-{
-m_pTopLevel->setAttribute(Qt::WA_NativeWindow);
-return m_pTopLevel->windowHandle();
-}
-else
-{
-m_pQWidget->setAttribute(Qt::WA_NativeWindow);
-return m_pQWidget->windowHandle();
-}
+QWidget* pChild = asChild();
+pChild->setAttribute(Qt::WA_NativeWindow);
+return pChild->windowHandle();
 }
 
 QScreen* Qt5Frame::screen() const
 {
 QWindow* const pWindow = windowHandle();
-if (pWindow)
-return pWindow->screen();
-else
-return nullptr;
+return pWindow ? pWindow->screen() : nullptr;
 }
 
-bool Qt5Frame::isMinimized() const
-{
-if (m_pTopLevel)
-return m_pTopLevel->isMinimized();
-else
-return m_pQWidget->isMinimized();
-}
+bool Qt5Frame::isMinimized() const { return asChild()->isMinimized(); }
 
-bool Qt5Frame::isMaximized() const
-{
-if (m_pTopLevel)
-return m_pTopLevel->isMaximized();
-else
-return m_pQWidget->isMaximized();
-}
+bool Qt5Frame::isMaximized() const { return asChild()->isMaximized(); }
 
 void Qt5Frame::SetWindowStateImpl(Qt::WindowStates eState)
 {
-if (m_pTopLevel)
-m_pTopLevel->setWindowState(eState);
-else
-m_pQWidget->setWindowState(eState);
+return asChild()->setWindowState(eState);
 }
 
 void Qt5Frame::SetTitle(const OUString& rTitle)
@@ -400,13 +361,7 @@ void Qt5Frame::DrawMenuBar() { /* not needed */}
 
 void Qt5Frame::SetExtendedFrameStyle(SalExtStyle 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-06-03 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Clipboard.hxx |   44 +++-
 vcl/qt5/Qt5Clipboard.cxx |   76 ++-
 vcl/qt5/Qt5DragAndDrop.cxx   |   33 +-
 vcl/qt5/Qt5Instance.cxx  |   12 +++---
 4 files changed, 84 insertions(+), 81 deletions(-)

New commits:
commit 6e8448cdf0541f017e8b54734dd0928e935c73fa
Author: Jan-Marek Glogowski 
AuthorDate: Fri May 31 16:34:37 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Mon Jun 3 16:24:44 2019 +0200

Qt5 remove header using namespaces and Vcl prefix

This is mainly about the using namespace in the Qt5Clipboard
header. While at it get rid of the Vcl prefix.

Change-Id: I62a804a83afe2feb4bf130eb5475790bc52365c4
Reviewed-on: https://gerrit.libreoffice.org/73287
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Clipboard.hxx b/vcl/inc/qt5/Qt5Clipboard.hxx
index 7539b748dc23..fb79ec463717 100644
--- a/vcl/inc/qt5/Qt5Clipboard.hxx
+++ b/vcl/inc/qt5/Qt5Clipboard.hxx
@@ -21,10 +21,6 @@
 
 #include 
 
-using namespace com::sun::star;
-using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-
 class Qt5Transferable : public 
cppu::WeakImplHelper
 {
 public:
@@ -44,31 +40,30 @@ private:
 QClipboard::Mode m_aClipboardMode;
 };
 
-class VclQt5Clipboard
+class Qt5Clipboard
 : public QObject,
-  public 
cppu::WeakComponentImplHelper
+  public 
cppu::WeakComponentImplHelper
 {
 Q_OBJECT
 
-private Q_SLOTS:
-void handleClipboardChange(QClipboard::Mode mode);
-
-private:
 osl::Mutex m_aMutex;
-Reference m_aContents;
-Reference m_aOwner;
-std::vector> 
m_aListeners;
+css::uno::Reference m_aContents;
+css::uno::Reference 
m_aOwner;
+
std::vector>
 m_aListeners;
 OUString m_aClipboardName;
 QClipboard::Mode m_aClipboardMode;
 // custom MIME type to detect whether clipboard content was added by self 
or externally
 const QString m_sMimeTypeUuid = "application/x-libreoffice-clipboard-uuid";
 const QByteArray m_aUuid;
 
+private Q_SLOTS:
+void handleClipboardChange(QClipboard::Mode mode);
+
 public:
-explicit VclQt5Clipboard(const OUString& aModeString);
-virtual ~VclQt5Clipboard() override;
+explicit Qt5Clipboard(const OUString& aModeString);
+virtual ~Qt5Clipboard() override;
 
 /*
  * XServiceInfo
@@ -76,17 +71,18 @@ public:
 
 virtual OUString SAL_CALL getImplementationName() override;
 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) 
override;
-virtual Sequence SAL_CALL getSupportedServiceNames() override;
+virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() 
override;
 
 /*
  * XClipboard
  */
 
-virtual Reference SAL_CALL getContents() 
override;
+virtual css::uno::Reference SAL_CALL 
getContents() override;
 
 virtual void SAL_CALL setContents(
-const Reference& xTrans,
-const Reference& 
xClipboardOwner) override;
+const css::uno::Reference& xTrans,
+const 
css::uno::Reference& 
xClipboardOwner)
+override;
 
 virtual OUString SAL_CALL getName() override;
 
@@ -105,10 +101,12 @@ public:
  * XClipboardNotifier
  */
 virtual void SAL_CALL addClipboardListener(
-const Reference& 
listener) override;
+const 
css::uno::Reference& listener)
+override;
 
 virtual void SAL_CALL removeClipboardListener(
-const Reference& 
listener) override;
+const 
css::uno::Reference& listener)
+override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Clipboard.cxx b/vcl/qt5/Qt5Clipboard.cxx
index 6d333d498ff2..8f9c373836bb 100644
--- a/vcl/qt5/Qt5Clipboard.cxx
+++ b/vcl/qt5/Qt5Clipboard.cxx
@@ -25,6 +25,8 @@
 
 #include 
 
+using namespace com::sun::star;
+
 namespace
 {
 std::map g_nameToClipboardMap
@@ -95,7 +97,7 @@ std::vector 
Qt5Transferable::getTransferDataFlavo
 else
 {
 aFlavor.MimeType = toOUString(rMimeType);
-aFlavor.DataType = cppu::UnoType>::get();
+aFlavor.DataType = 
cppu::UnoType>::get();
 aVector.push_back(aFlavor);
 }
 }
@@ -143,7 +145,8 @@ Qt5Transferable::getTransferData(const 
css::datatransfer::DataFlavor& rFlavor)
 {
 QString clipboardContent = mimeData->html();
 std::string aStr = clipboardContent.toStdString();
-Sequence aSeq(reinterpret_cast(aStr.c_str()), aStr.length());
+uno::Sequence aSeq(reinterpret_cast(aStr.c_str()),
+ aStr.length());
 aRet <<= aSeq;
 }
 else if (rFlavor.MimeType.startsWith("image") && mimeData->hasImage())
@@ -157,7 +160,7 @@ Qt5Transferable::getTransferData(const 
css::datatransfer::DataFlavor& rFlavor)
 buffer.open(QIODevice::WriteOnly);
 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-05-31 Thread Katarina Behrens (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx |2 +
 vcl/qt5/Qt5Frame.cxx |   75 +--
 2 files changed, 62 insertions(+), 15 deletions(-)

New commits:
commit 6f613f973dcb86dbebc212bc466fbaa2b002655b
Author: Katarina Behrens 
AuthorDate: Wed May 29 19:01:28 2019 +0200
Commit: Katarina Behrens 
CommitDate: Fri May 31 13:22:10 2019 +0200

tdf#124484: resize slideshow window so it spans all displays

Change-Id: I55b4ab8ec5059110525c5194e1133c65bbd07fec
Reviewed-on: https://gerrit.libreoffice.org/73183
Tested-by: Jenkins
Reviewed-by: Katarina Behrens 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index a42a95aac3bd..16743edc0fc6 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -83,6 +83,8 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public 
SalFrame
 bool m_bDefaultSize;
 bool m_bDefaultPos;
 bool m_bFullScreen;
+bool m_bFullScreenSpanAll;
+sal_uInt32 m_nRestoreScreen;
 QRect m_aRestoreGeometry;
 
 void Center();
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 386fa08052c7..6d19d825fa1c 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -60,6 +60,28 @@ static void SvpDamageHandler(void* handle, sal_Int32 
nExtentsX, sal_Int32 nExten
 pThis->Damage(nExtentsX, nExtentsY, nExtentsWidth, nExtentsHeight);
 }
 
+namespace
+{
+sal_Int32 screenNumber(const QScreen* pScreen)
+{
+const QList screens = QApplication::screens();
+
+sal_Int32 nScreen = 0;
+bool bFound = false;
+for (const QScreen* pCurScreen : screens)
+{
+if (pScreen == pCurScreen)
+{
+bFound = true;
+break;
+}
+nScreen++;
+}
+
+return bFound ? nScreen : -1;
+}
+}
+
 Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool 
bUseCairo)
 : m_pTopLevel(nullptr)
 , m_bUseCairo(bUseCairo)
@@ -74,6 +96,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 , m_bDefaultSize(true)
 , m_bDefaultPos(true)
 , m_bFullScreen(false)
+, m_bFullScreenSpanAll(false)
 {
 Qt5Instance* pInst = static_cast(GetSalData()->m_pInstance);
 pInst->insertFrame(this);
@@ -145,6 +168,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 // fake an initial geometry, gets updated via configure event or SetPosSize
 if (m_bDefaultPos || m_bDefaultSize)
 {
+maGeometry.nDisplayScreenNumber = 0;
 Size aDefSize = CalcDefaultSize();
 maGeometry.nX = -1;
 maGeometry.nY = -1;
@@ -431,16 +455,25 @@ void Qt5Frame::Center()
 Size Qt5Frame::CalcDefaultSize()
 {
 assert(isWindow());
-QSize qSize(0, 0);
-QScreen* pScreen = screen();
-if (pScreen)
-qSize = pScreen->size();
-else
-qSize = QApplication::desktop()->screenGeometry(0).size();
 
-Size aSize = toSize(qSize);
+Size aSize;
 if (!m_bFullScreen)
-aSize = bestmaxFrameSizeForScreenSize(aSize);
+{
+const QScreen* pScreen = screen();
+aSize = bestmaxFrameSizeForScreenSize(
+toSize(pScreen ? pScreen->size() : 
QApplication::desktop()->screenGeometry(0).size()));
+}
+else
+{
+if (!m_bFullScreenSpanAll)
+aSize = toSize(
+
QApplication::desktop()->screenGeometry(maGeometry.nDisplayScreenNumber).size());
+else
+{
+int nLeftScreen = QApplication::desktop()->screenNumber(QPoint(0, 
0));
+aSize = 
toSize(QApplication::screens()[nLeftScreen]->availableVirtualGeometry().size());
+}
+}
 
 return aSize;
 }
@@ -644,7 +677,11 @@ void Qt5Frame::ShowFullScreen(bool bFullScreen, sal_Int32 
nScreen)
 // only top-level windows can go fullscreen
 assert(m_pTopLevel);
 
+if (m_bFullScreen == bFullScreen)
+return;
+
 m_bFullScreen = bFullScreen;
+m_bFullScreenSpanAll = m_bFullScreen && (nScreen < 0);
 
 // show it if it isn't shown yet
 if (!isWindow())
@@ -653,15 +690,18 @@ void Qt5Frame::ShowFullScreen(bool bFullScreen, sal_Int32 
nScreen)
 if (m_bFullScreen)
 {
 m_aRestoreGeometry = m_pTopLevel->geometry();
-// do that before going fullscreen
-SetScreenNumber(nScreen);
-windowHandle()->showFullScreen();
+m_nRestoreScreen = maGeometry.nDisplayScreenNumber;
+SetScreenNumber(m_bFullScreenSpanAll ? m_nRestoreScreen : nScreen);
+if (!m_bFullScreenSpanAll)
+windowHandle()->showFullScreen();
+else
+windowHandle()->showNormal();
 }
 else
 {
+SetScreenNumber(m_nRestoreScreen);
 windowHandle()->showNormal();
 m_pTopLevel->setGeometry(m_aRestoreGeometry);
-m_aRestoreGeometry = QRect();
 }
 }
 
@@ -1101,23 +1141,25 @@ void Qt5Frame::SetScreenNumber(unsigned int nScreen)
 if (pWindow)
 {
   

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-05-24 Thread Katarina Behrens (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx |5 +++--
 vcl/qt5/Qt5Frame.cxx |   29 -
 vcl/qt5/Qt5Widget.cxx|5 +++--
 3 files changed, 30 insertions(+), 9 deletions(-)

New commits:
commit c58487251272b390e9c56a880fa4788d0a5b5a7f
Author: Katarina Behrens 
AuthorDate: Thu May 23 18:11:43 2019 +0200
Commit: Katarina Behrens 
CommitDate: Fri May 24 09:42:35 2019 +0200

tdf#125160: honour keyboard modifiers if used during DnD

e.g. copy-DnD with Ctrl held down. This is qt5 remix of tdf#109227

Change-Id: Ib0794c7468cc04d3d50686952305717e10c90c9a
Reviewed-on: https://gerrit.libreoffice.org/72878
Tested-by: Jenkins
Reviewed-by: Katarina Behrens 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 6fe1333bd138..9b9c13b4b7fa 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -140,8 +140,9 @@ public:
 virtual void registerDropTarget(Qt5DropTarget* pDropTarget);
 virtual void deregisterDropTarget(Qt5DropTarget const* pDropTarget);
 void draggingStarted(const int x, const int y, Qt::DropActions eActions,
- const QMimeData* pQMimeData);
-void dropping(const int x, const int y, const QMimeData* pQMimeData);
+ Qt::KeyboardModifiers eKeyMod, const QMimeData* 
pQMimeData);
+void dropping(const int x, const int y, Qt::KeyboardModifiers eKeyMod,
+  const QMimeData* pQMimeData);
 
 virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle) override;
 virtual void Show(bool bVisible, bool bNoActivate = false) override;
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 3cfb5d5d9e33..41a4544b4acb 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -1159,16 +1159,30 @@ void Qt5Frame::deregisterDropTarget(Qt5DropTarget 
const* pDropTarget)
 }
 
 void Qt5Frame::draggingStarted(const int x, const int y, Qt::DropActions 
eActions,
-   const QMimeData* pQMimeData)
+   Qt::KeyboardModifiers eKeyMod, const QMimeData* 
pQMimeData)
 {
 assert(m_pDropTarget);
 
+sal_Int8 nUserDropAction = 
css::datatransfer::dnd::DNDConstants::ACTION_MOVE;
+if ((eKeyMod & Qt::ShiftModifier) && !(eKeyMod & Qt::ControlModifier))
+nUserDropAction = css::datatransfer::dnd::DNDConstants::ACTION_MOVE;
+else if ((eKeyMod & Qt::ControlModifier) && !(eKeyMod & Qt::ShiftModifier))
+nUserDropAction = css::datatransfer::dnd::DNDConstants::ACTION_COPY;
+else if ((eKeyMod & Qt::ShiftModifier) && (eKeyMod & Qt::ControlModifier))
+nUserDropAction = css::datatransfer::dnd::DNDConstants::ACTION_LINK;
+
 css::datatransfer::dnd::DropTargetDragEnterEvent aEvent;
 aEvent.Source = 
static_cast(m_pDropTarget);
 aEvent.Context = 
static_cast(m_pDropTarget);
 aEvent.LocationX = x;
 aEvent.LocationY = y;
-aEvent.DropAction = getPreferredDropAction(eActions);
+
+// system drop action if neither Shift nor Control is held
+if (!(eKeyMod & (Qt::ShiftModifier | Qt::ControlModifier)))
+aEvent.DropAction = getPreferredDropAction(eActions);
+// otherwise user-preferred action
+else
+aEvent.DropAction = nUserDropAction;
 aEvent.SourceActions = toVclDropActions(eActions);
 
 css::uno::Reference xTransferable;
@@ -1190,7 +1204,8 @@ void Qt5Frame::draggingStarted(const int x, const int y, 
Qt::DropActions eAction
 m_pDropTarget->fire_dragOver(aEvent);
 }
 
-void Qt5Frame::dropping(const int x, const int y, const QMimeData* pQMimeData)
+void Qt5Frame::dropping(const int x, const int y, Qt::KeyboardModifiers 
eKeyMod,
+const QMimeData* pQMimeData)
 {
 assert(m_pDropTarget);
 
@@ -1199,8 +1214,12 @@ void Qt5Frame::dropping(const int x, const int y, const 
QMimeData* pQMimeData)
 aEvent.Context = 
static_cast(m_pDropTarget);
 aEvent.LocationX = x;
 aEvent.LocationY = y;
-aEvent.DropAction = m_pDropTarget->proposedDragAction()
-| css::datatransfer::dnd::DNDConstants::ACTION_DEFAULT;
+
+if (!(eKeyMod & (Qt::ShiftModifier | Qt::ControlModifier)))
+aEvent.DropAction = m_pDropTarget->proposedDragAction()
+| 
css::datatransfer::dnd::DNDConstants::ACTION_DEFAULT;
+else
+aEvent.DropAction = m_pDropTarget->proposedDragAction();
 aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_MOVE;
 
 css::uno::Reference xTransferable;
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index a388bf941672..4d620767472f 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -221,7 +221,8 @@ void Qt5Widget::dragMoveEvent(QDragMoveEvent* event)
 {
 QPoint point = event->pos();
 
-m_rFrame.draggingStarted(point.x(), point.y(), event->possibleActions(), 
event->mimeData());
+m_rFrame.draggingStarted(point.x(), point.y(), event->possibleActions(),
+

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-05-15 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Menu.hxx |3 +++
 vcl/qt5/Qt5Menu.cxx |   23 ++-
 2 files changed, 17 insertions(+), 9 deletions(-)

New commits:
commit a348806baf31b4072f02886d142ac6c3e1bba665
Author: Jan-Marek Glogowski 
AuthorDate: Mon May 6 17:18:56 2019 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Wed May 15 23:25:37 2019 +0200

Qt5 don't unconditionally disconnect close button

Change-Id: Ibfa4d493ed752a03554020c6ab06bfc38745d97d
Reviewed-on: https://gerrit.libreoffice.org/71871
Tested-by: Jenkins
Reviewed-by: Aleksei Nikiforov 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index 76d865b263ff..cf60ee2c0bb7 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -18,6 +18,7 @@
 class MenuItemList;
 class QAction;
 class QActionGroup;
+class QPushButton;
 class QMenu;
 class QMenuBar;
 class Qt5MenuItem;
@@ -34,6 +35,8 @@ private:
 bool mbMenuBar;
 QMenuBar* mpQMenuBar;
 QMenu* mpQMenu;
+QPushButton* mpCloseButton;
+QMetaObject::Connection maCloseButtonConnection;
 
 void DoFullMenuUpdate(Menu* pMenuBar);
 static void NativeItemText(OUString& rItemText);
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index 5bfaefa9b931..733b1505b49c 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -30,6 +30,7 @@ Qt5Menu::Qt5Menu(bool bMenuBar)
 , mbMenuBar(bMenuBar)
 , mpQMenuBar(nullptr)
 , mpQMenu(nullptr)
+, mpCloseButton(nullptr)
 {
 }
 
@@ -411,7 +412,17 @@ void Qt5Menu::SetFrame(const SalFrame* pFrame)
 {
 mpQMenuBar = pMainWindow->menuBar();
 if (mpQMenuBar)
+{
 mpQMenuBar->clear();
+QPushButton* pButton
+= 
static_cast(mpQMenuBar->cornerWidget(Qt::TopRightCorner));
+if (pButton && ((mpCloseButton != pButton) || 
!maCloseButtonConnection))
+{
+maCloseButtonConnection
+= connect(pButton, ::clicked, this, 
::slotCloseDocument);
+mpCloseButton = pButton;
+}
+}
 
 mpQMenu = nullptr;
 
@@ -622,19 +633,13 @@ void Qt5Menu::ShowCloseButton(bool bShow)
 pButton->setFlat(true);
 pButton->setToolTip(toQString(VclResId(SV_HELPTEXT_CLOSEDOCUMENT)));
 mpQMenuBar->setCornerWidget(pButton, Qt::TopRightCorner);
+maCloseButtonConnection
+= connect(pButton, ::clicked, this, 
::slotCloseDocument);
+mpCloseButton = pButton;
 }
 
 if (bShow)
-{
-// The mpQMenuBar is used in multiple Qt5Menu. If one Qt5Menu is 
deleted, the clicked button
-// connection is severed. The reconnect could be handled in SetFrame, 
but ShowCloseButton is
-// called so seldomly, that I decided to keep the reconnect in this 
function in one place. As
-// we don't know the connection state, we unconditionally remove it, 
so slotCloseDocument
-// isn't called multiple times on click.
-pButton->disconnect(SIGNAL(clicked(bool)));
-connect(pButton, ::clicked, this, 
::slotCloseDocument);
 pButton->show();
-}
 else
 pButton->hide();
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-05-13 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Frame.hxx|1 +
 vcl/inc/qt5/Qt5Instance.hxx |8 
 vcl/inc/qt5/Qt5Widget.hxx   |2 ++
 vcl/qt5/Qt5Frame.cxx|8 ++--
 vcl/qt5/Qt5Instance.cxx |   28 
 vcl/qt5/Qt5Widget.cxx   |   22 ++
 6 files changed, 67 insertions(+), 2 deletions(-)

New commits:
commit faecfd43646d9910e0409a39fecfd8816fe16cc9
Author: Jan-Marek Glogowski 
AuthorDate: Sun May 12 14:30:06 2019 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Mon May 13 12:22:46 2019 +0200

Qt5 handle theming-based change events

Qt generates three change events when changing the KDE theme:
FontChange, StyleChange and PaletteChange. LO has two:
SettingChanged and FontChanged. And like Qt LO will inform all
widgets / windows independently. To prevent several redraws,
this patch just collects all Qt's change events and notifies LO
once a bit later via a Timer.

Change-Id: I9b45f543f13a84e39247a642a0e33c9ec008a46a
Reviewed-on: https://gerrit.libreoffice.org/72196
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 1309c17d10a7..6fe1333bd138 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -66,6 +66,7 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public 
SalFrame
 bool m_bNullRegion;
 
 bool m_bGraphicsInUse;
+bool m_bGraphicsInvalid;
 SalFrameStyleFlags m_nStyle;
 Qt5Frame* m_pParent;
 PointerStyle m_ePointerStyle;
diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index a9be3581f64b..52b45b12d2b8 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -58,6 +59,11 @@ class VCLPLUG_QT5_PUBLIC Qt5Instance : public QObject,
 std::unique_ptr m_pFakeArgv;
 std::unique_ptr m_pFakeArgc;
 
+Timer m_aUpdateStyleTimer;
+bool m_bUpdateFonts;
+
+DECL_LINK(updateStyleHdl, Timer*, void);
+
 private Q_SLOTS:
 bool ImplYield(bool bWait, bool bHandleAllCurrentEvents);
 void ImplRunInMain();
@@ -138,6 +144,8 @@ public:
 CreateClipboard(const css::uno::Sequence& i_rArguments) 
override;
 virtual css::uno::Reference CreateDragSource() 
override;
 virtual css::uno::Reference CreateDropTarget() 
override;
+
+void UpdateStyle(bool bFontsChanged);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 8879bc10aef2..af48dbe5e4f5 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -27,6 +27,7 @@
 
 class Qt5Frame;
 class Qt5Object;
+class QEvent;
 class QFocusEvent;
 class QInputMethodEvent;
 class QKeyEvent;
@@ -66,6 +67,7 @@ class Qt5Widget : public QWidget
 virtual void showEvent(QShowEvent*) override;
 virtual void wheelEvent(QWheelEvent*) override;
 virtual void closeEvent(QCloseEvent*) override;
+virtual void changeEvent(QEvent*) override;
 
 void inputMethodEvent(QInputMethodEvent*) override;
 QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 5ed722aad391..acb43e515983 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -65,6 +65,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 , m_pSvpGraphics(nullptr)
 , m_bNullRegion(true)
 , m_bGraphicsInUse(false)
+, m_bGraphicsInvalid(false)
 , m_ePointerStyle(PointerStyle::Arrow)
 , m_pDragSource(nullptr)
 , m_pDropTarget(nullptr)
@@ -215,21 +216,23 @@ SalGraphics* Qt5Frame::AcquireGraphics()
 
 if (m_bUseCairo)
 {
-if (!m_pOurSvpGraphics.get())
+if (!m_pOurSvpGraphics.get() || m_bGraphicsInvalid)
 {
 m_pOurSvpGraphics.reset(new SvpSalGraphics());
 InitSvpSalGraphics(m_pOurSvpGraphics.get());
+m_bGraphicsInvalid = false;
 }
 return m_pOurSvpGraphics.get();
 }
 else
 {
-if (!m_pQt5Graphics.get())
+if (!m_pQt5Graphics.get() || m_bGraphicsInvalid)
 {
 m_pQt5Graphics.reset(new Qt5Graphics(this));
 m_pQImage.reset(new QImage(m_pQWidget->size(), 
Qt5_DefaultFormat32));
 m_pQImage->fill(Qt::transparent);
 m_pQt5Graphics->ChangeQImage(m_pQImage.get());
+m_bGraphicsInvalid = false;
 }
 return m_pQt5Graphics.get();
 }
@@ -1015,6 +1018,7 @@ void Qt5Frame::UpdateSettings(AllSettings& rSettings)
 style.SetShadowColor(toColor(pal.color(QPalette::Disabled, 
QPalette::WindowText)));
 style.SetDarkShadowColor(toColor(pal.color(QPalette::Inactive, 
QPalette::WindowText)));
 
+m_bGraphicsInvalid = true;
 rSettings.SetStyleSettings(style);
 }
 
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-05-09 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Widget.hxx |3 +++
 vcl/qt5/Qt5Frame.cxx  |4 +++-
 vcl/qt5/Qt5Widget.cxx |   38 +++---
 3 files changed, 37 insertions(+), 8 deletions(-)

New commits:
commit c1bcdf9aa5d8ea99435906ffa9787232a909ff0f
Author: Jan-Marek Glogowski 
AuthorDate: Wed May 8 11:51:15 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Thu May 9 10:37:47 2019 +0200

Qt5 IM handle (spurious?) all-empty IM events

2nd attempt to fix the bug described in commit 00221089800c ("Qt5
IM allow committing empty strings") and various siblings of it.
This also reverts it.

What I see is calls with "all-empty" events (preedit, commit and
replacementLength() == 0; no QInputMethodEvent::Attribute), some
from QIBusPlatformInputContext::updatePreeditText.

There are various Writer document edit states with (selected)
text, undo, cursor position and focus changes to other windows via
Ctrl+Tab, which will result in inputMethodEvent calls totally in
contrast to the expected text state, all somehow always related to
all-empty events. They currently result in wrongly deleted
selected text, change of selection, cursor movement or general
change of text from old preedit. Most time on focus out / window
change, some times at first meta-key press after focus in.

This patch tries hard not to corrupt Writers edit state with these
all-empty events. No idea if this is some bug on LO's qt5 side or
expected, but KDE kate and VCL gtk3 and gen work fine, so I assume
Qt's behaviour is correct. FWIW gtk3 also does some extended IM
handling with focus, so probably this is the Qt equivalent of it.
But then I couldn't find some eqivalent code in Qt's source code.
I actually expected an even more complex solution (if this really
fixes all cases).

Works for a multitude of tests I tried to come up with, but is
quite probably not the final fix to this, as qt5 current doesn't
handle replacementStart() and replacementLength() at all.
Also never saw a call to Qt5Frame::EndExtTextInput.

Change-Id: I4210e0588041cfb4d80dbdfdb937e430a5f7cbfb
Reviewed-on: https://gerrit.libreoffice.org/71988
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 30998a8a1c6d..8879bc10aef2 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -43,6 +43,7 @@ class Qt5Widget : public QWidget
 Q_OBJECT
 
 Qt5Frame& m_rFrame;
+bool m_bNonEmptyIMPreeditSeen;
 
 bool handleKeyEvent(QKeyEvent*, bool);
 void handleMouseButtonEvent(QMouseEvent*, bool);
@@ -51,6 +52,7 @@ class Qt5Widget : public QWidget
 
 virtual void focusInEvent(QFocusEvent*) override;
 virtual void focusOutEvent(QFocusEvent*) override;
+// keyPressEvent(QKeyEvent*) is handled via event(QEvent*); see comment
 virtual void keyReleaseEvent(QKeyEvent*) override;
 virtual void mouseMoveEvent(QMouseEvent*) override;
 virtual void mousePressEvent(QMouseEvent*) override;
@@ -76,6 +78,7 @@ public:
 
 Qt5Frame& getFrame() const { return m_rFrame; }
 void startDrag(sal_Int8 nSourceActions);
+void endExtTextInput();
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index b07ea360a1cc..07ae9f055bb1 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -723,7 +723,9 @@ void Qt5Frame::SetInputContext(SalInputContext* pContext)
 
 void Qt5Frame::EndExtTextInput(EndExtTextInputFlags /*nFlags*/)
 {
-// TODO fwd to IM handler
+Qt5Widget* pQt5Widget = static_cast(m_pQWidget);
+if (pQt5Widget)
+pQt5Widget->endExtTextInput();
 }
 
 OUString Qt5Frame::GetKeyName(sal_uInt16 nKeyCode)
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 865f36b0a567..a4c01cdede32 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -433,7 +433,11 @@ void Qt5Widget::keyReleaseEvent(QKeyEvent* pEvent)
 
 void Qt5Widget::focusInEvent(QFocusEvent*) { 
m_rFrame.CallCallback(SalEvent::GetFocus, nullptr); }
 
-void Qt5Widget::focusOutEvent(QFocusEvent*) { 
m_rFrame.CallCallback(SalEvent::LoseFocus, nullptr); }
+void Qt5Widget::focusOutEvent(QFocusEvent*)
+{
+endExtTextInput();
+m_rFrame.CallCallback(SalEvent::LoseFocus, nullptr);
+}
 
 void Qt5Widget::showTooltip(const OUString& rTooltip)
 {
@@ -444,6 +448,7 @@ void Qt5Widget::showTooltip(const OUString& rTooltip)
 Qt5Widget::Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f)
 : QWidget(Q_NULLPTR, f)
 , m_rFrame(rFrame)
+, m_bNonEmptyIMPreeditSeen(false)
 {
 create();
 setMouseTracking(true);
@@ -475,13 +480,14 @@ void Qt5Widget::inputMethodEvent(QInputMethodEvent* 
pEvent)
 aInputEvent.mpTextAttr = nullptr;
 aInputEvent.mnCursorFlags = 0;
 
-if (!pEvent->commitString().isNull())
+vcl::DeletionListener 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-05-07 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Menu.hxx  |2 +
 vcl/inc/qt5/Qt5Tools.hxx |5 +++
 vcl/qt5/Qt5Menu.cxx  |   74 +--
 vcl/qt5/Qt5Tools.cxx |   20 
 4 files changed, 80 insertions(+), 21 deletions(-)

New commits:
commit 8ea988f585db72da88994d29d006f1976007789d
Author: Jan-Marek Glogowski 
AuthorDate: Sat May 4 00:03:15 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Tue May 7 17:42:32 2019 +0200

tdf#123549 Qt5 implement Qt5Menu::ShowCloseButton

This includes some not-so-nice lifetime handling of the button
"clicked" connection handling. I decided to keep the code in
one place, simply always forcing a disconnect on show, instead
of a more "optimized" code version in SetFrame.

First we try to get the icon from the system theme, but use LO's
own icon theme as a fallback.

Change-Id: Ic0459623ec907b9a54bef4670bf65cf587cd47ea
Reviewed-on: https://gerrit.libreoffice.org/71784
Tested-by: Jenkins 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index f3807abb0bf6..76d865b263ff 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -67,6 +67,7 @@ public:
 virtual void SetAccelerator(unsigned nPos, SalMenuItem* pSalMenuItem,
 const vcl::KeyCode& rKeyCode, const OUString& 
rKeyName) override;
 virtual void GetSystemMenuData(SystemMenuData* pData) override;
+virtual void ShowCloseButton(bool bShow) override;
 
 void SetMenu(Menu* pMenu) { mpVCLMenu = pMenu; }
 Menu* GetMenu() { return mpVCLMenu; }
@@ -77,6 +78,7 @@ private slots:
 static void slotMenuTriggered(Qt5MenuItem* pQItem);
 static void slotMenuAboutToShow(Qt5MenuItem* pQItem);
 static void slotMenuAboutToHide(Qt5MenuItem* pQItem);
+void slotCloseDocument();
 };
 
 class Qt5MenuItem : public SalMenuItem
diff --git a/vcl/inc/qt5/Qt5Tools.hxx b/vcl/inc/qt5/Qt5Tools.hxx
index 8863e2496687..6b1fb1adcc7e 100644
--- a/vcl/inc/qt5/Qt5Tools.hxx
+++ b/vcl/inc/qt5/Qt5Tools.hxx
@@ -34,6 +34,9 @@
 
 #include 
 
+class Image;
+class QImage;
+
 inline OUString toOUString(const QString& s)
 {
 // QString stores UTF16, just like OUString
@@ -136,4 +139,6 @@ typedef std::unique_ptr 
UniqueCairoSurface;
 sal_uInt16 GetKeyModCode(Qt::KeyboardModifiers eKeyModifiers);
 sal_uInt16 GetMouseModCode(Qt::MouseButtons eButtons);
 
+QImage toQImage(const Image& rImage);
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index d119c71010b9..5bfaefa9b931 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -7,19 +7,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include 
-#include 
-#include 
 #include 
 #include 
+
+#include 
 #include 
+#include 
 
-#include 
+#include 
+#include 
 
 #include 
 #include 
-#include 
-#include 
+
+#include 
+#include 
 
 Qt5Menu::Qt5Menu(bool bMenuBar)
 : mpVCLMenu(nullptr)
@@ -421,6 +423,7 @@ void Qt5Menu::DoFullMenuUpdate(Menu* pMenuBar)
 {
 // clear action groups since menu is rebuilt
 ResetAllActionGroups();
+ShowCloseButton(false);
 
 for (sal_Int32 nItem = 0; nItem < static_cast(GetItemCount()); 
nItem++)
 {
@@ -507,21 +510,7 @@ void Qt5Menu::SetItemImage(unsigned, SalMenuItem* pItem, 
const Image& rImage)
 if (!pAction)
 return;
 
-QImage aImage;
-
-if (!!rImage)
-{
-SvMemoryStream aMemStm;
-vcl::PNGWriter aWriter(rImage.GetBitmapEx());
-aWriter.Write(aMemStm);
-
-if (!aImage.loadFromData(static_cast(aMemStm.GetData()), 
aMemStm.TellEnd()))
-{
-return;
-}
-}
-
-pAction->setIcon(QPixmap::fromImage(aImage));
+pAction->setIcon(QPixmap::fromImage(toQImage(rImage)));
 }
 
 void Qt5Menu::SetAccelerator(unsigned, SalMenuItem* pItem, const vcl::KeyCode&,
@@ -607,6 +596,49 @@ void Qt5Menu::NativeItemText(OUString& rItemText)
 rItemText = rItemText.replace('~', '&');
 }
 
+void Qt5Menu::slotCloseDocument()
+{
+MenuBar* pVclMenuBar = static_cast(mpVCLMenu.get());
+if (pVclMenuBar)
+Application::PostUserEvent(pVclMenuBar->GetCloseButtonClickHdl());
+}
+
+void Qt5Menu::ShowCloseButton(bool bShow)
+{
+if (!mpQMenuBar)
+return;
+
+QPushButton* pButton = 
static_cast(mpQMenuBar->cornerWidget(Qt::TopRightCorner));
+if (!pButton)
+{
+QIcon aIcon;
+if (QIcon::hasThemeIcon("window-close-symbolic"))
+aIcon = QIcon::fromTheme("window-close-symbolic");
+else
+aIcon = QIcon(
+QPixmap::fromImage((toQImage(Image(StockImage::Yes, 
SV_RESID_BITMAP_CLOSEDOC);
+pButton = new QPushButton(mpQMenuBar);
+pButton->setIcon(aIcon);
+pButton->setFlat(true);
+pButton->setToolTip(toQString(VclResId(SV_HELPTEXT_CLOSEDOCUMENT)));
+mpQMenuBar->setCornerWidget(pButton, 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-05-06 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Menu.hxx |3 ---
 vcl/qt5/Qt5Menu.cxx |1 -
 2 files changed, 4 deletions(-)

New commits:
commit ac52193805c537619402b993d7308935857ce668
Author: Jan-Marek Glogowski 
AuthorDate: Mon May 6 15:09:51 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Mon May 6 20:58:58 2019 +0200

Qt5 remove unused Qt5Menu::setFrameSignal

Change-Id: Iead091fee3b6c72d610f42598edb7cbb681d0cd4
Reviewed-on: https://gerrit.libreoffice.org/71870
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index b8a451657372..f3807abb0bf6 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -73,9 +73,6 @@ public:
 unsigned GetItemCount() { return maItems.size(); }
 Qt5MenuItem* GetItemAtPos(unsigned nPos) { return maItems[nPos]; }
 
-Q_SIGNALS:
-void setFrameSignal(const SalFrame* pFrame);
-
 private slots:
 static void slotMenuTriggered(Qt5MenuItem* pQItem);
 static void slotMenuAboutToShow(Qt5MenuItem* pQItem);
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index 6112a7aa4e6c..d119c71010b9 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -29,7 +29,6 @@ Qt5Menu::Qt5Menu(bool bMenuBar)
 , mpQMenuBar(nullptr)
 , mpQMenu(nullptr)
 {
-connect(this, ::setFrameSignal, this, ::SetFrame, 
Qt::BlockingQueuedConnection);
 }
 
 bool Qt5Menu::VisibleMenuBar() { return true; }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-05-06 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Widget.hxx   |5 ++
 vcl/qt5/Qt5AccessibleWidget.cxx |2 -
 vcl/qt5/Qt5Widget.cxx   |   79 +++-
 3 files changed, 43 insertions(+), 43 deletions(-)

New commits:
commit 8c71d28069acffa2d4590a4acf95a98d1415b563
Author: Jan-Marek Glogowski 
AuthorDate: Sun May 5 23:22:09 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Mon May 6 14:57:45 2019 +0200

Qt5 make Qt5Widdget's frame a private reference

Kind of a regression from commit 4d382636b0b1 ("qt5: Add basic
a11y support"), which made it public for a single call.

Change-Id: I631a861a98388223770cfca2704c3ddee6a0a8a0
Reviewed-on: https://gerrit.libreoffice.org/71836
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index d96afa64aeb0..30998a8a1c6d 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -42,6 +42,8 @@ class Qt5Widget : public QWidget
 {
 Q_OBJECT
 
+Qt5Frame& m_rFrame;
+
 bool handleKeyEvent(QKeyEvent*, bool);
 void handleMouseButtonEvent(QMouseEvent*, bool);
 
@@ -71,7 +73,8 @@ public slots:
 
 public:
 Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
-Qt5Frame* m_pFrame;
+
+Qt5Frame& getFrame() const { return m_rFrame; }
 void startDrag(sal_Int8 nSourceActions);
 };
 
diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx
index b76acb4a1c57..2c31a2bdb92a 100644
--- a/vcl/qt5/Qt5AccessibleWidget.cxx
+++ b/vcl/qt5/Qt5AccessibleWidget.cxx
@@ -718,7 +718,7 @@ QAccessibleInterface* 
Qt5AccessibleWidget::customFactory(const QString& classnam
 if (classname == QLatin1String("Qt5Widget") && object && 
object->isWidgetType())
 {
 Qt5Widget* pWidget = static_cast(object);
-vcl::Window* pWindow = pWidget->m_pFrame->GetWindow();
+vcl::Window* pWindow = pWidget->getFrame().GetWindow();
 
 if (pWindow)
 return new Qt5AccessibleWidget(pWindow->GetAccessible());
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 0b22cbb884f8..865f36b0a567 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -49,12 +49,12 @@
 void Qt5Widget::paintEvent(QPaintEvent* pEvent)
 {
 QPainter p(this);
-if (!m_pFrame->m_bNullRegion)
-p.setClipRegion(m_pFrame->m_aRegion);
+if (!m_rFrame.m_bNullRegion)
+p.setClipRegion(m_rFrame.m_aRegion);
 
-if (m_pFrame->m_bUseCairo)
+if (m_rFrame.m_bUseCairo)
 {
-cairo_surface_t* pSurface = m_pFrame->m_pSurface.get();
+cairo_surface_t* pSurface = m_rFrame.m_pSurface.get();
 cairo_surface_flush(pSurface);
 
 QImage aImage(cairo_image_surface_get_data(pSurface), size().width(), 
size().height(),
@@ -62,55 +62,55 @@ void Qt5Widget::paintEvent(QPaintEvent* pEvent)
 p.drawImage(pEvent->rect().topLeft(), aImage, pEvent->rect());
 }
 else
-p.drawImage(pEvent->rect().topLeft(), *m_pFrame->m_pQImage, 
pEvent->rect());
+p.drawImage(pEvent->rect().topLeft(), *m_rFrame.m_pQImage, 
pEvent->rect());
 }
 
 void Qt5Widget::resizeEvent(QResizeEvent* pEvent)
 {
-if (m_pFrame->m_bUseCairo)
+if (m_rFrame.m_bUseCairo)
 {
 int width = size().width();
 int height = size().height();
 
-if (m_pFrame->m_pSvpGraphics)
+if (m_rFrame.m_pSvpGraphics)
 {
 cairo_surface_t* pSurface
 = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, 
height);
 cairo_surface_set_user_data(pSurface, 
SvpSalGraphics::getDamageKey(),
-_pFrame->m_aDamageHandler, nullptr);
-m_pFrame->m_pSvpGraphics->setSurface(pSurface, 
basegfx::B2IVector(width, height));
-UniqueCairoSurface old_surface(m_pFrame->m_pSurface.release());
-m_pFrame->m_pSurface.reset(pSurface);
+_rFrame.m_aDamageHandler, nullptr);
+m_rFrame.m_pSvpGraphics->setSurface(pSurface, 
basegfx::B2IVector(width, height));
+UniqueCairoSurface old_surface(m_rFrame.m_pSurface.release());
+m_rFrame.m_pSurface.reset(pSurface);
 
 int min_width = qMin(pEvent->oldSize().width(), 
pEvent->size().width());
 int min_height = qMin(pEvent->oldSize().height(), 
pEvent->size().height());
 
 SalTwoRect rect(0, 0, min_width, min_height, 0, 0, min_width, 
min_height);
 
-m_pFrame->m_pSvpGraphics->copySource(rect, old_surface.get());
+m_rFrame.m_pSvpGraphics->copySource(rect, old_surface.get());
 }
 }
 else
 {
 QImage* pImage = nullptr;
 
-if (m_pFrame->m_pQImage)
+if (m_rFrame.m_pQImage)
 pImage = new QImage(
-m_pFrame->m_pQImage->copy(0, 0, pEvent->size().width(), 
pEvent->size().height()));
+

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-04-29 Thread Katarina Behrens (via logerrit)
 vcl/inc/qt5/Qt5DragAndDrop.hxx |2 ++
 vcl/qt5/Qt5DragAndDrop.cxx |   26 --
 2 files changed, 26 insertions(+), 2 deletions(-)

New commits:
commit cc6c1798b8d6d9d27dc40145e1ec71dd480c788a
Author: Katarina Behrens 
AuthorDate: Mon Apr 29 14:50:32 2019 +0200
Commit: Katarina Behrens 
CommitDate: Mon Apr 29 21:21:42 2019 +0200

tdf#124990: DnD operation can be set to fail in dropComplete

thus we reimplement it for Qt5DropTarget. This is qt5 remix of
tdf#118302 (in Calc drop into the same tab should cancel DnD, instead
of causing data loss)

Change-Id: Ib37ea5a018133779e85e8e131d81bb6cee7d9206
Reviewed-on: https://gerrit.libreoffice.org/71531
Tested-by: Jenkins
Reviewed-by: Katarina Behrens 

diff --git a/vcl/inc/qt5/Qt5DragAndDrop.hxx b/vcl/inc/qt5/Qt5DragAndDrop.hxx
index 099ba444ea15..3547131587f3 100644
--- a/vcl/inc/qt5/Qt5DragAndDrop.hxx
+++ b/vcl/inc/qt5/Qt5DragAndDrop.hxx
@@ -75,6 +75,8 @@ public:
 void fire_dragEnd(sal_Int8 nAction);
 
 static Qt5DragSource* m_ActiveDragSource;
+static bool m_bDropSuccessSet;
+static bool m_bDropSuccess;
 
 css::uno::Reference const& 
GetTransferable() const
 {
diff --git a/vcl/qt5/Qt5DragAndDrop.cxx b/vcl/qt5/Qt5DragAndDrop.cxx
index adc7a94fa0c2..42e61074a824 100644
--- a/vcl/qt5/Qt5DragAndDrop.cxx
+++ b/vcl/qt5/Qt5DragAndDrop.cxx
@@ -94,6 +94,9 @@ std::vector 
Qt5DnDTransferable::getTransferDataFl
 return aVector;
 }
 
+bool Qt5DragSource::m_bDropSuccessSet = false;
+bool Qt5DragSource::m_bDropSuccess = false;
+
 Qt5DragSource::~Qt5DragSource()
 {
 //if (m_pFrame)
@@ -140,6 +143,8 @@ void Qt5DragSource::startDrag(
 {
 Qt5Widget* qw = static_cast(m_pFrame->GetQWidget());
 m_ActiveDragSource = this;
+m_bDropSuccessSet = false;
+m_bDropSuccess = false;
 qw->startDrag(sourceActions);
 }
 else
@@ -165,7 +170,14 @@ void Qt5DragSource::fire_dragEnd(sal_Int8 nAction)
 {
 datatransfer::dnd::DragSourceDropEvent aEv;
 aEv.DropAction = nAction;
-aEv.DropSuccess = true; // FIXME: what if drop didn't work out?
+
+// internal DnD can accept the drop
+// but still fail in Qt5DropTarget::dropComplete
+if (m_bDropSuccessSet)
+aEv.DropSuccess = m_bDropSuccess;
+else
+aEv.DropSuccess = true;
+
 auto xListener = m_xListener;
 m_xListener.clear();
 xListener->dragDropEnd(aEv);
@@ -341,6 +353,16 @@ void Qt5DropTarget::rejectDrop()
 return;
 }
 
-void Qt5DropTarget::dropComplete(sal_Bool /*success*/) { return; }
+void Qt5DropTarget::dropComplete(sal_Bool success)
+{
+// internal DnD
+if (Qt5DragSource::m_ActiveDragSource)
+{
+Qt5DragSource::m_bDropSuccessSet = true;
+Qt5DragSource::m_bDropSuccess = success;
+}
+
+return;
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/unx

2019-04-04 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5Instance.hxx  |   22 +++-
 vcl/qt5/Qt5Instance.cxx  |  104 ++-
 vcl/unx/kde5/KDE5SalInstance.cxx |   82 +++---
 vcl/unx/kde5/KDE5SalInstance.hxx |4 +
 4 files changed, 92 insertions(+), 120 deletions(-)

New commits:
commit 810e62b8ba9c0fa5152592ef6b01400bfcfe59c0
Author: Jan-Marek Glogowski 
AuthorDate: Sat Mar 23 04:05:04 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Thu Apr 4 14:19:43 2019 +0200

Qt5 / KDE5 refactor create_SalInstance

Move most common code into Qt5Instance (static) functions.
Not much saved with regard to LOC, but since the code was
95% C'n'P, I hope it'll be less error prone this way.

Also handle all QApplication argument pointers via
std::unique_ptr from the beginning.

Change-Id: I87b2f571d398db7ccce3e740f16205b251be4ced
Reviewed-on: https://gerrit.libreoffice.org/69578
Tested-by: Jenkins
Reviewed-by: Aleksei Nikiforov 

diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 52153846faa1..a9be3581f64b 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -27,12 +27,21 @@
 
 #include 
 
+#include 
 #include 
+#include 
+#include 
 
 class QApplication;
 class SalYieldMutex;
 class SalFrame;
 
+struct StdFreeCStr
+{
+void operator()(char* arg) const noexcept { std::free(arg); }
+};
+using FreeableCStr = std::unique_ptr;
+
 class VCLPLUG_QT5_PUBLIC Qt5Instance : public QObject,
public SalGenericInstance,
public SalUserEventList
@@ -44,9 +53,8 @@ class VCLPLUG_QT5_PUBLIC Qt5Instance : public QObject,
 const bool m_bUseCairo;
 std::unordered_map> 
m_aClipboards;
 
-public:
 std::unique_ptr m_pQApplication;
-std::unique_ptr m_pFakeArgvFreeable;
+std::vector m_pFakeArgvFreeable;
 std::unique_ptr m_pFakeArgv;
 std::unique_ptr m_pFakeArgc;
 
@@ -61,9 +69,17 @@ Q_SIGNALS:
 void deleteObjectLaterSignal(QObject* pObject);
 
 public:
-explicit Qt5Instance(bool bUseCairo = false);
+explicit Qt5Instance(std::unique_ptr& pQApp, bool bUseCairo 
= false);
 virtual ~Qt5Instance() override;
 
+// handle common SalInstance setup
+static void AllocFakeCmdlineArgs(std::unique_ptr& rFakeArgv,
+ std::unique_ptr& rFakeArgc,
+ std::vector& 
rFakeArgvFreeable);
+void MoveFakeCmdlineArgs(std::unique_ptr& rFakeArgv, 
std::unique_ptr& rFakeArgc,
+ std::vector& rFakeArgvFreeable);
+static std::unique_ptr CreateQApplication(int& nArgc, char** 
pArgv);
+
 void RunInMainThread(std::function func);
 
 virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags 
nStyle) override;
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index f0d42666e3ce..dd0edddc97cf 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -200,10 +200,11 @@ void Qt5Instance::ImplRunInMain()
 (void)this; // suppress unhelpful [loplugin:staticmethods]; can't be static
 }
 
-Qt5Instance::Qt5Instance(bool bUseCairo)
+Qt5Instance::Qt5Instance(std::unique_ptr& pQApp, bool bUseCairo)
 : SalGenericInstance(std::make_unique())
 , m_postUserEventId(-1)
 , m_bUseCairo(bUseCairo)
+, m_pQApplication(std::move(pQApp))
 {
 ImplSVData* pSVData = ImplGetSVData();
 if (bUseCairo)
@@ -232,8 +233,6 @@ Qt5Instance::~Qt5Instance()
 // force freeing the QApplication before freeing the arguments,
 // as it uses references to the provided arguments!
 m_pQApplication.reset();
-for (int i = 0; i < *m_pFakeArgc; i++)
-free(m_pFakeArgvFreeable[i]);
 }
 
 void Qt5Instance::deleteObjectLater(QObject* pObject) { 
pObject->deleteLater(); }
@@ -441,18 +440,16 @@ Reference Qt5Instance::CreateDropTarget()
 return Reference(static_cast(new 
Qt5DropTarget()));
 }
 
-extern "C" {
-VCLPLUG_QT5_PUBLIC SalInstance* create_SalInstance()
+void Qt5Instance::AllocFakeCmdlineArgs(std::unique_ptr& rFakeArgv,
+   std::unique_ptr& rFakeArgc,
+   std::vector& 
rFakeArgvFreeable)
 {
 OString aVersion(qVersion());
 SAL_INFO("vcl.qt5", "qt version string is " << aVersion);
 
-QApplication* pQApplication;
-char** pFakeArgvFreeable = nullptr;
-
-int nFakeArgc = 2;
 const sal_uInt32 nParams = osl_getCommandArgCount();
 OString aDisplay;
+sal_uInt32 nDisplayValueIdx = 0;
 OUString aParam, aBin;
 
 for (sal_uInt32 nIdx = 0; nIdx < nParams; ++nIdx)
@@ -460,66 +457,85 @@ VCLPLUG_QT5_PUBLIC SalInstance* create_SalInstance()
 osl_getCommandArg(nIdx, );
 if (aParam != "-display")
 continue;
-if (!pFakeArgvFreeable)
-{
-pFakeArgvFreeable = new char*[nFakeArgc + 2];
-

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-03-30 Thread Katarina Behrens (via logerrit)
 vcl/inc/qt5/Qt5AccessibleWidget.hxx |1 
 vcl/qt5/Qt5AccessibleWidget.cxx |  285 +---
 2 files changed, 201 insertions(+), 85 deletions(-)

New commits:
commit 9e37ab4e650481f8bf03d1469815299b8ef1fb5f
Author: Katarina Behrens 
AuthorDate: Thu Mar 21 22:16:42 2019 +0100
Commit: Katarina Behrens 
CommitDate: Sat Mar 30 09:20:29 2019 +0100

tdf#122056: Catch DisposedExceptions everywhere

Change-Id: I6bdb9aa89a8a5181b096f47f90ab6fb5711e7447
Reviewed-on: https://gerrit.libreoffice.org/69541
Tested-by: Jenkins
Reviewed-by: Katarina Behrens 

diff --git a/vcl/inc/qt5/Qt5AccessibleWidget.hxx 
b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
index 19478586ea42..6b0d71cba9f5 100644
--- a/vcl/inc/qt5/Qt5AccessibleWidget.hxx
+++ b/vcl/inc/qt5/Qt5AccessibleWidget.hxx
@@ -136,6 +136,7 @@ public:
 
 private:
 css::uno::Reference m_xAccessible;
+css::uno::Reference 
getAccessibleContextImpl() const;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx
index efafab17f3cf..b76acb4a1c57 100644
--- a/vcl/qt5/Qt5AccessibleWidget.cxx
+++ b/vcl/qt5/Qt5AccessibleWidget.cxx
@@ -71,11 +71,41 @@ Qt5AccessibleWidget::Qt5AccessibleWidget(const 
Reference xAccessibl
 }
 }
 
+Reference Qt5AccessibleWidget::getAccessibleContextImpl() 
const
+{
+Reference xAc;
+
+if (m_xAccessible.is())
+{
+try
+{
+xAc = m_xAccessible->getAccessibleContext();
+}
+catch (css::lang::DisposedException /*ex*/)
+{
+SAL_WARN("vcl.qt5", "Accessible context disposed already");
+}
+// sometimes getAccessibleContext throws also RuntimeException if 
context is no longer alive
+catch (css::uno::RuntimeException /*ex*/)
+{
+// so let's catch it here, cuz otherwise soffice falls flat on its 
face
+// with FatalError and nothing else
+SAL_WARN("vcl.qt5", "Accessible context no longer alive");
+}
+}
+
+return xAc;
+}
+
 QWindow* Qt5AccessibleWidget::window() const { return nullptr; }
 
 int Qt5AccessibleWidget::childCount() const
 {
-return m_xAccessible->getAccessibleContext()->getAccessibleChildCount();
+Reference xAc = getAccessibleContextImpl();
+if (!xAc.is())
+return 0;
+
+return xAc->getAccessibleChildCount();
 }
 
 int Qt5AccessibleWidget::indexOfChild(const QAccessibleInterface* /* child */) 
const { return 0; }
@@ -144,25 +174,29 @@ QVector>
 Qt5AccessibleWidget::relations(QAccessible::Relation match) const
 {
 QVector> relations;
-Reference xRelationSet
-= m_xAccessible->getAccessibleContext()->getAccessibleRelationSet();
-if (!xRelationSet.is())
+
+Reference xAc = getAccessibleContextImpl();
+if (!xAc.is())
 return relations;
 
-if (match == QAccessible::AllRelations)
+Reference xRelationSet = 
xAc->getAccessibleRelationSet();
+if (xRelationSet.is())
 {
-int count = xRelationSet->getRelationCount();
-for (int i = 0; i < count; i++)
+if (match == QAccessible::AllRelations)
+{
+int count = xRelationSet->getRelationCount();
+for (int i = 0; i < count; i++)
+{
+AccessibleRelation aRelation = xRelationSet->getRelation(i);
+lcl_appendRelation(, aRelation);
+}
+}
+else
 {
-AccessibleRelation aRelation = xRelationSet->getRelation(i);
+AccessibleRelation aRelation = 
xRelationSet->getRelation(lcl_matchQtRelation(match));
 lcl_appendRelation(, aRelation);
 }
 }
-else
-{
-AccessibleRelation aRelation = 
xRelationSet->getRelation(lcl_matchQtRelation(match));
-lcl_appendRelation(, aRelation);
-}
 
 return relations;
 }
@@ -177,8 +211,11 @@ QAccessibleInterface* Qt5AccessibleWidget::focusChild() 
const
 
 QRect Qt5AccessibleWidget::rect() const
 {
-Reference 
xAccessibleComponent(m_xAccessible->getAccessibleContext(),
- UNO_QUERY);
+Reference xAc = getAccessibleContextImpl();
+if (!xAc.is())
+return QRect();
+
+Reference xAccessibleComponent(xAc, UNO_QUERY);
 awt::Point aPoint = xAccessibleComponent->getLocation();
 awt::Size aSize = xAccessibleComponent->getSize();
 
@@ -187,24 +224,35 @@ QRect Qt5AccessibleWidget::rect() const
 
 QAccessibleInterface* Qt5AccessibleWidget::parent() const
 {
-return QAccessible::queryAccessibleInterface(
-new 
Qt5XAccessible(m_xAccessible->getAccessibleContext()->getAccessibleParent()));
+Reference xAc = getAccessibleContextImpl();
+if (!xAc.is())
+return nullptr;
+
+return QAccessible::queryAccessibleInterface(new 
Qt5XAccessible(xAc->getAccessibleParent()));
 }
 QAccessibleInterface* Qt5AccessibleWidget::child(int 

[Libreoffice-commits] core.git: vcl/inc vcl/qt5

2019-03-23 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/qt5/Qt5FontFace.hxx  |1 +
 vcl/qt5/Qt5FontFace.cxx  |   41 ++---
 vcl/qt5/Qt5Graphics_Text.cxx |6 +-
 3 files changed, 32 insertions(+), 16 deletions(-)

New commits:
commit 3519325b7d1fa80220f52b74bce3dd75eb220038
Author: Jan-Marek Glogowski 
AuthorDate: Sat Mar 23 05:30:33 2019 +
Commit: Jan-Marek Glogowski 
CommitDate: Sat Mar 23 13:56:48 2019 +0100

tdf#123072 Qt5 just use data from QFontDatabase

This way we can skip the intermediate QFont creation, which takes
a much longer. The database information is actually sufficient.

Change-Id: Ie5ab163edf6a1712d45b0738bb2e4822f2e3298c
Reviewed-on: https://gerrit.libreoffice.org/69579
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/qt5/Qt5FontFace.hxx b/vcl/inc/qt5/Qt5FontFace.hxx
index 4f8f968700f9..350abd593d6a 100644
--- a/vcl/inc/qt5/Qt5FontFace.hxx
+++ b/vcl/inc/qt5/Qt5FontFace.hxx
@@ -35,6 +35,7 @@ class Qt5FontFace : public PhysicalFontFace
 {
 public:
 static Qt5FontFace* fromQFont(const QFont& rFont);
+static Qt5FontFace* fromQFontDatabase(const QString& aFamily, const 
QString& aStyle);
 static void fillAttributesFromQFont(const QFont& rFont, FontAttributes& 
rFA);
 
 sal_IntPtr GetFontId() const override;
diff --git a/vcl/qt5/Qt5FontFace.cxx b/vcl/qt5/Qt5FontFace.cxx
index e7b6a6ebf9b7..ec304603b2f1 100644
--- a/vcl/qt5/Qt5FontFace.cxx
+++ b/vcl/qt5/Qt5FontFace.cxx
@@ -32,6 +32,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -45,18 +46,10 @@ Qt5FontFace::Qt5FontFace(const Qt5FontFace& rSrc)
 m_xCharMap = rSrc.m_xCharMap;
 }
 
-void Qt5FontFace::fillAttributesFromQFont(const QFont& rFont, FontAttributes& 
rFA)
+static FontWeight fromQFontWeight(int nWeight)
 {
-QFontInfo aFontInfo(rFont);
-
-rFA.SetFamilyName(toOUString(aFontInfo.family()));
-if (IsStarSymbol(toOUString(aFontInfo.family(
-rFA.SetSymbolFlag(true);
-rFA.SetStyleName(toOUString(aFontInfo.styleName()));
-rFA.SetPitch(aFontInfo.fixedPitch() ? PITCH_FIXED : PITCH_VARIABLE);
-
 FontWeight eWeight = WEIGHT_DONTKNOW;
-switch (aFontInfo.weight())
+switch (nWeight)
 {
 case QFont::Thin:
 eWeight = WEIGHT_THIN;
@@ -86,7 +79,19 @@ void Qt5FontFace::fillAttributesFromQFont(const QFont& 
rFont, FontAttributes& rF
 eWeight = WEIGHT_BLACK;
 break;
 }
-rFA.SetWeight(eWeight);
+return eWeight;
+}
+
+void Qt5FontFace::fillAttributesFromQFont(const QFont& rFont, FontAttributes& 
rFA)
+{
+QFontInfo aFontInfo(rFont);
+
+rFA.SetFamilyName(toOUString(aFontInfo.family()));
+if (IsStarSymbol(toOUString(aFontInfo.family(
+rFA.SetSymbolFlag(true);
+rFA.SetStyleName(toOUString(aFontInfo.styleName()));
+rFA.SetPitch(aFontInfo.fixedPitch() ? PITCH_FIXED : PITCH_VARIABLE);
+rFA.SetWeight(fromQFontWeight(aFontInfo.weight()));
 
 switch (aFontInfo.style())
 {
@@ -109,6 +114,20 @@ Qt5FontFace* Qt5FontFace::fromQFont(const QFont& rFont)
 return new Qt5FontFace(aFA, rFont.toString());
 }
 
+Qt5FontFace* Qt5FontFace::fromQFontDatabase(const QString& aFamily, const 
QString& aStyle)
+{
+QFontDatabase aFDB;
+FontAttributes aFA;
+aFA.SetFamilyName(toOUString(aFamily));
+if (IsStarSymbol(aFA.GetFamilyName()))
+aFA.SetSymbolFlag(true);
+aFA.SetStyleName(toOUString(aStyle));
+aFA.SetPitch(aFDB.isFixedPitch(aFamily, aStyle) ? PITCH_FIXED : 
PITCH_VARIABLE);
+aFA.SetWeight(fromQFontWeight(aFDB.weight(aFamily, aStyle)));
+aFA.SetItalic(aFDB.italic(aFamily, aStyle) ? ITALIC_NORMAL : ITALIC_NONE);
+return new Qt5FontFace(aFA, aFamily + "," + aStyle);
+}
+
 Qt5FontFace::Qt5FontFace(const FontAttributes& rFA, const QString& rFontID)
 : PhysicalFontFace(rFA)
 , m_aFontId(rFontID)
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 693f67fe2df0..510aa5053237 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -124,11 +124,7 @@ void Qt5Graphics::GetDevFontList(PhysicalFontCollection* 
pPFC)
 
 for (auto& family : aFDB.families())
 for (auto& style : aFDB.styles(family))
-{
-// Just get any size - we don't care
-QList sizes = aFDB.smoothSizes(family, style);
-pPFC->Add(Qt5FontFace::fromQFont(aFDB.font(family, style, 
*sizes.begin(;
-}
+pPFC->Add(Qt5FontFace::fromQFontDatabase(family, style));
 }
 
 void Qt5Graphics::ClearDevFontCache() {}
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/unx

2019-03-22 Thread Caolán McNamara (via logerrit)
 vcl/inc/unx/fc_fontoptions.hxx |2 
 vcl/inc/unx/fontmanager.hxx|6 +-
 vcl/inc/unx/freetype_glyphcache.hxx|9 +--
 vcl/inc/unx/glyphcache.hxx |8 +-
 vcl/qt5/Qt5Graphics_Text.cxx   |3 -
 vcl/unx/generic/fontmanager/fontconfig.cxx |   48 +---
 vcl/unx/generic/fontmanager/fontmanager.cxx|   20 ++-
 vcl/unx/generic/gdi/cairotextrender.cxx|3 -
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |   71 ++---
 vcl/unx/generic/glyphs/glyphcache.cxx  |5 +
 vcl/unx/generic/print/genpspgraphics.cxx   |3 -
 11 files changed, 135 insertions(+), 43 deletions(-)

New commits:
commit cb54bb89494218589227246f1923d8a24ab1676a
Author: Caolán McNamara 
AuthorDate: Thu Mar 21 12:12:49 2019 +
Commit: Caolán McNamara 
CommitDate: Fri Mar 22 11:15:27 2019 +0100

rhbz#1690732 basic font variation support

on the fontconfig/harfbuzz/cairo drawing path for preset variations

Change-Id: I95ef68aecfd59687ae9aae58e01e394c83c6ea9e
Reviewed-on: https://gerrit.libreoffice.org/69505
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/vcl/inc/unx/fc_fontoptions.hxx b/vcl/inc/unx/fc_fontoptions.hxx
index 4e21a4d28c3e..c5ea38ce4f54 100644
--- a/vcl/inc/unx/fc_fontoptions.hxx
+++ b/vcl/inc/unx/fc_fontoptions.hxx
@@ -34,7 +34,7 @@ public:
 mpPattern(pPattern) {}
 ~FontConfigFontOptions();
 
-voidSyncPattern(const OString& rFileName, int nFontFace, 
bool bEmbolden);
+voidSyncPattern(const OString& rFileName, sal_uInt32 
nFontFace, sal_uInt32 nFontVariation, bool bEmbolden);
 FcPattern*  GetPattern() const;
 static void cairo_font_options_substitute(FcPattern* pPattern);
 private:
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx
index e19b5f3fc9ae..d796aba7e944 100644
--- a/vcl/inc/unx/fontmanager.hxx
+++ b/vcl/inc/unx/fontmanager.hxx
@@ -131,6 +131,7 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
 int   m_nDirectory;   // atom containing system 
dependent path
 OString   m_aFontFile;// relative to directory
 int   m_nCollectionEntry; // 0 for regular fonts, 0 to ... 
for fonts stemming from collections
+int   m_nVariationEntry;  // 0 for regular fonts, 0 to ... 
for fonts stemming from font variations
 
 explicit PrintFont();
 };
@@ -154,7 +155,7 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
 bool analyzeSfntFile(PrintFont* pFont) const;
 // finds the font id for the nFaceIndex face in this font file
 // There may be multiple font ids for font collections
-fontID findFontFileID( int nDirID, const OString& rFile, int nFaceIndex ) 
const;
+fontID findFontFileID(int nDirID, const OString& rFile, int nFaceIndex, 
int nVariationIndex) const;
 
 // There may be multiple font ids for font collections
 std::vector findFontFileIDs( int nDirID, const OString& rFile ) 
const;
@@ -242,6 +243,9 @@ public:
 // get the ttc face number
 int getFontFaceNumber( fontID nFontID ) const;
 
+// get the ttc face variation
+int getFontFaceVariation( fontID nFontID ) const;
+
 // get a specific fonts ascend
 int getFontAscend( fontID nFontID ) const;
 
diff --git a/vcl/inc/unx/freetype_glyphcache.hxx 
b/vcl/inc/unx/freetype_glyphcache.hxx
index eec85653cf7b..6fd0154d98a7 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -57,10 +57,9 @@ private:
 class FreetypeFontInfo
 {
 public:
-   FreetypeFontInfo( const FontAttributes&,
-   const OString& rNativeFileName,
-   int nFaceNum, sal_IntPtr nFontId);
-  ~FreetypeFontInfo();
+FreetypeFontInfo(const FontAttributes&, const OString& rNativeFileName,
+ int nFaceNum, int nFaceVariation, sal_IntPtr nFontId);
+~FreetypeFontInfo();
 
 const unsigned char*  GetTable( const char*, sal_uLong* pLength) const;
 
@@ -69,6 +68,7 @@ public:
 
 const OString&GetFontFileName() const   { return 
mpFontFile->GetFileName(); }
 int   GetFontFaceIndex() const  { return mnFaceNum; }
+int   GetFontFaceVariation() const  { return 
mnFaceVariation; }
 sal_IntPtrGetFontId() const { return mnFontId; }
 bool  IsSymbolFont() const  { return 
maDevFontAttributes.IsSymbolFont(); }
 const FontAttributes& GetFontAttributes() const { return 
maDevFontAttributes; }
@@ -82,6 +82,7 @@ private:
 FT_FaceRec_*maFaceFT;
 FreetypeFontFile* const mpFontFile;
 const int   mnFaceNum;
+const int   mnFaceVariation;
 int  

  1   2   >