bump product version to 6.4.0.3
[LibreOffice.git] / vcl / source / window / syschild.cxx
blob2ba10a2bcc757bb3e0d7fb955066127c3d20a15e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
25 #include <window.h>
26 #include <salinst.hxx>
27 #include <salobj.hxx>
28 #include <svdata.hxx>
30 using namespace ::com::sun::star;
32 static void ImplSysChildProc( SystemChildWindow* pInst, SalObjEvent nEvent )
34 VclPtr<SystemChildWindow> pWindow = pInst;
36 switch ( nEvent )
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() )
46 break;
47 pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = false;
48 pWindow->ImplGetFrameData()->mbInSysObjFocusHdl = true;
49 pWindow->GrabFocus();
50 if( pWindow->IsDisposed() )
51 break;
52 pWindow->ImplGetFrameData()->mbInSysObjFocusHdl = false;
53 break;
55 case SalObjEvent::LoseFocus:
56 // trigger a LoseFocus which matches the status
57 // of the window with matching Activate-Status
58 if (pWindow->IsDisposed())
59 break;
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 );
66 break;
68 case SalObjEvent::ToTop:
69 pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = true;
70 if ( !Application::GetFocusWindow() || pWindow->HasChildPathFocus() )
71 pWindow->ToTop( ToTopFlags::NoGrabFocus );
72 else
73 pWindow->ToTop();
74 if( pWindow->IsDisposed() )
75 break;
76 pWindow->GrabFocus();
77 if( pWindow->IsDisposed() )
78 break;
79 pWindow->ImplGetFrameData()->mbInSysObjToTopHdl = false;
80 break;
82 default: break;
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 );
97 SetBackground();
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()
115 disposeOnce();
118 void SystemChildWindow::dispose()
120 Hide();
121 if ( mpWindowImpl && mpWindowImpl->mpSysObj )
123 ImplGetSVData()->mpDefInst->DestroyObject( mpWindowImpl->mpSysObj );
124 mpWindowImpl->mpSysObj = nullptr;
126 Window::dispose();
129 const SystemEnvData* SystemChildWindow::GetSystemData() const
131 if ( mpWindowImpl->mpSysObj )
132 return mpWindowImpl->mpSysObj->GetSystemData();
133 else
134 return nullptr;
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
157 sal_IntPtr nRet = 0;
159 #if defined(_WIN32)
160 nRet = reinterpret_cast< sal_IntPtr >( GetSystemData()->hWnd );
161 #elif defined MACOSX
162 // FIXME: this is wrong
163 nRet = reinterpret_cast< sal_IntPtr >( GetSystemData()->mpNSView );
164 #elif defined ANDROID
165 // Nothing
166 #elif defined IOS
167 // Nothing
168 #elif defined UNX
169 nRet = GetSystemData()->aWindow;
170 #endif
172 return nRet;
175 void* SystemChildWindow::CreateGStreamerSink()
177 return ImplGetSVData()->mpDefInst->CreateGStreamerSink(this);
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */