LibreOffice Module vcl (master)  1
qt5/QtFrame.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #pragma once
21 
22 #include <config_vclplug.h>
23 
24 #include <salframe.hxx>
25 #include <vclpluginapi.h>
26 
27 #include "QtTools.hxx"
28 
29 #include <headless/svpgdi.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/sysdata.hxx>
32 
33 #include <QtCore/QObject>
34 
35 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11
37 // any better way to get rid of the X11 / Qt type clashes?
38 #undef Bool
39 #undef CursorShape
40 #undef Expose
41 #undef KeyPress
42 #undef KeyRelease
43 #undef FocusIn
44 #undef FocusOut
45 #undef FontChange
46 #undef None
47 #undef Status
48 #undef Unsorted
49 #endif
50 
51 class QtDragSource;
52 class QtDropTarget;
53 class QtGraphics;
54 class QtInstance;
55 class QtMainWindow;
56 class QtMenu;
57 class QtSvpGraphics;
58 
59 class QDragMoveEvent;
60 class QDropEvent;
61 class QImage;
62 class QMimeData;
63 class QPaintDevice;
64 class QScreen;
65 class QWidget;
66 
67 class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public SalFrame
68 {
69  Q_OBJECT
70 
71  friend class QtWidget;
72 
73  QWidget* m_pQWidget;
75 
76  const bool m_bUseCairo;
77  std::unique_ptr<QImage> m_pQImage;
78  std::unique_ptr<QtGraphics> m_pQtGraphics;
80  std::unique_ptr<QtSvpGraphics> m_pSvpGraphics;
82  QRegion m_aRegion;
84 
89 
91 
94  bool m_bInDrag;
95 
100  sal_uInt32 m_nRestoreScreen;
102 
103 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11
104  ScreenSaverInhibitor m_ScreenSaverInhibitor;
105 #endif
106 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT5_USING_X11) \
107  || (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT6_USING_X11)
108  ModKeyFlags m_nKeyModifiers;
109 #endif
110 
112 
113  void SetDefaultPos();
114  Size CalcDefaultSize();
115  void SetDefaultSize();
116 
117  bool isChild(bool bPlug = true, bool bSysChild = true) const
118  {
120  if (bPlug)
121  nMask |= SalFrameStyleFlags::PLUG;
122  if (bSysChild)
124  return bool(m_nStyle & nMask);
125  }
126 
127  bool isWindow() const;
128  QWindow* windowHandle() const;
129  QScreen* screen() const;
130  bool isMinimized() const;
131  bool isMaximized() const;
132  void SetWindowStateImpl(Qt::WindowStates eState);
133 
134  void fixICCCMwindowGroup();
135  void modalReparent(bool bVisible);
136 
137 public:
138  QtFrame(QtFrame* pParent, SalFrameStyleFlags nSalFrameStyle, bool bUseCairo);
139  virtual ~QtFrame() override;
140 
141  QWidget* GetQWidget() const { return m_pQWidget; }
142  QtMainWindow* GetTopLevelWindow() const { return m_pTopLevel; }
143  QWidget* asChild() const;
144  qreal devicePixelRatioF() const;
145 
146  void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 nExtentsWidth,
147  sal_Int32 nExtentsHeight) const;
148 
149  virtual SalGraphics* AcquireGraphics() override;
150  virtual void ReleaseGraphics(SalGraphics* pGraphics) override;
151 
152  virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
153 
154  virtual void SetTitle(const OUString& rTitle) override;
155  virtual void SetIcon(sal_uInt16 nIcon) override;
156  virtual void SetMenu(SalMenu* pMenu) override;
157  virtual void DrawMenuBar() override;
158 
159  virtual void registerDragSource(QtDragSource* pDragSource);
160  virtual void deregisterDragSource(QtDragSource const* pDragSource);
161  virtual void registerDropTarget(QtDropTarget* pDropTarget);
162  virtual void deregisterDropTarget(QtDropTarget const* pDropTarget);
163 
164  void handleDragLeave();
165  void handleDragMove(QDragMoveEvent* pEvent);
166  void handleDrop(QDropEvent* pEvent);
167 
168  virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle) override;
169  virtual void Show(bool bVisible, bool bNoActivate = false) override;
170  virtual void SetMinClientSize(tools::Long nWidth, tools::Long nHeight) override;
171  virtual void SetMaxClientSize(tools::Long nWidth, tools::Long nHeight) override;
172  virtual void SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight,
173  sal_uInt16 nFlags) override;
174  virtual void GetClientSize(tools::Long& rWidth, tools::Long& rHeight) override;
175  virtual void GetWorkArea(tools::Rectangle& rRect) override;
176  virtual SalFrame* GetParent() const override;
177  virtual void SetModal(bool bModal) override;
178  virtual bool GetModal() const override;
179  virtual void SetWindowState(const SalFrameState* pState) override;
180  virtual bool GetWindowState(SalFrameState* pState) override;
181  virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay) override;
182  virtual void StartPresentation(bool bStart) override;
183  virtual void SetAlwaysOnTop(bool bOnTop) override;
184  virtual void ToTop(SalFrameToTop nFlags) override;
185  virtual void SetPointer(PointerStyle ePointerStyle) override;
186  virtual void CaptureMouse(bool bMouse) override;
187  virtual void SetPointerPos(tools::Long nX, tools::Long nY) override;
188  virtual bool ShowTooltip(const OUString& rText, const tools::Rectangle& rHelpArea) override;
189  using SalFrame::Flush;
190  virtual void Flush() override;
191  virtual void SetInputContext(SalInputContext* pContext) override;
192  virtual void EndExtTextInput(EndExtTextInputFlags nFlags) override;
193  virtual OUString GetKeyName(sal_uInt16 nKeyCode) override;
194  virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode, LanguageType aLangType,
195  vcl::KeyCode& rKeyCode) override;
196  virtual LanguageType GetInputLanguage() override;
197  virtual void UpdateSettings(AllSettings& rSettings) override;
198  virtual void Beep() override;
199  virtual const SystemEnvData* GetSystemData() const override { return &m_aSystemData; }
200  virtual SalPointerState GetPointerState() override;
201  virtual KeyIndicatorState GetIndicatorState() override;
202  virtual void SimulateKeyPress(sal_uInt16 nKeyCode) override;
203  virtual void SetParent(SalFrame* pNewParent) override;
204  virtual void SetPluginParent(SystemParentData* pNewParent) override;
205  virtual void ResetClipRegion() override;
206  virtual void BeginSetClipRegion(sal_uInt32 nRects) override;
207  virtual void UnionClipRegion(tools::Long nX, tools::Long nY, tools::Long nWidth,
208  tools::Long nHeight) override;
209  virtual void EndSetClipRegion() override;
210 
211  virtual void SetScreenNumber(unsigned int) override;
212  virtual void SetApplicationID(const OUString&) override;
213  virtual void ResolveWindowHandle(SystemEnvData& rData) const override;
214 
215  inline bool CallCallback(SalEvent nEvent, const void* pEvent) const;
216 
217  void setInputLanguage(LanguageType);
218  inline bool isPopup() const;
219  static void FillSystemEnvData(SystemEnvData&, sal_IntPtr pWindow, QWidget* pWidget);
220 };
221 
222 inline bool QtFrame::CallCallback(SalEvent nEvent, const void* pEvent) const
223 {
224  SolarMutexGuard aGuard;
225  return SalFrame::CallCallback(nEvent, pEvent);
226 }
227 
228 inline bool QtFrame::isPopup() const
229 {
232 }
233 
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SalFrame * GetParent() const =0
bool CallCallback(SalEvent nEvent, const void *pEvent) const
Definition: salframe.hxx:307
virtual void ReleaseGraphics(SalGraphics *pGraphics)=0
SystemEnvData m_aSystemData
Definition: qt5/QtFrame.hxx:90
QtMainWindow * m_pTopLevel
Definition: qt5/QtFrame.hxx:74
virtual void ResolveWindowHandle(SystemEnvData &) const
Definition: salframe.hxx:222
virtual void DrawMenuBar()=0
virtual const SystemEnvData * GetSystemData() const override
virtual void ToTop(SalFrameToTop nFlags)=0
bool m_bFullScreenSpanAll
Definition: qt5/QtFrame.hxx:99
virtual void SetMaxClientSize(tools::Long nWidth, tools::Long nHeight)=0
#define VCLPLUG_QT_PUBLIC
Definition: vclpluginapi.h:53
bool m_bNullRegion
Definition: qt5/QtFrame.hxx:83
long Long
std::unique_ptr< QImage > m_pQImage
Definition: qt5/QtFrame.hxx:77
ModKeyFlags
Definition: keycodes.hxx:163
virtual void SetTitle(const OUString &rTitle)=0
bool m_bDefaultSize
Definition: qt5/QtFrame.hxx:96
QtDropTarget * m_pDropTarget
Definition: qt5/QtFrame.hxx:93
QtFrame * m_pParent
Definition: qt5/QtFrame.hxx:87
virtual void BeginSetClipRegion(sal_uInt32 nRects)=0
virtual void Show(bool bVisible, bool bNoActivate=false)=0
QRegion m_aRegion
Definition: qt5/QtFrame.hxx:82
virtual bool GetWindowState(SalFrameState *pState)=0
sal_uInt16 sal_Unicode
virtual void Beep()=0
virtual void GetWorkArea(tools::Rectangle &rRect)=0
virtual void SetIcon(sal_uInt16 nIcon)=0
virtual void EndExtTextInput(EndExtTextInputFlags nFlags)=0
const bool m_bUseCairo
Definition: qt5/QtFrame.hxx:76
bool m_bDefaultPos
Definition: qt5/QtFrame.hxx:97
sal_uInt64 SalExtStyle
Definition: salframe.hxx:97
bool isPopup() const
virtual void SetPointerPos(tools::Long nX, tools::Long nY)=0
virtual SalPointerState GetPointerState()=0
virtual void CaptureMouse(bool bMouse)=0
QtMainWindow * GetTopLevelWindow() const
SalFrameToTop
Definition: salframe.hxx:43
PointerStyle m_ePointerStyle
Definition: qt5/QtFrame.hxx:88
std::unique_ptr< QtGraphics > m_pQtGraphics
Definition: qt5/QtFrame.hxx:78
QWidget * m_pQWidget
Definition: qt5/QtFrame.hxx:73
virtual void SetInputContext(SalInputContext *pContext)=0
virtual void GetClientSize(tools::Long &rWidth, tools::Long &rHeight)=0
virtual void SetPointer(PointerStyle ePointerStyle)=0
LanguageType m_nInputLanguage
virtual void SetParent(SalFrame *pNewParent)=0
virtual void SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags)=0
bool m_bGraphicsInUse
Definition: qt5/QtFrame.hxx:85
virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle)=0
virtual bool PostEvent(std::unique_ptr< ImplSVEvent > pData)=0
std::unique_ptr< cairo_surface_t, CairoDeleter > UniqueCairoSurface
sal_uInt32 m_nRestoreScreen
DamageHandler m_aDamageHandler
Definition: qt5/QtFrame.hxx:81
virtual void EndSetClipRegion()=0
KeyIndicatorState
Definition: keycodes.hxx:184
bool isChild(bool bPlug=true, bool bSysChild=true) const
virtual LanguageType GetInputLanguage()=0
EndExtTextInputFlags
Definition: window.hxx:344
QWidget * GetQWidget() const
virtual void SetMinClientSize(tools::Long nWidth, tools::Long nHeight)=0
QtDragSource * m_pDragSource
Definition: qt5/QtFrame.hxx:92
virtual void UpdateSettings(AllSettings &rSettings)=0
bool m_bFullScreen
Definition: qt5/QtFrame.hxx:98
virtual void Flush()=0
virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay)=0
virtual void SetWindowState(const SalFrameState *pState)=0
SalEvent
Definition: salwtype.hxx:41
virtual void SetScreenNumber(unsigned int nScreen)=0
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:114
virtual void SetApplicationID(const OUString &rApplicationID)=0
virtual void SetModal(bool)
Definition: salframe.hxx:259
SalFrameStyleFlags m_nStyle
Definition: qt5/QtFrame.hxx:86
virtual void SetPluginParent(SystemParentData *pNewParent)=0
virtual KeyIndicatorState GetIndicatorState()=0
QRect m_aRestoreGeometry
SalFrameStyleFlags
Definition: salframe.hxx:64
virtual void SimulateKeyPress(sal_uInt16 nKeyCode)=0
virtual void StartPresentation(bool bStart)=0
std::unique_ptr< QtSvpGraphics > m_pSvpGraphics
Definition: qt5/QtFrame.hxx:80
bool CallCallback(SalEvent nEvent, const void *pEvent) const
virtual void UnionClipRegion(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight)=0
virtual SalGraphics * AcquireGraphics()=0
UniqueCairoSurface m_pSurface
Definition: qt5/QtFrame.hxx:79
PointerStyle
Definition: ptrstyle.hxx:25
virtual bool ShowTooltip(const OUString &, const tools::Rectangle &)
Definition: salframe.hxx:269
virtual void ResetClipRegion()=0
virtual OUString GetKeyName(sal_uInt16 nKeyCode)=0
virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode &rKeyCode)=0
virtual void SetAlwaysOnTop(bool bOnTop)=0
virtual void SetMenu(SalMenu *pSalMenu)=0
bool m_bInDrag
Definition: qt5/QtFrame.hxx:94
virtual bool GetModal() const
Definition: salframe.hxx:263