LibreOffice Module vcl (master)  1
osx/salinst.h
Go to the documentation of this file.
1 
2 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 /*
4  * This file is part of the LibreOffice project.
5  *
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/.
9  *
10  * This file incorporates work covered by the following license notice:
11  *
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 .
19  */
20 
21 #ifndef INCLUDED_VCL_INC_OSX_SALINST_H
22 #define INCLUDED_VCL_INC_OSX_SALINST_H
23 
24 #include <sal/config.h>
25 
26 #include <condition_variable>
27 #include <list>
28 #include <mutex>
29 
31 #include <osl/conditn.hxx>
32 #include <osl/thread.hxx>
33 
34 #ifdef MACOSX
35 #include <osx/osxvcltypes.h>
36 #endif
37 #include <salinst.hxx>
38 
39 #include <osx/runinmain.hxx>
40 
41 #include <salusereventlist.hxx>
42 
43 class AquaSalFrame;
44 class SalFrame;
45 class SalObject;
46 class ApplicationEvent;
47 class Image;
48 enum class SalEvent;
49 
51 
53 {
54 public:
56 
57 protected:
58  virtual void doAcquire( sal_uInt32 nLockCount ) override;
59  virtual sal_uInt32 doRelease( bool bUnlockAll ) override;
60 
61 public:
62  SalYieldMutex();
63  virtual ~SalYieldMutex() override;
64 
65  virtual bool IsCurrentThread() const override;
66 };
67 
69 {
70  friend class AquaSalFrame;
71 
72  bool RunInMainYield( bool bHandleAllCurrentEvents );
73 
74  virtual void ProcessEvent( SalUserEvent aEvent ) override;
75 
76 public:
77  virtual void TriggerUserEventProcessing() override;
78 
79  OUString maDefaultPrinter;
80  oslThreadIdentifier maMainThread;
83  osl::Condition maWaitingYieldCond;
87 
88  static std::list<const ApplicationEvent*> aAppEventList;
89 
91  virtual ~AquaSalInstance() override;
92 
93  virtual void AfterAppInit() override;
94  virtual bool SVMainHook(int *) override;
95 
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;
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;
125 
126  virtual OUString getOSVersion() override;
127 
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;
133 
134  static void handleAppDefinedEvent( NSEvent* pEvent );
135 
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& );
139 
140  void delayedSettingsChanged( bool bInvalidate );
141 
142  // Is this the NSAppThread?
143  virtual bool IsMainThread() const override;
144 
145  void startedPrintJob() { mnActivePrintJobs++; }
146  void endedPrintJob() { mnActivePrintJobs--; }
147 
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;
153 
154  static NSMenu* GetDynamicDockMenu();
155 };
156 
157 CGImageRef CreateCGImage( const Image& );
158 NSImage* CreateNSImage( const Image& );
159 
160 #endif // INCLUDED_VCL_INC_OSX_SALINST_H
161 
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual std::unique_ptr< SalMenu > CreateMenu(bool bMenuBar, Menu *pVCLMenu) override
NSImage * CreateNSImage(const Image &)
virtual void DestroyInfoPrinter(SalInfoPrinter *pPrinter) override
void delayedSettingsChanged(bool bInvalidate)
virtual css::uno::Reference< css::uno::XInterface > CreateDropTarget() override
virtual void doAcquire(sal_uInt32 nLockCount) override
virtual bool IsMainThread() const override
virtual std::shared_ptr< SalBitmap > CreateSalBitmap() override
CGImageRef CreateCGImage(const Image &)
virtual std::unique_ptr< SalVirtualDevice > CreateVirtualDevice(SalGraphics *pGraphics, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData=nullptr) override
bool RunInMainYield(bool bHandleAllCurrentEvents)
#define OSX_RUNINMAIN_MEMBERS
Definition: runinmain.hxx:60
virtual std::unique_ptr< SalPrinter > CreatePrinter(SalInfoPrinter *pInfoPrinter) override
virtual SalFrame * CreateChildFrame(SystemParentData *pParent, SalFrameStyleFlags nStyle) override
virtual OUString getOSVersion() override
get information about underlying versions
virtual void AfterAppInit() override
static void handleAppDefinedEvent(NSEvent *pEvent)
void startedPrintJob()
Definition: osx/salinst.h:145
virtual std::unique_ptr< SalMenuItem > CreateMenuItem(const SalItemParams &rItemData) override
OUString maDefaultPrinter
Definition: osx/salinst.h:79
virtual SalSystem * CreateSalSystem() override
An application can be notified of a number of different events:
Definition: svapp.hxx:121
virtual OUString GetDefaultPrinter() override
VclInputFlags
Definition: inputtypes.hxx:25
virtual void AddToRecentDocumentList(const OUString &rFileUrl, const OUString &rMimeType, const OUString &rDocumentService) override
static std::list< const ApplicationEvent * > aAppEventList
Definition: osx/salinst.h:88
virtual ~AquaSalInstance() override
virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override
Wait for the next event (if bWait) and dispatch it, includes posted events, and timers.
virtual void DestroyObject(SalObject *pObject) override
virtual void GetPrinterQueueInfo(ImplPrnQueueList *pList) override
virtual void DestroyFrame(SalFrame *pFrame) override
virtual bool SVMainHook(int *) override
void(^ RuninmainBlock)(void)
Definition: osx/salinst.h:50
virtual void ProcessEvent(SalUserEvent aEvent) override
void endedPrintJob()
Definition: osx/salinst.h:146
virtual bool IsCurrentThread() const override
osl::Condition maWaitingYieldCond
Definition: osx/salinst.h:83
static bool isOnCommandLine(const OUString &)
virtual void TriggerUserEventProcessing() override
static const short DispatchTimerEvent
Definition: osx/salinst.h:152
virtual SalFrame * CreateFrame(SalFrame *pParent, SalFrameStyleFlags nStyle) override
virtual OUString GetConnectionIdentifier() override
static const short AppStartTimerEvent
Definition: osx/salinst.h:150
virtual sal_uInt32 doRelease(bool bUnlockAll) override
SalEvent
Definition: salwtype.hxx:40
DeviceFormat
Definition: salgtype.hxx:28
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:112
static const short YieldWakeupEvent
Definition: osx/salinst.h:151
Definition: menu.hxx:121
virtual SalInfoPrinter * CreateInfoPrinter(SalPrinterQueueInfo *pQueueInfo, ImplJobSetup *pSetupData) override
static NSMenu * GetDynamicDockMenu()
bool mbTimerProcessed
Definition: osx/salinst.h:86
virtual ~SalYieldMutex() override
virtual css::uno::Reference< css::uno::XInterface > CreateDragSource() override
SalFrameStyleFlags
Definition: salframe.hxx:64
Definition: image.hxx:40
virtual SalObject * CreateObject(SalFrame *pParent, SystemWindowData *pWindowData, bool bShow) override
virtual void GetPrinterQueueState(SalPrinterQueueInfo *pInfo) override
osl::Mutex maUserEventListMutex
Definition: osx/salinst.h:82
virtual SalTimer * CreateSalTimer() override
virtual css::uno::Reference< css::uno::XInterface > CreateClipboard(const css::uno::Sequence< css::uno::Any > &i_rArguments) override
oslThreadIdentifier maMainThread
Definition: osx/salinst.h:80
virtual OpenGLContext * CreateOpenGLContext() override
virtual bool AnyInput(VclInputFlags nType) override
static const short AppExecuteSVMain
Definition: osx/salinst.h:149
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo