vcl/unx/generic/app/i18n_ic.cxx | 86 +- vcl/unx/generic/app/i18n_im.cxx | 44 - vcl/unx/generic/app/randrwrapper.cxx | 68 +- vcl/unx/generic/app/saldata.cxx | 58 - vcl/unx/generic/app/saldisp.cxx | 154 ++--- vcl/unx/generic/app/sm.cxx | 50 - vcl/unx/generic/app/wmadaptor.cxx | 712 ++++++++++++------------ vcl/unx/generic/dtrans/X11_droptarget.cxx | 42 - vcl/unx/generic/dtrans/X11_selection.cxx | 296 ++++----- vcl/unx/generic/dtrans/bmp.cxx | 28 vcl/unx/generic/fontmanager/fontconfig.cxx | 24 vcl/unx/generic/fontmanager/helper.cxx | 24 vcl/unx/generic/gdi/gdiimpl.cxx | 135 ++-- vcl/unx/generic/gdi/salbmp.cxx | 31 - vcl/unx/generic/gdi/salgdi.cxx | 24 vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 30 - vcl/unx/generic/print/common_gfx.cxx | 116 +-- vcl/unx/generic/print/genprnpsp.cxx | 56 - vcl/unx/generic/print/prtsetup.cxx | 68 +- vcl/unx/generic/printer/cupsmgr.cxx | 22 vcl/unx/generic/printer/jobdata.cxx | 30 - vcl/unx/generic/printer/ppdparser.cxx | 159 ++--- vcl/unx/generic/window/salframe.cxx | 320 +++++----- vcl/unx/generic/window/screensaverinhibitor.cxx | 24 vcl/unx/gtk3/a11y/gtk3atklistener.cxx | 100 +-- vcl/unx/gtk3/a11y/gtk3atkutil.cxx | 44 - vcl/unx/gtk3/gtk3gloactiongroup.cxx | 36 - vcl/unx/gtk3/gtk3gtkframe.cxx | 434 +++++++------- vcl/unx/gtk3/gtk3gtkinst.cxx | 222 +++---- vcl/unx/gtk3/gtk3gtkobject.cxx | 58 - vcl/unx/gtk3/gtk3gtksalmenu.cxx | 38 - vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx | 42 - vcl/unx/gtk3/gtk3salprn-gtk.cxx | 68 +- 33 files changed, 1824 insertions(+), 1819 deletions(-)
New commits: commit 6fc2a300ad8b1c6936b513eff94fd527ea74b469 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Aug 3 23:52:11 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Aug 4 01:40:45 2020 +0200 loplugin:flatten in vcl/unx Change-Id: Ib9df009a51db1ed96c6eea7bda68e288755e7a56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100032 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/unx/generic/app/i18n_ic.cxx b/vcl/unx/generic/app/i18n_ic.cxx index 6f94fe938818..8f1a814233ea 100644 --- a/vcl/unx/generic/app/i18n_ic.cxx +++ b/vcl/unx/generic/app/i18n_ic.cxx @@ -363,23 +363,23 @@ SalI18N_InputContext::Unmap() void SalI18N_InputContext::Map( SalFrame *pFrame ) { - if( mbUseable ) + if( !mbUseable ) + return; + + if( !pFrame ) + return; + + if ( maContext == nullptr ) { - if( pFrame ) - { - if ( maContext == nullptr ) - { - SalI18N_InputMethod *pInputMethod; - pInputMethod = vcl_sal::getSalDisplay(GetGenericUnixSalData())->GetInputMethod(); + SalI18N_InputMethod *pInputMethod; + pInputMethod = vcl_sal::getSalDisplay(GetGenericUnixSalData())->GetInputMethod(); - maContext = XCreateIC( pInputMethod->GetMethod(), - XNVaNestedList, mpAttributes, - nullptr ); - } - if( maClientData.pFrame != pFrame ) - SetICFocus( pFrame ); - } + maContext = XCreateIC( pInputMethod->GetMethod(), + XNVaNestedList, mpAttributes, + nullptr ); } + if( maClientData.pFrame != pFrame ) + SetICFocus( pFrame ); } // Handle DestroyCallbacks @@ -541,28 +541,28 @@ SalI18N_InputContext::UpdateSpotLocation() void SalI18N_InputContext::SetICFocus( SalFrame* pFocusFrame ) { - if ( mbUseable && (maContext != nullptr) ) - { - maClientData.pFrame = pFocusFrame; + if ( !(mbUseable && (maContext != nullptr)) ) + return; - const SystemEnvData* pEnv = pFocusFrame->GetSystemData(); - ::Window aClientWindow = pEnv->aShellWindow; - ::Window aFocusWindow = pEnv->aWindow; + maClientData.pFrame = pFocusFrame; - XSetICValues( maContext, - XNFocusWindow, aFocusWindow, - XNClientWindow, aClientWindow, - nullptr ); + const SystemEnvData* pEnv = pFocusFrame->GetSystemData(); + ::Window aClientWindow = pEnv->aShellWindow; + ::Window aFocusWindow = pEnv->aWindow; - if( maClientData.aInputEv.mpTextAttr ) - { - sendEmptyCommit(pFocusFrame); - // begin preedit again - vcl_sal::getSalDisplay(GetGenericUnixSalData())->SendInternalEvent( pFocusFrame, &maClientData.aInputEv, SalEvent::ExtTextInput ); - } + XSetICValues( maContext, + XNFocusWindow, aFocusWindow, + XNClientWindow, aClientWindow, + nullptr ); - XSetICFocus( maContext ); + if( maClientData.aInputEv.mpTextAttr ) + { + sendEmptyCommit(pFocusFrame); + // begin preedit again + vcl_sal::getSalDisplay(GetGenericUnixSalData())->SendInternalEvent( pFocusFrame, &maClientData.aInputEv, SalEvent::ExtTextInput ); } + + XSetICFocus( maContext ); } void @@ -583,20 +583,20 @@ SalI18N_InputContext::UnsetICFocus() void SalI18N_InputContext::EndExtTextInput() { - if ( mbUseable && (maContext != nullptr) && maClientData.pFrame ) + if ( !mbUseable || (maContext == nullptr) || !maClientData.pFrame ) + return; + + vcl::DeletionListener aDel( maClientData.pFrame ); + // delete preedit in sal (commit an empty string) + sendEmptyCommit( maClientData.pFrame ); + if( ! aDel.isDeleted() ) { - vcl::DeletionListener aDel( maClientData.pFrame ); - // delete preedit in sal (commit an empty string) - sendEmptyCommit( maClientData.pFrame ); - if( ! aDel.isDeleted() ) + // mark previous preedit state again (will e.g. be sent at focus gain) + maClientData.aInputEv.mpTextAttr = maClientData.aInputFlags.data(); + if( static_cast<X11SalFrame*>(maClientData.pFrame)->hasFocus() ) { - // mark previous preedit state again (will e.g. be sent at focus gain) - maClientData.aInputEv.mpTextAttr = maClientData.aInputFlags.data(); - if( static_cast<X11SalFrame*>(maClientData.pFrame)->hasFocus() ) - { - // begin preedit again - vcl_sal::getSalDisplay(GetGenericUnixSalData())->SendInternalEvent( maClientData.pFrame, &maClientData.aInputEv, SalEvent::ExtTextInput ); - } + // begin preedit again + vcl_sal::getSalDisplay(GetGenericUnixSalData())->SendInternalEvent( maClientData.pFrame, &maClientData.aInputEv, SalEvent::ExtTextInput ); } } } diff --git a/vcl/unx/generic/app/i18n_im.cxx b/vcl/unx/generic/app/i18n_im.cxx index a9e9fb42fb87..6a655ca39ea1 100644 --- a/vcl/unx/generic/app/i18n_im.cxx +++ b/vcl/unx/generic/app/i18n_im.cxx @@ -192,35 +192,35 @@ SalI18N_InputMethod::SetLocale() { // check whether we want an Input Method engine, if we don't we // do not need to set the locale - if ( mbUseable ) + if ( !mbUseable ) + return; + + char *locale = SetSystemLocale( "" ); + if ( (!IsXWindowCompatibleLocale(locale)) || IsPosixLocale(locale) ) { - char *locale = SetSystemLocale( "" ); - if ( (!IsXWindowCompatibleLocale(locale)) || IsPosixLocale(locale) ) - { - osl_setThreadTextEncoding (RTL_TEXTENCODING_ISO_8859_1); - locale = SetSystemLocale( "en_US" ); + osl_setThreadTextEncoding (RTL_TEXTENCODING_ISO_8859_1); + locale = SetSystemLocale( "en_US" ); #ifdef __sun - SetSystemEnvironment( "en_US" ); + SetSystemEnvironment( "en_US" ); #endif - if (! IsXWindowCompatibleLocale(locale)) - { - locale = SetSystemLocale( "C" ); + if (! IsXWindowCompatibleLocale(locale)) + { + locale = SetSystemLocale( "C" ); #ifdef __sun - SetSystemEnvironment( "C" ); + SetSystemEnvironment( "C" ); #endif - if (! IsXWindowCompatibleLocale(locale)) - mbUseable = False; - } + if (! IsXWindowCompatibleLocale(locale)) + mbUseable = False; } + } - // must not fail if mbUseable since XSupportsLocale() asserts success - if ( mbUseable && XSetLocaleModifiers("") == nullptr ) - { - SAL_WARN("vcl.app", - "I18N: Can't set X modifiers for locale \"" - << locale << "\"."); - mbUseable = False; - } + // must not fail if mbUseable since XSupportsLocale() asserts success + if ( mbUseable && XSetLocaleModifiers("") == nullptr ) + { + SAL_WARN("vcl.app", + "I18N: Can't set X modifiers for locale \"" + << locale << "\"."); + mbUseable = False; } } diff --git a/vcl/unx/generic/app/randrwrapper.cxx b/vcl/unx/generic/app/randrwrapper.cxx index ad884435cb36..431c70ae37af 100644 --- a/vcl/unx/generic/app/randrwrapper.cxx +++ b/vcl/unx/generic/app/randrwrapper.cxx @@ -131,47 +131,47 @@ void SalDisplay::processRandREvent( XEvent* pEvent ) { #ifdef USE_RANDR XConfigureEvent* pCnfEvent=reinterpret_cast<XConfigureEvent*>(pEvent); - if( pWrapper && pWrapper->XRRRootToScreen(GetDisplay(),pCnfEvent->window) != -1 ) + if( !pWrapper || pWrapper->XRRRootToScreen(GetDisplay(),pCnfEvent->window) == -1 ) + return; + + int nRet = pWrapper->XRRUpdateConfiguration( pEvent ); + if( nRet != 1 || pEvent->type == ConfigureNotify) // this should then be a XRRScreenChangeNotifyEvent + return; + + // update screens + bool bNotify = false; + for(ScreenData & rScreen : m_aScreens) { - int nRet = pWrapper->XRRUpdateConfiguration( pEvent ); - if( nRet == 1 && pEvent->type != ConfigureNotify) // this should then be a XRRScreenChangeNotifyEvent + if( rScreen.m_bInit ) { - // update screens - bool bNotify = false; - for(ScreenData & rScreen : m_aScreens) - { - if( rScreen.m_bInit ) - { - XRRScreenConfiguration *pConfig = nullptr; - XRRScreenSize *pSizes = nullptr; - int nSizes = 0; - Rotation nRot = 0; - SizeID nId = 0; - - pConfig = pWrapper->XRRGetScreenInfo( GetDisplay(), rScreen.m_aRoot ); - nId = pWrapper->XRRConfigCurrentConfiguration( pConfig, &nRot ); - pSizes = pWrapper->XRRConfigSizes( pConfig, &nSizes ); - XRRScreenSize *pTargetSize = pSizes + nId; - - bNotify = bNotify || - rScreen.m_aSize.Width() != pTargetSize->width || - rScreen.m_aSize.Height() != pTargetSize->height; - - rScreen.m_aSize = Size( pTargetSize->width, pTargetSize->height ); - - pWrapper->XRRFreeScreenConfigInfo( pConfig ); + XRRScreenConfiguration *pConfig = nullptr; + XRRScreenSize *pSizes = nullptr; + int nSizes = 0; + Rotation nRot = 0; + SizeID nId = 0; + + pConfig = pWrapper->XRRGetScreenInfo( GetDisplay(), rScreen.m_aRoot ); + nId = pWrapper->XRRConfigCurrentConfiguration( pConfig, &nRot ); + pSizes = pWrapper->XRRConfigSizes( pConfig, &nSizes ); + XRRScreenSize *pTargetSize = pSizes + nId; + + bNotify = bNotify || + rScreen.m_aSize.Width() != pTargetSize->width || + rScreen.m_aSize.Height() != pTargetSize->height; + + rScreen.m_aSize = Size( pTargetSize->width, pTargetSize->height ); + + pWrapper->XRRFreeScreenConfigInfo( pConfig ); #if OSL_DEBUG_LEVEL > 1 - SAL_INFO("vcl.app", "screen " << nId - << " changed to size " << (int)pTargetSize->width - << "x" << (int)pTargetSize->height); + SAL_INFO("vcl.app", "screen " << nId + << " changed to size " << (int)pTargetSize->width + << "x" << (int)pTargetSize->height); #endif - } - } - if( bNotify ) - emitDisplayChanged(); } } + if( bNotify ) + emitDisplayChanged(); #else (void)this; (void)pEvent; diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx index 1b58c7dab0f2..c5a97ee4d5cd 100644 --- a/vcl/unx/generic/app/saldata.cxx +++ b/vcl/unx/generic/app/saldata.cxx @@ -318,39 +318,39 @@ SalXLib::SalXLib() m_pDisplay = nullptr; m_pTimeoutFDS[0] = m_pTimeoutFDS[1] = -1; - if (pipe (m_pTimeoutFDS) != -1) - { - // initialize 'wakeup' pipe. - int flags; + if (pipe (m_pTimeoutFDS) == -1) + return; - // set close-on-exec descriptor flag. - if ((flags = fcntl (m_pTimeoutFDS[0], F_GETFD)) != -1) - { - flags |= FD_CLOEXEC; - (void)fcntl(m_pTimeoutFDS[0], F_SETFD, flags); - } - if ((flags = fcntl (m_pTimeoutFDS[1], F_GETFD)) != -1) - { - flags |= FD_CLOEXEC; - (void)fcntl(m_pTimeoutFDS[1], F_SETFD, flags); - } + // initialize 'wakeup' pipe. + int flags; - // set non-blocking I/O flag. - if ((flags = fcntl (m_pTimeoutFDS[0], F_GETFL)) != -1) - { - flags |= O_NONBLOCK; - (void)fcntl(m_pTimeoutFDS[0], F_SETFL, flags); - } - if ((flags = fcntl (m_pTimeoutFDS[1], F_GETFL)) != -1) - { - flags |= O_NONBLOCK; - (void)fcntl(m_pTimeoutFDS[1], F_SETFL, flags); - } + // set close-on-exec descriptor flag. + if ((flags = fcntl (m_pTimeoutFDS[0], F_GETFD)) != -1) + { + flags |= FD_CLOEXEC; + (void)fcntl(m_pTimeoutFDS[0], F_SETFD, flags); + } + if ((flags = fcntl (m_pTimeoutFDS[1], F_GETFD)) != -1) + { + flags |= FD_CLOEXEC; + (void)fcntl(m_pTimeoutFDS[1], F_SETFD, flags); + } - // insert [0] into read descriptor set. - FD_SET( m_pTimeoutFDS[0], &aReadFDS_ ); - nFDs_ = m_pTimeoutFDS[0] + 1; + // set non-blocking I/O flag. + if ((flags = fcntl (m_pTimeoutFDS[0], F_GETFL)) != -1) + { + flags |= O_NONBLOCK; + (void)fcntl(m_pTimeoutFDS[0], F_SETFL, flags); + } + if ((flags = fcntl (m_pTimeoutFDS[1], F_GETFL)) != -1) + { + flags |= O_NONBLOCK; + (void)fcntl(m_pTimeoutFDS[1], F_SETFL, flags); } + + // insert [0] into read descriptor set. + FD_SET( m_pTimeoutFDS[0], &aReadFDS_ ); + nFDs_ = m_pTimeoutFDS[0] + 1; } SalXLib::~SalXLib() diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index 679014cd53be..1b029e031f64 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -712,21 +712,21 @@ unsigned int GetKeySymMask(Display* dpy, KeySym nKeySym) void SalDisplay::SimulateKeyPress( sal_uInt16 nKeyCode ) { - if (nKeyCode == KEY_CAPSLOCK) - { - Display* dpy = GetDisplay(); - if (!InitXkb(dpy)) - return; + if (nKeyCode != KEY_CAPSLOCK) + return; - unsigned int nMask = GetKeySymMask(dpy, XK_Caps_Lock); - XkbStateRec xkbState; - XkbGetState(dpy, XkbUseCoreKbd, &xkbState); - unsigned int nCapsLockState = xkbState.locked_mods & nMask; - if (nCapsLockState) - XkbLockModifiers (dpy, XkbUseCoreKbd, nMask, 0); - else - XkbLockModifiers (dpy, XkbUseCoreKbd, nMask, nMask); - } + Display* dpy = GetDisplay(); + if (!InitXkb(dpy)) + return; + + unsigned int nMask = GetKeySymMask(dpy, XK_Caps_Lock); + XkbStateRec xkbState; + XkbGetState(dpy, XkbUseCoreKbd, &xkbState); + unsigned int nCapsLockState = xkbState.locked_mods & nMask; + if (nCapsLockState) + XkbLockModifiers (dpy, XkbUseCoreKbd, nMask, 0); + else + XkbLockModifiers (dpy, XkbUseCoreKbd, nMask, nMask); } KeyIndicatorState SalDisplay::GetIndicatorState() const @@ -2288,28 +2288,28 @@ void SalDisplay::InitXinerama() return; // multiple screens mean no xinerama } #if defined(USE_XINERAMA_XORG) - if( XineramaIsActive( pDisp_ ) ) + if( !XineramaIsActive( pDisp_ ) ) + return; + + int nFramebuffers = 1; + XineramaScreenInfo* pScreens = XineramaQueryScreens( pDisp_, &nFramebuffers ); + if( !pScreens ) + return; + + if( nFramebuffers > 1 ) { - int nFramebuffers = 1; - XineramaScreenInfo* pScreens = XineramaQueryScreens( pDisp_, &nFramebuffers ); - if( pScreens ) + m_aXineramaScreens = std::vector<tools::Rectangle>(); + m_aXineramaScreenIndexMap = std::vector<int>(nFramebuffers); + for( int i = 0; i < nFramebuffers; i++ ) { - if( nFramebuffers > 1 ) - { - m_aXineramaScreens = std::vector<tools::Rectangle>(); - m_aXineramaScreenIndexMap = std::vector<int>(nFramebuffers); - for( int i = 0; i < nFramebuffers; i++ ) - { - addXineramaScreenUnique( i, pScreens[i].x_org, - pScreens[i].y_org, - pScreens[i].width, - pScreens[i].height ); - } - m_bXinerama = m_aXineramaScreens.size() > 1; - } - XFree( pScreens ); + addXineramaScreenUnique( i, pScreens[i].x_org, + pScreens[i].y_org, + pScreens[i].width, + pScreens[i].height ); } + m_bXinerama = m_aXineramaScreens.size() > 1; } + XFree( pScreens ); #endif #if OSL_DEBUG_LEVEL > 1 if( m_bXinerama ) @@ -2395,61 +2395,61 @@ SalVisual::SalVisual(): SalVisual::SalVisual( const XVisualInfo* pXVI ) { *static_cast<XVisualInfo*>(this) = *pXVI; - if( GetClass() == TrueColor ) - { - nRedShift_ = sal_Shift( red_mask ); - nGreenShift_ = sal_Shift( green_mask ); - nBlueShift_ = sal_Shift( blue_mask ); - - nRedBits_ = sal_significantBits( red_mask ); - nGreenBits_ = sal_significantBits( green_mask ); - nBlueBits_ = sal_significantBits( blue_mask ); - - if( GetDepth() == 24 ) - if( red_mask == 0xFF0000 ) - if( green_mask == 0xFF00 ) - if( blue_mask == 0xFF ) - eRGBMode_ = SalRGB::RGB; - else - eRGBMode_ = SalRGB::otherSalRGB; - else if( blue_mask == 0xFF00 ) - if( green_mask == 0xFF ) - eRGBMode_ = SalRGB::RBG; - else - eRGBMode_ = SalRGB::otherSalRGB; + if( GetClass() != TrueColor ) + return; + + nRedShift_ = sal_Shift( red_mask ); + nGreenShift_ = sal_Shift( green_mask ); + nBlueShift_ = sal_Shift( blue_mask ); + + nRedBits_ = sal_significantBits( red_mask ); + nGreenBits_ = sal_significantBits( green_mask ); + nBlueBits_ = sal_significantBits( blue_mask ); + + if( GetDepth() == 24 ) + if( red_mask == 0xFF0000 ) + if( green_mask == 0xFF00 ) + if( blue_mask == 0xFF ) + eRGBMode_ = SalRGB::RGB; else eRGBMode_ = SalRGB::otherSalRGB; - else if( green_mask == 0xFF0000 ) - if( red_mask == 0xFF00 ) - if( blue_mask == 0xFF ) - eRGBMode_ = SalRGB::GRB; - else - eRGBMode_ = SalRGB::otherSalRGB; - else if( blue_mask == 0xFF00 ) - if( red_mask == 0xFF ) - eRGBMode_ = SalRGB::GBR; - else - eRGBMode_ = SalRGB::otherSalRGB; + else if( blue_mask == 0xFF00 ) + if( green_mask == 0xFF ) + eRGBMode_ = SalRGB::RBG; else eRGBMode_ = SalRGB::otherSalRGB; - else if( blue_mask == 0xFF0000 ) - if( red_mask == 0xFF00 ) - if( green_mask == 0xFF ) - eRGBMode_ = SalRGB::BRG; - else - eRGBMode_ = SalRGB::otherSalRGB; - else if( green_mask == 0xFF00 ) - if( red_mask == 0xFF ) - eRGBMode_ = SalRGB::BGR; - else - eRGBMode_ = SalRGB::otherSalRGB; + else + eRGBMode_ = SalRGB::otherSalRGB; + else if( green_mask == 0xFF0000 ) + if( red_mask == 0xFF00 ) + if( blue_mask == 0xFF ) + eRGBMode_ = SalRGB::GRB; + else + eRGBMode_ = SalRGB::otherSalRGB; + else if( blue_mask == 0xFF00 ) + if( red_mask == 0xFF ) + eRGBMode_ = SalRGB::GBR; + else + eRGBMode_ = SalRGB::otherSalRGB; + else + eRGBMode_ = SalRGB::otherSalRGB; + else if( blue_mask == 0xFF0000 ) + if( red_mask == 0xFF00 ) + if( green_mask == 0xFF ) + eRGBMode_ = SalRGB::BRG; + else + eRGBMode_ = SalRGB::otherSalRGB; + else if( green_mask == 0xFF00 ) + if( red_mask == 0xFF ) + eRGBMode_ = SalRGB::BGR; else eRGBMode_ = SalRGB::otherSalRGB; else eRGBMode_ = SalRGB::otherSalRGB; else eRGBMode_ = SalRGB::otherSalRGB; - } + else + eRGBMode_ = SalRGB::otherSalRGB; } // Converts the order of bytes of a Pixel into bytes of a Color diff --git a/vcl/unx/generic/app/sm.cxx b/vcl/unx/generic/app/sm.cxx index 30ff437a263a..7827f01eec35 100644 --- a/vcl/unx/generic/app/sm.cxx +++ b/vcl/unx/generic/app/sm.cxx @@ -450,20 +450,20 @@ void SessionManagerClient::saveDone() { SAL_INFO("vcl.sm", "SessionManagerClient::saveDone"); - if( m_pSmcConnection ) - { - assert(m_xICEConnectionObserver); - osl::MutexGuard g(m_xICEConnectionObserver->m_ICEMutex); - //SmcSetProperties( m_pSmcConnection, 1, &ppSmProps[ eCloneCommand ] ); - // this message-handling is now equal to kate and plasma desktop - SmcSetProperties( m_pSmcConnection, 1, &ppSmProps[ eRestartCommand ] ); - SmcDeleteProperties( m_pSmcConnection, 1, &ppSmDel[ eDiscardCommand ] ); - SmcSetProperties( m_pSmcConnection, 1, &ppSmProps[ eRestartStyleHint ] ); - - SmcSaveYourselfDone( m_pSmcConnection, True ); - SAL_INFO("vcl.sm.debug", " sent SmRestartHint = " << (*pSmRestartHint) ); - m_bDocSaveDone = true; - } + if( !m_pSmcConnection ) + return; + + assert(m_xICEConnectionObserver); + osl::MutexGuard g(m_xICEConnectionObserver->m_ICEMutex); + //SmcSetProperties( m_pSmcConnection, 1, &ppSmProps[ eCloneCommand ] ); + // this message-handling is now equal to kate and plasma desktop + SmcSetProperties( m_pSmcConnection, 1, &ppSmProps[ eRestartCommand ] ); + SmcDeleteProperties( m_pSmcConnection, 1, &ppSmDel[ eDiscardCommand ] ); + SmcSetProperties( m_pSmcConnection, 1, &ppSmProps[ eRestartStyleHint ] ); + + SmcSaveYourselfDone( m_pSmcConnection, True ); + SAL_INFO("vcl.sm.debug", " sent SmRestartHint = " << (*pSmRestartHint) ); + m_bDocSaveDone = true; } void SessionManagerClient::open(SalSession * pSession) @@ -553,19 +553,19 @@ void SessionManagerClient::close() { SAL_INFO("vcl.sm", "SessionManagerClient::close"); - if( m_pSmcConnection ) + if( !m_pSmcConnection ) + return; + + SAL_INFO("vcl.sm.debug", " attempting SmcCloseConnection"); + assert(m_xICEConnectionObserver); { - SAL_INFO("vcl.sm.debug", " attempting SmcCloseConnection"); - assert(m_xICEConnectionObserver); - { - osl::MutexGuard g(m_xICEConnectionObserver->m_ICEMutex); - SmcCloseConnection( m_pSmcConnection, 0, nullptr ); - SAL_INFO("vcl.sm", " SmcCloseConnection closed"); - } - m_xICEConnectionObserver->deactivate(); - m_xICEConnectionObserver.reset(); - m_pSmcConnection = nullptr; + osl::MutexGuard g(m_xICEConnectionObserver->m_ICEMutex); + SmcCloseConnection( m_pSmcConnection, 0, nullptr ); + SAL_INFO("vcl.sm", " SmcCloseConnection closed"); } + m_xICEConnectionObserver->deactivate(); + m_xICEConnectionObserver.reset(); + m_pSmcConnection = nullptr; } bool SessionManagerClient::queryInteraction() diff --git a/vcl/unx/generic/app/wmadaptor.cxx b/vcl/unx/generic/app/wmadaptor.cxx index 8304efbf226d..cc38683fe0e5 100644 --- a/vcl/unx/generic/app/wmadaptor.cxx +++ b/vcl/unx/generic/app/wmadaptor.cxx @@ -286,37 +286,37 @@ WMAdaptor::WMAdaptor( SalDisplay* pDisplay ) : } } } - if( m_aWMName.isEmpty() ) + if( !m_aWMName.isEmpty() ) + return; + + Atom aTTAPlatform = XInternAtom( m_pDisplay, "TTA_CLIENT_PLATFORM", True ); + if( aTTAPlatform == None || + XGetWindowProperty( m_pDisplay, + m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultXScreen() ), + aTTAPlatform, + 0, 32, + False, + XA_STRING, + &aRealType, + &nFormat, + &nItems, + &nBytesLeft, + &pProperty ) != 0 ) + return; + + if( aRealType == XA_STRING ) { - Atom aTTAPlatform = XInternAtom( m_pDisplay, "TTA_CLIENT_PLATFORM", True ); - if( aTTAPlatform != None && - XGetWindowProperty( m_pDisplay, - m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultXScreen() ), - aTTAPlatform, - 0, 32, - False, - XA_STRING, - &aRealType, - &nFormat, - &nItems, - &nBytesLeft, - &pProperty ) == 0 ) - { - if( aRealType == XA_STRING ) - { - m_aWMName = "Tarantella"; - // #i62319# pretend that AlwaysOnTop works since - // the alwaysontop workaround in salframe.cxx results - // in a raise/lower loop on a Windows tarantella client - // FIXME: this property contains an identification string that - // in theory should be good enough to recognize running on a - // Windows client; however this string does not seem to be - // documented as well as the property itself. - m_bEnableAlwaysOnTopWorks = true; - } - XFree( pProperty ); - } + m_aWMName = "Tarantella"; + // #i62319# pretend that AlwaysOnTop works since + // the alwaysontop workaround in salframe.cxx results + // in a raise/lower loop on a Windows tarantella client + // FIXME: this property contains an identification string that + // in theory should be good enough to recognize running on a + // Windows client; however this string does not seem to be + // documented as well as the property itself. + m_bEnableAlwaysOnTopWorks = true; } + XFree( pProperty ); } /* @@ -1066,104 +1066,104 @@ void NetWMAdaptor::setWMName( X11SalFrame* pFrame, const OUString& rWMName ) con */ void NetWMAdaptor::setNetWMState( X11SalFrame* pFrame ) const { - if( m_aWMAtoms[ NET_WM_STATE ] ) + if( !(m_aWMAtoms[ NET_WM_STATE ]) ) + return; + + Atom aStateAtoms[ 10 ]; + int nStateAtoms = 0; + + // set NET_WM_STATE_MODAL + if( pFrame->mbMaximizedVert + && m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_VERT ] ) + aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_VERT ]; + if( pFrame->mbMaximizedHorz + && m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_HORZ ] ) + aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_HORZ ]; + if( pFrame->bAlwaysOnTop_ && m_aWMAtoms[ NET_WM_STATE_STAYS_ON_TOP ] ) + aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_STAYS_ON_TOP ]; + if( pFrame->mbShaded && m_aWMAtoms[ NET_WM_STATE_SHADED ] ) + aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_SHADED ]; + if( pFrame->mbFullScreen && m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ] ) + aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ]; + if( pFrame->meWindowType == WMWindowType::Utility && m_aWMAtoms[ NET_WM_STATE_SKIP_TASKBAR ] ) + aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_SKIP_TASKBAR ]; + + if( nStateAtoms ) { - Atom aStateAtoms[ 10 ]; - int nStateAtoms = 0; - - // set NET_WM_STATE_MODAL - if( pFrame->mbMaximizedVert - && m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_VERT ] ) - aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_VERT ]; - if( pFrame->mbMaximizedHorz - && m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_HORZ ] ) - aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_HORZ ]; - if( pFrame->bAlwaysOnTop_ && m_aWMAtoms[ NET_WM_STATE_STAYS_ON_TOP ] ) - aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_STAYS_ON_TOP ]; - if( pFrame->mbShaded && m_aWMAtoms[ NET_WM_STATE_SHADED ] ) - aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_SHADED ]; - if( pFrame->mbFullScreen && m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ] ) - aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ]; - if( pFrame->meWindowType == WMWindowType::Utility && m_aWMAtoms[ NET_WM_STATE_SKIP_TASKBAR ] ) - aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_SKIP_TASKBAR ]; - - if( nStateAtoms ) - { - XChangeProperty( m_pDisplay, - pFrame->GetShellWindow(), - m_aWMAtoms[ NET_WM_STATE ], - XA_ATOM, - 32, - PropModeReplace, - reinterpret_cast<unsigned char*>(aStateAtoms), - nStateAtoms - ); - } - else - XDeleteProperty( m_pDisplay, - pFrame->GetShellWindow(), - m_aWMAtoms[ NET_WM_STATE ] ); - if( pFrame->mbMaximizedHorz - && pFrame->mbMaximizedVert - && ! ( pFrame->nStyle_ & SalFrameStyleFlags::SIZEABLE ) ) - { - /* - * for maximizing use NorthWestGravity (including decoration) - */ - XSizeHints hints; - long supplied; - bool bHint = false; - if( XGetWMNormalHints( m_pDisplay, - pFrame->GetShellWindow(), - &hints, - &supplied ) ) - { - bHint = true; - hints.flags |= PWinGravity; - hints.win_gravity = NorthWestGravity; - XSetWMNormalHints( m_pDisplay, - pFrame->GetShellWindow(), - &hints ); - XSync( m_pDisplay, False ); - } + XChangeProperty( m_pDisplay, + pFrame->GetShellWindow(), + m_aWMAtoms[ NET_WM_STATE ], + XA_ATOM, + 32, + PropModeReplace, + reinterpret_cast<unsigned char*>(aStateAtoms), + nStateAtoms + ); + } + else + XDeleteProperty( m_pDisplay, + pFrame->GetShellWindow(), + m_aWMAtoms[ NET_WM_STATE ] ); + if( !(pFrame->mbMaximizedHorz + && pFrame->mbMaximizedVert + && ! ( pFrame->nStyle_ & SalFrameStyleFlags::SIZEABLE )) ) + return; - // SetPosSize necessary to set width/height, min/max w/h - sal_Int32 nCurrent = 0; - /* - * get current desktop here if work areas have different size - * (does this happen on any platform ?) - */ - if( ! m_bEqualWorkAreas ) - { - nCurrent = getCurrentWorkArea(); - if( nCurrent < 0 ) - nCurrent = 0; - } - tools::Rectangle aPosSize = m_aWMWorkAreas[nCurrent]; - const SalFrameGeometry& rGeom( pFrame->GetUnmirroredGeometry() ); - aPosSize = tools::Rectangle( Point( aPosSize.Left() + rGeom.nLeftDecoration, - aPosSize.Top() + rGeom.nTopDecoration ), - Size( aPosSize.GetWidth() - - rGeom.nLeftDecoration - - rGeom.nRightDecoration, - aPosSize.GetHeight() - - rGeom.nTopDecoration - - rGeom.nBottomDecoration ) - ); - pFrame->SetPosSize( aPosSize ); - - /* - * reset gravity hint to static gravity - * (this should not move window according to ICCCM) - */ - if( bHint && pFrame->nShowState_ != SHOWSTATE_UNKNOWN ) - { - hints.win_gravity = StaticGravity; - XSetWMNormalHints( m_pDisplay, - pFrame->GetShellWindow(), - &hints ); - } - } + /* + * for maximizing use NorthWestGravity (including decoration) + */ + XSizeHints hints; + long supplied; + bool bHint = false; + if( XGetWMNormalHints( m_pDisplay, + pFrame->GetShellWindow(), + &hints, + &supplied ) ) + { + bHint = true; + hints.flags |= PWinGravity; + hints.win_gravity = NorthWestGravity; + XSetWMNormalHints( m_pDisplay, + pFrame->GetShellWindow(), + &hints ); + XSync( m_pDisplay, False ); + } + + // SetPosSize necessary to set width/height, min/max w/h + sal_Int32 nCurrent = 0; + /* + * get current desktop here if work areas have different size + * (does this happen on any platform ?) + */ + if( ! m_bEqualWorkAreas ) + { + nCurrent = getCurrentWorkArea(); + if( nCurrent < 0 ) + nCurrent = 0; + } + tools::Rectangle aPosSize = m_aWMWorkAreas[nCurrent]; + const SalFrameGeometry& rGeom( pFrame->GetUnmirroredGeometry() ); + aPosSize = tools::Rectangle( Point( aPosSize.Left() + rGeom.nLeftDecoration, + aPosSize.Top() + rGeom.nTopDecoration ), + Size( aPosSize.GetWidth() + - rGeom.nLeftDecoration + - rGeom.nRightDecoration, + aPosSize.GetHeight() + - rGeom.nTopDecoration + - rGeom.nBottomDecoration ) + ); + pFrame->SetPosSize( aPosSize ); + + /* + * reset gravity hint to static gravity + * (this should not move window according to ICCCM) + */ + if( bHint && pFrame->nShowState_ != SHOWSTATE_UNKNOWN ) + { + hints.win_gravity = StaticGravity; + XSetWMNormalHints( m_pDisplay, + pFrame->GetShellWindow(), + &hints ); } } @@ -1173,87 +1173,87 @@ void NetWMAdaptor::setNetWMState( X11SalFrame* pFrame ) const */ void GnomeWMAdaptor::setGnomeWMState( X11SalFrame* pFrame ) const { - if( m_aWMAtoms[ WIN_STATE ] ) - { - sal_uInt32 nWinWMState = 0; + if( !(m_aWMAtoms[ WIN_STATE ]) ) + return; - if( pFrame->mbMaximizedVert ) - nWinWMState |= 1 << 2; - if( pFrame->mbMaximizedHorz ) - nWinWMState |= 1 << 3; - if( pFrame->mbShaded ) - nWinWMState |= 1 << 5; + sal_uInt32 nWinWMState = 0; - XChangeProperty( m_pDisplay, - pFrame->GetShellWindow(), - m_aWMAtoms[ WIN_STATE ], - XA_CARDINAL, - 32, - PropModeReplace, - reinterpret_cast<unsigned char*>(&nWinWMState), - 1 - ); - if( pFrame->mbMaximizedHorz - && pFrame->mbMaximizedVert - && ! ( pFrame->nStyle_ & SalFrameStyleFlags::SIZEABLE ) ) - { - /* - * for maximizing use NorthWestGravity (including decoration) - */ - XSizeHints hints; - long supplied; - bool bHint = false; - if( XGetWMNormalHints( m_pDisplay, - pFrame->GetShellWindow(), - &hints, - &supplied ) ) - { - bHint = true; - hints.flags |= PWinGravity; - hints.win_gravity = NorthWestGravity; - XSetWMNormalHints( m_pDisplay, - pFrame->GetShellWindow(), - &hints ); - XSync( m_pDisplay, False ); - } + if( pFrame->mbMaximizedVert ) + nWinWMState |= 1 << 2; + if( pFrame->mbMaximizedHorz ) + nWinWMState |= 1 << 3; + if( pFrame->mbShaded ) + nWinWMState |= 1 << 5; - // SetPosSize necessary to set width/height, min/max w/h - sal_Int32 nCurrent = 0; - /* - * get current desktop here if work areas have different size - * (does this happen on any platform ?) - */ - if( ! m_bEqualWorkAreas ) - { - nCurrent = getCurrentWorkArea(); - if( nCurrent < 0 ) - nCurrent = 0; - } - tools::Rectangle aPosSize = m_aWMWorkAreas[nCurrent]; - const SalFrameGeometry& rGeom( pFrame->GetUnmirroredGeometry() ); - aPosSize = tools::Rectangle( Point( aPosSize.Left() + rGeom.nLeftDecoration, - aPosSize.Top() + rGeom.nTopDecoration ), - Size( aPosSize.GetWidth() - - rGeom.nLeftDecoration - - rGeom.nRightDecoration, - aPosSize.GetHeight() - - rGeom.nTopDecoration - - rGeom.nBottomDecoration ) - ); - pFrame->SetPosSize( aPosSize ); - - /* - * reset gravity hint to static gravity - * (this should not move window according to ICCCM) - */ - if( bHint && pFrame->nShowState_ != SHOWSTATE_UNKNOWN ) - { - hints.win_gravity = StaticGravity; - XSetWMNormalHints( m_pDisplay, - pFrame->GetShellWindow(), - &hints ); - } - } + XChangeProperty( m_pDisplay, + pFrame->GetShellWindow(), + m_aWMAtoms[ WIN_STATE ], + XA_CARDINAL, + 32, + PropModeReplace, + reinterpret_cast<unsigned char*>(&nWinWMState), + 1 + ); + if( !(pFrame->mbMaximizedHorz + && pFrame->mbMaximizedVert + && ! ( pFrame->nStyle_ & SalFrameStyleFlags::SIZEABLE )) ) + return; + + /* + * for maximizing use NorthWestGravity (including decoration) + */ + XSizeHints hints; + long supplied; + bool bHint = false; + if( XGetWMNormalHints( m_pDisplay, + pFrame->GetShellWindow(), + &hints, + &supplied ) ) + { + bHint = true; + hints.flags |= PWinGravity; + hints.win_gravity = NorthWestGravity; + XSetWMNormalHints( m_pDisplay, + pFrame->GetShellWindow(), + &hints ); + XSync( m_pDisplay, False ); + } + + // SetPosSize necessary to set width/height, min/max w/h + sal_Int32 nCurrent = 0; + /* + * get current desktop here if work areas have different size + * (does this happen on any platform ?) + */ + if( ! m_bEqualWorkAreas ) + { + nCurrent = getCurrentWorkArea(); + if( nCurrent < 0 ) + nCurrent = 0; + } + tools::Rectangle aPosSize = m_aWMWorkAreas[nCurrent]; + const SalFrameGeometry& rGeom( pFrame->GetUnmirroredGeometry() ); + aPosSize = tools::Rectangle( Point( aPosSize.Left() + rGeom.nLeftDecoration, + aPosSize.Top() + rGeom.nTopDecoration ), + Size( aPosSize.GetWidth() + - rGeom.nLeftDecoration + - rGeom.nRightDecoration, + aPosSize.GetHeight() + - rGeom.nTopDecoration + - rGeom.nBottomDecoration ) + ); + pFrame->SetPosSize( aPosSize ); + + /* + * reset gravity hint to static gravity + * (this should not move window according to ICCCM) + */ + if( bHint && pFrame->nShowState_ != SHOWSTATE_UNKNOWN ) + { + hints.win_gravity = StaticGravity; + XSetWMNormalHints( m_pDisplay, + pFrame->GetShellWindow(), + &hints ); } } @@ -1660,32 +1660,32 @@ void WMAdaptor::enableAlwaysOnTop( X11SalFrame*, bool /*bEnable*/ ) const void NetWMAdaptor::enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const { pFrame->bAlwaysOnTop_ = bEnable; - if( m_aWMAtoms[ NET_WM_STATE_STAYS_ON_TOP ] ) + if( !(m_aWMAtoms[ NET_WM_STATE_STAYS_ON_TOP ]) ) + return; + + if( pFrame->bMapped_ ) { - if( pFrame->bMapped_ ) - { - // window already mapped, send WM a message - XEvent aEvent; - aEvent.type = ClientMessage; - aEvent.xclient.display = m_pDisplay; - aEvent.xclient.window = pFrame->GetShellWindow(); - aEvent.xclient.message_type = m_aWMAtoms[ NET_WM_STATE ]; - aEvent.xclient.format = 32; - aEvent.xclient.data.l[0] = bEnable ? 1 : 0; - aEvent.xclient.data.l[1] = m_aWMAtoms[ NET_WM_STATE_STAYS_ON_TOP ]; - aEvent.xclient.data.l[2] = 0; - aEvent.xclient.data.l[3] = 0; - aEvent.xclient.data.l[4] = 0; - XSendEvent( m_pDisplay, - m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ), - False, - SubstructureNotifyMask | SubstructureRedirectMask, - &aEvent - ); - } - else - setNetWMState( pFrame ); + // window already mapped, send WM a message + XEvent aEvent; + aEvent.type = ClientMessage; + aEvent.xclient.display = m_pDisplay; + aEvent.xclient.window = pFrame->GetShellWindow(); + aEvent.xclient.message_type = m_aWMAtoms[ NET_WM_STATE ]; + aEvent.xclient.format = 32; + aEvent.xclient.data.l[0] = bEnable ? 1 : 0; + aEvent.xclient.data.l[1] = m_aWMAtoms[ NET_WM_STATE_STAYS_ON_TOP ]; + aEvent.xclient.data.l[2] = 0; + aEvent.xclient.data.l[3] = 0; + aEvent.xclient.data.l[4] = 0; + XSendEvent( m_pDisplay, + m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ), + False, + SubstructureNotifyMask | SubstructureRedirectMask, + &aEvent + ); } + else + setNetWMState( pFrame ); } /* @@ -1694,42 +1694,42 @@ void NetWMAdaptor::enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const void GnomeWMAdaptor::enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const { pFrame->bAlwaysOnTop_ = bEnable; - if( m_aWMAtoms[ WIN_LAYER ] ) + if( !(m_aWMAtoms[ WIN_LAYER ]) ) + return; + + if( pFrame->bMapped_ ) { - if( pFrame->bMapped_ ) - { - // window already mapped, send WM a message - XEvent aEvent; - aEvent.type = ClientMessage; - aEvent.xclient.display = m_pDisplay; - aEvent.xclient.window = pFrame->GetShellWindow(); - aEvent.xclient.message_type = m_aWMAtoms[ WIN_LAYER ]; - aEvent.xclient.format = 32; - aEvent.xclient.data.l[0] = bEnable ? 6 : 4; - aEvent.xclient.data.l[1] = 0; - aEvent.xclient.data.l[2] = 0; - aEvent.xclient.data.l[3] = 0; - aEvent.xclient.data.l[4] = 0; - XSendEvent( m_pDisplay, - m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ), - False, - SubstructureNotifyMask | SubstructureRedirectMask, - &aEvent - ); - } - else - { - sal_uInt32 nNewLayer = bEnable ? 6 : 4; - XChangeProperty( m_pDisplay, - pFrame->GetShellWindow(), - m_aWMAtoms[ WIN_LAYER ], - XA_CARDINAL, - 32, - PropModeReplace, - reinterpret_cast<unsigned char*>(&nNewLayer), - 1 - ); - } + // window already mapped, send WM a message + XEvent aEvent; + aEvent.type = ClientMessage; + aEvent.xclient.display = m_pDisplay; + aEvent.xclient.window = pFrame->GetShellWindow(); + aEvent.xclient.message_type = m_aWMAtoms[ WIN_LAYER ]; + aEvent.xclient.format = 32; + aEvent.xclient.data.l[0] = bEnable ? 6 : 4; + aEvent.xclient.data.l[1] = 0; + aEvent.xclient.data.l[2] = 0; + aEvent.xclient.data.l[3] = 0; + aEvent.xclient.data.l[4] = 0; + XSendEvent( m_pDisplay, + m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ), + False, + SubstructureNotifyMask | SubstructureRedirectMask, + &aEvent + ); + } + else + { + sal_uInt32 nNewLayer = bEnable ? 6 : 4; + XChangeProperty( m_pDisplay, + pFrame->GetShellWindow(), + m_aWMAtoms[ WIN_LAYER ], + XA_CARDINAL, + 32, + PropModeReplace, + reinterpret_cast<unsigned char*>(&nNewLayer), + 1 + ); } } @@ -1738,22 +1738,22 @@ void GnomeWMAdaptor::enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) cons */ void WMAdaptor::changeReferenceFrame( X11SalFrame* pFrame, X11SalFrame const * pReferenceFrame ) const { - if( ! ( pFrame->nStyle_ & SalFrameStyleFlags::PLUG ) + if( !(! ( pFrame->nStyle_ & SalFrameStyleFlags::PLUG ) && ! pFrame->IsOverrideRedirect() - && ! pFrame->IsFloatGrabWindow() + && ! pFrame->IsFloatGrabWindow()) ) + return; + + ::Window aTransient = pFrame->pDisplay_->GetRootWindow( pFrame->GetScreenNumber() ); + pFrame->mbTransientForRoot = true; + if( pReferenceFrame ) { - ::Window aTransient = pFrame->pDisplay_->GetRootWindow( pFrame->GetScreenNumber() ); - pFrame->mbTransientForRoot = true; - if( pReferenceFrame ) - { - aTransient = pReferenceFrame->GetShellWindow(); - pFrame->mbTransientForRoot = false; - } - XSetTransientForHint( m_pDisplay, - pFrame->GetShellWindow(), - aTransient ); + aTransient = pReferenceFrame->GetShellWindow(); + pFrame->mbTransientForRoot = false; } + XSetTransientForHint( m_pDisplay, + pFrame->GetShellWindow(), + aTransient ); } /* @@ -1918,38 +1918,38 @@ void WMAdaptor::shade( X11SalFrame*, bool /*bToShaded*/ ) const */ void NetWMAdaptor::shade( X11SalFrame* pFrame, bool bToShaded ) const { - if( m_aWMAtoms[ NET_WM_STATE ] + if( !(m_aWMAtoms[ NET_WM_STATE ] && m_aWMAtoms[ NET_WM_STATE_SHADED ] - && ( pFrame->nStyle_ & ~SalFrameStyleFlags::DEFAULT ) + && ( pFrame->nStyle_ & ~SalFrameStyleFlags::DEFAULT )) ) + return; + + pFrame->mbShaded = bToShaded; + if( pFrame->bMapped_ ) { - pFrame->mbShaded = bToShaded; - if( pFrame->bMapped_ ) - { - // window already mapped, send WM a message - XEvent aEvent; - aEvent.type = ClientMessage; - aEvent.xclient.display = m_pDisplay; - aEvent.xclient.window = pFrame->GetShellWindow(); - aEvent.xclient.message_type = m_aWMAtoms[ NET_WM_STATE ]; - aEvent.xclient.format = 32; - aEvent.xclient.data.l[0] = bToShaded ? 1 : 0; - aEvent.xclient.data.l[1] = m_aWMAtoms[ NET_WM_STATE_SHADED ]; - aEvent.xclient.data.l[2] = 0; - aEvent.xclient.data.l[3] = 0; - aEvent.xclient.data.l[4] = 0; - XSendEvent( m_pDisplay, - m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ), - False, - SubstructureNotifyMask | SubstructureRedirectMask, - &aEvent - ); - } - else - { - // window not mapped yet, set _NET_WM_STATE directly - setNetWMState( pFrame ); - } + // window already mapped, send WM a message + XEvent aEvent; + aEvent.type = ClientMessage; + aEvent.xclient.display = m_pDisplay; + aEvent.xclient.window = pFrame->GetShellWindow(); + aEvent.xclient.message_type = m_aWMAtoms[ NET_WM_STATE ]; + aEvent.xclient.format = 32; + aEvent.xclient.data.l[0] = bToShaded ? 1 : 0; + aEvent.xclient.data.l[1] = m_aWMAtoms[ NET_WM_STATE_SHADED ]; + aEvent.xclient.data.l[2] = 0; + aEvent.xclient.data.l[3] = 0; + aEvent.xclient.data.l[4] = 0; + XSendEvent( m_pDisplay, + m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ), + False, + SubstructureNotifyMask | SubstructureRedirectMask, + &aEvent + ); + } + else + { + // window not mapped yet, set _NET_WM_STATE directly + setNetWMState( pFrame ); } } @@ -1958,33 +1958,33 @@ void NetWMAdaptor::shade( X11SalFrame* pFrame, bool bToShaded ) const */ void GnomeWMAdaptor::shade( X11SalFrame* pFrame, bool bToShaded ) const { - if( m_aWMAtoms[ WIN_STATE ] ) + if( !(m_aWMAtoms[ WIN_STATE ]) ) + return; + + pFrame->mbShaded = bToShaded; + if( pFrame->bMapped_ ) { - pFrame->mbShaded = bToShaded; - if( pFrame->bMapped_ ) - { - // window already mapped, send WM a message - XEvent aEvent; - aEvent.type = ClientMessage; - aEvent.xclient.display = m_pDisplay; - aEvent.xclient.window = pFrame->GetShellWindow(); - aEvent.xclient.message_type = m_aWMAtoms[ WIN_STATE ]; - aEvent.xclient.format = 32; - aEvent.xclient.data.l[0] = (1<<5); - aEvent.xclient.data.l[1] = bToShaded ? (1<<5) : 0; - aEvent.xclient.data.l[2] = 0; - aEvent.xclient.data.l[3] = 0; - aEvent.xclient.data.l[4] = 0; - XSendEvent( m_pDisplay, - m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ), - False, - SubstructureNotifyMask | SubstructureRedirectMask, - &aEvent - ); - } - else - setGnomeWMState( pFrame ); + // window already mapped, send WM a message + XEvent aEvent; + aEvent.type = ClientMessage; + aEvent.xclient.display = m_pDisplay; + aEvent.xclient.window = pFrame->GetShellWindow(); + aEvent.xclient.message_type = m_aWMAtoms[ WIN_STATE ]; + aEvent.xclient.format = 32; + aEvent.xclient.data.l[0] = (1<<5); + aEvent.xclient.data.l[1] = bToShaded ? (1<<5) : 0; + aEvent.xclient.data.l[2] = 0; + aEvent.xclient.data.l[3] = 0; + aEvent.xclient.data.l[4] = 0; + XSendEvent( m_pDisplay, + m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ), + False, + SubstructureNotifyMask | SubstructureRedirectMask, + &aEvent + ); } + else + setGnomeWMState( pFrame ); } /* @@ -2236,19 +2236,19 @@ void NetWMAdaptor::setUserTime( X11SalFrame* i_pFrame, long i_nUserTime ) const */ void WMAdaptor::setPID( X11SalFrame const * i_pFrame ) const { - if( m_aWMAtoms[NET_WM_PID] ) - { - long nPID = static_cast<long>(getpid()); - XChangeProperty( m_pDisplay, - i_pFrame->GetShellWindow(), - m_aWMAtoms[NET_WM_PID], - XA_CARDINAL, - 32, - PropModeReplace, - reinterpret_cast<unsigned char*>(&nPID), - 1 - ); - } + if( !(m_aWMAtoms[NET_WM_PID]) ) + return; + + long nPID = static_cast<long>(getpid()); + XChangeProperty( m_pDisplay, + i_pFrame->GetShellWindow(), + m_aWMAtoms[NET_WM_PID], + XA_CARDINAL, + 32, + PropModeReplace, + reinterpret_cast<unsigned char*>(&nPID), + 1 + ); } /* @@ -2263,21 +2263,21 @@ void WMAdaptor::setClientMachine( X11SalFrame const * i_pFrame ) const void WMAdaptor::answerPing( X11SalFrame const * i_pFrame, XClientMessageEvent const * i_pEvent ) const { - if( m_aWMAtoms[NET_WM_PING] && - i_pEvent->message_type == m_aWMAtoms[ WM_PROTOCOLS ] && - static_cast<Atom>(i_pEvent->data.l[0]) == m_aWMAtoms[ NET_WM_PING ] ) - { - XEvent aEvent; - aEvent.xclient = *i_pEvent; - aEvent.xclient.window = m_pSalDisplay->GetRootWindow( i_pFrame->GetScreenNumber() ); - XSendEvent( m_pDisplay, - m_pSalDisplay->GetRootWindow( i_pFrame->GetScreenNumber() ), - False, - SubstructureNotifyMask | SubstructureRedirectMask, - &aEvent - ); - XFlush( m_pDisplay ); - } + if( !m_aWMAtoms[NET_WM_PING] || + i_pEvent->message_type != m_aWMAtoms[ WM_PROTOCOLS ] || + static_cast<Atom>(i_pEvent->data.l[0]) != m_aWMAtoms[ NET_WM_PING ] ) + return; + + XEvent aEvent; + aEvent.xclient = *i_pEvent; + aEvent.xclient.window = m_pSalDisplay->GetRootWindow( i_pFrame->GetScreenNumber() ); + XSendEvent( m_pDisplay, + m_pSalDisplay->GetRootWindow( i_pFrame->GetScreenNumber() ), + False, + SubstructureNotifyMask | SubstructureRedirectMask, + &aEvent + ); + XFlush( m_pDisplay ); } void WMAdaptor::activateWindow( X11SalFrame const *pFrame, Time nTimestamp ) diff --git a/vcl/unx/generic/dtrans/X11_droptarget.cxx b/vcl/unx/generic/dtrans/X11_droptarget.cxx index 72f8dff00d9e..745e695a7a14 100644 --- a/vcl/unx/generic/dtrans/X11_droptarget.cxx +++ b/vcl/unx/generic/dtrans/X11_droptarget.cxx @@ -47,28 +47,28 @@ DropTarget::~DropTarget() void DropTarget::initialize( const Sequence< Any >& arguments ) { - if( arguments.getLength() > 1 ) + if( arguments.getLength() <= 1 ) + return; + + OUString aDisplayName; + Reference< XDisplayConnection > xConn; + arguments.getConstArray()[0] >>= xConn; + if( xConn.is() ) + { + Any aIdentifier; + aIdentifier >>= aDisplayName; + } + + m_xSelectionManager = &SelectionManager::get( aDisplayName ); + m_xSelectionManager->initialize( arguments ); + + if( m_xSelectionManager->getDisplay() ) // #136582# sanity check { - OUString aDisplayName; - Reference< XDisplayConnection > xConn; - arguments.getConstArray()[0] >>= xConn; - if( xConn.is() ) - { - Any aIdentifier; - aIdentifier >>= aDisplayName; - } - - m_xSelectionManager = &SelectionManager::get( aDisplayName ); - m_xSelectionManager->initialize( arguments ); - - if( m_xSelectionManager->getDisplay() ) // #136582# sanity check - { - sal_IntPtr aWindow = None; - arguments.getConstArray()[1] >>= aWindow; - m_xSelectionManager->registerDropTarget( aWindow, this ); - m_aTargetWindow = aWindow; - m_bActive = true; - } + sal_IntPtr aWindow = None; + arguments.getConstArray()[1] >>= aWindow; + m_xSelectionManager->registerDropTarget( aWindow, this ); + m_aTargetWindow = aWindow; + m_bActive = true; } } diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx index 20321c9915c2..4be75f23ee56 100644 --- a/vcl/unx/generic/dtrans/X11_selection.cxx +++ b/vcl/unx/generic/dtrans/X11_selection.cxx @@ -345,113 +345,113 @@ void SelectionManager::initialize( const Sequence< Any >& arguments ) m_xDisplayConnection->addEventHandler( Any(), this, ~0 ); } - if( ! m_pDisplay ) + if( m_pDisplay ) + return; + + OUString aUDisplay; + if( m_xDisplayConnection.is() ) { - OUString aUDisplay; - if( m_xDisplayConnection.is() ) - { - Any aIdentifier = m_xDisplayConnection->getIdentifier(); - aIdentifier >>= aUDisplay; - } + Any aIdentifier = m_xDisplayConnection->getIdentifier(); + aIdentifier >>= aUDisplay; + } - OString aDisplayName( OUStringToOString( aUDisplay, RTL_TEXTENCODING_ISO_8859_1 ) ); + OString aDisplayName( OUStringToOString( aUDisplay, RTL_TEXTENCODING_ISO_8859_1 ) ); - m_pDisplay = XOpenDisplay( aDisplayName.isEmpty() ? nullptr : aDisplayName.getStr()); + m_pDisplay = XOpenDisplay( aDisplayName.isEmpty() ? nullptr : aDisplayName.getStr()); + + if( !m_pDisplay ) + return; - if( m_pDisplay ) - { #ifdef SYNCHRONIZE - XSynchronize( m_pDisplay, True ); + XSynchronize( m_pDisplay, True ); #endif - // special targets - m_nTARGETSAtom = getAtom( "TARGETS" ); - m_nTIMESTAMPAtom = getAtom( "TIMESTAMP" ); - m_nTEXTAtom = getAtom( "TEXT" ); - m_nINCRAtom = getAtom( "INCR" ); - m_nCOMPOUNDAtom = getAtom( "COMPOUND_TEXT" ); - m_nMULTIPLEAtom = getAtom( "MULTIPLE" ); - m_nImageBmpAtom = getAtom( "image/bmp" ); - - // Atoms for Xdnd protocol - m_nXdndAware = getAtom( "XdndAware" ); - m_nXdndEnter = getAtom( "XdndEnter" ); - m_nXdndLeave = getAtom( "XdndLeave" ); - m_nXdndPosition = getAtom( "XdndPosition" ); - m_nXdndStatus = getAtom( "XdndStatus" ); - m_nXdndDrop = getAtom( "XdndDrop" ); - m_nXdndFinished = getAtom( "XdndFinished" ); - m_nXdndSelection = getAtom( "XdndSelection" ); - m_nXdndTypeList = getAtom( "XdndTypeList" ); - m_nXdndProxy = getAtom( "XdndProxy" ); - m_nXdndActionCopy = getAtom( "XdndActionCopy" ); - m_nXdndActionMove = getAtom( "XdndActionMove" ); - m_nXdndActionLink = getAtom( "XdndActionLink" ); - m_nXdndActionAsk = getAtom( "XdndActionAsk" ); - - // initialize map with member none - m_aAtomToString[ 0 ]= "None"; - m_aAtomToString[ XA_PRIMARY ] = "PRIMARY"; - - // create a (invisible) message window - m_aWindow = XCreateSimpleWindow( m_pDisplay, DefaultRootWindow( m_pDisplay ), - 10, 10, 10, 10, 0, 0, 1 ); - - // initialize threshold for incremental transfers - // ICCCM says it should be smaller that the max request size - // which in turn is guaranteed to be at least 16k bytes - m_nIncrementalThreshold = XMaxRequestSize( m_pDisplay ) - 1024; - - if( m_aWindow ) - { - // initialize default cursors - m_aMoveCursor = createCursor( movedata_curs_bits, - movedata_mask_bits, - movedata_curs_width, - movedata_curs_height, - movedata_curs_x_hot, - movedata_curs_y_hot ); - m_aCopyCursor = createCursor( copydata_curs_bits, - copydata_mask_bits, - copydata_curs_width, - copydata_curs_height, - copydata_curs_x_hot, - copydata_curs_y_hot ); - m_aLinkCursor = createCursor( linkdata_curs_bits, - linkdata_mask_bits, - linkdata_curs_width, - linkdata_curs_height, - linkdata_curs_x_hot, - linkdata_curs_y_hot ); - m_aNoneCursor = createCursor( nodrop_curs_bits, - nodrop_mask_bits, - nodrop_curs_width, - nodrop_curs_height, - nodrop_curs_x_hot, - nodrop_curs_y_hot ); - - // just interested in SelectionClear/Notify/Request and PropertyChange - XSelectInput( m_pDisplay, m_aWindow, PropertyChangeMask ); - // create the transferable for Drag operations - m_xDropTransferable = new X11Transferable( *this, m_nXdndSelection ); - registerHandler( m_nXdndSelection, *this ); - - m_aThread = osl_createSuspendedThread( call_SelectionManager_run, this ); - if( m_aThread ) - osl_resumeThread( m_aThread ); + // special targets + m_nTARGETSAtom = getAtom( "TARGETS" ); + m_nTIMESTAMPAtom = getAtom( "TIMESTAMP" ); + m_nTEXTAtom = getAtom( "TEXT" ); + m_nINCRAtom = getAtom( "INCR" ); + m_nCOMPOUNDAtom = getAtom( "COMPOUND_TEXT" ); + m_nMULTIPLEAtom = getAtom( "MULTIPLE" ); + m_nImageBmpAtom = getAtom( "image/bmp" ); + + // Atoms for Xdnd protocol + m_nXdndAware = getAtom( "XdndAware" ); + m_nXdndEnter = getAtom( "XdndEnter" ); + m_nXdndLeave = getAtom( "XdndLeave" ); + m_nXdndPosition = getAtom( "XdndPosition" ); + m_nXdndStatus = getAtom( "XdndStatus" ); + m_nXdndDrop = getAtom( "XdndDrop" ); + m_nXdndFinished = getAtom( "XdndFinished" ); + m_nXdndSelection = getAtom( "XdndSelection" ); + m_nXdndTypeList = getAtom( "XdndTypeList" ); + m_nXdndProxy = getAtom( "XdndProxy" ); + m_nXdndActionCopy = getAtom( "XdndActionCopy" ); + m_nXdndActionMove = getAtom( "XdndActionMove" ); + m_nXdndActionLink = getAtom( "XdndActionLink" ); + m_nXdndActionAsk = getAtom( "XdndActionAsk" ); + + // initialize map with member none + m_aAtomToString[ 0 ]= "None"; + m_aAtomToString[ XA_PRIMARY ] = "PRIMARY"; + + // create a (invisible) message window + m_aWindow = XCreateSimpleWindow( m_pDisplay, DefaultRootWindow( m_pDisplay ), + 10, 10, 10, 10, 0, 0, 1 ); + + // initialize threshold for incremental transfers + // ICCCM says it should be smaller that the max request size + // which in turn is guaranteed to be at least 16k bytes + m_nIncrementalThreshold = XMaxRequestSize( m_pDisplay ) - 1024; + + if( !m_aWindow ) + return; + + // initialize default cursors + m_aMoveCursor = createCursor( movedata_curs_bits, + movedata_mask_bits, + movedata_curs_width, + movedata_curs_height, + movedata_curs_x_hot, + movedata_curs_y_hot ); + m_aCopyCursor = createCursor( copydata_curs_bits, + copydata_mask_bits, + copydata_curs_width, + copydata_curs_height, + copydata_curs_x_hot, + copydata_curs_y_hot ); + m_aLinkCursor = createCursor( linkdata_curs_bits, + linkdata_mask_bits, + linkdata_curs_width, + linkdata_curs_height, + linkdata_curs_x_hot, + linkdata_curs_y_hot ); + m_aNoneCursor = createCursor( nodrop_curs_bits, + nodrop_mask_bits, + nodrop_curs_width, + nodrop_curs_height, + nodrop_curs_x_hot, + nodrop_curs_y_hot ); + + // just interested in SelectionClear/Notify/Request and PropertyChange + XSelectInput( m_pDisplay, m_aWindow, PropertyChangeMask ); + // create the transferable for Drag operations + m_xDropTransferable = new X11Transferable( *this, m_nXdndSelection ); + registerHandler( m_nXdndSelection, *this ); + + m_aThread = osl_createSuspendedThread( call_SelectionManager_run, this ); + if( m_aThread ) + osl_resumeThread( m_aThread ); #if OSL_DEBUG_LEVEL > 1 - else - SAL_WARN("vcl.unx.dtrans", "SelectionManager::initialize: " - << "creation of dispatch thread failed !."); + else + SAL_WARN("vcl.unx.dtrans", "SelectionManager::initialize: " + << "creation of dispatch thread failed !."); #endif - if (pipe(m_EndThreadPipe) != 0) { + if (pipe(m_EndThreadPipe) != 0) { #if OSL_DEBUG_LEVEL > 1 - SAL_WARN("vcl.unx.dtrans", "Failed to create endThreadPipe."); + SAL_WARN("vcl.unx.dtrans", "Failed to create endThreadPipe."); #endif - m_EndThreadPipe[0] = m_EndThreadPipe[1] = 0; - } - } - } + m_EndThreadPipe[0] = m_EndThreadPipe[1] = 0; } } @@ -492,29 +492,29 @@ SelectionManager::~SelectionManager() SAL_INFO("vcl.unx.dtrans", "shutting down SelectionManager."); #endif - if( m_pDisplay ) - { - deregisterHandler( m_nXdndSelection ); - // destroy message window - if( m_aWindow ) - XDestroyWindow( m_pDisplay, m_aWindow ); - // release cursors - if (m_aMoveCursor != None) - XFreeCursor(m_pDisplay, m_aMoveCursor); - if (m_aCopyCursor != None) - XFreeCursor(m_pDisplay, m_aCopyCursor); - if (m_aLinkCursor != None) - XFreeCursor(m_pDisplay, m_aLinkCursor); - if (m_aNoneCursor != None) - XFreeCursor(m_pDisplay, m_aNoneCursor); - - // paranoia setting, the drag thread should have - // done that already - XUngrabPointer( m_pDisplay, CurrentTime ); - XUngrabKeyboard( m_pDisplay, CurrentTime ); + if( !m_pDisplay ) + return; - XCloseDisplay( m_pDisplay ); - } + deregisterHandler( m_nXdndSelection ); + // destroy message window + if( m_aWindow ) + XDestroyWindow( m_pDisplay, m_aWindow ); + // release cursors + if (m_aMoveCursor != None) + XFreeCursor(m_pDisplay, m_aMoveCursor); + if (m_aCopyCursor != None) + XFreeCursor(m_pDisplay, m_aCopyCursor); + if (m_aLinkCursor != None) + XFreeCursor(m_pDisplay, m_aLinkCursor); + if (m_aNoneCursor != None) + XFreeCursor(m_pDisplay, m_aNoneCursor); + + // paranoia setting, the drag thread should have + // done that already + XUngrabPointer( m_pDisplay, CurrentTime ); + XUngrabKeyboard( m_pDisplay, CurrentTime ); + + XCloseDisplay( m_pDisplay ); } SelectionAdaptor* SelectionManager::getAdaptor( Atom selection ) @@ -2919,44 +2919,44 @@ bool SelectionManager::handleDragEvent( XEvent const & rMessage ) void SelectionManager::accept( sal_Int8 dragOperation, ::Window aDropWindow ) { - if( aDropWindow == m_aCurrentDropWindow ) - { + if( aDropWindow != m_aCurrentDropWindow ) + return; + #if OSL_DEBUG_LEVEL > 1 - SAL_INFO("vcl.unx.dtrans", "accept: " << std::hex << dragOperation); + SAL_INFO("vcl.unx.dtrans", "accept: " << std::hex << dragOperation); #endif - Atom nAction = None; - dragOperation &= (DNDConstants::ACTION_MOVE | DNDConstants::ACTION_COPY | DNDConstants::ACTION_LINK); - if( dragOperation & DNDConstants::ACTION_MOVE ) - nAction = m_nXdndActionMove; - else if( dragOperation & DNDConstants::ACTION_COPY ) - nAction = m_nXdndActionCopy; - else if( dragOperation & DNDConstants::ACTION_LINK ) - nAction = m_nXdndActionLink; - m_bLastDropAccepted = true; - sendDragStatus( nAction ); - } + Atom nAction = None; + dragOperation &= (DNDConstants::ACTION_MOVE | DNDConstants::ACTION_COPY | DNDConstants::ACTION_LINK); + if( dragOperation & DNDConstants::ACTION_MOVE ) + nAction = m_nXdndActionMove; + else if( dragOperation & DNDConstants::ACTION_COPY ) + nAction = m_nXdndActionCopy; + else if( dragOperation & DNDConstants::ACTION_LINK ) + nAction = m_nXdndActionLink; + m_bLastDropAccepted = true; + sendDragStatus( nAction ); } void SelectionManager::reject( ::Window aDropWindow ) { - if( aDropWindow == m_aCurrentDropWindow ) - { + if( aDropWindow != m_aCurrentDropWindow ) + return; + #if OSL_DEBUG_LEVEL > 1 - SAL_INFO("vcl.unx.dtrans", "reject."); + SAL_INFO("vcl.unx.dtrans", "reject."); #endif - m_bLastDropAccepted = false; - sendDragStatus( None ); - if( m_bDropSent && m_xDragSourceListener.is() ) - { - DragSourceDropEvent dsde; - dsde.Source = static_cast< OWeakObject* >(this); - dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this ); - dsde.DragSource = static_cast< XDragSource* >(this); - dsde.DropAction = DNDConstants::ACTION_NONE; - dsde.DropSuccess = false; - m_xDragSourceListener->dragDropEnd( dsde ); - m_xDragSourceListener.clear(); - } + m_bLastDropAccepted = false; + sendDragStatus( None ); + if( m_bDropSent && m_xDragSourceListener.is() ) + { + DragSourceDropEvent dsde; + dsde.Source = static_cast< OWeakObject* >(this); + dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this ); + dsde.DragSource = static_cast< XDragSource* >(this); + dsde.DropAction = DNDConstants::ACTION_NONE; + dsde.DropSuccess = false; + m_xDragSourceListener->dragDropEnd( dsde ); + m_xDragSourceListener.clear(); } } diff --git a/vcl/unx/generic/dtrans/bmp.cxx b/vcl/unx/generic/dtrans/bmp.cxx index 7f0111a614e4..0b5f6f85c236 100644 --- a/vcl/unx/generic/dtrans/bmp.cxx +++ b/vcl/unx/generic/dtrans/bmp.cxx @@ -401,20 +401,20 @@ PixmapHolder::PixmapHolder( Display* pDisplay ) << std::showbase << std::hex << m_aColormap); #endif - if( m_aInfo.c_class == TrueColor ) - { - int nRedShift2(0); - int nGreenShift2(0); - int nBlueShift2(0); - int nRedSig, nGreenSig, nBlueSig; - getShift( m_aInfo.red_mask, m_nRedShift, nRedSig, nRedShift2 ); - getShift( m_aInfo.green_mask, m_nGreenShift, nGreenSig, nGreenShift2 ); - getShift( m_aInfo.blue_mask, m_nBlueShift, nBlueSig, nBlueShift2 ); - - m_nBlueShift2Mask = nBlueShift2 ? ~static_cast<unsigned long>((1<<nBlueShift2)-1) : ~0L; - m_nGreenShift2Mask = nGreenShift2 ? ~static_cast<unsigned long>((1<<nGreenShift2)-1) : ~0L; - m_nRedShift2Mask = nRedShift2 ? ~static_cast<unsigned long>((1<<nRedShift2)-1) : ~0L; - } + if( m_aInfo.c_class != TrueColor ) + return; + + int nRedShift2(0); + int nGreenShift2(0); + int nBlueShift2(0); + int nRedSig, nGreenSig, nBlueSig; + getShift( m_aInfo.red_mask, m_nRedShift, nRedSig, nRedShift2 ); + getShift( m_aInfo.green_mask, m_nGreenShift, nGreenSig, nGreenShift2 ); + getShift( m_aInfo.blue_mask, m_nBlueShift, nBlueSig, nBlueShift2 ); + + m_nBlueShift2Mask = nBlueShift2 ? ~static_cast<unsigned long>((1<<nBlueShift2)-1) : ~0L; + m_nGreenShift2Mask = nGreenShift2 ? ~static_cast<unsigned long>((1<<nGreenShift2)-1) : ~0L; + m_nRedShift2Mask = nRedShift2 ? ~static_cast<unsigned long>((1<<nRedShift2)-1) : ~0L; } PixmapHolder::~PixmapHolder() diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx index dea4cd548949..d8cc1db16849 100644 --- a/vcl/unx/generic/fontmanager/fontconfig.cxx +++ b/vcl/unx/generic/fontmanager/fontconfig.cxx @@ -726,20 +726,20 @@ static void addtopattern(FcPattern *pPattern, } FcPatternAddInteger(pPattern, FC_WIDTH, nWidth); } - if( ePitch != PITCH_DONTKNOW ) + if( ePitch == PITCH_DONTKNOW ) + return; + + int nSpacing = FC_PROPORTIONAL; + switch( ePitch ) { - int nSpacing = FC_PROPORTIONAL; - switch( ePitch ) - { - case PITCH_FIXED: nSpacing = FC_MONO;break; - case PITCH_VARIABLE: nSpacing = FC_PROPORTIONAL;break; - default: - break; - } - FcPatternAddInteger(pPattern, FC_SPACING, nSpacing); - if (nSpacing == FC_MONO) - FcPatternAddString(pPattern, FC_FAMILY, reinterpret_cast<FcChar8 const *>("monospace")); + case PITCH_FIXED: nSpacing = FC_MONO;break; + case PITCH_VARIABLE: nSpacing = FC_PROPORTIONAL;break; + default: + break; } + FcPatternAddInteger(pPattern, FC_SPACING, nSpacing); + if (nSpacing == FC_MONO) + FcPatternAddString(pPattern, FC_FAMILY, reinterpret_cast<FcChar8 const *>("monospace")); } namespace diff --git a/vcl/unx/generic/fontmanager/helper.cxx b/vcl/unx/generic/fontmanager/helper.cxx index c28753e33b35..79b772c39d6e 100644 --- a/vcl/unx/generic/fontmanager/helper.cxx +++ b/vcl/unx/generic/fontmanager/helper.cxx @@ -153,20 +153,20 @@ void psp::getPrinterPathList( std::vector< OUString >& rPathList, const char* pS } #endif - if( rPathList.empty() ) + if( !rPathList.empty() ) + return; + + // last resort: next to program file (mainly for setup) + OUString aExe; + if( osl_getExecutableFile( &aExe.pData ) == osl_Process_E_None ) { - // last resort: next to program file (mainly for setup) - OUString aExe; - if( osl_getExecutableFile( &aExe.pData ) == osl_Process_E_None ) + INetURLObject aDir( aExe ); + aDir.removeSegment(); + aExe = aDir.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + OUString aSysPath; + if( osl_getSystemPathFromFileURL( aExe.pData, &aSysPath.pData ) == osl_File_E_None ) { - INetURLObject aDir( aExe ); - aDir.removeSegment(); - aExe = aDir.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - OUString aSysPath; - if( osl_getSystemPathFromFileURL( aExe.pData, &aSysPath.pData ) == osl_File_E_None ) - { - rPathList.push_back( aSysPath ); - } + rPathList.push_back( aSysPath ); } } } diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx index 6310b6ba99fa..a348b752dc89 100644 --- a/vcl/unx/generic/gdi/gdiimpl.cxx +++ b/vcl/unx/generic/gdi/gdiimpl.cxx @@ -102,19 +102,20 @@ namespace //fdo#33455 and fdo#80160 handle 1 bit depth pngs with palette entries //to set fore/back colors SalBitmap& rBitmap = const_cast<SalBitmap&>(rSalBitmap); - if (BitmapBuffer* pBitmapBuffer = rBitmap.AcquireBuffer(BitmapAccessMode::Read)) + BitmapBuffer* pBitmapBuffer = rBitmap.AcquireBuffer(BitmapAccessMode::Read); + if (!pBitmapBuffer) + return; + + const BitmapPalette& rPalette = pBitmapBuffer->maPalette; + if (rPalette.GetEntryCount() == 2) { - const BitmapPalette& rPalette = pBitmapBuffer->maPalette; - if (rPalette.GetEntryCount() == 2) - { - const BitmapColor aWhite(rPalette[rPalette.GetBestIndex(COL_WHITE)]); - rValues.foreground = rColMap.GetPixel(aWhite); + const BitmapColor aWhite(rPalette[rPalette.GetBestIndex(COL_WHITE)]); + rValues.foreground = rColMap.GetPixel(aWhite); - const BitmapColor aBlack(rPalette[rPalette.GetBestIndex(COL_BLACK)]); - rValues.background = rColMap.GetPixel(aBlack); - } - rBitmap.ReleaseBuffer(pBitmapBuffer, BitmapAccessMode::Read); + const BitmapColor aBlack(rPalette[rPalette.GetBestIndex(COL_BLACK)]); + rValues.background = rColMap.GetPixel(aBlack); } + rBitmap.ReleaseBuffer(pBitmapBuffer, BitmapAccessMode::Read); } } @@ -925,19 +926,19 @@ void X11SalGraphicsImpl::drawMask( const SalTwoRect& rPosAry, void X11SalGraphicsImpl::ResetClipRegion() { - if( mrParent.mpClipRegion ) - { - mbPenGC = false; - mbBrushGC = false; - mbCopyGC = false; - mbInvertGC = false; - mbInvert50GC = false; - mbStippleGC = false; - mbTrackingGC = false; + if( !mrParent.mpClipRegion ) + return; - XDestroyRegion( mrParent.mpClipRegion ); - mrParent.mpClipRegion = nullptr; - } + mbPenGC = false; + mbBrushGC = false; + mbCopyGC = false; + mbInvertGC = false; + mbInvert50GC = false; + mbStippleGC = false; + mbTrackingGC = false; + + XDestroyRegion( mrParent.mpClipRegion ); + mrParent.mpClipRegion = nullptr; } bool X11SalGraphicsImpl::setClipRegion( const vcl::Region& i_rClip ) @@ -1036,32 +1037,32 @@ void X11SalGraphicsImpl::SetFillColor() void X11SalGraphicsImpl::SetFillColor( Color nColor ) { - if( mnBrushColor != nColor ) - { - mbDitherBrush = false; - mnBrushColor = nColor; - mnBrushPixel = mrParent.GetPixel( nColor ); - if( TrueColor != mrParent.GetColormap().GetVisual().GetClass() - && mrParent.GetColormap().GetColor( mnBrushPixel ) != mnBrushColor - && nColor != Color( 0x00, 0x00, 0x00 ) // black - && nColor != Color( 0x00, 0x00, 0x80 ) // blue - && nColor != Color( 0x00, 0x80, 0x00 ) // green - && nColor != Color( 0x00, 0x80, 0x80 ) // cyan - && nColor != Color( 0x80, 0x00, 0x00 ) // red - && nColor != Color( 0x80, 0x00, 0x80 ) // magenta - && nColor != Color( 0x80, 0x80, 0x00 ) // brown - && nColor != Color( 0x80, 0x80, 0x80 ) // gray - && nColor != Color( 0xC0, 0xC0, 0xC0 ) // light gray - && nColor != Color( 0x00, 0x00, 0xFF ) // light blue - && nColor != Color( 0x00, 0xFF, 0x00 ) // light green - && nColor != Color( 0x00, 0xFF, 0xFF ) // light cyan - && nColor != Color( 0xFF, 0x00, 0x00 ) // light red - && nColor != Color( 0xFF, 0x00, 0xFF ) // light magenta - && nColor != Color( 0xFF, 0xFF, 0x00 ) // light brown - && nColor != Color( 0xFF, 0xFF, 0xFF ) ) - mbDitherBrush = mrParent.GetDitherPixmap(nColor); - mbBrushGC = false; - } + if( mnBrushColor == nColor ) + return; + + mbDitherBrush = false; + mnBrushColor = nColor; + mnBrushPixel = mrParent.GetPixel( nColor ); + if( TrueColor != mrParent.GetColormap().GetVisual().GetClass() + && mrParent.GetColormap().GetColor( mnBrushPixel ) != mnBrushColor + && nColor != Color( 0x00, 0x00, 0x00 ) // black + && nColor != Color( 0x00, 0x00, 0x80 ) // blue + && nColor != Color( 0x00, 0x80, 0x00 ) // green + && nColor != Color( 0x00, 0x80, 0x80 ) // cyan + && nColor != Color( 0x80, 0x00, 0x00 ) // red + && nColor != Color( 0x80, 0x00, 0x80 ) // magenta + && nColor != Color( 0x80, 0x80, 0x00 ) // brown + && nColor != Color( 0x80, 0x80, 0x80 ) // gray + && nColor != Color( 0xC0, 0xC0, 0xC0 ) // light gray + && nColor != Color( 0x00, 0x00, 0xFF ) // light blue + && nColor != Color( 0x00, 0xFF, 0x00 ) // light green + && nColor != Color( 0x00, 0xFF, 0xFF ) // light cyan + && nColor != Color( 0xFF, 0x00, 0x00 ) // light red + && nColor != Color( 0xFF, 0x00, 0xFF ) // light magenta + && nColor != Color( 0xFF, 0xFF, 0x00 ) // light brown + && nColor != Color( 0xFF, 0xFF, 0xFF ) ) + mbDitherBrush = mrParent.GetDitherPixmap(nColor); + mbBrushGC = false; } void X11SalGraphicsImpl::SetROPLineColor( SalROPColor nROPColor ) @@ -1124,29 +1125,29 @@ void X11SalGraphicsImpl::drawPixel( long nX, long nY ) void X11SalGraphicsImpl::drawPixel( long nX, long nY, Color nColor ) { - if( nColor != SALCOLOR_NONE ) - { - Display *pDisplay = mrParent.GetXDisplay(); + if( nColor == SALCOLOR_NONE ) + return; - if( (mnPenColor == SALCOLOR_NONE) && !mbPenGC ) - { - SetLineColor( nColor ); - XDrawPoint( pDisplay, mrParent.GetDrawable(), SelectPen(), nX, nY ); - mnPenColor = SALCOLOR_NONE; - mbPenGC = False; - } - else - { - GC pGC = SelectPen(); + Display *pDisplay = mrParent.GetXDisplay(); + + if( (mnPenColor == SALCOLOR_NONE) && !mbPenGC ) + { + SetLineColor( nColor ); + XDrawPoint( pDisplay, mrParent.GetDrawable(), SelectPen(), nX, nY ); + mnPenColor = SALCOLOR_NONE; + mbPenGC = False; + } + else + { + GC pGC = SelectPen(); - if( nColor != mnPenColor ) - XSetForeground( pDisplay, pGC, mrParent.GetPixel( nColor ) ); + if( nColor != mnPenColor ) + XSetForeground( pDisplay, pGC, mrParent.GetPixel( nColor ) ); - XDrawPoint( pDisplay, mrParent.GetDrawable(), pGC, nX, nY ); + XDrawPoint( pDisplay, mrParent.GetDrawable(), pGC, nX, nY ); - if( nColor != mnPenColor ) - XSetForeground( pDisplay, pGC, mnPenPixel ); - } + if( nColor != mnPenColor ) + XSetForeground( pDisplay, pGC, mnPenPixel ); } } diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx index 01a5e7637827..b0a3f3cfcab0 100644 --- a/vcl/unx/generic/gdi/salbmp.cxx +++ b/vcl/unx/generic/gdi/salbmp.cxx @@ -852,25 +852,26 @@ ImplSalDDB::ImplSalDDB( XImage* pImage, Drawable aDrawable, SalDisplay* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); Display* pXDisp = pSalDisp->GetDisplay(); - if( (maPixmap = limitXCreatePixmap( pXDisp, aDrawable, ImplGetWidth(), ImplGetHeight(), ImplGetDepth() )) ) - { - XGCValues aValues; - GC aGC; - int nValues = GCFunction; + maPixmap = limitXCreatePixmap( pXDisp, aDrawable, ImplGetWidth(), ImplGetHeight(), ImplGetDepth() ); + if (!maPixmap) + return; - aValues.function = GXcopy; + XGCValues aValues; + GC aGC; + int nValues = GCFunction; - if( 1 == mnDepth ) - { - nValues |= ( GCForeground | GCBackground ); - aValues.foreground = 1; - aValues.background = 0; - } + aValues.function = GXcopy; - aGC = XCreateGC( pXDisp, maPixmap, nValues, &aValues ); - XPutImage( pXDisp, maPixmap, aGC, pImage, 0, 0, 0, 0, maTwoRect.mnDestWidth, maTwoRect.mnDestHeight ); - XFreeGC( pXDisp, aGC ); + if( 1 == mnDepth ) + { + nValues |= ( GCForeground | GCBackground ); + aValues.foreground = 1; + aValues.background = 0; } + + aGC = XCreateGC( pXDisp, maPixmap, nValues, &aValues ); + XPutImage( pXDisp, maPixmap, aGC, pImage, 0, 0, 0, 0, maTwoRect.mnDestWidth, maTwoRect.mnDestHeight ); + XFreeGC( pXDisp, aGC ); } ImplSalDDB::ImplSalDDB( diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx index 3ecbe013a88d..4b2632087e7d 100644 --- a/vcl/unx/generic/gdi/salgdi.cxx +++ b/vcl/unx/generic/gdi/salgdi.cxx @@ -320,20 +320,20 @@ void X11SalGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) // cons } // #i12705# equalize x- and y-resolution if they are close enough - if( rDPIX != rDPIY ) - { - // different x- and y- resolutions are usually artifacts of - // a wrongly calculated screen size. + if( rDPIX == rDPIY ) + return; + + // different x- and y- resolutions are usually artifacts of + // a wrongly calculated screen size. #ifdef DEBUG - SAL_INFO("vcl.gdi", "Forcing Resolution from " - << std::hex << rDPIX - << std::dec << rDPIX - << " to " - << std::hex << rDPIY - << std::dec << rDPIY); + SAL_INFO("vcl.gdi", "Forcing Resolution from " + << std::hex << rDPIX + << std::dec << rDPIX + << " to " + << std::hex << rDPIY + << std::dec << rDPIY); #endif - rDPIX = rDPIY; // y-resolution is more trustworthy - } + rDPIX = rDPIY; // y-resolution is more trustworthy } sal_uInt16 X11SalGraphics::GetBitCount() const diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index 885978ed1889..9ddf206572ac 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -203,25 +203,25 @@ FT_FaceRec_* FreetypeFontInfo::GetFaceFT() void FreetypeFont::SetFontVariationsOnHBFont(hb_font_t* pHbFace) const { sal_uInt32 nFaceVariation = mxFontInfo->GetFontFaceVariation(); - if (maFaceFT && nFaceVariation) + if (!(maFaceFT && nFaceVariation)) + return; + + FT_MM_Var *pFtMMVar; + if (FT_Get_MM_Var(maFaceFT, &pFtMMVar) != 0) + return; + + if (nFaceVariation <= pFtMMVar->num_namedstyles) { - FT_MM_Var *pFtMMVar; - if (FT_Get_MM_Var(maFaceFT, &pFtMMVar) == 0) + FT_Var_Named_Style *instance = &pFtMMVar->namedstyle[nFaceVariation - 1]; + std::vector<hb_variation_t> aVariations(pFtMMVar->num_axis); + for (FT_UInt i = 0; i < pFtMMVar->num_axis; ++i) { - if (nFaceVariation <= pFtMMVar->num_namedstyles) - { - FT_Var_Named_Style *instance = &pFtMMVar->namedstyle[nFaceVariation - 1]; - std::vector<hb_variation_t> aVariations(pFtMMVar->num_axis); - for (FT_UInt i = 0; i < pFtMMVar->num_axis; ++i) - { - aVariations[i].tag = pFtMMVar->axis[i].tag; - aVariations[i].value = instance->coords[i] / 65536.0; - } - hb_font_set_variations(pHbFace, aVariations.data(), aVariations.size()); - } - dlFT_Done_MM_Var(aLibFT, pFtMMVar); + aVariations[i].tag = pFtMMVar->axis[i].tag; + aVariations[i].value = instance->coords[i] / 65536.0; } + hb_font_set_variations(pHbFace, aVariations.data(), aVariations.size()); } + dlFT_Done_MM_Var(aLibFT, pFtMMVar); } void FreetypeFontInfo::ReleaseFaceFT() diff --git a/vcl/unx/generic/print/common_gfx.cxx b/vcl/unx/generic/print/common_gfx.cxx index b6c92e49c84a..3938dfdebbea 100644 --- a/vcl/unx/generic/print/common_gfx.cxx +++ b/vcl/unx/generic/print/common_gfx.cxx @@ -476,49 +476,49 @@ PrinterGfx::DrawPolyLineBezier (sal_uInt32 nPoints, const Point* pPath, const Po const sal_uInt32 nBezString= 1024; char pString[nBezString]; - if ( nPoints > 1 && maLineColor.Is() && pPath ) - { - PSSetColor (maLineColor); - PSSetColor (); - PSSetLineWidth (); + if ( nPoints <= 1 || !maLineColor.Is() || !pPath ) + return; - snprintf(pString, nBezString, "%li %li moveto\n", pPath[0].X(), pPath[0].Y()); - WritePS(mpPageBody, pString); + PSSetColor (maLineColor); + PSSetColor (); + PSSetLineWidth (); + + snprintf(pString, nBezString, "%li %li moveto\n", pPath[0].X(), pPath[0].Y()); + WritePS(mpPageBody, pString); - // Handle the drawing of mixed lines mixed with curves - // - a normal point followed by a normal point is a line - // - a normal point followed by 2 control points and a normal point is a curve - for (unsigned int i=1; i<nPoints;) + // Handle the drawing of mixed lines mixed with curves + // - a normal point followed by a normal point is a line + // - a normal point followed by 2 control points and a normal point is a curve + for (unsigned int i=1; i<nPoints;) + { + if (pFlgAry[i] != PolyFlags::Control) //If the next point is a PolyFlags::Normal, we're drawing a line + { + snprintf(pString, nBezString, "%li %li lineto\n", pPath[i].X(), pPath[i].Y()); + i++; + } + else //Otherwise we're drawing a spline { - if (pFlgAry[i] != PolyFlags::Control) //If the next point is a PolyFlags::Normal, we're drawing a line + if (i+2 >= nPoints) + return; //Error: wrong sequence of control/normal points somehow + if ((pFlgAry[i] == PolyFlags::Control) && (pFlgAry[i+1] == PolyFlags::Control) && + (pFlgAry[i+2] != PolyFlags::Control)) { - snprintf(pString, nBezString, "%li %li lineto\n", pPath[i].X(), pPath[i].Y()); - i++; + snprintf(pString, nBezString, "%li %li %li %li %li %li curveto\n", + pPath[i].X(), pPath[i].Y(), + pPath[i+1].X(), pPath[i+1].Y(), + pPath[i+2].X(), pPath[i+2].Y()); } - else //Otherwise we're drawing a spline + else { - if (i+2 >= nPoints) - return; //Error: wrong sequence of control/normal points somehow - if ((pFlgAry[i] == PolyFlags::Control) && (pFlgAry[i+1] == PolyFlags::Control) && - (pFlgAry[i+2] != PolyFlags::Control)) - { - snprintf(pString, nBezString, "%li %li %li %li %li %li curveto\n", - pPath[i].X(), pPath[i].Y(), - pPath[i+1].X(), pPath[i+1].Y(), - pPath[i+2].X(), pPath[i+2].Y()); - } - else - { - OSL_FAIL( "PrinterGfx::DrawPolyLineBezier: Strange output" ); - } - i+=3; + OSL_FAIL( "PrinterGfx::DrawPolyLineBezier: Strange output" ); } - WritePS(mpPageBody, pString); + i+=3; } - - // now draw outlines - WritePS (mpPageBody, "stroke\n"); + WritePS(mpPageBody, pString); } + + // now draw outlines + WritePS (mpPageBody, "stroke\n"); } void @@ -683,34 +683,34 @@ PrinterGfx::PSSetColor () { PrinterColor& rColor( maVirtualStatus.maColor ); - if( currentState().maColor != rColor ) - { - currentState().maColor = rColor; + if( currentState().maColor == rColor ) + return; - OStringBuffer pBuffer; + currentState().maColor = rColor; - if( mbColor ) - { - psp::getValueOfDouble (pBuffer, - static_cast<double>(rColor.GetRed()) / 255.0, 5); - psp::appendStr (" ", pBuffer); - psp::getValueOfDouble (pBuffer, - static_cast<double>(rColor.GetGreen()) / 255.0, 5); - psp::appendStr (" ", pBuffer); - psp::getValueOfDouble (pBuffer, - static_cast<double>(rColor.GetBlue()) / 255.0, 5); - psp::appendStr (" setrgbcolor\n", pBuffer ); - } - else - { - Color aColor( rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue() ); - sal_uInt8 nCol = aColor.GetLuminance(); - psp::getValueOfDouble( pBuffer, static_cast<double>(nCol) / 255.0, 5 ); - psp::appendStr( " setgray\n", pBuffer ); - } + OStringBuffer pBuffer; - WritePS (mpPageBody, pBuffer.makeStringAndClear()); + if( mbColor ) + { + psp::getValueOfDouble (pBuffer, + static_cast<double>(rColor.GetRed()) / 255.0, 5); + psp::appendStr (" ", pBuffer); + psp::getValueOfDouble (pBuffer, + static_cast<double>(rColor.GetGreen()) / 255.0, 5); + psp::appendStr (" ", pBuffer); + psp::getValueOfDouble (pBuffer, + static_cast<double>(rColor.GetBlue()) / 255.0, 5); + psp::appendStr (" setrgbcolor\n", pBuffer ); } + else + { + Color aColor( rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue() ); + sal_uInt8 nCol = aColor.GetLuminance(); + psp::getValueOfDouble( pBuffer, static_cast<double>(nCol) / 255.0, 5 ); + psp::appendStr( " setgray\n", pBuffer ); + } + + WritePS (mpPageBody, pBuffer.makeStringAndClear()); } void diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx index 5cfb5dcb7e11..18caa2e8f413 100644 --- a/vcl/unx/generic/print/genprnpsp.cxx +++ b/vcl/unx/generic/print/genprnpsp.cxx @@ -352,22 +352,22 @@ static bool createPdf( const OUString& rToFile, const OUString& rFromFile, const void SalGenericInstance::configurePspInfoPrinter(PspSalInfoPrinter *pPrinter, SalPrinterQueueInfo const * pQueueInfo, ImplJobSetup* pJobSetup) { - if( pJobSetup ) - { - PrinterInfoManager& rManager( PrinterInfoManager::get() ); - PrinterInfo aInfo( rManager.getPrinterInfo( pQueueInfo->maPrinterName ) ); - pPrinter->m_aJobData = aInfo; - pPrinter->m_aPrinterGfx.Init( pPrinter->m_aJobData ); - - if( pJobSetup->GetDriverData() ) - JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), - pJobSetup->GetDriverDataLen(), aInfo ); - - pJobSetup->SetSystem( JOBSETUP_SYSTEM_UNIX ); - pJobSetup->SetPrinterName( pQueueInfo->maPrinterName ); - pJobSetup->SetDriver( aInfo.m_aDriverName ); - copyJobDataToJobSetup( pJobSetup, aInfo ); - } + if( !pJobSetup ) + return; + + PrinterInfoManager& rManager( PrinterInfoManager::get() ); + PrinterInfo aInfo( rManager.getPrinterInfo( pQueueInfo->maPrinterName ) ); + pPrinter->m_aJobData = aInfo; + pPrinter->m_aPrinterGfx.Init( pPrinter->m_aJobData ); + + if( pJobSetup->GetDriverData() ) + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), + pJobSetup->GetDriverDataLen(), aInfo ); + + pJobSetup->SetSystem( JOBSETUP_SYSTEM_UNIX ); + pJobSetup->SetPrinterName( pQueueInfo->maPrinterName ); + pJobSetup->SetDriver( aInfo.m_aDriverName ); + copyJobDataToJobSetup( pJobSetup, aInfo ); } SalInfoPrinter* SalGenericInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, @@ -451,20 +451,20 @@ void PspSalInfoPrinter::InitPaperFormats( const ImplJobSetup* ) m_aPaperFormats.clear(); m_bPapersInit = true; - if( m_aJobData.m_pParser ) + if( !m_aJobData.m_pParser ) + return; + + const PPDKey* pKey = m_aJobData.m_pParser->getKey( "PageSize" ); + if( pKey ) { - const PPDKey* pKey = m_aJobData.m_pParser->getKey( "PageSize" ); - if( pKey ) + int nValues = pKey->countValues(); + for( int i = 0; i < nValues; i++ ) { - int nValues = pKey->countValues(); - for( int i = 0; i < nValues; i++ ) - { - const PPDValue* pValue = pKey->getValue( i ); - int nWidth = 0, nHeight = 0; - m_aJobData.m_pParser->getPaperDimension( pValue->m_aOption, nWidth, nHeight ); - PaperInfo aInfo(PtTo10Mu( nWidth ), PtTo10Mu( nHeight )); - m_aPaperFormats.push_back( aInfo ); - } + const PPDValue* pValue = pKey->getValue( i ); + int nWidth = 0, nHeight = 0; + m_aJobData.m_pParser->getPaperDimension( pValue->m_aOption, nWidth, nHeight ); + PaperInfo aInfo(PtTo10Mu( nWidth ), PtTo10Mu( nHeight )); + m_aPaperFormats.push_back( aInfo ); } } } diff --git a/vcl/unx/generic/print/prtsetup.cxx b/vcl/unx/generic/print/prtsetup.cxx index fae6a155220e..5ad90b7b878e 100644 --- a/vcl/unx/generic/print/prtsetup.cxx +++ b/vcl/unx/generic/print/prtsetup.cxx @@ -199,21 +199,21 @@ void RTSPaperPage::update() m_xSlotBox->set_sensitive( false ); } - if ( m_pParent->m_aJobData.meSetupMode == PrinterSetupMode::SingleJob ) - { - m_xCbFromSetup->show(); + if ( m_pParent->m_aJobData.meSetupMode != PrinterSetupMode::SingleJob ) + return; - if ( m_pParent->m_aJobData.m_bPapersizeFromSetup ) - m_xCbFromSetup->set_active(m_pParent->m_aJobData.m_bPapersizeFromSetup); - // disable those, unless user wants to use papersize from printer prefs - // as they have no influence on what's going to be printed anyway - else - { - m_xPaperText->set_sensitive( false ); - m_xPaperBox->set_sensitive( false ); - m_xOrientText->set_sensitive( false ); - m_xOrientBox->set_sensitive( false ); ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits