diff options
author | Oliver Bolte <obo@openoffice.org> | 2009-09-08 10:44:42 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2009-09-08 10:44:42 +0000 |
commit | 20e02da5b2d5328b0e31443e19d769ff2aa521f4 (patch) | |
tree | d0aec949b19c5ad35172a1ad85e3226a84265b05 /vcl/unx | |
parent | f4967ff057d7b1534fd0bc71fb8cbb4c6f4f5f0f (diff) |
CWS-TOOLING: integrate CWS vcl104
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx | 32 | ||||
-rw-r--r-- | vcl/unx/kde/salnativewidgets-kde.cxx | 1 | ||||
-rw-r--r-- | vcl/unx/kde4/KDEData.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/kde4/KDESalFrame.cxx | 1 | ||||
-rw-r--r-- | vcl/unx/kde4/KDESalGraphics.cxx | 129 | ||||
-rw-r--r-- | vcl/unx/source/app/sm.cxx | 40 | ||||
-rw-r--r-- | vcl/unx/source/gdi/cdeint.cxx | 1 | ||||
-rw-r--r-- | vcl/unx/source/gdi/salgdi.cxx | 83 | ||||
-rw-r--r-- | vcl/unx/source/plugadapt/salplug.cxx | 4 |
9 files changed, 203 insertions, 90 deletions
diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx index fdaa102c614b..6208d3b859c2 100644 --- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx @@ -3291,12 +3291,38 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) aBackColor = getColor( pMenubarStyle->bg[GTK_STATE_NORMAL] ); aStyleSet.SetMenuBarColor( aBackColor ); aBackColor = getColor( pMenuStyle->bg[GTK_STATE_NORMAL] ); - aTextColor = getColor( pMenuTextStyle->fg[GTK_STATE_NORMAL] ); - if( aBackColor == aTextColor ) - aTextColor = (aBackColor.GetLuminance() < 128) ? Color( COL_WHITE ) : Color( COL_BLACK ); + aTextColor = getColor( pMenuTextStyle->text[GTK_STATE_NORMAL] ); aStyleSet.SetMenuColor( aBackColor ); aStyleSet.SetMenuTextColor( aTextColor ); + aTextColor = getColor( pMenubarStyle->text[GTK_STATE_NORMAL] ); + aStyleSet.SetMenuBarTextColor( aTextColor ); + +#if OSL_DEBUG_LEVEL > 1 + std::fprintf( stderr, "==\n" ); + std::fprintf( stderr, "MenuColor = %x (%d)\n", (int)aStyleSet.GetMenuColor().GetColor(), aStyleSet.GetMenuColor().GetLuminance() ); + std::fprintf( stderr, "MenuTextColor = %x (%d)\n", (int)aStyleSet.GetMenuTextColor().GetColor(), aStyleSet.GetMenuTextColor().GetLuminance() ); + std::fprintf( stderr, "MenuBarColor = %x (%d)\n", (int)aStyleSet.GetMenuBarColor().GetColor(), aStyleSet.GetMenuBarColor().GetLuminance() ); + std::fprintf( stderr, "MenuBarTextColor = %x (%d)\n", (int)aStyleSet.GetMenuBarTextColor().GetColor(), aStyleSet.GetMenuBarTextColor().GetLuminance() ); + std::fprintf( stderr, "LightColor = %x (%d)\n", (int)aStyleSet.GetLightColor().GetColor(), aStyleSet.GetLightColor().GetLuminance() ); + std::fprintf( stderr, "ShadowColor = %x (%d)\n", (int)aStyleSet.GetShadowColor().GetColor(), aStyleSet.GetShadowColor().GetLuminance() ); +#endif + + // Awful hack for menu separators in the Sonar and similar themes. + // If the menu color is not too dark, and the menu text color is lighter, + // make the "light" color lighter than the menu color and the "shadow" + // color darker than it. + if ( aStyleSet.GetMenuColor().GetLuminance() >= 32 && + aStyleSet.GetMenuColor().GetLuminance() <= aStyleSet.GetMenuTextColor().GetLuminance() ) + { + Color temp = aStyleSet.GetMenuColor(); + temp.IncreaseLuminance( 8 ); + aStyleSet.SetLightColor( temp ); + temp = aStyleSet.GetMenuColor(); + temp.DecreaseLuminance( 16 ); + aStyleSet.SetShadowColor( temp ); + } + aHighlightColor = getColor( pMenuItemStyle->bg[ GTK_STATE_SELECTED ] ); aHighlightTextColor = getColor( pMenuTextStyle->fg[ GTK_STATE_PRELIGHT ] ); if( aHighlightColor == aHighlightTextColor ) diff --git a/vcl/unx/kde/salnativewidgets-kde.cxx b/vcl/unx/kde/salnativewidgets-kde.cxx index 24358022d6a1..f5a2b57eb6a2 100644 --- a/vcl/unx/kde/salnativewidgets-kde.cxx +++ b/vcl/unx/kde/salnativewidgets-kde.cxx @@ -1996,6 +1996,7 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings ) } aStyleSettings.SetMenuTextColor( aMenuFore ); + aStyleSettings.SetMenuBarTextColor( aMenuFore ); aStyleSettings.SetMenuColor( aMenuBack ); aStyleSettings.SetMenuBarColor( aMenuBack ); diff --git a/vcl/unx/kde4/KDEData.cxx b/vcl/unx/kde4/KDEData.cxx index 07a10c60d933..91e3a758da3c 100644 --- a/vcl/unx/kde4/KDEData.cxx +++ b/vcl/unx/kde4/KDEData.cxx @@ -45,6 +45,8 @@ void KDEData::initNWF() // draw toolbars on separate lines pSVData->maNWFData.mbDockingAreaSeparateTB = true; + // no borders for menu, theming does that + pSVData->maNWFData.mbFlatMenu = true; } void KDEData::deInitNWF() diff --git a/vcl/unx/kde4/KDESalFrame.cxx b/vcl/unx/kde4/KDESalFrame.cxx index ad8f467ee960..796350a63d50 100644 --- a/vcl/unx/kde4/KDESalFrame.cxx +++ b/vcl/unx/kde4/KDESalFrame.cxx @@ -318,6 +318,7 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings ) aMenuBack = toColor( qMenuCG.color( QPalette::Button ) ); style.SetMenuTextColor( aMenuFore ); + style.SetMenuBarTextColor( aMenuFore ); style.SetMenuColor( aMenuBack ); style.SetMenuBarColor( aMenuBack ); diff --git a/vcl/unx/kde4/KDESalGraphics.cxx b/vcl/unx/kde4/KDESalGraphics.cxx index ae917f252b11..2e8f0dcad96b 100644 --- a/vcl/unx/kde4/KDESalGraphics.cxx +++ b/vcl/unx/kde4/KDESalGraphics.cxx @@ -35,6 +35,8 @@ #include <QStyle> #include <QStyleOption> #include <QPainter> +#include <QFrame> +#include <QLabel> #include <kapplication.h> @@ -42,10 +44,9 @@ #include "KDESalGraphics.hxx" -#include <vcl/settings.hxx> -#include <rtl/ustrbuf.hxx> - -#include <stdio.h> +#include "vcl/settings.hxx" +#include "vcl/decoview.hxx" +#include "rtl/ustrbuf.hxx" using namespace ::rtl; @@ -150,6 +151,30 @@ BOOL KDESalGraphics::hitTestNativeControl( ControlType, ControlPart, return FALSE; } +void lcl_drawFrame( QRect& i_rRect, QPainter& i_rPainter, QStyle::PrimitiveElement i_nElement, + ControlState i_nState, const ImplControlValue& i_rValue ) +{ + #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) ) + QStyleOptionFrameV3 styleOption; + styleOption.frameShape = QFrame::StyledPanel; + #else + QStyleOptionFrame styleOption; + QFrame aFrame( NULL ); + aFrame.setFrameRect( QRect(0, 0, i_rRect.width(), i_rRect.height()) ); + aFrame.setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); + aFrame.ensurePolished(); + styleOption.initFrom( &aFrame ); + styleOption.lineWidth = aFrame.lineWidth(); + styleOption.midLineWidth = aFrame.midLineWidth(); + #endif + styleOption.rect = QRect(0, 0, i_rRect.width(), i_rRect.height()); + styleOption.state = vclStateValue2StateFlag( i_nState, i_rValue ); + #if ( QT_VERSION < QT_VERSION_CHECK( 4, 5, 0 ) ) + styleOption.state |= QStyle::State_Sunken; + #endif + kapp->style()->drawPrimitive(i_nElement, &styleOption, &i_rPainter); +} + BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, const Region& rControlRegion, ControlState nControlState, const ImplControlValue& value, SalControlHandle&, @@ -352,18 +377,25 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, } else if (type == CTRL_LISTBOX) { - QStyleOptionComboBox styleOption; - - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - - if (part == PART_SUB_EDIT) + if( part == PART_WINDOW ) { - kapp->style()->drawControl(QStyle::CE_ComboBoxLabel, &styleOption, &painter); + lcl_drawFrame( widgetRect, painter, QStyle::PE_Frame, nControlState, value ); } else { - kapp->style()->drawComplexControl(QStyle::CC_ComboBox, &styleOption, &painter); + QStyleOptionComboBox styleOption; + + styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); + styleOption.state = vclStateValue2StateFlag( nControlState, value ); + + if (part == PART_SUB_EDIT) + { + kapp->style()->drawControl(QStyle::CE_ComboBoxLabel, &styleOption, &painter); + } + else + { + kapp->style()->drawComplexControl(QStyle::CC_ComboBox, &styleOption, &painter); + } } } else if (type == CTRL_LISTNODE) @@ -481,33 +513,11 @@ BOOL KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, } else if (type == CTRL_FRAME) { - #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) ) - QStyleOptionFrameV3 styleOption; - #else - QStyleOptionFrameV2 styleOption; - #endif - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) ) - styleOption.frameShape = QFrame::StyledPanel; - #endif - - kapp->style()->drawPrimitive(QStyle::PE_FrameWindow, &styleOption, &painter); + lcl_drawFrame( widgetRect, painter, QStyle::PE_Frame, nControlState, value ); } else if (type == CTRL_FIXEDBORDER) { - #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) ) - QStyleOptionFrameV3 styleOption; - #else - QStyleOptionFrameV2 styleOption; - #endif - styleOption.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); - styleOption.state = vclStateValue2StateFlag( nControlState, value ); - #if ( QT_VERSION >= QT_VERSION_CHECK( 4, 5, 0 ) ) - styleOption.frameShape = QFrame::StyledPanel; - #endif - - kapp->style()->drawPrimitive(QStyle::PE_FrameWindow, &styleOption, &painter); + lcl_drawFrame( widgetRect, painter, QStyle::PE_FrameWindow, nControlState, value ); } else if (type == CTRL_WINDOW_BACKGROUND) { @@ -573,14 +583,21 @@ BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part, break; case CTRL_EDITBOX: { - styleOption.rect = QRect(0, 0, contentRect.width(), contentRect.height()); - styleOption.state = vclStateValue2StateFlag(controlState, val); - - int size = kapp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) - 1; - - contentRect.adjust( -size, -size, size, size); - boundingRect = contentRect; - + int nFontHeight = kapp->fontMetrics().height(); + //int nFrameSize = kapp->style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + int nLayoutTop = kapp->style()->pixelMetric(QStyle::PM_LayoutTopMargin); + int nLayoutBottom = kapp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin); + int nLayoutLeft = kapp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin); + int nLayoutRight = kapp->style()->pixelMetric(QStyle::PM_LayoutRightMargin); + + int nMinHeight = (nFontHeight + nLayoutTop + nLayoutBottom); + if( boundingRect.height() < nMinHeight ) + { + int delta = nMinHeight - boundingRect.height(); + boundingRect.adjust( 0, 0, 0, delta ); + } + contentRect = boundingRect; + contentRect.adjust( -nLayoutLeft+1, -nLayoutTop+1, nLayoutRight-1, nLayoutBottom-1 ); retVal = true; break; @@ -621,7 +638,6 @@ BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part, case PART_ENTIRE_CONTROL: { int size = kapp->style()->pixelMetric(QStyle::PM_ComboBoxFrameWidth) - 2; - contentRect.adjust(-size,-size,size,size); // find out the minimum size that should be used // assume contents is a text ling @@ -632,6 +648,11 @@ BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part, if( aMinSize.height() > contentRect.height() ) contentRect.adjust( 0, 0, 0, aMinSize.height() - contentRect.height() ); boundingRect = contentRect; + // FIXME: why this difference between comboboxes and listboxes ? + // because a combobox has a sub edit and that is positioned + // inside the outer bordered control ? + if( type == CTRL_COMBOBOX ) + contentRect.adjust(-size,-size,size,size); retVal = true; break; } @@ -647,6 +668,9 @@ BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part, retVal = true; break; + case PART_WINDOW: + retVal = true; + break; } break; } @@ -703,14 +727,19 @@ BOOL KDESalGraphics::getNativeControlRegion( ControlType type, ControlPart part, break; case CTRL_FRAME: { - if (part == PART_BORDER) + if( part == PART_BORDER ) { - int size = kapp->style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - //contentRect.adjust(size, size, size, size); - boundingRect.adjust(-size, -size, size, size); + int size = kapp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin); + USHORT nStyle = val.getNumericVal(); + if( nStyle & FRAME_DRAW_NODRAW ) + { + // in this case the question is: how thick would a frame be + // see brdwin.cxx, decoview.cxx + // most probably the behavior in decoview.cxx is wrong. + contentRect.adjust(size, size, -size, -size); + } retVal = true; } - break; } case CTRL_RADIOBUTTON: diff --git a/vcl/unx/source/app/sm.cxx b/vcl/unx/source/app/sm.cxx index 7e4e16579623..ff981b04259b 100644 --- a/vcl/unx/source/app/sm.cxx +++ b/vcl/unx/source/app/sm.cxx @@ -48,6 +48,7 @@ #include <saldisp.hxx> #include <salframe.h> #include <vcl/svapp.hxx> +#include <vcl/window.hxx> #include <salinst.h> #include <osl/conditn.h> @@ -187,6 +188,7 @@ bool SessionManagerClient::bDocSaveDone = false; static SmProp* pSmProps = NULL; static SmProp** ppSmProps = NULL; static int nSmProps = 0; +static unsigned char *pSmRestartHint = NULL; static void BuildSmPropertyList() @@ -195,7 +197,7 @@ static void BuildSmPropertyList() { ByteString aExec( SessionManagerClient::getExecName(), osl_getThreadTextEncoding() ); - nSmProps = 4; + nSmProps = 5; pSmProps = new SmProp[ nSmProps ]; pSmProps[ 0 ].name = const_cast<char*>(SmCloneCommand); @@ -243,6 +245,15 @@ static void BuildSmPropertyList() pSmProps[ 3 ].vals->value = strdup( aUser.getStr() ); pSmProps[ 3 ].vals->length = strlen( (char *)pSmProps[ 3 ].vals->value )+1; + pSmProps[ 4 ].name = const_cast<char*>(SmRestartStyleHint); + pSmProps[ 4 ].type = const_cast<char*>(SmCARD8); + pSmProps[ 4 ].num_vals = 1; + pSmProps[ 4 ].vals = new SmPropValue; + pSmProps[ 4 ].vals->value = malloc(1); + pSmRestartHint = (unsigned char *)pSmProps[ 4 ].vals->value; + *pSmRestartHint = SmRestartIfRunning; + pSmProps[ 4 ].vals->length = 1; + ppSmProps = new SmProp*[ nSmProps ]; for( int i = 0; i < nSmProps; i++ ) ppSmProps[ i ] = &pSmProps[i]; @@ -257,6 +268,31 @@ bool SessionManagerClient::checkDocumentsSaved() IMPL_STATIC_LINK( SessionManagerClient, SaveYourselfHdl, void*, EMPTYARG ) { SMprintf( "posting save documents event shutdown = %s\n", (pThis!=0) ? "true" : "false" ); + + static bool bFirstShutdown=true; + if (pThis != 0 && bFirstShutdown) //first shutdown request + { + bFirstShutdown = false; + /* + If we have no actual frames open, e.g. we launched a quickstarter, + and then shutdown all our frames leaving just a quickstarter running, + then we don't want to launch an empty toplevel frame on the next + start. (The job of scheduling the restart of the quick-starter is a + task of the quick-starter) + */ + *pSmRestartHint = SmRestartNever; + const std::list< SalFrame* >& rFrames = GetX11SalData()->GetDisplay()->getFrames(); + for( std::list< SalFrame* >::const_iterator it = rFrames.begin(); it != rFrames.end(); ++it ) + { + Window *pWindow = (*it)->GetWindow(); + if (pWindow && pWindow->IsVisible()) + { + *pSmRestartHint = SmRestartIfRunning; + break; + } + } + } + if( pOneInstance ) { SalSessionSaveRequestEvent aEvent( pThis != 0, false ); @@ -385,7 +421,7 @@ void SessionManagerClient::saveDone() ICEConnectionObserver::lock(); SmcSetProperties( aSmcConnection, nSmProps, ppSmProps ); SmcSaveYourselfDone( aSmcConnection, True ); - SMprintf( "sent SaveYourselfDone\n" ); + SMprintf( "sent SaveYourselfDone SmRestartHint of %d\n", *pSmRestartHint ); bDocSaveDone = true; ICEConnectionObserver::unlock(); } diff --git a/vcl/unx/source/gdi/cdeint.cxx b/vcl/unx/source/gdi/cdeint.cxx index 4d2a6dba78ca..3794737b293e 100644 --- a/vcl/unx/source/gdi/cdeint.cxx +++ b/vcl/unx/source/gdi/cdeint.cxx @@ -216,6 +216,7 @@ void CDEIntegrator::GetSystemLook( AllSettings& rSettings ) aStyleSettings.SetDialogTextColor( aDeactive ); aStyleSettings.SetMenuTextColor( aDeactive ); + aStyleSettings.SetMenuBarTextColor( aDeactive ); aStyleSettings.SetButtonTextColor( aDeactive ); aStyleSettings.SetRadioCheckTextColor( aDeactive ); aStyleSettings.SetGroupTextColor( aDeactive ); diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx index 4d3e40840a7b..34f2dfd4b935 100644 --- a/vcl/unx/source/gdi/salgdi.cxx +++ b/vcl/unx/source/gdi/salgdi.cxx @@ -1176,11 +1176,11 @@ typedef std::multiset< int, TrapezoidYCompare > VerticalTrapSet; } // end of anonymous namespace // draw a poly-polygon -bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly, double fTransparency) +bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPolyPoly, double fTransparency) { // nothing to do for empty polypolygons - const int nPolygonCount = rPolyPoly.count(); - if( nPolygonCount <= 0 ) + const int nOrigPolyCount = rOrigPolyPoly.count(); + if( nOrigPolyCount <= 0 ) return TRUE; // nothing to do if everything is transparent @@ -1209,28 +1209,22 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly // don't bother with polygons outside of visible area const basegfx::B2DRange aViewRange( 0, 0, GetGraphicsWidth(), GetGraphicsHeight() ); - const basegfx::B2DRange aPolyRange = basegfx::tools::getRange( rPolyPoly ); + const basegfx::B2DRange aPolyRange = basegfx::tools::getRange( rOrigPolyPoly ); const bool bNeedViewClip = !aPolyRange.isInside( aViewRange ); if( !aPolyRange.overlaps( aViewRange ) ) return true; // convert the polypolygon to trapezoids - // first convert the B2DPolyPolygon to HalfTrapezoids - // #i100922# try to prevent priority-queue reallocations by reservering enough + // prepare the polypolygon for the algorithm below: + // - clip it against the view range + // - make sure it contains no self-intersections + // while we are at it guess the number of involved polygon points int nHTQueueReserve = 0; - for( int nOuterPolyIdx = 0; nOuterPolyIdx < nPolygonCount; ++nOuterPolyIdx ) - { - const ::basegfx::B2DPolygon aOuterPolygon = rPolyPoly.getB2DPolygon( nOuterPolyIdx ); - const int nPointCount = aOuterPolygon.count(); - nHTQueueReserve += aOuterPolygon.areControlPointsUsed() ? 8 * nPointCount : nPointCount; - } - nHTQueueReserve = ((4*nHTQueueReserve) | 0x1FFF) + 1; - HTQueue aHTQueue; - aHTQueue.reserve( nHTQueueReserve ); - for( int nOuterPolyIdx = 0; nOuterPolyIdx < nPolygonCount; ++nOuterPolyIdx ) + basegfx::B2DPolyPolygon aGoodPolyPoly; + for( int nOrigPolyIdx = 0; nOrigPolyIdx < nOrigPolyCount; ++nOrigPolyIdx ) { - const ::basegfx::B2DPolygon aOuterPolygon = rPolyPoly.getB2DPolygon( nOuterPolyIdx ); + const ::basegfx::B2DPolygon aOuterPolygon = rOrigPolyPoly.getB2DPolygon( nOrigPolyIdx ); // render-trapezoids should be inside the view => clip polygon against view range basegfx::B2DPolyPolygon aClippedPolygon( aOuterPolygon ); @@ -1238,33 +1232,55 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly { aClippedPolygon = basegfx::tools::clipPolygonOnRange( aOuterPolygon, aViewRange, true, false ); DBG_ASSERT( aClippedPolygon.count(), "polygon confirmed to overlap with view should not get here" ); - if( !aClippedPolygon.count() ) - continue; } + const int nClippedPolyCount = aClippedPolygon.count(); + if( !nClippedPolyCount ) + continue; - // render-trapezoids have linear edges => get rid of bezier segments - if( aClippedPolygon.areControlPointsUsed() ) - aClippedPolygon = ::basegfx::tools::adaptiveSubdivideByDistance( aClippedPolygon, 0.125 ); - - // test and remove self intersections - // TODO: make code intersection save, then remove this test - basegfx::B2DPolyPolygon aInnerPolyPoly(basegfx::tools::solveCrossovers( aClippedPolygon)); - const int nInnerPolyCount = aInnerPolyPoly.count(); - for( int nInnerPolyIdx = 0; nInnerPolyIdx < nInnerPolyCount; ++nInnerPolyIdx ) + // #i103259# polypoly.solveCrossover() fails to remove self-intersections + // but polygon.solveCrossover() works. Use it to build the intersection-free polypolygon + // TODO: if the self-intersection prevention is too expensive make the trap-algorithm tolerate intersections + for( int nClippedPolyIdx = 0; nClippedPolyIdx < nClippedPolyCount; ++nClippedPolyIdx ) { - ::basegfx::B2DPolygon aInnerPolygon = aInnerPolyPoly.getB2DPolygon( nInnerPolyIdx ); - const int nPointCount = aInnerPolygon.count(); - if( !nPointCount ) - continue; + ::basegfx::B2DPolygon aUnsolvedPolygon = aClippedPolygon.getB2DPolygon( nClippedPolyIdx ); + basegfx::B2DPolyPolygon aSolvedPolyPoly( basegfx::tools::solveCrossovers( aUnsolvedPolygon) ); + const int nSolvedPolyCount = aSolvedPolyPoly.count(); + for( int nSolvedPolyIdx = 0; nSolvedPolyIdx < nSolvedPolyCount; ++nSolvedPolyIdx ) + { + // build the intersection-free polypolygon one by one + const ::basegfx::B2DPolygon aSolvedPolygon = aSolvedPolyPoly.getB2DPolygon( nSolvedPolyIdx ); + aGoodPolyPoly.append( aSolvedPolygon ); + // and while we are at it use the conviently available point count to guess the number of needed half-traps + const int nPointCount = aSolvedPolygon.count(); + nHTQueueReserve += aSolvedPolygon.areControlPointsUsed() ? 8 * nPointCount : nPointCount; + } + } + } + // #i100922# try to prevent priority-queue reallocations by reservering enough + nHTQueueReserve = ((4*nHTQueueReserve) | 0x1FFF) + 1; + HTQueue aHTQueue; + aHTQueue.reserve( nHTQueueReserve ); - aHTQueue.reserve( aHTQueue.size() + 8 * nPointCount ); + // first convert the B2DPolyPolygon to HalfTrapezoids + const int nGoodPolyCount = aGoodPolyPoly.count(); + for( int nGoodPolyIdx = 0; nGoodPolyIdx < nGoodPolyCount; ++nGoodPolyIdx ) + { + ::basegfx::B2DPolygon aInnerPolygon = aGoodPolyPoly.getB2DPolygon( nGoodPolyIdx ); + + // render-trapezoids have linear edges => get rid of bezier segments + if( aInnerPolygon.areControlPointsUsed() ) + aInnerPolygon = ::basegfx::tools::adaptiveSubdivideByDistance( aInnerPolygon, 0.125 ); + const int nPointCount = aInnerPolygon.count(); + if( nPointCount >= 3 ) + { // convert polygon point pairs to HalfTrapezoids // connect the polygon point with the first one if needed XPointFixed aOldXPF = { 0, 0 }; XPointFixed aNewXPF; for( int nPointIdx = 0; nPointIdx <= nPointCount; ++nPointIdx, aOldXPF = aNewXPF ) { + // auto-close the polygon if needed const int k = (nPointIdx < nPointCount) ? nPointIdx : 0; const ::basegfx::B2DPoint& aPoint = aInnerPolygon.getB2DPoint( k ); @@ -1551,3 +1567,4 @@ bool X11SalGraphics::drawPolyLine(const ::basegfx::B2DPolygon& rPolygon, const : } // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + diff --git a/vcl/unx/source/plugadapt/salplug.cxx b/vcl/unx/source/plugadapt/salplug.cxx index 8a1ed05b8e25..48908ec498c5 100644 --- a/vcl/unx/source/plugadapt/salplug.cxx +++ b/vcl/unx/source/plugadapt/salplug.cxx @@ -382,10 +382,10 @@ static const char * get_desktop_environment() if ( is_kde4_desktop( pDisplay ) ) pRet = desktop_strings[DESKTOP_KDE4]; - else if ( is_kde_desktop( pDisplay ) ) - pRet = desktop_strings[DESKTOP_KDE]; else if ( is_gnome_desktop( pDisplay ) ) pRet = desktop_strings[DESKTOP_GNOME]; + else if ( is_kde_desktop( pDisplay ) ) + pRet = desktop_strings[DESKTOP_KDE]; else if ( is_cde_desktop( pDisplay ) ) pRet = desktop_strings[DESKTOP_CDE]; else |