Ignore:
Timestamp:
Aug 20, 2006, 9:50:11 AM (19 years ago)
Author:
bird
Message:

fixed a couple of clipboard issues. seems to work now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/synergy/lib/platform/CPMClipboard.cpp

    r2770 r2774  
    4343
    4444bool
    45 CPMClipboard::emptyUnowned()
     45CPMClipboard::empty()
    4646{
    4747    LOG((CLOG_DEBUG "empty clipboard"));
    48 
    49     // empty the clipboard (and take ownership)
    5048    if (!WinEmptyClipbrd(CPMUtil::getHAB())) {
    51         LOG((CLOG_DEBUG "failed to grab clipboard"));
    52         return false;
    53     }
    54 
    55     return true;
    56 }
    57 
    58 bool
    59 CPMClipboard::empty()
    60 {
    61     if (!emptyUnowned()) {
     49        LOG((CLOG_ERR "failed to empty the clipboard"));
    6250        return false;
    6351    }
     
    7058        return false;
    7159    }
    72     return !!WinSetClipbrdData(CPMUtil::getHAB(), (ULONG)pv, getOwnershipFormat(), CFI_POINTER);
     60    if (!WinSetClipbrdData(CPMUtil::getHAB(), (ULONG)pv, getOwnershipFormat(), CFI_POINTER)) {
     61        LOG((CLOG_ERR "failed to set dummy clipboard data. %#x", WinGetLastError(CPMUtil::getHAB())));
     62        DosFreeMem(pv);
     63        return false;
     64    }
     65    return true;
    7366}
    7467
     
    9285                if (!WinSetClipbrdData(CPMUtil::getHAB(), ulPMData, ulPMFormat, ulPMFormatInfo)) {
    9386                    // free converted data if we couldn't put it on the clipboard
     87                    LOG((CLOG_ERR "failed to set clipboard data ulPMData=%#lx ulPMFormat=%#lx ulPMFormatInfo=%#lx. %#x",
     88                         ulPMData, ulPMFormat, ulPMFormatInfo, WinGetLastError(CPMUtil::getHAB())));
    9489                    converter->freePMData(ulPMData);
    9590                }
     
    108103        return false;
    109104    }
    110 
    111105    m_time = time;
    112 
    113106    return true;
    114107}
     
    118111{
    119112    LOG((CLOG_DEBUG "close clipboard"));
    120     WinCloseClipbrd(CPMUtil::getHAB());
     113    if (!WinCloseClipbrd(CPMUtil::getHAB())) {
     114        LOG((CLOG_WARN "failed to close the clipboard. %#x", WinGetLastError(CPMUtil::getHAB())));
     115    }
    121116}
    122117
     
    130125CPMClipboard::has(EFormat format) const
    131126{
     127    LOG((CLOG_DEBUG "has clipboard format=%d?", format));
    132128    for (ConverterList::const_iterator index = m_converters.begin();
    133129         index != m_converters.end();
    134130         ++index) {
    135131        IPMClipboardConverter* converter = *index;
     132        LOG((CLOG_DEBUG2 "CPMClipboard::has: format=%d convert->getFormat()->%d (pmformat=%d)", format, converter->getFormat(), converter->getPMFormat()));
    136133        if (converter->getFormat() == format) {
    137134            ULONG fFmtInfo;
    138             if (WinQueryClipbrdFmtInfo(CPMUtil::getHAB(), getOwnershipFormat(), &fFmtInfo)) {
     135            if (WinQueryClipbrdFmtInfo(CPMUtil::getHAB(), converter->getPMFormat(), &fFmtInfo)) {
     136                LOG((CLOG_DEBUG "yes, we have format %d!", format));
    139137                return true;
    140138            }
    141139        }
    142140    }
     141    LOG((CLOG_DEBUG "sorry, no we haven't."));
    143142    return false;
    144143}
     
    147146CPMClipboard::get(EFormat format) const
    148147{
     148    LOG((CLOG_DEBUG "get clipboard format=%d?", format));
     149
    149150    // find the converter for the first clipboard format we can handle
    150151    IPMClipboardConverter* converter = NULL;
     
    155156             ++index) {
    156157            converter = *index;
     158            LOG((CLOG_DEBUG2 "CPMClipboard::get: pmFormat=%d format=%d ?=? %d:%d", pmFormat, format, converter->getPMFormat(), converter->getFormat()));
    157159            if (converter->getPMFormat() == pmFormat &&
    158160                converter->getFormat()   == format) {
     
    172174    ULONG ulData = WinQueryClipbrdData(CPMUtil::getHAB(), converter->getPMFormat());
    173175    if (ulData == 0) {
     176        LOG((CLOG_DEBUG "CPMClipboard::get: ulData=%#x\n", ulData));
    174177        return CString();
    175178    }
    176179
    177180    // convert
    178     return converter->toIClipboard(ulData);
     181    CString str = converter->toIClipboard(ulData);
     182    LOG((CLOG_DEBUG2 "CPMClipboard::get: converted ulData=%lx to '%s'\n", ulData, str.c_str()));
     183    return str;
    179184}
    180185
     
    194199{
    195200    ULONG fFmtInfo;
    196     return (!!WinQueryClipbrdFmtInfo(CPMUtil::getHAB(), getOwnershipFormat(), &fFmtInfo));
     201    if (WinQueryClipbrdFmtInfo(CPMUtil::getHAB(), getOwnershipFormat(), &fFmtInfo)) {
     202        LOG((CLOG_DEBUG "isOwnedBySynergy: yes"));
     203        return true;
     204    }
     205    LOG((CLOG_DEBUG "isOwnedBySynergy: no"));
     206    return false;
    197207}
    198208
Note: See TracChangeset for help on using the changeset viewer.