Kaydet (Commit) 06283e7b authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

tdf#101822 X11 SalDisplay init => AfterAppInit

This fixes all X11 based VCL plugins to move display
initialization  into AfterAppInit (gen, TDE, KDE4),

This is done by moving input method and display into
SalXLib, so they are available in AfterAppInit.

Otherwise the configmgr service won't be available in
SalDisplay::BestVisual.

Change-Id: I9380075b9770bceb8f453bbcb7fe31291634ff89
üst 3bc2b8c5
......@@ -71,6 +71,9 @@ public:
class KDESalInstance : public X11SalInstance
{
protected:
virtual SalX11Display* CreateDisplay() const override;
public:
KDESalInstance( SalYieldMutex* pMutex )
: X11SalInstance( pMutex ) {}
......
......@@ -143,6 +143,8 @@ public:
SalColor GetColor( Pixel nPixel ) const;
};
class SalI18N_InputMethod;
typedef int(*YieldFunc)(int fd, void* data);
class VCLPLUG_GEN_PUBLIC SalXLib
......@@ -157,6 +159,9 @@ protected:
fd_set aReadFDS_;
fd_set aExceptionFDS_;
Display *m_pDisplay;
SalI18N_InputMethod *m_pInputMethod;
public:
SalXLib();
virtual ~SalXLib();
......@@ -176,9 +181,12 @@ public:
virtual void StopTimer();
bool CheckTimeout( bool bExecuteTimers = true );
SalI18N_InputMethod* GetInputMethod() const { return m_pInputMethod; }
void SetInputMethod( SalI18N_InputMethod *pInputMethod );
Display* GetDisplay() const { return m_pDisplay; }
};
class SalI18N_InputMethod;
class SalI18N_KeyboardExtension;
class AttributeProvider;
......@@ -251,7 +259,6 @@ public:
protected:
SalXLib *pXLib_;
SalI18N_InputMethod *mpInputMethod;
SalI18N_KeyboardExtension *mpKbdExtension;
AttributeProvider *mpFactory;
......@@ -359,10 +366,8 @@ public:
bool XIfEventWithTimeout( XEvent*, XPointer, X_if_predicate ) const;
SalXLib* GetXLib() const { return pXLib_; }
SalI18N_InputMethod* GetInputMethod() const { return mpInputMethod; }
SalI18N_InputMethod* GetInputMethod() const { return pXLib_->GetInputMethod(); }
SalI18N_KeyboardExtension* GetKbdExtension() const { return mpKbdExtension; }
void SetInputMethod( SalI18N_InputMethod *pInputMethod )
{ mpInputMethod = pInputMethod; }
void SetKbdExtension(SalI18N_KeyboardExtension *pKbdExtension)
{ mpKbdExtension = pKbdExtension; }
::vcl_sal::WMAdaptor* getWMAdaptor() const { return m_pWMAdaptor; }
......@@ -394,7 +399,7 @@ public:
virtual void PostUserEvent() override;
bool IsEvent();
void SetupInput( SalI18N_InputMethod *pInputMethod );
void SetupInput();
};
namespace vcl_sal {
......
......@@ -34,6 +34,7 @@ namespace com { namespace sun { namespace star { namespace datatransfer {
class SalXLib;
class X11SalGraphics;
class SalX11Display;
class VCLPLUG_GEN_PUBLIC X11SalInstance : public SalGenericInstance
{
......@@ -43,6 +44,8 @@ private:
protected:
SalXLib *mpXLib;
virtual SalX11Display* CreateDisplay() const;
public:
explicit X11SalInstance(SalYieldMutex* pMutex);
virtual ~X11SalInstance() override;
......@@ -77,6 +80,8 @@ public:
virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) override;
void SetLib( SalXLib *pXLib ) { mpXLib = pXLib; }
virtual void AfterAppInit() override;
// dtrans implementation
virtual css::uno::Reference< css::uno::XInterface >
CreateClipboard( const css::uno::Sequence< css::uno::Any >& i_rArguments ) override;
......
......@@ -334,6 +334,9 @@ SalXLib::SalXLib()
FD_ZERO( &aReadFDS_ );
FD_ZERO( &aExceptionFDS_ );
m_pInputMethod = nullptr;
m_pDisplay = nullptr;
m_pTimeoutFDS[0] = m_pTimeoutFDS[1] = -1;
if (pipe (m_pTimeoutFDS) != -1)
{
......@@ -375,6 +378,14 @@ SalXLib::~SalXLib()
// close 'wakeup' pipe.
close (m_pTimeoutFDS[0]);
close (m_pTimeoutFDS[1]);
delete m_pInputMethod;
}
void SalXLib::SetInputMethod( SalI18N_InputMethod *pInputMethod )
{
delete m_pInputMethod;
m_pInputMethod = pInputMethod;
}
static Display *OpenX11Display(OString& rDisplay)
......@@ -431,14 +442,14 @@ static Display *OpenX11Display(OString& rDisplay)
void SalXLib::Init()
{
SalI18N_InputMethod* pInputMethod = new SalI18N_InputMethod;
pInputMethod->SetLocale();
m_pInputMethod = new SalI18N_InputMethod;
m_pInputMethod->SetLocale();
XrmInitialize();
OString aDisplay;
Display *pDisp = OpenX11Display(aDisplay);
m_pDisplay = OpenX11Display(aDisplay);
if ( !pDisp )
if ( !m_pDisplay )
{
OUString aProgramFileURL;
osl_getExecutableFile( &aProgramFileURL.pData );
......@@ -455,11 +466,6 @@ void SalXLib::Init()
std::fflush( stderr );
exit(0);
}
SalX11Display *pSalDisplay = new SalX11Display( pDisp );
pInputMethod->CreateMethod( pDisp );
pSalDisplay->SetupInput( pInputMethod );
}
extern "C" {
......
......@@ -285,7 +285,6 @@ bool SalDisplay::BestVisual( Display *pDisplay,
SalDisplay::SalDisplay( Display *display ) :
pXLib_( nullptr ),
mpInputMethod( nullptr ),
mpKbdExtension( nullptr ),
mpFactory( nullptr ),
pDisp_( display ),
......@@ -343,8 +342,6 @@ void SalDisplay::doDestruct()
if( IsDisplay() )
{
delete mpInputMethod;
mpInputMethod = nullptr;
delete mpKbdExtension;
mpKbdExtension = nullptr;
......@@ -662,10 +659,8 @@ void SalDisplay::Init()
#endif
}
void SalX11Display::SetupInput( SalI18N_InputMethod *pInputMethod )
void SalX11Display::SetupInput()
{
SetInputMethod( pInputMethod );
GetGenericData()->ErrorTrapPush();
SalI18N_KeyboardExtension *pKbdExtension = new SalI18N_KeyboardExtension( pDisp_ );
XSync( pDisp_, False );
......@@ -1444,10 +1439,14 @@ KeySym SalDisplay::GetKeySym( XKeyEvent *pEvent,
memset( pPrintable, 0, *pLen );
*pStatusReturn = 0;
SalI18N_InputMethod *pInputMethod = nullptr;
if ( pXLib_ )
pInputMethod = pXLib_->GetInputMethod();
// first get the printable of the possibly modified KeySym
if ( (aInputContext == nullptr)
|| (pEvent->type == KeyRelease)
|| (mpInputMethod != nullptr && mpInputMethod->PosixLocale()) )
|| (pInputMethod != nullptr && pInputMethod->PosixLocale()) )
{
// XmbLookupString must not be called for KeyRelease events
// Cannot enter space in c locale problem #89616# #88978# btraq #4478197
......@@ -1960,6 +1959,10 @@ void SalX11Display::Yield()
bool SalX11Display::Dispatch( XEvent *pEvent )
{
SalI18N_InputMethod *pInputMethod = nullptr;
if ( pXLib_ )
pInputMethod = pXLib_->GetInputMethod();
if( pEvent->type == KeyPress || pEvent->type == KeyRelease )
{
::Window aWindow = pEvent->xkey.window;
......@@ -1976,12 +1979,12 @@ bool SalX11Display::Dispatch( XEvent *pEvent )
}
if( it != m_aFrames.end() )
{
if ( mpInputMethod->FilterEvent( pEvent , aWindow ) )
if ( pInputMethod && pInputMethod->FilterEvent( pEvent , aWindow ) )
return false;
}
}
else
if ( mpInputMethod->FilterEvent( pEvent, None ) )
if ( pInputMethod && pInputMethod->FilterEvent( pEvent, None ) )
return false;
SalInstance* pInstance = GetSalData()->m_pInstance;
......
......@@ -31,6 +31,8 @@
#include <unx/salframe.h>
#include <unx/genprn.h>
#include <unx/sm.hxx>
#include <unx/i18n_im.hxx>
#include <unx/saldisp.hxx>
#include <vcl/inputtypes.hxx>
#include <vcl/helper.hxx>
......@@ -85,6 +87,11 @@ X11SalInstance::~X11SalInstance()
GetGenericData()->Dispose();
}
SalX11Display* X11SalInstance::CreateDisplay() const
{
return new SalX11Display( mpXLib->GetDisplay() );
}
// AnyInput from sv/mow/source/app/svapp.cxx
struct PredicateReturn
......@@ -195,6 +202,16 @@ void X11SalInstance::DestroyFrame( SalFrame* pFrame )
delete pFrame;
}
void X11SalInstance::AfterAppInit()
{
assert( mpXLib->GetDisplay() );
assert( mpXLib->GetInputMethod() );
SalX11Display *pSalDisplay = CreateDisplay();
mpXLib->GetInputMethod()->CreateMethod( mpXLib->GetDisplay() );
pSalDisplay->SetupInput();
}
extern "C" { static void SAL_CALL thisModule() {} }
void X11SalInstance::AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService)
......
......@@ -104,8 +104,8 @@ KDEXLib::~KDEXLib()
void KDEXLib::Init()
{
SalI18N_InputMethod* pInputMethod = new SalI18N_InputMethod;
pInputMethod->SetLocale();
m_pInputMethod = new SalI18N_InputMethod;
m_pInputMethod->SetLocale();
XrmInitialize();
KAboutData *kAboutData = new KAboutData( "LibreOffice",
......@@ -163,12 +163,7 @@ void KDEXLib::Init()
m_pApplication = new VCLKDEApplication();
kapp->disableSessionManagement();
Display* pDisp = QPaintDevice::x11AppDisplay();
SalX11Display *pSalDisplay = new SalKDEDisplay( pDisp );
pInputMethod->CreateMethod( pDisp );
pSalDisplay->SetupInput( pInputMethod );
m_pDisplay = QPaintDevice::x11AppDisplay();
}
void KDEXLib::doStartup()
......
......@@ -27,6 +27,7 @@
#include <unx/salgdi.h>
#include <unx/kde/kdedata.hxx>
#include "unx/pixmap.hxx"
#include <unx/i18n_im.hxx>
#include <vcl/settings.hxx>
#include "unx/fontmanager.hxx"
......@@ -2106,6 +2107,11 @@ uno::Reference< ui::dialogs::XFilePicker2 > KDESalInstance::createFilePicker(
new UnxFilePicker( xMSF ) );
}
SalX11Display* KDESalInstance::CreateDisplay() const
{
return new SalKDEDisplay( QPaintDevice::x11AppDisplay() );
}
// KDESalData pieces
// Create the widget painter so we have some control over
......
......@@ -23,6 +23,9 @@
#include "KDESalFrame.hxx"
#include "KDEXLib.hxx"
#include "KDESalDisplay.hxx"
#include <QX11Info>
using namespace com::sun::star;
......@@ -55,4 +58,9 @@ int KDESalInstance::getFrameWidth()
return static_cast<KDEXLib*>( mpXLib )->getFrameWidth();
}
SalX11Display* KDESalInstance::CreateDisplay() const
{
return new SalKDEDisplay( QX11Info::display() );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -26,6 +26,9 @@ class SalFrame;
class KDESalInstance : public X11SalInstance
{
protected:
virtual SalX11Display* CreateDisplay() const override;
public:
explicit KDESalInstance(SalYieldMutex* pMutex);
virtual ~KDESalInstance() override {}
......
......@@ -96,8 +96,8 @@ KDEXLib::~KDEXLib()
void KDEXLib::Init()
{
SalI18N_InputMethod* pInputMethod = new SalI18N_InputMethod;
pInputMethod->SetLocale();
m_pInputMethod = new SalI18N_InputMethod;
m_pInputMethod->SetLocale();
XrmInitialize();
KAboutData *kAboutData = new KAboutData( "LibreOffice",
......@@ -195,11 +195,7 @@ void KDEXLib::Init()
setupEventLoop();
Display* pDisp = QX11Info::display();
SalKDEDisplay *pSalDisplay = new SalKDEDisplay(pDisp);
pInputMethod->CreateMethod( pDisp );
pSalDisplay->SetupInput( pInputMethod );
m_pDisplay = QX11Info::display();
}
// When we use Qt event loop, it can actually use its own event loop handling, or wrap
......
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