25#include <osl/file.hxx>
26#include <osl/signal.h>
83#include <config_features.h>
84#include <config_feature_opencl.h>
86#include <osl/process.h>
87#include <com/sun/star/lang/XComponent.hpp>
88#include <com/sun/star/frame/Desktop.hpp>
91#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
96#include <uno/current_context.hxx>
106#if OSL_DEBUG_LEVEL > 0
108#include <rtl/strbuf.hxx>
121 static volatile bool bIn =
false;
125 return osl_Signal_ActCallNextHdl;
130 if ( (pInfo->Signal == osl_Signal_AccessViolation) ||
131 (pInfo->Signal == osl_Signal_IntegerDivideByZero) ||
132 (pInfo->Signal == osl_Signal_FloatDivideByZero) ||
133 (pInfo->Signal == osl_Signal_DebugBreak) )
136#if HAVE_FEATURE_OPENGL
144#if HAVE_FEATURE_OPENCL
145 if (OpenCLZone::isInZone())
149 if (OpenCLInitialZone::isInZone())
157 if ((pInfo->Signal == osl_Signal_User) &&
158 (pInfo->UserSignal == OSL_SIGNAL_USER_X11SUBSYSTEMERROR) )
170 if ( pSVData->
mpApp )
181 return osl_Signal_ActCallNextHdl;
192 int nReturn = EXIT_FAILURE;
195 const bool bInit = bWasInitVCL ||
InitVCL();
248class DesktopEnvironmentContext:
public cppu::WeakImplHelper< css::uno::XCurrentContext >
251 explicit DesktopEnvironmentContext( css::uno::Reference< css::uno::XCurrentContext >
ctx)
252 : m_xNextContext(std::move(
ctx )) {}
255 virtual css::uno::Any SAL_CALL getValueByName(
const OUString&
Name )
override;
258 css::uno::Reference< css::uno::XCurrentContext > m_xNextContext;
263uno::Any SAL_CALL DesktopEnvironmentContext::getValueByName(
const OUString& Name)
267 if ( Name ==
"system.desktop-environment" )
271 else if( m_xNextContext.is() )
274 retVal = m_xNextContext->getValueByName( Name );
283 pSVData->
mpApp !=
nullptr &&
302 SAL_INFO(
"vcl.app",
"Double initialization of vcl");
328 css::uno::setCurrentContext(
329 new DesktopEnvironmentContext( css::uno::getCurrentContext() ) );
345 OUString aLocaleString(
SvtSysLocaleOptions().GetRealUILanguageTag().getGlibcLocaleString(
u".UTF-8"));
346 if (!aLocaleString.isEmpty())
349 OUString envVar(
"LANGUAGE");
350 osl_setEnvironment(envVar.pData, aLocaleString.pData);
353 catch (
const uno::Exception &)
361 OUString aExeFileName;
362 osl_getExecutableFile( &aExeFileName.pData );
365 OUString aNativeFileName;
366 osl::FileBase::getSystemPathFromFileURL( aExeFileName, aNativeFileName );
382#if OSL_DEBUG_LEVEL > 0
389 unsetenv(
"DESKTOP_STARTUP_ID");
403class VCLUnoWrapperDeleter :
public cppu::WeakImplHelper<css::lang::XEventListener>
405 virtual void SAL_CALL disposing(lang::EventObject
const& rSource)
override;
409VCLUnoWrapperDeleter::disposing(lang::EventObject
const& )
435 ::comphelper::JoinAsyncEventNotifiers();
446#if OSL_DEBUG_LEVEL > 0
447 OStringBuffer
aBuf( 256 );
448 aBuf.append(
"DeInitVCL: some top Windows are still alive\n" );
460 aBuf.append(
"text = \""
463 +
typeid(*pWin).name()
465 + OString::number(
reinterpret_cast<sal_Int64
>( pWin ), 16 )
496 if (
auto const comp = css::uno::Reference<css::lang::XComponent>(
497 pSVData->m_xSystemClipboard, css::uno::UNO_QUERY))
502 pSVData->m_xSystemClipboard.clear();
513 uno::Reference<frame::XDesktop2>
const xDesktop = frame::Desktop::create(
515 xDesktop->addEventListener(
new VCLUnoWrapperDeleter);
517 catch (uno::Exception
const&)
622struct WorkerThreadData
624 oslWorkerFunction pWorker;
626 WorkerThreadData( oslWorkerFunction pWorker_,
void * pThreadData_ )
627 : pWorker( pWorker_ )
628 , pThreadData( pThreadData_ )
637static DWORD WINAPI threadmain( _In_ LPVOID pArgs )
639 OleInitialize(
nullptr );
640 static_cast<WorkerThreadData*
>(pArgs)->pWorker(
static_cast<WorkerThreadData*
>(pArgs)->pThreadData );
641 delete static_cast<WorkerThreadData*
>(pArgs);
652 static_cast<WorkerThreadData*
>(pArgs)->pWorker(
static_cast<WorkerThreadData*
>(pArgs)->pThreadData );
653 delete static_cast<WorkerThreadData*
>(pArgs);
669 new WorkerThreadData( pWorker, pThreadData ),
682 WaitForSingleObject(
hThreadID, INFINITE);
Base class used mainly for the LibreOffice Desktop class.
static tools::Long GetTopWindowCount()
Return the number of top-level windows being used by the application.
virtual void Init()
Initialize the application itself.
static vcl::Window * GetTopWindow(tools::Long nIndex)
Get the nth top window.
static SystemWindowFlags GetSystemWindowMode()
Get the system window mode of dialogs.
virtual void Exception(ExceptionCategory nCategory)
Handles an error.
static void SetSystemWindowMode(SystemWindowFlags nMode)
Make a dialog box a system window or not.
virtual int Main()
Pure virtual entrypoint to the application.
static const OUString & GetDesktopEnvironment()
Get the desktop environment the process is currently running in.
virtual void DeInit()
Deinitialized the application itself.
static DebugEventInjector * getCreate()
static void clearTemporaryFontFiles()
Removes all temporary fonts in the path used by fileUrlForTemporaryFont().
static VCL_DLLPUBLIC ImageTree & get()
VCL_DLLPUBLIC void shutdown()
a crude form of life cycle control (called from DeInitVCL; otherwise, if the ImplImageTree singleton ...
static LanguageType getSystemUILanguage()
static void hardDisable()
static void hardDisable()
Called from a signal handler or watchdog thread if we get a crash or hang in some GL code.
virtual bool SVMainHook(int *)
void AcquireYieldMutex(sal_uInt32 nCount=1)
sal_uInt32 ReleaseYieldMutexAll()
virtual void AfterAppInit()
static void ImplDeInitScheduler()
static void hardDisable()
A helper class that calls Application::ReleaseSolarMutex() in its constructor and restores the mutex ...
virtual void flushAll()=0
static void SAL_DLLPRIVATE ImplDeleteOnDeInit()
guard class that uses tryToAcquire() and has isAcquired() to check
static bool IsLOKWindowsEmpty()
check if LOK Window container is empty
virtual OUString GetText() const
void DbgGUIInitSolarMutexCheck()
void DbgGUIDeInitSolarMutexCheck()
#define TOOLS_INFO_EXCEPTION(area, stream)
EXITHELPER_NORMAL_RESTART
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
Reference< XComponentContext > getProcessComponentContext()
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
void ImplDeletePrnQueueList()
void DestroySalInstance(SalInstance *pInst)
SalInstance * CreateSalInstance()
VclPtr< ImplWheelWindow > mpWheelWindow
std::vector< Link< VclWindowEvent &, bool > > maKeyListeners
std::optional< OUString > mxAppFileName
std::optional< AllSettings > mxSettings
VclPtr< PopupMenu > mpActivePopupMenu
LocaleConfigurationListener * mpCfgListener
ImplAccelManager * mpAccelMgr
std::vector< Image > maCheckImgList
std::optional< Image > moDisclosureMinus
std::optional< Image > moDisclosurePlus
std::vector< Image > maRadioImgList
ImplSVCtrlData maCtrlData
ImplSchedulerContext maSchedCtx
ImplSVFrameData maFrameData
oslThreadIdentifier mnMainThreadId
UnoWrapperBase * mpUnoWrapper
rtl::Reference< vcl::DisplayConnectionDispatch > mxDisplayConnection
std::unique_ptr< BlendFrameCache > mpBlendFrameCache
Link< LinkParamNone *, void > maDeInitHook
css::uno::Reference< css::lang::XComponent > mxAccessBridge
VclPtr< WorkWindow > mpDefaultWin
ImplSVWinData * mpWinData
std::unique_ptr< SalSystem > mpSalSystem
std::unique_ptr< vcl::SettingsConfigItem > mpSettingsConfigItem
VclPtr< vcl::Window > mpIntroWindow
VclPtr< WorkWindow > mpAppWin
VclPtr< vcl::Window > mpFirstFrame
VclPtr< vcl::Window > mpActiveApplicationFrame
VclPtr< vcl::WindowOutputDevice > mpLastWinGraphics
VclPtr< OutputDevice > mpLastVirGraphics
VclPtr< Printer > mpFirstPrnGraphics
std::shared_ptr< vcl::font::PhysicalFontCollection > mxScreenFontList
VclPtr< Printer > mpFirstPrinter
std::shared_ptr< ImplFontCache > mxScreenFontCache
std::unique_ptr< GraphicConverter > mxGrfConverter
VclPtr< VirtualDevice > mpFirstVirDev
VclPtr< OutputDevice > mpFirstVirGraphics
VclPtr< vcl::WindowOutputDevice > mpFirstWinGraphics
VclPtr< Printer > mpLastPrnGraphics
VclPtr< vcl::Window > mpLastWheelWindow
VclPtr< FloatingWindow > mpFirstFloat
VclPtr< vcl::Window > mpLastDeacWin
std::vector< Image > maMsgBoxImgList
VclPtr< vcl::Window > mpAutoScrollWin
VclPtr< vcl::Window > mpCaptureWin
VclPtr< vcl::Window > mpTrackWin
VclPtr< vcl::Window > mpExtTextInputWin
std::vector< VclPtr< Dialog > > mpExecuteDialogs
Stack of dialogs that are Execute()'d - the last one is the top most one.
SalTimer * mpSalTimer
interface to sal event loop / system timer
ImplSVData * ImplGetSVData()
basegfx::SystemDependentDataManager & ImplGetSystemDependentDataManager()
void JoinMainLoopThread()
static void MainWorkerFunction(void *pArgs)
static Application * pOwnSvApp
static oslThread hThreadID
static oslSignalHandler pExceptionHandler
static bool g_bIsLeanException
static oslSignalAction VCLExceptionSignal_impl(void *, oslSignalInfo *pInfo)
void CreateMainLoopThread(oslWorkerFunction pWorker, void *pThreadData)