Indentation changes.

This commit is contained in:
crs 2002-04-29 14:40:01 +00:00
parent 3ca72b35f3
commit ea6b347b18
72 changed files with 428 additions and 428 deletions

View File

@ -4,13 +4,13 @@
#include "IJob.h"
class CFunctionJob : public IJob {
public:
public:
CFunctionJob(void (*func)(void*), void* arg = NULL);
// IJob overrides
virtual void run();
private:
private:
void (*m_func)(void*);
void* m_arg;
};

View File

@ -4,19 +4,19 @@
#include <stdarg.h>
class CLog {
public:
public:
typedef void (*Outputter)(const char*);
static void print(const char*, ...);
static void printt(const char* file, int line, const char*, ...);
static void setOutputter(Outputter);
private:
private:
static void output(int priority, char* msg);
static char* vsprint(int pad, char*, int len, const char*, va_list);
static int nprint(const char*, va_list);
private:
private:
static Outputter s_outputter;
};

View File

@ -135,7 +135,7 @@ static PTimeGetTime s_tgt = NULL;
//
class CStopwatchInit {
public:
public:
CStopwatchInit();
~CStopwatchInit();
};

View File

@ -4,54 +4,54 @@
#include "common.h"
class CStopwatch {
public:
// the default constructor does an implicit reset() or setTrigger().
// if triggered == false then the clock starts ticking.
CStopwatch(bool triggered = false);
~CStopwatch();
public:
// the default constructor does an implicit reset() or setTrigger().
// if triggered == false then the clock starts ticking.
CStopwatch(bool triggered = false);
~CStopwatch();
// manipulators
// manipulators
// set the start time to the current time, returning the time since
// the last reset. this does not remove the trigger if it's set nor
// does it start a stopped clock. if the clock is stopped then
// subsequent reset()'s will return 0.
double reset();
// set the start time to the current time, returning the time since
// the last reset. this does not remove the trigger if it's set nor
// does it start a stopped clock. if the clock is stopped then
// subsequent reset()'s will return 0.
double reset();
// stop and start the stopwatch. while stopped, no time elapses.
// stop() does not remove the trigger but start() does, even if
// the clock was already started.
void stop();
void start();
// stop and start the stopwatch. while stopped, no time elapses.
// stop() does not remove the trigger but start() does, even if
// the clock was already started.
void stop();
void start();
// setTrigger() stops the clock like stop() except there's an
// implicit start() the next time (non-const) getTime() is called.
// this is useful when you want the clock to start the first time
// you check it.
void setTrigger();
// setTrigger() stops the clock like stop() except there's an
// implicit start() the next time (non-const) getTime() is called.
// this is useful when you want the clock to start the first time
// you check it.
void setTrigger();
// return the time since the last reset() (or call reset() and
// return zero if the trigger is set).
double getTime();
// return the time since the last reset() (or call reset() and
// return zero if the trigger is set).
double getTime();
operator double();
// accessors
// accessors
// returns true if the watch is stopped
bool isStopped() const;
// returns true if the watch is stopped
bool isStopped() const;
// return the time since the last reset(). these cannot trigger
// the clock to start so if the trigger is set it's as if it wasn't.
double getTime() const;
// return the time since the last reset(). these cannot trigger
// the clock to start so if the trigger is set it's as if it wasn't.
double getTime() const;
operator double() const;
private:
double getClock() const;
private:
double getClock() const;
private:
double m_mark;
bool m_triggered;
bool m_stopped;
private:
double m_mark;
bool m_triggered;
bool m_stopped;
};
#endif

View File

@ -15,7 +15,7 @@
#define _CS(_x) _x
class CString : public std::string {
public:
public:
typedef char _e;
typedef _e CharT;
typedef std::allocator<_e> _a;

View File

@ -4,7 +4,7 @@
#include "common.h"
class IInterface {
public:
public:
virtual ~IInterface() { }
};

View File

@ -4,7 +4,7 @@
#include "IInterface.h"
class IJob : public IInterface {
public:
public:
virtual void run() = 0;
};

View File

@ -5,13 +5,13 @@
template <class T>
class TMethodJob : public IJob {
public:
public:
TMethodJob(T* object, void (T::*method)(void*), void* arg = NULL);
// IJob overrides
virtual void run();
private:
private:
T* m_object;
void (T::*m_method)(void*);
void* m_arg;

View File

@ -5,7 +5,7 @@
#include <exception>
class XBase : public std::exception {
public:
public:
XBase();
XBase(const CString& msg);
virtual ~XBase();
@ -13,7 +13,7 @@ class XBase : public std::exception {
// std::exception overrides
virtual const char* what() const;
protected:
protected:
// returns a human readable string describing the exception
virtual CString getWhat() const throw() = 0;
@ -21,12 +21,12 @@ class XBase : public std::exception {
virtual CString format(const char* id,
const char* defaultFormat, ...) const throw();
private:
private:
mutable CString m_what;
};
class MXErrno {
public:
public:
MXErrno();
MXErrno(int);
@ -37,7 +37,7 @@ class MXErrno {
int getErrno() const;
const char* getErrstr() const;
private:
private:
int m_errno;
};

View File

@ -13,7 +13,7 @@ class IOutputStream;
class ISecondaryScreen;
class CClient {
public:
public:
CClient(const CString& clientName);
~CClient();
@ -27,7 +27,7 @@ class CClient {
// accessors
private:
private:
void runSession(void*);
// open/close the primary screen
@ -49,7 +49,7 @@ class CClient {
void onMouseMove();
void onMouseWheel();
private:
private:
CMutex m_mutex;
CString m_name;
IInputStream* m_input;

View File

@ -31,14 +31,14 @@ static DWORD s_thread = 0;
static BOOL CALLBACK WINAPI debugProc(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG:
case WM_INITDIALOG:
return TRUE;
case WM_CLOSE:
case WM_CLOSE:
PostQuitMessage(0);
return TRUE;
case WM_APP:
case WM_APP:
if (!s_logMore.empty()) {
if (s_log.size() > 20000)
s_log = s_logMore;
@ -194,19 +194,19 @@ void CMSWindowsSecondaryScreen::mouseDown(ButtonID button)
// map button id to button flag
DWORD flags;
switch (button) {
case kButtonLeft:
case kButtonLeft:
flags = MOUSEEVENTF_LEFTDOWN;
break;
case kButtonMiddle:
case kButtonMiddle:
flags = MOUSEEVENTF_MIDDLEDOWN;
break;
case kButtonRight:
case kButtonRight:
flags = MOUSEEVENTF_RIGHTDOWN;
break;
default:
default:
return;
}
@ -219,19 +219,19 @@ void CMSWindowsSecondaryScreen::mouseUp(ButtonID button)
// map button id to button flag
DWORD flags;
switch (button) {
case kButtonLeft:
case kButtonLeft:
flags = MOUSEEVENTF_LEFTUP;
break;
case kButtonMiddle:
case kButtonMiddle:
flags = MOUSEEVENTF_MIDDLEUP;
break;
case kButtonRight:
case kButtonRight:
flags = MOUSEEVENTF_RIGHTUP;
break;
default:
default:
return;
}
@ -361,12 +361,12 @@ LRESULT CMSWindowsSecondaryScreen::onEvent(
WPARAM wParam, LPARAM lParam)
{
switch (msg) {
// FIXME -- handle display changes
case WM_PAINT:
// FIXME -- handle display changes
case WM_PAINT:
ValidateRect(hwnd, NULL);
return 0;
case WM_ACTIVATEAPP:
case WM_ACTIVATEAPP:
if (wParam == FALSE) {
// some other app activated. hide the hider window.
log((CLOG_INFO "show cursor"));
@ -374,7 +374,7 @@ LRESULT CMSWindowsSecondaryScreen::onEvent(
}
break;
case WM_DRAWCLIPBOARD:
case WM_DRAWCLIPBOARD:
log((CLOG_DEBUG "clipboard was taken"));
// first pass it on
@ -389,7 +389,7 @@ LRESULT CMSWindowsSecondaryScreen::onEvent(
}
return 0;
case WM_CHANGECBCHAIN:
case WM_CHANGECBCHAIN:
if (m_nextClipboardWindow == (HWND)wParam)
m_nextClipboardWindow = (HWND)lParam;
else

View File

@ -5,7 +5,7 @@
#include "ISecondaryScreen.h"
class CMSWindowsSecondaryScreen : public CMSWindowsScreen, public ISecondaryScreen {
public:
public:
CMSWindowsSecondaryScreen();
virtual ~CMSWindowsSecondaryScreen();
@ -29,17 +29,17 @@ class CMSWindowsSecondaryScreen : public CMSWindowsScreen, public ISecondaryScre
virtual SInt32 getJumpZoneSize() const;
virtual void getClipboard(IClipboard*) const;
protected:
protected:
// CMSWindowsScreen overrides
virtual bool onPreTranslate(MSG*);
virtual LRESULT onEvent(HWND, UINT, WPARAM, LPARAM);
virtual void onOpenDisplay();
virtual void onCloseDisplay();
private:
private:
UINT mapKey(KeyID, KeyModifierMask) const;
private:
private:
CClient* m_client;
HWND m_window;
HWND m_nextClipboardWindow;

View File

@ -38,7 +38,7 @@ void CXWindowsSecondaryScreen::run()
// handle event
switch (xevent.type) {
case MappingNotify: {
case MappingNotify: {
// keyboard mapping changed
CDisplayLock display(this);
XRefreshKeyboardMapping(&xevent.xmapping);
@ -47,17 +47,17 @@ void CXWindowsSecondaryScreen::run()
updateModifierMap(display);
updateModifiers(display);
break;
}
}
case LeaveNotify: {
case LeaveNotify: {
// mouse moved out of hider window somehow. hide the window.
assert(m_window != None);
CDisplayLock display(this);
XUnmapWindow(display, m_window);
break;
}
}
case SelectionClear:
case SelectionClear:
// we just lost the selection. that means someone else
// grabbed the selection so this screen is now the
// selection owner. report that to the server.
@ -68,7 +68,7 @@ void CXWindowsSecondaryScreen::run()
}
break;
case SelectionNotify:
case SelectionNotify:
// notification of selection transferred. we shouldn't
// get this here because we handle them in the selection
// retrieval methods. we'll just delete the property
@ -79,7 +79,7 @@ void CXWindowsSecondaryScreen::run()
}
break;
case SelectionRequest:
case SelectionRequest:
// somebody is asking for clipboard data
if (xevent.xselectionrequest.owner == m_window) {
addClipboardRequest(m_window,
@ -105,7 +105,7 @@ void CXWindowsSecondaryScreen::run()
}
break;
case PropertyNotify:
case PropertyNotify:
// clipboard transfers involve property changes so forward
// the event to the superclass. we only care about the
// deletion of properties.
@ -116,7 +116,7 @@ void CXWindowsSecondaryScreen::run()
}
break;
case DestroyNotify:
case DestroyNotify:
// looks like one of the windows that requested a clipboard
// transfer has gone bye-bye.
destroyClipboardRequest(xevent.xdestroywindow.window);

View File

@ -6,7 +6,7 @@
#include <vector>
class CXWindowsSecondaryScreen : public CXWindowsScreen, public ISecondaryScreen {
public:
public:
CXWindowsSecondaryScreen();
virtual ~CXWindowsSecondaryScreen();
@ -30,13 +30,13 @@ class CXWindowsSecondaryScreen : public CXWindowsScreen, public ISecondaryScreen
virtual SInt32 getJumpZoneSize() const;
virtual void getClipboard(ClipboardID, IClipboard*) const;
protected:
protected:
// CXWindowsScreen overrides
virtual void onOpenDisplay();
virtual void onCloseDisplay();
virtual long getEventMask(Window) const;
private:
private:
struct KeyCodeMask {
public:
KeyCode keycode;
@ -64,7 +64,7 @@ class CXWindowsSecondaryScreen : public CXWindowsScreen, public ISecondaryScreen
void updateModifierMap(Display* display);
static bool isToggleKeysym(KeySym);
private:
private:
CClient* m_client;
Window m_window;

View File

@ -9,7 +9,7 @@ class CMutex;
class IJob;
class CBufferedInputStream : public IInputStream {
public:
public:
CBufferedInputStream(CMutex*, IJob* adoptedCloseCB);
~CBufferedInputStream();
@ -39,7 +39,7 @@ class CBufferedInputStream : public IInputStream {
virtual UInt32 read(void*, UInt32 count);
virtual UInt32 getSize() const;
private:
private:
CMutex* m_mutex;
CCondVar<bool> m_empty;
IJob* m_closeCB;

View File

@ -8,7 +8,7 @@ class CMutex;
class IJob;
class CBufferedOutputStream : public IOutputStream {
public:
public:
CBufferedOutputStream(CMutex*, IJob* adoptedCloseCB);
~CBufferedOutputStream();
@ -33,10 +33,10 @@ class CBufferedOutputStream : public IOutputStream {
virtual UInt32 write(const void*, UInt32 count);
virtual void flush();
private:
private:
UInt32 getSizeWithLock() const;
private:
private:
CMutex* m_mutex;
IJob* m_closeCB;
CStreamBuffer m_buffer;

View File

@ -4,7 +4,7 @@
#include "IInputStream.h"
class CInputStreamFilter : public IInputStream {
public:
public:
CInputStreamFilter(IInputStream*, bool adoptStream = true);
~CInputStreamFilter();
@ -17,10 +17,10 @@ class CInputStreamFilter : public IInputStream {
virtual UInt32 read(void*, UInt32 maxCount) = 0;
virtual UInt32 getSize() const = 0;
protected:
protected:
IInputStream* getStream() const;
private:
private:
IInputStream* m_stream;
bool m_adopted;
};

View File

@ -4,7 +4,7 @@
#include "IOutputStream.h"
class COutputStreamFilter : public IOutputStream {
public:
public:
COutputStreamFilter(IOutputStream*, bool adoptStream = true);
~COutputStreamFilter();
@ -17,10 +17,10 @@ class COutputStreamFilter : public IOutputStream {
virtual UInt32 write(const void*, UInt32 count) = 0;
virtual void flush() = 0;
protected:
protected:
IOutputStream* getStream() const;
private:
private:
IOutputStream* m_stream;
bool m_adopted;
};

View File

@ -6,7 +6,7 @@
#include <vector>
class CStreamBuffer {
public:
public:
CStreamBuffer();
~CStreamBuffer();
@ -25,7 +25,7 @@ class CStreamBuffer {
// return the number of bytes in the buffer
UInt32 getSize() const;
private:
private:
static const UInt32 kChunkSize;
typedef std::vector<UInt8> Chunk;

View File

@ -6,7 +6,7 @@
#include "XIO.h"
class IInputStream : public IInterface {
public:
public:
// manipulators
// close the stream

View File

@ -6,7 +6,7 @@
#include "XIO.h"
class IOutputStream : public IInterface {
public:
public:
// manipulators
// close the stream

View File

@ -7,25 +7,25 @@
class XIO : public XBase { };
class XIOErrno : public XIO, public MXErrno {
public:
public:
XIOErrno();
XIOErrno(int);
};
class XIOClose: public XIOErrno {
protected:
protected:
// XBase overrides
virtual CString getWhat() const throw();
};
class XIOClosed : public XIO {
protected:
protected:
// XBase overrides
virtual CString getWhat() const throw();
};
class XIOEndOfStream : public XIO {
protected:
protected:
// XBase overrides
virtual CString getWhat() const throw();
};

View File

@ -148,14 +148,14 @@ bool CCondVarBase::wait(
}
switch (status) {
case 0:
case 0:
// success
return true;
case ETIMEDOUT:
case ETIMEDOUT:
return false;
default:
default:
assert(0 && "condition variable wait error");
return false;
}
@ -183,8 +183,8 @@ void CCondVarBase::init()
{
// prepare events
HANDLE* events = new HANDLE[2];
events[kSignal] = CreateEvent(NULL, FALSE, FALSE, NULL);
events[kBroadcast] = CreateEvent(NULL, TRUE, FALSE, NULL);
events[kSignal] = CreateEvent(NULL, FALSE, FALSE, NULL);
events[kBroadcast] = CreateEvent(NULL, TRUE, FALSE, NULL);
// prepare members
m_cond = reinterpret_cast<void*>(events);
@ -194,8 +194,8 @@ void CCondVarBase::init()
void CCondVarBase::fini()
{
HANDLE* events = reinterpret_cast<HANDLE*>(m_cond);
CloseHandle(events[kSignal]);
CloseHandle(events[kBroadcast]);
CloseHandle(events[kSignal]);
CloseHandle(events[kBroadcast]);
delete[] events;
}
@ -210,7 +210,7 @@ void CCondVarBase::signal()
// wake one thread if anybody is waiting
if (hasWaiter)
SetEvent(reinterpret_cast<HANDLE*>(m_cond)[kSignal]);
SetEvent(reinterpret_cast<HANDLE*>(m_cond)[kSignal]);
}
void CCondVarBase::broadcast()
@ -224,7 +224,7 @@ void CCondVarBase::broadcast()
// wake all threads if anybody is waiting
if (hasWaiter)
SetEvent(reinterpret_cast<HANDLE*>(m_cond)[kBroadcast]);
SetEvent(reinterpret_cast<HANDLE*>(m_cond)[kBroadcast]);
}
bool CCondVarBase::wait(

View File

@ -7,7 +7,7 @@
class CStopwatch;
class CCondVarBase {
public:
public:
// mutex must be supplied. all condition variables have an
// associated mutex. the copy c'tor uses the same mutex as the
// argument and is otherwise like the default c'tor.
@ -45,7 +45,7 @@ class CCondVarBase {
// get the mutex passed to the c'tor
CMutex* getMutex() const;
private:
private:
void init();
void fini();
@ -53,7 +53,7 @@ class CCondVarBase {
CCondVarBase(const CCondVarBase&);
CCondVarBase& operator=(const CCondVarBase&);
private:
private:
CMutex* m_mutex;
void* m_cond;
@ -66,7 +66,7 @@ class CCondVarBase {
template <class T>
class CCondVar : public CCondVarBase {
public:
public:
CCondVar(CMutex* mutex, const T&);
CCondVar(const CCondVar&);
~CCondVar();
@ -85,7 +85,7 @@ class CCondVar : public CCondVarBase {
// calling this method.
operator const T&() const;
private:
private:
T m_data;
};

View File

@ -7,17 +7,17 @@ class CMutex;
class CCondVarBase;
class CLock {
public:
public:
CLock(const CMutex* mutex);
CLock(const CCondVarBase* cv);
~CLock();
private:
private:
// not implemented
CLock(const CLock&);
CLock& operator=(const CLock&);
private:
private:
const CMutex* m_mutex;
};

View File

@ -60,19 +60,19 @@ void CMutex::lock() const
int status = pthread_mutex_lock(mutex);
switch (status) {
case 0:
case 0:
// success
return;
case EDEADLK:
case EDEADLK:
assert(0 && "lock already owned");
break;
case EAGAIN:
case EAGAIN:
assert(0 && "too many recursive locks");
break;
default:
default:
log((CLOG_ERR "pthread_mutex_lock status %d", status));
assert(0 && "unexpected error");
}
@ -84,15 +84,15 @@ void CMutex::unlock() const
int status = pthread_mutex_unlock(mutex);
switch (status) {
case 0:
case 0:
// success
return;
case EPERM:
case EPERM:
assert(0 && "thread doesn't own a lock");
break;
default:
default:
log((CLOG_ERR "pthread_mutex_unlock status %d", status));
assert(0 && "unexpected error");
}

View File

@ -5,7 +5,7 @@
// recursive mutex class
class CMutex {
public:
public:
// copy c'tor is equivalent to default c'tor. it's here to
// allow copying of objects that have mutexes.
CMutex();
@ -14,22 +14,22 @@ class CMutex {
// manipulators
// this has no effect. it's only here to allow assignment of
// this has no effect. it's only here to allow assignment of
// objects that have mutexes.
CMutex& operator=(const CMutex&);
CMutex& operator=(const CMutex&);
// accessors
void lock() const;
void unlock() const;
private:
private:
void init();
void fini();
private:
private:
friend class CCondVarBase;
void* m_mutex;
void* m_mutex;
};
#endif

View File

@ -8,44 +8,44 @@ class CThreadRep;
// note -- do not derive from this class
class CThread {
public:
// create and start a new thread executing the job.
public:
// create and start a new thread executing the job.
// the user data can be retrieved with getUserData().
CThread(IJob* adopted, void* userData = 0);
CThread(IJob* adopted, void* userData = 0);
// make a new thread object that refers to an existing thread.
// make a new thread object that refers to an existing thread.
// this does *not* start a new thread.
CThread(const CThread&);
CThread(const CThread&);
// release thread. this does not terminate the thread. a thread
// will keep running until the job completes or calls exit().
~CThread();
// release thread. this does not terminate the thread. a thread
// will keep running until the job completes or calls exit().
~CThread();
// manipulators
// manipulators
// assign thread. this has no effect on the threads. it simply
// makes this thread object refer to another thread. it does *not*
// assign thread. this has no effect on the threads. it simply
// makes this thread object refer to another thread. it does *not*
// start a new thread.
CThread& operator=(const CThread&);
CThread& operator=(const CThread&);
// initialize the thread library. this must be called before
// any other thread methods or creating a thread object. it
// is harmless to call init() multiple times.
static void init();
// the calling thread sleeps for the given number of seconds. if
// timeout <= 0.0 then the call returns immediately. if timeout
// the calling thread sleeps for the given number of seconds. if
// timeout <= 0.0 then the call returns immediately. if timeout
// == 0.0 then the calling thread yields the CPU.
// (cancellation point)
static void sleep(double timeout);
static void sleep(double timeout);
// terminate the calling thread. this function does not return but
// the stack is unwound and automatic objects are destroyed, as if
// exit() threw an exception (which is, in fact, what it does). the
// argument is saved as the result returned by getResult(). if you
// have a catch(...) block then you should add the following before
// it to avoid catching the exit: catch(CThreadExit&) { throw; }
static void exit(void*);
// terminate the calling thread. this function does not return but
// the stack is unwound and automatic objects are destroyed, as if
// exit() threw an exception (which is, in fact, what it does). the
// argument is saved as the result returned by getResult(). if you
// have a catch(...) block then you should add the following before
// it to avoid catching the exit: catch(CThreadExit&) { throw; }
static void exit(void*);
// enable/disable cancellation. default is enabled. this is not
// a cancellation point so if you enabled cancellation and want to
@ -76,26 +76,26 @@ class CThread {
// exception. clients that catch(...) must either rethrow the
// exception or include a catch (XThreadCancel) handler that
// rethrows.
void cancel();
void cancel();
// change the priority of the thread. normal priority is 0, 1 is
// change the priority of the thread. normal priority is 0, 1 is
// the next lower, etc. -1 is the next higher, etc. but boosting
// the priority may not be available.
void setPriority(int n);
void setPriority(int n);
// accessors
// accessors
// return a thread object representing the calling thread
static CThread getCurrentThread();
// return a thread object representing the calling thread
static CThread getCurrentThread();
// get the user data passed to the constructor for the current
// get the user data passed to the constructor for the current
// thread.
static void* getUserData();
static void* getUserData();
// testCancel() does nothing but is a cancellation point. call
// testCancel() does nothing but is a cancellation point. call
// this to make a function itself a cancellation point.
// (cancellation point)
static void testCancel();
static void testCancel();
// waits for the thread to terminate (by exit() or cancel() or
// by returning from the thread job). returns immediately if
@ -105,30 +105,30 @@ class CThread {
// (cancellation point)
bool wait(double timeout = -1.0) const;
// get the exit result. does an implicit wait(). returns NULL
// get the exit result. does an implicit wait(). returns NULL
// immediately if called by a thread on itself. returns NULL for
// threads that were cancelled.
// (cancellation point)
void* getResult() const;
// compare threads for (in)equality
bool operator==(const CThread&) const;
bool operator!=(const CThread&) const;
// compare threads for (in)equality
bool operator==(const CThread&) const;
bool operator!=(const CThread&) const;
private:
CThread(CThreadRep*);
private:
CThread(CThreadRep*);
private:
CThreadRep* m_rep;
private:
CThreadRep* m_rep;
};
// disables cancellation in the c'tor and enables it in the d'tor.
class CThreadMaskCancel {
public:
public:
CThreadMaskCancel() : m_old(CThread::enableCancel(false)) { }
~CThreadMaskCancel() { CThread::enableCancel(m_old); }
private:
private:
bool m_old;
};

View File

@ -518,15 +518,15 @@ bool CThreadRep::wait(CThreadRep* target, double timeout)
// handle result
switch (result) {
case WAIT_OBJECT_0 + 0:
case WAIT_OBJECT_0 + 0:
// target thread terminated
return true;
case WAIT_OBJECT_0 + 1:
case WAIT_OBJECT_0 + 1:
// this thread was cancelled. does not return.
testCancel();
default:
default:
// error
return false;
}
@ -536,16 +536,16 @@ void CThreadRep::setPriority(int n)
{
if (n < 0) {
switch (-n) {
case 1: n = THREAD_PRIORITY_ABOVE_NORMAL; break;
default: n = THREAD_PRIORITY_HIGHEST; break;
case 1: n = THREAD_PRIORITY_ABOVE_NORMAL; break;
default: n = THREAD_PRIORITY_HIGHEST; break;
}
}
else {
switch (n) {
case 0: n = THREAD_PRIORITY_NORMAL; break;
case 1: n = THREAD_PRIORITY_BELOW_NORMAL; break;
case 2: n = THREAD_PRIORITY_LOWEST; break;
default: n = THREAD_PRIORITY_IDLE; break;
case 0: n = THREAD_PRIORITY_NORMAL; break;
case 1: n = THREAD_PRIORITY_BELOW_NORMAL; break;
case 2: n = THREAD_PRIORITY_LOWEST; break;
default: n = THREAD_PRIORITY_IDLE; break;
}
}
SetThreadPriority(m_thread, n);

View File

@ -13,7 +13,7 @@ class CMutex;
class IJob;
class CThreadRep {
public:
public:
CThreadRep(IJob*, void* userData);
// manipulators
@ -25,9 +25,9 @@ class CThreadRep {
void ref();
void unref();
// the calling thread sleeps for t seconds. if t == 0.0 then
// the thread yields the CPU.
void sleep(double timeout);
// the calling thread sleeps for t seconds. if t == 0.0 then
// the thread yields the CPU.
void sleep(double timeout);
// cancel the thread
void cancel();
@ -42,16 +42,16 @@ class CThreadRep {
// wait for thread to exit or for current thread to cancel
bool wait(CThreadRep*, double timeout);
// set the priority
void setPriority(int n);
// set the priority
void setPriority(int n);
// accessors
// accessors
// get the exit result for this thread. thread must be terminated.
void* getResult() const;
// get the exit result for this thread. thread must be terminated.
void* getResult() const;
// get the user data passed to the constructor
void* getUserData() const;
// get the user data passed to the constructor
void* getUserData() const;
// get the current cancellable state
bool isCancellable() const;
@ -63,14 +63,14 @@ class CThreadRep {
HANDLE getCancelEvent() const;
#endif
// return the thread rep for the calling thread. the returned
// rep has been ref()'d.
static CThreadRep* getCurrentThreadRep();
// return the thread rep for the calling thread. the returned
// rep has been ref()'d.
static CThreadRep* getCurrentThreadRep();
protected:
protected:
virtual ~CThreadRep();
private:
private:
// internal constructor
CThreadRep();
@ -94,7 +94,7 @@ class CThreadRep {
CThreadRep(const CThreadRep&);
CThreadRep& operator=(const CThreadRep&);
private:
private:
static CMutex* s_mutex;
static CThreadRep* s_head;
@ -127,18 +127,18 @@ class CThreadRep {
//
class CThreadPtr {
public:
public:
CThreadPtr(CThreadRep* rep) : m_rep(rep) { }
~CThreadPtr() { m_rep->unref(); }
CThreadRep* operator->() const { return m_rep; }
private:
private:
// not implemented
CThreadPtr(const CThreadPtr&);
CThreadPtr& operator=(const CThreadPtr&);
private:
private:
CThreadRep* m_rep;
};

View File

@ -6,18 +6,18 @@
class CThread;
class CTimerThread {
public:
public:
CTimerThread(double timeout);
~CTimerThread();
private:
private:
void timer(void*);
// not implemented
CTimerThread(const CTimerThread&);
CTimerThread& operator=(const CTimerThread&);
private:
private:
double m_timeout;
CThread* m_callingThread;
CThread* m_timingThread;

View File

@ -10,12 +10,12 @@ class XThread { };
// must not throw this type but must rethrow it if caught (by
// XThreadExit, XThread, or ...).
class XThreadExit : public XThread {
public:
XThreadExit(void* result) : m_result(result) { }
~XThreadExit() { }
public:
XThreadExit(void* result) : m_result(result) { }
~XThreadExit() { }
public:
void* m_result;
public:
void* m_result;
};
// thrown to cancel a thread. clients must not throw this type, but

View File

@ -26,7 +26,7 @@ typedef int ssize_t;
// FIXME -- must handle htonl and ilk when defined as macros
class CNetwork {
public:
public:
#if defined(CONFIG_PLATFORM_WIN32)
typedef SOCKET Socket;
typedef struct sockaddr Address;
@ -129,7 +129,7 @@ class CNetwork {
static int (PASCAL FAR *gethosterror)(void);
#if defined(CONFIG_PLATFORM_WIN32)
private:
private:
static void init2(HMODULE);
static int PASCAL FAR poll2(PollEntry[], int nfds, int timeout);
static ssize_t PASCAL FAR read2(Socket s, void FAR * buf, size_t len);

View File

@ -24,15 +24,15 @@ CNetworkAddress::CNetworkAddress(const CString& hostname, UInt16 port)
struct hostent* hent = CNetwork::gethostbyname(hostname.c_str());
if (hent == NULL) {
switch (CNetwork::gethosterror()) {
case CNetwork::kHOST_NOT_FOUND:
case CNetwork::kHOST_NOT_FOUND:
throw XSocketAddress(XSocketAddress::kNotFound, hostname, port);
case CNetwork::kNO_DATA:
case CNetwork::kNO_DATA:
throw XSocketAddress(XSocketAddress::kNoAddress, hostname, port);
case CNetwork::kNO_RECOVERY:
case CNetwork::kTRY_AGAIN:
default:
case CNetwork::kNO_RECOVERY:
case CNetwork::kTRY_AGAIN:
default:
throw XSocketAddress(XSocketAddress::kUnknown, hostname, port);
}
}

View File

@ -8,7 +8,7 @@
class CString;
class CNetworkAddress {
public:
public:
CNetworkAddress(UInt16 port);
CNetworkAddress(const CString& hostname, UInt16 port);
~CNetworkAddress();
@ -20,7 +20,7 @@ class CNetworkAddress {
const CNetwork::Address* getAddress() const;
CNetwork::AddressLength getAddressLength() const;
private:
private:
CNetwork::Address m_address;
};

View File

@ -9,7 +9,7 @@ class CMutex;
class IJob;
class CSocketInputStream : public IInputStream {
public:
public:
CSocketInputStream(CMutex*, IJob* adoptedCloseCB);
~CSocketInputStream();
@ -30,7 +30,7 @@ class CSocketInputStream : public IInputStream {
virtual UInt32 read(void*, UInt32 count);
virtual UInt32 getSize() const;
private:
private:
CMutex* m_mutex;
CCondVar<bool> m_empty;
IJob* m_closeCB;

View File

@ -8,7 +8,7 @@ class CMutex;
class IJob;
class CSocketOutputStream : public IOutputStream {
public:
public:
CSocketOutputStream(CMutex*, IJob* adoptedCloseCB);
~CSocketOutputStream();
@ -30,10 +30,10 @@ class CSocketOutputStream : public IOutputStream {
virtual UInt32 write(const void*, UInt32 count);
virtual void flush();
private:
private:
UInt32 getSizeWithLock() const;
private:
private:
CMutex* m_mutex;
IJob* m_closeCB;
CSocketStreamBuffer m_buffer;

View File

@ -6,7 +6,7 @@
#include <vector>
class CSocketStreamBuffer {
public:
public:
CSocketStreamBuffer();
~CSocketStreamBuffer();
@ -25,7 +25,7 @@ class CSocketStreamBuffer {
// return the number of bytes in the buffer
UInt32 getSize() const;
private:
private:
static const UInt32 kChunkSize;
typedef std::vector<UInt8> Chunk;

View File

@ -5,7 +5,7 @@
#include "CNetwork.h"
class CTCPListenSocket : public IListenSocket {
public:
public:
CTCPListenSocket();
~CTCPListenSocket();
@ -18,7 +18,7 @@ class CTCPListenSocket : public IListenSocket {
virtual ISocket* accept();
virtual void close();
private:
private:
CNetwork::Socket m_fd;
};

View File

@ -13,7 +13,7 @@ class CBufferedInputStream;
class CBufferedOutputStream;
class CTCPSocket : public ISocket {
public:
public:
CTCPSocket();
CTCPSocket(CNetwork::Socket);
~CTCPSocket();
@ -29,14 +29,14 @@ class CTCPSocket : public ISocket {
virtual IInputStream* getInputStream();
virtual IOutputStream* getOutputStream();
private:
private:
void init();
void ioThread(void*);
void ioService();
void closeInput(void*);
void closeOutput(void*);
private:
private:
enum { kClosed = 0, kRead = 1, kWrite = 2, kReadWrite = 3 };
CNetwork::Socket m_fd;

View File

@ -9,7 +9,7 @@ class CNetworkAddress;
class ISocket;
class IListenSocket : public IInterface {
public:
public:
// manipulators
// bind the socket to a particular address

View File

@ -11,7 +11,7 @@ class IInputStream;
class IOutputStream;
class ISocket : public IInterface {
public:
public:
// manipulators
// bind the socket to a particular address

View File

@ -8,19 +8,19 @@
class XNetwork : public XBase { };
class XNetworkUnavailable : public XNetwork {
protected:
protected:
// XBase overrides
virtual CString getWhat() const throw();
};
class XNetworkFailed : public XNetwork {
protected:
protected:
// XBase overrides
virtual CString getWhat() const throw();
};
class XNetworkVersion : public XNetwork {
public:
public:
XNetworkVersion(int major, int minor) throw();
// accessors
@ -28,24 +28,24 @@ class XNetworkVersion : public XNetwork {
int getMajor() const throw();
int getMinor() const throw();
protected:
protected:
// XBase overrides
virtual CString getWhat() const throw();
private:
private:
int m_major;
int m_minor;
};
class XNetworkFunctionUnavailable : public XNetwork {
public:
public:
XNetworkFunctionUnavailable(const char* name) throw();
protected:
protected:
// XBase overrides
virtual CString getWhat() const throw();
private:
private:
CString m_name;
};

View File

@ -8,7 +8,7 @@
class XSocket : public XBase { };
class XSocketAddress : public XSocket {
public:
public:
enum Error { kUnknown, kNotFound, kNoAddress, kBadPort };
XSocketAddress(Error, const CString& hostname, SInt16 port) throw();
@ -19,24 +19,24 @@ class XSocketAddress : public XSocket {
virtual CString getHostname() const throw();
virtual SInt16 getPort() const throw();
protected:
protected:
// XBase overrides
virtual CString getWhat() const throw();
private:
private:
Error m_error;
CString m_hostname;
SInt16 m_port;
};
class XSocketErrno : public XSocket, public MXErrno {
public:
public:
XSocketErrno();
XSocketErrno(int);
};
class XSocketBind : public XSocketErrno {
protected:
protected:
// XBase overrides
virtual CString getWhat() const throw();
};
@ -44,13 +44,13 @@ class XSocketBind : public XSocketErrno {
class XSocketAddressInUse : public XSocketBind { };
class XSocketConnect : public XSocketErrno {
protected:
protected:
// XBase overrides
virtual CString getWhat() const throw();
};
class XSocketCreate : public XSocketErrno {
protected:
protected:
// XBase overrides
virtual CString getWhat() const throw();
};

View File

@ -38,14 +38,14 @@ static DWORD s_thread = 0;
static BOOL CALLBACK WINAPI debugProc(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG:
case WM_INITDIALOG:
return TRUE;
case WM_CLOSE:
case WM_CLOSE:
PostQuitMessage(0);
return TRUE;
case WM_APP:
case WM_APP:
if (!s_logMore.empty()) {
if (s_log.size() > 20000)
s_log = s_logMore;
@ -340,11 +340,11 @@ if (IsDialogMessage(s_debug, msg)) {
// handle event
switch (msg->message) {
case SYNERGY_MSG_MARK:
case SYNERGY_MSG_MARK:
m_markReceived = msg->wParam;
return true;
case SYNERGY_MSG_KEY:
case SYNERGY_MSG_KEY:
// ignore if not at current mark
if (m_mark == m_markReceived) {
KeyModifierMask mask;
@ -373,23 +373,23 @@ log((CLOG_DEBUG "event: key event vk=%d info=0x%08x", msg->wParam, msg->lParam))
}
return true;
case SYNERGY_MSG_MOUSE_BUTTON:
case SYNERGY_MSG_MOUSE_BUTTON:
// ignore if not at current mark
if (m_mark == m_markReceived) {
const ButtonID button = mapButton(msg->wParam);
switch (msg->wParam) {
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
log((CLOG_DEBUG "event: button press button=%d", button));
if (button != kButtonNone) {
m_server->onMouseDown(button);
}
break;
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
log((CLOG_DEBUG "event: button release button=%d", button));
if (button != kButtonNone) {
m_server->onMouseUp(button);
@ -399,7 +399,7 @@ log((CLOG_DEBUG "event: key event vk=%d info=0x%08x", msg->wParam, msg->lParam))
}
return true;
case SYNERGY_MSG_MOUSE_MOVE:
case SYNERGY_MSG_MOUSE_MOVE:
// ignore if not at current mark
if (m_mark == m_markReceived) {
SInt32 x = (SInt32)msg->wParam;
@ -445,12 +445,12 @@ LRESULT CMSWindowsPrimaryScreen::onEvent(
WPARAM wParam, LPARAM lParam)
{
switch (msg) {
// FIXME -- handle display changes
case WM_PAINT:
// FIXME -- handle display changes
case WM_PAINT:
ValidateRect(hwnd, NULL);
return 0;
case WM_DRAWCLIPBOARD:
case WM_DRAWCLIPBOARD:
log((CLOG_DEBUG "clipboard was taken"));
// first pass it on
@ -470,7 +470,7 @@ LRESULT CMSWindowsPrimaryScreen::onEvent(
}
return 0;
case WM_CHANGECBCHAIN:
case WM_CHANGECBCHAIN:
if (m_nextClipboardWindow == (HWND)wParam)
m_nextClipboardWindow = (HWND)lParam;
else
@ -818,19 +818,19 @@ ButtonID CMSWindowsPrimaryScreen::mapButton(
WPARAM button) const
{
switch (button) {
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
return kButtonLeft;
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
return kButtonMiddle;
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
return kButtonRight;
default:
default:
return kButtonNone;
}
}

View File

@ -7,7 +7,7 @@
#include "IPrimaryScreen.h"
class CMSWindowsPrimaryScreen : public CMSWindowsScreen, public IPrimaryScreen {
public:
public:
typedef bool (CMSWindowsPrimaryScreen::*HookMethod)(int, WPARAM, LPARAM);
CMSWindowsPrimaryScreen();
@ -27,14 +27,14 @@ class CMSWindowsPrimaryScreen : public CMSWindowsScreen, public IPrimaryScreen {
virtual SInt32 getJumpZoneSize() const;
virtual void getClipboard(IClipboard*) const;
protected:
protected:
// CMSWindowsScreen overrides
virtual bool onPreTranslate(MSG*);
virtual LRESULT onEvent(HWND, UINT, WPARAM, LPARAM);
virtual void onOpenDisplay();
virtual void onCloseDisplay();
private:
private:
void doEnter();
void nextMark();
@ -43,7 +43,7 @@ class CMSWindowsPrimaryScreen : public CMSWindowsScreen, public IPrimaryScreen {
KeyModifierMask* maskOut) const;
ButtonID mapButton(WPARAM button) const;
private:
private:
CServer* m_server;
bool m_active;
HWND m_window;

View File

@ -6,7 +6,7 @@
#include <map>
class CScreenMap {
public:
public:
enum EDirection { kLeft, kRight, kTop, kBottom,
kFirstDirection = kLeft, kLastDirection = kBottom };
enum EDirectionMask { kLeftMask = 1, kRightMask = 2,
@ -38,9 +38,9 @@ class CScreenMap {
// get the name of a direction (for debugging)
static const char* dirName(EDirection);
private:
private:
class CCell {
public:
public:
CString m_neighbor[kLastDirection - kFirstDirection + 1];
};
typedef std::map<CString, CCell> CCellMap;

View File

@ -606,7 +606,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
// find destination screen, adjusting x or y (but not both)
switch (srcSide) {
case CScreenMap::kLeft:
case CScreenMap::kLeft:
while (dst != NULL) {
lastGoodScreen = dst;
w = lastGoodScreen->m_width;
@ -620,7 +620,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
}
break;
case CScreenMap::kRight:
case CScreenMap::kRight:
while (dst != NULL) {
lastGoodScreen = dst;
x -= w;
@ -634,7 +634,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
}
break;
case CScreenMap::kTop:
case CScreenMap::kTop:
while (dst != NULL) {
lastGoodScreen = dst;
w = lastGoodScreen->m_width;
@ -648,7 +648,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
}
break;
case CScreenMap::kBottom:
case CScreenMap::kBottom:
while (dst != NULL) {
lastGoodScreen = dst;
y -= h;
@ -675,25 +675,25 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
if (lastGoodScreen->m_protocol == NULL) {
const CString dstName(lastGoodScreen->m_name);
switch (srcSide) {
case CScreenMap::kLeft:
case CScreenMap::kLeft:
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kRight).empty() &&
x > w - 1 - lastGoodScreen->m_zoneSize)
x = w - 1 - lastGoodScreen->m_zoneSize;
break;
case CScreenMap::kRight:
case CScreenMap::kRight:
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kLeft).empty() &&
x < lastGoodScreen->m_zoneSize)
x = lastGoodScreen->m_zoneSize;
break;
case CScreenMap::kTop:
case CScreenMap::kTop:
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kBottom).empty() &&
y > h - 1 - lastGoodScreen->m_zoneSize)
y = h - 1 - lastGoodScreen->m_zoneSize;
break;
case CScreenMap::kBottom:
case CScreenMap::kBottom:
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kTop).empty() &&
y < lastGoodScreen->m_zoneSize)
y = lastGoodScreen->m_zoneSize;
@ -715,8 +715,8 @@ void CServer::mapPosition(CScreenInfo* src,
srcSide <= CScreenMap::kLastDirection);
switch (srcSide) {
case CScreenMap::kLeft:
case CScreenMap::kRight:
case CScreenMap::kLeft:
case CScreenMap::kRight:
if (y < 0)
y = 0;
else if (y >= src->m_height)
@ -727,8 +727,8 @@ void CServer::mapPosition(CScreenInfo* src,
(src->m_height - 1));
break;
case CScreenMap::kTop:
case CScreenMap::kBottom:
case CScreenMap::kTop:
case CScreenMap::kBottom:
if (x < 0)
x = 0;
else if (x >= src->m_width)

View File

@ -19,7 +19,7 @@ class ISecurityFactory;
class IPrimaryScreen;
class CServer {
public:
public:
CServer();
~CServer();
@ -64,36 +64,36 @@ class CServer {
// get the sides of the primary screen that have neighbors
UInt32 getActivePrimarySides() const;
protected:
protected:
bool onCommandKey(KeyID, KeyModifierMask, bool down);
private:
private:
class CCleanupNote {
public:
public:
CCleanupNote(CServer*);
~CCleanupNote();
private:
private:
CServer* m_server;
};
class CConnectionNote {
public:
public:
CConnectionNote(CServer*, const CString&, IServerProtocol*);
~CConnectionNote();
private:
private:
bool m_pending;
CServer* m_server;
CString m_name;
};
class CScreenInfo {
public:
public:
CScreenInfo(const CString& name, IServerProtocol*);
~CScreenInfo();
public:
public:
CString m_name;
IServerProtocol* m_protocol;
SInt32 m_width, m_height;
@ -155,7 +155,7 @@ class CServer {
CScreenInfo* addConnection(const CString& name, IServerProtocol*);
void removeConnection(const CString& name);
private:
private:
typedef std::list<CThread*> CThreadList;
typedef std::map<CString, CScreenInfo*> CScreenList;
class CClipboardInfo {

View File

@ -9,7 +9,7 @@ class IInputStream;
class IOutputStream;
class CServerProtocol : public IServerProtocol {
public:
public:
CServerProtocol(CServer*, const CString& clientName,
IInputStream*, IOutputStream*);
~CServerProtocol();
@ -44,13 +44,13 @@ class CServerProtocol : public IServerProtocol {
virtual void sendMouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
virtual void sendMouseWheel(SInt32 delta) = 0;
protected:
protected:
//IServerProtocol overrides
virtual void recvInfo() = 0;
virtual void recvClipboard() = 0;
virtual void recvGrabClipboard() = 0;
private:
private:
CServer* m_server;
CString m_client;
IInputStream* m_input;

View File

@ -4,7 +4,7 @@
#include "CServerProtocol.h"
class CServerProtocol1_0 : public CServerProtocol {
public:
public:
CServerProtocol1_0(CServer*, const CString&, IInputStream*, IOutputStream*);
~CServerProtocol1_0();
@ -29,7 +29,7 @@ class CServerProtocol1_0 : public CServerProtocol {
virtual void sendMouseMove(SInt32 xAbs, SInt32 yAbs);
virtual void sendMouseWheel(SInt32 delta);
protected:
protected:
// IServerProtocol overrides
virtual void recvInfo();
virtual void recvClipboard();

View File

@ -70,16 +70,16 @@ static LRESULT CALLBACK mouseHook(int code, WPARAM wParam, LPARAM lParam)
if (code >= 0) {
if (g_relay) {
switch (wParam) {
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
PostMessage(g_hwnd, SYNERGY_MSG_MOUSE_BUTTON, wParam, 0);
return 1;
case WM_MOUSEMOVE: {
case WM_MOUSEMOVE: {
const MOUSEHOOKSTRUCT* info = (const MOUSEHOOKSTRUCT*)lParam;
SInt32 x = (SInt32)info->pt.x;
SInt32 y = (SInt32)info->pt.y;
@ -100,7 +100,7 @@ static LRESULT CALLBACK mouseHook(int code, WPARAM wParam, LPARAM lParam)
// relay the motion
PostMessage(g_hwnd, SYNERGY_MSG_MOUSE_MOVE, x, y);
return 1;
}
}
}
}
else {

View File

@ -36,21 +36,21 @@ void CXWindowsPrimaryScreen::run()
// handle event
switch (xevent.type) {
case CreateNotify: {
case CreateNotify: {
// select events on new window
CDisplayLock display(this);
selectEvents(display, xevent.xcreatewindow.window);
break;
}
}
case MappingNotify: {
case MappingNotify: {
// keyboard mapping changed
CDisplayLock display(this);
XRefreshKeyboardMapping(&xevent.xmapping);
break;
}
}
case KeyPress: {
case KeyPress: {
log((CLOG_DEBUG1 "event: KeyPress code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
const KeyID key = mapKey(&xevent.xkey);
@ -60,11 +60,11 @@ void CXWindowsPrimaryScreen::run()
m_server->onKeyUp(key, mask | KeyModifierCapsLock);
}
break;
}
}
// FIXME -- simulate key repeat. X sends press/release for
// repeat. must detect auto repeat and use kKeyRepeat.
case KeyRelease: {
// FIXME -- simulate key repeat. X sends press/release for
// repeat. must detect auto repeat and use kKeyRepeat.
case KeyRelease: {
log((CLOG_DEBUG1 "event: KeyRelease code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
const KeyID key = mapKey(&xevent.xkey);
@ -74,27 +74,27 @@ void CXWindowsPrimaryScreen::run()
m_server->onKeyUp(key, mask);
}
break;
}
}
case ButtonPress: {
case ButtonPress: {
log((CLOG_DEBUG1 "event: ButtonPress button=%d", xevent.xbutton.button));
const ButtonID button = mapButton(xevent.xbutton.button);
if (button != kButtonNone) {
m_server->onMouseDown(button);
}
break;
}
}
case ButtonRelease: {
case ButtonRelease: {
log((CLOG_DEBUG1 "event: ButtonRelease button=%d", xevent.xbutton.button));
const ButtonID button = mapButton(xevent.xbutton.button);
if (button != kButtonNone) {
m_server->onMouseUp(button);
}
break;
}
}
case MotionNotify: {
case MotionNotify: {
log((CLOG_DEBUG2 "event: MotionNotify %d,%d", xevent.xmotion.x_root, xevent.xmotion.y_root));
SInt32 x, y;
if (!m_active) {
@ -129,9 +129,9 @@ void CXWindowsPrimaryScreen::run()
m_server->onMouseMoveSecondary(x, y);
}
break;
}
}
case SelectionClear:
case SelectionClear:
// we just lost the selection. that means someone else
// grabbed the selection so this screen is now the
// selection owner. report that to the server.
@ -142,7 +142,7 @@ void CXWindowsPrimaryScreen::run()
}
break;
case SelectionNotify:
case SelectionNotify:
// notification of selection transferred. we shouldn't
// get this here because we handle them in the selection
// retrieval methods. we'll just delete the property
@ -153,7 +153,7 @@ void CXWindowsPrimaryScreen::run()
}
break;
case SelectionRequest:
case SelectionRequest:
// somebody is asking for clipboard data
if (xevent.xselectionrequest.owner == m_window) {
addClipboardRequest(m_window,
@ -179,7 +179,7 @@ void CXWindowsPrimaryScreen::run()
}
break;
case PropertyNotify:
case PropertyNotify:
// clipboard transfers involve property changes so forward
// the event to the superclass. we only care about the
// deletion of properties.
@ -190,7 +190,7 @@ void CXWindowsPrimaryScreen::run()
}
break;
case DestroyNotify:
case DestroyNotify:
// looks like one of the windows that requested a clipboard
// transfer has gone bye-bye.
destroyClipboardRequest(xevent.xdestroywindow.window);

View File

@ -7,7 +7,7 @@
#include "IPrimaryScreen.h"
class CXWindowsPrimaryScreen : public CXWindowsScreen, public IPrimaryScreen {
public:
public:
CXWindowsPrimaryScreen();
virtual ~CXWindowsPrimaryScreen();
@ -25,13 +25,13 @@ class CXWindowsPrimaryScreen : public CXWindowsScreen, public IPrimaryScreen {
virtual SInt32 getJumpZoneSize() const;
virtual void getClipboard(ClipboardID, IClipboard*) const;
protected:
protected:
// CXWindowsScreen overrides
virtual void onOpenDisplay();
virtual void onCloseDisplay();
virtual long getEventMask(Window) const;
private:
private:
void selectEvents(Display*, Window) const;
void warpCursorNoLock(Display*,
SInt32 xAbsolute, SInt32 yAbsolute);
@ -40,7 +40,7 @@ class CXWindowsPrimaryScreen : public CXWindowsScreen, public IPrimaryScreen {
KeyID mapKey(XKeyEvent*) const;
ButtonID mapButton(unsigned int button) const;
private:
private:
CServer* m_server;
bool m_active;
Window m_window;

View File

@ -9,7 +9,7 @@
#include "CString.h"
class CClipboard : public IClipboard {
public:
public:
CClipboard();
virtual ~CClipboard();
@ -40,11 +40,11 @@ class CClipboard : public IClipboard {
static void copy(IClipboard* dst, const IClipboard* src);
static void copy(IClipboard* dst, const IClipboard* src, Time);
private:
private:
UInt32 readUInt32(const char*) const;
void writeUInt32(CString*, UInt32) const;
private:
private:
Time m_time;
bool m_added[kNumFormats];
CString m_data[kNumFormats];

View File

@ -6,7 +6,7 @@
#include "CMutex.h"
class CInputPacketStream : public CInputStreamFilter {
public:
public:
CInputPacketStream(IInputStream*, bool adoptStream = true);
~CInputPacketStream();
@ -19,11 +19,11 @@ class CInputPacketStream : public CInputStreamFilter {
virtual UInt32 read(void*, UInt32 maxCount);
virtual UInt32 getSize() const;
private:
private:
UInt32 getSizeNoLock() const;
bool hasFullMessage() const;
private:
private:
CMutex m_mutex;
mutable UInt32 m_size;
mutable CBufferedInputStream m_buffer;

View File

@ -53,11 +53,11 @@ void CMSWindowsClipboard::add(
const UINT win32Format = convertFormatToWin32(format);
HANDLE win32Data;
switch (win32Format) {
case CF_TEXT:
case CF_TEXT:
win32Data = convertTextToWin32(data);
break;
default:
default:
win32Data = NULL;
break;
}
@ -95,7 +95,7 @@ CString CMSWindowsClipboard::get(EFormat format) const
if (win32Data != NULL) {
// convert the data
switch (win32Format) {
case CF_TEXT:
case CF_TEXT:
data = convertTextFromWin32(win32Data);
}
}
@ -110,10 +110,10 @@ UINT CMSWindowsClipboard::convertFormatToWin32(
EFormat format) const
{
switch (format) {
case kText:
case kText:
return CF_TEXT;
default:
default:
return 0;
}
}

View File

@ -5,7 +5,7 @@
#include <windows.h>
class CMSWindowsClipboard : public IClipboard {
public:
public:
CMSWindowsClipboard(HWND window);
virtual ~CMSWindowsClipboard();
@ -16,12 +16,12 @@ class CMSWindowsClipboard : public IClipboard {
virtual bool has(EFormat) const;
virtual CString get(EFormat) const;
private:
private:
UINT convertFormatToWin32(EFormat) const;
HANDLE convertTextToWin32(const CString& data) const;
CString convertTextFromWin32(HANDLE) const;
private:
private:
HWND m_window;
};

View File

@ -10,7 +10,7 @@ class CString;
class CThread;
class CMSWindowsScreen {
public:
public:
CMSWindowsScreen();
virtual ~CMSWindowsScreen();
@ -18,7 +18,7 @@ class CMSWindowsScreen {
static void init(HINSTANCE);
protected:
protected:
// runs an event loop and returns when WM_QUIT is received
void doRun();
@ -62,10 +62,10 @@ class CMSWindowsScreen {
// called by closeDisplay() to
virtual void onCloseDisplay() = 0;
private:
private:
static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
private:
private:
static HINSTANCE s_instance;
ATOM m_class;
HICON m_icon;

View File

@ -4,7 +4,7 @@
#include "COutputStreamFilter.h"
class COutputPacketStream : public COutputStreamFilter {
public:
public:
COutputPacketStream(IOutputStream*, bool adoptStream = true);
~COutputPacketStream();

View File

@ -64,7 +64,7 @@ void CProtocolUtil::readf(IInputStream* stream,
++fmt;
UInt32 len = eatLength(&fmt);
switch (*fmt) {
case 'i': {
case 'i': {
// check for valid length
assert(len == 1 || len == 2 || len == 4);
@ -75,13 +75,13 @@ void CProtocolUtil::readf(IInputStream* stream,
// convert it
void* v = va_arg(args, void*);
switch (len) {
case 1:
case 1:
// 1 byte integer
*reinterpret_cast<UInt8*>(v) = buffer[0];
log((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt8*>(v), *reinterpret_cast<UInt8*>(v)));
break;
case 2:
case 2:
// 2 byte integer
*reinterpret_cast<UInt16*>(v) =
(static_cast<UInt16>(buffer[0]) << 8) |
@ -89,7 +89,7 @@ void CProtocolUtil::readf(IInputStream* stream,
log((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt16*>(v), *reinterpret_cast<UInt16*>(v)));
break;
case 4:
case 4:
// 4 byte integer
*reinterpret_cast<UInt32*>(v) =
(static_cast<UInt32>(buffer[0]) << 24) |
@ -100,9 +100,9 @@ void CProtocolUtil::readf(IInputStream* stream,
break;
}
break;
}
}
case 's': {
case 's': {
assert(len == 0);
// read the string length
@ -146,13 +146,13 @@ void CProtocolUtil::readf(IInputStream* stream,
delete[] sBuffer;
}
break;
}
}
case '%':
case '%':
assert(len == 0);
break;
default:
default:
assert(0 && "invalid format specifier");
}
@ -188,29 +188,29 @@ UInt32 CProtocolUtil::getLength(
++fmt;
UInt32 len = eatLength(&fmt);
switch (*fmt) {
case 'i':
case 'i':
assert(len == 1 || len == 2 || len == 4);
(void)va_arg(args, UInt32);
break;
case 's':
case 's':
assert(len == 0);
len = (va_arg(args, CString*))->size() + 4;
(void)va_arg(args, UInt8*);
break;
case 'S':
case 'S':
assert(len == 0);
len = va_arg(args, UInt32) + 4;
(void)va_arg(args, UInt8*);
break;
case '%':
case '%':
assert(len == 0);
len = 1;
break;
default:
default:
assert(0 && "invalid format specifier");
}
@ -238,21 +238,21 @@ void CProtocolUtil::writef(void* buffer,
++fmt;
UInt32 len = eatLength(&fmt);
switch (*fmt) {
case 'i': {
case 'i': {
const UInt32 v = va_arg(args, UInt32);
switch (len) {
case 1:
case 1:
// 1 byte integer
*dst++ = static_cast<UInt8>(v & 0xff);
break;
case 2:
case 2:
// 2 byte integer
*dst++ = static_cast<UInt8>((v >> 8) & 0xff);
*dst++ = static_cast<UInt8>( v & 0xff);
break;
case 4:
case 4:
// 4 byte integer
*dst++ = static_cast<UInt8>((v >> 24) & 0xff);
*dst++ = static_cast<UInt8>((v >> 16) & 0xff);
@ -260,14 +260,14 @@ void CProtocolUtil::writef(void* buffer,
*dst++ = static_cast<UInt8>( v & 0xff);
break;
default:
default:
assert(0 && "invalid integer format length");
return;
}
break;
}
}
case 's': {
case 's': {
assert(len == 0);
const CString* src = va_arg(args, CString*);
const UInt32 len = (src != NULL) ? src->size() : 0;
@ -280,9 +280,9 @@ void CProtocolUtil::writef(void* buffer,
dst += len;
}
break;
}
}
case 'S': {
case 'S': {
assert(len == 0);
const UInt32 len = va_arg(args, UInt32);
const UInt8* src = va_arg(args, UInt8*);
@ -293,14 +293,14 @@ void CProtocolUtil::writef(void* buffer,
memcpy(dst, src, len);
dst += len;
break;
}
}
case '%':
case '%':
assert(len == 0);
*dst++ = '%';
break;
default:
default:
assert(0 && "invalid format specifier");
}
@ -321,17 +321,17 @@ UInt32 CProtocolUtil::eatLength(const char** pfmt)
for (;;) {
UInt32 d;
switch (*fmt) {
case '0': d = 0; break;
case '1': d = 1; break;
case '2': d = 2; break;
case '3': d = 3; break;
case '4': d = 4; break;
case '5': d = 5; break;
case '6': d = 6; break;
case '7': d = 7; break;
case '8': d = 8; break;
case '9': d = 9; break;
default: *pfmt = fmt; return n;
case '0': d = 0; break;
case '1': d = 1; break;
case '2': d = 2; break;
case '3': d = 3; break;
case '4': d = 4; break;
case '5': d = 5; break;
case '6': d = 6; break;
case '7': d = 7; break;
case '8': d = 8; break;
case '9': d = 9; break;
default: *pfmt = fmt; return n;
}
n = 10 * n + d;
++fmt;

View File

@ -9,7 +9,7 @@ class IInputStream;
class IOutputStream;
class CProtocolUtil {
public:
public:
// write formatted binary data to a stream. fmt consists of
// regular characters and format specifiers. format specifiers
// begin with %. all characters not part of a format specifier
@ -37,7 +37,7 @@ class CProtocolUtil {
static void readf(IInputStream*,
const char* fmt, ...);
private:
private:
static UInt32 getLength(const char* fmt, va_list);
static void writef(void*, const char* fmt, va_list);
static UInt32 eatLength(const char** fmt);
@ -45,7 +45,7 @@ class CProtocolUtil {
};
class XIOReadMismatch : public XIO {
public:
public:
// XBase overrides
virtual CString getWhat() const throw();
};

View File

@ -4,7 +4,7 @@
#include "ISocketFactory.h"
class CTCPSocketFactory : public ISocketFactory {
public:
public:
CTCPSocketFactory();
virtual ~CTCPSocketFactory();

View File

@ -4,7 +4,7 @@
#include "IClipboard.h"
class CXWindowsClipboard : public IClipboard {
public:
public:
CXWindowsClipboard();
virtual ~CXWindowsClipboard();

View File

@ -403,19 +403,19 @@ bool CXWindowsScreen::getDisplayClipboard(
// transferred. use it as a hint to size our buffer.
UInt32 size;
switch (datumSize) {
case 8:
case 8:
size = *(reinterpret_cast<const UInt8*>(data.data()));
break;
case 16:
case 16:
size = *(reinterpret_cast<const UInt16*>(data.data()));
break;
case 32:
case 32:
size = *(reinterpret_cast<const UInt32*>(data.data()));
break;
default:
default:
assert(0 && "invalid datum size");
}

View File

@ -12,19 +12,19 @@
class CString;
class CXWindowsScreen {
public:
public:
CXWindowsScreen();
virtual ~CXWindowsScreen();
protected:
protected:
class CDisplayLock {
public:
public:
CDisplayLock(const CXWindowsScreen*);
~CDisplayLock();
operator Display*() const;
private:
private:
const CMutex* m_mutex;
Display* m_display;
};
@ -104,14 +104,14 @@ class CXWindowsScreen {
// get the X event mask required by the subclass for the given window
virtual long getEventMask(Window) const = 0;
private:
private:
struct CPropertyNotifyInfo {
public:
public:
Window m_window;
Atom m_property;
};
struct CClipboardRequest {
public:
public:
CString m_data;
UInt32 m_sent;
Window m_requestor;
@ -147,7 +147,7 @@ class CXWindowsScreen {
bool wasOwnedAtTime(ClipboardID, Window, Time) const;
Time getCurrentTimeNoLock(Window) const;
private:
private:
class CClipboardInfo {
public:
CClipboardInfo();

View File

@ -7,7 +7,7 @@
class CString;
class IClipboard : public IInterface {
public:
public:
// timestamp type. timestamps are in milliseconds from some
// arbitrary starting time. timestamps will wrap around to 0
// after about 49 3/4 days.

View File

@ -9,7 +9,7 @@ class CServer;
class IClipboard;
class IPrimaryScreen : public IInterface {
public:
public:
// manipulators
// enter the screen's message loop. this returns when it detects

View File

@ -11,7 +11,7 @@ class CClient;
class IClipboard;
class ISecondaryScreen : public IInterface {
public:
public:
// manipulators
// enter the screen's message loop. this returns when it detects

View File

@ -11,7 +11,7 @@
class IClipboard;
class IServerProtocol : public IInterface {
public:
public:
// manipulators
// process messages from the client and insert the appropriate
@ -39,7 +39,7 @@ class IServerProtocol : public IInterface {
// accessors
protected:
protected:
// manipulators
virtual void recvInfo() = 0;

View File

@ -8,7 +8,7 @@ class ISocket;
class IListenSocket;
class ISocketFactory : public IInterface {
public:
public:
// manipulators
// accessors

View File

@ -7,13 +7,13 @@ class XSynergy : public XBase { };
// client is misbehaving
class XBadClient : public XSynergy {
protected:
protected:
virtual CString getWhat() const throw();
};
// client has incompatible version
class XIncompatibleClient : public XSynergy {
public:
public:
XIncompatibleClient(int major, int minor);
// manipulators
@ -23,10 +23,10 @@ class XIncompatibleClient : public XSynergy {
int getMajor() const throw();
int getMinor() const throw();
protected:
protected:
virtual CString getWhat() const throw();
private:
private:
int m_major;
int m_minor;
};