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 #include <tools/long.hxx>
34 
35 #ifdef MACOSX
36 #include <osx/osxvcltypes.h>
37 #endif
38 #include <salinst.hxx>
39 
40 #include <osx/runinmain.hxx>
41 
42 #include <salusereventlist.hxx>
43 
44 class AquaSalFrame;
45 class SalFrame;
46 class SalObject;
47 class ApplicationEvent;
48 class Image;
49 enum class SalEvent;
50 
52 
54 {
55 public:
57 
58 protected:
59  virtual void doAcquire( sal_uInt32 nLockCount ) override;
60  virtual sal_uInt32 doRelease( bool bUnlockAll ) override;
61 
62 public:
63  SalYieldMutex();
64  virtual ~SalYieldMutex() override;
65 
66  virtual bool IsCurrentThread() const override;
67 };
68 
70 {
71  friend class AquaSalFrame;
72 
73  bool RunInMainYield( bool bHandleAllCurrentEvents );
74 
75  virtual void ProcessEvent( SalUserEvent aEvent ) override;
76 
77 public:
78  virtual void TriggerUserEventProcessing() override;
79 
80  OUString maDefaultPrinter;
81  oslThreadIdentifier maMainThread;
84  osl::Condition maWaitingYieldCond;
88 
89  static std::list<const ApplicationEvent*> aAppEventList;
90 
92  virtual ~AquaSalInstance() override;
93 
94  virtual void AfterAppInit() override;
95  virtual bool SVMainHook(int *) override;
96 
97  virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
98  virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
99  virtual void DestroyFrame( SalFrame* pFrame ) override;
100  virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData,
101  bool bShow ) override;
102  virtual void DestroyObject( SalObject* pObject ) override;
103  virtual std::unique_ptr<SalVirtualDevice>
104  CreateVirtualDevice( SalGraphics* pGraphics,
105  tools::Long &nDX, tools::Long &nDY,
106  DeviceFormat eFormat,
107  const SystemGraphicsData *pData = nullptr ) override;
109  ImplJobSetup* pSetupData ) override;
110  virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) override;
111  virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
112  virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) override;
113  virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) override;
114  virtual OUString GetDefaultPrinter() override;
115  virtual SalTimer* CreateSalTimer() override;
116  virtual SalSystem* CreateSalSystem() override;
117  virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override;
118  virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override;
119  virtual bool AnyInput( VclInputFlags nType ) override;
120  virtual std::unique_ptr<SalMenu> CreateMenu( bool bMenuBar, Menu* pVCLMenu ) override;
121  virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams & rItemData ) override;
122  virtual OpenGLContext* CreateOpenGLContext() override;
123  virtual OUString GetConnectionIdentifier() override;
124  virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType,
125  const OUString& rDocumentService) override;
126 
127  virtual OUString getOSVersion() override;
128 
129  // dtrans implementation
130  virtual css::uno::Reference< css::uno::XInterface > CreateClipboard(
131  const css::uno::Sequence< css::uno::Any >& i_rArguments ) override;
132  virtual css::uno::Reference< css::uno::XInterface > CreateDragSource() override;
133  virtual css::uno::Reference< css::uno::XInterface > CreateDropTarget() override;
134 
135  static void handleAppDefinedEvent( NSEvent* pEvent );
136 
137  // check whether a particular string is passed on the command line
138  // this is needed to avoid duplicate open events through a) command line and b) NSApp's openFile
139  static bool isOnCommandLine( const OUString& );
140 
141  void delayedSettingsChanged( bool bInvalidate );
142 
143  // Is this the NSAppThread?
144  virtual bool IsMainThread() const override;
145 
146  void startedPrintJob() { mnActivePrintJobs++; }
147  void endedPrintJob() { mnActivePrintJobs--; }
148 
149  // event subtypes for NSApplicationDefined events
150  static const short AppExecuteSVMain = 1;
151  static const short AppStartTimerEvent = 10;
152  static const short YieldWakeupEvent = 20;
153  static const short DispatchTimerEvent = 30;
154 
155  static NSMenu* GetDynamicDockMenu();
156 };
157 
158 CGImageRef CreateCGImage( const Image& );
159 NSImage* CreateNSImage( const Image& );
160 
161 #endif // INCLUDED_VCL_INC_OSX_SALINST_H
162 
163 /* 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 &)
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
long Long
virtual void AfterAppInit() override
static void handleAppDefinedEvent(NSEvent *pEvent)
void startedPrintJob()
Definition: osx/salinst.h:146
virtual std::unique_ptr< SalMenuItem > CreateMenuItem(const SalItemParams &rItemData) override
OUString maDefaultPrinter
Definition: osx/salinst.h:80
virtual SalSystem * CreateSalSystem() override
An application can be notified of a number of different events:
Definition: svapp.hxx:115
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:89
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:51
virtual void ProcessEvent(SalUserEvent aEvent) override
void endedPrintJob()
Definition: osx/salinst.h:147
virtual bool IsCurrentThread() const override
osl::Condition maWaitingYieldCond
Definition: osx/salinst.h:84
static bool isOnCommandLine(const OUString &)
virtual std::unique_ptr< SalVirtualDevice > CreateVirtualDevice(SalGraphics *pGraphics, tools::Long &nDX, tools::Long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData=nullptr) override
virtual void TriggerUserEventProcessing() override
static const short DispatchTimerEvent
Definition: osx/salinst.h:153
virtual SalFrame * CreateFrame(SalFrame *pParent, SalFrameStyleFlags nStyle) override
virtual OUString GetConnectionIdentifier() override
static const short AppStartTimerEvent
Definition: osx/salinst.h:151
virtual sal_uInt32 doRelease(bool bUnlockAll) override
SalEvent
Definition: salwtype.hxx:41
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:152
Definition: menu.hxx:123
virtual SalInfoPrinter * CreateInfoPrinter(SalPrinterQueueInfo *pQueueInfo, ImplJobSetup *pSetupData) override
static NSMenu * GetDynamicDockMenu()
bool mbTimerProcessed
Definition: osx/salinst.h:87
virtual ~SalYieldMutex() override
virtual css::uno::Reference< css::uno::XInterface > CreateDragSource() override
SalFrameStyleFlags
Definition: salframe.hxx:64
Definition: image.hxx:39
virtual SalObject * CreateObject(SalFrame *pParent, SystemWindowData *pWindowData, bool bShow) override
virtual void GetPrinterQueueState(SalPrinterQueueInfo *pInfo) override
osl::Mutex maUserEventListMutex
Definition: osx/salinst.h:83
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:81
virtual OpenGLContext * CreateOpenGLContext() override
virtual bool AnyInput(VclInputFlags nType) override
static const short AppExecuteSVMain
Definition: osx/salinst.h:150
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo