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 "Qt5Tools.hxx"
29 #include <headless/svpgdi.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/sysdata.hxx>
33 #include <QtCore/QObject>
36 #include <unx/screensaverinhibitor.hxx>
37 // any better way to get rid of the X11 / Qt type clashes?
67 class VCLPLUG_QT5_PUBLIC Qt5Frame
: public QObject
, public SalFrame
71 friend class Qt5Widget
;
74 Qt5MainWindow
* m_pTopLevel
;
76 const bool m_bUseCairo
;
77 std::unique_ptr
<QImage
> m_pQImage
;
78 std::unique_ptr
<Qt5Graphics
> m_pQt5Graphics
;
79 UniqueCairoSurface m_pSurface
;
80 std::unique_ptr
<Qt5SvpGraphics
> m_pOurSvpGraphics
;
81 // in base class, this ptr is the same as m_pOurSvpGraphic
82 // in derived class, it can point to a derivative
83 // of Qt5SvpGraphics (which the derived class then owns)
84 Qt5SvpGraphics
* m_pSvpGraphics
;
85 DamageHandler m_aDamageHandler
;
89 bool m_bGraphicsInUse
;
90 bool m_bGraphicsInvalid
;
91 SalFrameStyleFlags m_nStyle
;
93 PointerStyle m_ePointerStyle
;
95 SystemEnvData m_aSystemData
;
99 Qt5DragSource
* m_pDragSource
;
100 Qt5DropTarget
* m_pDropTarget
;
106 bool m_bFullScreenSpanAll
;
107 sal_uInt32 m_nRestoreScreen
;
108 QRect m_aRestoreGeometry
;
111 ScreenSaverInhibitor m_ScreenSaverInhibitor
;
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
);
135 void TriggerPaintEvent();
136 void TriggerPaintEvent(QRect aRect
);
137 void fixICCCMwindowGroup();
140 Qt5Frame(Qt5Frame
* pParent
, SalFrameStyleFlags nSalFrameStyle
, bool bUseCairo
);
141 virtual ~Qt5Frame() override
;
143 QWidget
* GetQWidget() const { return m_pQWidget
; }
144 Qt5MainWindow
* GetTopLevelWindow() const { return m_pTopLevel
; }
145 QWidget
* asChild() const;
147 void Damage(sal_Int32 nExtentsX
, sal_Int32 nExtentsY
, sal_Int32 nExtentsWidth
,
148 sal_Int32 nExtentsHeight
) const;
150 void InitQt5SvpGraphics(Qt5SvpGraphics
* pQt5SvpGraphics
);
151 virtual SalGraphics
* AcquireGraphics() override
;
152 virtual void ReleaseGraphics(SalGraphics
* pGraphics
) override
;
154 virtual bool PostEvent(std::unique_ptr
<ImplSVEvent
> pData
) override
;
156 virtual void SetTitle(const OUString
& rTitle
) override
;
157 virtual void SetIcon(sal_uInt16 nIcon
) override
;
158 virtual void SetMenu(SalMenu
* pMenu
) override
;
159 virtual void DrawMenuBar() override
;
161 virtual void registerDragSource(Qt5DragSource
* pDragSource
);
162 virtual void deregisterDragSource(Qt5DragSource
const* pDragSource
);
163 virtual void registerDropTarget(Qt5DropTarget
* pDropTarget
);
164 virtual void deregisterDropTarget(Qt5DropTarget
const* pDropTarget
);
166 void handleDragLeave();
167 void handleDragMove(QDragMoveEvent
* pEvent
);
168 void handleDrop(QDropEvent
* pEvent
);
170 virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle
) override
;
171 virtual void Show(bool bVisible
, bool bNoActivate
= false) override
;
172 virtual void SetMinClientSize(long nWidth
, long nHeight
) override
;
173 virtual void SetMaxClientSize(long nWidth
, long nHeight
) override
;
174 virtual void SetPosSize(long nX
, long nY
, long nWidth
, long nHeight
,
175 sal_uInt16 nFlags
) override
;
176 virtual void GetClientSize(long& rWidth
, long& rHeight
) override
;
177 virtual void GetWorkArea(tools::Rectangle
& rRect
) override
;
178 virtual SalFrame
* GetParent() const override
;
179 virtual void SetModal(bool bModal
) override
;
180 virtual bool GetModal() const override
;
181 virtual void SetWindowState(const SalFrameState
* pState
) override
;
182 virtual bool GetWindowState(SalFrameState
* pState
) override
;
183 virtual void ShowFullScreen(bool bFullScreen
, sal_Int32 nDisplay
) override
;
184 virtual void StartPresentation(bool bStart
) override
;
185 virtual void SetAlwaysOnTop(bool bOnTop
) override
;
186 virtual void ToTop(SalFrameToTop nFlags
) override
;
187 virtual void SetPointer(PointerStyle ePointerStyle
) override
;
188 virtual void CaptureMouse(bool bMouse
) override
;
189 virtual void SetPointerPos(long nX
, long nY
) override
;
190 virtual bool ShowTooltip(const OUString
& rText
, const tools::Rectangle
& rHelpArea
) override
;
191 using SalFrame::Flush
;
192 virtual void Flush() override
;
193 virtual void SetInputContext(SalInputContext
* pContext
) override
;
194 virtual void EndExtTextInput(EndExtTextInputFlags nFlags
) override
;
195 virtual OUString
GetKeyName(sal_uInt16 nKeyCode
) override
;
196 virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode
, LanguageType aLangType
,
197 vcl::KeyCode
& rKeyCode
) override
;
198 virtual LanguageType
GetInputLanguage() override
;
199 virtual void UpdateSettings(AllSettings
& rSettings
) override
;
200 virtual void Beep() override
;
201 virtual const SystemEnvData
* GetSystemData() const override
{ return &m_aSystemData
; }
202 virtual SalPointerState
GetPointerState() override
;
203 virtual KeyIndicatorState
GetIndicatorState() override
;
204 virtual void SimulateKeyPress(sal_uInt16 nKeyCode
) override
;
205 virtual void SetParent(SalFrame
* pNewParent
) override
;
206 virtual bool SetPluginParent(SystemParentData
* pNewParent
) override
;
207 virtual void ResetClipRegion() override
;
208 virtual void BeginSetClipRegion(sal_uInt32 nRects
) override
;
209 virtual void UnionClipRegion(long nX
, long nY
, long nWidth
, long nHeight
) override
;
210 virtual void EndSetClipRegion() override
;
212 virtual void SetScreenNumber(unsigned int) override
;
213 virtual void SetApplicationID(const OUString
&) override
;
215 inline bool CallCallback(SalEvent nEvent
, const void* pEvent
) const;
217 cairo_t
* getCairoContext() const;
220 inline bool Qt5Frame::CallCallback(SalEvent nEvent
, const void* pEvent
) const
222 SolarMutexGuard aGuard
;
223 return SalFrame::CallCallback(nEvent
, pEvent
);
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */