1*161f4cd1SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*161f4cd1SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*161f4cd1SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*161f4cd1SAndrew Rist * distributed with this work for additional information 6*161f4cd1SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*161f4cd1SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*161f4cd1SAndrew Rist * "License"); you may not use this file except in compliance 9*161f4cd1SAndrew Rist * with the License. You may obtain a copy of the License at 10*161f4cd1SAndrew Rist * 11*161f4cd1SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*161f4cd1SAndrew Rist * 13*161f4cd1SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*161f4cd1SAndrew Rist * software distributed under the License is distributed on an 15*161f4cd1SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*161f4cd1SAndrew Rist * KIND, either express or implied. See the License for the 17*161f4cd1SAndrew Rist * specific language governing permissions and limitations 18*161f4cd1SAndrew Rist * under the License. 19*161f4cd1SAndrew Rist * 20*161f4cd1SAndrew Rist *************************************************************/ 21*161f4cd1SAndrew Rist 22*161f4cd1SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _VCL_GTKINST_HXX 25cdf0e10cSrcweir #define _VCL_GTKINST_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <unx/salinst.h> 28cdf0e10cSrcweir #include <unx/salsys.h> 29cdf0e10cSrcweir 30cdf0e10cSrcweir class GtkYieldMutex : public SalYieldMutex 31cdf0e10cSrcweir { 32cdf0e10cSrcweir public: 33cdf0e10cSrcweir GtkYieldMutex(); 34cdf0e10cSrcweir virtual void acquire(); 35cdf0e10cSrcweir virtual void release(); 36cdf0e10cSrcweir virtual sal_Bool tryToAcquire(); 37cdf0e10cSrcweir 38cdf0e10cSrcweir virtual int Grab(); 39cdf0e10cSrcweir virtual void Ungrab( int ); 40cdf0e10cSrcweir 41cdf0e10cSrcweir class GtkYieldGuard 42cdf0e10cSrcweir { 43cdf0e10cSrcweir GtkYieldMutex* m_pMutex; 44cdf0e10cSrcweir int m_nGrab; 45cdf0e10cSrcweir public: GtkYieldGuard(GtkYieldMutex * pMutex)46cdf0e10cSrcweir GtkYieldGuard( GtkYieldMutex* pMutex ) 47cdf0e10cSrcweir : m_pMutex( pMutex ) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir m_nGrab = m_pMutex->Grab(); 50cdf0e10cSrcweir } ~GtkYieldGuard()51cdf0e10cSrcweir ~GtkYieldGuard() 52cdf0e10cSrcweir { 53cdf0e10cSrcweir m_pMutex->Ungrab( m_nGrab ); 54cdf0e10cSrcweir } 55cdf0e10cSrcweir }; 56cdf0e10cSrcweir }; 57cdf0e10cSrcweir 58cdf0e10cSrcweir class GtkHookedYieldMutex : public GtkYieldMutex 59cdf0e10cSrcweir { Grab()60cdf0e10cSrcweir virtual int Grab() { return 0; }; Ungrab(int)61cdf0e10cSrcweir virtual void Ungrab(int ) {}; 62cdf0e10cSrcweir std::list<sal_uLong> aYieldStack; 63cdf0e10cSrcweir public: 64cdf0e10cSrcweir GtkHookedYieldMutex(); 65cdf0e10cSrcweir virtual void acquire(); 66cdf0e10cSrcweir virtual void release(); tryToAcquire()67cdf0e10cSrcweir virtual sal_Bool tryToAcquire() { return SalYieldMutex::tryToAcquire(); } 68cdf0e10cSrcweir void ThreadsEnter(); 69cdf0e10cSrcweir void ThreadsLeave(); 70cdf0e10cSrcweir }; 71cdf0e10cSrcweir 72cdf0e10cSrcweir 73cdf0e10cSrcweir #define GTK_YIELD_GRAB() GtkYieldMutex::GtkYieldGuard aLocalGtkYieldGuard( static_cast<GtkYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex()) ) 74cdf0e10cSrcweir 75cdf0e10cSrcweir class GtkInstance : public X11SalInstance 76cdf0e10cSrcweir { 77cdf0e10cSrcweir public: GtkInstance(SalYieldMutex * pMutex)78cdf0e10cSrcweir GtkInstance( SalYieldMutex* pMutex ) 79cdf0e10cSrcweir : X11SalInstance( pMutex ) 80cdf0e10cSrcweir {} 81cdf0e10cSrcweir virtual ~GtkInstance(); 82cdf0e10cSrcweir 83cdf0e10cSrcweir virtual SalFrame* CreateFrame( SalFrame* pParent, sal_uLong nStyle ); 84cdf0e10cSrcweir virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle ); 85cdf0e10cSrcweir virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow = sal_True ); 86cdf0e10cSrcweir virtual SalSystem* CreateSalSystem(); 87cdf0e10cSrcweir virtual void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType); 88cdf0e10cSrcweir }; 89cdf0e10cSrcweir 90cdf0e10cSrcweir class GtkSalSystem : public X11SalSystem 91cdf0e10cSrcweir { 92cdf0e10cSrcweir public: GtkSalSystem()93cdf0e10cSrcweir GtkSalSystem() : X11SalSystem() {} 94cdf0e10cSrcweir virtual ~GtkSalSystem(); 95cdf0e10cSrcweir virtual int ShowNativeDialog( const String& rTitle, 96cdf0e10cSrcweir const String& rMessage, 97cdf0e10cSrcweir const std::list< String >& rButtons, 98cdf0e10cSrcweir int nDefButton ); 99cdf0e10cSrcweir }; 100cdf0e10cSrcweir 101cdf0e10cSrcweir #endif // _VCL_GTKINST_HXX 102