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 .
20 #include <vcl/window.hxx>
21 #include <vcl/sysdata.hxx>
22 #include <vcl/svapp.hxx>
23 #include <vcl/syschild.hxx>
26 #include <salinst.hxx>
30 using namespace ::com::sun::star
;
32 static void ImplSysChildProc( SystemChildWindow
* pInst
, SalObjEvent nEvent
)
34 VclPtr
<SystemChildWindow
> pWindow
= pInst
;
38 case SalObjEvent::GetFocus
:
39 // get focus, such that all handlers are called,
40 // as if this window gets the focus assuring
41 // that the frame does not steal it
42 pWindow
->ImplGetFrameData()->mbSysObjFocus
= true;
43 pWindow
->ImplGetFrameData()->mbInSysObjToTopHdl
= true;
44 pWindow
->ToTop( ToTopFlags::NoGrabFocus
);
45 if( pWindow
->IsDisposed() )
47 pWindow
->ImplGetFrameData()->mbInSysObjToTopHdl
= false;
48 pWindow
->ImplGetFrameData()->mbInSysObjFocusHdl
= true;
50 if( pWindow
->IsDisposed() )
52 pWindow
->ImplGetFrameData()->mbInSysObjFocusHdl
= false;
55 case SalObjEvent::LoseFocus
:
56 // trigger a LoseFocus which matches the status
57 // of the window with matching Activate-Status
58 if (pWindow
->IsDisposed())
60 pWindow
->ImplGetFrameData()->mbSysObjFocus
= false;
61 if ( !pWindow
->ImplGetFrameData()->mnFocusId
)
63 pWindow
->ImplGetFrameData()->mbStartFocusState
= true;
64 pWindow
->ImplGetFrameData()->mnFocusId
= Application::PostUserEvent( LINK( pWindow
->ImplGetFrameWindow(), vcl::Window
, ImplAsyncFocusHdl
), nullptr, true );
68 case SalObjEvent::ToTop
:
69 pWindow
->ImplGetFrameData()->mbInSysObjToTopHdl
= true;
70 if ( !Application::GetFocusWindow() || pWindow
->HasChildPathFocus() )
71 pWindow
->ToTop( ToTopFlags::NoGrabFocus
);
74 if( pWindow
->IsDisposed() )
77 if( pWindow
->IsDisposed() )
79 pWindow
->ImplGetFrameData()->mbInSysObjToTopHdl
= false;
86 void SystemChildWindow::ImplInitSysChild( vcl::Window
* pParent
, WinBits nStyle
, SystemWindowData
*pData
, bool bShow
)
88 mpWindowImpl
->mpSysObj
= ImplGetSVData()->mpDefInst
->CreateObject( pParent
->ImplGetFrame(), pData
, bShow
);
90 Window::ImplInit( pParent
, nStyle
, nullptr );
92 // we do not paint if it is the right SysChild
93 if ( GetSystemData() )
95 mpWindowImpl
->mpSysObj
->SetCallback( this, ImplSysChildProc
);
96 SetParentClipMode( ParentClipMode::Clip
);
101 SystemChildWindow::SystemChildWindow( vcl::Window
* pParent
, WinBits nStyle
) :
102 Window( WindowType::SYSTEMCHILDWINDOW
)
104 ImplInitSysChild( pParent
, nStyle
, nullptr );
107 SystemChildWindow::SystemChildWindow( vcl::Window
* pParent
, WinBits nStyle
, SystemWindowData
*pData
, bool bShow
) :
108 Window( WindowType::SYSTEMCHILDWINDOW
)
110 ImplInitSysChild( pParent
, nStyle
, pData
, bShow
);
113 SystemChildWindow::~SystemChildWindow()
118 void SystemChildWindow::dispose()
121 if ( mpWindowImpl
&& mpWindowImpl
->mpSysObj
)
123 ImplGetSVData()->mpDefInst
->DestroyObject( mpWindowImpl
->mpSysObj
);
124 mpWindowImpl
->mpSysObj
= nullptr;
129 const SystemEnvData
* SystemChildWindow::GetSystemData() const
131 if ( mpWindowImpl
->mpSysObj
)
132 return mpWindowImpl
->mpSysObj
->GetSystemData();
137 void SystemChildWindow::EnableEraseBackground( bool bEnable
)
139 if ( mpWindowImpl
->mpSysObj
)
140 mpWindowImpl
->mpSysObj
->EnableEraseBackground( bEnable
);
143 void SystemChildWindow::SetLeaveEnterBackgrounds(const css::uno::Sequence
<css::uno::Any
>& rLeaveArgs
, const css::uno::Sequence
<css::uno::Any
>& rEnterArgs
)
145 if (mpWindowImpl
->mpSysObj
)
146 mpWindowImpl
->mpSysObj
->SetLeaveEnterBackgrounds(rLeaveArgs
, rEnterArgs
);
149 void SystemChildWindow::SetForwardKey( bool bEnable
)
151 if ( mpWindowImpl
->mpSysObj
)
152 mpWindowImpl
->mpSysObj
->SetForwardKey( bEnable
);
155 sal_IntPtr
SystemChildWindow::GetParentWindowHandle() const
160 nRet
= reinterpret_cast< sal_IntPtr
>( GetSystemData()->hWnd
);
162 // FIXME: this is wrong
163 nRet
= reinterpret_cast< sal_IntPtr
>( GetSystemData()->mpNSView
);
164 #elif defined ANDROID
169 nRet
= GetSystemData()->aWindow
;
175 void* SystemChildWindow::CreateGStreamerSink()
177 return ImplGetSVData()->mpDefInst
->CreateGStreamerSink(this);
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */