Kaydet (Commit) 10517629 authored tarafından Michael Meeks's avatar Michael Meeks

generic: factor out generic display code, reducing cut+paste+bug

üst 6297a9c4
...@@ -266,6 +266,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ ...@@ -266,6 +266,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/window/wrkwin \ vcl/source/window/wrkwin \
vcl/generic/app/gensys \ vcl/generic/app/gensys \
vcl/generic/app/geninst \ vcl/generic/app/geninst \
vcl/generic/app/gendisp \
vcl/generic/print/bitmap_gfx \ vcl/generic/print/bitmap_gfx \
vcl/generic/print/common_gfx \ vcl/generic/print/common_gfx \
vcl/generic/print/glyphset \ vcl/generic/print/glyphset \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_vcl.hxx"
#include <salframe.hxx>
#include <generic/gendisp.hxx>
#include <generic/geninst.h>
using ::rtl::OUString;
SalGenericDisplay::SalGenericDisplay()
{
m_pCapture = NULL;
m_aEventGuard = osl_createMutex();
}
SalGenericDisplay::~SalGenericDisplay()
{
if (m_aEventGuard)
osl_destroyMutex( m_aEventGuard );
m_aEventGuard = NULL;
}
void SalGenericDisplay::registerFrame( SalFrame* pFrame )
{
m_aFrames.push_front( pFrame );
}
void SalGenericDisplay::deregisterFrame( SalFrame* pFrame )
{
if( osl_acquireMutex( m_aEventGuard ) )
{
std::list< SalUserEvent >::iterator it = m_aUserEvents.begin();
while ( it != m_aUserEvents.end() )
{
if( it->m_pFrame == pFrame )
it = m_aUserEvents.erase( it );
else
++it;
}
osl_releaseMutex( m_aEventGuard );
}
else
OSL_FAIL( "SalGenericDisplay::deregisterFrame !acquireMutex\n" );
m_aFrames.remove( pFrame );
}
bool SalGenericDisplay::DispatchInternalEvent()
{
void* pData = NULL;
SalFrame* pFrame = NULL;
sal_uInt16 nEvent = 0;
if( osl_acquireMutex( m_aEventGuard ) )
{
if( m_aUserEvents.begin() != m_aUserEvents.end() )
{
pFrame = m_aUserEvents.front().m_pFrame;
pData = m_aUserEvents.front().m_pData;
nEvent = m_aUserEvents.front().m_nEvent;
m_aUserEvents.pop_front();
}
osl_releaseMutex( m_aEventGuard );
}
else
OSL_FAIL( "SalGenericDisplay::Yield !acquireMutex\n" );
if( pFrame )
pFrame->CallCallback( nEvent, pData );
return pFrame != NULL;
}
void SalGenericDisplay::SendInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
{
if( osl_acquireMutex( m_aEventGuard ) )
{
m_aUserEvents.push_back( SalUserEvent( pFrame, pData, nEvent ) );
PostUserEvent(); // wakeup the concrete mainloop
osl_releaseMutex( m_aEventGuard );
}
else
OSL_FAIL( "SalGenericDisplay::SendInternalEvent !acquireMutex\n" );
}
void SalGenericDisplay::CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
{
if( osl_acquireMutex( m_aEventGuard ) )
{
if( ! m_aUserEvents.empty() )
{
std::list< SalUserEvent >::iterator it, next;
next = m_aUserEvents.begin();
do
{
it = next++;
if( it->m_pFrame == pFrame &&
it->m_pData == pData &&
it->m_nEvent == nEvent )
{
m_aUserEvents.erase( it );
}
} while( next != m_aUserEvents.end() );
}
osl_releaseMutex( m_aEventGuard );
}
else
OSL_FAIL( "SalGenericDisplay::CancelInternalEvent !acquireMutex\n" );
}
bool SalGenericDisplay::HasUserEvents() const
{
bool bRet = false;
if( osl_acquireMutex( m_aEventGuard ) )
{
if( m_aUserEvents.begin() != m_aUserEvents.end() )
bRet = true;
osl_releaseMutex( m_aEventGuard );
}
return bRet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _VCL_GEN_DISP_HXX
#define _VCL_GEN_DISP_HXX
#include <sal/types.h>
#include <osl/mutex.h>
#include <osl/conditn.hxx>
#include <salwtype.hxx>
#include <vcl/dllapi.h>
#include <tools/gen.hxx>
#include <list>
#include <vector>
class SalFrame;
class VCL_DLLPUBLIC SalGenericDisplay
{
oslMutex m_aEventGuard;
struct SalUserEvent
{
SalFrame* m_pFrame;
void* m_pData;
sal_uInt16 m_nEvent;
SalUserEvent( SalFrame* pFrame, void* pData,
sal_uInt16 nEvent )
: m_pFrame( pFrame ),
m_pData( pData ),
m_nEvent( nEvent )
{}
};
std::list< SalUserEvent > m_aUserEvents;
protected:
SalFrame* m_pCapture;
std::list<SalFrame*> m_aFrames;
public:
SalGenericDisplay();
virtual ~SalGenericDisplay();
inline void EventGuardAcquire() { osl_acquireMutex( m_aEventGuard ); }
inline void EventGuardRelease() { osl_releaseMutex( m_aEventGuard ); }
virtual void registerFrame( SalFrame* pFrame );
virtual void deregisterFrame( SalFrame* pFrame );
// Event handling
virtual void PostUserEvent() = 0;
virtual void SendInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent = SALEVENT_USEREVENT );
virtual void CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent );
virtual bool DispatchInternalEvent();
bool HasUserEvents() const;
sal_Bool MouseCaptured( const SalFrame *pFrameData ) const
{ return m_pCapture == pFrameData; }
SalFrame* GetCaptureFrame() const
{ return m_pCapture; }
};
#endif // _VCL_GEN_DISP_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
static gboolean userEventFn( gpointer data ); static gboolean userEventFn( gpointer data );
void PostUserEvent(); virtual void PostUserEvent();
void Yield( bool bWait, bool bHandleAllCurrentEvents ); void Yield( bool bWait, bool bHandleAllCurrentEvents );
GtkSalDisplay *GetDisplay() { return m_pGtkSalDisplay; } GtkSalDisplay *GetDisplay() { return m_pGtkSalDisplay; }
inline GdkDisplay *GetGdkDisplay(); inline GdkDisplay *GetGdkDisplay();
...@@ -121,7 +121,7 @@ inline GtkData* GetGtkSalData() ...@@ -121,7 +121,7 @@ inline GtkData* GetGtkSalData()
class GtkSalFrame; class GtkSalFrame;
#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0)
class GtkSalDisplay class GtkSalDisplay : public SalGenericDisplay
#else #else
class GtkSalDisplay : public SalDisplay class GtkSalDisplay : public SalDisplay
#endif #endif
...@@ -139,7 +139,6 @@ public: ...@@ -139,7 +139,6 @@ public:
GdkDisplay* GetGdkDisplay() const { return m_pGdkDisplay; } GdkDisplay* GetGdkDisplay() const { return m_pGdkDisplay; }
virtual void registerFrame( SalFrame* pFrame );
virtual void deregisterFrame( SalFrame* pFrame ); virtual void deregisterFrame( SalFrame* pFrame );
GdkCursor *getCursor( PointerStyle ePointerStyle ); GdkCursor *getCursor( PointerStyle ePointerStyle );
virtual int CaptureMouse( SalFrame* pFrame ); virtual int CaptureMouse( SalFrame* pFrame );
...@@ -160,38 +159,11 @@ public: ...@@ -160,38 +159,11 @@ public:
void errorTrapPush(); void errorTrapPush();
void errorTrapPop(); void errorTrapPop();
inline bool HasMoreEvents() { return m_aUserEvents.size() > 1; } virtual void PostUserEvent();
inline void EventGuardAcquire() { osl_acquireMutex( hEventGuard_ ); }
inline void EventGuardRelease() { osl_releaseMutex( hEventGuard_ ); }
#if !GTK_CHECK_VERSION(3,0,0) #if !GTK_CHECK_VERSION(3,0,0)
virtual long Dispatch( XEvent *pEvent ); virtual long Dispatch( XEvent *pEvent );
#else #else
void SendInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent = SALEVENT_USEREVENT );
void CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent );
bool DispatchInternalEvent();
SalFrame *m_pCapture;
sal_Bool MouseCaptured( const SalFrame *pFrameData ) const
{ return m_pCapture == pFrameData; }
SalFrame* GetCaptureFrame() const
{ return m_pCapture; }
struct SalUserEvent
{
SalFrame* m_pFrame;
void* m_pData;
sal_uInt16 m_nEvent;
SalUserEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent = SALEVENT_USEREVENT )
: m_pFrame( pFrame ),
m_pData( pData ),
m_nEvent( nEvent )
{}
};
oslMutex hEventGuard_;
std::list< SalUserEvent > m_aUserEvents;
guint32 GetLastUserEventTime( bool /* b */ ) { return GDK_CURRENT_TIME; } // horrible hack guint32 GetLastUserEventTime( bool /* b */ ) { return GDK_CURRENT_TIME; } // horrible hack
#endif #endif
}; };
......
...@@ -46,6 +46,7 @@ class SalXLib; ...@@ -46,6 +46,7 @@ class SalXLib;
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#include <tools/gen.hxx> #include <tools/gen.hxx>
#include <salwtype.hxx> #include <salwtype.hxx>
#include <generic/gendisp.hxx>
#include <vclpluginapi.h> #include <vclpluginapi.h>
...@@ -266,7 +267,7 @@ extern "C" { ...@@ -266,7 +267,7 @@ extern "C" {
typedef Bool(*X_if_predicate)(Display*,XEvent*,XPointer); typedef Bool(*X_if_predicate)(Display*,XEvent*,XPointer);
} }
class VCLPLUG_GEN_PUBLIC SalDisplay class VCLPLUG_GEN_PUBLIC SalDisplay : public SalGenericDisplay
{ {
public: public:
struct RenderEntry struct RenderEntry
...@@ -311,19 +312,6 @@ public: ...@@ -311,19 +312,6 @@ public:
m_aRenderData( 1 ) m_aRenderData( 1 )
{} {}
}; };
// -=-= UserEvent =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
struct SalUserEvent
{
SalFrame* m_pFrame;
void* m_pData;
sal_uInt16 m_nEvent;
SalUserEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent = SALEVENT_USEREVENT )
: m_pFrame( pFrame ),
m_pData( pData ),
m_nEvent( nEvent )
{}
};
protected: protected:
SalXLib *pXLib_; SalXLib *pXLib_;
...@@ -347,11 +335,7 @@ protected: ...@@ -347,11 +335,7 @@ protected:
sal_Bool mbLocalIsValid; // bLocal_ is valid ? sal_Bool mbLocalIsValid; // bLocal_ is valid ?
// until x bytes // until x bytes
oslMutex hEventGuard_;
std::list< SalUserEvent > m_aUserEvents;
XLIB_Cursor aPointerCache_[POINTER_COUNT]; XLIB_Cursor aPointerCache_[POINTER_COUNT];
SalFrame* m_pCapture;
// Keyboard // Keyboard
sal_Bool bNumLockFromXS_; // Num Lock handled by X Server sal_Bool bNumLockFromXS_; // Num Lock handled by X Server
...@@ -392,19 +376,12 @@ public: ...@@ -392,19 +376,12 @@ public:
virtual ~SalDisplay(); virtual ~SalDisplay();
virtual void registerFrame( SalFrame* pFrame );
virtual void deregisterFrame( SalFrame* pFrame );
void setHaveSystemChildFrame() const void setHaveSystemChildFrame() const
{ pXLib_->setHaveSystemChildFrame(); } { pXLib_->setHaveSystemChildFrame(); }
bool getHaveSystemChildFrame() const bool getHaveSystemChildFrame() const
{ return pXLib_->getHaveSystemChildFrame(); } { return pXLib_->getHaveSystemChildFrame(); }
void Init(); void Init();
void SendInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent = SALEVENT_USEREVENT );
void CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent );
bool DispatchInternalEvent();
void PrintInfo() const; void PrintInfo() const;
#ifdef DBG_UTIL #ifdef DBG_UTIL
...@@ -468,11 +445,6 @@ public: ...@@ -468,11 +445,6 @@ public:
XLIB_Time GetLastUserEventTime( bool bAlwaysReget = false ) const; XLIB_Time GetLastUserEventTime( bool bAlwaysReget = false ) const;
bool XIfEventWithTimeout( XEvent*, XPointer, X_if_predicate, long i_nTimeout = 1000 ) const; bool XIfEventWithTimeout( XEvent*, XPointer, X_if_predicate, long i_nTimeout = 1000 ) const;
sal_Bool MouseCaptured( const SalFrame *pFrameData ) const
{ return m_pCapture == pFrameData; }
SalFrame* GetCaptureFrame() const
{ return m_pCapture; }
SalXLib* GetXLib() const { return pXLib_; } SalXLib* GetXLib() const { return pXLib_; }
SalI18N_InputMethod* GetInputMethod() const { return mpInputMethod; } SalI18N_InputMethod* GetInputMethod() const { return mpInputMethod; }
...@@ -497,6 +469,8 @@ public: ...@@ -497,6 +469,8 @@ public:
sal_Bool IsNumLockFromXS() const { return bNumLockFromXS_; } sal_Bool IsNumLockFromXS() const { return bNumLockFromXS_; }
std::list< SalObject* >& getSalObjects() { return m_aSalObjects; } std::list< SalObject* >& getSalObjects() { return m_aSalObjects; }
virtual void PostUserEvent();
}; };
// -=-= inlines =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-= inlines =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
......
...@@ -537,10 +537,6 @@ void SalDisplay::doDestruct() ...@@ -537,10 +537,6 @@ void SalDisplay::doDestruct()
delete mpInputMethod, mpInputMethod = (SalI18N_InputMethod*)ILLEGAL_POINTER; delete mpInputMethod, mpInputMethod = (SalI18N_InputMethod*)ILLEGAL_POINTER;
delete mpKbdExtension, mpKbdExtension = (SalI18N_KeyboardExtension*)ILLEGAL_POINTER; delete mpKbdExtension, mpKbdExtension = (SalI18N_KeyboardExtension*)ILLEGAL_POINTER;
// do not call anything that could implicitly call back into
// this object after this point
osl_destroyMutex( hEventGuard_ );
for( unsigned int i = 0; i < m_aScreens.size(); i++ ) for( unsigned int i = 0; i < m_aScreens.size(); i++ )
{ {
ScreenData& rData = m_aScreens[i]; ScreenData& rData = m_aScreens[i];
...@@ -561,8 +557,6 @@ void SalDisplay::doDestruct() ...@@ -561,8 +557,6 @@ void SalDisplay::doDestruct()
} }
} }
hEventGuard_ = (oslMutex)ILLEGAL_POINTER;
for( size_t i = 0; i < POINTER_COUNT; i++ ) for( size_t i = 0; i < POINTER_COUNT; i++ )
{ {
if( aPointerCache_[i] ) if( aPointerCache_[i] )
...@@ -780,9 +774,7 @@ void SalDisplay::Init() ...@@ -780,9 +774,7 @@ void SalDisplay::Init()
aPointerCache_[i] = None; aPointerCache_[i] = None;
eWindowManager_ = otherwm; eWindowManager_ = otherwm;
hEventGuard_ = NULL;
mpFactory = (AttributeProvider*)NULL; mpFactory = (AttributeProvider*)NULL;
m_pCapture = NULL;
m_bXinerama = false; m_bXinerama = false;
int nDisplayScreens = ScreenCount( pDisp_ ); int nDisplayScreens = ScreenCount( pDisp_ );
...@@ -819,7 +811,6 @@ void SalDisplay::Init() ...@@ -819,7 +811,6 @@ void SalDisplay::Init()
SetServerVendor(); SetServerVendor();
X11SalBitmap::ImplCreateCache(); X11SalBitmap::ImplCreateCache();
hEventGuard_ = osl_createMutex();
bLocal_ = sal_False; /* dont care, initialize later by bLocal_ = sal_False; /* dont care, initialize later by
calling SalDisplay::IsLocal() */ calling SalDisplay::IsLocal() */
mbLocalIsValid = sal_False; /* bLocal_ is not yet initialized */ mbLocalIsValid = sal_False; /* bLocal_ is not yet initialized */
...@@ -2064,97 +2055,15 @@ int SalDisplay::CaptureMouse( SalFrame *pCapture ) ...@@ -2064,97 +2055,15 @@ int SalDisplay::CaptureMouse( SalFrame *pCapture )
// Events // Events
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void SalDisplay::SendInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
{
if( osl_acquireMutex( hEventGuard_ ) )
{
m_aUserEvents.push_back( SalUserEvent( pFrame, pData, nEvent ) );
// Notify SalXLib::Yield() of a pending event.
pXLib_->PostUserEvent();
osl_releaseMutex( hEventGuard_ );
}
else {
DBG_ASSERT( 1, "SalDisplay::SendInternalEvent !acquireMutex\n" );
}
}
void SalDisplay::CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
{
if( osl_acquireMutex( hEventGuard_ ) )
{
if( ! m_aUserEvents.empty() )
{
std::list< SalUserEvent >::iterator it, next;
next = m_aUserEvents.begin();
do
{
it = next++;
if( it->m_pFrame == pFrame &&
it->m_pData == pData &&
it->m_nEvent == nEvent )
{
m_aUserEvents.erase( it );
}
} while( next != m_aUserEvents.end() );
}
osl_releaseMutex( hEventGuard_ );
}
else {
DBG_ASSERT( 1, "SalDisplay::CancelInternalEvent !acquireMutex\n" );
}
}
sal_Bool SalX11Display::IsEvent() sal_Bool SalX11Display::IsEvent()
{ {
sal_Bool bRet = sal_False; if( HasUserEvents() || XEventsQueued( pDisp_, QueuedAlready ) )
if( osl_acquireMutex( hEventGuard_ ) )
{
if( m_aUserEvents.begin() != m_aUserEvents.end() )
bRet = sal_True;
osl_releaseMutex( hEventGuard_ );
}
if( bRet || XEventsQueued( pDisp_, QueuedAlready ) )
return sal_True; return sal_True;
XFlush( pDisp_ ); XFlush( pDisp_ );
return sal_False; return sal_False;
} }
bool SalDisplay::DispatchInternalEvent()
{
SalFrame* pFrame = NULL;
void* pData = NULL;
sal_uInt16 nEvent = 0;
if( osl_acquireMutex( hEventGuard_ ) )
{
if( m_aUserEvents.begin() != m_aUserEvents.end() )
{
pFrame = m_aUserEvents.front().m_pFrame;
pData = m_aUserEvents.front().m_pData;
nEvent = m_aUserEvents.front().m_nEvent;
m_aUserEvents.pop_front();
}
osl_releaseMutex( hEventGuard_ );
}
else {
DBG_ASSERT( 1, "SalDisplay::Yield !acquireMutex\n" );
}
if( pFrame )
pFrame->CallCallback( nEvent, pData );
return pFrame != NULL;
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void SalX11Display::Yield() void SalX11Display::Yield()
{ {
if( DispatchInternalEvent() ) if( DispatchInternalEvent() )
...@@ -2581,32 +2490,6 @@ if( XineramaIsActive( pDisp_ ) ) ...@@ -2581,32 +2490,6 @@ if( XineramaIsActive( pDisp_ ) )
#endif // USE_XINERAMA #endif // USE_XINERAMA
} }
void SalDisplay::registerFrame( SalFrame* pFrame )
{
m_aFrames.push_front( pFrame );
}
void SalDisplay::deregisterFrame( SalFrame* pFrame )
{
if( osl_acquireMutex( hEventGuard_ ) )
{
std::list< SalUserEvent >::iterator it = m_aUserEvents.begin();
while ( it != m_aUserEvents.end() )
{
if( it->m_pFrame == pFrame )
it = m_aUserEvents.erase( it );
else
++it;
}
osl_releaseMutex( hEventGuard_ );
}
else {
OSL_FAIL( "SalDisplay::deregisterFrame !acquireMutex\n" );
}
m_aFrames.remove( pFrame );
}
extern "C" extern "C"
{ {
...@@ -3260,4 +3143,10 @@ Pixel SalColormap::GetPixel( SalColor nSalColor ) const ...@@ -3260,4 +3143,10 @@ Pixel SalColormap::GetPixel( SalColor nSalColor ) const
+ ((b+8)/17) ]; + ((b+8)/17) ];
} }
void SalDisplay::PostUserEvent()
{
if( pXLib_ )
pXLib_->PostUserEvent();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -91,13 +91,9 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) : ...@@ -91,13 +91,9 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) :
{ {
for(int i = 0; i < POINTER_COUNT; i++) for(int i = 0; i < POINTER_COUNT; i++)
m_aCursors[ i ] = NULL; m_aCursors[ i ] = NULL;
#if GTK_CHECK_VERSION(3,0,0) #if !GTK_CHECK_VERSION(3,0,0)
m_pCapture = NULL;
hEventGuard_ = osl_createMutex();
#else
m_bUseRandRWrapper = false; // use gdk signal instead m_bUseRandRWrapper = false; // use gdk signal instead
Init (); Init ();
hEventGuard_ = NULL;
#endif #endif
gdk_window_add_filter( NULL, call_filterGdkEvent, this ); gdk_window_add_filter( NULL, call_filterGdkEvent, this );
...@@ -121,10 +117,6 @@ GtkSalDisplay::~GtkSalDisplay() ...@@ -121,10 +117,6 @@ GtkSalDisplay::~GtkSalDisplay()
for(int i = 0; i < POINTER_COUNT; i++) for(int i = 0; i < POINTER_COUNT; i++)
if( m_aCursors[ i ] ) if( m_aCursors[ i ] )
gdk_cursor_unref( m_aCursors[ i ] ); gdk_cursor_unref( m_aCursors[ i ] );
if (hEventGuard_)
osl_destroyMutex( hEventGuard_ );
hEventGuard_ = NULL;
} }
void GtkSalDisplay::errorTrapPush() void GtkSalDisplay::errorTrapPush()
...@@ -141,25 +133,6 @@ void GtkSalDisplay::errorTrapPop() ...@@ -141,25 +133,6 @@ void GtkSalDisplay::errorTrapPop()
#endif #endif
} }
void GtkSalDisplay::registerFrame( SalFrame* pFrame )
{
#if !GTK_CHECK_VERSION(3,0,0)
SalDisplay::registerFrame( pFrame );
#endif
}
void GtkSalDisplay::deregisterFrame( SalFrame* pFrame )
{
if( m_pCapture == pFrame )
{
static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( FALSE );
m_pCapture = NULL;
}
#if !GTK_CHECK_VERSION(3,0,0)
SalDisplay::deregisterFrame( pFrame );
#endif
}
extern "C" { extern "C" {
void signalKeysChanged( GdkKeymap*, gpointer data ) void signalKeysChanged( GdkKeymap*, gpointer data )
...@@ -610,7 +583,7 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -610,7 +583,7 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
* fits the vcl event model (see e.g. the generic plugin). * fits the vcl event model (see e.g. the generic plugin).
*/ */
bool bDispatchThread = false; bool bDispatchThread = false;
gboolean wasEvent = FALSE; bool bWasEvent = false;
{ {
// release YieldMutex (and re-acquire at block end) // release YieldMutex (and re-acquire at block end)
YieldMutexReleaser aReleaser; YieldMutexReleaser aReleaser;
...@@ -619,7 +592,6 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -619,7 +592,6 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
else if( ! bWait ) else if( ! bWait )
return; // someone else is waiting already, return return; // someone else is waiting already, return
if( bDispatchThread ) if( bDispatchThread )
{ {
int nMaxEvents = bHandleAllCurrentEvents ? 100 : 1; int nMaxEvents = bHandleAllCurrentEvents ? 100 : 1;
...@@ -628,10 +600,10 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -628,10 +600,10 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
{ {
wasOneEvent = g_main_context_iteration( NULL, FALSE ); wasOneEvent = g_main_context_iteration( NULL, FALSE );
if( wasOneEvent ) if( wasOneEvent )
wasEvent = TRUE; bWasEvent = true;
} }
if( bWait && ! wasEvent ) if( bWait && ! bWasEvent )
wasEvent = g_main_context_iteration( NULL, TRUE ); bWasEvent = g_main_context_iteration( NULL, TRUE ) != 0;
} }
else if( bWait ) else if( bWait )
{ {
...@@ -649,7 +621,7 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -649,7 +621,7 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
if( bDispatchThread ) if( bDispatchThread )
{ {
osl_releaseMutex( m_aDispatchMutex ); osl_releaseMutex( m_aDispatchMutex );
if( wasEvent ) if( bWasEvent )
osl_setCondition( m_aDispatchCondition ); // trigger non dispatch thread yields osl_setCondition( m_aDispatchCondition ); // trigger non dispatch thread yields
} }
} }
...@@ -861,7 +833,7 @@ gboolean GtkData::userEventFn( gpointer data ) ...@@ -861,7 +833,7 @@ gboolean GtkData::userEventFn( gpointer data )
#endif #endif
pThis->m_pGtkSalDisplay->EventGuardAcquire(); pThis->m_pGtkSalDisplay->EventGuardAcquire();
if( !pThis->m_pGtkSalDisplay->HasMoreEvents() ) if( !pThis->m_pGtkSalDisplay->HasUserEvents() )
{ {
if( pThis->m_pUserEvent ) if( pThis->m_pUserEvent )
{ {
...@@ -881,81 +853,6 @@ gboolean GtkData::userEventFn( gpointer data ) ...@@ -881,81 +853,6 @@ gboolean GtkData::userEventFn( gpointer data )
return bContinue; return bContinue;
} }
#if GTK_CHECK_VERSION(3,0,0)
// FIXME: cut/paste from saldisp.cxx - needs some re-factoring love
bool GtkSalDisplay::DispatchInternalEvent()
{
SalFrame* pFrame = NULL;
void* pData = NULL;
sal_uInt16 nEvent = 0;
if( osl_acquireMutex( hEventGuard_ ) )
{
if( m_aUserEvents.begin() != m_aUserEvents.end() )
{
pFrame = m_aUserEvents.front().m_pFrame;
pData = m_aUserEvents.front().m_pData;
nEvent = m_aUserEvents.front().m_nEvent;
m_aUserEvents.pop_front();
}
osl_releaseMutex( hEventGuard_ );
}
else {
DBG_ASSERT( 1, "SalDisplay::Yield !acquireMutex\n" );
}
if( pFrame )
pFrame->CallCallback( nEvent, pData );
return pFrame != NULL;
}
void GtkSalDisplay::SendInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
{
if( osl_acquireMutex( hEventGuard_ ) )
{
m_aUserEvents.push_back( SalUserEvent( pFrame, pData, nEvent ) );
// Notify GtkData::Yield() of a pending event.
GetGtkSalData()->PostUserEvent();
osl_releaseMutex( hEventGuard_ );
}
else {
DBG_ASSERT( 1, "SalDisplay::SendInternalEvent !acquireMutex\n" );
}
}
void GtkSalDisplay::CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
{
if( osl_acquireMutex( hEventGuard_ ) )
{
if( ! m_aUserEvents.empty() )
{
std::list< SalUserEvent >::iterator it, next;
next = m_aUserEvents.begin();
do
{
it = next++;
if( it->m_pFrame == pFrame &&
it->m_pData == pData &&
it->m_nEvent == nEvent )
{
m_aUserEvents.erase( it );
}
} while( next != m_aUserEvents.end() );
}
osl_releaseMutex( hEventGuard_ );
}
else
DBG_ASSERT( 1, "SalDisplay::CancelInternalEvent !acquireMutex\n" );
}
#endif
extern "C" { extern "C" {
static gboolean call_userEventFn( void *data ) static gboolean call_userEventFn( void *data )
{ {
...@@ -979,4 +876,19 @@ void GtkData::PostUserEvent() ...@@ -979,4 +876,19 @@ void GtkData::PostUserEvent()
} }
} }
void GtkSalDisplay::PostUserEvent()
{
GetGtkSalData()->PostUserEvent();
}
void GtkSalDisplay::deregisterFrame( SalFrame* pFrame )
{
if( m_pCapture == pFrame )
{
static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( FALSE );
m_pCapture = NULL;
}
SalGenericDisplay::deregisterFrame( pFrame );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment