25#include <osl/file.hxx>
26#include <osl/signal.h>
82#include <config_features.h>
83#include <config_feature_opencl.h>
85#include <osl/process.h>
86#include <com/sun/star/lang/XComponent.hpp>
87#include <com/sun/star/frame/Desktop.hpp>
90#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
95#include <uno/current_context.hxx>
105#if OSL_DEBUG_LEVEL > 0
107#include <rtl/strbuf.hxx>
120 static volatile bool bIn =
false;
124 return osl_Signal_ActCallNextHdl;
129 if ( (pInfo->Signal == osl_Signal_AccessViolation) ||
130 (pInfo->Signal == osl_Signal_IntegerDivideByZero) ||
131 (pInfo->Signal == osl_Signal_FloatDivideByZero) ||
132 (pInfo->Signal == osl_Signal_DebugBreak) )
135#if HAVE_FEATURE_OPENGL
143#if HAVE_FEATURE_OPENCL
144 if (OpenCLZone::isInZone())
148 if (OpenCLInitialZone::isInZone())
156 if ((pInfo->Signal == osl_Signal_User) &&
157 (pInfo->UserSignal == OSL_SIGNAL_USER_X11SUBSYSTEMERROR) )
169 if ( pSVData->
mpApp )
180 return osl_Signal_ActCallNextHdl;
191 int nReturn = EXIT_FAILURE;
194 const bool bInit = bWasInitVCL ||
InitVCL();
247class DesktopEnvironmentContext:
public cppu::WeakImplHelper< css::uno::XCurrentContext >
250 explicit DesktopEnvironmentContext( css::uno::Reference< css::uno::XCurrentContext >
ctx)
251 : m_xNextContext(std::move(
ctx )) {}
254 virtual css::uno::Any SAL_CALL getValueByName(
const OUString&
Name )
override;
257 css::uno::Reference< css::uno::XCurrentContext > m_xNextContext;
262uno::Any SAL_CALL DesktopEnvironmentContext::getValueByName(
const OUString& Name)
266 if ( Name ==
"system.desktop-environment" )
270 else if( m_xNextContext.is() )
273 retVal = m_xNextContext->getValueByName( Name );
282 pSVData->
mpApp !=
nullptr &&
301 SAL_INFO(
"vcl.app",
"Double initialization of vcl");
327 css::uno::setCurrentContext(
328 new DesktopEnvironmentContext( css::uno::getCurrentContext() ) );
344 OUString aLocaleString(
SvtSysLocaleOptions().GetRealUILanguageTag().getGlibcLocaleString(
u".UTF-8"));
345 if (!aLocaleString.isEmpty())
348 OUString envVar(
"LANGUAGE");
349 osl_setEnvironment(envVar.pData, aLocaleString.pData);
352 catch (
const uno::Exception &)
360 OUString aExeFileName;
361 osl_getExecutableFile( &aExeFileName.pData );
364 OUString aNativeFileName;
365 osl::FileBase::getSystemPathFromFileURL( aExeFileName, aNativeFileName );
381#if OSL_DEBUG_LEVEL > 0
388 unsetenv(
"DESKTOP_STARTUP_ID");
402class VCLUnoWrapperDeleter :
public cppu::WeakImplHelper<css::lang::XEventListener>
404 virtual void SAL_CALL disposing(lang::EventObject
const& rSource)
override;
408VCLUnoWrapperDeleter::disposing(lang::EventObject
const& )
434 ::comphelper::JoinAsyncEventNotifiers();
445#if OSL_DEBUG_LEVEL > 0
446 OStringBuffer
aBuf( 256 );
447 aBuf.append(
"DeInitVCL: some top Windows are still alive\n" );
459 aBuf.append(
"text = \"" );
461 aBuf.append(
"\" type = \"" );
462 aBuf.append(
typeid(*pWin).name() );
463 aBuf.append(
"\", ptr = 0x" );
464 aBuf.append(
reinterpret_cast<sal_Int64
>( pWin ), 16 );
495 if (
auto const comp = css::uno::Reference<css::lang::XComponent>(
496 pSVData->m_xSystemClipboard, css::uno::UNO_QUERY))
501 pSVData->m_xSystemClipboard.clear();
512 uno::Reference<frame::XDesktop2>
const xDesktop = frame::Desktop::create(
514 xDesktop->addEventListener(
new VCLUnoWrapperDeleter);
516 catch (uno::Exception
const&)
625struct WorkerThreadData
627 oslWorkerFunction pWorker;
629 WorkerThreadData( oslWorkerFunction pWorker_,
void * pThreadData_ )
630 : pWorker( pWorker_ )
631 , pThreadData( pThreadData_ )
640static DWORD WINAPI threadmain( _In_ LPVOID pArgs )
642 OleInitialize(
nullptr );
643 static_cast<WorkerThreadData*
>(pArgs)->pWorker(
static_cast<WorkerThreadData*
>(pArgs)->pThreadData );
644 delete static_cast<WorkerThreadData*
>(pArgs);
655 static_cast<WorkerThreadData*
>(pArgs)->pWorker(
static_cast<WorkerThreadData*
>(pArgs)->pThreadData );
656 delete static_cast<WorkerThreadData*
>(pArgs);
672 new WorkerThreadData( pWorker, pThreadData ),
685 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
void remove_if(UnaryPredicate pred)
std::pair< Key, Value > key_value_pair_t
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::unique_ptr< Image > mpDisclosurePlus
std::unique_ptr< Image > mpDisclosureMinus
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
o3tl::lru_map< OUString, BitmapEx > maThemeImageCache
VclPtr< vcl::WindowOutputDevice > mpLastWinGraphics
VclPtr< OutputDevice > mpLastVirGraphics
VclPtr< Printer > mpFirstPrnGraphics
lru_scale_cache maScaleCache
std::shared_ptr< vcl::font::PhysicalFontCollection > mxScreenFontList
o3tl::lru_map< OUString, gfx::DrawRoot > maThemeDrawCommandsCache
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)