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,\
vcl/source/window/wrkwin \
vcl/generic/app/gensys \
vcl/generic/app/geninst \
vcl/generic/app/gendisp \
vcl/generic/print/bitmap_gfx \
vcl/generic/print/common_gfx \
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:
static gboolean userEventFn( gpointer data );
void PostUserEvent();
virtual void PostUserEvent();
void Yield( bool bWait, bool bHandleAllCurrentEvents );
GtkSalDisplay *GetDisplay() { return m_pGtkSalDisplay; }
inline GdkDisplay *GetGdkDisplay();
......@@ -121,7 +121,7 @@ inline GtkData* GetGtkSalData()
class GtkSalFrame;
#if GTK_CHECK_VERSION(3,0,0)
class GtkSalDisplay
class GtkSalDisplay : public SalGenericDisplay
#else
class GtkSalDisplay : public SalDisplay
#endif
......@@ -139,7 +139,6 @@ public:
GdkDisplay* GetGdkDisplay() const { return m_pGdkDisplay; }
virtual void registerFrame( SalFrame* pFrame );
virtual void deregisterFrame( SalFrame* pFrame );
GdkCursor *getCursor( PointerStyle ePointerStyle );
virtual int CaptureMouse( SalFrame* pFrame );
......@@ -160,38 +159,11 @@ public:
void errorTrapPush();
void errorTrapPop();
inline bool HasMoreEvents() { return m_aUserEvents.size() > 1; }
inline void EventGuardAcquire() { osl_acquireMutex( hEventGuard_ ); }
inline void EventGuardRelease() { osl_releaseMutex( hEventGuard_ ); }
virtual void PostUserEvent();
#if !GTK_CHECK_VERSION(3,0,0)
virtual long Dispatch( XEvent *pEvent );
#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
#endif
};
......
......@@ -46,6 +46,7 @@ class SalXLib;
#include <boost/unordered_map.hpp>
#include <tools/gen.hxx>
#include <salwtype.hxx>
#include <generic/gendisp.hxx>
#include <vclpluginapi.h>
......@@ -222,11 +223,11 @@ protected:
public:
SalXLib();
virtual ~SalXLib();
virtual void Init();
virtual void Init();
virtual void Yield( bool bWait, bool bHandleAllCurrentEvents );
virtual void Wakeup();
virtual void PostUserEvent();
virtual void Yield( bool bWait, bool bHandleAllCurrentEvents );
virtual void Wakeup();
virtual void PostUserEvent();
virtual void Insert( int fd, void* data,
YieldFunc pending,
......@@ -266,7 +267,7 @@ extern "C" {
typedef Bool(*X_if_predicate)(Display*,XEvent*,XPointer);
}
class VCLPLUG_GEN_PUBLIC SalDisplay
class VCLPLUG_GEN_PUBLIC SalDisplay : public SalGenericDisplay
{
public:
struct RenderEntry
......@@ -311,19 +312,6 @@ public:
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:
SalXLib *pXLib_;
......@@ -338,7 +326,7 @@ protected:
ScreenData m_aInvalidScreenData;
Pair aResolution_; // [dpi]
bool mbExactResolution;
sal_uLong nMaxRequestSize_; // [byte]
sal_uLong nMaxRequestSize_; // [byte]
srv_vendor_t meServerVendor;
SalWM eWindowManager_;
......@@ -347,14 +335,10 @@ protected:
sal_Bool mbLocalIsValid; // bLocal_ is valid ?
// until x bytes
oslMutex hEventGuard_;
std::list< SalUserEvent > m_aUserEvents;
XLIB_Cursor aPointerCache_[POINTER_COUNT];
SalFrame* m_pCapture;
// Keyboard
sal_Bool bNumLockFromXS_; // Num Lock handled by X Server
sal_Bool bNumLockFromXS_; // Num Lock handled by X Server
int nNumLockIndex_; // modifier index in modmap
int nNumLockMask_; // keyevent state mask for
KeySym nShiftKeySym_; // first shift modifier
......@@ -392,19 +376,12 @@ public:
virtual ~SalDisplay();
virtual void registerFrame( SalFrame* pFrame );
virtual void deregisterFrame( SalFrame* pFrame );
void setHaveSystemChildFrame() const
{ pXLib_->setHaveSystemChildFrame(); }
bool getHaveSystemChildFrame() const
{ return pXLib_->getHaveSystemChildFrame(); }
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;
#ifdef DBG_UTIL
......@@ -468,11 +445,6 @@ public:
XLIB_Time GetLastUserEventTime( bool bAlwaysReget = false ) 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_; }
SalI18N_InputMethod* GetInputMethod() const { return mpInputMethod; }
......@@ -497,6 +469,8 @@ public:
sal_Bool IsNumLockFromXS() const { return bNumLockFromXS_; }
std::list< SalObject* >& getSalObjects() { return m_aSalObjects; }
virtual void PostUserEvent();
};
// -=-= inlines =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
......
......@@ -537,10 +537,6 @@ void SalDisplay::doDestruct()
delete mpInputMethod, mpInputMethod = (SalI18N_InputMethod*)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++ )
{
ScreenData& rData = m_aScreens[i];
......@@ -561,8 +557,6 @@ void SalDisplay::doDestruct()
}
}
hEventGuard_ = (oslMutex)ILLEGAL_POINTER;
for( size_t i = 0; i < POINTER_COUNT; i++ )
{
if( aPointerCache_[i] )
......@@ -780,9 +774,7 @@ void SalDisplay::Init()
aPointerCache_[i] = None;
eWindowManager_ = otherwm;
hEventGuard_ = NULL;
mpFactory = (AttributeProvider*)NULL;
m_pCapture = NULL;
m_bXinerama = false;
int nDisplayScreens = ScreenCount( pDisp_ );
......@@ -819,7 +811,6 @@ void SalDisplay::Init()
SetServerVendor();
X11SalBitmap::ImplCreateCache();
hEventGuard_ = osl_createMutex();
bLocal_ = sal_False; /* dont care, initialize later by
calling SalDisplay::IsLocal() */
mbLocalIsValid = sal_False; /* bLocal_ is not yet initialized */
......@@ -2064,97 +2055,15 @@ int SalDisplay::CaptureMouse( SalFrame *pCapture )
// 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 bRet = sal_False;
if( osl_acquireMutex( hEventGuard_ ) )
{
if( m_aUserEvents.begin() != m_aUserEvents.end() )
bRet = sal_True;
osl_releaseMutex( hEventGuard_ );
}
if( bRet || XEventsQueued( pDisp_, QueuedAlready ) )
if( HasUserEvents() || XEventsQueued( pDisp_, QueuedAlready ) )
return sal_True;
XFlush( pDisp_ );
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()
{
if( DispatchInternalEvent() )
......@@ -2581,32 +2490,6 @@ if( XineramaIsActive( pDisp_ ) )
#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"
{
......@@ -3260,4 +3143,10 @@ Pixel SalColormap::GetPixel( SalColor nSalColor ) const
+ ((b+8)/17) ];
}
void SalDisplay::PostUserEvent()
{
if( pXLib_ )
pXLib_->PostUserEvent();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -91,13 +91,9 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) :
{
for(int i = 0; i < POINTER_COUNT; i++)
m_aCursors[ i ] = NULL;
#if GTK_CHECK_VERSION(3,0,0)
m_pCapture = NULL;
hEventGuard_ = osl_createMutex();
#else
#if !GTK_CHECK_VERSION(3,0,0)
m_bUseRandRWrapper = false; // use gdk signal instead
Init ();
hEventGuard_ = NULL;
#endif
gdk_window_add_filter( NULL, call_filterGdkEvent, this );
......@@ -121,10 +117,6 @@ GtkSalDisplay::~GtkSalDisplay()
for(int i = 0; i < POINTER_COUNT; i++)
if( m_aCursors[ i ] )
gdk_cursor_unref( m_aCursors[ i ] );
if (hEventGuard_)
osl_destroyMutex( hEventGuard_ );
hEventGuard_ = NULL;
}
void GtkSalDisplay::errorTrapPush()
......@@ -141,25 +133,6 @@ void GtkSalDisplay::errorTrapPop()
#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" {
void signalKeysChanged( GdkKeymap*, gpointer data )
......@@ -610,7 +583,7 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
* fits the vcl event model (see e.g. the generic plugin).
*/
bool bDispatchThread = false;
gboolean wasEvent = FALSE;
bool bWasEvent = false;
{
// release YieldMutex (and re-acquire at block end)
YieldMutexReleaser aReleaser;
......@@ -619,7 +592,6 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
else if( ! bWait )
return; // someone else is waiting already, return
if( bDispatchThread )
{
int nMaxEvents = bHandleAllCurrentEvents ? 100 : 1;
......@@ -628,13 +600,13 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
{
wasOneEvent = g_main_context_iteration( NULL, FALSE );
if( wasOneEvent )
wasEvent = TRUE;
bWasEvent = true;
}
if( bWait && ! wasEvent )
wasEvent = g_main_context_iteration( NULL, TRUE );
if( bWait && ! bWasEvent )
bWasEvent = g_main_context_iteration( NULL, TRUE ) != 0;
}
else if( bWait )
{
{
/* #i41693# in case the dispatch thread hangs in join
* for this thread the condition will never be set
* workaround: timeout of 1 second a emergency exit
......@@ -649,7 +621,7 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
if( bDispatchThread )
{
osl_releaseMutex( m_aDispatchMutex );
if( wasEvent )
if( bWasEvent )
osl_setCondition( m_aDispatchCondition ); // trigger non dispatch thread yields
}
}
......@@ -861,7 +833,7 @@ gboolean GtkData::userEventFn( gpointer data )
#endif
pThis->m_pGtkSalDisplay->EventGuardAcquire();
if( !pThis->m_pGtkSalDisplay->HasMoreEvents() )
if( !pThis->m_pGtkSalDisplay->HasUserEvents() )
{
if( pThis->m_pUserEvent )
{
......@@ -881,81 +853,6 @@ gboolean GtkData::userEventFn( gpointer data )
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" {
static gboolean call_userEventFn( void *data )
{
......@@ -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: */
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