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 .
21 #include <sal/log.hxx>
22 #include <vcl/svapp.hxx>
23 #include <vcl/wrkwin.hxx>
24 // declare system types in sysdata.hxx
25 #include <vcl/sysdata.hxx>
26 #include <com/sun/star/lang/XComponent.hpp>
27 #include <com/sun/star/rendering/XCanvas.hpp>
30 #include <salframe.hxx>
34 void WorkWindow::ImplInitWorkWindowData()
36 mnIcon
= 0; // Should be removed in the next top level update - now in SystemWindow
38 mnPresentationFlags
= PresentationFlags::NONE
;
39 mbPresentationMode
= false;
40 mbPresentationVisible
= false;
41 mbPresentationFull
= false;
42 mbFullScreenMode
= false;
44 maLayoutIdle
.SetDebugName( "vcl::WorkWindow maLayoutIdle" );
47 void WorkWindow::ImplInit( vcl::Window
* pParent
, WinBits nStyle
, SystemParentData
* pSystemParentData
)
49 BorderWindowStyle nFrameStyle
= BorderWindowStyle::Frame
;
50 if ( nStyle
& WB_APP
)
51 nFrameStyle
|= BorderWindowStyle::App
;
53 VclPtrInstance
<ImplBorderWindow
> pBorderWin( pParent
, pSystemParentData
, nStyle
, nFrameStyle
);
54 Window::ImplInit( pBorderWin
, nStyle
& (WB_3DLOOK
| WB_CLIPCHILDREN
| WB_DIALOGCONTROL
| WB_SYSTEMFLOATWIN
), nullptr );
55 pBorderWin
->mpWindowImpl
->mpClientWindow
= this;
56 pBorderWin
->GetBorder( mpWindowImpl
->mnLeftBorder
, mpWindowImpl
->mnTopBorder
, mpWindowImpl
->mnRightBorder
, mpWindowImpl
->mnBottomBorder
);
57 mpWindowImpl
->mpBorderWindow
= pBorderWin
;
59 // mpWindowImpl->mpRealParent = pParent; // should actually be set, but is not set due to errors with the menubar!!
61 if ( nStyle
& WB_APP
)
63 ImplSVData
* pSVData
= ImplGetSVData();
64 SAL_WARN_IF(pSVData
->maFrameData
.mpAppWin
, "vcl",
65 "WorkWindow::WorkWindow(): More than one window with style WB_APP");
66 pSVData
->maFrameData
.mpAppWin
= this;
69 SetActivateMode( ActivateModeFlags::GrabFocus
);
72 void WorkWindow::ImplInit( vcl::Window
* pParent
, WinBits nStyle
, const css::uno::Any
& aSystemWorkWindowToken
)
74 if( aSystemWorkWindowToken
.hasValue() )
76 css::uno::Sequence
< sal_Int8
> aSeq
;
77 aSystemWorkWindowToken
>>= aSeq
;
78 SystemParentData
* pData
= reinterpret_cast<SystemParentData
*>(aSeq
.getArray());
79 SAL_WARN_IF( aSeq
.getLength() != sizeof( SystemParentData
) || pData
->nSize
!= sizeof( SystemParentData
), "vcl", "WorkWindow::WorkWindow( vcl::Window*, const Any&, WinBits ) called with invalid Any" );
80 // init with style 0 as does WorkWindow::WorkWindow( SystemParentData* );
81 ImplInit( pParent
, 0, pData
);
84 ImplInit( pParent
, nStyle
);
87 WorkWindow::WorkWindow( WindowType nType
) :
90 ImplInitWorkWindowData();
93 WorkWindow::WorkWindow( vcl::Window
* pParent
, WinBits nStyle
) :
94 SystemWindow( WindowType::WORKWINDOW
)
96 ImplInitWorkWindowData();
97 ImplInit( pParent
, nStyle
);
100 WorkWindow::WorkWindow( vcl::Window
* pParent
, const css::uno::Any
& aSystemWorkWindowToken
, WinBits nStyle
) :
101 SystemWindow( WindowType::WORKWINDOW
)
103 ImplInitWorkWindowData();
105 ImplInit( pParent
, nStyle
, aSystemWorkWindowToken
);
108 WorkWindow::WorkWindow( SystemParentData
* pParent
) :
109 SystemWindow( WindowType::WORKWINDOW
)
111 ImplInitWorkWindowData();
113 ImplInit( nullptr, 0, pParent
);
116 WorkWindow::~WorkWindow()
121 void WorkWindow::dispose()
123 ImplSVData
* pSVData
= ImplGetSVData();
124 if (pSVData
->maFrameData
.mpAppWin
== this)
126 pSVData
->maFrameData
.mpAppWin
= nullptr;
129 SystemWindow::dispose();
132 void WorkWindow::ShowFullScreenMode( bool bFullScreenMode
)
134 return ShowFullScreenMode( bFullScreenMode
, GetScreenNumber());
137 void WorkWindow::ShowFullScreenMode( bool bFullScreenMode
, sal_Int32 nDisplayScreen
)
139 if ( !mbFullScreenMode
== !bFullScreenMode
)
142 mbFullScreenMode
= bFullScreenMode
;
146 // Dispose of the canvas implementation, which might rely on
147 // screen-specific system data.
148 css::uno::Reference
< css::rendering::XCanvas
> xCanvas( mpWindowImpl
->mxCanvas
);
151 css::uno::Reference
< css::lang::XComponent
> xCanvasComponent( xCanvas
, css::uno::UNO_QUERY
);
152 if( xCanvasComponent
.is() )
153 xCanvasComponent
->dispose();
156 mpWindowImpl
->mpFrameWindow
->mpWindowImpl
->mbWaitSystemResize
= true;
157 ImplGetFrame()->ShowFullScreen( bFullScreenMode
, nDisplayScreen
);
160 void WorkWindow::StartPresentationMode( PresentationFlags nFlags
)
162 return StartPresentationMode( false/*bPresentation*/, nFlags
, GetScreenNumber());
165 void WorkWindow::StartPresentationMode( bool bPresentation
, PresentationFlags nFlags
, sal_Int32 nDisplayScreen
)
167 if ( !bPresentation
== !mbPresentationMode
)
172 mbPresentationMode
= true;
173 mbPresentationVisible
= IsVisible();
174 mbPresentationFull
= mbFullScreenMode
;
175 mnPresentationFlags
= nFlags
;
177 ShowFullScreenMode( true, nDisplayScreen
);
180 if ( mnPresentationFlags
& PresentationFlags::HideAllApps
)
181 mpWindowImpl
->mpFrame
->SetAlwaysOnTop( true );
183 mpWindowImpl
->mpFrame
->StartPresentation( true );
190 Show( mbPresentationVisible
);
193 mpWindowImpl
->mpFrame
->StartPresentation( false );
194 if ( mnPresentationFlags
& PresentationFlags::HideAllApps
)
195 mpWindowImpl
->mpFrame
->SetAlwaysOnTop( false );
197 ShowFullScreenMode( mbPresentationFull
, nDisplayScreen
);
199 mbPresentationMode
= false;
200 mbPresentationVisible
= false;
201 mbPresentationFull
= false;
202 mnPresentationFlags
= PresentationFlags::NONE
;
206 bool WorkWindow::IsMinimized() const
208 //return mpWindowImpl->mpFrameData->mbMinimized;
209 SalFrameState aState
;
210 if (mpWindowImpl
->mpFrame
->GetWindowState(&aState
))
211 return bool(aState
.mnState
& WindowStateState::Minimized
);
216 void WorkWindow::SetPluginParent( SystemParentData
* pParent
)
218 SAL_WARN_IF( mbPresentationMode
|| mbFullScreenMode
, "vcl", "SetPluginParent in fullscreen or presentation mode !" );
220 bool bWasDnd
= Window::ImplStopDnd();
222 bool bShown
= IsVisible();
224 mpWindowImpl
->mpFrame
->SetPluginParent( pParent
);
228 Window::ImplStartDnd();
231 void WorkWindow::ImplSetFrameState( WindowStateState aFrameState
)
233 SalFrameState aState
;
234 aState
.mnMask
= WindowStateMask::State
;
235 aState
.mnState
= aFrameState
;
236 mpWindowImpl
->mpFrame
->SetWindowState( &aState
);
239 void WorkWindow::Minimize()
241 ImplSetFrameState( WindowStateState::Minimized
);
244 void WorkWindow::Restore()
246 ImplSetFrameState( WindowStateState::Normal
);
249 bool WorkWindow::Close()
251 bool bCanClose
= SystemWindow::Close();
253 // if it's the application window then close the application
254 if (bCanClose
&& (ImplGetSVData()->maFrameData
.mpAppWin
== this))
260 void WorkWindow::Maximize( bool bMaximize
)
262 ImplSetFrameState( bMaximize
? WindowStateState::Maximized
: WindowStateState::Normal
);
265 bool WorkWindow::IsMaximized() const
269 SalFrameState aState
;
270 if( mpWindowImpl
->mpFrame
->GetWindowState( &aState
) )
272 if( aState
.mnState
& (WindowStateState::Maximized
|
273 WindowStateState::MaximizedHorz
|
274 WindowStateState::MaximizedVert
) )
280 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */