summaryrefslogtreecommitdiff
path: root/vcl/unx/generic
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2011-10-03 16:36:26 +0100
committerMichael Meeks <michael.meeks@suse.com>2011-10-25 13:41:52 +0100
commitc529623457889a67473f773d080941903e2784fc (patch)
treea8a41cbb19a3063d10c22db8e6fe6d5dddc5960b /vcl/unx/generic
parentf88ff49c733392e66dd178928efa3d807f2cffca (diff)
generic: re-work X error push/pop and error message handling
Diffstat (limited to 'vcl/unx/generic')
-rw-r--r--vcl/unx/generic/app/i18n_status.cxx10
-rw-r--r--vcl/unx/generic/app/saldata.cxx155
-rw-r--r--vcl/unx/generic/app/saldisp.cxx25
-rw-r--r--vcl/unx/generic/app/wmadaptor.cxx166
-rw-r--r--vcl/unx/generic/gdi/salbmp.cxx5
-rw-r--r--vcl/unx/generic/gdi/salgdi2.cxx7
-rw-r--r--vcl/unx/generic/window/salframe.cxx40
-rw-r--r--vcl/unx/generic/window/salobj.cxx17
8 files changed, 227 insertions, 198 deletions
diff --git a/vcl/unx/generic/app/i18n_status.cxx b/vcl/unx/generic/app/i18n_status.cxx
index e2fcdae113c7..d99894c6955d 100644
--- a/vcl/unx/generic/app/i18n_status.cxx
+++ b/vcl/unx/generic/app/i18n_status.cxx
@@ -468,15 +468,14 @@ void IIIMPStatusWindow::GetFocus()
if( it != rFrames.end() )
{
const SystemEnvData* pParentEnvData = m_pResetFocus->GetSystemData();
- SalXLib* pXLib = GetGenericData()->GetSalDisplay()->GetXLib();
- pXLib->PushXErrorLevel( true );
+ GetGenericData()->ErrorTrapPush();
XSetInputFocus( (Display*)pParentEnvData->pDisplay,
(XLIB_Window)pParentEnvData->aShellWindow,
RevertToNone,
CurrentTime
);
XSync( (Display*)pParentEnvData->pDisplay, False );
- pXLib->PopXErrorLevel();
+ GetGenericData()->ErrorTrapPop();
}
m_pResetFocus = NULL;
}
@@ -501,15 +500,14 @@ IMPL_LINK( IIIMPStatusWindow, SelectHdl, MenuButton*, pBtn )
if( pParent && pParent->isMapped() )
{
const SystemEnvData* pEnv = pParent->GetSystemData();
- SalXLib* pXLib = GetGenericData()->GetSalDisplay()->GetXLib();
- pXLib->PushXErrorLevel( true );
+ GetGenericData()->ErrorTrapPush();
XSetInputFocus( (Display*)pEnv->pDisplay,
(XLIB_Window)pEnv->aShellWindow,
RevertToNone,
CurrentTime
);
XSync( (Display*)pEnv->pDisplay, False );
- pXLib->PopXErrorLevel();
+ GetGenericData()->ErrorTrapPop();
}
}
}
diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx
index 940dc22b0517..4b235a4f7ac6 100644
--- a/vcl/unx/generic/app/saldata.cxx
+++ b/vcl/unx/generic/app/saldata.cxx
@@ -232,43 +232,6 @@ static const char* XRequest[] = {
"X_NoOperation"
};
-// -=-= C statics =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-int X11SalData::XErrorHdl( Display *pDisplay, XErrorEvent *pEvent )
-{
- OSL_ASSERT( GetX11SalData()->GetType() != SAL_DATA_GTK );
-
- GetX11SalData()->XError( pDisplay, pEvent );
- return 0;
-}
-
-int X11SalData::XIOErrorHdl( Display * )
-{
- OSL_ASSERT( GetX11SalData()->GetType() != SAL_DATA_GTK );
-
- /* #106197# hack: until a real shutdown procedure exists
- * _exit ASAP
- */
- if( ImplGetSVData()->maAppData.mbAppQuit )
- _exit(1);
-
- // really bad hack
- if( ! SessionManagerClient::checkDocumentsSaved() )
- /* oslSignalAction eToDo = */ osl_raiseSignal (OSL_SIGNAL_USER_X11SUBSYSTEMERROR, NULL);
-
- std::fprintf( stderr, "X IO Error\n" );
- std::fflush( stdout );
- std::fflush( stderr );
-
- /* #106197# the same reasons to use _exit instead of exit in salmain
- * do apply here. Since there is nothing to be done after an XIO
- * error we have to _exit immediately.
- */
- _exit(0);
- return 0;
-}
-
// -=-= SalData =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include <pthread.h>
@@ -281,11 +244,16 @@ X11SalData::X11SalData( SalGenericDataType t )
m_pPlugin = NULL;
hMainThread_ = pthread_self();
+
+ m_aOrigXIOErrorHandler = XSetIOErrorHandler ( (XIOErrorHandler)XIOErrorHdl );
+ PushXErrorLevel( !!getenv( "SAL_IGNOREXERRORS" ) );
}
X11SalData::~X11SalData()
{
DeleteDisplay();
+ PopXErrorLevel();
+ XSetIOErrorHandler (m_aOrigXIOErrorHandler);
}
void X11SalData::Dispose()
@@ -317,6 +285,75 @@ void X11SalData::deInitNWF( void )
{
}
+void X11SalData::ErrorTrapPush()
+{
+ PushXErrorLevel( true );
+}
+
+bool X11SalData::ErrorTrapPop( bool bIgnoreError )
+{
+ bool err = false;
+ if( !bIgnoreError )
+ err = HasXErrorOccurred();
+ PopXErrorLevel();
+ return err;
+}
+
+
+void X11SalData::PushXErrorLevel( bool bIgnore )
+{
+ m_aXErrorHandlerStack.push_back( XErrorStackEntry() );
+ XErrorStackEntry& rEnt = m_aXErrorHandlerStack.back();
+ rEnt.m_bWas = false;
+ rEnt.m_bIgnore = bIgnore;
+ rEnt.m_nLastErrorRequest = 0;
+ rEnt.m_aHandler = XSetErrorHandler( (XErrorHandler)XErrorHdl );
+}
+
+void X11SalData::PopXErrorLevel()
+{
+ if( m_aXErrorHandlerStack.size() )
+ {
+ XSetErrorHandler( m_aXErrorHandlerStack.back().m_aHandler );
+ m_aXErrorHandlerStack.pop_back();
+ }
+}
+
+// -=-= C statics =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+int X11SalData::XErrorHdl( Display *pDisplay, XErrorEvent *pEvent )
+{
+ GetX11SalData()->XError( pDisplay, pEvent );
+ return 0;
+}
+
+int X11SalData::XIOErrorHdl( Display * )
+{
+ /* #106197# hack: until a real shutdown procedure exists
+ * _exit ASAP
+ */
+ if( ImplGetSVData()->maAppData.mbAppQuit )
+ _exit(1);
+
+ // really bad hack
+ if( ! SessionManagerClient::checkDocumentsSaved() )
+ /* oslSignalAction eToDo = */ osl_raiseSignal (OSL_SIGNAL_USER_X11SUBSYSTEMERROR, NULL);
+
+ std::fprintf( stderr, "X IO Error\n" );
+ std::fflush( stdout );
+ std::fflush( stderr );
+
+ /* #106197# the same reasons to use _exit instead of exit in salmain
+ * do apply here. Since there is nothing to be done after an XIO
+ * error we have to _exit immediately.
+ */
+ _exit(0);
+ return 0;
+}
+
+
+
// -=-= SalXLib =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
SalXLib::SalXLib()
@@ -363,10 +400,6 @@ SalXLib::SalXLib()
FD_SET( m_pTimeoutFDS[0], &aReadFDS_ );
nFDs_ = m_pTimeoutFDS[0] + 1;
}
-
- m_bHaveSystemChildFrames = false;
- m_aOrigXIOErrorHandler = XSetIOErrorHandler ( (XIOErrorHandler)X11SalData::XIOErrorHdl );
- PushXErrorLevel( !!getenv( "SAL_IGNOREXERRORS" ) );
}
SalXLib::~SalXLib()
@@ -374,28 +407,6 @@ SalXLib::~SalXLib()
// close 'wakeup' pipe.
close (m_pTimeoutFDS[0]);
close (m_pTimeoutFDS[1]);
-
- PopXErrorLevel();
- XSetIOErrorHandler (m_aOrigXIOErrorHandler);
-}
-
-void SalXLib::PushXErrorLevel( bool bIgnore )
-{
- m_aXErrorHandlerStack.push_back( XErrorStackEntry() );
- XErrorStackEntry& rEnt = m_aXErrorHandlerStack.back();
- rEnt.m_bWas = false;
- rEnt.m_bIgnore = bIgnore;
- rEnt.m_nLastErrorRequest = 0;
- rEnt.m_aHandler = XSetErrorHandler( (XErrorHandler)X11SalData::XErrorHdl );
-}
-
-void SalXLib::PopXErrorLevel()
-{
- if( m_aXErrorHandlerStack.size() )
- {
- XSetErrorHandler( m_aXErrorHandlerStack.back().m_aHandler );
- m_aXErrorHandlerStack.pop_back();
- }
}
void SalXLib::Init()
@@ -470,19 +481,10 @@ void SalXLib::Init()
exit(0);
}
- SalDisplay *pSalDisplay = new SalX11Display( pDisp );
+ SalX11Display *pSalDisplay = new SalX11Display( pDisp );
pInputMethod->CreateMethod( pDisp );
- pSalDisplay->SetInputMethod( pInputMethod );
-
- PushXErrorLevel( true );
- SalI18N_KeyboardExtension *pKbdExtension = new SalI18N_KeyboardExtension( pDisp );
- XSync( pDisp, False );
-
- pKbdExtension->UseExtension( ! HasXErrorOccurred() );
- PopXErrorLevel();
-
- pSalDisplay->SetKbdExtension( pKbdExtension );
+ pSalDisplay->SetupInput( pInputMethod );
}
extern "C" {
@@ -536,11 +538,8 @@ static void PrintXError( Display *pDisplay, XErrorEvent *pEvent )
std::fflush( stderr );
}
-void SalXLib::XError( Display *pDisplay, XErrorEvent *pEvent )
+void X11SalData::XError( Display *pDisplay, XErrorEvent *pEvent )
{
- if( m_bHaveSystemChildFrames )
- return;
-
if( ! m_aXErrorHandlerStack.back().m_bIgnore )
{
if ( (pEvent->error_code == BadAlloc)
diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx
index c0ca7fe1eb22..004b3fc4f914 100644
--- a/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -113,6 +113,11 @@ using ::rtl::OUString;
#define SALCOLOR_WHITE MAKE_SALCOLOR( 0xFF, 0xFF, 0xFF )
#define SALCOLOR_BLACK MAKE_SALCOLOR( 0x00, 0x00, 0x00 )
+inline X11SalData* GetX11SalData()
+{
+ return (X11SalData*)ImplGetSVData()->mpSalData;
+}
+
// -=-= Prototyps =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// -=-= static variables -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -831,6 +836,22 @@ void SalDisplay::Init()
#endif
}
+void SalX11Display::SetupInput( SalI18N_InputMethod *pInputMethod )
+{
+ SetInputMethod( pInputMethod );
+
+ GetGenericData()->ErrorTrapPush();
+ SalI18N_KeyboardExtension *pKbdExtension = new SalI18N_KeyboardExtension( pDisp_ );
+ XSync( pDisp_, False );
+
+ bool bError = GetGenericData()->ErrorTrapPop( false );
+ GetGenericData()->ErrorTrapPush();
+ pKbdExtension->UseExtension( ! bError );
+ GetGenericData()->ErrorTrapPop();
+
+ SetKbdExtension( pKbdExtension );
+}
+
// Sound
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void SalDisplay::Beep() const
@@ -2078,13 +2099,13 @@ void SalX11Display::Yield()
Dispatch( &aEvent );
#ifdef DBG_UTIL
- if( pXLib_->HasXErrorOccurred() )
+ if( GetX11SalData()->HasXErrorOccurred() )
{
XFlush( pDisp_ );
DbgPrintDisplayEvent("SalDisplay::Yield (WasXError)", &aEvent);
}
#endif
- pXLib_->ResetXErrorOccurred();
+ GetX11SalData()->ResetXErrorOccurred();
}
long SalX11Display::Dispatch( XEvent *pEvent )
diff --git a/vcl/unx/generic/app/wmadaptor.cxx b/vcl/unx/generic/app/wmadaptor.cxx
index 89e9d5b486e9..ed97ddb189f0 100644
--- a/vcl/unx/generic/app/wmadaptor.cxx
+++ b/vcl/unx/generic/app/wmadaptor.cxx
@@ -579,7 +579,7 @@ GnomeWMAdaptor::GnomeWMAdaptor( SalDisplay* pSalDisplay ) :
XFree( pProperty );
pProperty = NULL;
XLIB_Window aCheckWindow = None;
- m_pSalDisplay->GetXLib()->PushXErrorLevel( true );
+ GetGenericData()->ErrorTrapPush();
if( XGetWindowProperty( m_pDisplay,
aWMChild,
m_aWMAtoms[ WIN_SUPPORTING_WM_CHECK ],
@@ -593,26 +593,31 @@ GnomeWMAdaptor::GnomeWMAdaptor( SalDisplay* pSalDisplay ) :
&pProperty ) == 0
&& aRealType == XA_CARDINAL
&& nFormat == 32
- && nItems != 0
- && ! m_pSalDisplay->GetXLib()->HasXErrorOccurred()
- )
+ && nItems != 0 )
{
- aCheckWindow = *(XLIB_Window*)pProperty;
- XFree( pProperty );
- pProperty = NULL;
- if( aCheckWindow == aWMChild )
+ if (! GetGenericData()->ErrorTrapPop( false ) )
{
- m_bValid = true;
- /*
- * get name of WM
- * this is NOT part of the GNOME WM hints, but e.g. Sawfish
- * already supports this part of the extended WM hints
- */
- m_aWMAtoms[ UTF8_STRING ] = XInternAtom( m_pDisplay, "UTF8_STRING", False );
- getNetWmName();
+ GetGenericData()->ErrorTrapPush();
+
+ aCheckWindow = *(XLIB_Window*)pProperty;
+ XFree( pProperty );
+ pProperty = NULL;
+ if( aCheckWindow == aWMChild )
+ {
+ m_bValid = true;
+ /*
+ * get name of WM
+ * this is NOT part of the GNOME WM hints, but e.g. Sawfish
+ * already supports this part of the extended WM hints
+ */
+ m_aWMAtoms[ UTF8_STRING ] = XInternAtom( m_pDisplay, "UTF8_STRING", False );
+ getNetWmName();
+ }
}
+ else
+ GetGenericData()->ErrorTrapPush();
}
- m_pSalDisplay->GetXLib()->PopXErrorLevel();
+ GetGenericData()->ErrorTrapPop();
}
else if( pProperty )
{
@@ -779,7 +784,7 @@ bool WMAdaptor::getNetWmName()
XFree( pProperty );
pProperty = NULL;
XLIB_Window aCheckWindow = None;
- m_pSalDisplay->GetXLib()->PushXErrorLevel( true );
+ GetGenericData()->ErrorTrapPush();
if( XGetWindowProperty( m_pDisplay,
aWMChild,
m_aWMAtoms[ NET_SUPPORTING_WM_CHECK ],
@@ -793,63 +798,25 @@ bool WMAdaptor::getNetWmName()
&pProperty ) == 0
&& aRealType == XA_WINDOW
&& nFormat == 32
- && nItems != 0
- && ! m_pSalDisplay->GetXLib()->HasXErrorOccurred()
- )
- {
- aCheckWindow = *(XLIB_Window*)pProperty;
- XFree( pProperty );
- pProperty = NULL;
- if( aCheckWindow == aWMChild )
+ && nItems != 0 )
{
- bNetWM = true;
- // get name of WM
- m_aWMAtoms[ UTF8_STRING ] = XInternAtom( m_pDisplay, "UTF8_STRING", False );
- if( XGetWindowProperty( m_pDisplay,
- aWMChild,
- m_aWMAtoms[ NET_WM_NAME ],
- 0, 256,
- False,
- AnyPropertyType, /* m_aWMAtoms[ UTF8_STRING ],*/
- &aRealType,
- &nFormat,
- &nItems,
- &nBytesLeft,
- &pProperty ) == 0
- && nItems != 0
- )
- {
- if (aRealType == m_aWMAtoms[ UTF8_STRING ])
- {
- m_aWMName = String( (sal_Char*)pProperty, nItems, RTL_TEXTENCODING_UTF8 );
- }
- else
- if (aRealType == XA_STRING)
- {
- m_aWMName = String( (sal_Char*)pProperty, nItems, RTL_TEXTENCODING_ISO_8859_1 );
- }
-
- XFree( pProperty );
- pProperty = NULL;
- }
- else if( pProperty )
+ if ( GetGenericData()->ErrorTrapPop( false ) )
{
+ GetGenericData()->ErrorTrapPush();
+ aCheckWindow = *(XLIB_Window*)pProperty;
XFree( pProperty );
pProperty = NULL;
- }
- // if this is metacity, check for version to enable a legacy workaround
- if( m_aWMName.EqualsAscii( "Metacity" ) )
- {
- int nVersionMajor = 0, nVersionMinor = 0;
- Atom nVersionAtom = XInternAtom( m_pDisplay, "_METACITY_VERSION", True );
- if( nVersionAtom )
+ if( aCheckWindow == aWMChild )
{
+ bNetWM = true;
+ // get name of WM
+ m_aWMAtoms[ UTF8_STRING ] = XInternAtom( m_pDisplay, "UTF8_STRING", False );
if( XGetWindowProperty( m_pDisplay,
aWMChild,
- nVersionAtom,
+ m_aWMAtoms[ NET_WM_NAME ],
0, 256,
False,
- m_aWMAtoms[ UTF8_STRING ],
+ AnyPropertyType, /* m_aWMAtoms[ UTF8_STRING ],*/
&aRealType,
&nFormat,
&nItems,
@@ -858,27 +825,68 @@ bool WMAdaptor::getNetWmName()
&& nItems != 0
)
{
- String aMetaVersion( (sal_Char*)pProperty, nItems, RTL_TEXTENCODING_UTF8 );
- nVersionMajor = aMetaVersion.GetToken( 0, '.' ).ToInt32();
- nVersionMinor = aMetaVersion.GetToken( 1, '.' ).ToInt32();
+ if (aRealType == m_aWMAtoms[ UTF8_STRING ])
+ m_aWMName = String( (sal_Char*)pProperty, nItems, RTL_TEXTENCODING_UTF8 );
+ else if (aRealType == XA_STRING)
+ m_aWMName = String( (sal_Char*)pProperty, nItems, RTL_TEXTENCODING_ISO_8859_1 );
+
+ XFree( pProperty );
+ pProperty = NULL;
}
- if( pProperty )
+ else if( pProperty )
{
XFree( pProperty );
pProperty = NULL;
}
+
+ // if this is metacity, check for version to enable a legacy workaround
+ if( m_aWMName.EqualsAscii( "Metacity" ) )
+ {
+ int nVersionMajor = 0, nVersionMinor = 0;
+ Atom nVersionAtom = XInternAtom( m_pDisplay, "_METACITY_VERSION", True );
+ if( nVersionAtom )
+ {
+ if( XGetWindowProperty( m_pDisplay,
+ aWMChild,
+ nVersionAtom,
+ 0, 256,
+ False,
+ m_aWMAtoms[ UTF8_STRING ],
+ &aRealType,
+ &nFormat,
+ &nItems,
+ &nBytesLeft,
+ &pProperty ) == 0
+ && nItems != 0
+ )
+ {
+ String aMetaVersion( (sal_Char*)pProperty, nItems, RTL_TEXTENCODING_UTF8 );
+ nVersionMajor = aMetaVersion.GetToken( 0, '.' ).ToInt32();
+ nVersionMinor = aMetaVersion.GetToken( 1, '.' ).ToInt32();
+ }
+ if( pProperty )
+ {
+ XFree( pProperty );
+ pProperty = NULL;
+ }
+ }
+ if( nVersionMajor < 2 || (nVersionMajor == 2 && nVersionMinor < 12) )
+ m_bLegacyPartialFullscreen = true;
+ }
}
- if( nVersionMajor < 2 || (nVersionMajor == 2 && nVersionMinor < 12) )
- m_bLegacyPartialFullscreen = true;
+ }
+ else
+ {
+ if( pProperty )
+ {
+ XFree( pProperty );
+ pProperty = NULL;
+ }
+ GetGenericData()->ErrorTrapPush();
}
}
- }
- else if( pProperty )
- {
- XFree( pProperty );
- pProperty = NULL;
- }
- m_pSalDisplay->GetXLib()->PopXErrorLevel();
+
+ GetGenericData()->ErrorTrapPop();
}
else if( pProperty )
{
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index c2057e79fb9b..d0201e3df6d6 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -226,10 +226,9 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB(
// but this call can actually work on servers with backing store
// defaults even if the rectangle is offscreen
// so better catch the XError
- pXLib->PushXErrorLevel( true );
+ GetGenericData()->ErrorTrapPush();
XImage* pImage = XGetImage( pXDisp, aDrawable, nX, nY, nWidth, nHeight, AllPlanes, ZPixmap );
- bool bWasError = pXLib->HasXErrorOccurred() && pXLib->GetLastXErrorRequestCode() == X_GetImage;
- pXLib->PopXErrorLevel();
+ bool bWasError = GetGenericData()->ErrorTrapPop( false );
if( ! bWasError && pImage && pImage->data )
{
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index 1669ab6f2662..2b2612025a68 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -84,20 +84,17 @@ void X11SalGraphics::CopyScreenArea( Display* pDisplay,
src_x, src_y, w, h, dest_x, dest_y );
else
{
- SalXLib* pLib = GetGenericData()->GetSalDisplay()->GetXLib();
- pLib->PushXErrorLevel( true );
+ GetGenericData()->ErrorTrapPush();
XImage* pImage = XGetImage( pDisplay, aSrc, src_x, src_y, w, h,
AllPlanes, ZPixmap );
if( pImage )
{
if( pImage->data )
- {
XPutImage( pDisplay, aDest, aDestGC, pImage,
0, 0, dest_x, dest_y, w, h );
- }
XDestroyImage( pImage );
}
- pLib->PopXErrorLevel();
+ GetGenericData()->ErrorTrapPop();
}
}
else
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 6d821bdee88a..ad43f7afefe6 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -114,7 +114,7 @@ X11SalFrame* X11SalFrame::s_pSaveYourselfFrame = NULL;
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
static void doReparentPresentationDialogues( SalDisplay* pDisplay )
{
- pDisplay->GetXLib()->PushXErrorLevel( true );
+ GetGenericData()->ErrorTrapPush();
while( aPresentationReparentList.begin() != aPresentationReparentList.end() )
{
int x, y;
@@ -139,7 +139,7 @@ static void doReparentPresentationDialogues( SalDisplay* pDisplay )
if( hPresFocusWindow )
XSetInputFocus( pDisplay->GetDisplay(), hPresFocusWindow, PointerRoot, CurrentTime );
XSync( pDisplay->GetDisplay(), False );
- pDisplay->GetXLib()->PopXErrorLevel();
+ GetGenericData()->ErrorTrapPop();
}
// -=-= SalFrame / X11SalFrame =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -201,12 +201,12 @@ void X11SalFrame::askForXEmbedFocus( sal_Int32 i_nTimeCode )
aEvent.xclient.data.l[3] = 0;
aEvent.xclient.data.l[4] = 0;
- GetDisplay()->GetXLib()->PushXErrorLevel( true );
+ GetGenericData()->ErrorTrapPush();
XSendEvent( pDisplay_->GetDisplay(),
mhForeignParent,
False, NoEventMask, &aEvent );
XSync( pDisplay_->GetDisplay(), False );
- GetDisplay()->GetXLib()->PopXErrorLevel();
+ GetGenericData()->ErrorTrapPop();
}
@@ -281,9 +281,9 @@ void X11SalFrame::Init( sal_uLong nSalFrameStyle, int nScreen, SystemParentData*
}
else if( pParentData )
{
- // plugin parent may be killed unexpectedly by
- // plugging process; ignore XErrors in that case
- GetDisplay()->setHaveSystemChildFrame();
+ // plugin parent may be killed unexpectedly by plugging
+ // process; start permanantly ignoring X errors ...
+ GetGenericData()->ErrorTrapPush();
nStyle_ |= SAL_FRAME_STYLE_PLUG;
Attributes.override_redirect = True;
@@ -3786,7 +3786,7 @@ long X11SalFrame::HandleReparentEvent( XReparentEvent *pEvent )
static const char* pDisableStackingCheck = getenv( "SAL_DISABLE_STACKING_CHECK" );
- GetDisplay()->GetXLib()->PushXErrorLevel( true );
+ GetGenericData()->ErrorTrapPush();
/*
* don't rely on the new parent from the event.
@@ -3805,7 +3805,11 @@ long X11SalFrame::HandleReparentEvent( XReparentEvent *pEvent )
&hDummy,
&Children,
&nChildren );
- if( GetDisplay()->GetXLib()->HasXErrorOccurred() )
+
+ bool bError = GetGenericData()->ErrorTrapPop( false );
+ GetGenericData()->ErrorTrapPush();
+
+ if( bError )
{
hWM_Parent = GetShellWindow();
break;
@@ -3813,7 +3817,7 @@ long X11SalFrame::HandleReparentEvent( XReparentEvent *pEvent )
/* this sometimes happens if a Show(sal_True) is
* immediately followed by Show(sal_False) (which is braindead anyway)
*/
- if( hDummy == hWM_Parent )
+ if( hDummy == hWM_Parent )
hDummy = hRoot;
if( hDummy != hRoot )
{
@@ -3844,7 +3848,7 @@ long X11SalFrame::HandleReparentEvent( XReparentEvent *pEvent )
// Reparenting before Destroy
aPresentationReparentList.remove( GetStackingWindow() );
mhStackingWindow = None;
- GetDisplay()->GetXLib()->PopXErrorLevel();
+ GetGenericData()->ErrorTrapPop();
return 0;
}
@@ -3895,7 +3899,11 @@ long X11SalFrame::HandleReparentEvent( XReparentEvent *pEvent )
* so need real geometries here
* (this will fail with virtual roots ?)
*/
- GetDisplay()->GetXLib()->ResetXErrorOccurred();
+
+ // reset error occurred
+ GetGenericData()->ErrorTrapPop();
+ GetGenericData()->ErrorTrapPush();
+
int xp, yp, x, y;
unsigned int wp, w, hp, h, bw, d;
XGetGeometry( GetXDisplay(),
@@ -3907,7 +3915,10 @@ long X11SalFrame::HandleReparentEvent( XReparentEvent *pEvent )
&hRoot,
&xp, &yp, &wp, &hp, &bw, &d );
bool bResized = false;
- if( ! GetDisplay()->GetXLib()->HasXErrorOccurred() )
+ bool bError = GetGenericData()->ErrorTrapPop( false );
+ GetGenericData()->ErrorTrapPush();
+
+ if( ! bError )
{
maGeometry.nRightDecoration = wp - w - maGeometry.nLeftDecoration;
maGeometry.nBottomDecoration = hp - h - maGeometry.nTopDecoration;
@@ -3922,7 +3933,6 @@ long X11SalFrame::HandleReparentEvent( XReparentEvent *pEvent )
maGeometry.nHeight = h;
}
-
// limit width and height if we are too large: #47757
// olwm and fvwm need this, it doesnt harm the rest
@@ -3951,7 +3961,7 @@ long X11SalFrame::HandleReparentEvent( XReparentEvent *pEvent )
if( bResized )
CallCallback( SALEVENT_RESIZE, NULL );
- GetDisplay()->GetXLib()->PopXErrorLevel();
+ GetGenericData()->ErrorTrapPop();
return 1;
}
diff --git a/vcl/unx/generic/window/salobj.cxx b/vcl/unx/generic/window/salobj.cxx
index cc9487fda4be..da0937858150 100644
--- a/vcl/unx/generic/window/salobj.cxx
+++ b/vcl/unx/generic/window/salobj.cxx
@@ -134,7 +134,7 @@ X11SalObject* X11SalObject::CreateObject( SalFrame* pParent, SystemWindowData* p
static_cast<unsigned int> (pSalDisp->GetVisual( nScreen ).GetVisualId()),
static_cast<unsigned int> (aVisID) );
#endif
- pSalDisp->GetXLib()->PushXErrorLevel( true );
+ GetGenericData()->ErrorTrapPush();
// create colormap for visual - there might not be one
pObject->maColormap = aAttribs.colormap = XCreateColormap(
@@ -152,9 +152,7 @@ X11SalObject* X11SalObject::CreateObject( SalFrame* pParent, SystemWindowData* p
pVisual,
CWEventMask|CWColormap, &aAttribs );
XSync( pDisp, False );
- sal_Bool bWasXError = pSalDisp->GetXLib()->HasXErrorOccurred();
- pSalDisp->GetXLib()->PopXErrorLevel();
- if( bWasXError )
+ if( GetGenericData()->ErrorTrapPop( false ) )
{
pObject->maSecondary = None;
delete pObject;
@@ -163,7 +161,7 @@ X11SalObject* X11SalObject::CreateObject( SalFrame* pParent, SystemWindowData* p
XReparentWindow( pDisp, pObject->maSecondary, pObject->maPrimary, 0, 0 );
}
- pSalDisp->GetXLib()->PushXErrorLevel( true );
+ GetGenericData()->ErrorTrapPush();
if( bShow ) {
XMapWindow( pDisp, pObject->maSecondary );
XMapWindow( pDisp, pObject->maPrimary );
@@ -179,9 +177,7 @@ X11SalObject* X11SalObject::CreateObject( SalFrame* pParent, SystemWindowData* p
pObjData->pAppContext = NULL;
XSync(pDisp, False);
- sal_Bool bWasXError = pSalDisp->GetXLib()->HasXErrorOccurred();
- pSalDisp->GetXLib()->PopXErrorLevel();
- if( bWasXError )
+ if( GetGenericData()->ErrorTrapPop( false ) )
{
delete pObject;
return NULL;
@@ -278,7 +274,8 @@ X11SalObject::~X11SalObject()
std::list< SalObject* >& rObjects = GetGenericData()->GetSalDisplay()->getSalObjects();
rObjects.remove( this );
SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
- pSalDisp->GetXLib()->PushXErrorLevel( true );
+
+ GetGenericData()->ErrorTrapPush();
if ( maSecondary )
XDestroyWindow( (Display*)maSystemChildData.pDisplay, maSecondary );
if ( maPrimary )
@@ -286,7 +283,7 @@ X11SalObject::~X11SalObject()
if ( maColormap )
XFreeColormap((Display*)maSystemChildData.pDisplay, maColormap);
XSync( (Display*)maSystemChildData.pDisplay, False );
- pSalDisp->GetXLib()->PopXErrorLevel();
+ GetGenericData()->ErrorTrapPop();
}