2002-08-02 23:57:46 +04:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
* Copyright (C) 2002 Chris Schoeneman
|
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* found in the file COPYING that should have accompanied this file.
|
|
|
|
*
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
#ifndef CMSWINDOWSCLIPBOARD_H
|
|
|
|
#define CMSWINDOWSCLIPBOARD_H
|
|
|
|
|
|
|
|
#include "IClipboard.h"
|
2002-07-23 19:26:40 +04:00
|
|
|
#include "stdvector.h"
|
2002-06-10 20:49:46 +04:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2001-11-25 21:32:41 +03:00
|
|
|
#include <windows.h>
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-07-23 19:26:40 +04:00
|
|
|
class IMSWindowsClipboardConverter;
|
|
|
|
|
2002-07-29 21:03:55 +04:00
|
|
|
//! Microsoft windows clipboard implementation
|
2001-11-19 03:33:36 +03:00
|
|
|
class CMSWindowsClipboard : public IClipboard {
|
2002-04-29 18:40:01 +04:00
|
|
|
public:
|
2001-11-25 21:32:41 +03:00
|
|
|
CMSWindowsClipboard(HWND window);
|
2001-11-19 03:33:36 +03:00
|
|
|
virtual ~CMSWindowsClipboard();
|
|
|
|
|
2003-08-07 01:09:25 +04:00
|
|
|
//! Empty clipboard without ownership
|
|
|
|
/*!
|
|
|
|
Take ownership of the clipboard and clear all data from it.
|
|
|
|
This must be called between a successful open() and close().
|
|
|
|
Return false if the clipboard ownership could not be taken;
|
|
|
|
the clipboard should not be emptied in this case. Unlike
|
|
|
|
empty(), isOwnedBySynergy() will return false when emptied
|
|
|
|
this way. This is useful when synergy wants to put data on
|
|
|
|
clipboard but pretend (to itself) that some other app did it.
|
|
|
|
When using empty(), synergy assumes the data came from the
|
|
|
|
server and doesn't need to be sent back. emptyUnowned()
|
|
|
|
makes synergy send the data to the server.
|
|
|
|
*/
|
|
|
|
bool emptyUnowned();
|
|
|
|
|
Fixed several win32 bugs. First, synergy wasn't forwarding mouse
events to other hook functions, which broke some tools like objectbar.
Second, windows key processing was fixed. Previously pressing and
release the key would only send a press event, locking the user onto
the client window; also, the win32 server treated as a Meta modifier
instead of a Super modifier, which broke any use of it as any kind of
modifier key. Third, added hacks to support several key combinations
on windows 95/98/me that are treated specially by windows, including
Alt+Tab, Alt+Shift+Tab, Alt+Esc, Alt+Shift+Esc, Ctrl+Esc, and any
combination using the windows key like Win+E and Win+F but not
Ctrl+Alt+Del. Fourth, scroll lock only locking to the client (which
only happened when using a synergy server on windows) has been fixed;
unfortunately the solution causes a lot of screen redraws for some
reason. Finally, there's been a fix to clipboard handling that may
or may not fix a problem where the clipboard would stop transferring
between systems after a little while. I can't be sure if it fixes
the problem because I can't reproduce the problem.
2003-04-13 18:59:53 +04:00
|
|
|
//! Test if clipboard is owned by synergy
|
|
|
|
static bool isOwnedBySynergy();
|
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
// IClipboard overrides
|
2002-05-27 22:55:51 +04:00
|
|
|
virtual bool empty();
|
2001-11-19 03:33:36 +03:00
|
|
|
virtual void add(EFormat, const CString& data);
|
2002-05-27 22:55:51 +04:00
|
|
|
virtual bool open(Time) const;
|
|
|
|
virtual void close() const;
|
2002-04-30 20:23:03 +04:00
|
|
|
virtual Time getTime() const;
|
2001-11-19 03:33:36 +03:00
|
|
|
virtual bool has(EFormat) const;
|
|
|
|
virtual CString get(EFormat) const;
|
2001-11-25 21:32:41 +03:00
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
private:
|
2002-07-23 19:26:40 +04:00
|
|
|
void clearConverters();
|
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
UINT convertFormatToWin32(EFormat) const;
|
|
|
|
HANDLE convertTextToWin32(const CString& data) const;
|
|
|
|
CString convertTextFromWin32(HANDLE) const;
|
|
|
|
|
Fixed several win32 bugs. First, synergy wasn't forwarding mouse
events to other hook functions, which broke some tools like objectbar.
Second, windows key processing was fixed. Previously pressing and
release the key would only send a press event, locking the user onto
the client window; also, the win32 server treated as a Meta modifier
instead of a Super modifier, which broke any use of it as any kind of
modifier key. Third, added hacks to support several key combinations
on windows 95/98/me that are treated specially by windows, including
Alt+Tab, Alt+Shift+Tab, Alt+Esc, Alt+Shift+Esc, Ctrl+Esc, and any
combination using the windows key like Win+E and Win+F but not
Ctrl+Alt+Del. Fourth, scroll lock only locking to the client (which
only happened when using a synergy server on windows) has been fixed;
unfortunately the solution causes a lot of screen redraws for some
reason. Finally, there's been a fix to clipboard handling that may
or may not fix a problem where the clipboard would stop transferring
between systems after a little while. I can't be sure if it fixes
the problem because I can't reproduce the problem.
2003-04-13 18:59:53 +04:00
|
|
|
static UINT getOwnershipFormat();
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
private:
|
2002-07-23 19:26:40 +04:00
|
|
|
typedef std::vector<IMSWindowsClipboardConverter*> ConverterList;
|
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
HWND m_window;
|
2002-05-27 22:55:51 +04:00
|
|
|
mutable Time m_time;
|
2002-07-23 19:26:40 +04:00
|
|
|
ConverterList m_converters;
|
Fixed several win32 bugs. First, synergy wasn't forwarding mouse
events to other hook functions, which broke some tools like objectbar.
Second, windows key processing was fixed. Previously pressing and
release the key would only send a press event, locking the user onto
the client window; also, the win32 server treated as a Meta modifier
instead of a Super modifier, which broke any use of it as any kind of
modifier key. Third, added hacks to support several key combinations
on windows 95/98/me that are treated specially by windows, including
Alt+Tab, Alt+Shift+Tab, Alt+Esc, Alt+Shift+Esc, Ctrl+Esc, and any
combination using the windows key like Win+E and Win+F but not
Ctrl+Alt+Del. Fourth, scroll lock only locking to the client (which
only happened when using a synergy server on windows) has been fixed;
unfortunately the solution causes a lot of screen redraws for some
reason. Finally, there's been a fix to clipboard handling that may
or may not fix a problem where the clipboard would stop transferring
between systems after a little while. I can't be sure if it fixes
the problem because I can't reproduce the problem.
2003-04-13 18:59:53 +04:00
|
|
|
static UINT s_ownershipFormat;
|
2002-07-23 19:26:40 +04:00
|
|
|
};
|
|
|
|
|
2002-07-29 21:03:55 +04:00
|
|
|
//! Clipboard format converter interface
|
|
|
|
/*!
|
|
|
|
This interface defines the methods common to all win32 clipboard format
|
|
|
|
converters.
|
|
|
|
*/
|
2002-07-23 19:26:40 +04:00
|
|
|
class IMSWindowsClipboardConverter : public IInterface {
|
|
|
|
public:
|
|
|
|
// accessors
|
|
|
|
|
|
|
|
// return the clipboard format this object converts from/to
|
|
|
|
virtual IClipboard::EFormat
|
|
|
|
getFormat() const = 0;
|
|
|
|
|
|
|
|
// return the atom representing the win32 clipboard format that
|
|
|
|
// this object converts from/to
|
|
|
|
virtual UINT getWin32Format() const = 0;
|
|
|
|
|
|
|
|
// convert from the IClipboard format to the win32 clipboard format.
|
|
|
|
// the input data must be in the IClipboard format returned by
|
|
|
|
// getFormat(). the return data will be in the win32 clipboard
|
|
|
|
// format returned by getWin32Format(), allocated by GlobalAlloc().
|
|
|
|
virtual HANDLE fromIClipboard(const CString&) const = 0;
|
|
|
|
|
|
|
|
// convert from the win32 clipboard format to the IClipboard format
|
|
|
|
// (i.e., the reverse of fromIClipboard()).
|
|
|
|
virtual CString toIClipboard(HANDLE data) const = 0;
|
2001-11-19 03:33:36 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|