diff options
-rw-r--r-- | i18nutil/source/utility/casefolding.cxx | 9 | ||||
-rw-r--r-- | vcl/inc/vcl/i18nhelp.hxx | 2 | ||||
-rw-r--r-- | vcl/source/app/i18nhelp.cxx | 64 | ||||
-rw-r--r-- | vcl/source/control/ilstbox.cxx | 3 | ||||
-rw-r--r-- | vcl/unx/gtk/window/gtkframe.cxx | 21 | ||||
-rw-r--r-- | vcl/unx/inc/saldisp.hxx | 5 | ||||
-rw-r--r-- | vcl/unx/inc/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/unx/source/app/saldisp.cxx | 45 | ||||
-rw-r--r-- | vcl/unx/source/gdi/salgdi2.cxx | 29 |
9 files changed, 129 insertions, 51 deletions
diff --git a/i18nutil/source/utility/casefolding.cxx b/i18nutil/source/utility/casefolding.cxx index 401a2a5803f7..8a679b8afbe5 100644 --- a/i18nutil/source/utility/casefolding.cxx +++ b/i18nutil/source/utility/casefolding.cxx @@ -131,9 +131,13 @@ is_ja_voice_sound_mark(sal_Unicode& current, sal_Unicode next) sal_Unicode casefolding::getNextChar(const sal_Unicode *str, sal_Int32& idx, sal_Int32 len, MappingElement& e, Locale& aLocale, sal_uInt8 nMappingType, TransliterationModules moduleLoaded) throw (RuntimeException) { + if( idx >= len ) + return 0; + sal_Unicode c; + if (moduleLoaded & TransliterationModules_IGNORE_CASE) { - if (e.current >= e.element.nmap && idx < len ) { + if( e.current >= e.element.nmap ) { e.element = getValue(str, idx++, len, aLocale, nMappingType); e.current = 0; } @@ -141,6 +145,7 @@ sal_Unicode casefolding::getNextChar(const sal_Unicode *str, sal_Int32& idx, sal } else { c = *(str + idx++); } + if (moduleLoaded & TransliterationModules_IGNORE_KANA) { if (0x3040 <= c && c <= 0x3094 || 0x309d <= c && c <= 0x309f) c += 0x60; @@ -154,7 +159,9 @@ sal_Unicode casefolding::getNextChar(const sal_Unicode *str, sal_Int32& idx, sal is_ja_voice_sound_mark(c, half2fullTable[*(str + idx)])) idx++; } + return c; } } } } } + diff --git a/vcl/inc/vcl/i18nhelp.hxx b/vcl/inc/vcl/i18nhelp.hxx index 82f9d74b7ad2..e50ddecaa947 100644 --- a/vcl/inc/vcl/i18nhelp.hxx +++ b/vcl/inc/vcl/i18nhelp.hxx @@ -90,6 +90,8 @@ public: String GetDate( const Date& rDate ) const; String GetNum( long nNumber, USHORT nDecimals, BOOL bUseThousandSep = TRUE, BOOL bTrailingZeros = TRUE ) const; + + static String filterFormattingChars( const String& ); }; } // namespace vcl diff --git a/vcl/source/app/i18nhelp.cxx b/vcl/source/app/i18nhelp.cxx index 5b0d45773512..1622fe3e5bea 100644 --- a/vcl/source/app/i18nhelp.cxx +++ b/vcl/source/app/i18nhelp.cxx @@ -31,25 +31,15 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" +#include "vcl/i18nhelp.hxx" +#include "com/sun/star/lang/XMultiServiceFactory.hpp" +#include "com/sun/star/i18n/TransliterationModules.hpp" +#include "unotools/localedatawrapper.hxx" +#include "unotools/transliterationwrapper.hxx" +#include "i18npool/mslangid.hxx" -#include <vcl/i18nhelp.hxx> - -/* -#include <com/sun/star/lang/XSingleServiceFactory.hpp> - - -#include <comphelper/processfactory.hxx> -*/ - -// #include <cppuhelper/servicefactory.hxx> - - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/i18n/TransliterationModules.hpp> -#include <unotools/localedatawrapper.hxx> -#include <unotools/transliterationwrapper.hxx> -#include <i18npool/mslangid.hxx> +#include "rtl/ustrbuf.hxx" using namespace ::com::sun::star; @@ -104,6 +94,37 @@ const ::com::sun::star::lang::Locale& vcl::I18nHelper::getLocale() const return maLocale; } +inline bool is_formatting_mark( sal_Unicode c ) +{ + if( (c >= 0x200B) && (c <= 0x200F) ) // BiDi and zero-width-markers + return true; + if( (c >= 0x2028) && (c <= 0x202E) ) // BiDi and paragraph-markers + return true; + return false; +} + +/* #i100057# filter formatting marks out of strings before passing them to + the transliteration. The real solution would have been an additional TransliterationModule + to ignore these marks during transliteration; however changin the code in i18npool that actually + implements this could produce unwanted side effects. + + Of course this copying around is not really good, but looking at i18npool, one more time + will not hurt. +*/ +String vcl::I18nHelper::filterFormattingChars( const String& rStr ) +{ + sal_Int32 nUnicodes = rStr.Len(); + rtl::OUStringBuffer aBuf( nUnicodes ); + const sal_Unicode* pStr = rStr.GetBuffer(); + while( nUnicodes-- ) + { + if( ! is_formatting_mark( *pStr ) ) + aBuf.append( *pStr ); + pStr++; + } + return aBuf.makeStringAndClear(); +} + sal_Int32 vcl::I18nHelper::CompareString( const String& rStr1, const String& rStr2 ) const { ::osl::Guard< ::osl::Mutex > aGuard( ((vcl::I18nHelper*)this)->maMutex ); @@ -117,7 +138,10 @@ sal_Int32 vcl::I18nHelper::CompareString( const String& rStr1, const String& rSt ((vcl::I18nHelper*)this)->mpTransliterationWrapper = NULL; } - return ImplGetTransliterationWrapper().compareString( rStr1, rStr2 ); + + String aStr1( filterFormattingChars(rStr1) ); + String aStr2( filterFormattingChars(rStr2) ); + return ImplGetTransliterationWrapper().compareString( aStr1, aStr2 ); } sal_Bool vcl::I18nHelper::MatchString( const String& rStr1, const String& rStr2 ) const @@ -133,7 +157,9 @@ sal_Bool vcl::I18nHelper::MatchString( const String& rStr1, const String& rStr2 ((vcl::I18nHelper*)this)->mpTransliterationWrapper = NULL; } - return ImplGetTransliterationWrapper().isMatch( rStr1, rStr2 ); + String aStr1( filterFormattingChars(rStr1) ); + String aStr2( filterFormattingChars(rStr2) ); + return ImplGetTransliterationWrapper().isMatch( aStr1, aStr2 ); } sal_Bool vcl::I18nHelper::MatchMnemonic( const String& rString, sal_Unicode cMnemonicChar ) const diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index c41a6a710b15..c717e491d7b2 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -275,7 +275,8 @@ USHORT ImplEntryList::FindEntry( const XubString& rString, BOOL bSearchMRUArea ) for ( USHORT n = bSearchMRUArea ? 0 : GetMRUCount(); n < nEntries; n++ ) { ImplEntryType* pImplEntry = GetEntry( n ); - if ( pImplEntry->maStr == rString ) + String aComp( vcl::I18nHelper::filterFormattingChars( pImplEntry->maStr ) ); + if ( aComp == rString ) return n; } return LISTBOX_ENTRY_NOTFOUND; diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx index 8e280675866a..a47b9bf31b01 100644 --- a/vcl/unx/gtk/window/gtkframe.cxx +++ b/vcl/unx/gtk/window/gtkframe.cxx @@ -832,7 +832,11 @@ void GtkSalFrame::Init( SalFrame* pParent, ULONG nStyle ) { guint32 nUserTime = 0; if( (nStyle & (SAL_FRAME_STYLE_OWNERDRAWDECORATION|SAL_FRAME_STYLE_TOOLWINDOW)) == 0 ) - nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window); + { + /* #i99360# ugly workaround an X11 library bug */ + nUserTime= getDisplay()->GetLastUserEventTime( true ); + // nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window); + } lcl_set_user_time(GTK_WIDGET(m_pWindow)->window, nUserTime); } @@ -1297,7 +1301,9 @@ void GtkSalFrame::Show( BOOL bVisible, BOOL bNoActivate ) guint32 nUserTime = 0; if( ! bNoActivate && (m_nStyle & (SAL_FRAME_STYLE_OWNERDRAWDECORATION|SAL_FRAME_STYLE_TOOLWINDOW)) == 0 ) - nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window); + /* #i99360# ugly workaround an X11 library bug */ + nUserTime= getDisplay()->GetLastUserEventTime( true ); + //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 @@ -1327,7 +1333,9 @@ void GtkSalFrame::Show( BOOL bVisible, BOOL bNoActivate ) ) ) { - nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window); + /* #i99360# ugly workaround an X11 library bug */ + nUserTime= getDisplay()->GetLastUserEventTime( true ); + //nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window); } lcl_set_user_time( GTK_WIDGET(m_pWindow)->window, nUserTime ); @@ -2023,7 +2031,12 @@ void GtkSalFrame::ToTop( USHORT nFlags ) if( ! (nFlags & SAL_FRAME_TOTOP_GRABFOCUS_ONLY) ) gtk_window_present( GTK_WINDOW(m_pWindow) ); else - gdk_window_focus( m_pWindow->window, gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window) ); + { + // gdk_window_focus( m_pWindow->window, gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window) ); + /* #i99360# ugly workaround an X11 library bug */ + guint32 nUserTime= getDisplay()->GetLastUserEventTime( true ); + gdk_window_focus( m_pWindow->window, nUserTime ); + } /* 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 diff --git a/vcl/unx/inc/saldisp.hxx b/vcl/unx/inc/saldisp.hxx index 9f9383106615..6e520df97f25 100644 --- a/vcl/unx/inc/saldisp.hxx +++ b/vcl/unx/inc/saldisp.hxx @@ -283,6 +283,7 @@ DECLARE_LIST( SalFontCache, ExtendedFontStruct* ) extern "C" { struct SnDisplay; struct SnLauncheeContext; + typedef Bool(*X_if_predicate)(Display*,XEvent*,XPointer); } class VCL_DLLPUBLIC SalDisplay @@ -494,7 +495,9 @@ public: bool GetExactResolution() const { return mbExactResolution; } ULONG GetProperties() const { return nProperties_; } ULONG GetMaxRequestSize() const { return nMaxRequestSize_; } - XLIB_Time GetLastUserEventTime() const; + XLIB_Time GetLastUserEventTime( bool bAlwaysReget = false ) const; + + bool XIfEventWithTimeout( XEvent*, XPointer, X_if_predicate, long i_nTimeout = 1000 ) const; BOOL MouseCaptured( const SalFrame *pFrameData ) const { return m_pCapture == pFrameData; } diff --git a/vcl/unx/inc/salgdi.h b/vcl/unx/inc/salgdi.h index 0a5028b764eb..55c8f8303052 100644 --- a/vcl/unx/inc/salgdi.h +++ b/vcl/unx/inc/salgdi.h @@ -344,7 +344,7 @@ public: * it is imperative to eat up graphics exposes even in case you don't need * them because the next one using XCopyArea can depend on them */ - static void YieldGraphicsExpose( Display* pDisplay, SalFrame* pFrame, Drawable aDrawable ); + void YieldGraphicsExpose(); // do XCopyArea or XGet/PutImage depending on screen numbers // signature is like XCopyArea with screen numbers added diff --git a/vcl/unx/source/app/saldisp.cxx b/vcl/unx/source/app/saldisp.cxx index 95679d77fdfb..b599cf0895eb 100644 --- a/vcl/unx/source/app/saldisp.cxx +++ b/vcl/unx/source/app/saldisp.cxx @@ -104,6 +104,7 @@ Status XineramaGetInfo(Display*, int, XRectangle*, unsigned char*, int*); #include <dtint.hxx> #include <osl/socket.h> +#include <poll.h> using namespace rtl; using namespace vcl_sal; @@ -520,7 +521,7 @@ SalDisplay::SalDisplay( Display *display ) : m_pWMAdaptor( NULL ), m_pDtIntegrator( NULL ), m_bUseRandRWrapper( true ), - m_nLastUserEventTime( 0 ) + m_nLastUserEventTime( CurrentTime ) { #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "SalDisplay::SalDisplay()\n" ); @@ -2726,9 +2727,9 @@ extern "C" } } -XLIB_Time SalDisplay::GetLastUserEventTime() const +XLIB_Time SalDisplay::GetLastUserEventTime( bool i_bAlwaysReget ) const { - if( m_nLastUserEventTime == 0 ) + if( m_nLastUserEventTime == CurrentTime || i_bAlwaysReget ) { // get current server time unsigned char c = 0; @@ -2736,12 +2737,48 @@ XLIB_Time SalDisplay::GetLastUserEventTime() const Atom nAtom = getWMAdaptor()->getAtom( WMAdaptor::SAL_GETTIMEEVENT ); XChangeProperty( GetDisplay(), GetDrawable( GetDefaultScreenNumber() ), nAtom, nAtom, 8, PropModeReplace, &c, 1 ); - XIfEvent( GetDisplay(), &aEvent, timestamp_predicate, (XPointer)this ); + XFlush( GetDisplay() ); + + if( ! XIfEventWithTimeout( &aEvent, (XPointer)this, timestamp_predicate ) ) + { + // this should not happen at all; still sometimes it happens + aEvent.xproperty.time = CurrentTime; + } + m_nLastUserEventTime = aEvent.xproperty.time; } return m_nLastUserEventTime; } +bool SalDisplay::XIfEventWithTimeout( XEvent* o_pEvent, XPointer i_pPredicateData, + X_if_predicate i_pPredicate, long i_nTimeout ) const +{ + /* #i99360# ugly workaround an X11 library bug + this replaces the following call: + XIfEvent( GetDisplay(), o_pEvent, i_pPredicate, i_pPredicateData ); + */ + bool bRet = true; + + if( ! XCheckIfEvent( GetDisplay(), o_pEvent, i_pPredicate, i_pPredicateData ) ) + { + // wait for some event to arrive + struct pollfd aFD; + aFD.fd = ConnectionNumber(GetDisplay()); + aFD.events = POLLIN; + aFD.revents = 0; + poll( &aFD, 1, i_nTimeout ); + if( ! XCheckIfEvent( GetDisplay(), o_pEvent, i_pPredicate, i_pPredicateData ) ) + { + poll( &aFD, 1, i_nTimeout ); // try once more for a packet of events from the Xserver + if( ! XCheckIfEvent( GetDisplay(), o_pEvent, i_pPredicate, i_pPredicateData ) ) + { + bRet = false; + } + } + } + return bRet; +} + // -=-= SalVisual -=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= SalVisual::SalVisual() diff --git a/vcl/unx/source/gdi/salgdi2.cxx b/vcl/unx/source/gdi/salgdi2.cxx index 7192a417f96c..5a01b7f13d39 100644 --- a/vcl/unx/source/gdi/salgdi2.cxx +++ b/vcl/unx/source/gdi/salgdi2.cxx @@ -419,9 +419,12 @@ extern "C" } -void X11SalGraphics::YieldGraphicsExpose( Display* pDisplay, SalFrame* pFrame, Drawable aWindow ) +void X11SalGraphics::YieldGraphicsExpose() { // get frame if necessary + SalFrame* pFrame = m_pFrame; + Display* pDisplay = GetXDisplay(); + XLIB_Window aWindow = GetDrawable(); if( ! pFrame ) { const std::list< SalFrame* >& rFrames = GetX11SalData()->GetDisplay()->getFrames(); @@ -444,24 +447,10 @@ void X11SalGraphics::YieldGraphicsExpose( Display* pDisplay, SalFrame* pFrame, D do { - if( ! XCheckIfEvent( pDisplay, &aEvent, GraphicsExposePredicate, (XPointer)aWindow ) ) - { - // wait for some event to arrive - struct pollfd aFD; - aFD.fd = ConnectionNumber(pDisplay); - aFD.events = POLLIN; - aFD.revents = 0; - poll( &aFD, 1, 1000 ); - if( ! XCheckIfEvent( pDisplay, &aEvent, GraphicsExposePredicate, (XPointer)aWindow ) ) - { - poll( &aFD, 1, 1000 ); // try once more for a packet of events from the Xserver - if( ! XCheckIfEvent( pDisplay, &aEvent, GraphicsExposePredicate, (XPointer)aWindow ) ) - { - // this should not happen at all; still sometimes it happens - break; - } - } - } + if( ! GetDisplay()->XIfEventWithTimeout( &aEvent, (XPointer)aWindow, GraphicsExposePredicate ) ) + // this should not happen at all; still sometimes it happens + break; + if( aEvent.type == NoExpose ) break; @@ -581,7 +570,7 @@ void X11SalGraphics::copyBits( const SalTwoRect *pPosAry, if( bNeedGraphicsExposures ) { - YieldGraphicsExpose( GetXDisplay(), m_pFrame, GetDrawable() ); + YieldGraphicsExpose(); if( pCopyGC ) XSetGraphicsExposures( GetXDisplay(), |