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 <config_features.h>
22 #include <rtl/process.h>
23 #include <rtl/ref.hxx>
27 #include <vcl/window.hxx>
28 #include <vcl/sysdata.hxx>
29 #include <vcl/svapp.hxx>
30 #include <vcl/syschild.hxx>
33 #include <salinst.hxx>
34 #include <salframe.hxx>
42 #include <comphelper/processfactory.hxx>
45 #include <jvmaccess/virtualmachine.hxx>
46 #include <com/sun/star/java/JavaVirtualMachine.hpp>
47 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50 using namespace ::com::sun::star
;
52 long ImplSysChildProc( void* pInst
, SalObject
* /* pObject */,
53 SalObjEvent nEvent
, const void* /* pEvent */ )
55 VclPtr
<SystemChildWindow
> pWindow
= static_cast<SystemChildWindow
*>(pInst
);
60 case SalObjEvent::GetFocus
:
61 // get focus, such that all handlers are called,
62 // as if this window gets the focus assuring
63 // that the frame does not steal it
64 pWindow
->ImplGetFrameData()->mbSysObjFocus
= true;
65 pWindow
->ImplGetFrameData()->mbInSysObjToTopHdl
= true;
66 pWindow
->ToTop( ToTopFlags::NoGrabFocus
);
67 if( pWindow
->IsDisposed() )
69 pWindow
->ImplGetFrameData()->mbInSysObjToTopHdl
= false;
70 pWindow
->ImplGetFrameData()->mbInSysObjFocusHdl
= true;
72 if( pWindow
->IsDisposed() )
74 pWindow
->ImplGetFrameData()->mbInSysObjFocusHdl
= false;
77 case SalObjEvent::LoseFocus
:
78 // trigger a LoseFocus which matches the status
79 // of the window with matching Activate-Status
80 pWindow
->ImplGetFrameData()->mbSysObjFocus
= false;
81 if ( !pWindow
->ImplGetFrameData()->mnFocusId
)
83 pWindow
->ImplGetFrameData()->mbStartFocusState
= true;
84 pWindow
->ImplGetFrameData()->mnFocusId
= Application::PostUserEvent( LINK( pWindow
->ImplGetFrameWindow(), vcl::Window
, ImplAsyncFocusHdl
), nullptr, true );
88 case SalObjEvent::ToTop
:
89 pWindow
->ImplGetFrameData()->mbInSysObjToTopHdl
= true;
90 if ( !Application::GetFocusWindow() || pWindow
->HasChildPathFocus() )
91 pWindow
->ToTop( ToTopFlags::NoGrabFocus
);
94 if( pWindow
->IsDisposed() )
97 if( pWindow
->IsDisposed() )
99 pWindow
->ImplGetFrameData()->mbInSysObjToTopHdl
= false;
108 void SystemChildWindow::ImplInitSysChild( vcl::Window
* pParent
, WinBits nStyle
, SystemWindowData
*pData
, bool bShow
)
110 mpWindowImpl
->mpSysObj
= ImplGetSVData()->mpDefInst
->CreateObject( pParent
->ImplGetFrame(), pData
, bShow
);
112 Window::ImplInit( pParent
, nStyle
, nullptr );
114 // we do not paint if it is the right SysChild
115 if ( GetSystemData() )
117 mpWindowImpl
->mpSysObj
->SetCallback( this, ImplSysChildProc
);
118 SetParentClipMode( ParentClipMode::Clip
);
123 SystemChildWindow::SystemChildWindow( vcl::Window
* pParent
, WinBits nStyle
) :
124 Window( WINDOW_SYSTEMCHILDWINDOW
)
126 ImplInitSysChild( pParent
, nStyle
, nullptr );
129 SystemChildWindow::SystemChildWindow( vcl::Window
* pParent
, WinBits nStyle
, SystemWindowData
*pData
, bool bShow
) :
130 Window( WINDOW_SYSTEMCHILDWINDOW
)
132 ImplInitSysChild( pParent
, nStyle
, pData
, bShow
);
135 SystemChildWindow::~SystemChildWindow()
140 void SystemChildWindow::dispose()
143 if ( mpWindowImpl
&& mpWindowImpl
->mpSysObj
)
145 ImplGetSVData()->mpDefInst
->DestroyObject( mpWindowImpl
->mpSysObj
);
146 mpWindowImpl
->mpSysObj
= nullptr;
151 const SystemEnvData
* SystemChildWindow::GetSystemData() const
153 if ( mpWindowImpl
->mpSysObj
)
154 return mpWindowImpl
->mpSysObj
->GetSystemData();
159 void SystemChildWindow::EnableEraseBackground( bool bEnable
)
161 if ( mpWindowImpl
->mpSysObj
)
162 mpWindowImpl
->mpSysObj
->EnableEraseBackground( bEnable
);
165 void SystemChildWindow::SetLeaveEnterBackgrounds(const css::uno::Sequence
<css::uno::Any
>& rLeaveArgs
, const css::uno::Sequence
<css::uno::Any
>& rEnterArgs
)
167 if (mpWindowImpl
->mpSysObj
)
168 mpWindowImpl
->mpSysObj
->SetLeaveEnterBackgrounds(rLeaveArgs
, rEnterArgs
);
171 void SystemChildWindow::SetForwardKey( bool bEnable
)
173 if ( mpWindowImpl
->mpSysObj
)
174 mpWindowImpl
->mpSysObj
->SetForwardKey( bEnable
);
177 sal_IntPtr
SystemChildWindow::GetParentWindowHandle()
182 nRet
= reinterpret_cast< sal_IntPtr
>( GetSystemData()->hWnd
);
184 // FIXME: this is wrong
185 nRet
= reinterpret_cast< sal_IntPtr
>( GetSystemData()->mpNSView
);
186 #elif defined ANDROID
191 nRet
= (sal_IntPtr
) GetSystemData()->aWindow
;
197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */