FKeyboard now uses references for keyboard buffer passing

This commit is contained in:
Markus Gans 2018-10-11 03:46:37 +02:00
parent a274dd8b5e
commit fea78841b9
8 changed files with 259 additions and 215 deletions

View File

@ -1,3 +1,6 @@
2018-10-11 Markus Gans <guru.mail@muenster.de>
* FKeyboard now uses references for keyboard buffer passing
2018-10-09 Markus Gans <guru.mail@muenster.de>
* Terminal detection for newer vte libraries (>= 0.53.0)

View File

@ -565,9 +565,8 @@ inline void FApplication::performKeyboardAction()
case fc::Fkey_mouse:
if ( mouse )
{
char* buffer = keyboard->getKeyBuffer();
int buffer_size = keyboard->getKeyBufferSize();
mouse->setRawData (FMouse::x11, buffer, buffer_size);
FKeyboard::keybuffer& buffer = keyboard->getKeyBuffer();
mouse->setRawData (FMouse::x11, buffer);
keyboard->unprocessedInput() = mouse->isInputDataPending();
processMouseEvent();
}
@ -576,9 +575,8 @@ inline void FApplication::performKeyboardAction()
case fc::Fkey_extended_mouse:
if ( mouse )
{
char* buffer = keyboard->getKeyBuffer();
int buffer_size = keyboard->getKeyBufferSize();
mouse->setRawData (FMouse::sgr, buffer, buffer_size);
FKeyboard::keybuffer& buffer = keyboard->getKeyBuffer();
mouse->setRawData (FMouse::sgr, buffer);
keyboard->unprocessedInput() = mouse->isInputDataPending();
processMouseEvent();
}
@ -587,9 +585,8 @@ inline void FApplication::performKeyboardAction()
case fc::Fkey_urxvt_mouse:
if ( mouse )
{
char* buffer = keyboard->getKeyBuffer();
int buffer_size = keyboard->getKeyBufferSize();
mouse->setRawData (FMouse::urxvt, buffer, buffer_size);
FKeyboard::keybuffer& buffer = keyboard->getKeyBuffer();
mouse->setRawData (FMouse::urxvt, buffer);
keyboard->unprocessedInput() = mouse->isInputDataPending();
processMouseEvent();
}

View File

@ -70,7 +70,6 @@ FKeyboard::FKeyboard()
: key(0)
, fifo_offset(0)
, fifo_in_use(false)
, fifo_buf_size(sizeof(fifo_buf))
, stdin_status_flags(0)
, input_data_pending(false)
, utf8_input(false)
@ -92,8 +91,8 @@ FKeyboard::FKeyboard()
std::abort();
// Initialize arrays with '\0'
std::fill_n (k_buf, sizeof(k_buf), '\0');
std::fill_n (fifo_buf, fifo_buf_size, '\0');
std::fill_n (read_buf, READ_BUF_SIZE, '\0');
std::fill_n (fifo_buf, FIFO_BUF_SIZE, '\0');
}
//----------------------------------------------------------------------
@ -159,7 +158,7 @@ void FKeyboard::clearKeyBuffer()
fifo_offset = 0;
key = 0;
std::fill_n (fifo_buf, fifo_buf_size, '\0');
std::fill_n (fifo_buf, FIFO_BUF_SIZE, '\0');
fifo_in_use = false;
}
@ -230,7 +229,7 @@ inline int FKeyboard::getTermcapKey()
{
// Looking for termcap key strings in the buffer
assert ( fifo_buf_size > 0 );
assert ( FIFO_BUF_SIZE > 0 );
if ( ! key_map )
return -1;
@ -243,12 +242,12 @@ inline int FKeyboard::getTermcapKey()
if ( k && std::strncmp(k, fifo_buf, uInt(len)) == 0 ) // found
{
int n;
std::size_t n;
for (n = len; n < fifo_buf_size; n++) // Remove founded entry
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove founded entry
fifo_buf[n - len] = fifo_buf[n];
for (n = n - len; n < fifo_buf_size; n++) // Fill rest with '\0'
for (n = n - len; n < FIFO_BUF_SIZE; n++) // Fill rest with '\0'
fifo_buf[n] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0');
@ -264,7 +263,7 @@ inline int FKeyboard::getMetaKey()
{
// Looking for meta key strings in the buffer
assert ( fifo_buf_size > 0 );
assert ( FIFO_BUF_SIZE > 0 );
for (int i = 0; fc::Fmetakey[i].string[0] != 0; i++)
{
@ -273,7 +272,7 @@ inline int FKeyboard::getMetaKey()
if ( std::strncmp(kmeta, fifo_buf, uInt(len)) == 0 ) // found
{
int n;
std::size_t n;
if ( len == 2 && ( fifo_buf[1] == 'O'
|| fifo_buf[1] == '['
@ -283,10 +282,10 @@ inline int FKeyboard::getMetaKey()
return NEED_MORE_DATA;
}
for (n = len; n < fifo_buf_size; n++) // Remove founded entry
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove founded entry
fifo_buf[n - len] = fifo_buf[n];
for (n = n - len; n < fifo_buf_size; n++) // Fill rest with '\0'
for (n = n - len; n < FIFO_BUF_SIZE; n++) // Fill rest with '\0'
fifo_buf[n] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0');
@ -303,7 +302,8 @@ inline int FKeyboard::getSingleKey()
// Looking for single key code in the buffer
uChar firstchar = uChar(fifo_buf[0]);
int keycode, n, len;
std::size_t n;
int keycode, len;
len = 1;
// Look for a utf-8 character
@ -326,10 +326,10 @@ inline int FKeyboard::getSingleKey()
else
keycode = uChar(fifo_buf[0] & 0xff);
for (n = len; n < fifo_buf_size; n++) // Remove the key from the buffer front
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove the key from the buffer front
fifo_buf[n - len] = fifo_buf[n];
for (n = n - len; n < fifo_buf_size; n++) // Fill the rest with '\0' bytes
for (n = n - len; n < FIFO_BUF_SIZE; n++) // Fill the rest with '\0' bytes
fifo_buf[n] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0');
@ -424,7 +424,7 @@ inline ssize_t FKeyboard::readKey()
{
ssize_t bytes;
setNonBlockingInput();
bytes = read(FTermios::getStdIn(), &k_buf, sizeof(k_buf) - 1);
bytes = read(FTermios::getStdIn(), &read_buf, READ_BUF_SIZE - 1);
unsetNonBlockingInput();
return bytes;
}
@ -437,11 +437,11 @@ void FKeyboard::parseKeyBuffer()
while ( (bytesread = readKey()) > 0 )
{
if ( bytesread + fifo_offset <= fifo_buf_size )
if ( bytesread + fifo_offset <= int(FIFO_BUF_SIZE) )
{
for (int i = 0; i < bytesread; i++)
{
fifo_buf[fifo_offset] = k_buf[i];
fifo_buf[fifo_offset] = read_buf[i];
fifo_offset++;
}
@ -474,7 +474,7 @@ void FKeyboard::parseKeyBuffer()
key = 0;
}
std::fill_n (k_buf, sizeof(k_buf), '\0');
std::fill_n (read_buf, READ_BUF_SIZE, '\0');
}
//----------------------------------------------------------------------

View File

@ -270,7 +270,7 @@ bool FMouseGPM::hasData()
}
//----------------------------------------------------------------------
void FMouseGPM::setRawData (char[], int)
void FMouseGPM::setRawData (FKeyboard::keybuffer&)
{ }
//----------------------------------------------------------------------
@ -490,12 +490,13 @@ bool FMouseX11::hasData()
}
//----------------------------------------------------------------------
void FMouseX11::setRawData (char fifo_buf[], int fifo_buf_size)
void FMouseX11::setRawData (FKeyboard::keybuffer& fifo_buf)
{
// Import the X11 xterm mouse protocol (SGR-Mode) raw mouse data
static const int len = 6;
int n;
static const std::size_t len = 6;
std::size_t fifo_buf_size = sizeof(fifo_buf);
std::size_t n;
x11_mouse[0] = fifo_buf[3];
x11_mouse[1] = fifo_buf[4];
x11_mouse[2] = fifo_buf[5];
@ -691,12 +692,13 @@ bool FMouseSGR::hasData()
}
//----------------------------------------------------------------------
void FMouseSGR::setRawData (char fifo_buf[], int fifo_buf_size)
void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf)
{
// Import the X11 xterm mouse protocol (SGR-Mode) raw mouse data
int len = int(std::strlen(fifo_buf));
int n = 3;
std::size_t fifo_buf_size = sizeof(fifo_buf);
std::size_t len = std::strlen(fifo_buf);
std::size_t n = 3;
while ( n < len && n < fifo_buf_size )
{
@ -944,12 +946,13 @@ bool FMouseUrxvt::hasData()
}
//----------------------------------------------------------------------
void FMouseUrxvt::setRawData (char fifo_buf[], int fifo_buf_size)
void FMouseUrxvt::setRawData (FKeyboard::keybuffer& fifo_buf)
{
// Import the X11 xterm mouse protocol (Urxvt-Mode) raw mouse data
int len = int(std::strlen(fifo_buf));
int n = 2;
std::size_t fifo_buf_size = sizeof(fifo_buf);
std::size_t len = std::strlen(fifo_buf);
std::size_t n = 2;
while ( n < len && n < fifo_buf_size )
{
@ -1535,13 +1538,12 @@ void FMouseControl::disable()
//----------------------------------------------------------------------
void FMouseControl::setRawData ( FMouse::mouse_type mt
, char fifo_buf[]
, int fifo_buf_size )
, FKeyboard::keybuffer& fifo_buf)
{
FMouse* mouse = mouse_protocol[mt];
if ( mouse )
mouse->setRawData (fifo_buf, fifo_buf_size);
mouse->setRawData (fifo_buf);
}
//----------------------------------------------------------------------

View File

@ -83,6 +83,12 @@ class FKeyboardCommand
class FKeyboard
{
public:
// Constants
static const std::size_t FIFO_BUF_SIZE = 512;
// Typedef
typedef char keybuffer[FIFO_BUF_SIZE];
// Constructor
FKeyboard();
@ -93,8 +99,7 @@ class FKeyboard
virtual const char* getClassName() const;
int getKey();
const FString getKeyName (int);
char* getKeyBuffer();
int getKeyBufferSize();
keybuffer& getKeyBuffer();
timeval* getKeyPressedTime();
// Mutators
@ -127,6 +132,7 @@ class FKeyboard
private:
// Constants
static const int NEED_MORE_DATA = -1;
static const std::size_t READ_BUF_SIZE = 1024;
// Disable copy constructor
FKeyboard (const FKeyboard&);
@ -161,11 +167,10 @@ class FKeyboard
// Data Members
int key;
char k_buf[1024];
char fifo_buf[512];
char read_buf[READ_BUF_SIZE];
char fifo_buf[FIFO_BUF_SIZE];
int fifo_offset;
bool fifo_in_use;
int fifo_buf_size;
int stdin_status_flags;
static long key_timeout;
bool input_data_pending;
@ -195,12 +200,9 @@ inline const char* FKeyboard::getClassName() const
inline int FKeyboard::getKey()
{ return key; }
inline char* FKeyboard::getKeyBuffer()
{ return fifo_buf; }
//----------------------------------------------------------------------
inline int FKeyboard::getKeyBufferSize()
{ return fifo_buf_size; }
inline FKeyboard::keybuffer& FKeyboard::getKeyBuffer()
{ return fifo_buf; }
//----------------------------------------------------------------------
inline timeval* FKeyboard::getKeyPressedTime()

View File

@ -64,6 +64,7 @@
#include <map>
#include "final/fconfig.h"
#include "final/fkeyboard.h"
#include "final/fpoint.h"
#include "final/ftypes.h"
@ -135,7 +136,7 @@ class FMouse
// Methods
static FMouse* createMouseObject (mouse_type);
virtual void setRawData (char[], int) = 0;
virtual void setRawData (FKeyboard::keybuffer&) = 0;
virtual void processEvent (struct timeval*) = 0;
protected:
@ -211,7 +212,7 @@ class FMouseGPM : public FMouse
bool isGpmMouseEnabled();
// Methods
virtual void setRawData (char[], int);
virtual void setRawData (FKeyboard::keybuffer&);
virtual void processEvent (struct timeval*);
bool gpmMouse (bool);
bool enableGpmMouse();
@ -276,7 +277,7 @@ class FMouseX11 : public FMouse
virtual bool hasData();
// Methods
virtual void setRawData (char[], int);
virtual void setRawData (FKeyboard::keybuffer&);
virtual void processEvent (struct timeval*);
private:
@ -339,7 +340,7 @@ class FMouseSGR : public FMouse
virtual bool hasData();
// Methods
virtual void setRawData (char[], int);
virtual void setRawData (FKeyboard::keybuffer&);
virtual void processEvent (struct timeval*);
private:
@ -402,7 +403,7 @@ class FMouseUrxvt : public FMouse
virtual bool hasData();
// Methods
virtual void setRawData (char[], int);
virtual void setRawData (FKeyboard::keybuffer&);
virtual void processEvent (struct timeval*);
private:
@ -492,8 +493,8 @@ class FMouseControl
// Methods
void enable();
void disable();
virtual void setRawData (FMouse::mouse_type, char[], int);
virtual void setRawData ( FMouse::mouse_type
, FKeyboard::keybuffer& );
virtual void processEvent (struct timeval* time);
bool getGpmKeyPressed (bool);
void drawGpmPointer();

View File

@ -310,14 +310,14 @@ void FKeyboardTest::classNameTest()
void FKeyboardTest::noArgumentTest()
{
CPPUNIT_ASSERT ( keyboard->getKey() == 0 );
char* buffer = keyboard->getKeyBuffer();
int size = keyboard->getKeyBufferSize();
finalcut::FKeyboard::keybuffer& buffer = keyboard->getKeyBuffer();
std::size_t size = sizeof(buffer);
CPPUNIT_ASSERT ( size == 512 );
CPPUNIT_ASSERT ( size == finalcut::FKeyboard::FIFO_BUF_SIZE );
CPPUNIT_ASSERT ( buffer[0] == 0 );
int sum = 0;
for (int i = 0; i < size; i++)
for (std::size_t i = 0; i < size; i++)
sum += int(buffer[i]);
CPPUNIT_ASSERT ( sum == 0 );

View File

@ -44,7 +44,7 @@ class FMouse_protected : public finalcut::FMouse
virtual bool hasData()
{ return true; }
virtual void setRawData (char[], int)
virtual void setRawData (finalcut::FKeyboard::keybuffer&)
{ }
virtual void processEvent (struct timeval*)
@ -263,8 +263,9 @@ void FMouseTest::x11MouseTest()
finalcut::FMouseX11 x11_mouse;
CPPUNIT_ASSERT ( ! x11_mouse.hasData() );
char rawdata1[] = { 0x1b, '[', 'M', 0x23, 0x50, 0x32, 0x40, 0x40 };
x11_mouse.setRawData (rawdata1, sizeof(rawdata1));
finalcut::FKeyboard::keybuffer rawdata1 = \
{ 0x1b, '[', 'M', 0x23, 0x50, 0x32, 0x40, 0x40 };
x11_mouse.setRawData (rawdata1);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 );
@ -290,14 +291,16 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
// The same input again
char raw[] = { 0x1b, '[', 'M', 0x23, 0x50, 0x32 };
x11_mouse.setRawData ( raw, sizeof(raw));
finalcut::FKeyboard::keybuffer raw = \
{ 0x1b, '[', 'M', 0x23, 0x50, 0x32 };
x11_mouse.setRawData (raw);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasEvent() );
// Left mouse button pressed
char rawdata2[] = { 0x1b, '[', 'M', 0x20, 0x21, 0x21 };
x11_mouse.setRawData (rawdata2, sizeof(rawdata2));
finalcut::FKeyboard::keybuffer rawdata2 = \
{ 0x1b, '[', 'M', 0x20, 0x21, 0x21 };
x11_mouse.setRawData (rawdata2);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( ! x11_mouse.isInputDataPending() );
x11_mouse.processEvent (&tv);
@ -319,8 +322,9 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
// Left mouse button released
char rawdata3[] = { 0x1b, '[', 'M', 0x23, 0x21, 0x21 };
x11_mouse.setRawData (rawdata3, sizeof(rawdata3));
finalcut::FKeyboard::keybuffer rawdata3 = \
{ 0x1b, '[', 'M', 0x23, 0x21, 0x21 };
x11_mouse.setRawData (rawdata3);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( ! x11_mouse.isInputDataPending() );
@ -343,8 +347,9 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
// Left mouse button pressed again (double click)
char rawdata4[] = { 0x1b, '[', 'M', 0x20, 0x21, 0x21 };
x11_mouse.setRawData (rawdata4, sizeof(rawdata4));
finalcut::FKeyboard::keybuffer rawdata4 = \
{ 0x1b, '[', 'M', 0x20, 0x21, 0x21 };
x11_mouse.setRawData (rawdata4);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( ! x11_mouse.isInputDataPending() );
@ -369,9 +374,10 @@ void FMouseTest::x11MouseTest()
// Middle mouse button
char rawdata5[] = { 0x1b, '[', 'M', 0x21, 0x21, 0x21
, 0x1b, '[', 'M', 0x23, 0x21, 0x21 };
x11_mouse.setRawData (rawdata5, sizeof(rawdata5));
finalcut::FKeyboard::keybuffer rawdata5 = \
{ 0x1b, '[', 'M', 0x21, 0x21, 0x21
, 0x1b, '[', 'M', 0x23, 0x21, 0x21 };
x11_mouse.setRawData (rawdata5);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() );
@ -394,16 +400,17 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata5, sizeof(rawdata5));
x11_mouse.setRawData (rawdata5);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! x11_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( ! x11_mouse.isMiddleButtonPressed() );
CPPUNIT_ASSERT ( x11_mouse.isMiddleButtonReleased() );
// Right mouse button
char rawdata6[] = { 0x1b, '[', 'M', 0x22, 0x21, 0x21
, 0x1b, '[', 'M', 0x23, 0x21, 0x21 };
x11_mouse.setRawData (rawdata6, sizeof(rawdata6));
finalcut::FKeyboard::keybuffer rawdata6 = \
{ 0x1b, '[', 'M', 0x22, 0x21, 0x21
, 0x1b, '[', 'M', 0x23, 0x21, 0x21 };
x11_mouse.setRawData (rawdata6);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() );
@ -426,16 +433,17 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata6, sizeof(rawdata6));
x11_mouse.setRawData (rawdata6);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! x11_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( ! x11_mouse.isRightButtonPressed() );
CPPUNIT_ASSERT ( x11_mouse.isRightButtonReleased() );
// Mouse wheel
char rawdata7[] = { 0x1b, '[', 'M', 0x60, 0x70, 0x39
, 0x1b, '[', 'M', 0x61, 0x70, 0x39 };
x11_mouse.setRawData (rawdata7, sizeof(rawdata7));
finalcut::FKeyboard::keybuffer rawdata7 = \
{ 0x1b, '[', 'M', 0x60, 0x70, 0x39
, 0x1b, '[', 'M', 0x61, 0x70, 0x39 };
x11_mouse.setRawData (rawdata7);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() );
@ -458,16 +466,17 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata7, sizeof(rawdata7));
x11_mouse.setRawData (rawdata7);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! x11_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( x11_mouse.isWheelDown() );
// Mouse move
char rawdata8[] = { 0x1b, '[', 'M', 0x20, 0x21, 0x21
, 0x1b, '[', 'M', 0x40, 0x23, 0x25
, 0x1b, '[', 'M', 0x23, 0x23, 0x25 };
x11_mouse.setRawData (rawdata8, sizeof(rawdata8));
finalcut::FKeyboard::keybuffer rawdata8 = \
{ 0x1b, '[', 'M', 0x20, 0x21, 0x21
, 0x1b, '[', 'M', 0x40, 0x23, 0x25
, 0x1b, '[', 'M', 0x23, 0x23, 0x25 };
x11_mouse.setRawData (rawdata8);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() );
@ -490,22 +499,23 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata8, sizeof(rawdata8));
x11_mouse.setRawData (rawdata8);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(3, 5) );
CPPUNIT_ASSERT ( x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata8, sizeof(rawdata8));
x11_mouse.setRawData (rawdata8);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(3, 5) );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
// Mouse + keyboard modifier key
char rawdata9[] = { 0x1b, '[', 'M', 0x24, 0x30, 0x40
, 0x1b, '[', 'M', 0x28, 0x30, 0x40
, 0x1b, '[', 'M', 0x30, 0x30, 0x40
, 0x1b, '[', 'M', 0x3c, 0x30, 0x40 };
x11_mouse.setRawData (rawdata9, sizeof(rawdata9));
finalcut::FKeyboard::keybuffer rawdata9 = \
{ 0x1b, '[', 'M', 0x24, 0x30, 0x40
, 0x1b, '[', 'M', 0x28, 0x30, 0x40
, 0x1b, '[', 'M', 0x30, 0x30, 0x40
, 0x1b, '[', 'M', 0x3c, 0x30, 0x40 };
x11_mouse.setRawData (rawdata9);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.isInputDataPending() );
@ -528,21 +538,21 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata9, sizeof(rawdata9));
x11_mouse.setRawData (rawdata9);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! x11_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( ! x11_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( x11_mouse.isMetaKeyPressed() );
x11_mouse.setRawData (rawdata9, sizeof(rawdata9));
x11_mouse.setRawData (rawdata9);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! x11_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( x11_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( ! x11_mouse.isMetaKeyPressed() );
x11_mouse.setRawData (rawdata9, sizeof(rawdata9));
x11_mouse.setRawData (rawdata9);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( x11_mouse.isShiftKeyPressed() );
@ -550,8 +560,9 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( x11_mouse.isMetaKeyPressed() );
// Clear event test
char rawdata10[] = { 0x1b, '[', 'M', 0x20, 0x7f, 0x3f };
x11_mouse.setRawData (rawdata10, sizeof(rawdata10));
finalcut::FKeyboard::keybuffer rawdata10 = \
{ 0x1b, '[', 'M', 0x20, 0x7f, 0x3f };
x11_mouse.setRawData (rawdata10);
CPPUNIT_ASSERT ( x11_mouse.hasData() );
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.hasEvent() );
@ -566,9 +577,10 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.hasData() );
// Left mouse button pressed
char rawdata1[] = { 0x1b, '[', '<', '0', ';', '7'
, '3', ';', '4', 'M', '@', '@' };
sgr_mouse.setRawData (rawdata1, sizeof(rawdata1));
finalcut::FKeyboard::keybuffer rawdata1 = \
{ 0x1b, '[', '<', '0', ';', '7'
, '3', ';', '4', 'M', '@', '@' };
sgr_mouse.setRawData (rawdata1);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 );
@ -594,14 +606,16 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
// The same input again
char raw[] = { 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'M' };
sgr_mouse.setRawData ( raw, sizeof(raw));
finalcut::FKeyboard::keybuffer raw = \
{ 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'M' };
sgr_mouse.setRawData (raw);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
// Left mouse button released
char rawdata2[] = { 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'm' };
sgr_mouse.setRawData (rawdata2, sizeof(rawdata2));
finalcut::FKeyboard::keybuffer rawdata2 = \
{ 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'm' };
sgr_mouse.setRawData (rawdata2);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( ! sgr_mouse.isInputDataPending() );
@ -624,8 +638,9 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
// Left mouse button pressed again (double click)
char rawdata4[] = { 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'M' };
sgr_mouse.setRawData (rawdata4, sizeof(rawdata4));
finalcut::FKeyboard::keybuffer rawdata4 = \
{ 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'M' };
sgr_mouse.setRawData (rawdata4);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( ! sgr_mouse.isInputDataPending() );
@ -649,9 +664,10 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
// Middle mouse button
char rawdata5[] = { 0x1b, '[', '<', '1', ';', '1', ';', '1', 'M'
, 0x1b, '[', '<', '1', ';', '1', ';', '1', 'm' };
sgr_mouse.setRawData (rawdata5, sizeof(rawdata5));
finalcut::FKeyboard::keybuffer rawdata5 = \
{ 0x1b, '[', '<', '1', ';', '1', ';', '1', 'M'
, 0x1b, '[', '<', '1', ';', '1', ';', '1', 'm' };
sgr_mouse.setRawData (rawdata5);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() );
@ -674,16 +690,17 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata5, sizeof(rawdata5));
sgr_mouse.setRawData (rawdata5);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! sgr_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMiddleButtonPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isMiddleButtonReleased() );
// Right mouse button
char rawdata6[] = { 0x1b, '[', '<', '2', ';', '3', ';', '3', 'M'
, 0x1b, '[', '<', '2', ';', '3', ';', '4', 'm' };
sgr_mouse.setRawData (rawdata6, sizeof(rawdata6));
finalcut::FKeyboard::keybuffer rawdata6 = \
{ 0x1b, '[', '<', '2', ';', '3', ';', '3', 'M'
, 0x1b, '[', '<', '2', ';', '3', ';', '4', 'm' };
sgr_mouse.setRawData (rawdata6);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() );
@ -706,7 +723,7 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata6, sizeof(rawdata6));
sgr_mouse.setRawData (rawdata6);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! sgr_mouse.isInputDataPending() );
@ -714,9 +731,10 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( sgr_mouse.isRightButtonReleased() );
// Mouse wheel
char rawdata7[] = { 0x1b, '[', '<', '6', '4', ';', '4', ';', '9', 'M'
, 0x1b, '[', '<', '6', '5', ';', '4', ';', '9', 'M' };
sgr_mouse.setRawData (rawdata7, sizeof(rawdata7));
finalcut::FKeyboard::keybuffer rawdata7 = \
{ 0x1b, '[', '<', '6', '4', ';', '4', ';', '9', 'M'
, 0x1b, '[', '<', '6', '5', ';', '4', ';', '9', 'M' };
sgr_mouse.setRawData (rawdata7);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() );
@ -739,16 +757,17 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata7, sizeof(rawdata7));
sgr_mouse.setRawData (rawdata7);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! sgr_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( sgr_mouse.isWheelDown() );
// Mouse move
char rawdata8[] = { 0x1b, '[', '<', '0', ';', '1', ';', '2', 'M'
, 0x1b, '[', '<', '3', '2', ';', '2', ';', '3', 'M'
, 0x1b, '[', '<', '0', ';', '3', ';', '4', 'm' };
sgr_mouse.setRawData (rawdata8, sizeof(rawdata8));
finalcut::FKeyboard::keybuffer rawdata8 = \
{ 0x1b, '[', '<', '0', ';', '1', ';', '2', 'M'
, 0x1b, '[', '<', '3', '2', ';', '2', ';', '3', 'M'
, 0x1b, '[', '<', '0', ';', '3', ';', '4', 'm' };
sgr_mouse.setRawData (rawdata8);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() );
@ -771,22 +790,23 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata8, sizeof(rawdata8));
sgr_mouse.setRawData (rawdata8);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(2, 3) );
CPPUNIT_ASSERT ( sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata8, sizeof(rawdata8));
sgr_mouse.setRawData (rawdata8);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
// Mouse + keyboard modifier key
char rawdata9[] = { 0x1b, '[', '<', '4', ';', '5', ';', '5', 'M'
, 0x1b, '[', '<', '8', ';', '5', ';', '5', 'M'
, 0x1b, '[', '<', '1', '6', ';', '5', ';', '5', 'M'
, 0x1b, '[', '<', '2', '8', ';', '5', ';', '5', 'M' };
sgr_mouse.setRawData (rawdata9, sizeof(rawdata9));
finalcut::FKeyboard::keybuffer rawdata9 = \
{ 0x1b, '[', '<', '4', ';', '5', ';', '5', 'M'
, 0x1b, '[', '<', '8', ';', '5', ';', '5', 'M'
, 0x1b, '[', '<', '1', '6', ';', '5', ';', '5', 'M'
, 0x1b, '[', '<', '2', '8', ';', '5', ';', '5', 'M' };
sgr_mouse.setRawData (rawdata9);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.isInputDataPending() );
@ -809,21 +829,21 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata9, sizeof(rawdata9));
sgr_mouse.setRawData (rawdata9);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! sgr_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( ! sgr_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isMetaKeyPressed() );
sgr_mouse.setRawData (rawdata9, sizeof(rawdata9));
sgr_mouse.setRawData (rawdata9);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! sgr_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMetaKeyPressed() );
sgr_mouse.setRawData (rawdata9, sizeof(rawdata9));
sgr_mouse.setRawData (rawdata9);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isShiftKeyPressed() );
@ -831,8 +851,9 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( sgr_mouse.isMetaKeyPressed() );
// Clear event test
char rawdata10[] = { 0x1b, '[', '<', '2', ';', '1', ';', '1', 'M' };
sgr_mouse.setRawData (rawdata10, sizeof(rawdata10));
finalcut::FKeyboard::keybuffer rawdata10 = \
{ 0x1b, '[', '<', '2', ';', '1', ';', '1', 'M' };
sgr_mouse.setRawData (rawdata10);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.hasEvent() );
@ -840,20 +861,21 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
// Wrong mouse data
char rawdata11[] = { 0x1b, '[', '<', '2', 'O', ';', '2', ';', '2', 'M'
, 0x1b, '[', '<', '1', ';', 'x', ';', '3', 'M'
, 0x1b, '[', '<', '6', ';', '5', ';', '@', 'M', '@' };
sgr_mouse.setRawData (rawdata11, sizeof(rawdata11));
finalcut::FKeyboard::keybuffer rawdata11 = \
{ 0x1b, '[', '<', '2', 'O', ';', '2', ';', '2', 'M'
, 0x1b, '[', '<', '1', ';', 'x', ';', '3', 'M'
, 0x1b, '[', '<', '6', ';', '5', ';', '@', 'M', '@' };
sgr_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
sgr_mouse.setRawData (rawdata11, sizeof(rawdata11));
sgr_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
sgr_mouse.setRawData (rawdata11, sizeof(rawdata11));
sgr_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( sgr_mouse.hasData() );
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
@ -869,9 +891,10 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
// Left mouse button pressed
char rawdata1[] = { 0x1b, '[', '3', '2', ';', '4'
, '9', ';', '6', 'M', '@', '@' };
urxvt_mouse.setRawData (rawdata1, sizeof(rawdata1));
finalcut::FKeyboard::keybuffer rawdata1 = \
{ 0x1b, '[', '3', '2', ';', '4'
, '9', ';', '6', 'M', '@', '@' };
urxvt_mouse.setRawData (rawdata1);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 );
@ -896,14 +919,16 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
// The same input again
char raw[] = { 0x1b, '[', '3', '2', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData ( raw, sizeof(raw));
finalcut::FKeyboard::keybuffer raw = \
{ 0x1b, '[', '3', '2', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData (raw);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
// Left mouse button released
char rawdata2[] = { 0x1b, '[', '3', '5', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData (rawdata2, sizeof(rawdata2));
finalcut::FKeyboard::keybuffer rawdata2 = \
{ 0x1b, '[', '3', '5', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData (rawdata2);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isInputDataPending() );
@ -926,8 +951,9 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
// Left mouse button pressed again (double click)
char rawdata4[] = { 0x1b, '[', '3', '2', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData (rawdata4, sizeof(rawdata4));
finalcut::FKeyboard::keybuffer rawdata4 = \
{ 0x1b, '[', '3', '2', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData (rawdata4);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isInputDataPending() );
@ -951,9 +977,10 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
// Middle mouse button
char rawdata5[] = { 0x1b, '[', '3', '3', ';', '1', ';', '1', 'M'
, 0x1b, '[', '3', '5', ';', '1', ';', '1', 'M' };
urxvt_mouse.setRawData (rawdata5, sizeof(rawdata5));
finalcut::FKeyboard::keybuffer rawdata5 = \
{ 0x1b, '[', '3', '3', ';', '1', ';', '1', 'M'
, 0x1b, '[', '3', '5', ';', '1', ';', '1', 'M' };
urxvt_mouse.setRawData (rawdata5);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
@ -976,16 +1003,17 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata5, sizeof(rawdata5));
urxvt_mouse.setRawData (rawdata5);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMiddleButtonPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isMiddleButtonReleased() );
// Right mouse button
char rawdata6[] = { 0x1b, '[', '3', '4', ';', '3', ';', '3', 'M'
, 0x1b, '[', '3', '5', ';', '3', ';', '4', 'M' };
urxvt_mouse.setRawData (rawdata6, sizeof(rawdata6));
finalcut::FKeyboard::keybuffer rawdata6 = \
{ 0x1b, '[', '3', '4', ';', '3', ';', '3', 'M'
, 0x1b, '[', '3', '5', ';', '3', ';', '4', 'M' };
urxvt_mouse.setRawData (rawdata6);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
@ -1008,7 +1036,7 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata6, sizeof(rawdata6));
urxvt_mouse.setRawData (rawdata6);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! urxvt_mouse.isInputDataPending() );
@ -1016,9 +1044,10 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.isRightButtonReleased() );
// Mouse wheel
char rawdata7[] = { 0x1b, '[', '9', '6', ';', '4', ';', '9', 'M'
, 0x1b, '[', '9', '7', ';', '4', ';', '9', 'M' };
urxvt_mouse.setRawData (rawdata7, sizeof(rawdata7));
finalcut::FKeyboard::keybuffer rawdata7 = \
{ 0x1b, '[', '9', '6', ';', '4', ';', '9', 'M'
, 0x1b, '[', '9', '7', ';', '4', ';', '9', 'M' };
urxvt_mouse.setRawData (rawdata7);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
@ -1041,16 +1070,17 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata7, sizeof(rawdata7));
urxvt_mouse.setRawData (rawdata7);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.isInputDataPending() );
CPPUNIT_ASSERT ( urxvt_mouse.isWheelDown() );
// Mouse move
char rawdata8[] = { 0x1b, '[', '3', '2', ';', '1', ';', '2', 'M'
, 0x1b, '[', '6', '4', ';', '2', ';', '3', 'M'
, 0x1b, '[', '3', '5', ';', '3', ';', '4', 'M' };
urxvt_mouse.setRawData (rawdata8, sizeof(rawdata8));
finalcut::FKeyboard::keybuffer rawdata8 = \
{ 0x1b, '[', '3', '2', ';', '1', ';', '2', 'M'
, 0x1b, '[', '6', '4', ';', '2', ';', '3', 'M'
, 0x1b, '[', '3', '5', ';', '3', ';', '4', 'M' };
urxvt_mouse.setRawData (rawdata8);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
@ -1073,22 +1103,23 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata8, sizeof(rawdata8));
urxvt_mouse.setRawData (rawdata8);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(2, 3) );
CPPUNIT_ASSERT ( urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata8, sizeof(rawdata8));
urxvt_mouse.setRawData (rawdata8);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
// Mouse + keyboard modifier key
char rawdata9[] = { 0x1b, '[', '3', '6', ';', '5', ';', '5', 'M'
, 0x1b, '[', '4', '0', ';', '5', ';', '5', 'M'
, 0x1b, '[', '4', '8', ';', '5', ';', '5', 'M'
, 0x1b, '[', '6', '0', ';', '5', ';', '5', 'M' };
urxvt_mouse.setRawData (rawdata9, sizeof(rawdata9));
finalcut::FKeyboard::keybuffer rawdata9 = \
{ 0x1b, '[', '3', '6', ';', '5', ';', '5', 'M'
, 0x1b, '[', '4', '0', ';', '5', ';', '5', 'M'
, 0x1b, '[', '4', '8', ';', '5', ';', '5', 'M'
, 0x1b, '[', '6', '0', ';', '5', ';', '5', 'M' };
urxvt_mouse.setRawData (rawdata9);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
@ -1111,21 +1142,21 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isWheelDown() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata9, sizeof(rawdata9));
urxvt_mouse.setRawData (rawdata9);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isMetaKeyPressed() );
urxvt_mouse.setRawData (rawdata9, sizeof(rawdata9));
urxvt_mouse.setRawData (rawdata9);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMetaKeyPressed() );
urxvt_mouse.setRawData (rawdata9, sizeof(rawdata9));
urxvt_mouse.setRawData (rawdata9);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isShiftKeyPressed() );
@ -1133,8 +1164,9 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.isMetaKeyPressed() );
// Clear event test
char rawdata10[] = { 0x1b, '[', '3', '2', ';', '1', ';', '1', 'M' };
urxvt_mouse.setRawData (rawdata10, sizeof(rawdata10));
finalcut::FKeyboard::keybuffer rawdata10 = \
{ 0x1b, '[', '3', '2', ';', '1', ';', '1', 'M' };
urxvt_mouse.setRawData (rawdata10);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
@ -1142,20 +1174,21 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
// Wrong mouse data
char rawdata11[] = { 0x1b, '[', '3', 'O', ';', '2', ';', '2', 'M'
, 0x1b, '[', '3', '3', ';', 'x', ';', '3', 'M'
, 0x1b, '[', '3', '4', ';', '5', ';', '@', 'M', '@' };
urxvt_mouse.setRawData (rawdata11, sizeof(rawdata11));
finalcut::FKeyboard::keybuffer rawdata11 = \
{ 0x1b, '[', '3', 'O', ';', '2', ';', '2', 'M'
, 0x1b, '[', '3', '3', ';', 'x', ';', '3', 'M'
, 0x1b, '[', '3', '4', ';', '5', ';', '@', 'M', '@' };
urxvt_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
urxvt_mouse.setRawData (rawdata11, sizeof(rawdata11));
urxvt_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
urxvt_mouse.setRawData (rawdata11, sizeof(rawdata11));
urxvt_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
@ -1164,9 +1197,10 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( std::strcmp(rawdata11, "@") == 0 );
// Negative values
char rawdata12[] = { 0x1b, '[', '3', '2', ';', '-', '5', ';', '5', 'M'
, 0x1b, '[', '3', '2', ';', '3', ';', '-', '3', 'M' };
urxvt_mouse.setRawData (rawdata12, sizeof(rawdata12));
finalcut::FKeyboard::keybuffer rawdata12 = \
{ 0x1b, '[', '3', '2', ';', '-', '5', ';', '5', 'M'
, 0x1b, '[', '3', '2', ';', '3', ';', '-', '3', 'M' };
urxvt_mouse.setRawData (rawdata12);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.isInputDataPending() );
urxvt_mouse.processEvent (&tv);
@ -1175,7 +1209,7 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(1, 5) );
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
urxvt_mouse.setRawData (rawdata12, sizeof(rawdata12));
urxvt_mouse.setRawData (rawdata12);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
@ -1186,8 +1220,9 @@ void FMouseTest::urxvtMouseTest()
// Oversize values
urxvt_mouse.setMaxWidth(40);
urxvt_mouse.setMaxHeight(20);
char rawdata13[] = { 0x1b, '[', '3', '2', ';', '7', '0', ';', '2', '5', 'M' };
urxvt_mouse.setRawData (rawdata13, sizeof(rawdata13));
finalcut::FKeyboard::keybuffer rawdata13 = \
{ 0x1b, '[', '3', '2', ';', '7', '0', ';', '2', '5', 'M' };
urxvt_mouse.setRawData (rawdata13);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
@ -1233,9 +1268,10 @@ void FMouseTest::mouseControlTest()
}
// Left mouse button pressed on an X11 mouse
char rawdata1[] = { 0x1b, '[', 'M', 0x20, 0x25, 0x28
, 0x1b, '[', 'M', 0x23, 0x25, 0x28 };
mouse_control.setRawData (finalcut::FMouse::x11, rawdata1, sizeof(rawdata1));
finalcut::FKeyboard::keybuffer rawdata1 = \
{ 0x1b, '[', 'M', 0x20, 0x25, 0x28
, 0x1b, '[', 'M', 0x23, 0x25, 0x28 };
mouse_control.setRawData (finalcut::FMouse::x11, rawdata1);
CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.isInputDataPending() );
@ -1260,7 +1296,7 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
CPPUNIT_ASSERT ( mouse_control.isInputDataPending() );
mouse_control.setRawData (finalcut::FMouse::x11, rawdata1, sizeof(rawdata1));
mouse_control.setRawData (finalcut::FMouse::x11, rawdata1);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( ! mouse_control.isInputDataPending() );
CPPUNIT_ASSERT ( ! mouse_control.isLeftButtonPressed() );
@ -1268,9 +1304,10 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isLeftButtonDoubleClick() );
// Middle mouse button on an SGR mouse
char rawdata2[] = { 0x1b, '[', '<', '1', ';', '1', ';', '1', 'M'
, 0x1b, '[', '<', '1', ';', '1', ';', '1', 'm' };
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata2, sizeof(rawdata2));
finalcut::FKeyboard::keybuffer rawdata2 = \
{ 0x1b, '[', '<', '1', ';', '1', ';', '1', 'M'
, 0x1b, '[', '<', '1', ';', '1', ';', '1', 'm' };
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata2);
CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.isInputDataPending() );
finalcut::FObject::getCurrentTime(&tv);
@ -1292,16 +1329,16 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata2, sizeof(rawdata2));
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata2);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( ! mouse_control.isInputDataPending() );
CPPUNIT_ASSERT ( ! mouse_control.isMiddleButtonPressed() );
CPPUNIT_ASSERT ( mouse_control.isMiddleButtonReleased() );
// Right mouse button on a urxvt mouse
char rawdata3[] = { 0x1b, '[', '3', '4', ';', '3', ';', '3', 'M'
finalcut::FKeyboard::keybuffer rawdata3 = { 0x1b, '[', '3', '4', ';', '3', ';', '3', 'M'
, 0x1b, '[', '3', '5', ';', '3', ';', '4', 'M' };
mouse_control.setRawData (finalcut::FMouse::urxvt, rawdata3, sizeof(rawdata3));
mouse_control.setRawData (finalcut::FMouse::urxvt, rawdata3);
CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.isInputDataPending() );
finalcut::FObject::getCurrentTime(&tv);
@ -1323,7 +1360,7 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::urxvt, rawdata3, sizeof(rawdata3));
mouse_control.setRawData (finalcut::FMouse::urxvt, rawdata3);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! mouse_control.isInputDataPending() );
@ -1331,9 +1368,10 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( mouse_control.isRightButtonReleased() );
// Mouse wheel on an X11 mouse
char rawdata4[] = { 0x1b, '[', 'M', 0x60, 0x70, 0x39
, 0x1b, '[', 'M', 0x61, 0x70, 0x39 };
mouse_control.setRawData (finalcut::FMouse::x11, rawdata4, sizeof(rawdata4));
finalcut::FKeyboard::keybuffer rawdata4 = \
{ 0x1b, '[', 'M', 0x60, 0x70, 0x39
, 0x1b, '[', 'M', 0x61, 0x70, 0x39 };
mouse_control.setRawData (finalcut::FMouse::x11, rawdata4);
CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.isInputDataPending() );
finalcut::FObject::getCurrentTime(&tv);
@ -1355,16 +1393,17 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::x11, rawdata4, sizeof(rawdata4));
mouse_control.setRawData (finalcut::FMouse::x11, rawdata4);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( ! mouse_control.isInputDataPending() );
CPPUNIT_ASSERT ( mouse_control.isWheelDown() );
// Mouse move on an SGR mouse
char rawdata5[] = { 0x1b, '[', '<', '0', ';', '1', ';', '2', 'M'
, 0x1b, '[', '<', '3', '2', ';', '2', ';', '3', 'M'
, 0x1b, '[', '<', '0', ';', '3', ';', '4', 'm' };
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5, sizeof(rawdata5));
finalcut::FKeyboard::keybuffer rawdata5 = \
{ 0x1b, '[', '<', '0', ';', '1', ';', '2', 'M'
, 0x1b, '[', '<', '3', '2', ';', '2', ';', '3', 'M'
, 0x1b, '[', '<', '0', ';', '3', ';', '4', 'm' };
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5);
CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.isInputDataPending() );
finalcut::FObject::getCurrentTime(&tv);
@ -1386,12 +1425,12 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5, sizeof(rawdata5));
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(2, 3) );
CPPUNIT_ASSERT ( mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5, sizeof(rawdata5));
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() );