1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <config_vclplug.h>
24 #include <salframe.hxx>
25 #include <vclpluginapi.h>
27 #include "QtTools.hxx"
28 #include "QtWidget.hxx"
30 #include <headless/svpgdi.hxx>
31 #include <vcl/svapp.hxx>
32 #include <vcl/sysdata.hxx>
34 #include <QtCore/QObject>
36 #if CHECK_ANY_QT_USING_X11
37 #include <unx/screensaverinhibitor.hxx>
38 // any better way to get rid of the X11 / Qt type clashes?
68 class VCLPLUG_QT_PUBLIC QtFrame
: public QObject
, public SalFrame
72 friend class QtWidget
;
75 QtMainWindow
* m_pTopLevel
;
77 const bool m_bUseCairo
;
78 std::unique_ptr
<QImage
> m_pQImage
;
79 std::unique_ptr
<QtGraphics
> m_pQtGraphics
;
80 UniqueCairoSurface m_pSurface
;
81 std::unique_ptr
<QtSvpGraphics
> m_pSvpGraphics
;
82 DamageHandler m_aDamageHandler
;
86 bool m_bGraphicsInUse
;
87 SalFrameStyleFlags m_nStyle
;
89 PointerStyle m_ePointerStyle
;
91 SystemEnvData m_aSystemData
;
93 QtDragSource
* m_pDragSource
;
94 QtDropTarget
* m_pDropTarget
;
100 bool m_bFullScreenSpanAll
;
101 sal_uInt32 m_nRestoreScreen
;
102 QRect m_aRestoreGeometry
;
104 #if CHECK_ANY_QT_USING_X11
105 ScreenSaverInhibitor m_ScreenSaverInhibitor
;
106 ModKeyFlags m_nKeyModifiers
;
109 LanguageType m_nInputLanguage
;
111 OUString m_aTooltipText
;
112 QRect m_aTooltipArea
;
114 void SetDefaultPos();
115 Size
CalcDefaultSize();
116 void SetDefaultSize();
118 bool isChild(bool bPlug
= true, bool bSysChild
= true) const
120 SalFrameStyleFlags nMask
= SalFrameStyleFlags::NONE
;
122 nMask
|= SalFrameStyleFlags::PLUG
;
124 nMask
|= SalFrameStyleFlags::SYSTEMCHILD
;
125 return bool(m_nStyle
& nMask
);
128 bool isWindow() const;
129 QWindow
* windowHandle() const;
130 QScreen
* screen() const;
131 bool isMinimized() const;
132 bool isMaximized() const;
133 void SetWindowStateImpl(Qt::WindowStates eState
);
134 int menuBarOffset() const;
136 void fixICCCMwindowGroup();
139 void screenChanged(QScreen
*);
142 QtFrame(QtFrame
* pParent
, SalFrameStyleFlags nSalFrameStyle
, bool bUseCairo
);
143 virtual ~QtFrame() override
;
145 QWidget
* GetQWidget() const { return m_pQWidget
; }
146 QtMainWindow
* GetTopLevelWindow() const { return m_pTopLevel
; }
147 QWidget
* asChild() const;
148 qreal
devicePixelRatioF() const;
150 void Damage(sal_Int32 nExtentsX
, sal_Int32 nExtentsY
, sal_Int32 nExtentsWidth
,
151 sal_Int32 nExtentsHeight
) const;
153 virtual SalGraphics
* AcquireGraphics() override
;
154 virtual void ReleaseGraphics(SalGraphics
* pGraphics
) override
;
156 virtual bool PostEvent(std::unique_ptr
<ImplSVEvent
> pData
) override
;
158 virtual void SetTitle(const OUString
& rTitle
) override
;
159 virtual void SetIcon(sal_uInt16 nIcon
) override
;
160 virtual void SetMenu(SalMenu
* pMenu
) override
;
162 virtual void registerDragSource(QtDragSource
* pDragSource
);
163 virtual void deregisterDragSource(QtDragSource
const* pDragSource
);
164 virtual void registerDropTarget(QtDropTarget
* pDropTarget
);
165 virtual void deregisterDropTarget(QtDropTarget
const* pDropTarget
);
167 void handleDragLeave();
168 void handleDragMove(QDragMoveEvent
* pEvent
);
169 void handleDrop(QDropEvent
* pEvent
);
171 virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle
) override
;
172 virtual void Show(bool bVisible
, bool bNoActivate
= false) override
;
173 virtual void SetMinClientSize(tools::Long nWidth
, tools::Long nHeight
) override
;
174 virtual void SetMaxClientSize(tools::Long nWidth
, tools::Long nHeight
) override
;
175 virtual void SetPosSize(tools::Long nX
, tools::Long nY
, tools::Long nWidth
, tools::Long nHeight
,
176 sal_uInt16 nFlags
) override
;
177 virtual void GetClientSize(tools::Long
& rWidth
, tools::Long
& rHeight
) override
;
178 virtual void GetWorkArea(tools::Rectangle
& rRect
) override
;
179 virtual SalFrame
* GetParent() const override
;
180 virtual void SetModal(bool bModal
) override
;
181 virtual bool GetModal() const override
;
182 virtual void SetWindowState(const vcl::WindowData
*) override
;
183 virtual bool GetWindowState(vcl::WindowData
*) override
;
184 virtual void ShowFullScreen(bool bFullScreen
, sal_Int32 nDisplay
) override
;
185 virtual void StartPresentation(bool bStart
) override
;
186 virtual void SetAlwaysOnTop(bool bOnTop
) override
;
187 virtual void ToTop(SalFrameToTop nFlags
) override
;
188 virtual void SetPointer(PointerStyle ePointerStyle
) override
;
189 virtual void CaptureMouse(bool bMouse
) override
;
190 virtual void SetPointerPos(tools::Long nX
, tools::Long nY
) override
;
191 virtual bool ShowTooltip(const OUString
& rText
, const tools::Rectangle
& rHelpArea
) override
;
192 using SalFrame::Flush
;
193 virtual void Flush() override
;
194 virtual void SetInputContext(SalInputContext
* pContext
) override
;
195 virtual void EndExtTextInput(EndExtTextInputFlags nFlags
) override
;
196 virtual OUString
GetKeyName(sal_uInt16 nKeyCode
) override
;
197 virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode
, LanguageType aLangType
,
198 vcl::KeyCode
& rKeyCode
) override
;
199 virtual LanguageType
GetInputLanguage() override
;
200 virtual void UpdateSettings(AllSettings
& rSettings
) override
;
201 virtual void Beep() override
;
202 virtual const SystemEnvData
* GetSystemData() const override
{ return &m_aSystemData
; }
203 virtual SalPointerState
GetPointerState() override
;
204 virtual KeyIndicatorState
GetIndicatorState() override
;
205 virtual void SimulateKeyPress(sal_uInt16 nKeyCode
) override
;
206 virtual void SetParent(SalFrame
* pNewParent
) override
;
207 virtual void SetPluginParent(SystemParentData
* pNewParent
) override
;
208 virtual void ResetClipRegion() override
;
209 virtual void BeginSetClipRegion(sal_uInt32 nRects
) override
;
210 virtual void UnionClipRegion(tools::Long nX
, tools::Long nY
, tools::Long nWidth
,
211 tools::Long nHeight
) override
;
212 virtual void EndSetClipRegion() override
;
214 virtual void SetScreenNumber(unsigned int) override
;
215 virtual void SetApplicationID(const OUString
&) override
;
216 virtual void ResolveWindowHandle(SystemEnvData
& rData
) const override
;
218 inline bool CallCallback(SalEvent nEvent
, const void* pEvent
) const;
220 void setInputLanguage(LanguageType
);
221 inline bool isPopup() const;
222 static void FillSystemEnvData(SystemEnvData
&, sal_IntPtr pWindow
, QWidget
* pWidget
);
225 inline bool QtFrame::CallCallback(SalEvent nEvent
, const void* pEvent
) const
227 SolarMutexGuard aGuard
;
228 return SalFrame::CallCallback(nEvent
, pEvent
);
231 inline bool QtFrame::isPopup() const
233 return ((m_nStyle
& SalFrameStyleFlags::FLOAT
)
234 && !(m_nStyle
& SalFrameStyleFlags::OWNERDRAWDECORATION
));
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */