LibreOffice Module vcl (master) 1
syschild.cxx
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#include <vcl/window.hxx>
21#include <vcl/sysdata.hxx>
22#include <vcl/svapp.hxx>
23#include <vcl/syschild.hxx>
24
25#include <window.h>
26#include <salframe.hxx>
27#include <salinst.hxx>
28#include <salobj.hxx>
29#include <svdata.hxx>
30
31using namespace ::com::sun::star;
32
33static void ImplSysChildProc( SystemChildWindow* pInst, SalObjEvent nEvent )
34{
35 VclPtr<SystemChildWindow> pWindow = pInst;
36
37 switch ( nEvent )
38 {
40 // get focus, such that all handlers are called,
41 // as if this window gets the focus assuring
42 // that the frame does not steal it
43 pWindow->ImplGetFrameData()->mbSysObjFocus = true;
44 pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = true;
46 if( pWindow->isDisposed() )
47 break;
48 pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = false;
49 pWindow->ImplGetFrameData()->mbInSysObjFocusHdl = true;
50 pWindow->GrabFocus();
51 if( pWindow->isDisposed() )
52 break;
53 pWindow->ImplGetFrameData()->mbInSysObjFocusHdl = false;
54 break;
55
57 // trigger a LoseFocus which matches the status
58 // of the window with matching Activate-Status
59 if (pWindow->isDisposed())
60 break;
61 pWindow->ImplGetFrameData()->mbSysObjFocus = false;
62 if ( !pWindow->ImplGetFrameData()->mnFocusId )
63 {
64 pWindow->ImplGetFrameData()->mbStartFocusState = true;
65 pWindow->ImplGetFrameData()->mnFocusId = Application::PostUserEvent( LINK( pWindow->ImplGetFrameWindow(), vcl::Window, ImplAsyncFocusHdl ), nullptr, true );
66 }
67 break;
68
70 pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = true;
73 else
74 pWindow->ToTop();
75 if( pWindow->isDisposed() )
76 break;
77 pWindow->GrabFocus();
78 if( pWindow->isDisposed() )
79 break;
80 pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = false;
81 break;
82
83 default: break;
84 }
85}
86
87void SystemChildWindow::ImplInitSysChild( vcl::Window* pParent, WinBits nStyle, SystemWindowData *pData, bool bShow )
88{
89 mpWindowImpl->mpSysObj = ImplGetSVData()->mpDefInst->CreateObject( pParent->ImplGetFrame(), pData, bShow );
90
91 Window::ImplInit( pParent, nStyle, nullptr );
92
93 // we do not paint if it is the right SysChild
94 if ( GetSystemData() )
95 {
96 mpWindowImpl->mpSysObj->SetCallback( this, ImplSysChildProc );
99 }
100}
101
104{
105 ImplInitSysChild( pParent, nStyle, nullptr );
106}
107
110{
111 ImplInitSysChild( pParent, nStyle, pData, bShow );
112}
113
115{
116 disposeOnce();
117}
118
120{
121 Hide();
122 if ( mpWindowImpl && mpWindowImpl->mpSysObj )
123 {
125 mpWindowImpl->mpSysObj = nullptr;
126 }
127 Window::dispose();
128}
129
131{
132 if ( mpWindowImpl->mpSysObj )
133 return mpWindowImpl->mpSysObj->GetSystemData();
134 else
135 return nullptr;
136}
137
139{
140 if ( mpWindowImpl->mpSysObj )
141 mpWindowImpl->mpSysObj->EnableEraseBackground( bEnable );
142}
143
145{
146 if (mpWindowImpl->mpSysObj)
147 return mpWindowImpl->mpSysObj->GetOptimalSize();
149}
150
151void SystemChildWindow::SetLeaveEnterBackgrounds(const css::uno::Sequence<css::uno::Any>& rLeaveArgs, const css::uno::Sequence<css::uno::Any>& rEnterArgs)
152{
153 if (mpWindowImpl->mpSysObj)
154 mpWindowImpl->mpSysObj->SetLeaveEnterBackgrounds(rLeaveArgs, rEnterArgs);
155}
156
158{
159 if ( mpWindowImpl->mpSysObj )
160 mpWindowImpl->mpSysObj->SetForwardKey( bEnable );
161}
162
164{
165 sal_IntPtr nRet = 0;
166
167#if defined(_WIN32)
168 nRet = reinterpret_cast< sal_IntPtr >( GetSystemData()->hWnd );
169#elif defined MACOSX
170 // FIXME: this is wrong
171 nRet = reinterpret_cast< sal_IntPtr >( GetSystemData()->mpNSView );
172#elif defined ANDROID
173 // Nothing
174#elif defined IOS
175 // Nothing
176#elif defined UNX
178#endif
179
180 return nRet;
181}
182
184{
186}
187
188#if defined( MACOSX )
189#elif defined( ANDROID )
190#elif defined( IOS )
191#elif defined( UNX )
192sal_uIntPtr SystemEnvData::GetWindowHandle(const SalFrame* pReference) const
193{
194 if (!aWindow && pReference)
195 pReference->ResolveWindowHandle(const_cast<SystemEnvData&>(*this));
196 return aWindow;
197}
198#endif
199
200/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
Post a user event to the default window.
Definition: svapp.cxx:1122
static vcl::Window * GetFocusWindow()
Get the currently focused window.
Definition: svapp.cxx:1161
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:115
virtual void ResolveWindowHandle(SystemEnvData &) const
Definition: salframe.hxx:220
virtual SalObject * CreateObject(SalFrame *pParent, SystemWindowData *pWindowData, bool bShow)=0
virtual void DestroyObject(SalObject *pObject)=0
virtual void * CreateGStreamerSink(const SystemChildWindow *)
Definition: salinst.hxx:211
SystemChildWindow(const SystemChildWindow &)=delete
void SetLeaveEnterBackgrounds(const css::uno::Sequence< css::uno::Any > &rLeaveArgs, const css::uno::Sequence< css::uno::Any > &rEnterArgs)
Definition: syschild.cxx:151
sal_IntPtr GetParentWindowHandle() const
Definition: syschild.cxx:163
void * CreateGStreamerSink()
Definition: syschild.cxx:183
SAL_DLLPRIVATE void ImplInitSysChild(vcl::Window *pParent, WinBits nStyle, SystemWindowData *pData, bool bShow=false)
Definition: syschild.cxx:87
virtual ~SystemChildWindow() override
Definition: syschild.cxx:114
virtual Size GetOptimalSize() const override
Definition: syschild.cxx:144
virtual const SystemEnvData * GetSystemData() const override
Definition: syschild.cxx:130
void SetForwardKey(bool bEnable)
Definition: syschild.cxx:157
void EnableEraseBackground(bool bEnable)
Definition: syschild.cxx:138
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: syschild.cxx:119
bool isDisposed() const
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:3011
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
void GrabFocus()
Definition: window.cxx:2983
void ToTop(ToTopFlags nFlags=ToTopFlags::NONE)
Definition: stacking.cxx:418
virtual Size GetOptimalSize() const
Definition: window3.cxx:26
void Hide()
Definition: window.hxx:885
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:484
SalFrame * ImplGetFrame() const
Definition: window2.cxx:874
SAL_DLLPRIVATE ImplFrameData * ImplGetFrameData()
Definition: window2.cxx:869
SAL_DLLPRIVATE vcl::Window * ImplGetFrameWindow() const
Definition: window2.cxx:932
void SetBackground()
Definition: window3.cxx:100
std::unique_ptr< sal_Int32[]> pData
SalObjEvent
Definition: salwtype.hxx:235
bool mbStartFocusState
Definition: window.h:167
bool mbInSysObjToTopHdl
Definition: window.h:169
bool mbInSysObjFocusHdl
Definition: window.h:168
ImplSVEvent * mnFocusId
Definition: window.h:145
bool mbSysObjFocus
Definition: window.h:170
SalInstance * mpDefInst
Definition: svdata.hxx:392
sal_uIntPtr aWindow
Definition: sysdata.hxx:77
sal_uIntPtr GetWindowHandle(const SalFrame *pReference) const
Definition: syschild.cxx:192
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:76
static void ImplSysChildProc(SystemChildWindow *pInst, SalObjEvent nEvent)
Definition: syschild.cxx:33
sal_Int64 WinBits
Definition: wintypes.hxx:109
WindowType
Definition: wintypes.hxx:27