vcl/inc/skia/x11/salvd.hxx | 4 vcl/inc/unx/saldisp.hxx | 40 +++---- vcl/inc/unx/salframe.h | 4 vcl/inc/unx/salgdi.h | 4 vcl/inc/unx/salvd.h | 4 vcl/inc/unx/wmadaptor.hxx | 12 +- vcl/skia/x11/gdiimpl.cxx | 2 vcl/skia/x11/salvd.cxx | 2 vcl/unx/generic/app/randrwrapper.cxx | 8 - vcl/unx/generic/app/saldisp.cxx | 182 +++++++++++++++-------------------- vcl/unx/generic/app/salinst.cxx | 4 vcl/unx/generic/app/sm.cxx | 2 vcl/unx/generic/app/wmadaptor.cxx | 12 +- vcl/unx/generic/gdi/salgdi.cxx | 2 vcl/unx/generic/gdi/salvd.cxx | 2 vcl/unx/generic/window/salframe.cxx | 4 vcl/unx/generic/window/salobj.cxx | 4 vcl/unx/x11/x11sys.cxx | 8 - 18 files changed, 136 insertions(+), 164 deletions(-)
New commits: commit 724388d65417ab8983f899d4945d5c79f0e78dcd Author: Michael Weghorn <[email protected]> AuthorDate: Wed Feb 25 10:01:40 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Wed Feb 25 14:43:57 2026 +0100 vcl: Drop dead code in SalX11Display dtor SalX11Display::pDisp_ will be set to null in the above if block already, so no need to check again. This being unnecessary became more clear with previous commit Change-Id: Ia0eae9f03c25ff82cbc0834f290c0a828c7c49ed Author: Michael Weghorn <[email protected]> Date: Wed Feb 25 09:56:35 2026 +0100 vcl: Merge SalDisplay and SalX11Display Change-Id: I8519606ae88d072b828d143a87cc9b47f73481b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200300 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index 384d9effd527..20235b396a9f 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -273,14 +273,6 @@ SalX11Display::~SalX11Display() pDisp_ = nullptr; } - if( pDisp_ ) - { - doDestruct(); -#if OSL_DEBUG_LEVEL > 1 - SAL_INFO("vcl.app", "display " << pDisp_ << " closed."); -#endif - pDisp_ = nullptr; - } // don't do this in doDestruct since RandR extension adds hooks into Display // that is XCloseDisplay still needs the RandR library if it was used DeInitRandR(); commit eeafcbe2ac3af295ceb99a3498242ee57f2ea564 Author: Michael Weghorn <[email protected]> AuthorDate: Wed Feb 25 09:56:35 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Wed Feb 25 14:43:49 2026 +0100 vcl: Merge SalDisplay and SalX11Display SalX11Display is the only subclass of the abstract SalDisplay class. Merge them and keep the SalX11Display name to clarify that this is specific to the gen/x11 VCL plugin. Further simplification (e.g. in the dtor can follow in separate commits). Change-Id: Ia0eae9f03c25ff82cbc0834f290c0a828c7c49ed Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200299 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/inc/skia/x11/salvd.hxx b/vcl/inc/skia/x11/salvd.hxx index fcdc2925b4ea..6e39be22a74f 100644 --- a/vcl/inc/skia/x11/salvd.hxx +++ b/vcl/inc/skia/x11/salvd.hxx @@ -15,7 +15,7 @@ class X11SkiaSalVirtualDevice final : public SalVirtualDevice { - SalDisplay* mpDisplay; + SalX11Display* mpDisplay; std::unique_ptr<X11SalGraphics> mpGraphics; bool mbGraphicsAcquired; // is Graphics used SalX11Screen mnXScreen; @@ -34,7 +34,7 @@ public: virtual tools::Long GetWidth() const override { return mnWidth; } virtual tools::Long GetHeight() const override { return mnHeight; } - SalDisplay* GetDisplay() const { return mpDisplay; } + SalX11Display* GetDisplay() const { return mpDisplay; } const SalX11Screen& GetXScreenNumber() const { return mnXScreen; } virtual SalGraphics* AcquireGraphics() override; diff --git a/vcl/inc/unx/saldisp.hxx b/vcl/inc/unx/saldisp.hxx index 241a189e8255..383666c0e812 100644 --- a/vcl/inc/unx/saldisp.hxx +++ b/vcl/inc/unx/saldisp.hxx @@ -39,7 +39,7 @@ #include <vclpluginapi.h> -class SalDisplay; +class SalX11Display; /* From <X11/Intrinsic.h> */ @@ -91,7 +91,7 @@ struct OwnershipFlag { class SalColormap { - const SalDisplay* m_pDisplay; + const SalX11Display* m_pDisplay; Colormap m_hColormap; std::vector<Color> m_aPalette; // Pseudocolor SalVisual m_aVisual; @@ -101,7 +101,7 @@ class SalColormap Pixel m_nUsed; // Pseudocolor public: - SalColormap( const SalDisplay* pSalDisplay, + SalColormap( const SalX11Display* pSalDisplay, Colormap hColormap, SalX11Screen nXScreen ); SalColormap( sal_uInt16 nDepth ); @@ -113,7 +113,7 @@ public: SalColormap & operator =(SalColormap &&) = default; Colormap GetXColormap() const { return m_hColormap; } - const SalDisplay* GetDisplay() const { return m_pDisplay; } + const SalX11Display* GetDisplay() const { return m_pDisplay; } inline Display* GetXDisplay() const; const SalVisual& GetVisual() const { return m_aVisual; } Pixel GetWhitePixel() const { return m_nWhitePixel; } @@ -192,7 +192,7 @@ public: virtual ~GLX11Window() override; }; -class VCLPLUG_GEN_PUBLIC SalDisplay : public SalGenericDisplay +class VCLPLUG_GEN_PUBLIC SalX11Display : public SalGenericDisplay { public: @@ -261,7 +261,6 @@ protected: mutable Time m_nLastUserEventTime; // mutable because changed on first access - virtual void Dispatch( XEvent *pEvent ) = 0; SAL_DLLPRIVATE void InitXinerama(); SAL_DLLPRIVATE void InitRandR( ::Window aRoot ) const; SAL_DLLPRIVATE static void DeInitRandR(); @@ -273,12 +272,19 @@ protected: public: SAL_DLLPRIVATE static bool BestVisual(Display *pDisp, int nScreen, XVisualInfo &rVI); - SAL_DLLPRIVATE SalDisplay( Display* pDisp ); + SAL_DLLPRIVATE SalX11Display(Display* pDisp); - virtual ~SalDisplay() override; + virtual ~SalX11Display() override; SAL_DLLPRIVATE void Init(); + void Dispatch(XEvent* pEvent); + void Yield(); + virtual void TriggerUserEventProcessing() override; + + bool IsEvent(); + void SetupInput(); + #ifdef DBG_UTIL void PrintInfo() const; void DbgPrintDisplayEvent(const char *pComment, const XEvent *pEvent) const; @@ -344,30 +350,16 @@ public: inline Display *SalColormap::GetXDisplay() const { return m_pDisplay->GetDisplay(); } -class SalX11Display final : public SalDisplay -{ -public: - SalX11Display( Display* pDisp ); - virtual ~SalX11Display() override; - - virtual void Dispatch( XEvent *pEvent ) override; - void Yield(); - virtual void TriggerUserEventProcessing() override; - - bool IsEvent(); - void SetupInput(); -}; - namespace vcl_sal { // get foreign key names OUString getKeysymReplacementName( std::u16string_view pLang, KeySym nSymbol ); - inline SalDisplay *getSalDisplay(GenericUnixSalData const * data) + inline SalX11Display* getSalDisplay(GenericUnixSalData const * data) { assert(data != nullptr); - return static_cast<SalDisplay *>(data->GetDisplay()); + return static_cast<SalX11Display*>(data->GetDisplay()); } } diff --git a/vcl/inc/unx/salframe.h b/vcl/inc/unx/salframe.h index baae77b2504e..3045879ab970 100644 --- a/vcl/inc/unx/salframe.h +++ b/vcl/inc/unx/salframe.h @@ -68,7 +68,7 @@ class X11SalFrame final : public SalFrame bool mbTransientForRoot; std::list< X11SalFrame* > maChildren; // List of child frames - SalDisplay *pDisplay_; + SalX11Display* pDisplay_; SalX11Screen m_nXScreen; ::Window mhWindow; cairo_surface_t* mpSurface; @@ -167,7 +167,7 @@ public: void Init( SalFrameStyleFlags nSalFrameStyle, SalX11Screen nScreen, SystemParentData const * pParentData, bool bUseGeometry = false ); - SalDisplay* GetDisplay() const + SalX11Display* GetDisplay() const { return pDisplay_; } diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index a03c5a64574d..baacb72f35cb 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -53,7 +53,7 @@ public: X11Common(); const SalColormap& GetColormap() const { return *m_pColormap; } - const SalDisplay* GetDisplay() const { return GetColormap().GetDisplay(); } + const SalX11Display* GetDisplay() const { return GetColormap().GetDisplay(); } const SalVisual& GetVisual() const { return GetColormap().GetVisual(); } Display* GetXDisplay() const { return GetColormap().GetXDisplay(); } Drawable GetDrawable() const { return m_hDrawable; } @@ -128,7 +128,7 @@ private: public: Drawable GetDrawable() const { return maX11Common.GetDrawable(); } - const SalDisplay* GetDisplay() const { return maX11Common.GetDisplay(); } + const SalX11Display* GetDisplay() const { return maX11Common.GetDisplay(); } const SalVisual& GetVisual() const { return maX11Common.GetVisual(); } Display* GetXDisplay() const { return maX11Common.GetXDisplay(); } }; diff --git a/vcl/inc/unx/salvd.h b/vcl/inc/unx/salvd.h index a0cfb1b30105..c6ea702374de 100644 --- a/vcl/inc/unx/salvd.h +++ b/vcl/inc/unx/salvd.h @@ -34,7 +34,7 @@ typedef struct _cairo_surface cairo_surface_t; class X11SalVirtualDevice final : public SalVirtualDevice { - SalDisplay *pDisplay_; + SalX11Display* pDisplay_; std::unique_ptr<X11SalGraphics> pGraphics_; Pixmap hDrawable_; @@ -60,7 +60,7 @@ public: { return pDisplay_->GetDisplay(); } - SalDisplay *GetDisplay() const + SalX11Display* GetDisplay() const { return pDisplay_; } diff --git a/vcl/inc/unx/wmadaptor.hxx b/vcl/inc/unx/wmadaptor.hxx index 6d3ee56277c4..d70bc4b3ea49 100644 --- a/vcl/inc/unx/wmadaptor.hxx +++ b/vcl/inc/unx/wmadaptor.hxx @@ -27,7 +27,7 @@ #include "salframe.h" #include <vector> -class SalDisplay; +class SalX11Display; class X11SalFrame; namespace vcl_sal { @@ -123,8 +123,8 @@ public: static const int decoration_All = 0x10000000; protected: - SalDisplay* m_pSalDisplay; // Display to use - Display* m_pDisplay; // X Display of SalDisplay + SalX11Display* m_pSalDisplay; // Display to use + Display* m_pDisplay; // X Display of SalX11Display OUString m_aWMName; Atom m_aWMAtoms[ NetAtomMax]; int m_nDesktops; @@ -138,7 +138,7 @@ protected: bool m_bWMshouldSwitchWorkspace; bool m_bWMshouldSwitchWorkspaceInit; - WMAdaptor( SalDisplay * ) + WMAdaptor(SalX11Display*) ; void initAtoms(); bool getNetWmName(); @@ -154,9 +154,9 @@ public: virtual ~WMAdaptor(); /* - * creates a valid WMAdaptor instance for the SalDisplay + * creates a valid WMAdaptor instance for the SalX11Display */ - static std::unique_ptr<WMAdaptor> createWMAdaptor( SalDisplay* ); + static std::unique_ptr<WMAdaptor> createWMAdaptor(SalX11Display*); /* * may return an empty string if the window manager could diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx index 04ea2da8d0d5..30ab945b0f39 100644 --- a/vcl/skia/x11/gdiimpl.cxx +++ b/vcl/skia/x11/gdiimpl.cxx @@ -147,7 +147,7 @@ void X11SkiaSalGraphicsImpl::Flush() { performFlush(); } std::unique_ptr<skwindow::WindowContext> createVulkanWindowContext(bool temporary) { - SalDisplay* salDisplay = vcl_sal::getSalDisplay(GetGenericUnixSalData()); + SalX11Display* salDisplay = vcl_sal::getSalDisplay(GetGenericUnixSalData()); const XVisualInfo* visual; XVisualInfo* visuals = nullptr; if (!temporary) diff --git a/vcl/skia/x11/salvd.cxx b/vcl/skia/x11/salvd.cxx index 6f7a5abc089a..1aca3a608faa 100644 --- a/vcl/skia/x11/salvd.cxx +++ b/vcl/skia/x11/salvd.cxx @@ -18,7 +18,7 @@ void X11SalGraphics::Init(X11SkiaSalVirtualDevice* pDevice) { - SalDisplay* pDisplay = pDevice->GetDisplay(); + SalX11Display* pDisplay = pDevice->GetDisplay(); m_nXScreen = pDevice->GetXScreenNumber(); maX11Common.m_pColormap = &pDisplay->GetColormap(m_nXScreen); diff --git a/vcl/unx/generic/app/randrwrapper.cxx b/vcl/unx/generic/app/randrwrapper.cxx index 1ef474c347f9..4e76a89ed939 100644 --- a/vcl/unx/generic/app/randrwrapper.cxx +++ b/vcl/unx/generic/app/randrwrapper.cxx @@ -107,7 +107,7 @@ void RandRWrapper::releaseWrapper() #include <cstdio> #endif -void SalDisplay::InitRandR( ::Window aRoot ) const +void SalX11Display::InitRandR(::Window aRoot) const { #ifdef USE_RANDR RandRWrapper::get( GetDisplay() ).XRRSelectInput( GetDisplay(), aRoot, RRScreenChangeNotifyMask ); @@ -117,17 +117,17 @@ void SalDisplay::InitRandR( ::Window aRoot ) const #endif } -void SalDisplay::DeInitRandR() +void SalX11Display::DeInitRandR() { #ifdef USE_RANDR RandRWrapper::releaseWrapper(); #if OSL_DEBUG_LEVEL > 1 - SAL_INFO("vcl.app", "SalDisplay::DeInitRandR()."); + SAL_INFO("vcl.app", "SalX11Display::DeInitRandR()."); #endif #endif } -void SalDisplay::processRandREvent( XEvent* pEvent ) +void SalX11Display::processRandREvent( XEvent* pEvent ) { #ifdef USE_RANDR XConfigureEvent* pCnfEvent=reinterpret_cast<XConfigureEvent*>(pEvent); diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index 0837fcfe8044..384d9effd527 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -131,9 +131,7 @@ sal_GetServerVendor( Display *p_display ) return vendor_unknown; } -bool SalDisplay::BestVisual( Display *pDisplay, - int nScreen, - XVisualInfo &rVI ) +bool SalX11Display::BestVisual(Display* pDisplay, int nScreen, XVisualInfo& rVI) { VisualID nDefVID = XVisualIDFromVisual( DefaultVisual( pDisplay, nScreen ) ); VisualID nVID = 0; @@ -228,7 +226,7 @@ static int DisplayYield(int fd, void* data) return 1; } -SalDisplay::SalDisplay( Display *display ) : +SalX11Display::SalX11Display(Display* display) : pXLib_( nullptr ), mpKbdExtension( nullptr ), pDisp_( display ), @@ -244,21 +242,37 @@ SalDisplay::SalDisplay( Display *display ) : m_nLastUserEventTime( CurrentTime ) { #if OSL_DEBUG_LEVEL > 1 - SAL_INFO("vcl.app", "SalDisplay::SalDisplay()."); + SAL_INFO("vcl.app", "SalX11Display::SalX11Display()."); #endif GenericUnixSalData *pData = GetGenericUnixSalData(); - SAL_WARN_IF( pData->GetDisplay(), "vcl", "Second SalDisplay created !!!" ); + SAL_WARN_IF( pData->GetDisplay(), "vcl", "Second SalX11Display created !!!" ); pData->SetDisplay( this ); m_nXDefaultScreen = SalX11Screen( DefaultScreen( pDisp_ ) ); + + Init(); + + pXLib_ = GetX11SalData()->GetLib(); + pXLib_->Insert( ConnectionNumber( pDisp_ ), + this, + reinterpret_cast<YieldFunc>(DisplayHasEvent), + reinterpret_cast<YieldFunc>(DisplayQueue), + reinterpret_cast<YieldFunc>(DisplayYield) ); } -SalDisplay::~SalDisplay() +SalX11Display::~SalX11Display() { #if OSL_DEBUG_LEVEL > 1 - SAL_INFO("vcl.app", "SalDisplay::~SalDisplay()."); + SAL_INFO("vcl.app", "SalX11Display::~SalX11Display()."); #endif + if( pDisp_ ) + { + doDestruct(); + XCloseDisplay( pDisp_ ); + pDisp_ = nullptr; + } + if( pDisp_ ) { doDestruct(); @@ -272,7 +286,7 @@ SalDisplay::~SalDisplay() DeInitRandR(); } -void SalDisplay::doDestruct() +void SalX11Display::doDestruct() { GenericUnixSalData *pData = GetGenericUnixSalData(); @@ -319,40 +333,13 @@ void SalDisplay::doDestruct() pData->SetDisplay( nullptr ); } -SalX11Display::SalX11Display( Display *display ) - : SalDisplay( display ) -{ - Init(); - - pXLib_ = GetX11SalData()->GetLib(); - pXLib_->Insert( ConnectionNumber( pDisp_ ), - this, - reinterpret_cast<YieldFunc>(DisplayHasEvent), - reinterpret_cast<YieldFunc>(DisplayQueue), - reinterpret_cast<YieldFunc>(DisplayYield) ); -} - -SalX11Display::~SalX11Display() -{ -#if OSL_DEBUG_LEVEL > 1 - SAL_INFO("vcl.app", "SalX11Display::~SalX11Display()."); -#endif - if( pDisp_ ) - { - doDestruct(); - XCloseDisplay( pDisp_ ); - pDisp_ = nullptr; - } -} - void SalX11Display::TriggerUserEventProcessing() { if( pXLib_ ) pXLib_->TriggerUserEventProcessing(); } -SalDisplay::ScreenData * -SalDisplay::initScreen( SalX11Screen nXScreen ) const +SalX11Display::ScreenData* SalX11Display::initScreen(SalX11Screen nXScreen) const { if( nXScreen.getXScreen() >= m_aScreens.size() ) nXScreen = m_nXDefaultScreen; @@ -364,7 +351,7 @@ SalDisplay::initScreen( SalX11Screen nXScreen ) const XVisualInfo aVI; Colormap aColMap; - if( SalDisplay::BestVisual( pDisp_, nXScreen.getXScreen(), aVI ) ) // DefaultVisual + if (SalX11Display::BestVisual(pDisp_, nXScreen.getXScreen(), aVI)) // DefaultVisual aColMap = DefaultColormap( pDisp_, nXScreen.getXScreen() ); else aColMap = XCreateColormap( pDisp_, @@ -483,7 +470,7 @@ SalDisplay::initScreen( SalX11Screen nXScreen ) const return pSD; } -void SalDisplay::Init() +void SalX11Display::Init() { for( Cursor & aCsr : aPointerCache_ ) aCsr = None; @@ -570,7 +557,7 @@ void SalX11Display::SetupInput() } // Sound -void SalDisplay::Beep() const +void SalX11Display::Beep() const { XBell( pDisp_, 100 ); } @@ -612,7 +599,7 @@ unsigned int GetKeySymMask(Display* dpy, KeySym nKeySym) } -void SalDisplay::SimulateKeyPress( sal_uInt16 nKeyCode ) +void SalX11Display::SimulateKeyPress(sal_uInt16 nKeyCode) { if (nKeyCode != KEY_CAPSLOCK) return; @@ -631,7 +618,7 @@ void SalDisplay::SimulateKeyPress( sal_uInt16 nKeyCode ) XkbLockModifiers (dpy, XkbUseCoreKbd, nMask, nMask); } -KeyIndicatorState SalDisplay::GetIndicatorState() const +KeyIndicatorState SalX11Display::GetIndicatorState() const { unsigned int _state = 0; KeyIndicatorState nState = KeyIndicatorState::NONE; @@ -647,7 +634,7 @@ KeyIndicatorState SalDisplay::GetIndicatorState() const return nState; } -OUString SalDisplay::GetKeyNameFromKeySym( KeySym nKeySym ) const +OUString SalX11Display::GetKeyNameFromKeySym(KeySym nKeySym) const { OUString aLang = Application::GetSettings().GetUILanguageTag().getLanguage(); OUString aRet; @@ -691,7 +678,7 @@ static KeySym sal_XModifier2Keysym( Display *pDisplay, 0,0 ); } -void SalDisplay::ModifierMapping() +void SalX11Display::ModifierMapping() { XModifierKeymap *pXModMap = XGetModifierMapping( pDisp_ ); @@ -719,7 +706,7 @@ void SalDisplay::ModifierMapping() XFreeModifiermap( pXModMap ); } -OUString SalDisplay::GetKeyName( sal_uInt16 nKeyCode ) const +OUString SalX11Display::GetKeyName(sal_uInt16 nKeyCode) const { OUString aStrMap; OUString aCustomKeyName; @@ -949,7 +936,7 @@ OUString SalDisplay::GetKeyName( sal_uInt16 nKeyCode ) const #define IsISOKey( n ) (0x0000FE00==((n)&0xFFFFFF00)) #endif -sal_uInt16 SalDisplay::GetKeyCode( KeySym keysym, char*pcPrintable ) const +sal_uInt16 SalX11Display::GetKeyCode(KeySym keysym, char* pcPrintable) const { sal_uInt16 nKey = 0; @@ -1357,7 +1344,7 @@ sal_uInt16 SalDisplay::GetKeyCode( KeySym keysym, char*pcPrintable ) const return nKey; } -KeySym SalDisplay::GetKeySym( XKeyEvent *pEvent, +KeySym SalX11Display::GetKeySym( XKeyEvent *pEvent, char *pPrintable, int *pLen, KeySym *pUnmodifiedKeySym, @@ -1460,7 +1447,7 @@ const unsigned char nullcurs_bits[] = { 0x00, 0x00, 0x00, 0x00 }; nXHot = name##curs_x_hot; \ nYHot = name##curs_y_hot -Cursor SalDisplay::GetPointer( PointerStyle ePointerStyle ) +Cursor SalX11Display::GetPointer(PointerStyle ePointerStyle) { Cursor &aCur = aPointerCache_[ePointerStyle]; @@ -1801,7 +1788,7 @@ Cursor SalDisplay::GetPointer( PointerStyle ePointerStyle ) return aCur; } -int SalDisplay::CaptureMouse( SalFrame *pCapture ) +int SalX11Display::CaptureMouse(SalFrame* pCapture) { static const char* pEnv = getenv( "SAL_NO_MOUSEGRABS" ); @@ -1832,7 +1819,7 @@ int SalDisplay::CaptureMouse( SalFrame *pCapture ) if( ret != GrabSuccess ) { - SAL_WARN("vcl", "SalDisplay::CaptureMouse could not grab pointer: " << ret); + SAL_WARN("vcl", "SalX11Display::CaptureMouse could not grab pointer: " << ret); return -1; } } @@ -1859,7 +1846,7 @@ void SalX11Display::Yield() XEvent aEvent; DBG_ASSERT(GetSalInstance()->GetYieldMutex()->IsCurrentThread(), - "will crash soon since solar mutex not locked in SalDisplay::Yield" ); + "will crash soon since solar mutex not locked in SalX11Display::Yield" ); XNextEvent( pDisp_, &aEvent ); @@ -1869,13 +1856,13 @@ void SalX11Display::Yield() if( GetX11SalData()->HasXErrorOccurred() ) { XFlush( pDisp_ ); - DbgPrintDisplayEvent("SalDisplay::Yield (WasXError)", &aEvent); + DbgPrintDisplayEvent("SalX11Display::Yield (WasXError)", &aEvent); } #endif GetX11SalData()->ResetXErrorOccurred(); } -void SalX11Display::Dispatch( XEvent *pEvent ) +void SalX11Display::Dispatch(XEvent* pEvent) { SalI18N_InputMethod* const pInputMethod = pXLib_ ? pXLib_->GetInputMethod() : nullptr; @@ -1982,7 +1969,7 @@ void SalX11Display::Dispatch( XEvent *pEvent ) } #ifdef DBG_UTIL -void SalDisplay::DbgPrintDisplayEvent(const char *pComment, const XEvent *pEvent) const +void SalX11Display::DbgPrintDisplayEvent(const char* pComment, const XEvent* pEvent) const { static const char* const EventNames[] = { @@ -2153,7 +2140,7 @@ void SalDisplay::DbgPrintDisplayEvent(const char *pComment, const XEvent *pEvent << " w=" << pEvent->xany.window); } -void SalDisplay::PrintInfo() const +void SalX11Display::PrintInfo() const { if( IsDisplay() ) { @@ -2194,7 +2181,7 @@ void SalDisplay::PrintInfo() const } #endif -void SalDisplay::addXineramaScreenUnique( int i, tools::Long i_nX, tools::Long i_nY, tools::Long i_nWidth, tools::Long i_nHeight ) +void SalX11Display::addXineramaScreenUnique( int i, tools::Long i_nX, tools::Long i_nY, tools::Long i_nWidth, tools::Long i_nHeight ) { // see if any frame buffers are at the same coordinates // this can happen with weird configuration e.g. on @@ -2218,7 +2205,7 @@ void SalDisplay::addXineramaScreenUnique( int i, tools::Long i_nX, tools::Long i m_aXineramaScreens.emplace_back( AbsoluteScreenPixelPoint( i_nX, i_nY ), AbsoluteScreenPixelSize( i_nWidth, i_nHeight ) ); } -void SalDisplay::InitXinerama() +void SalX11Display::InitXinerama() { if( m_aScreens.size() > 1 ) { @@ -2264,7 +2251,7 @@ extern "C" { static Bool timestamp_predicate( Display*, XEvent* i_pEvent, XPointer i_pArg ) { - SalDisplay* pSalDisplay = reinterpret_cast<SalDisplay*>(i_pArg); + SalX11Display* pSalDisplay = reinterpret_cast<SalX11Display*>(i_pArg); if( i_pEvent->type == PropertyNotify && i_pEvent->xproperty.window == pSalDisplay->GetDrawable( pSalDisplay->GetDefaultXScreen() ) && i_pEvent->xproperty.atom == pSalDisplay->getWMAdaptor()->getAtom( WMAdaptor::SAL_GETTIMEEVENT ) @@ -2275,7 +2262,7 @@ extern "C" } } -Time SalDisplay::GetEventTimeImpl( bool i_bAlwaysReget ) const +Time SalX11Display::GetEventTimeImpl(bool i_bAlwaysReget) const { if( m_nLastUserEventTime == CurrentTime || i_bAlwaysReget ) { @@ -2285,7 +2272,7 @@ Time SalDisplay::GetEventTimeImpl( bool i_bAlwaysReget ) const Atom nAtom = getWMAdaptor()->getAtom( WMAdaptor::SAL_GETTIMEEVENT ); XChangeProperty( GetDisplay(), GetDrawable( GetDefaultXScreen() ), nAtom, nAtom, 8, PropModeReplace, &c, 1 ); - XIfEvent( GetDisplay(), &aEvent, timestamp_predicate, reinterpret_cast<XPointer>(const_cast<SalDisplay *>(this))); + XIfEvent( GetDisplay(), &aEvent, timestamp_predicate, reinterpret_cast<XPointer>(const_cast<SalX11Display*>(this))); m_nLastUserEventTime = aEvent.xproperty.time; } return m_nLastUserEventTime; @@ -2306,7 +2293,7 @@ SalVisual::SalVisual( const XVisualInfo* pXVI ) // Color is RGB (ABGR) a=0xFF000000, r=0xFF0000, g=0xFF00, b=0xFF -SalColormap::SalColormap( const SalDisplay *pDisplay, Colormap hColormap, +SalColormap::SalColormap( const SalX11Display* pDisplay, Colormap hColormap, SalX11Screen nXScreen ) : m_pDisplay( pDisplay ), m_hColormap( hColormap ) diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx index 256a3f7c43d3..c96181ec5fe9 100644 --- a/vcl/unx/generic/app/salinst.cxx +++ b/vcl/unx/generic/app/salinst.cxx @@ -85,7 +85,7 @@ X11SalInstance::~X11SalInstance() // close session management SessionManagerClient::close(); - // dispose SalDisplay list from SalData + // dispose SalX11Display list from SalData // would be done in a static destructor else which is // a little late GetX11SalData()->Dispose(); @@ -221,7 +221,7 @@ void X11SalInstance::AddToRecentDocumentList(const OUString&, const OUString&, c void X11SalInstance::PostPrintersChanged() { - SalDisplay* pDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); + SalX11Display* pDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); for (auto pSalFrame : pDisp->getFrames() ) pDisp->PostEvent( pSalFrame, nullptr, SalEvent::PrinterChanged ); } diff --git a/vcl/unx/generic/app/sm.cxx b/vcl/unx/generic/app/sm.cxx index b38ea0184d82..20234681c9f3 100644 --- a/vcl/unx/generic/app/sm.cxx +++ b/vcl/unx/generic/app/sm.cxx @@ -518,7 +518,7 @@ void SessionManagerClient::open(SalSession * pSession) pClientID = nullptr; } - SalDisplay* pDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); + SalX11Display* pDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); if( pDisp->GetDrawable(pDisp->GetDefaultXScreen()) && !m_aClientID.isEmpty() ) { SAL_INFO("vcl.sm.debug", " SmcOpenConnection open: pDisp->GetDrawable = true"); diff --git a/vcl/unx/generic/app/wmadaptor.cxx b/vcl/unx/generic/app/wmadaptor.cxx index dfbc63c0e7e0..2500b82ca9fb 100644 --- a/vcl/unx/generic/app/wmadaptor.cxx +++ b/vcl/unx/generic/app/wmadaptor.cxx @@ -49,7 +49,7 @@ class NetWMAdaptor : public WMAdaptor void initAtoms(); virtual bool isValid() const override; public: - explicit NetWMAdaptor( SalDisplay* ); + explicit NetWMAdaptor(SalX11Display*); virtual void setWMName( X11SalFrame* pFrame, const OUString& rWMName ) const override; virtual void maximizeFrame( X11SalFrame* pFrame, bool bHorizontal = true, bool bVertical = true ) const override; @@ -69,7 +69,7 @@ class GnomeWMAdaptor : public WMAdaptor void initAtoms(); virtual bool isValid() const override; public: - explicit GnomeWMAdaptor( SalDisplay * ); + explicit GnomeWMAdaptor(SalX11Display*); virtual void maximizeFrame( X11SalFrame* pFrame, bool bHorizontal = true, bool bVertical = true ) const override; virtual void enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const override; @@ -173,7 +173,7 @@ static int compareProtocol( const void* pLeft, const void* pRight ) } } -std::unique_ptr<WMAdaptor> WMAdaptor::createWMAdaptor( SalDisplay* pSalDisplay ) +std::unique_ptr<WMAdaptor> WMAdaptor::createWMAdaptor(SalX11Display* pSalDisplay) { std::unique_ptr<WMAdaptor> pAdaptor; @@ -217,7 +217,7 @@ std::unique_ptr<WMAdaptor> WMAdaptor::createWMAdaptor( SalDisplay* pSalDisplay ) * WMAdaptor constructor */ -WMAdaptor::WMAdaptor( SalDisplay* pDisplay ) : +WMAdaptor::WMAdaptor(SalX11Display* pDisplay) : m_pSalDisplay( pDisplay ), m_bEnableAlwaysOnTopWorks( false ), m_bLegacyPartialFullscreen( false ), @@ -332,7 +332,7 @@ WMAdaptor::~WMAdaptor() * NetWMAdaptor constructor */ -NetWMAdaptor::NetWMAdaptor( SalDisplay* pSalDisplay ) : +NetWMAdaptor::NetWMAdaptor(SalX11Display* pSalDisplay) : WMAdaptor( pSalDisplay ) { // currently all _NET WMs do transient like expected @@ -516,7 +516,7 @@ NetWMAdaptor::NetWMAdaptor( SalDisplay* pSalDisplay ) : * GnomeWMAdaptor constructor */ -GnomeWMAdaptor::GnomeWMAdaptor( SalDisplay* pSalDisplay ) : +GnomeWMAdaptor::GnomeWMAdaptor(SalX11Display* pSalDisplay) : WMAdaptor( pSalDisplay ), m_bValid( false ) { diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx index cd3c591cf5d6..ec40d1f2c708 100644 --- a/vcl/unx/generic/gdi/salgdi.cxx +++ b/vcl/unx/generic/gdi/salgdi.cxx @@ -155,7 +155,7 @@ void X11SalGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) // cons return; } - const SalDisplay *pDisplay = GetDisplay(); + const SalX11Display* pDisplay = GetDisplay(); if (!pDisplay) { SAL_WARN( "vcl", "Null display"); diff --git a/vcl/unx/generic/gdi/salvd.cxx b/vcl/unx/generic/gdi/salvd.cxx index fd7e08e35118..26eafa3b0611 100644 --- a/vcl/unx/generic/gdi/salvd.cxx +++ b/vcl/unx/generic/gdi/salvd.cxx @@ -75,7 +75,7 @@ std::unique_ptr<SalVirtualDevice> X11SalInstance::CreateVirtualDevice(SalGraphic void X11SalGraphics::Init(X11SalVirtualDevice *pDevice, SalColormap* pColormap, bool bDeleteColormap, bool bAlphaMaskTransparent) { - SalDisplay *pDisplay = pDevice->GetDisplay(); + SalX11Display* pDisplay = pDevice->GetDisplay(); m_nXScreen = pDevice->GetXScreenNumber(); int nVisualDepth = pDisplay->GetColormap( m_nXScreen ).GetVisual().GetDepth(); diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index 74f1e034dfdb..e0aeb08e21c0 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -95,7 +95,7 @@ static ::Window hPresentationWindow = None, hPresFocusWindow = None; static ::std::list< ::Window > aPresentationReparentList; static int nVisibleFloats = 0; -static void doReparentPresentationDialogues( SalDisplay const * pDisplay ) +static void doReparentPresentationDialogues(SalX11Display const * pDisplay ) { GetGenericUnixSalData()->ErrorTrapPush(); for (auto const& elem : aPresentationReparentList) @@ -784,7 +784,7 @@ X11SalFrame::~X11SalFrame() if( mpParent ) mpParent->maChildren.remove( this ); - // deregister on SalDisplay + // deregister on SalX11Display pDisplay_->deregisterFrame( this ); // unselect all events, some may be still in the queue anyway diff --git a/vcl/unx/generic/window/salobj.cxx b/vcl/unx/generic/window/salobj.cxx index 7f3631878465..21038e51ed41 100644 --- a/vcl/unx/generic/window/salobj.cxx +++ b/vcl/unx/generic/window/salobj.cxx @@ -59,7 +59,7 @@ X11SalObject* X11SalObject::CreateObject( SalFrame* pParent, SystemWindowData* p pObject->mpParent = pParent; - SalDisplay* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); + SalX11Display* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); const SystemEnvData& rEnv = pParent->GetSystemData(); Display* pDisp = pSalDisp->GetDisplay(); ::Window aObjectParent = static_cast<::Window>(rEnv.GetWindowHandle(pParent)); @@ -469,7 +469,7 @@ bool X11SalObject::Dispatch( XEvent* pEvent ) void X11SalObject::SetLeaveEnterBackgrounds(const css::uno::Sequence<css::uno::Any>& rLeaveArgs, const css::uno::Sequence<css::uno::Any>& rEnterArgs) { - SalDisplay* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); + SalX11Display* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); Display* pDisp = pSalDisp->GetDisplay(); ::Window aObjectParent = maParentWin; diff --git a/vcl/unx/x11/x11sys.cxx b/vcl/unx/x11/x11sys.cxx index 9e094df3ebef..21a334009b30 100644 --- a/vcl/unx/x11/x11sys.cxx +++ b/vcl/unx/x11/x11sys.cxx @@ -42,21 +42,21 @@ X11SalSystem::~X11SalSystem() // for the moment only handle xinerama case unsigned int X11SalSystem::GetDisplayScreenCount() { - SalDisplay* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); + SalX11Display* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); return pSalDisp->IsXinerama() ? pSalDisp->GetXineramaScreens().size() : pSalDisp->GetXScreenCount(); } unsigned int X11SalSystem::GetDisplayBuiltInScreen() { - SalDisplay* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); + SalX11Display* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); return pSalDisp->GetDefaultXScreen().getXScreen(); } AbsoluteScreenPixelRectangle X11SalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen ) { AbsoluteScreenPixelRectangle aRet; - SalDisplay* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); + SalX11Display* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); if( pSalDisp->IsXinerama() ) { const std::vector< AbsoluteScreenPixelRectangle >& rScreens = pSalDisp->GetXineramaScreens(); @@ -69,7 +69,7 @@ AbsoluteScreenPixelRectangle X11SalSystem::GetDisplayScreenPosSizePixel( unsigne } else { - const SalDisplay::ScreenData& rScreen = + const SalX11Display::ScreenData& rScreen = pSalDisp->getDataForScreen( SalX11Screen( nScreen ) ); aRet = AbsoluteScreenPixelRectangle( AbsoluteScreenPixelPoint( 0, 0 ), rScreen.m_aSize ); } commit a80c60dd593b56ecf1134cc20882b16e97b9805c Author: Michael Weghorn <[email protected]> AuthorDate: Wed Feb 25 09:17:49 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Wed Feb 25 14:43:42 2026 +0100 vcl: Move static SalX11Display helpers further up This is in preparation of merging SalX11Display and SalDisplay in an upcoming commit. (In order to be able to use them in what is now the SalDisplay ctor, move the static helpers above that one, to avoid having to forward-declare them.) Do this in a separate preparatory commit to keep the diff of the upcoming commit smaller/clearer. Change-Id: If186390d116eab1b46bf5c0bb05921db12f84f3a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200298 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index 0fdfaceb60eb..0837fcfe8044 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -190,6 +190,44 @@ bool SalDisplay::BestVisual( Display *pDisplay, return rVI.visualid == nDefVID; } +static int DisplayHasEvent(int fd, void* data) +{ + auto pDisplay = static_cast<SalX11Display*>(data); + SAL_WARN_IF(ConnectionNumber(pDisplay->GetDisplay()) != fd, "vcl", + "wrong fd in DisplayHasEvent"); + if (!pDisplay->IsDisplay()) + return 0; + + bool result; + + SolarMutexGuard aGuard; + result = pDisplay->IsEvent(); + return int(result); +} + +static int DisplayQueue(int fd, void* data) +{ + auto pDisplay = static_cast<SalX11Display*>(data); + SAL_WARN_IF(ConnectionNumber(pDisplay->GetDisplay()) != fd, "vcl", + "wrong fd in DisplayHasEvent"); + int result; + + SolarMutexGuard aGuard; + result = XEventsQueued(pDisplay->GetDisplay(), QueuedAfterReading); + return result; +} + +static int DisplayYield(int fd, void* data) +{ + auto pDisplay = static_cast<SalX11Display*>(data); + SAL_WARN_IF(ConnectionNumber(pDisplay->GetDisplay()) != fd, "vcl", + "wrong fd in DisplayHasEvent"); + + SolarMutexGuard aGuard; + pDisplay->Yield(); + return 1; +} + SalDisplay::SalDisplay( Display *display ) : pXLib_( nullptr ), mpKbdExtension( nullptr ), @@ -281,43 +319,6 @@ void SalDisplay::doDestruct() pData->SetDisplay( nullptr ); } -static int DisplayHasEvent( int fd, void * data ) -{ - auto pDisplay = static_cast<SalX11Display *>(data); - SAL_WARN_IF( ConnectionNumber( pDisplay->GetDisplay() ) != fd, "vcl", - "wrong fd in DisplayHasEvent" ); - if( ! pDisplay->IsDisplay() ) - return 0; - - bool result; - - SolarMutexGuard aGuard; - result = pDisplay->IsEvent(); - return int(result); -} -static int DisplayQueue( int fd, void * data ) -{ - auto pDisplay = static_cast<SalX11Display *>(data); - SAL_WARN_IF( ConnectionNumber( pDisplay->GetDisplay() ) != fd, "vcl", - "wrong fd in DisplayHasEvent" ); - int result; - - SolarMutexGuard aGuard; - result = XEventsQueued( pDisplay->GetDisplay(), - QueuedAfterReading ); - return result; -} -static int DisplayYield( int fd, void * data ) -{ - auto pDisplay = static_cast<SalX11Display *>(data); - SAL_WARN_IF( ConnectionNumber( pDisplay->GetDisplay() ) != fd, "vcl", - "wrong fd in DisplayHasEvent" ); - - SolarMutexGuard aGuard; - pDisplay->Yield(); - return 1; -} - SalX11Display::SalX11Display( Display *display ) : SalDisplay( display ) {
