Changeset 2774 for trunk


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.

Location:
trunk/synergy
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/synergy/Makefile.kmk

    r2764 r2774  
    243243synrgyhk_ASTOOL.os2 = NASM
    244244synrgyhk_ASFLAGS.os2 = -f obj
    245 synrgyhk_CXXFLAGS.os2 = -fno-exceptions 
     245synrgyhk_CXXFLAGS.os2 = -fno-exceptions
    246246synrgyhk_LDFLAGS.os2 = -nostdlib -los2 -v -lend
    247247synrgyhk_SOURCES.nt = \
     
    252252        lib/platform/CPMSynergyHook.def
    253253
     254
     255#
     256# A debugging testcase.
     257#
     258PROGRAMS += syntest
     259syntest_SOURCES = syntest.cpp
     260syntest_LIBS = \
     261        $(TARGET_platform) \
     262        $(TARGET_synergy) \
     263        $(TARGET_net) \
     264        $(TARGET_base) \
     265        $(TARGET_io) \
     266        $(TARGET_mt) \
     267        $(TARGET_arch) \
     268        $(TARGET_common)
     269
     270
    254271include $(PATH_KBUILD)/footer.kmk
  • 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
  • trunk/synergy/lib/platform/CPMClipboard.h

    r2770 r2774  
    3131    CPMClipboard(HWND window);
    3232    virtual ~CPMClipboard();
    33 
    34     //! Empty clipboard without ownership
    35     /*!
    36     Take ownership of the clipboard and clear all data from it.
    37     This must be called between a successful open() and close().
    38     Return false if the clipboard ownership could not be taken;
    39     the clipboard should not be emptied in this case.  Unlike
    40     empty(), isOwnedBySynergy() will return false when emptied
    41     this way.  This is useful when synergy wants to put data on
    42     clipboard but pretend (to itself) that some other app did it.
    43     When using empty(), synergy assumes the data came from the
    44     server and doesn't need to be sent back.  emptyUnowned()
    45     makes synergy send the data to the server.
    46     */
    47     bool                emptyUnowned();
    4833
    4934    //! Test if clipboard is owned by synergy
  • trunk/synergy/lib/platform/CPMClipboardAnyTextConverter.cpp

    r2752 r2774  
    33 * Copyright (C) 2002 Chris Schoeneman
    44 * Copyright (C) 2006 Knut St. Osmundsen
    5  * 
     5 *
    66 * This package is free software; you can redistribute it and/or
    77 * modify it under the terms of the GNU General Public License
    88 * found in the file COPYING that should have accompanied this file.
    9  * 
     9 *
    1010 * This package is distributed in the hope that it will be useful,
    1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     
    1515
    1616#include "CPMClipboardAnyTextConverter.h"
     17#include "CLog.h"
    1718
    1819//
     
    5051        // copy to memory handle
    5152    PVOID pv = NULL;
    52     APIRET rc = DosAllocSharedMem(&pv, NULL, cb, PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_GETTABLE | OBJ_GIVEABLE);
     53    APIRET rc = DosAllocSharedMem(&pv, NULL, cb + 1, PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_GETTABLE | OBJ_GIVEABLE);
    5354    if (rc == NO_ERROR) {
    54         return (ULONG)memcpy(pv, text.data(), cb);
     55                const char *psz = text.c_str();
     56LOG((CLOG_DEBUG "fromIClipboard: psz='%s' cb=%d strlen=%d\n", psz, cb, strlen(psz)));
     57        return (ULONG)memcpy(pv, psz, cb);
    5558    }
    5659    return 0;
    5760}
    5861
    59 void 
     62void
    6063CPMClipboardAnyTextConverter::freePMData(ULONG ulPMData) const
    6164{
     
    6871        // convert text
    6972    const char *psz = (const char *)data;
    70         CString text = doToIClipboard(CString(psz));
     73LOG((CLOG_DEBUG "toIClipboard: psz='%s' strlen=%d\n", psz, strlen(psz)));
     74        CString raw = CString(psz);
     75LOG((CLOG_DEBUG "toIClipboard: raw='%s'\n", raw.c_str()));
     76        CString text = doToIClipboard(raw);
     77LOG((CLOG_DEBUG "toIClipboard: text='%s'\n", text.c_str()));
    7178
    7279        // convert newlines
     
    7784CPMClipboardAnyTextConverter::convertLinefeedToPM(const CString& src) const
    7885{
    79         // note -- we assume src is a valid UTF-8 string
     86        // note -- we assume src is a valid UTF-8 string    L
    8087
    8188        // count newlines in string
  • trunk/synergy/lib/platform/CPMScreen.cpp

    r2771 r2774  
    547547    qmsg.ptl.y = 0;
    548548    qmsg.reserved = 0;
    549 LOG((CLOG_DEBUG "fakeMessage: msg=%#lx mp1=%#lx mp2=%#lx...", msg, mp1, mp2));
     549    LOG((CLOG_DEBUG "fakeMessage: msg=%#lx mp1=%#lx mp2=%#lx...", msg, mp1, mp2));
    550550    const char *pszError = m_fakeMsg(m_hab, &qmsg);
    551551    if (pszError) {
    552552        LOG((CLOG_CRIT "fakeMessage: msg=%#lx mp1=%#lx mp2=%#lx failed: %s", msg, mp1, mp2, pszError));
    553553    }
    554 else LOG((CLOG_DEBUG "fakeMessage: done"));
    555554}
    556555
     
    624623    POINTL ptl;
    625624    if (WinQueryPointerPos(HWND_DESKTOP, &ptl)) {
    626         LOG((CLOG_DEBUG "fakeMouseRelativeMove: %d,%d (%d,%d +/- %d,%d)", ptl.x + dx, ptl.y - dy, ptl.y, ptl.x, dx, dy));
     625        LOG((CLOG_DEBUG1 "fakeMouseRelativeMove: %d,%d (%d,%d +/- %d,%d)", ptl.x + dx, ptl.y - dy, ptl.y, ptl.x, dx, dy));
    627626        fakeMouseMove(ptl.x + dx, ptl.y - dy - m_cy);
    628627        return;
     
    762761        throw XScreenOpenFailure();
    763762    }
    764     LOG((CLOG_DEBUG1 "openHookLibrary: hmod=%#lx '%s'", hmod, name));
     763    LOG((CLOG_DEBUG2 "openHookLibrary: hmod=%#lx '%s'", hmod, name));
    765764    return hmod;
    766765}
     
    769768CPMScreen::closeHookLibrary(HMODULE hmod) const
    770769{
    771     LOG((CLOG_DEBUG1 "closeHookLibrary: hmod=%#lx\n", hmod));
     770    LOG((CLOG_DEBUG2 "closeHookLibrary: hmod=%#lx\n", hmod));
    772771    if (hmod != NULL) {
    773772        m_cleanup(m_hab);
     
    911910{
    912911    switch (msg) {
    913     case WM_DRAWCLIPBOARD:
     912
     913        //
     914        // Just freak out and close the clipboard if we get any of these.
     915        //
     916    case WM_RENDERFMT:
     917    case WM_RENDERALLFMTS:
     918    case WM_PAINTCLIPBOARD:
     919    case WM_SIZECLIPBOARD:
     920    case WM_HSCROLLCLIPBOARD:
     921    case WM_VSCROLLCLIPBOARD:
     922        LOG((CLOG_DEBUG "msg=%#x -> closing clipboard.\n", msg));
     923        WinCloseClipbrd(m_hab);
     924        break;
     925
     926        //
     927        // The content has changed.
     928        //
     929    //case WM_DESTROYCLIPBOARD:
     930        case WM_DRAWCLIPBOARD:
    914931        //// first pass on the message
    915932        //if (m_nextClipboardWindow != NULL) {
Note: See TracChangeset for help on using the changeset viewer.