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 .
23 #include <sal/config.h>
25 #include <condition_variable>
29 #include <comphelper/solarmutex.hxx>
30 #include <osl/conditn.hxx>
31 #include <osl/thread.hxx>
32 #include <tools/long.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 NSButtonCell
* mpButtonCell
;
80 NSButtonCell
* mpCheckCell
;
81 NSButtonCell
* mpRadioCell
;
82 NSTextFieldCell
* mpTextFieldCell
;
83 NSComboBoxCell
* mpComboBoxCell
;
84 NSPopUpButtonCell
* mpPopUpButtonCell
;
85 NSStepperCell
* mpStepperCell
;
86 NSButtonCell
* mpListNodeCell
;
87 OUString maDefaultPrinter
;
88 oslThreadIdentifier maMainThread
;
89 int mnActivePrintJobs
;
90 osl::Mutex maUserEventListMutex
;
91 osl::Condition maWaitingYieldCond
;
93 bool mbTimerProcessed
;
95 static std::list
<const ApplicationEvent
*> aAppEventList
;
98 virtual ~AquaSalInstance() override
;
100 virtual void AfterAppInit() override
;
101 virtual bool SVMainHook(int *) override
;
103 virtual SalFrame
* CreateChildFrame( SystemParentData
* pParent
, SalFrameStyleFlags nStyle
) override
;
104 virtual SalFrame
* CreateFrame( SalFrame
* pParent
, SalFrameStyleFlags nStyle
) override
;
105 virtual void DestroyFrame( SalFrame
* pFrame
) override
;
106 virtual SalObject
* CreateObject( SalFrame
* pParent
, SystemWindowData
* pWindowData
,
107 bool bShow
) override
;
108 virtual void DestroyObject( SalObject
* pObject
) override
;
109 virtual std::unique_ptr
<SalVirtualDevice
>
110 CreateVirtualDevice( SalGraphics
& rGraphics
,
111 tools::Long
&nDX
, tools::Long
&nDY
,
112 DeviceFormat eFormat
,
113 const SystemGraphicsData
*pData
= nullptr ) override
;
114 virtual SalInfoPrinter
* CreateInfoPrinter( SalPrinterQueueInfo
* pQueueInfo
,
115 ImplJobSetup
* pSetupData
) override
;
116 virtual void DestroyInfoPrinter( SalInfoPrinter
* pPrinter
) override
;
117 virtual std::unique_ptr
<SalPrinter
> CreatePrinter( SalInfoPrinter
* pInfoPrinter
) override
;
118 virtual void GetPrinterQueueInfo( ImplPrnQueueList
* pList
) override
;
119 virtual void GetPrinterQueueState( SalPrinterQueueInfo
* pInfo
) override
;
120 virtual OUString
GetDefaultPrinter() override
;
121 virtual SalTimer
* CreateSalTimer() override
;
122 virtual SalSystem
* CreateSalSystem() override
;
123 virtual std::shared_ptr
<SalBitmap
> CreateSalBitmap() override
;
124 virtual bool DoYield(bool bWait
, bool bHandleAllCurrentEvents
) override
;
125 virtual bool AnyInput( VclInputFlags nType
) override
;
126 virtual std::unique_ptr
<SalMenu
> CreateMenu( bool bMenuBar
, Menu
* pVCLMenu
) override
;
127 virtual std::unique_ptr
<SalMenuItem
> CreateMenuItem( const SalItemParams
& rItemData
) override
;
128 virtual OpenGLContext
* CreateOpenGLContext() override
;
129 virtual OUString
GetConnectionIdentifier() override
;
130 virtual void AddToRecentDocumentList(const OUString
& rFileUrl
, const OUString
& rMimeType
,
131 const OUString
& rDocumentService
) override
;
133 virtual OUString
getOSVersion() override
;
135 // dtrans implementation
136 virtual css::uno::Reference
< css::uno::XInterface
> CreateClipboard(
137 const css::uno::Sequence
< css::uno::Any
>& i_rArguments
) override
;
138 virtual css::uno::Reference
<css::uno::XInterface
> ImplCreateDragSource(const SystemEnvData
*) override
;
139 virtual css::uno::Reference
<css::uno::XInterface
> ImplCreateDropTarget(const SystemEnvData
*) override
;
141 static void handleAppDefinedEvent( NSEvent
* pEvent
);
143 // check whether a particular string is passed on the command line
144 // this is needed to avoid duplicate open events through a) command line and b) NSApp's openFile
145 static bool isOnCommandLine( const OUString
& );
147 void delayedSettingsChanged( bool bInvalidate
);
149 // Is this the NSAppThread?
150 virtual bool IsMainThread() const override
;
152 void startedPrintJob() { mnActivePrintJobs
++; }
153 void endedPrintJob() { mnActivePrintJobs
--; }
155 // event subtypes for NSEventTypeApplicationDefined events
156 static const short AppExecuteSVMain
= 1;
157 static const short AppStartTimerEvent
= 10;
158 static const short YieldWakeupEvent
= 20;
159 static const short DispatchTimerEvent
= 30;
161 static NSMenu
* GetDynamicDockMenu();
164 CGImageRef
CreateCGImage( const Image
& );
165 NSImage
* CreateNSImage( const Image
& );
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */