2 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 * This file incorporates work covered by the following license notice:
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed
14 * with this work for additional information regarding copyright
15 * ownership. The ASF licenses this file to you under the Apache
16 * License, Version 2.0 (the "License"); you may not use this file
17 * except in compliance with the License. You may obtain a copy of
18 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #ifndef INCLUDED_VCL_INC_OSX_SALINST_H
22 #define INCLUDED_VCL_INC_OSX_SALINST_H
24 #include <sal/config.h>
26 #include <condition_variable>
30 #include <comphelper/solarmutex.hxx>
31 #include <osl/conditn.hxx>
32 #include <osl/thread.hxx>
35 #include <osx/osxvcltypes.h>
37 #include <salinst.hxx>
39 #include <osx/runinmain.hxx>
41 #include <salusereventlist.hxx>
46 class ApplicationEvent
;
50 typedef void(^RuninmainBlock
)(void);
52 class SalYieldMutex
: public comphelper::SolarMutex
58 virtual void doAcquire( sal_uInt32 nLockCount
) override
;
59 virtual sal_uInt32
doRelease( bool bUnlockAll
) override
;
63 virtual ~SalYieldMutex() override
;
65 virtual bool IsCurrentThread() const override
;
68 class AquaSalInstance
: public SalInstance
, public SalUserEventList
70 friend class AquaSalFrame
;
72 bool RunInMainYield( bool bHandleAllCurrentEvents
);
74 virtual void ProcessEvent( SalUserEvent aEvent
) override
;
77 virtual void TriggerUserEventProcessing() override
;
79 OUString maDefaultPrinter
;
80 oslThreadIdentifier maMainThread
;
81 int mnActivePrintJobs
;
82 osl::Mutex maUserEventListMutex
;
83 osl::Condition maWaitingYieldCond
;
86 bool mbTimerProcessed
;
88 static std::list
<const ApplicationEvent
*> aAppEventList
;
91 virtual ~AquaSalInstance() override
;
93 virtual void AfterAppInit() override
;
94 virtual bool SVMainHook(int *) override
;
96 virtual SalFrame
* CreateChildFrame( SystemParentData
* pParent
, SalFrameStyleFlags nStyle
) override
;
97 virtual SalFrame
* CreateFrame( SalFrame
* pParent
, SalFrameStyleFlags nStyle
) override
;
98 virtual void DestroyFrame( SalFrame
* pFrame
) override
;
99 virtual SalObject
* CreateObject( SalFrame
* pParent
, SystemWindowData
* pWindowData
,
100 bool bShow
) override
;
101 virtual void DestroyObject( SalObject
* pObject
) override
;
102 virtual std::unique_ptr
<SalVirtualDevice
>
103 CreateVirtualDevice( SalGraphics
* pGraphics
,
104 long &nDX
, long &nDY
,
105 DeviceFormat eFormat
,
106 const SystemGraphicsData
*pData
= nullptr ) override
;
107 virtual SalInfoPrinter
* CreateInfoPrinter( SalPrinterQueueInfo
* pQueueInfo
,
108 ImplJobSetup
* pSetupData
) override
;
109 virtual void DestroyInfoPrinter( SalInfoPrinter
* pPrinter
) override
;
110 virtual std::unique_ptr
<SalPrinter
> CreatePrinter( SalInfoPrinter
* pInfoPrinter
) override
;
111 virtual void GetPrinterQueueInfo( ImplPrnQueueList
* pList
) override
;
112 virtual void GetPrinterQueueState( SalPrinterQueueInfo
* pInfo
) override
;
113 virtual OUString
GetDefaultPrinter() override
;
114 virtual SalTimer
* CreateSalTimer() override
;
115 virtual SalSystem
* CreateSalSystem() override
;
116 virtual std::shared_ptr
<SalBitmap
> CreateSalBitmap() override
;
117 virtual bool DoYield(bool bWait
, bool bHandleAllCurrentEvents
) override
;
118 virtual bool AnyInput( VclInputFlags nType
) override
;
119 virtual std::unique_ptr
<SalMenu
> CreateMenu( bool bMenuBar
, Menu
* pVCLMenu
) override
;
120 virtual std::unique_ptr
<SalMenuItem
> CreateMenuItem( const SalItemParams
& rItemData
) override
;
121 virtual OpenGLContext
* CreateOpenGLContext() override
;
122 virtual OUString
GetConnectionIdentifier() override
;
123 virtual void AddToRecentDocumentList(const OUString
& rFileUrl
, const OUString
& rMimeType
,
124 const OUString
& rDocumentService
) override
;
126 virtual OUString
getOSVersion() override
;
128 // dtrans implementation
129 virtual css::uno::Reference
< css::uno::XInterface
> CreateClipboard(
130 const css::uno::Sequence
< css::uno::Any
>& i_rArguments
) override
;
131 virtual css::uno::Reference
< css::uno::XInterface
> CreateDragSource() override
;
132 virtual css::uno::Reference
< css::uno::XInterface
> CreateDropTarget() override
;
134 static void handleAppDefinedEvent( NSEvent
* pEvent
);
136 // check whether a particular string is passed on the command line
137 // this is needed to avoid duplicate open events through a) command line and b) NSApp's openFile
138 static bool isOnCommandLine( const OUString
& );
140 void delayedSettingsChanged( bool bInvalidate
);
142 // Is this the NSAppThread?
143 virtual bool IsMainThread() const override
;
145 void startedPrintJob() { mnActivePrintJobs
++; }
146 void endedPrintJob() { mnActivePrintJobs
--; }
148 // event subtypes for NSApplicationDefined events
149 static const short AppExecuteSVMain
= 1;
150 static const short AppStartTimerEvent
= 10;
151 static const short YieldWakeupEvent
= 20;
152 static const short DispatchTimerEvent
= 30;
154 static NSMenu
* GetDynamicDockMenu();
157 CGImageRef
CreateCGImage( const Image
& );
158 NSImage
* CreateNSImage( const Image
& );
160 #endif // INCLUDED_VCL_INC_OSX_SALINST_H
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */