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