/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
/* #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(1); return 0;
}
SalXLib::~SalXLib()
{ // close 'wakeup' pipe.
close (m_pTimeoutFDS[0]);
close (m_pTimeoutFDS[1]);
m_pInputMethod.reset();
}
static Display *OpenX11Display(OString& rDisplay)
{ /* * open connection to X11 Display * try in this order: * o -display command line parameter, * o $DISPLAY environment variable * o default display
*/
if ((pDisp = XOpenDisplay(rDisplay.getStr()))!=nullptr)
{ /* * if a -display switch was used, we need * to set the environment accordingly since * the clipboard build another connection * to the xserver using $DISPLAY
*/
OUString envVar(u"DISPLAY"_ustr);
osl_setEnvironment(envVar.pData, aParam.pData);
} break;
}
}
if (!pDisp && rDisplay.isEmpty())
{ // Open $DISPLAY or default... char *pDisplay = getenv("DISPLAY"); if (pDisplay != nullptr)
rDisplay = OString(pDisplay);
pDisp = XOpenDisplay(pDisplay);
}
return pDisp;
}
void SalXLib::Init()
{
m_pInputMethod.reset( new SalI18N_InputMethod );
m_pInputMethod->SetLocale();
XrmInitialize();
if( !getenv( "SAL_SYNCHRONIZE" ) )
{
std::fprintf( stderr, "These errors are reported asynchronously,\n");
std::fprintf( stderr, "set environment variable SAL_SYNCHRONIZE to 1 to help debugging\n");
}
std::fflush( stdout );
std::fflush( stderr );
}
void X11SalData::XError( Display *pDisplay, XErrorEvent *pEvent )
{ if( ! m_aXErrorHandlerStack.back().m_bIgnore )
{ if ( (pEvent->error_code == BadAlloc)
&& (pEvent->request_code == X_OpenFont) )
{ staticBool bOnce = False; if ( !bOnce )
{
std::fprintf(stderr, "X-Error occurred in a request for X_OpenFont\n");
EmitFontpathWarning();
bOnce = True ;
} return;
} /* ignore * X_SetInputFocus: it's a hint only anyway * X_GetProperty: this is part of the XGetWindowProperty call and will * be handled by the return value of that function
*/ elseif( pEvent->request_code == X_SetInputFocus ||
pEvent->request_code == X_GetProperty
) return;
bool SalXLib::CheckTimeout( bool bExecuteTimers )
{ bool bRet = false; if( m_aTimeout.tv_sec ) // timer is started
{
timeval aTimeOfDay;
gettimeofday( &aTimeOfDay, nullptr ); if( aTimeOfDay >= m_aTimeout )
{
bRet = true; if( bExecuteTimers )
{ // timed out, update timeout
m_aTimeout = aTimeOfDay; /* * #107827# autorestart immediately, will be stopped (or set * to different value in notify hdl if necessary; * CheckTimeout should return false while * timers are being dispatched.
*/
m_aTimeout += m_nTimeoutMS; // notify
X11SalData::Timeout();
}
}
} return bRet;
}
bool
SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
{ // check for timeouts here if you want to make screenshots staticchar* p_prioritize_timer = getenv ("SAL_HIGHPRIORITY_REPAINT"); bool bHandledEvent = false; if (p_prioritize_timer != nullptr)
bHandledEvent = CheckTimeout();
// first, check for already queued events. for ( int nFD = 0; nFD < nFDs_; nFD++ )
{
YieldEntry* pEntry = &(yieldTable[nFD]); if ( pEntry->fd )
{
SAL_WARN_IF( nFD != pEntry->fd, "vcl", "wrong fd in Yield()" ); for( int i = 0; i < nMaxEvents && pEntry->HasPendingEvent(); i++ )
{
pEntry->HandleNextEvent(); if( ! bHandleAllCurrentEvents )
{ returntrue;
}
}
}
}
// next, select with or without timeout according to bWait. int nFDs = nFDs_;
fd_set ReadFDS = aReadFDS_;
fd_set ExceptionFDS = aExceptionFDS_; int nFound = 0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.