basebmp/inc/rgbmaskpixelformats.hxx | 14 basebmp/source/bitmapdevice.cxx | 7 basebmp/source/debug.cxx | 2 basebmp/test/bmpmasktest.cxx | 4 desktop/qa/desktop_lib/test_desktop_lib.cxx | 2 desktop/source/lib/init.cxx | 39 include/basebmp/scanlineformats.hxx | 4 include/vcl/virdev.hxx | 6 vcl/headless/svpbmp.cxx | 20 vcl/headless/svpgdi.cxx | 4 vcl/inc/headless/svpgdi.hxx | 2 vcl/inc/unx/gtk/gtkframe.hxx | 16 vcl/qa/cppunit/BitmapTest.cxx | 2 vcl/source/gdi/virdev.cxx | 14 vcl/unx/gtk/gtksalframe.cxx | 646 ----- vcl/unx/gtk3/gtk3gtkframe.cxx | 3500 +++++++++++++++++++++++++++- 16 files changed, 3547 insertions(+), 735 deletions(-)
New commits: commit 20dbcd613d2e5d6abce34f6d6d99aa32d1e7d073 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Dec 7 13:45:26 2015 +0000 last arg of SetOutputSizePixelScaleOffsetAndBuffer no longer used Reviewed-on: https://gerrit.libreoffice.org/20441 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 2191a11022f657eae5fb21f87dd443ea9228920b) Change-Id: I65e7e82e46c5751617b00a39df47d864b29b6ce1 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 963bb1b..5d1586f 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -896,11 +896,9 @@ void doc_paintTile (LibreOfficeKitDocument* pThis, boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() ); - boost::shared_array<sal_uInt8> aAlphaBuffer; - pDevice->SetOutputSizePixelScaleOffsetAndBuffer( Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), - aBuffer, aAlphaBuffer); + aBuffer); pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx index cd6db85..c48f10d 100644 --- a/include/vcl/virdev.hxx +++ b/include/vcl/virdev.hxx @@ -48,8 +48,7 @@ private: SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer ); SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, - const basebmp::RawMemorySharedArray &pBuffer, - const basebmp::RawMemorySharedArray &pAlphaBuffer ); + const basebmp::RawMemorySharedArray &pBuffer ); VirtualDevice (const VirtualDevice &) = delete; VirtualDevice & operator= (const VirtualDevice &) = delete; @@ -127,8 +126,7 @@ public: bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset, - const basebmp::RawMemorySharedArray &pBuffer, - const basebmp::RawMemorySharedArray &pAlphaBuffer ); + const basebmp::RawMemorySharedArray &pBuffer ); bool SetOutputSize( const Size& rNewSize, bool bErase = true ) { return SetOutputSizePixel( LogicToPixel( rNewSize ), bErase ); } diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index 085237f..af9bbbd 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -394,8 +394,7 @@ void VirtualDevice::ImplFillOpaqueRectangle( const Rectangle& rRect ) } bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, - const basebmp::RawMemorySharedArray &pBuffer, - const basebmp::RawMemorySharedArray &pAlphaBuffer ) + const basebmp::RawMemorySharedArray &pBuffer ) { if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer) ) { @@ -411,7 +410,7 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, { mpAlphaVDev = VclPtr<VirtualDevice>::Create(*this, meAlphaFormat); mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase, - pAlphaBuffer); + basebmp::RawMemorySharedArray()); } // TODO: copy full outdev state to new one, here. Also needed in outdev2.cxx:DrawOutDev @@ -444,16 +443,13 @@ void VirtualDevice::EnableRTL( bool bEnable ) bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase ) { - return ImplSetOutputSizePixel( rNewSize, bErase, basebmp::RawMemorySharedArray(), basebmp::RawMemorySharedArray()); + return ImplSetOutputSizePixel(rNewSize, bErase, basebmp::RawMemorySharedArray()); } bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset, - const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pAlphaBuffer ) + const basebmp::RawMemorySharedArray &pBuffer ) { - if (pAlphaBuffer) - meAlphaFormat = DeviceFormat::DEFAULT; - if (pBuffer) { MapMode mm = GetMapMode(); mm.SetOrigin( rNewOffset ); @@ -461,7 +457,7 @@ bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( mm.SetScaleY( rScale ); SetMapMode( mm ); } - return ImplSetOutputSizePixel( rNewSize, true, pBuffer, pAlphaBuffer ); + return ImplSetOutputSizePixel(rNewSize, true, pBuffer); } void VirtualDevice::SetReferenceDevice( RefDevMode i_eRefDevMode ) commit 0b7776fac09797c910de6bce615409eeecdeb65c Author: Caolán McNamara <caol...@redhat.com> Date: Mon Dec 7 13:34:01 2015 +0000 Resolves: tdf#96224 don't fiddle around with a separate alpha buffer use a format that supports alpha directly now we can unify the android and linux cases as well and drop the BGRX support Change-Id: I3c845913691d8194822423005d308cfa7ef13ec3 Reviewed-on: https://gerrit.libreoffice.org/20440 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit bc45215ec6e5d508415465ad3f619c3dbe23f7c8) diff --git a/basebmp/inc/rgbmaskpixelformats.hxx b/basebmp/inc/rgbmaskpixelformats.hxx index 6306882..9fde0d0 100644 --- a/basebmp/inc/rgbmaskpixelformats.hxx +++ b/basebmp/inc/rgbmaskpixelformats.hxx @@ -334,20 +334,6 @@ typedef PixelFormatTraitsTemplate_RGBMask< BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_RGBA32_8888::getter_type, PixelFormatTraits_RGBA32_8888::setter_type); -// Added for Cairo needs, perhaps Android should get an XRGB and replace -// some uses of ARGB with that instead ? - -typedef PixelFormatTraitsTemplate_RGBMask< - sal_uInt32, - 0x00000000, - 0x00FF0000, - 0x0000FF00, - 0x000000FF, - BASEBMP_TRUECOLORMASK_LSB_SWAP > PixelFormatTraits_BGRX32_8888; -BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_BGRX32_8888::getter_type, - PixelFormatTraits_BGRX32_8888::setter_type); - - } // namespace basebmp #endif /* INCLUDED_BASEBMP_INC_RGBMASKPIXELFORMATS_HXX */ diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx index a50f0df..37ebf91 100644 --- a/basebmp/source/bitmapdevice.cxx +++ b/basebmp/source/bitmapdevice.cxx @@ -109,7 +109,6 @@ static const o3tl::enumarray<Format,sal_uInt8> bitsPerPixel = 16, // SIXTEEN_BIT_LSB_TC_MASK 16, // SIXTEEN_BIT_MSB_TC_MASK 24, // TWENTYFOUR_BIT_TC_MASK - 32, // TWENTYFOUR_BIT_TC_MASK_BGRX 32, // THIRTYTWO_BIT_TC_MASK_BGRA 32, // THIRTYTWO_BIT_TC_MASK_ARGB 32, // THIRTYTWO_BIT_TC_MASK_ABGR @@ -2053,12 +2052,6 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& // thirtytwo bit formats - // 8 red bits, 8 green bits, 8 blue bits, and 8 ignored bits like CAIRO_FORMAT_RGB24 - case Format::ThirtyTwoBitTcMaskBGRX: - return createRenderer<PixelFormatTraits_BGRX32_8888,StdMasks>( - aBounds, rSize, nScanlineFormat, nScanlineStride, - pFirstScanline, pMem, pPal, rDamage ); - case Format::ThirtyTwoBitTcMaskBGRA: return createRenderer<PixelFormatTraits_BGRA32_8888,StdMasks>( aBounds, rSize, nScanlineFormat, nScanlineStride, diff --git a/basebmp/source/debug.cxx b/basebmp/source/debug.cxx index 3b9de68..f01fd39 100644 --- a/basebmp/source/debug.cxx +++ b/basebmp/source/debug.cxx @@ -63,8 +63,6 @@ namespace basebmp return "SIXTEEN_BIT_MSB_TC_MASK"; case Format::TwentyFourBitTcMask: return "TWENTYFOUR_BIT_TC_MASK"; - case Format::ThirtyTwoBitTcMaskBGRX: - return "THIRTYTWO_BIT_TC_MASK_BGRX"; case Format::ThirtyTwoBitTcMaskBGRA: return "THIRTYTWO_BIT_TC_MASK_BGRA"; case Format::ThirtyTwoBitTcMaskARGB: diff --git a/basebmp/test/bmpmasktest.cxx b/basebmp/test/bmpmasktest.cxx index 7f7e913..daa9263 100644 --- a/basebmp/test/bmpmasktest.cxx +++ b/basebmp/test/bmpmasktest.cxx @@ -177,13 +177,13 @@ public: DrawMode::Paint ); xBitmap = createBitmapDevice( aSize, false, - Format::ThirtyTwoBitTcMaskBGRX ); + Format::ThirtyTwoBitTcMaskBGRA ); xBitmap->clear(Color(0x80808080)); } { // mpOutput & mpBitmap const basegfx::B2ISize aSize(9, 9); xOutput = createBitmapDevice( aSize, false, - Format::ThirtyTwoBitTcMaskBGRX ); + Format::ThirtyTwoBitTcMaskBGRA ); xOutput->clear(Color(0xffffffff)); } diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 07607dd..987ac1b 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -316,7 +316,7 @@ void DesktopLOKTest::testPaintTile() LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); int nCanvasWidth = 100; int nCanvasHeight = 300; - sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(basebmp::Format::ThirtyTwoBitTcMaskBGRX, + sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(basebmp::Format::ThirtyTwoBitTcMaskBGRA, nCanvasWidth); std::vector<unsigned char> aBuffer(nStride * nCanvasHeight); int nTilePosX = 0; diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 2bdea80..963bb1b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -886,33 +886,17 @@ void doc_paintTile (LibreOfficeKitDocument* pThis, pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); -#elif defined(ANDROID) - ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT) ; - - boost::shared_array<sal_uInt8> aBuffer(pBuffer, NoDelete< sal_uInt8 >()); - - boost::shared_array<sal_uInt8> aAlphaBuffer; - - pDevice->SetOutputSizePixelScaleOffsetAndBuffer( - Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), - aBuffer, aAlphaBuffer); - - pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, - nTilePosX, nTilePosY, nTileWidth, nTileHeight); #else ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT) ; +#if !defined(ANDROID) // Set background to transparent by default. pDevice->SetBackground(Wallpaper(Color(COL_TRANSPARENT))); +#endif boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() ); - // Allocate a separate buffer for the alpha device. - sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(basebmp::Format::ThirtyTwoBitTcMaskBGRX, - nCanvasWidth); - std::vector<sal_uInt8> aAlpha(nCanvasHeight * nStride); - - boost::shared_array<sal_uInt8> aAlphaBuffer(aAlpha.data(), NoDelete<sal_uInt8>()); + boost::shared_array<sal_uInt8> aAlphaBuffer; pDevice->SetOutputSizePixelScaleOffsetAndBuffer( Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), @@ -933,21 +917,6 @@ void doc_paintTile (LibreOfficeKitDocument* pThis, pDevice->DrawRect(aRect); pDevice->Pop(); } - - // Overwrite pBuffer's alpha channel with the separate alpha buffer. - for (int nRow = 0; nRow < nCanvasHeight; ++nRow) - { - for (int nCol = 0; nCol < nCanvasWidth; ++nCol) - { - const int nOffset = (nRow * nStride) + nCol * 4; - // VCL's transparent is 0, RGBA's transparent is 0xff. - pBuffer[nOffset + 3] = 0xff - aAlpha[nOffset]; - double fAlpha = pBuffer[nOffset + 3]/255.0; - for (int i = 0; i < 3; ++i) - pBuffer[nOffset + i] *= fAlpha; - } - } - #endif #else diff --git a/include/basebmp/scanlineformats.hxx b/include/basebmp/scanlineformats.hxx index ec246d2..efdc43f 100644 --- a/include/basebmp/scanlineformats.hxx +++ b/include/basebmp/scanlineformats.hxx @@ -42,10 +42,6 @@ enum class Format SixteenBitLsbTcMask, SixteenBitMsbTcMask, TwentyFourBitTcMask, - // CAIRO_FORMAT_RGB24, each pixel is a 32-bit quantity, with the upper 8 - // bits unused. Red, Green, and Blue are stored in the remaining 24 bits in - // that order (below U is for unused) - ThirtyTwoBitTcMaskBGRX, // The order of the channels code letters indicates the order of the // channel bytes in memory ThirtyTwoBitTcMaskBGRA, diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 02f1453..e6d962f 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -198,25 +198,6 @@ BitmapBuffer* SvpSalBitmap::AcquireBuffer( BitmapAccessMode ) nBitCount = 24; pBuf->mnFormat = BMP_FORMAT_24BIT_TC_BGR; break; - case Format::ThirtyTwoBitTcMaskBGRX: - { - nBitCount = 32; - pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK; -#ifdef OSL_BIGENDIAN - ColorMaskElement aRedMask(0x0000ff00); - ColorMaskElement aGreenMask(0x00ff0000); - ColorMaskElement aBlueMask(0xff000000); -#else - ColorMaskElement aRedMask(0x00ff0000); - ColorMaskElement aGreenMask(0x0000ff00); - ColorMaskElement aBlueMask(0x000000ff); -#endif - aBlueMask.CalcMaskShift(); - aRedMask.CalcMaskShift(); - aGreenMask.CalcMaskShift(); - pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask); - break; - } case Format::ThirtyTwoBitTcMaskBGRA: { nBitCount = 32; @@ -457,7 +438,6 @@ sal_uInt32 SvpSalBitmap::getBitCountFromScanlineFormat( basebmp::Format nFormat case Format::TwentyFourBitTcMask: nBitCount = 24; break; - case Format::ThirtyTwoBitTcMaskBGRX: case Format::ThirtyTwoBitTcMaskBGRA: case Format::ThirtyTwoBitTcMaskARGB: case Format::ThirtyTwoBitTcMaskABGR: diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 9e3b16e..57cb68a 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -110,7 +110,7 @@ namespace sal_Int32 nStride = rBuffer->getScanlineStride(); cairo_format_t nFormat; if (rBuffer->getScanlineFormat() == SVP_CAIRO_FORMAT) - nFormat = CAIRO_FORMAT_RGB24; + nFormat = CAIRO_FORMAT_ARGB32; else nFormat = CAIRO_FORMAT_A1; return (cairo_format_stride_for_width(nFormat, size.getX()) == nStride); @@ -1045,7 +1045,7 @@ cairo_t* SvpSalGraphics::createCairoContext(const basebmp::BitmapDeviceSharedPtr basebmp::RawMemorySharedArray data = rBuffer->getBuffer(); cairo_format_t nFormat; if (rBuffer->getScanlineFormat() == SVP_CAIRO_FORMAT) - nFormat = CAIRO_FORMAT_RGB24; + nFormat = CAIRO_FORMAT_ARGB32; else nFormat = CAIRO_FORMAT_A1; cairo_surface_t *target = diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 944ac83..fa6a063 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -41,7 +41,7 @@ #ifdef ANDROID # define SVP_CAIRO_FORMAT basebmp::Format::ThirtyTwoBitTcMaskRGBA #else -# define SVP_CAIRO_FORMAT basebmp::Format::ThirtyTwoBitTcMaskBGRX +# define SVP_CAIRO_FORMAT basebmp::Format::ThirtyTwoBitTcMaskBGRA #endif class GlyphCache; diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx index 33820e4..eb393bc 100644 --- a/vcl/qa/cppunit/BitmapTest.cxx +++ b/vcl/qa/cppunit/BitmapTest.cxx @@ -70,7 +70,7 @@ void BitmapTest::testConvert() { Bitmap::ScopedReadAccess pReadAccess(aBitmap); #if defined LINUX - // 24 bit Bitmap on SVP backend uses 32bit BGRX format + // 24 bit Bitmap on SVP backend uses 32bit BGRA format CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(32), pReadAccess->GetBitCount()); CPPUNIT_ASSERT_EQUAL(sal_uLong(40), pReadAccess->GetScanlineSize()); #else diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx index 75fa0df..62b2ac4 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -1511,7 +1511,7 @@ void GtkSalFrame::AllocateFrame() if( aFrameSize.getY() == 0 ) aFrameSize.setY( 1 ); m_aFrame = basebmp::createBitmapDevice(aFrameSize, true, SVP_CAIRO_FORMAT); - assert(cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, aFrameSize.getX()) == + assert(cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, aFrameSize.getX()) == m_aFrame->getScanlineStride()); m_aFrame->setDamageTracker( basebmp::IBitmapDeviceDamageTrackerSharedPtr(new DamageTracker(*this)) ); commit 2fbff6cdb3266a26a32390ddddd58ebd11947c49 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Dec 4 11:40:13 2015 +0000 Resolves: tdf#95865 gtk3: disentangle Geometry handling don't set our maGeometry directly, wait until gtk confirms the result to update it. We're getting in a real muddle here Change-Id: If1f0b3ef50cabd8ddd5bca66f823bcbea1ecbcaf Reviewed-on: https://gerrit.libreoffice.org/20396 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 77f2fed86d512d8e1942a75b91cd13ce1945c149) diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx index 06e6078..75fa0df 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -1076,11 +1076,6 @@ void GtkSalFrame::InitCommon() maGeometry.nRightDecoration = 0; } } - else - { - resizeWindow( maGeometry.nWidth, maGeometry.nHeight ); - moveWindow( maGeometry.nX, maGeometry.nY ); - } updateScreenNumber(); SetIcon(1); @@ -1341,32 +1336,10 @@ void GtkSalFrame::DrawMenuBar() void GtkSalFrame::Center() { - long nX, nY; - - if( m_pParent ) - { - nX = ((long)m_pParent->maGeometry.nWidth - (long)maGeometry.nWidth)/2; - nY = ((long)m_pParent->maGeometry.nHeight - (long)maGeometry.nHeight)/2; - } + if (m_pParent) + gtk_window_set_position(GTK_WINDOW(m_pWindow), GTK_WIN_POS_CENTER_ON_PARENT); else - { - GdkScreen *pScreen = nullptr; - gint px, py; - GdkModifierType nMask; - gdk_display_get_pointer( getGdkDisplay(), &pScreen, &px, &py, &nMask ); - if( !pScreen ) - pScreen = gtk_widget_get_screen( m_pWindow ); - - gint nMonitor; - nMonitor = gdk_screen_get_monitor_at_point( pScreen, px, py ); - - GdkRectangle aMonitor; - gdk_screen_get_monitor_geometry( pScreen, nMonitor, &aMonitor ); - - nX = aMonitor.x + (aMonitor.width - (long)maGeometry.nWidth)/2; - nY = aMonitor.y + (aMonitor.height - (long)maGeometry.nHeight)/2; - } - SetPosSize( nX, nY, 0, 0, SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y ); + gtk_window_set_position(GTK_WINDOW(m_pWindow), GTK_WIN_POS_CENTER); } Size GtkSalFrame::calcDefaultSize() @@ -1460,8 +1433,6 @@ void GtkSalFrame::Show( bool bVisible, bool bNoActivate ) // the display connection used for clipboard and our connection Flush(); } - CallCallback( SALEVENT_RESIZE, nullptr ); - TriggerPaintEvent(); } } @@ -1491,19 +1462,6 @@ void GtkSalFrame::setMinMaxSize() aHints |= GDK_HINT_MAX_SIZE; } } - else - { - if( ! m_bFullscreen ) - { - aGeo.min_width = maGeometry.nWidth; - aGeo.min_height = maGeometry.nHeight; - aHints |= GDK_HINT_MIN_SIZE; - - aGeo.max_width = maGeometry.nWidth; - aGeo.max_height = maGeometry.nHeight; - aHints |= GDK_HINT_MAX_SIZE; - } - } if( m_bFullscreen && m_aMaxSize.Width() && m_aMaxSize.Height() ) { aGeo.max_width = m_aMaxSize.Width(); @@ -1525,9 +1483,7 @@ void GtkSalFrame::SetMaxClientSize( long nWidth, long nHeight ) if( ! isChild() ) { m_aMaxSize = Size( nWidth, nHeight ); - // Show does a setMinMaxSize - if( IS_WIDGET_MAPPED( m_pWindow ) ) - setMinMaxSize(); + setMinMaxSize(); } } void GtkSalFrame::SetMinClientSize( long nWidth, long nHeight ) @@ -1538,9 +1494,7 @@ void GtkSalFrame::SetMinClientSize( long nWidth, long nHeight ) if( m_pWindow ) { widget_set_size_request(nWidth, nHeight ); - // Show does a setMinMaxSize - if( IS_WIDGET_MAPPED( m_pWindow ) ) - setMinMaxSize(); + setMinMaxSize(); } } } @@ -1577,23 +1531,17 @@ void GtkSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u if( !m_pWindow || isChild( true, false ) ) return; - bool bSized = false, bMoved = false; - if( (nFlags & ( SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT )) && (nWidth > 0 && nHeight > 0 ) // sometimes stupid things happen ) { m_bDefaultSize = false; - if( (unsigned long)nWidth != maGeometry.nWidth || (unsigned long)nHeight != maGeometry.nHeight ) - bSized = true; - maGeometry.nWidth = nWidth; - maGeometry.nHeight = nHeight; - if( isChild( false ) ) widget_set_size_request(nWidth, nHeight); else if( ! ( m_nState & GDK_WINDOW_STATE_MAXIMIZED ) ) window_resize(nWidth, nHeight); + setMinMaxSize(); } else if( m_bDefaultSize ) @@ -1611,14 +1559,9 @@ void GtkSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u nY += m_pParent->maGeometry.nY; } - if( nX != maGeometry.nX || nY != maGeometry.nY ) - bMoved = true; - maGeometry.nX = nX; - maGeometry.nY = nY; - m_bDefaultPos = false; - moveWindow( maGeometry.nX, maGeometry.nY ); + moveWindow(nX, nY); updateScreenNumber(); } @@ -1626,19 +1569,6 @@ void GtkSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u Center(); m_bDefaultPos = false; - - if( bSized ) - AllocateFrame(); - - if( bSized && ! bMoved ) - CallCallback( SALEVENT_RESIZE, nullptr ); - else if( bMoved && ! bSized ) - CallCallback( SALEVENT_MOVE, nullptr ); - else if( bMoved && bSized ) - CallCallback( SALEVENT_MOVERESIZE, nullptr ); - - if (bSized) - TriggerPaintEvent(); } void GtkSalFrame::GetClientSize( long& rWidth, long& rHeight ) @@ -1692,16 +1622,11 @@ void GtkSalFrame::SetWindowState( const SalFrameState* pState ) moveWindow( pState->mnX, pState->mnY ); m_bDefaultPos = m_bDefaultSize = false; - maGeometry.nX = pState->mnMaximizedX; - maGeometry.nY = pState->mnMaximizedY; - maGeometry.nWidth = pState->mnMaximizedWidth; - maGeometry.nHeight = pState->mnMaximizedHeight; updateScreenNumber(); m_nState = GdkWindowState( m_nState | GDK_WINDOW_STATE_MAXIMIZED ); m_aRestorePosSize = Rectangle( Point( pState->mnX, pState->mnY ), Size( pState->mnWidth, pState->mnHeight ) ); - CallCallback( SALEVENT_RESIZE, nullptr ); } else if( pState->mnMask & (WINDOWSTATE_MASK_X | WINDOWSTATE_MASK_Y | WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT ) ) @@ -1798,6 +1723,8 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz if (maGeometry.nDisplayScreenNumber == nNewScreen && eType == SET_RETAIN_SIZE) return; + int nX = maGeometry.nX, nY = maGeometry.nY, + nWidth = maGeometry.nWidth, nHeight = maGeometry.nHeight; GdkScreen *pScreen = nullptr; GdkRectangle aNewMonitor; @@ -1851,8 +1778,8 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz gdk_screen_get_monitor_geometry( pScreen, nOldMonitor, &aOldMonitor ); gdk_screen_get_monitor_geometry( pScreen, nMonitor, &aNewMonitor ); - maGeometry.nX = aNewMonitor.x + maGeometry.nX - aOldMonitor.x; - maGeometry.nY = aNewMonitor.y + maGeometry.nY - aOldMonitor.y; + nX = aNewMonitor.x + nX - aOldMonitor.x; + nY = aNewMonitor.y + nY - aOldMonitor.y; } bool bResize = false; @@ -1862,10 +1789,10 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz if( eType == SET_FULLSCREEN ) { - maGeometry.nX = aNewMonitor.x; - maGeometry.nY = aNewMonitor.y; - maGeometry.nWidth = aNewMonitor.width; - maGeometry.nHeight = aNewMonitor.height; + nX = aNewMonitor.x; + nY = aNewMonitor.y; + nWidth = aNewMonitor.width; + nHeight = aNewMonitor.height; m_nStyle |= SalFrameStyleFlags::PARTIAL_FULLSCREEN; bResize = true; @@ -1877,10 +1804,10 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz if( pSize && eType == SET_UN_FULLSCREEN ) { - maGeometry.nX = pSize->Left(); - maGeometry.nY = pSize->Top(); - maGeometry.nWidth = pSize->GetWidth(); - maGeometry.nHeight = pSize->GetHeight(); + nX = pSize->Left(); + nY = pSize->Top(); + nWidth = pSize->GetWidth(); + nHeight = pSize->GetHeight(); m_nStyle &= ~SalFrameStyleFlags::PARTIAL_FULLSCREEN; bResize = true; } @@ -1890,14 +1817,10 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz // temporarily re-sizeable if( !(m_nStyle & SalFrameStyleFlags::SIZEABLE) ) gtk_window_set_resizable( GTK_WINDOW(m_pWindow), TRUE ); - window_resize(maGeometry.nWidth, maGeometry.nHeight); - //I wonder if we should instead leave maGeometry alone and rely on - //configure-event to trigger signalConfigure and set it there - AllocateFrame(); - TriggerPaintEvent(); + window_resize(nWidth, nHeight); } - gtk_window_move( GTK_WINDOW( m_pWindow ), maGeometry.nX, maGeometry.nY ); + gtk_window_move(GTK_WINDOW(m_pWindow), nX, nY); #if GTK_CHECK_VERSION(3,8,0) gdk_window_set_fullscreen_mode( widget_get_window(m_pWindow), m_bSpanMonitorsWhenFullscreen @@ -1921,7 +1844,6 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz m_bDefaultPos = m_bDefaultSize = false; updateScreenNumber(); - CallCallback( SALEVENT_MOVERESIZE, nullptr ); if( bVisible ) Show( true ); @@ -2693,45 +2615,20 @@ gboolean GtkSalFrame::signalDraw( GtkWidget*, cairo_t *cr, gpointer frame ) void GtkSalFrame::sizeAllocated(GtkWidget*, GdkRectangle *pAllocation, gpointer frame) { GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame); - - bool bSized = false; - - if( pThis->m_bFullscreen || (pThis->m_nStyle & (SalFrameStyleFlags::SIZEABLE | SalFrameStyleFlags::PLUG)) == SalFrameStyleFlags::SIZEABLE ) - { - if( pAllocation->width != (int)pThis->maGeometry.nWidth || pAllocation->height != (int)pThis->maGeometry.nHeight ) - { - bSized = true; - pThis->maGeometry.nWidth = pAllocation->width; - pThis->maGeometry.nHeight = pAllocation->height; - } - } - - if( bSized ) - { - pThis->AllocateFrame(); - pThis->CallCallback( SALEVENT_RESIZE, nullptr ); - pThis->TriggerPaintEvent(); - } + pThis->maGeometry.nWidth = pAllocation->width; + pThis->maGeometry.nHeight = pAllocation->height; + pThis->AllocateFrame(); + pThis->CallCallback( SALEVENT_RESIZE, nullptr ); + pThis->TriggerPaintEvent(); } gboolean GtkSalFrame::signalConfigure(GtkWidget*, GdkEventConfigure* pEvent, gpointer frame) { GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame); - pThis->m_bPaintsBlocked = false; bool bMoved = false; int x = pEvent->x, y = pEvent->y; - /* HACK: during sizing/moving a toolbar pThis->maGeometry is actually - * already exact; even worse: due to the asynchronicity of configure - * events the borderwindow which would evaluate this event - * would size/move based on wrong data if we would actually evaluate - * this event. So let's swallow it. - */ - if( (pThis->m_nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION) && - GtkSalFrame::getDisplay()->GetCaptureFrame() == pThis ) - return false; - /* #i31785# claims we cannot trust the x,y members of the event; * they are e.g. not set correctly on maximize/demaximize; * yet the gdkdisplay-x11.c code handling configure_events has @@ -2745,23 +2642,12 @@ gboolean GtkSalFrame::signalConfigure(GtkWidget*, GdkEventConfigure* pEvent, gpo } // update decoration hints - if( ! (pThis->m_nStyle & SalFrameStyleFlags::PLUG) ) - { - GdkRectangle aRect; - gdk_window_get_frame_extents( widget_get_window(GTK_WIDGET(pThis->m_pWindow)), &aRect ); - pThis->maGeometry.nTopDecoration = y - aRect.y; - pThis->maGeometry.nBottomDecoration = aRect.y + aRect.height - y - pEvent->height; - pThis->maGeometry.nLeftDecoration = x - aRect.x; - pThis->maGeometry.nRightDecoration = aRect.x + aRect.width - x - pEvent->width; - } - else - { - pThis->maGeometry.nTopDecoration = - pThis->maGeometry.nBottomDecoration = - pThis->maGeometry.nLeftDecoration = - pThis->maGeometry.nRightDecoration = 0; - } - + GdkRectangle aRect; + gdk_window_get_frame_extents( widget_get_window(GTK_WIDGET(pThis->m_pWindow)), &aRect ); + pThis->maGeometry.nTopDecoration = y - aRect.y; + pThis->maGeometry.nBottomDecoration = aRect.y + aRect.height - y - pEvent->height; + pThis->maGeometry.nLeftDecoration = x - aRect.x; + pThis->maGeometry.nRightDecoration = aRect.x + aRect.width - x - pEvent->width; pThis->updateScreenNumber(); if (bMoved) commit c58ee8173c1c3a46164d14707da2e3e0f961f595 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Dec 4 11:06:01 2015 +0000 remove gtk2 stuff from gtk3 salframe Change-Id: I096a3a9b6fd69b8c8943b9db19d5a3fd32dfcb02 Reviewed-on: https://gerrit.libreoffice.org/20395 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 8b361da6b729b25ed8293f26132ae99350f7f472) diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx index 66b2d39..06e6078 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -38,9 +38,6 @@ #include <vcl/window.hxx> #include <vcl/settings.hxx> -#if !GTK_CHECK_VERSION(3,0,0) -# include <unx/x11/xlimits.hxx> -#endif #if defined(ENABLE_DBUS) && defined(ENABLE_GIO) # include <unx/gtk/gtksalmenu.hxx> #endif @@ -82,19 +79,12 @@ #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/util/URLTransformer.hpp> -#if GTK_CHECK_VERSION(3,0,0) -# include <gdk/gdkkeysyms-compat.h> -#endif +#include <gdk/gdkkeysyms-compat.h> #include <config_folders.h> -#if GTK_CHECK_VERSION(3,0,0) #define IS_WIDGET_REALIZED gtk_widget_get_realized #define IS_WIDGET_MAPPED gtk_widget_get_mapped -#else -#define IS_WIDGET_REALIZED GTK_WIDGET_REALIZED -#define IS_WIDGET_MAPPED GTK_WIDGET_MAPPED -#endif #ifndef GDK_IS_X11_DISPLAY #define GDK_IS_X11_DISPLAY(foo) (true) @@ -152,33 +142,19 @@ static sal_uInt16 GetKeyCode( guint keyval ) nCode = KEY_A + (keyval-GDK_a ); else if( keyval >= GDK_F1 && keyval <= GDK_F26 ) { -#if !GTK_CHECK_VERSION(3,0,0) - if( GetGtkSalData()->GetGtkDisplay()->IsNumLockFromXS() ) - { - nCode = KEY_F1 + (keyval-GDK_F1); - } - else -#endif + switch( keyval ) { - switch( keyval ) - { - // - - - - - Sun keyboard, see vcl/unx/source/app/saldisp.cxx - case GDK_L2: -#if !GTK_CHECK_VERSION(3,0,0) - if( GetGtkSalData()->GetGtkDisplay()->GetServerVendor() == vendor_sun ) - nCode = KEY_REPEAT; - else -#endif - nCode = KEY_F12; - break; - case GDK_L3: nCode = KEY_PROPERTIES; break; - case GDK_L4: nCode = KEY_UNDO; break; - case GDK_L6: nCode = KEY_COPY; break; // KEY_F16 - case GDK_L8: nCode = KEY_PASTE; break; // KEY_F18 - case GDK_L10: nCode = KEY_CUT; break; // KEY_F20 - default: - nCode = KEY_F1 + (keyval-GDK_F1); break; - } + // - - - - - Sun keyboard, see vcl/unx/source/app/saldisp.cxx + case GDK_L2: + nCode = KEY_F12; + break; + case GDK_L3: nCode = KEY_PROPERTIES; break; + case GDK_L4: nCode = KEY_UNDO; break; + case GDK_L6: nCode = KEY_COPY; break; // KEY_F16 + case GDK_L8: nCode = KEY_PASTE; break; // KEY_F18 + case GDK_L10: nCode = KEY_CUT; break; // KEY_F20 + default: + nCode = KEY_F1 + (keyval-GDK_F1); break; } } else @@ -359,8 +335,6 @@ GetAlternateKeyCode( const sal_uInt16 nKeyCode ) return aAlternate; } -#if GTK_CHECK_VERSION(3,0,0) - namespace { /// Decouple SalFrame lifetime from damagetracker lifetime struct DamageTracker : public basebmp::IBitmapDeviceDamageTracker @@ -380,7 +354,6 @@ struct DamageTracker : public basebmp::IBitmapDeviceDamageTracker } static bool dumpframes = false; -#endif void GtkSalFrame::doKeyCallback( guint state, guint keyval, @@ -400,7 +373,6 @@ void GtkSalFrame::doKeyCallback( guint state, vcl::DeletionListener aDel( this ); -#if GTK_CHECK_VERSION(3,0,0) #if 0 // shift-zero forces a re-draw and event is swallowed if (keyval == GDK_0) @@ -422,7 +394,6 @@ void GtkSalFrame::doKeyCallback( guint state, return; } #endif -#endif /* * #i42122# translate all keys with Ctrl and/or Alt to group 0 else @@ -526,28 +497,10 @@ GtkSalFrame::GtkSalFrame( SystemParentData* pSysData ) #ifdef ENABLE_GMENU_INTEGRATION static void -gdk_x11_window_set_utf8_property (GdkWindow *window, - const gchar *name, - const gchar *value) +gdk_x11_window_set_utf8_property (GdkWindow * /*window*/, + const gchar * /*name*/, + const gchar * /*value*/) { -#if !GTK_CHECK_VERSION(3,0,0) - GdkDisplay* display = gdk_window_get_display (window); - - if (value != nullptr) - { - XChangeProperty (GDK_DISPLAY_XDISPLAY (display), - GDK_WINDOW_XID (window), - gdk_x11_get_xatom_by_name_for_display (display, name), - gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8, - PropModeReplace, reinterpret_cast<guchar const *>(value), strlen (value)); - } - else - { - XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), - GDK_WINDOW_XID (window), - gdk_x11_get_xatom_by_name_for_display (display, name)); - } -#endif } // AppMenu watch functions. @@ -752,11 +705,7 @@ gboolean ensure_dbus_setup( gpointer data ) g_object_unref(thirdsubmenu); GSimpleActionGroup *group = g_simple_action_group_new (); -#if GLIB_CHECK_VERSION(2,38,0) // g_simple_action_group_add_entries is deprecated since 2.38 g_action_map_add_action_entries (G_ACTION_MAP (group), app_entries, G_N_ELEMENTS (app_entries), nullptr); -#else - g_simple_action_group_add_entries (group, app_entries, G_N_ELEMENTS (app_entries), NULL); -#endif GActionGroup* pAppActionGroup = G_ACTION_GROUP(group); pSalFrame->m_nAppActionGroupExportId = g_dbus_connection_export_action_group( pSessionBus, "/org/libreoffice", pAppActionGroup, nullptr); @@ -846,10 +795,6 @@ void GtkSalFrame::InvalidateGraphics() { if( m_pGraphics ) { -#if !GTK_CHECK_VERSION(3,0,0) - m_pGraphics->SetDrawable( None, m_nXScreen ); - m_pGraphics->SetWindow(nullptr); -#endif m_bGraphics = false; } } @@ -865,22 +810,8 @@ GtkSalFrame::~GtkSalFrame() if( m_pRegion ) { -#if GTK_CHECK_VERSION(3,0,0) cairo_region_destroy( m_pRegion ); -#else - gdk_region_destroy( m_pRegion ); -#endif - } - -#if !GTK_CHECK_VERSION(3,0,0) - if( m_hBackgroundPixmap ) - { - XSetWindowBackgroundPixmap( getDisplay()->GetDisplay(), - widget_get_xid(m_pWindow), - None ); - XFreePixmap( getDisplay()->GetDisplay(), m_hBackgroundPixmap ); } -#endif delete m_pIMHandler; @@ -943,29 +874,11 @@ void GtkSalFrame::moveWindow( long nX, long nY ) void GtkSalFrame::widget_set_size_request(long nWidth, long nHeight) { -#if !GTK_CHECK_VERSION(3,0,0) - gint nOrigwidth, nOrigheight; - gtk_window_get_size(GTK_WINDOW(m_pWindow), &nOrigwidth, &nOrigheight); - if (nWidth > nOrigwidth || nHeight > nOrigheight) - { - m_bPaintsBlocked = true; - } - gtk_widget_set_size_request(m_pWindow, nWidth, nHeight ); -#else gtk_widget_set_size_request(GTK_WIDGET(m_pFixedContainer), nWidth, nHeight ); -#endif } void GtkSalFrame::window_resize(long nWidth, long nHeight) { -#if !GTK_CHECK_VERSION(3,0,0) - gint nOrigwidth, nOrigheight; - gtk_window_get_size(GTK_WINDOW(m_pWindow), &nOrigwidth, &nOrigheight); - if (nWidth > nOrigwidth || nHeight > nOrigheight) - { - m_bPaintsBlocked = true; - } -#endif gtk_window_resize(GTK_WINDOW(m_pWindow), nWidth, nHeight); } @@ -979,8 +892,6 @@ void GtkSalFrame::resizeWindow( long nWidth, long nHeight ) window_resize(nWidth, nHeight); } -#if GTK_CHECK_VERSION(3,2,0) - static void ooo_fixed_class_init(GtkFixedClass *klass) { @@ -988,8 +899,6 @@ ooo_fixed_class_init(GtkFixedClass *klass) widget_class->get_accessible = ooo_fixed_get_accessible; } -#endif - /* * Always use a sub-class of GtkFixed we can tag for a11y. This allows us to * utilize GAIL for the toplevel window and toolkit implementation incl. @@ -1007,11 +916,7 @@ ooo_fixed_get_type() sizeof (GtkFixedClass), nullptr, /* base init */ nullptr, /* base finalize */ -#if GTK_CHECK_VERSION(3,2,0) reinterpret_cast<GClassInitFunc>(ooo_fixed_class_init), /* class init */ -#else - nullptr, /* class init */ -#endif nullptr, /* class finalize */ nullptr, /* class data */ sizeof (GtkFixed), /* instance size */ @@ -1038,16 +943,11 @@ void GtkSalFrame::updateScreenNumber() GtkWidget *GtkSalFrame::getMouseEventWidget() const { -#if GTK_CHECK_VERSION(3,0,0) return GTK_WIDGET(m_pEventBox); -#else - return m_pWindow; -#endif } void GtkSalFrame::InitCommon() { -#if GTK_CHECK_VERSION(3,0,0) m_pEventBox = GTK_EVENT_BOX(gtk_event_box_new()); gtk_widget_add_events( GTK_WIDGET(m_pEventBox), GDK_ALL_EVENTS_MASK ); @@ -1057,13 +957,6 @@ void GtkSalFrame::InitCommon() // fixed is needed since we have to position plugin windows m_pFixedContainer = GTK_FIXED(g_object_new( ooo_fixed_get_type(), nullptr )); gtk_container_add( GTK_CONTAINER(m_pEventBox), GTK_WIDGET(m_pFixedContainer) ); -#else - m_pEventBox = nullptr; - // add the fixed container child, - // fixed is needed since we have to position plugin windows - m_pFixedContainer = GTK_FIXED(g_object_new( ooo_fixed_get_type(), nullptr )); - gtk_container_add( GTK_CONTAINER(m_pWindow), GTK_WIDGET(m_pFixedContainer) ); -#endif GtkWidget *pEventWidget = getMouseEventWidget(); @@ -1080,7 +973,6 @@ void GtkSalFrame::InitCommon() m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "button-press-event", G_CALLBACK(signalButton), this )); m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "motion-notify-event", G_CALLBACK(signalMotion), this )); m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "button-release-event", G_CALLBACK(signalButton), this )); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect( G_OBJECT(m_pFixedContainer), "draw", G_CALLBACK(signalDraw), this ); g_signal_connect( G_OBJECT(m_pFixedContainer), "size-allocate", G_CALLBACK(sizeAllocated), this ); #if GTK_CHECK_VERSION(3,14,0) @@ -1096,9 +988,6 @@ void GtkSalFrame::InitCommon() #endif -#else - g_signal_connect( G_OBJECT(m_pFixedContainer), "expose-event", G_CALLBACK(signalExpose), this ); -#endif g_signal_connect( G_OBJECT(m_pWindow), "focus-in-event", G_CALLBACK(signalFocus), this ); g_signal_connect( G_OBJECT(m_pWindow), "focus-out-event", G_CALLBACK(signalFocus), this ); g_signal_connect( G_OBJECT(m_pWindow), "map-event", G_CALLBACK(signalMap), this ); @@ -1143,31 +1032,17 @@ void GtkSalFrame::InitCommon() ); // show the widgets -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_show_all( GTK_WIDGET(m_pEventBox) ); -#else - gtk_widget_show_all( GTK_WIDGET(m_pFixedContainer) ); -#endif // realize the window, we need an XWindow id gtk_widget_realize( m_pWindow ); //system data m_aSystemData.nSize = sizeof( SystemEnvData ); -#if !GTK_CHECK_VERSION(3,0,0) - GtkSalDisplay* pDisp = GetGtkSalData()->GetGtkDisplay(); - m_aSystemData.pDisplay = pDisp->GetDisplay(); - m_aSystemData.pVisual = pDisp->GetVisual( m_nXScreen ).GetVisual(); - m_aSystemData.nDepth = pDisp->GetVisual( m_nXScreen ).GetDepth(); - m_aSystemData.aColormap = pDisp->GetColormap( m_nXScreen ).GetXColormap(); - m_aSystemData.aWindow = widget_get_xid(m_pWindow); - m_aSystemData.aShellWindow = m_aSystemData.aWindow; -#else static int nWindow = 0; m_aSystemData.aWindow = nWindow; m_aSystemData.aShellWindow = nWindow; ++nWindow; -#endif m_aSystemData.pSalFrame = this; m_aSystemData.pWidget = m_pWindow; m_aSystemData.nScreen = m_nXScreen.getXScreen(); @@ -1209,139 +1084,8 @@ void GtkSalFrame::InitCommon() updateScreenNumber(); SetIcon(1); - -#if !GTK_CHECK_VERSION(3,0,0) - m_nWorkArea = pDisp->getWMAdaptor()->getCurrentWorkArea(); - /* #i64117# gtk sets a nice background pixmap - * but we actually don't really want that, so save - * some time on the Xserver as well as prevent - * some paint issues - */ - XSetWindowBackgroundPixmap( getDisplay()->GetDisplay(), - widget_get_xid(m_pWindow), - m_hBackgroundPixmap ); -#endif -} - -/* Sadly gtk_window_set_accept_focus exists only since gtk 2.4 - * for achieving the same effect we will remove the WM_TAKE_FOCUS - * protocol from the window and set the input hint to false. - * But gtk_window_set_accept_focus needs to be called before - * window realization whereas the removal obviously can only happen - * after realization. - */ - -#if !GTK_CHECK_VERSION(3,0,0) -extern "C" { - typedef void(*setAcceptFn)( GtkWindow*, gboolean ); - static setAcceptFn p_gtk_window_set_accept_focus = nullptr; - static bool bGetAcceptFocusFn = true; - - typedef void(*setUserTimeFn)( GdkWindow*, guint32 ); - static setUserTimeFn p_gdk_x11_window_set_user_time = nullptr; - static bool bGetSetUserTimeFn = true; -} -#endif - -static void lcl_set_accept_focus( GtkWindow* pWindow, gboolean bAccept, bool bBeforeRealize ) -{ -#if !GTK_CHECK_VERSION(3,0,0) - if( bGetAcceptFocusFn ) - { - bGetAcceptFocusFn = false; - p_gtk_window_set_accept_focus = reinterpret_cast<setAcceptFn>(osl_getAsciiFunctionSymbol( GetSalData()->m_pPlugin, "gtk_window_set_accept_focus" )); - } - if( p_gtk_window_set_accept_focus && bBeforeRealize ) - p_gtk_window_set_accept_focus( pWindow, bAccept ); - else if( ! bBeforeRealize ) - { - Display* pDisplay = GetGtkSalData()->GetGtkDisplay()->GetDisplay(); - ::Window aWindow = widget_get_xid(GTK_WIDGET(pWindow)); - XWMHints* pHints = XGetWMHints( pDisplay, aWindow ); - if( ! pHints ) - { - pHints = XAllocWMHints(); - pHints->flags = 0; - } - pHints->flags |= InputHint; - pHints->input = bAccept ? True : False; - XSetWMHints( pDisplay, aWindow, pHints ); - XFree( pHints ); - - if (GetGtkSalData()->GetGtkDisplay()->getWMAdaptor()->getWindowManagerName() == "compiz") - return; - - /* remove WM_TAKE_FOCUS protocol; this would usually be the - * right thing, but gtk handles it internally whereas we - * want to handle it ourselves (as to sometimes not get - * the focus) - */ - Atom* pProtocols = nullptr; - int nProtocols = 0; - XGetWMProtocols( pDisplay, - aWindow, - &pProtocols, &nProtocols ); - if( pProtocols ) - { - bool bSet = false; - Atom nTakeFocus = XInternAtom( pDisplay, "WM_TAKE_FOCUS", True ); - if( nTakeFocus ) - { - for( int i = 0; i < nProtocols; i++ ) - { - if( pProtocols[i] == nTakeFocus ) - { - for( int n = i; n < nProtocols-1; n++ ) - pProtocols[n] = pProtocols[n+1]; - nProtocols--; - i--; - bSet = true; - } - } - } - if( bSet ) - XSetWMProtocols( pDisplay, aWindow, pProtocols, nProtocols ); - XFree( pProtocols ); - } - } -#else - gtk_window_set_accept_focus(pWindow, bAccept); - (void)bBeforeRealize; -#endif } -#if !GTK_CHECK_VERSION(3,0,0) -static void lcl_set_user_time( GtkWindow* i_pWindow, guint32 i_nTime ) -{ - if( bGetSetUserTimeFn ) - { - bGetSetUserTimeFn = false; - p_gdk_x11_window_set_user_time = reinterpret_cast<setUserTimeFn>(osl_getAsciiFunctionSymbol( GetSalData()->m_pPlugin, "gdk_x11_window_set_user_time" )); - } - bool bSet = false; - if( p_gdk_x11_window_set_user_time ) - { - GdkWindow* pWin = widget_get_window(GTK_WIDGET(i_pWindow)); - if( pWin ) // only if the window is realized. - { - p_gdk_x11_window_set_user_time( pWin, i_nTime ); - bSet = true; - } - } - if( !bSet ) - { - Display* pDisplay = GetGtkSalData()->GetGtkDisplay()->GetDisplay(); - Atom nUserTime = XInternAtom( pDisplay, "_NET_WM_USER_TIME", True ); - if( nUserTime ) - { - XChangeProperty( pDisplay, widget_get_xid(GTK_WIDGET(i_pWindow)), - nUserTime, XA_CARDINAL, 32, - PropModeReplace, reinterpret_cast<unsigned char*>(&i_nTime), 1 ); - } - } -}; -#endif - GtkSalFrame *GtkSalFrame::getFromWindow( GtkWindow *pWindow ) { return static_cast<GtkSalFrame *>(g_object_get_data( G_OBJECT( pWindow ), "SalFrame" )); @@ -1429,20 +1173,12 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle ) else if( (nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION) ) { eType = GDK_WINDOW_TYPE_HINT_TOOLBAR; - lcl_set_accept_focus( GTK_WINDOW(m_pWindow), false, true ); + gtk_window_set_accept_focus(GTK_WINDOW(m_pWindow), false); } else if( (nStyle & SalFrameStyleFlags::FLOAT_FOCUSABLE) ) { eType = GDK_WINDOW_TYPE_HINT_UTILITY; } -#if !GTK_CHECK_VERSION(3,0,0) - if( (nStyle & SalFrameStyleFlags::PARTIAL_FULLSCREEN ) - && getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) - { - eType = GDK_WINDOW_TYPE_HINT_TOOLBAR; - gtk_window_set_keep_above( GTK_WINDOW(m_pWindow), true ); - } -#endif gtk_window_set_type_hint( GTK_WINDOW(m_pWindow), eType ); gtk_window_set_gravity( GTK_WINDOW(m_pWindow), GDK_GRAVITY_STATIC ); } @@ -1456,57 +1192,21 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle ) ensure_dbus_setup( this ); #endif -#if !GTK_CHECK_VERSION(3,0,0) - guint32 nUserTime = 0; - if( (nStyle & (SalFrameStyleFlags::OWNERDRAWDECORATION|SalFrameStyleFlags::TOOLWINDOW)) == SalFrameStyleFlags::NONE ) - { - nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window); - } - lcl_set_user_time(GTK_WINDOW(m_pWindow), nUserTime); -#endif } if( bDecoHandling ) { gtk_window_set_resizable( GTK_WINDOW(m_pWindow), bool(nStyle & SalFrameStyleFlags::SIZEABLE) ); if( ( (nStyle & (SalFrameStyleFlags::OWNERDRAWDECORATION)) ) ) - lcl_set_accept_focus( GTK_WINDOW(m_pWindow), false, false ); + gtk_window_set_accept_focus(GTK_WINDOW(m_pWindow), false); } } GdkNativeWindow GtkSalFrame::findTopLevelSystemWindow( GdkNativeWindow aWindow ) { -#if !GTK_CHECK_VERSION(3,0,0) - ::Window aRoot, aParent; - ::Window* pChildren; - unsigned int nChildren; - bool bBreak = false; - do - { - pChildren = nullptr; - nChildren = 0; - aParent = aRoot = None; - XQueryTree( getDisplay()->GetDisplay(), aWindow, - &aRoot, &aParent, &pChildren, &nChildren ); - XFree( pChildren ); - if( aParent != aRoot ) - aWindow = aParent; - int nCount = 0; - Atom* pProps = XListProperties( getDisplay()->GetDisplay(), - aWindow, - &nCount ); - for( int i = 0; i < nCount && ! bBreak; ++i ) - bBreak = (pProps[i] == XA_WM_HINTS); - if( pProps ) - XFree( pProps ); - } while( aParent != aRoot && ! bBreak ); - - return aWindow; -#else (void)aWindow; //FIXME: no findToplevelSystemWindow return 0; -#endif } void GtkSalFrame::Init( SystemParentData* pSysData ) @@ -1520,11 +1220,7 @@ void GtkSalFrame::Init( SystemParentData* pSysData ) if( pSysData->nSize > sizeof(pSysData->nSize)+sizeof(pSysData->aWindow) && pSysData->bXEmbedSupport ) { -#if GTK_CHECK_VERSION(3,0,0) m_pWindow = gtk_plug_new_for_display( getGdkDisplay(), pSysData->aWindow ); -#else - m_pWindow = gtk_plug_new( pSysData->aWindow ); -#endif m_bWindowIsGtkPlug = true; widget_set_can_default( m_pWindow, true ); widget_set_can_focus( m_pWindow, true ); @@ -1541,54 +1237,14 @@ void GtkSalFrame::Init( SystemParentData* pSysData ) m_pForeignParent = gdk_window_foreign_new_for_display( getGdkDisplay(), m_aForeignParentWindow ); gdk_window_set_events( m_pForeignParent, GDK_STRUCTURE_MASK ); -#if !GTK_CHECK_VERSION(3,0,0) - int x_ret, y_ret; - unsigned int w, h, bw, d; - ::Window aRoot; - XGetGeometry( getDisplay()->GetDisplay(), pSysData->aWindow, - &aRoot, &x_ret, &y_ret, &w, &h, &bw, &d ); - maGeometry.nWidth = w; - maGeometry.nHeight = h; - window_resize(w, h); - gtk_window_move( GTK_WINDOW(m_pWindow), 0, 0 ); - if( ! m_bWindowIsGtkPlug ) - { - XReparentWindow( getDisplay()->GetDisplay(), - widget_get_xid(m_pWindow), - (::Window)pSysData->aWindow, - 0, 0 ); - } -#else //FIXME: Handling embedded windows, is going to be fun ... -#endif } void GtkSalFrame::askForXEmbedFocus( sal_Int32 i_nTimeCode ) { -#if !GTK_CHECK_VERSION(3,0,0) - XEvent aEvent; - - memset( &aEvent, 0, sizeof(aEvent) ); - aEvent.xclient.window = m_aForeignParentWindow; - aEvent.xclient.type = ClientMessage; - aEvent.xclient.message_type = getDisplay()->getWMAdaptor()->getAtom( vcl_sal::WMAdaptor::XEMBED ); - aEvent.xclient.format = 32; - aEvent.xclient.data.l[0] = i_nTimeCode ? i_nTimeCode : CurrentTime; - aEvent.xclient.data.l[1] = 3; // XEMBED_REQUEST_FOCUS - aEvent.xclient.data.l[2] = 0; - aEvent.xclient.data.l[3] = 0; - aEvent.xclient.data.l[4] = 0; - - GetGenericData()->ErrorTrapPush(); - XSendEvent( getDisplay()->GetDisplay(), - m_aForeignParentWindow, - False, NoEventMask, &aEvent ); - GetGenericData()->ErrorTrapPop(); -#else (void) this; // loplugin:staticmethods (void)i_nTimeCode; //FIXME: no askForXEmbedFocus for gtk3 yet -#endif } void GtkSalFrame::SetExtendedFrameStyle( SalExtStyle nStyle ) @@ -1607,7 +1263,6 @@ SalGraphics* GtkSalFrame::AcquireGraphics() if( !m_pGraphics ) { -#if GTK_CHECK_VERSION(3,0,0) m_pGraphics = new GtkSalGraphics( this, m_pWindow ); if( !m_aFrame.get() ) { @@ -1615,9 +1270,6 @@ SalGraphics* GtkSalFrame::AcquireGraphics() TriggerPaintEvent(); } m_pGraphics->setDevice( m_aFrame ); -#else // common case: - m_pGraphics = new GtkSalGraphics( this, m_pWindow, m_nXScreen ); -#endif } m_bGraphics = true; return m_pGraphics; @@ -1735,29 +1387,13 @@ void GtkSalFrame::SetDefaultSize() static void initClientId() { -#if !GTK_CHECK_VERSION(3,0,0) - static bool bOnce = false; - if (!bOnce) - { - bOnce = true; - const OString& rID = SessionManagerClient::getSessionID(); - if (!rID.isEmpty()) - gdk_set_sm_client_id(rID.getStr()); - } -#else // No session management support for gtk3+ - this is now legacy. -#endif } void GtkSalFrame::Show( bool bVisible, bool bNoActivate ) { if( m_pWindow ) { -#if !GTK_CHECK_VERSION(3,0,0) - if( m_pParent && (m_pParent->m_nStyle & SalFrameStyleFlags::PARTIAL_FULLSCREEN) - && getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) - gtk_window_set_keep_above( GTK_WINDOW(m_pWindow), bVisible ); -#endif if( bVisible ) { initClientId(); @@ -1769,12 +1405,6 @@ void GtkSalFrame::Show( bool bVisible, bool bNoActivate ) SetDefaultSize(); setMinMaxSize(); -#if !GTK_CHECK_VERSION(3,0,0) - // #i45160# switch to desktop where a dialog with parent will appear - if( m_pParent && m_pParent->m_nWorkArea != m_nWorkArea && IS_WIDGET_MAPPED(m_pParent->m_pWindow) ) - getDisplay()->getWMAdaptor()->switchToWorkArea( m_pParent->m_nWorkArea ); -#endif - if( isFloatGrabWindow() && m_pParent && m_nFloats == 0 && @@ -1790,39 +1420,6 @@ void GtkSalFrame::Show( bool bVisible, bool bNoActivate ) m_pParent->grabPointer( true, true ); } -#if !GTK_CHECK_VERSION(3,0,0) - guint32 nUserTime = 0; - if( ! bNoActivate && !(m_nStyle & (SalFrameStyleFlags::OWNERDRAWDECORATION|SalFrameStyleFlags::TOOLWINDOW)) ) - nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window); - - //For these floating windows we don't want the main window to lose focus, and metacity has... - // metacity-2.24.0/src/core/window.c - - // if ((focus_window != NULL) && XSERVER_TIME_IS_BEFORE (compare, focus_window->net_wm_user_time)) - // "compare" window focus prevented by other activity - - // where "compare" is this window - - // which leads to... - - // /* This happens for error dialogs or alerts; these need to remain on - // * top, but it would be confusing to have its ancestor remain - // * focused. - // */ - // if (meta_window_is_ancestor_of_transient (focus_window, window)) - // "The focus window %s is an ancestor of the newly mapped " - // "window %s which isn't being focused. Unfocusing the " - // "ancestor.\n", - - // i.e. having a time < that of the toplevel frame means that the toplevel frame gets unfocused. - // awesome. - if( nUserTime == 0 ) - { - nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window); - } - lcl_set_user_time(GTK_WINDOW(m_pWindow), nUserTime ); -#endif - if( ! bNoActivate && (m_nStyle & SalFrameStyleFlags::TOOLWINDOW) ) m_bSetFocusOnMap = true; @@ -1952,7 +1549,6 @@ void GtkSalFrame::SetMinClientSize( long nWidth, long nHeight ) // share their AllocateFrame ! void GtkSalFrame::AllocateFrame() { -#if GTK_CHECK_VERSION(3,0,0) basegfx::B2IVector aFrameSize( maGeometry.nWidth, maGeometry.nHeight ); if( ! m_aFrame.get() || m_aFrame->getSize() != aFrameSize ) { @@ -1974,7 +1570,6 @@ void GtkSalFrame::AllocateFrame() if( m_pGraphics ) m_pGraphics->setDevice( m_aFrame ); } -#endif } void GtkSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags ) @@ -2059,9 +1654,6 @@ void GtkSalFrame::GetClientSize( long& rWidth, long& rHeight ) void GtkSalFrame::GetWorkArea( Rectangle& rRect ) { -#if !GTK_CHECK_VERSION(3,0,0) - rRect = GetGtkSalData()->GetGtkDisplay()->getWMAdaptor()->getWorkArea( 0 ); -#else GdkScreen *pScreen = gtk_window_get_screen(GTK_WINDOW(m_pWindow)); Rectangle aRetRect; int max = gdk_screen_get_n_monitors (pScreen); @@ -2073,7 +1665,6 @@ void GtkSalFrame::GetWorkArea( Rectangle& rRect ) aRetRect.Union(aMonitorRect); } rRect = aRetRect; -#endif } SalFrame* GtkSalFrame::GetParent() const @@ -2308,20 +1899,14 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, int eType, Rectangle *pSiz gtk_window_move( GTK_WINDOW( m_pWindow ), maGeometry.nX, maGeometry.nY ); -#if !GTK_CHECK_VERSION(3,0,0) - // _NET_WM_STATE_FULLSCREEN (Metacity <-> KWin) - if( ! getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) -#endif - { #if GTK_CHECK_VERSION(3,8,0) - gdk_window_set_fullscreen_mode( widget_get_window(m_pWindow), m_bSpanMonitorsWhenFullscreen - ? GDK_FULLSCREEN_ON_ALL_MONITORS : GDK_FULLSCREEN_ON_CURRENT_MONITOR ); + gdk_window_set_fullscreen_mode( widget_get_window(m_pWindow), m_bSpanMonitorsWhenFullscreen + ? GDK_FULLSCREEN_ON_ALL_MONITORS : GDK_FULLSCREEN_ON_CURRENT_MONITOR ); #endif - if( eType == SET_FULLSCREEN ) - gtk_window_fullscreen( GTK_WINDOW( m_pWindow ) ); - else if( eType == SET_UN_FULLSCREEN ) - gtk_window_unfullscreen( GTK_WINDOW( m_pWindow ) ); - } + if( eType == SET_FULLSCREEN ) + gtk_window_fullscreen( GTK_WINDOW( m_pWindow ) ); + else if( eType == SET_UN_FULLSCREEN ) + gtk_window_unfullscreen( GTK_WINDOW( m_pWindow ) ); if( eType == SET_UN_FULLSCREEN && !(m_nStyle & SalFrameStyleFlags::SIZEABLE) ) @@ -2357,11 +1942,7 @@ void GtkSalFrame::updateWMClass() if (!getDisplay()->IsX11Display()) return; -#if GTK_CHECK_VERSION(3,0,0) display = GDK_DISPLAY_XDISPLAY(getGdkDisplay()); -#else - display = getDisplay()->GetDisplay(); -#endif if( IS_WIDGET_REALIZED( m_pWindow ) ) { @@ -2444,30 +2025,9 @@ void GtkSalFrame::ToTop( sal_uInt16 nFlags ) gtk_window_present( GTK_WINDOW(m_pWindow) ); else { -#if !GTK_CHECK_VERSION(3,0,0) - guint32 nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window); -#else guint32 nUserTime = GDK_CURRENT_TIME; -#endif gdk_window_focus( widget_get_window(m_pWindow), nUserTime ); } -#if !GTK_CHECK_VERSION(3,0,0) - /* need to do an XSetInputFocus here because - * gdk_window_focus will ask a EWMH compliant WM to put the focus - * to our window - which it of course won't since our input hint - * is set to false. - */ - if( (m_nStyle & (SalFrameStyleFlags::OWNERDRAWDECORATION|SalFrameStyleFlags::FLOAT_FOCUSABLE)) ) - { - // sad but true: this can cause an XError, we need to catch that - // to do this we need to synchronize with the XServer - GetGenericData()->ErrorTrapPush(); - XSetInputFocus( getDisplay()->GetDisplay(), widget_get_xid(m_pWindow), RevertToParent, CurrentTime ); - // fdo#46687 - an XSync should not be necessary - but for some reason it is. - XSync( getDisplay()->GetDisplay(), False ); - GetGenericData()->ErrorTrapPop(); - } -#endif } else { @@ -2505,59 +2065,12 @@ void GtkSalFrame::grabPointer( bool bGrab, bool bOwnerEvents ) const int nMask = (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); -#if GTK_CHECK_VERSION(3,0,0) GdkDeviceManager* pDeviceManager = gdk_display_get_device_manager(getGdkDisplay()); GdkDevice* pPointer = gdk_device_manager_get_client_pointer(pDeviceManager); if (bGrab) gdk_device_grab(pPointer, widget_get_window(getMouseEventWidget()), GDK_OWNERSHIP_NONE, bOwnerEvents, (GdkEventMask) nMask, m_pCurrentCursor, GDK_CURRENT_TIME); else gdk_device_ungrab(pPointer, GDK_CURRENT_TIME); -#else - if( bGrab ) - { - bool bUseGdkGrab = true; - const std::list< SalFrame* >& rFrames = getDisplay()->getFrames(); - for( std::list< SalFrame* >::const_iterator it = rFrames.begin(); it != rFrames.end(); ++it ) - { - const GtkSalFrame* pFrame = static_cast< const GtkSalFrame* >(*it); - if( pFrame->m_bWindowIsGtkPlug ) - { - bUseGdkGrab = false; - break; - } - } - if( bUseGdkGrab ) - { - gdk_pointer_grab( widget_get_window( m_pWindow ), bOwnerEvents, - (GdkEventMask) nMask, nullptr, m_pCurrentCursor, - GDK_CURRENT_TIME ); - } - else - { - // FIXME: for some unknown reason gdk_pointer_grab does not - // really produce owner events for GtkPlug windows - // the cause is yet unknown - - // this is of course a bad hack, especially as we cannot - // set the right cursor this way - XGrabPointer( getDisplay()->GetDisplay(), - widget_get_xid( m_pWindow ), - bOwnerEvents, - PointerMotionMask | ButtonPressMask | ButtonReleaseMask, - GrabModeAsync, - GrabModeAsync, - None, - None, - CurrentTime - ); - } - } - else - { - // Two GdkDisplays may be open - gdk_display_pointer_ungrab( getGdkDisplay(), GDK_CURRENT_TIME); - } -#endif } void GtkSalFrame::grabKeyboard( bool bGrab ) @@ -2569,7 +2082,6 @@ void GtkSalFrame::grabKeyboard( bool bGrab ) if (!m_pWindow) return; -#if GTK_CHECK_VERSION(3,0,0) GdkDeviceManager* pDeviceManager = gdk_display_get_device_manager(getGdkDisplay()); GdkDevice* pPointer = gdk_device_manager_get_client_pointer(pDeviceManager); GdkDevice* pKeyboard = gdk_device_get_associated_device(pPointer); @@ -2582,17 +2094,6 @@ void GtkSalFrame::grabKeyboard( bool bGrab ) { gdk_device_ungrab(pKeyboard, GDK_CURRENT_TIME); } -#else - if( bGrab ) - { - gdk_keyboard_grab(widget_get_window(m_pWindow), true, - GDK_CURRENT_TIME); - } - else - { - gdk_keyboard_ungrab(GDK_CURRENT_TIME); - } -#endif } void GtkSalFrame::CaptureMouse( bool bCapture ) @@ -2628,11 +2129,7 @@ void GtkSalFrame::SetPointerPos( long nX, long nY ) void GtkSalFrame::Flush() { -#if GTK_CHECK_VERSION(3,0,0) gdk_display_flush( getGdkDisplay() ); -#else - XFlush (GDK_DISPLAY_XDISPLAY (getGdkDisplay())); -#endif } #ifndef GDK_Open @@ -2733,9 +2230,6 @@ void GtkSalFrame::KeyCodeToGdkKey(const vcl::KeyCode& rKeyCode, OUString GtkSalFrame::GetKeyName( sal_uInt16 nKeyCode ) { -#if !GTK_CHECK_VERSION(3,0,0) - return getDisplay()->GetKeyName( nKeyCode ); -#else guint nGtkKeyCode; GdkModifierType nGtkModifiers; KeyCodeToGdkKey(nKeyCode, &nGtkKeyCode, &nGtkModifiers ); @@ -2744,7 +2238,6 @@ OUString GtkSalFrame::GetKeyName( sal_uInt16 nKeyCode ) OUString aRet(pName, rtl_str_getLength(pName), RTL_TEXTENCODING_UTF8); g_free(pName); return aRet; -#endif } GdkDisplay *GtkSalFrame::getGdkDisplay() @@ -2771,9 +2264,6 @@ SalFrame::SalPointerState GtkSalFrame::GetPointerState() KeyIndicatorState GtkSalFrame::GetIndicatorState() { -#if !GTK_CHECK_VERSION(3,0,0) - return GetGtkSalData()->GetGtkDisplay()->GetIndicatorState(); -#else KeyIndicatorState nState = KeyIndicatorState::NONE; GdkKeymap *pKeyMap = gdk_keymap_get_for_display(getGdkDisplay()); @@ -2788,16 +2278,11 @@ KeyIndicatorState GtkSalFrame::GetIndicatorState() #endif return nState; -#endif } void GtkSalFrame::SimulateKeyPress( sal_uInt16 nKeyCode ) { -#if !GTK_CHECK_VERSION(3,0,0) - GetGtkSalData()->GetGtkDisplay()->SimulateKeyPress(nKeyCode); -#else g_warning ("missing simulate keypress %d", nKeyCode); -#endif } void GtkSalFrame::SetInputContext( SalInputContext* pContext ) @@ -2877,118 +2362,11 @@ void GtkSalFrame::SetParent( SalFrame* pNewParent ) ); } -#if !GTK_CHECK_VERSION(3,0,0) - -void GtkSalFrame::createNewWindow( ::Window aNewParent, bool bXEmbed, SalX11Screen nXScreen ) -{ - bool bWasVisible = m_pWindow && IS_WIDGET_MAPPED(m_pWindow); - if( bWasVisible ) - Show( false ); - - if( (int)nXScreen.getXScreen() >= getDisplay()->GetXScreenCount() ) - nXScreen = m_nXScreen; - - SystemParentData aParentData; - aParentData.nSize = sizeof(SystemParentData); - aParentData.aWindow = aNewParent; - aParentData.bXEmbedSupport = bXEmbed; - if( aNewParent == None ) - { - aParentData.aWindow = None; - aParentData.bXEmbedSupport = false; - } - else - { - // is new parent a root window ? - Display* pDisp = getDisplay()->GetDisplay(); - int nScreens = getDisplay()->GetXScreenCount(); - for( int i = 0; i < nScreens; i++ ) - { - if( aNewParent == RootWindow( pDisp, i ) ) - { - nXScreen = SalX11Screen( i ); - aParentData.aWindow = None; - aParentData.bXEmbedSupport = false; - break; - } - } - } - - // free xrender resources - if( m_pGraphics ) - m_pGraphics->SetDrawable( None, m_nXScreen ); - - // first deinit frame - if( m_pIMHandler ) - { - delete m_pIMHandler; - m_pIMHandler = nullptr; - } - if( m_pRegion ) - { - gdk_region_destroy( m_pRegion ); - } - - GtkWidget *pEventWidget = getMouseEventWidget(); - for (auto handler_id : m_aMouseSignalIds) - g_signal_handler_disconnect(G_OBJECT(pEventWidget), handler_id); - if( m_pFixedContainer ) - gtk_widget_destroy( GTK_WIDGET(m_pFixedContainer) ); - if( m_pEventBox ) - gtk_widget_destroy( GTK_WIDGET(m_pEventBox) ); - if( m_pWindow ) - gtk_widget_destroy( m_pWindow ); - if( m_pForeignParent ) - g_object_unref( G_OBJECT( m_pForeignParent ) ); - if( m_pForeignTopLevel ) - g_object_unref( G_OBJECT( m_pForeignTopLevel ) ); - - // init new window - m_bDefaultPos = m_bDefaultSize = false; - if( aParentData.aWindow != None ) - { - m_nStyle |= SalFrameStyleFlags::PLUG; - Init( &aParentData ); - } - else - { - m_nStyle &= ~SalFrameStyleFlags::PLUG; - Init( (m_pParent && m_pParent->m_nXScreen == m_nXScreen) ? m_pParent : nullptr, m_nStyle ); - } - - // update graphics - if( m_pGraphics ) - { - m_pGraphics->SetDrawable( widget_get_xid(m_pWindow), m_nXScreen ); - m_pGraphics->SetWindow( m_pWindow ); - } - - if( ! m_aTitle.isEmpty() ) - SetTitle( m_aTitle ); - - if( bWasVisible ) - Show( true ); - - std::list< GtkSalFrame* > aChildren = m_aChildren; - m_aChildren.clear(); - for( std::list< GtkSalFrame* >::iterator it = aChildren.begin(); it != aChildren.end(); ++it ) - (*it)->createNewWindow( None, false, m_nXScreen ); - - // FIXME: SalObjects -} -#endif - bool GtkSalFrame::SetPluginParent( SystemParentData* pSysParent ) { -#if !GTK_CHECK_VERSION(3,0,0) - GetGenericData()->ErrorTrapPush(); // permanantly ignore unruly children's errors - createNewWindow( pSysParent->aWindow, (pSysParent->nSize > sizeof(long)) && pSysParent->bXEmbedSupport, m_nXScreen ); - return true; -#else (void)pSysParent; //FIXME: no SetPluginParent impl. for gtk3 return false; -#endif } void GtkSalFrame::ResetClipRegion() @@ -2999,15 +2377,9 @@ void GtkSalFrame::ResetClipRegion() void GtkSalFrame::BeginSetClipRegion( sal_uLong ) { -#if GTK_CHECK_VERSION(3,0,0) if( m_pRegion ) cairo_region_destroy( m_pRegion ); m_pRegion = cairo_region_create(); -#else - if( m_pRegion ) - gdk_region_destroy( m_pRegion ); - m_pRegion = gdk_region_new(); -#endif } void GtkSalFrame::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) @@ -3019,11 +2391,7 @@ void GtkSalFrame::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) aRect.y = nY; aRect.width = nWidth; aRect.height = nHeight; -#if GTK_CHECK_VERSION(3,0,0) cairo_region_union_rectangle( m_pRegion, &aRect ); -#else - gdk_region_union_with_rect( m_pRegion, &aRect ); -#endif } } @@ -3033,83 +2401,6 @@ void GtkSalFrame::EndSetClipRegion() gdk_window_shape_combine_region( widget_get_window(m_pWindow), m_pRegion, 0, 0 ); } -#if !GTK_CHECK_VERSION(3,0,0) -bool GtkSalFrame::Dispatch( const XEvent* pEvent ) -{ - bool bContinueDispatch = true; - - if( pEvent->type == PropertyNotify ) - { - vcl_sal::WMAdaptor* pAdaptor = getDisplay()->getWMAdaptor(); - Atom nDesktopAtom = pAdaptor->getAtom( vcl_sal::WMAdaptor::NET_WM_DESKTOP ); - if( pEvent->xproperty.atom == nDesktopAtom && - pEvent->xproperty.state == PropertyNewValue ) - { - m_nWorkArea = pAdaptor->getWindowWorkArea( widget_get_xid(m_pWindow) ); - } - } - else if( pEvent->type == ConfigureNotify ) - { - if( m_pForeignParent && pEvent->xconfigure.window == m_aForeignParentWindow ) - { - bContinueDispatch = false; - gtk_window_resize( GTK_WINDOW(m_pWindow), pEvent->xconfigure.width, pEvent->xconfigure.height ); - if( ( sal::static_int_cast< int >(maGeometry.nWidth) != - pEvent->xconfigure.width ) || - ( sal::static_int_cast< int >(maGeometry.nHeight) != - pEvent->xconfigure.height ) ) - { - maGeometry.nWidth = pEvent->xconfigure.width; - maGeometry.nHeight = pEvent->xconfigure.height; - setMinMaxSize(); - getDisplay()->SendInternalEvent( this, nullptr, SALEVENT_RESIZE ); - } - } - else if( m_pForeignTopLevel && pEvent->xconfigure.window == m_aForeignTopLevelWindow ) - { - bContinueDispatch = false; - // update position - int x = 0, y = 0; - ::Window aChild; - XTranslateCoordinates( getDisplay()->GetDisplay(), - widget_get_xid(m_pWindow), - getDisplay()->GetRootWindow( getDisplay()->GetDefaultXScreen() ), - 0, 0, - &x, &y, - &aChild ); - if( x != maGeometry.nX || y != maGeometry.nY ) - { - maGeometry.nX = x; - maGeometry.nY = y; - getDisplay()->SendInternalEvent( this, nullptr, SALEVENT_MOVE ); - } - } - } - else if( pEvent->type == ClientMessage && - pEvent->xclient.message_type == getDisplay()->getWMAdaptor()->getAtom( vcl_sal::WMAdaptor::XEMBED ) && - pEvent->xclient.window == widget_get_xid(m_pWindow) && - m_bWindowIsGtkPlug - ) - { - // FIXME: this should not be necessary, GtkPlug should do this - // transparently for us - if( pEvent->xclient.data.l[1] == 1 || // XEMBED_WINDOW_ACTIVATE - pEvent->xclient.data.l[1] == 2 // XEMBED_WINDOW_DEACTIVATE - ) - { - GdkEventFocus aEvent; - aEvent.type = GDK_FOCUS_CHANGE; - aEvent.window = widget_get_window( m_pWindow ); - aEvent.send_event = gint8(TRUE); - aEvent.in = gint16(pEvent->xclient.data.l[1] == 1); - signalFocus( m_pWindow, &aEvent, this ); - } - } - - return bContinueDispatch; -} -#endif - gboolean GtkSalFrame::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer frame ) { GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame); @@ -3206,11 +2497,9 @@ gboolean GtkSalFrame::signalScroll( GtkWidget*, GdkEvent* pEvent, gpointer frame GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame); GdkEventScroll* pSEvent = reinterpret_cast<GdkEventScroll*>(pEvent); -#if GTK_CHECK_VERSION(3,0,0) //TODO: do something less feeble here if (pSEvent->direction == GDK_SCROLL_SMOOTH) return true; -#endif static sal_uLong nLines = 0; if( ! nLines ) @@ -3340,8 +2629,6 @@ gboolean GtkSalFrame::signalCrossing( GtkWidget*, GdkEventCrossing* pEvent, gpoi return true; } -#if GTK_CHECK_VERSION(3,0,0) - cairo_t* GtkSalFrame::getCairoContext() const { cairo_t* cr = SvpSalGraphics::createCairoContext(m_aFrame); @@ -3482,101 +2769,6 @@ gboolean GtkSalFrame::signalConfigure(GtkWidget*, GdkEventConfigure* pEvent, gpo return false; } -#else -gboolean GtkSalFrame::signalExpose( GtkWidget*, GdkEventExpose* pEvent, gpointer frame ) -{ - GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame); - pThis->m_bPaintsBlocked = false; - - struct SalPaintEvent aEvent( pEvent->area.x, pEvent->area.y, pEvent->area.width, pEvent->area.height ); - - pThis->CallCallback( SALEVENT_PAINT, &aEvent ); - - return false; -} - -gboolean GtkSalFrame::signalConfigure( GtkWidget*, GdkEventConfigure* pEvent, gpointer frame ) -{ - GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame); - pThis->m_bPaintsBlocked = false; - - bool bMoved = false, bSized = false; - int x = pEvent->x, y = pEvent->y; - - /* HACK: during sizing/moving a toolbar pThis->maGeometry is actually - * already exact; even worse: due to the asynchronicity of configure - * events the borderwindow which would evaluate this event - * would size/move based on wrong data if we would actually evaluate - * this event. So let's swallow it. - */ - if( (pThis->m_nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION) && - GtkSalFrame::getDisplay()->GetCaptureFrame() == pThis ) - return false; - - /* #i31785# claims we cannot trust the x,y members of the event; - * they are e.g. not set correctly on maximize/demaximize; - * yet the gdkdisplay-x11.c code handling configure_events has - * done this XTranslateCoordinates work since the day ~zero. - */ - if( x != pThis->maGeometry.nX || y != pThis->maGeometry.nY ) - { - bMoved = true; - pThis->maGeometry.nX = x; - pThis->maGeometry.nY = y; - } - /* #i86302# - * for non sizeable windows we set the min and max hint for the window manager to - * achieve correct sizing. However this is asynchronous and e.g. on Compiz - * it sometimes happens that the window gets resized to another size (some default) - * if we update the size here, subsequent setMinMaxSize will use this wrong size - * - which is not good since the window manager will now size the window back to this - * wrong size at some point. - */ - if( pThis->m_bFullscreen || (pThis->m_nStyle & (SalFrameStyleFlags::SIZEABLE | SalFrameStyleFlags::PLUG)) == SalFrameStyleFlags::SIZEABLE ) - { - if( pEvent->width != (int)pThis->maGeometry.nWidth || pEvent->height != (int)pThis->maGeometry.nHeight ) - { - bSized = true; - pThis->maGeometry.nWidth = pEvent->width; - pThis->maGeometry.nHeight = pEvent->height; - } - } - - // update decoration hints - if( ! (pThis->m_nStyle & SalFrameStyleFlags::PLUG) ) - { - GdkRectangle aRect; - gdk_window_get_frame_extents( widget_get_window(GTK_WIDGET(pThis->m_pWindow)), &aRect ); - pThis->maGeometry.nTopDecoration = y - aRect.y; - pThis->maGeometry.nBottomDecoration = aRect.y + aRect.height - y - pEvent->height; - pThis->maGeometry.nLeftDecoration = x - aRect.x; - pThis->maGeometry.nRightDecoration = aRect.x + aRect.width - x - pEvent->width; - } - else - { - pThis->maGeometry.nTopDecoration = - pThis->maGeometry.nBottomDecoration = - pThis->maGeometry.nLeftDecoration = - pThis->maGeometry.nRightDecoration = 0; - } - - pThis->updateScreenNumber(); - if( bSized ) - pThis->AllocateFrame(); - - if( bMoved && bSized ) - pThis->CallCallback( SALEVENT_MOVERESIZE, nullptr ); - else if( bMoved ) - pThis->CallCallback( SALEVENT_MOVE, nullptr ); - else if( bSized ) - pThis->CallCallback( SALEVENT_RESIZE, nullptr ); - - if (bSized) - pThis->TriggerPaintEvent(); - return false; -} - -#endif // GTK_CHECK_VERSION(3,0,0) void GtkSalFrame::TriggerPaintEvent() { @@ -3592,12 +2784,10 @@ void GtkSalFrame::TriggerPaintEvent() // //The other alternative was to always paint everything on "draw", but //that duplicates the amount of drawing and is hideously slow -#if GTK_CHECK_VERSION(3,0,0) SAL_INFO("vcl.gtk3", "force painting" << 0 << "," << 0 << " " << maGeometry.nWidth << "x" << maGeometry.nHeight); SalPaintEvent aPaintEvt(0, 0, maGeometry.nWidth, maGeometry.nHeight, true); CallCallback(SALEVENT_PAINT, &aPaintEvt); gtk_widget_queue_draw(GTK_WIDGET(m_pFixedContainer)); -#endif } gboolean GtkSalFrame::signalFocus( GtkWidget*, GdkEventFocus* pEvent, gpointer frame ) @@ -3635,72 +2825,15 @@ gboolean GtkSalFrame::signalFocus( GtkWidget*, GdkEventFocus* pEvent, gpointer f return false; } -#if !GTK_CHECK_VERSION(3,8,0) -static OString getDisplayString() -{ - int nParams = rtl_getAppCommandArgCount(); - OUString aParam; - for( int i = 0; i < nParams; i++ ) - { - rtl_getAppCommandArg( i, &aParam.pData ); - if( i < nParams-1 && (aParam == "-display" || aParam == "--display" ) ) - { - rtl_getAppCommandArg( i+1, &aParam.pData ); - return OUStringToOString( aParam, osl_getThreadTextEncoding() ); - } - } - return OString(); -} -#endif - gboolean GtkSalFrame::signalMap( GtkWidget *pWidget, GdkEvent*, gpointer frame ) { GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame); -#if !GTK_CHECK_VERSION(3,8,0) - //Spawn off a helper program that will attempt to set this fullscreen - //window to span all displays. - if (pThis->m_bFullscreen && pThis->m_bSpanMonitorsWhenFullscreen) - { - GdkWindow* gdkwin = widget_get_window(pThis->m_pWindow); - if (gdkwin) - { - OUString sProgramURL( "$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER "/xid-fullscreen-on-all-monitors"); - rtl::Bootstrap::expandMacros(sProgramURL); - OUString sProgram; - if (osl::FileBase::getSystemPathFromFileURL(sProgramURL, sProgram) == osl::File::E_None) - { - OString sFinalProgram(OUStringToOString(sProgram, osl_getThreadTextEncoding()) - + " " + OString::number((int)GDK_WINDOW_XID(gdkwin))); - OString sDisplay(getDisplayString()); - if (!sDisplay.isEmpty()) - { - sFinalProgram += "--display " + sDisplay; - } - int returnValue = system(sFinalProgram.getStr()); - (void)returnValue; - } - } - } -#endif - bool bSetFocus = pThis->m_bSetFocusOnMap; pThis->m_bSetFocusOnMap = false; -#if !GTK_CHECK_VERSION(3,0,0) - if( bSetFocus ) - { - GetGenericData()->ErrorTrapPush(); - XSetInputFocus( GtkSalFrame::getDisplay()->GetDisplay(), - widget_get_xid(pWidget), - RevertToParent, CurrentTime ); - XSync( GtkSalFrame::getDisplay()->GetDisplay(), False ); - GetGenericData()->ErrorTrapPop(); - } -#else (void)pWidget; (void)bSetFocus; //FIXME: no set input focus ... -#endif pThis->CallCallback( SALEVENT_RESIZE, nullptr ); pThis->TriggerPaintEvent(); @@ -3837,13 +2970,11 @@ gboolean GtkSalFrame::signalDelete( GtkWidget*, GdkEvent*, gpointer frame ) { GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame); -#if GTK_CHECK_VERSION(3,0,0) //If we went into the backdrop we disabled the toplevel window, if we //receive a delete here, re-enable so we can process it bool bBackDrop = (gtk_widget_get_state_flags(GTK_WIDGET(pThis->m_pWindow)) & GTK_STATE_FLAG_BACKDROP); if (bBackDrop) pThis->GetWindow()->Enable(); -#endif pThis->CallCallback( SALEVENT_CLOSE, nullptr ); @@ -3866,29 +2997,6 @@ void GtkSalFrame::signalStyleSet( GtkWidget*, GtkStyle* pPrevious, gpointer fram GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SALEVENT_SETTINGSCHANGED ); GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SALEVENT_FONTCHANGED ); } - -#if !GTK_CHECK_VERSION(3,0,0) - /* #i64117# gtk sets a nice background pixmap - * but we actually don't really want that, so save - * some time on the Xserver as well as prevent - * some paint issues - */ - GdkWindow* pWin = widget_get_window(GTK_WIDGET(pThis->getWindow())); - if( pWin ) - { - ::Window aWin = GDK_WINDOW_XWINDOW(pWin); - if( aWin != None ) - XSetWindowBackgroundPixmap( GtkSalFrame::getDisplay()->GetDisplay(), - aWin, - pThis->m_hBackgroundPixmap ); - } - if( ! pThis->m_pParent ) - { - // signalize theme changed for NWF caches - // FIXME: should be called only once for a style change - GtkSalGraphics::bThemeChanged = true; - } -#endif } gboolean GtkSalFrame::signalWindowState( GtkWidget*, GdkEvent* pEvent, gpointer frame ) commit d320fc09a252cbbbfb7d092352e2de6c124323a7 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Dec 4 10:58:07 2015 +0000 remove gtk3 stuff from gtk2 salframe Reviewed-on: https://gerrit.libreoffice.org/20394 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 8f77810a9cb44fb252a591939f74a5404b41be87) Change-Id: Ica4b64df4cd88dcdbc3483f7b6aa3c9aceb215ec diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx index 424966a..709c04e 100644 --- a/vcl/unx/gtk/gtksalframe.cxx +++ b/vcl/unx/gtk/gtksalframe.cxx @@ -38,9 +38,7 @@ #include <vcl/window.hxx> #include <vcl/settings.hxx> -#if !GTK_CHECK_VERSION(3,0,0) -# include <unx/x11/xlimits.hxx> -#endif +#include <unx/x11/xlimits.hxx> #if defined(ENABLE_DBUS) && defined(ENABLE_GIO) # include <unx/gtk/gtksalmenu.hxx> #endif @@ -82,24 +80,10 @@ #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/util/URLTransformer.hpp> -#if GTK_CHECK_VERSION(3,0,0) -# include <gdk/gdkkeysyms-compat.h> -#endif - #include <config_folders.h> -#if GTK_CHECK_VERSION(3,0,0) #define IS_WIDGET_REALIZED gtk_widget_get_realized #define IS_WIDGET_MAPPED gtk_widget_get_mapped -#else -#define IS_WIDGET_REALIZED GTK_WIDGET_REALIZED -#define IS_WIDGET_MAPPED GTK_WIDGET_MAPPED -#endif - -#ifndef GDK_IS_X11_DISPLAY -#define GDK_IS_X11_DISPLAY(foo) (true) -#endif - using namespace com::sun::star; @@ -152,23 +136,19 @@ static sal_uInt16 GetKeyCode( guint keyval ) nCode = KEY_A + (keyval-GDK_a ); else if( keyval >= GDK_F1 && keyval <= GDK_F26 ) { -#if !GTK_CHECK_VERSION(3,0,0) if( GetGtkSalData()->GetGtkDisplay()->IsNumLockFromXS() ) { nCode = KEY_F1 + (keyval-GDK_F1); } else -#endif { switch( keyval ) { // - - - - - Sun keyboard, see vcl/unx/source/app/saldisp.cxx case GDK_L2: -#if !GTK_CHECK_VERSION(3,0,0) if( GetGtkSalData()->GetGtkDisplay()->GetServerVendor() == vendor_sun ) nCode = KEY_REPEAT; else -#endif nCode = KEY_F12; break; case GDK_L3: nCode = KEY_PROPERTIES; break; @@ -359,29 +339,6 @@ GetAlternateKeyCode( const sal_uInt16 nKeyCode ) return aAlternate; } -#if GTK_CHECK_VERSION(3,0,0) - -namespace { -/// Decouple SalFrame lifetime from damagetracker lifetime -struct DamageTracker : public basebmp::IBitmapDeviceDamageTracker -{ - DamageTracker(GtkSalFrame& rFrame) : m_rFrame(rFrame) - {} - - virtual ~DamageTracker() {} - - virtual void damaged(const basegfx::B2IBox& rDamageRect) const override - { - m_rFrame.damaged(rDamageRect); - } - - GtkSalFrame& m_rFrame; -}; -} - -static bool dumpframes = false; -#endif - void GtkSalFrame::doKeyCallback( guint state, guint keyval, guint16 hardware_keycode, @@ -400,30 +357,6 @@ void GtkSalFrame::doKeyCallback( guint state, vcl::DeletionListener aDel( this ); -#if GTK_CHECK_VERSION(3,0,0) -#if 0 - // shift-zero forces a re-draw and event is swallowed - if (keyval == GDK_0) - { - fprintf( stderr, "force widget_queue_draw\n"); - gtk_widget_queue_draw(GTK_WIDGET(m_pFixedContainer)); - return; - } - else if (keyval == GDK_1) - { - fprintf( stderr, "force repaint all\n"); - TriggerPaintEvent(); - return; - } - else if (keyval == GDK_2) - { - dumpframes = !dumpframes; - fprintf(stderr, "toggle dump frames to %d\n", dumpframes); - return; - } -#endif -#endif - /* * #i42122# translate all keys with Ctrl and/or Alt to group 0 else * shortcuts (e.g. Ctrl-o) will not work but be inserted by the @@ -526,7 +459,6 @@ gdk_x11_window_set_utf8_property (GdkWindow *window, const gchar *name, const gchar *value) { -#if !GTK_CHECK_VERSION(3,0,0) GdkDisplay* display = gdk_window_get_display (window); if (value != nullptr) @@ -543,7 +475,6 @@ gdk_x11_window_set_utf8_property (GdkWindow *window, GDK_WINDOW_XID (window), gdk_x11_get_xatom_by_name_for_display (display, name)); } -#endif } // AppMenu watch functions. @@ -842,10 +773,8 @@ void GtkSalFrame::InvalidateGraphics() { if( m_pGraphics ) { -#if !GTK_CHECK_VERSION(3,0,0) m_pGraphics->SetDrawable( None, m_nXScreen ); m_pGraphics->SetWindow(nullptr); -#endif m_bGraphics = false; } } @@ -861,14 +790,9 @@ GtkSalFrame::~GtkSalFrame() if( m_pRegion ) { -#if GTK_CHECK_VERSION(3,0,0) - cairo_region_destroy( m_pRegion ); -#else gdk_region_destroy( m_pRegion ); -#endif } -#if !GTK_CHECK_VERSION(3,0,0) if( m_hBackgroundPixmap ) { XSetWindowBackgroundPixmap( getDisplay()->GetDisplay(), @@ -876,7 +800,6 @@ GtkSalFrame::~GtkSalFrame() None ); XFreePixmap( getDisplay()->GetDisplay(), m_hBackgroundPixmap ); } -#endif delete m_pIMHandler; @@ -941,12 +864,10 @@ void GtkSalFrame::widget_set_size_request(long nWidth, long nHeight) { gint nOrigwidth, nOrigheight; gtk_window_get_size(GTK_WINDOW(m_pWindow), &nOrigwidth, &nOrigheight); -#if !GTK_CHECK_VERSION(3,0,0) if (nWidth > nOrigwidth || nHeight > nOrigheight) { m_bPaintsBlocked = true; } -#endif gtk_widget_set_size_request(m_pWindow, nWidth, nHeight ); } @@ -954,12 +875,10 @@ void GtkSalFrame::window_resize(long nWidth, long nHeight) { gint nOrigwidth, nOrigheight; gtk_window_get_size(GTK_WINDOW(m_pWindow), &nOrigwidth, &nOrigheight); -#if !GTK_CHECK_VERSION(3,0,0) if (nWidth > nOrigwidth || nHeight > nOrigheight) { m_bPaintsBlocked = true; } -#endif gtk_window_resize(GTK_WINDOW(m_pWindow), nWidth, nHeight); } @@ -973,17 +892,6 @@ void GtkSalFrame::resizeWindow( long nWidth, long nHeight ) window_resize(nWidth, nHeight); } -#if GTK_CHECK_VERSION(3,2,0) - -static void -ooo_fixed_class_init(GtkFixedClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - widget_class->get_accessible = ooo_fixed_get_accessible; -} - -#endif - /* * Always use a sub-class of GtkFixed we can tag for a11y. This allows us to * utilize GAIL for the toplevel window and toolkit implementation incl. @@ -1001,11 +909,7 @@ ooo_fixed_get_type() sizeof (GtkFixedClass), nullptr, /* base init */ nullptr, /* base finalize */ -#if GTK_CHECK_VERSION(3,2,0) - reinterpret_cast<GClassInitFunc>(ooo_fixed_class_init), /* class init */ -#else nullptr, /* class init */ -#endif nullptr, /* class finalize */ nullptr, /* class data */ sizeof (GtkFixed), /* instance size */ @@ -1032,40 +936,21 @@ void GtkSalFrame::updateScreenNumber() GtkWidget *GtkSalFrame::getMouseEventWidget() const { -#if GTK_CHECK_VERSION(3,0,0) - return GTK_WIDGET(m_pEventBox); -#else return m_pWindow; -#endif } void GtkSalFrame::InitCommon() { -#if GTK_CHECK_VERSION(3,0,0) - m_pEventBox = GTK_EVENT_BOX(gtk_event_box_new()); - gtk_widget_add_events( GTK_WIDGET(m_pEventBox), - GDK_ALL_EVENTS_MASK ); - gtk_container_add( GTK_CONTAINER(m_pWindow), GTK_WIDGET(m_pEventBox) ); - - // add the fixed container child, - // fixed is needed since we have to position plugin windows - m_pFixedContainer = GTK_FIXED(g_object_new( ooo_fixed_get_type(), nullptr )); - gtk_container_add( GTK_CONTAINER(m_pEventBox), GTK_WIDGET(m_pFixedContainer) ); -#else m_pEventBox = nullptr; // add the fixed container child, // fixed is needed since we have to position plugin windows m_pFixedContainer = GTK_FIXED(g_object_new( ooo_fixed_get_type(), nullptr )); gtk_container_add( GTK_CONTAINER(m_pWindow), GTK_WIDGET(m_pFixedContainer) ); -#endif GtkWidget *pEventWidget = getMouseEventWidget(); gtk_widget_set_app_paintable(GTK_WIDGET(m_pFixedContainer), true); - /*non-X11 displays won't show anything at all without double-buffering - enabled*/ - if (GDK_IS_X11_DISPLAY(getGdkDisplay())) - gtk_widget_set_double_buffered(GTK_WIDGET(m_pFixedContainer), false); + gtk_widget_set_double_buffered(GTK_WIDGET(m_pFixedContainer), false); gtk_widget_set_redraw_on_allocate(GTK_WIDGET(m_pFixedContainer), false); @@ -1074,25 +959,7 @@ void GtkSalFrame::InitCommon() m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "button-press-event", G_CALLBACK(signalButton), this )); m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "motion-notify-event", G_CALLBACK(signalMotion), this )); m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "button-release-event", G_CALLBACK(signalButton), this )); -#if GTK_CHECK_VERSION(3,0,0) - g_signal_connect( G_OBJECT(m_pFixedContainer), "draw", G_CALLBACK(signalDraw), this ); - g_signal_connect( G_OBJECT(m_pWindow), "size-allocate", G_CALLBACK(sizeAllocated), this ); -#if GTK_CHECK_VERSION(3,14,0) - GtkGesture *pSwipe = gtk_gesture_swipe_new(pEventWidget); - g_signal_connect(pSwipe, "swipe", G_CALLBACK(gestureSwipe), this); - gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER (pSwipe), GTK_PHASE_TARGET); - g_object_weak_ref(G_OBJECT(pEventWidget), reinterpret_cast<GWeakNotify>(g_object_unref), pSwipe); - - GtkGesture *pLongPress = gtk_gesture_long_press_new(pEventWidget); - g_signal_connect(pLongPress, "pressed", G_CALLBACK(gestureLongPress), this); - gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER (pLongPress), GTK_PHASE_TARGET); - g_object_weak_ref(G_OBJECT(pEventWidget), reinterpret_cast<GWeakNotify>(g_object_unref), pLongPress); - -#endif - -#else g_signal_connect( G_OBJECT(m_pFixedContainer), "expose-event", G_CALLBACK(signalExpose), this ); -#endif g_signal_connect( G_OBJECT(m_pWindow), "focus-in-event", G_CALLBACK(signalFocus), this ); g_signal_connect( G_OBJECT(m_pWindow), "focus-out-event", G_CALLBACK(signalFocus), this ); g_signal_connect( G_OBJECT(m_pWindow), "map-event", G_CALLBACK(signalMap), this ); @@ -1137,18 +1004,13 @@ void GtkSalFrame::InitCommon() ); // show the widgets -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_show_all( GTK_WIDGET(m_pEventBox) ); -#else gtk_widget_show_all( GTK_WIDGET(m_pFixedContainer) ); -#endif // realize the window, we need an XWindow id gtk_widget_realize( m_pWindow ); //system data m_aSystemData.nSize = sizeof( SystemEnvData ); -#if !GTK_CHECK_VERSION(3,0,0) GtkSalDisplay* pDisp = GetGtkSalData()->GetGtkDisplay(); m_aSystemData.pDisplay = pDisp->GetDisplay(); m_aSystemData.pVisual = pDisp->GetVisual( m_nXScreen ).GetVisual(); @@ -1156,12 +1018,6 @@ void GtkSalFrame::InitCommon() m_aSystemData.aColormap = pDisp->GetColormap( m_nXScreen ).GetXColormap(); m_aSystemData.aWindow = widget_get_xid(m_pWindow); m_aSystemData.aShellWindow = m_aSystemData.aWindow; -#else - static int nWindow = 0; - m_aSystemData.aWindow = nWindow; - m_aSystemData.aShellWindow = nWindow; - ++nWindow; -#endif m_aSystemData.pSalFrame = this; m_aSystemData.pWidget = m_pWindow; m_aSystemData.nScreen = m_nXScreen.getXScreen(); @@ -1204,7 +1060,6 @@ void GtkSalFrame::InitCommon() SetIcon(1); -#if !GTK_CHECK_VERSION(3,0,0) m_nWorkArea = pDisp->getWMAdaptor()->getCurrentWorkArea(); /* #i64117# gtk sets a nice background pixmap * but we actually don't really want that, so save @@ -1214,7 +1069,6 @@ void GtkSalFrame::InitCommon() XSetWindowBackgroundPixmap( getDisplay()->GetDisplay(), widget_get_xid(m_pWindow), m_hBackgroundPixmap ); -#endif } /* Sadly gtk_window_set_accept_focus exists only since gtk 2.4 @@ -1225,7 +1079,6 @@ void GtkSalFrame::InitCommon() * after realization. */ -#if !GTK_CHECK_VERSION(3,0,0) extern "C" { typedef void(*setAcceptFn)( GtkWindow*, gboolean ); static setAcceptFn p_gtk_window_set_accept_focus = nullptr; @@ -1235,11 +1088,9 @@ extern "C" { static setUserTimeFn p_gdk_x11_window_set_user_time = nullptr; static bool bGetSetUserTimeFn = true; } -#endif static void lcl_set_accept_focus( GtkWindow* pWindow, gboolean bAccept, bool bBeforeRealize ) { -#if !GTK_CHECK_VERSION(3,0,0) if( bGetAcceptFocusFn ) { bGetAcceptFocusFn = false; @@ -1298,13 +1149,8 @@ static void lcl_set_accept_focus( GtkWindow* pWindow, gboolean bAccept, bool bBe XFree( pProtocols ); } } -#else - gtk_window_set_accept_focus(pWindow, bAccept); - (void)bBeforeRealize; -#endif } -#if !GTK_CHECK_VERSION(3,0,0) static void lcl_set_user_time( GtkWindow* i_pWindow, guint32 i_nTime ) { if( bGetSetUserTimeFn ) @@ -1334,7 +1180,6 @@ static void lcl_set_user_time( GtkWindow* i_pWindow, guint32 i_nTime ) } } }; -#endif GtkSalFrame *GtkSalFrame::getFromWindow( GtkWindow *pWindow ) { @@ -1420,14 +1265,12 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle ) { eType = GDK_WINDOW_TYPE_HINT_UTILITY; } -#if !GTK_CHECK_VERSION(3,0,0) if( (nStyle & SalFrameStyleFlags::PARTIAL_FULLSCREEN ) && getDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() ) { eType = GDK_WINDOW_TYPE_HINT_TOOLBAR; gtk_window_set_keep_above( GTK_WINDOW(m_pWindow), true ); } -#endif gtk_window_set_type_hint( GTK_WINDOW(m_pWindow), eType ); gtk_window_set_gravity( GTK_WINDOW(m_pWindow), GDK_GRAVITY_STATIC ); if( m_pParent && ! (m_pParent->m_nStyle & SalFrameStyleFlags::PLUG) ) @@ -1449,14 +1292,12 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle ) ensure_dbus_setup( this ); #endif -#if !GTK_CHECK_VERSION(3,0,0) ... etc. - the rest is truncated
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits