Changes to integrate with app_server:
Added code to send more than just mouse move messages Removed the input_server's dependency on local PortLink sources Broke the BeIDE project by removing the PortLink dependency (oh well) -- see me for a fix if you run into problems building locally git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5089 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include "Entry.h"
|
||||
#include "Locker.h"
|
||||
#include "Debug.h"
|
||||
#include <String.h>
|
||||
|
||||
#include "InputServerDeviceListEntry.h"
|
||||
#include "InputServerFilterListEntry.h"
|
||||
@@ -48,12 +49,9 @@
|
||||
#include "Message.h"
|
||||
|
||||
// include app_server headers for communication
|
||||
#include <PortLink.h>
|
||||
#include <ServerProtocol.h>
|
||||
|
||||
#include "PortLink.h"
|
||||
#include "ServerProtocol.h"
|
||||
|
||||
#define SERVER_PORT_NAME "OBappserver"
|
||||
#define SERVER_INPUT_PORT "OBinputport"
|
||||
#define X_VALUE "x"
|
||||
#define Y_VALUE "y"
|
||||
|
||||
@@ -95,7 +93,7 @@ int main()
|
||||
*/
|
||||
InputServer::InputServer(void) : BApplication("application/x-vnd.OBOS-input_server")
|
||||
{
|
||||
void *pointer;
|
||||
void *pointer=NULL;
|
||||
|
||||
EventLoop(pointer);
|
||||
|
||||
@@ -1087,8 +1085,174 @@ int InputServer::DispatchEvent(BMessage *message)
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Should be some Mouse Down and Up code here ..
|
||||
// Along with some Key Down and up codes ..
|
||||
case B_MOUSE_DOWN:{
|
||||
|
||||
BPoint pt;
|
||||
int32 buttons,clicks,mod;
|
||||
int64 time=(int64)real_time_clock();
|
||||
|
||||
if(message->FindPoint("where",&pt)!=B_OK ||
|
||||
message->FindInt32("modifiers",&mod)!=B_OK ||
|
||||
message->FindInt32("buttons",&buttons)!=B_OK ||
|
||||
message->FindInt32("clicks",&clicks)!=B_OK)
|
||||
break;
|
||||
|
||||
appsvrlink->SetOpCode(B_MOUSE_DOWN);
|
||||
appsvrlink->Attach(&time, sizeof(int64));
|
||||
appsvrlink->Attach(&pt.x,sizeof(float));
|
||||
appsvrlink->Attach(&pt.y,sizeof(float));
|
||||
appsvrlink->Attach(&mod, sizeof(uint32));
|
||||
appsvrlink->Attach(&buttons, sizeof(uint32));
|
||||
appsvrlink->Attach(&clicks, sizeof(uint32));
|
||||
appsvrlink->Flush();
|
||||
break;
|
||||
}
|
||||
case B_MOUSE_UP:{
|
||||
BPoint pt;
|
||||
int32 mod;
|
||||
int64 time=(int64)real_time_clock();
|
||||
|
||||
if(message->FindPoint("where",&pt)!=B_OK ||
|
||||
message->FindInt32("modifiers",&mod)!=B_OK)
|
||||
break;
|
||||
|
||||
appsvrlink->SetOpCode(B_MOUSE_UP);
|
||||
appsvrlink->Attach(&time, sizeof(int64));
|
||||
appsvrlink->Attach(&pt.x,sizeof(float));
|
||||
appsvrlink->Attach(&pt.y,sizeof(float));
|
||||
appsvrlink->Attach(&mod, sizeof(uint32));
|
||||
appsvrlink->Flush();
|
||||
break;
|
||||
}
|
||||
case B_MOUSE_WHEEL_CHANGED:{
|
||||
float x,y;
|
||||
message->FindFloat("be:wheel_delta_x",&x);
|
||||
message->FindFloat("be:wheel_delta_y",&y);
|
||||
int64 time=real_time_clock();
|
||||
|
||||
appsvrlink->SetOpCode(B_MOUSE_WHEEL_CHANGED);
|
||||
appsvrlink->Attach(&time,sizeof(int64));
|
||||
appsvrlink->Attach(x);
|
||||
appsvrlink->Attach(y);
|
||||
appsvrlink->Flush();
|
||||
break;
|
||||
}
|
||||
case B_KEY_DOWN:{
|
||||
bigtime_t systime;
|
||||
int32 scancode, asciicode,repeatcount,modifiers;
|
||||
int8 utf8data[3];
|
||||
BString string;
|
||||
int8 keyarray[16];
|
||||
|
||||
systime=(int64)real_time_clock();
|
||||
message->FindInt32("key",&scancode);
|
||||
message->FindInt32("be:key_repeat",&repeatcount);
|
||||
message->FindInt32("modifiers",&modifiers);
|
||||
message->FindInt32("raw_char",&asciicode);
|
||||
message->FindInt8("byte",0,utf8data);
|
||||
message->FindInt8("byte",1,utf8data+1);
|
||||
message->FindInt8("byte",2,utf8data+2);
|
||||
message->FindString("bytes",&string);
|
||||
for(int8 i=0;i<15;i++)
|
||||
message->FindInt8("states",i,&keyarray[i]);
|
||||
appsvrlink->SetOpCode(B_KEY_DOWN);
|
||||
appsvrlink->Attach(&systime,sizeof(bigtime_t));
|
||||
appsvrlink->Attach(scancode);
|
||||
appsvrlink->Attach(asciicode);
|
||||
appsvrlink->Attach(repeatcount);
|
||||
appsvrlink->Attach(modifiers);
|
||||
appsvrlink->Attach(utf8data,sizeof(int8)*3);
|
||||
appsvrlink->Attach(string.Length()+1);
|
||||
appsvrlink->Attach(string.String());
|
||||
appsvrlink->Attach(keyarray,sizeof(int8)*16);
|
||||
appsvrlink->Flush();
|
||||
break;
|
||||
}
|
||||
case B_KEY_UP:{
|
||||
bigtime_t systime;
|
||||
int32 scancode, asciicode,modifiers;
|
||||
int8 utf8data[3];
|
||||
BString string;
|
||||
int8 keyarray[16];
|
||||
|
||||
systime=(int64)real_time_clock();
|
||||
message->FindInt32("key",&scancode);
|
||||
message->FindInt32("raw_char",&asciicode);
|
||||
message->FindInt32("modifiers",&modifiers);
|
||||
message->FindInt8("byte",0,utf8data);
|
||||
message->FindInt8("byte",1,utf8data+1);
|
||||
message->FindInt8("byte",2,utf8data+2);
|
||||
message->FindString("bytes",&string);
|
||||
for(int8 i=0;i<15;i++)
|
||||
message->FindInt8("states",i,&keyarray[i]);
|
||||
appsvrlink->SetOpCode(B_KEY_UP);
|
||||
appsvrlink->Attach(&systime,sizeof(bigtime_t));
|
||||
appsvrlink->Attach(scancode);
|
||||
appsvrlink->Attach(asciicode);
|
||||
appsvrlink->Attach(modifiers);
|
||||
appsvrlink->Attach(utf8data,sizeof(int8)*3);
|
||||
appsvrlink->Attach(string.Length()+1);
|
||||
appsvrlink->Attach(string.String());
|
||||
appsvrlink->Attach(keyarray,sizeof(int8)*16);
|
||||
appsvrlink->Flush();
|
||||
break;
|
||||
}
|
||||
case B_UNMAPPED_KEY_DOWN:{
|
||||
bigtime_t systime;
|
||||
int32 scancode,modifiers;
|
||||
int8 keyarray[16];
|
||||
|
||||
systime=(int64)real_time_clock();
|
||||
message->FindInt32("key",&scancode);
|
||||
message->FindInt32("modifiers",&modifiers);
|
||||
for(int8 i=0;i<15;i++)
|
||||
message->FindInt8("states",i,&keyarray[i]);
|
||||
appsvrlink->SetOpCode(B_UNMAPPED_KEY_DOWN);
|
||||
appsvrlink->Attach(&systime,sizeof(bigtime_t));
|
||||
appsvrlink->Attach(scancode);
|
||||
appsvrlink->Attach(modifiers);
|
||||
appsvrlink->Attach(keyarray,sizeof(int8)*16);
|
||||
appsvrlink->Flush();
|
||||
break;
|
||||
}
|
||||
case B_UNMAPPED_KEY_UP:{
|
||||
bigtime_t systime;
|
||||
int32 scancode,modifiers;
|
||||
int8 keyarray[16];
|
||||
|
||||
systime=(int64)real_time_clock();
|
||||
message->FindInt32("key",&scancode);
|
||||
message->FindInt32("modifiers",&modifiers);
|
||||
for(int8 i=0;i<15;i++)
|
||||
message->FindInt8("states",i,&keyarray[i]);
|
||||
appsvrlink->SetOpCode(B_UNMAPPED_KEY_UP);
|
||||
appsvrlink->Attach(&systime,sizeof(bigtime_t));
|
||||
appsvrlink->Attach(scancode);
|
||||
appsvrlink->Attach(modifiers);
|
||||
appsvrlink->Attach(keyarray,sizeof(int8)*16);
|
||||
appsvrlink->Flush();
|
||||
break;
|
||||
}
|
||||
case B_MODIFIERS_CHANGED:{
|
||||
bigtime_t systime;
|
||||
int32 scancode,modifiers,oldmodifiers;
|
||||
int8 keyarray[16];
|
||||
|
||||
systime=(int64)real_time_clock();
|
||||
message->FindInt32("key",&scancode);
|
||||
message->FindInt32("modifiers",&modifiers);
|
||||
message->FindInt32("be:old_modifiers",&oldmodifiers);
|
||||
for(int8 i=0;i<15;i++)
|
||||
message->FindInt8("states",i,&keyarray[i]);
|
||||
appsvrlink->SetOpCode(B_MODIFIERS_CHANGED);
|
||||
appsvrlink->Attach(&systime,sizeof(bigtime_t));
|
||||
appsvrlink->Attach(scancode);
|
||||
appsvrlink->Attach(modifiers);
|
||||
appsvrlink->Attach(oldmodifiers);
|
||||
appsvrlink->Attach(keyarray,sizeof(int8)*16);
|
||||
appsvrlink->Flush();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
|
||||
@@ -6,11 +6,12 @@ SubDir OBOS_TOP src servers input ;
|
||||
# input_server.rsrc
|
||||
# ;
|
||||
|
||||
UsePrivateHeaders app ;
|
||||
|
||||
Server input_server :
|
||||
InputServer.cpp
|
||||
InputServerDevice.cpp
|
||||
InputServerFilter.cpp
|
||||
InputServerMethod.cpp
|
||||
PortLink.cpp
|
||||
;
|
||||
LinkSharedOSLibs input_server : be root ;
|
||||
LinkSharedOSLibs input_server : be root <boot!home!config!lib>libopenbeos.so ;
|
||||
|
||||
@@ -1,440 +0,0 @@
|
||||
/*
|
||||
PortLink.cpp:
|
||||
A helper class for port-based messaging
|
||||
|
||||
------------------------------------------------------------------------
|
||||
How it works:
|
||||
The class utilizes a fixed-size array of PortLinkData object pointers. When
|
||||
data is attached, a new PortLinkData object is allocated and a copy of the
|
||||
passed data is created inside it. When the time comes for the message to be sent,
|
||||
the data is pieced together into a flattened array and written to the port.
|
||||
------------------------------------------------------------------------
|
||||
Data members:
|
||||
|
||||
*attachments[] - fixed-size array of pointers used to hold the attached data
|
||||
opcode - message value which is sent along with any data
|
||||
target - port to which the message is sent when Flush() is called
|
||||
replyport - port used with synchronous messaging - FlushWithReply()
|
||||
bufferlength - total bytes taken up by attachments
|
||||
num_attachments - internal variable which is used to track which "slot"
|
||||
will be the next one to receive an attachment object
|
||||
*/
|
||||
|
||||
#include "PortLink.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#ifdef OPENBEOS
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
//#define PLDEBUG
|
||||
|
||||
// Internal data storage class for holding attached data whilst it is waiting
|
||||
// to be Flattened() and then Flushed(). There is no need for this to be called outside
|
||||
// the PortLink class.
|
||||
class PortLinkData
|
||||
{
|
||||
public:
|
||||
PortLinkData(void);
|
||||
~PortLinkData(void);
|
||||
bool Set(void *data, size_t size);
|
||||
char *buffer;
|
||||
size_t buffersize;
|
||||
};
|
||||
|
||||
PortLink::PortLink(port_id port)
|
||||
{
|
||||
// For this class to be useful (and to prevent a lot of init problems)
|
||||
// we require a port in the constructor
|
||||
target=port;
|
||||
|
||||
// We start out without any data attached to the port message
|
||||
num_attachments=0;
|
||||
opcode=0;
|
||||
bufferlength=0;
|
||||
replyport=create_port(30,"PortLink reply port");
|
||||
}
|
||||
|
||||
PortLink::~PortLink(void)
|
||||
{
|
||||
// If, for some odd reason, this is deleted with something attached,
|
||||
// free the memory used by the attachments. We do not flush the queue
|
||||
// because the port may no longer be valid in cases such as the app
|
||||
// is in the process of quitting
|
||||
MakeEmpty();
|
||||
}
|
||||
|
||||
void PortLink::SetOpCode(int32 code)
|
||||
{
|
||||
// Sets the message code. This does not change once the message is sent.
|
||||
// Another call to SetOpCode() is required for such things.
|
||||
opcode=code;
|
||||
}
|
||||
|
||||
void PortLink::SetPort(port_id port)
|
||||
{
|
||||
// Sets the target port. While not necessary in most uses, this exists
|
||||
// mostly to prevent flexibility problems
|
||||
target=port;
|
||||
}
|
||||
|
||||
port_id PortLink::GetPort(void)
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
void PortLink::Flush(void)
|
||||
{
|
||||
// Fires a message off to the target, complete with attachments. NOTE:
|
||||
// the recipient must delete all attachments, being the PortLink object assumes
|
||||
// no responsiblity for the attachments once the message is sent.
|
||||
int8 *msgbuffer;
|
||||
int32 size;
|
||||
|
||||
if(num_attachments>0)
|
||||
{
|
||||
FlattenData(&msgbuffer,&size);
|
||||
// Dump message to port, reset attachments, and clean up
|
||||
write_port(target,opcode,msgbuffer,size);
|
||||
MakeEmpty();
|
||||
}
|
||||
else
|
||||
write_port(target,opcode,NULL,0);
|
||||
|
||||
// if(size>0)
|
||||
// delete msgbuffer;
|
||||
}
|
||||
|
||||
int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT)
|
||||
{
|
||||
// Fires a message to the target and then waits for a reply. The target will
|
||||
// receive a message with the first item being the port_id to reply to.
|
||||
// NOTE: like Flush(), any attached data must be deleted.
|
||||
|
||||
// Effectively, an Attach() call inlined for changes
|
||||
|
||||
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||
{
|
||||
*status=B_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// create a new storage object and stash the data
|
||||
PortLinkData *pld=new PortLinkData;
|
||||
if(pld->Set(&replyport,sizeof(port_id)))
|
||||
{
|
||||
bufferlength+=sizeof(port_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pld;
|
||||
*status=B_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Flatten() inlined to make some necessary changes
|
||||
int8 *buffer=new int8[bufferlength];
|
||||
int8 *bufferindex=buffer;
|
||||
size_t size=0;
|
||||
|
||||
// attach our port_id first
|
||||
memcpy(bufferindex, pld->buffer, pld->buffersize);
|
||||
bufferindex += pld->buffersize;
|
||||
size+=pld->buffersize;
|
||||
|
||||
// attach everything else
|
||||
for(int i=0;i<num_attachments;i++)
|
||||
{
|
||||
pld=attachments[i];
|
||||
memcpy(bufferindex, pld->buffer, pld->buffersize);
|
||||
bufferindex += pld->buffersize;
|
||||
size+=pld->buffersize;
|
||||
}
|
||||
|
||||
// Flush the thing....FOOSH! :P
|
||||
write_port(target,opcode,buffer,size);
|
||||
MakeEmpty();
|
||||
delete buffer;
|
||||
|
||||
// Now we wait for the reply
|
||||
if(timeout==B_INFINITE_TIMEOUT)
|
||||
{
|
||||
*buffersize=port_buffer_size(replyport);
|
||||
if(*buffersize>0)
|
||||
buffer=(int8*)new int8[*buffersize];
|
||||
read_port(replyport,code, buffer, *buffersize);
|
||||
}
|
||||
else
|
||||
{
|
||||
*buffersize=port_buffer_size_etc(replyport,0,timeout);
|
||||
if(*buffersize==B_TIMED_OUT)
|
||||
{
|
||||
*status=*buffersize;
|
||||
return NULL;
|
||||
//return *buffersize;
|
||||
}
|
||||
if(*buffersize>0)
|
||||
buffer=(int8*)new int8[*buffersize];
|
||||
read_port(replyport,code, buffer, *buffersize);
|
||||
}
|
||||
|
||||
// We got this far, so we apparently have some data
|
||||
*status=B_OK;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void PortLink::Attach(void *data, size_t size)
|
||||
{
|
||||
// This is the member called to attach data to a message. Attachments are
|
||||
// treated to be in 'Append' mode, tacking on each attached piece of data
|
||||
// to the end of the list.
|
||||
|
||||
// Prevent parameter problems
|
||||
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||
return;
|
||||
|
||||
if(size==0)
|
||||
return;
|
||||
|
||||
// create a new storage object and stash the data
|
||||
PortLinkData *pld=new PortLinkData;
|
||||
if(pld->Set(data,size))
|
||||
{
|
||||
num_attachments++;
|
||||
attachments[num_attachments-1]=pld;
|
||||
bufferlength+=size;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pld;
|
||||
}
|
||||
}
|
||||
|
||||
// These functions were added for a major convenience in passing common types
|
||||
// Eventually, I'd like to templatize these, but for now, this'll do
|
||||
|
||||
void PortLink::Attach(int32 data)
|
||||
{
|
||||
// Prevent parameter problems
|
||||
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||
return;
|
||||
|
||||
int32 size=sizeof(int32);
|
||||
|
||||
// create a new storage object and stash the data
|
||||
PortLinkData *pld=new PortLinkData;
|
||||
if(pld->Set(&data,size))
|
||||
{
|
||||
num_attachments++;
|
||||
attachments[num_attachments-1]=pld;
|
||||
bufferlength+=size;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pld;
|
||||
}
|
||||
}
|
||||
|
||||
void PortLink::Attach(int16 data)
|
||||
{
|
||||
// Prevent parameter problems
|
||||
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||
return;
|
||||
|
||||
int32 size=sizeof(int16);
|
||||
|
||||
// create a new storage object and stash the data
|
||||
PortLinkData *pld=new PortLinkData;
|
||||
if(pld->Set(&data,size))
|
||||
{
|
||||
num_attachments++;
|
||||
attachments[num_attachments-1]=pld;
|
||||
bufferlength+=size;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pld;
|
||||
}
|
||||
}
|
||||
|
||||
void PortLink::Attach(int8 data)
|
||||
{
|
||||
// Prevent parameter problems
|
||||
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||
return;
|
||||
|
||||
int32 size=sizeof(int8);
|
||||
|
||||
// create a new storage object and stash the data
|
||||
PortLinkData *pld=new PortLinkData;
|
||||
if(pld->Set(&data,size))
|
||||
{
|
||||
num_attachments++;
|
||||
attachments[num_attachments-1]=pld;
|
||||
bufferlength+=size;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pld;
|
||||
}
|
||||
}
|
||||
|
||||
void PortLink::Attach(float data)
|
||||
{
|
||||
// Prevent parameter problems
|
||||
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||
return;
|
||||
|
||||
int32 size=sizeof(float);
|
||||
|
||||
// create a new storage object and stash the data
|
||||
PortLinkData *pld=new PortLinkData;
|
||||
if(pld->Set(&data,size))
|
||||
{
|
||||
num_attachments++;
|
||||
attachments[num_attachments-1]=pld;
|
||||
bufferlength+=size;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pld;
|
||||
}
|
||||
}
|
||||
|
||||
void PortLink::Attach(bool data)
|
||||
{
|
||||
// Prevent parameter problems
|
||||
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||
return;
|
||||
|
||||
int32 size=sizeof(bool);
|
||||
|
||||
// create a new storage object and stash the data
|
||||
PortLinkData *pld=new PortLinkData;
|
||||
if(pld->Set(&data,size))
|
||||
{
|
||||
num_attachments++;
|
||||
attachments[num_attachments-1]=pld;
|
||||
bufferlength+=size;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pld;
|
||||
}
|
||||
}
|
||||
|
||||
void PortLink::Attach(BRect data)
|
||||
{
|
||||
// Prevent parameter problems
|
||||
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||
return;
|
||||
|
||||
int32 size=sizeof(BRect);
|
||||
|
||||
// create a new storage object and stash the data
|
||||
PortLinkData *pld=new PortLinkData;
|
||||
if(pld->Set(&data,size))
|
||||
{
|
||||
num_attachments++;
|
||||
attachments[num_attachments-1]=pld;
|
||||
bufferlength+=size;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pld;
|
||||
}
|
||||
}
|
||||
|
||||
void PortLink::Attach(BPoint data)
|
||||
{
|
||||
// Prevent parameter problems
|
||||
if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS)
|
||||
return;
|
||||
|
||||
int32 size=sizeof(BPoint);
|
||||
|
||||
// create a new storage object and stash the data
|
||||
PortLinkData *pld=new PortLinkData;
|
||||
if(pld->Set(&data,size))
|
||||
{
|
||||
num_attachments++;
|
||||
attachments[num_attachments-1]=pld;
|
||||
bufferlength+=size;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pld;
|
||||
}
|
||||
}
|
||||
|
||||
void PortLink::FlattenData(int8 **buffer,int32 *size)
|
||||
{
|
||||
// This function is where all the magic happens, but it is strictly internal.
|
||||
// It iterates through each PortLinkData object and copies it to the main buffer
|
||||
// which ends up, ultimately, being written to the PortLink's target port.
|
||||
|
||||
// skip if there aree no attachments
|
||||
if(bufferlength<1)
|
||||
return;
|
||||
|
||||
*buffer=new int8[bufferlength];
|
||||
int8 *bufferindex=*buffer;
|
||||
PortLinkData *pld;
|
||||
*size=0;
|
||||
|
||||
for(int i=0;i<num_attachments;i++)
|
||||
{
|
||||
pld=attachments[i];
|
||||
memcpy(bufferindex, pld->buffer, pld->buffersize);
|
||||
bufferindex += pld->buffersize;
|
||||
*size+=pld->buffersize;
|
||||
}
|
||||
}
|
||||
|
||||
void PortLink::MakeEmpty(void)
|
||||
{
|
||||
// Nukes all the attachments currently held by the PortLink class
|
||||
if(num_attachments!=0)
|
||||
{
|
||||
for(int i=0; i<num_attachments; i++)
|
||||
{
|
||||
delete attachments[i];
|
||||
}
|
||||
}
|
||||
num_attachments=0;
|
||||
bufferlength=0;
|
||||
}
|
||||
|
||||
PortLinkData::PortLinkData(void)
|
||||
{
|
||||
// Initialize object to empty
|
||||
buffersize=0;
|
||||
}
|
||||
|
||||
PortLinkData::~PortLinkData(void)
|
||||
{
|
||||
// Frees the buffer if we actually used the class to store data
|
||||
if(buffersize>0)
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
bool PortLinkData::Set(void *data, size_t size)
|
||||
{
|
||||
// Function copies the passed to the internal buffers for storage
|
||||
if(size>0 && buffersize==0 && data!=NULL)
|
||||
{
|
||||
buffer=(char *)malloc(size);
|
||||
if(buffer==NULL)
|
||||
return false;
|
||||
memcpy(buffer, data, size);
|
||||
buffersize=size;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef OPENBEOS
|
||||
}
|
||||
#endif
|
||||
@@ -1,51 +0,0 @@
|
||||
#ifndef _PORTLINK_H_
|
||||
#define _PORTLINK_H_
|
||||
|
||||
#include <Errors.h>
|
||||
#include <OS.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <Rect.h>
|
||||
|
||||
#ifndef _PORTLINK_BUFFERSIZE
|
||||
#define _PORTLINK_MAX_ATTACHMENTS 50
|
||||
#endif
|
||||
|
||||
#ifdef OPENBEOS
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
class PortLinkData;
|
||||
|
||||
class PortLink
|
||||
{
|
||||
public:
|
||||
PortLink(port_id port);
|
||||
~PortLink(void);
|
||||
void SetOpCode(int32 code);
|
||||
void SetPort(port_id port);
|
||||
port_id GetPort(void);
|
||||
void Flush(void);
|
||||
int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize,
|
||||
bigtime_t timeout=B_INFINITE_TIMEOUT);
|
||||
void Attach(void *data, size_t size);
|
||||
void Attach(int32 data);
|
||||
void Attach(int16 data);
|
||||
void Attach(int8 data);
|
||||
void Attach(float data);
|
||||
void Attach(bool data);
|
||||
void Attach(BRect data);
|
||||
void Attach(BPoint data);
|
||||
void MakeEmpty(void);
|
||||
protected:
|
||||
void FlattenData(int8 **buffer,int32 *size);
|
||||
port_id target, replyport;
|
||||
int32 opcode, bufferlength;
|
||||
int num_attachments;
|
||||
PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS];
|
||||
};
|
||||
|
||||
#ifdef OPENBEOS
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,95 +0,0 @@
|
||||
#ifndef _APPSERVER_PROTOCOL_
|
||||
#define _APPSERVER_PROTOCOL_
|
||||
|
||||
#define CREATE_APP 'drca'
|
||||
#define DELETE_APP 'drda'
|
||||
#define QUIT_APP 'srqa'
|
||||
|
||||
#define SET_SERVER_PORT 'srsp'
|
||||
|
||||
#define CREATE_WINDOW 'drcw'
|
||||
#define DELETE_WINDOW 'drdw'
|
||||
#define SHOW_WINDOW 'drsw'
|
||||
#define HIDE_WINDOW 'drhw'
|
||||
#define QUIT_WINDOW 'srqw'
|
||||
|
||||
#define SERVER_PORT_NAME "OBappserver"
|
||||
#define SERVER_INPUT_PORT "OBinputport"
|
||||
|
||||
#define SET_CURSOR_DATA 'sscd'
|
||||
#define SET_CURSOR_BCURSOR 'sscb'
|
||||
#define SET_CURSOR_BBITMAP 'sscB'
|
||||
#define SHOW_CURSOR 'srsc'
|
||||
#define HIDE_CURSOR 'srhc'
|
||||
#define OBSCURE_CURSOR 'sroc'
|
||||
|
||||
#define GFX_COUNT_WORKSPACES 'gcws'
|
||||
#define GFX_SET_WORKSPACE_COUNT 'ggwc'
|
||||
#define GFX_CURRENT_WORKSPACE 'ggcw'
|
||||
#define GFX_ACTIVATE_WORKSPACE 'gaws'
|
||||
#define GFX_GET_SYSTEM_COLORS 'gsyc'
|
||||
#define GFX_SET_SYSTEM_COLORS 'gsyc'
|
||||
#define GFX_SET_SCREEN_MODE 'gssm'
|
||||
#define GFX_GET_SCROLLBAR_INFO 'ggsi'
|
||||
#define GFX_SET_SCROLLBAR_INFO 'gssi'
|
||||
#define GFX_IDLE_TIME 'gidt'
|
||||
#define GFX_SELECT_PRINTER_PANEL 'gspp'
|
||||
#define GFX_ADD_PRINTER_PANEL 'gapp'
|
||||
#define GFX_RUN_BE_ABOUT 'grba'
|
||||
#define GFX_SET_FOCUS_FOLLOWS_MOUSE 'gsfm'
|
||||
#define GFX_FOCUS_FOLLOWS_MOUSE 'gffm'
|
||||
|
||||
#define GFX_SET_HIGH_COLOR 'gshc'
|
||||
#define GFX_SET_LOW_COLOR 'gslc'
|
||||
#define GFX_SET_VIEW_COLOR 'gsvc'
|
||||
|
||||
#define GFX_STROKE_ARC 'gsar'
|
||||
#define GFX_STROKE_BEZIER 'gsbz'
|
||||
#define GFX_STROKE_ELLIPSE 'gsel'
|
||||
#define GFX_STROKE_LINE 'gsln'
|
||||
#define GFX_STROKE_POLYGON 'gspy'
|
||||
#define GFX_STROKE_RECT 'gsrc'
|
||||
#define GFX_STROKE_ROUNDRECT 'gsrr'
|
||||
#define GFX_STROKE_SHAPE 'gssh'
|
||||
#define GFX_STROKE_TRIANGLE 'gstr'
|
||||
|
||||
#define GFX_FILL_ARC 'gfar'
|
||||
#define GFX_FILL_BEZIER 'gfbz'
|
||||
#define GFX_FILL_ELLIPSE 'gfel'
|
||||
#define GFX_FILL_POLYGON 'gfpy'
|
||||
#define GFX_FILL_RECT 'gfrc'
|
||||
#define GFX_FILL_REGION 'gfrg'
|
||||
#define GFX_FILL_ROUNDRECT 'gfrr'
|
||||
#define GFX_FILL_SHAPE 'gfsh'
|
||||
#define GFX_FILL_TRIANGLE 'gftr'
|
||||
|
||||
#define GFX_MOVEPENBY 'gmpb'
|
||||
#define GFX_MOVEPENTO 'gmpt'
|
||||
#define GFX_SETPENSIZE 'gsps'
|
||||
|
||||
#define GFX_DRAW_STRING 'gdst'
|
||||
#define GFX_SET_FONT 'gsft'
|
||||
#define GFX_SET_FONT_SIZE 'gsfs'
|
||||
|
||||
#define GFX_FLUSH 'gfsh'
|
||||
#define GFX_SYNC 'gsyn'
|
||||
|
||||
#define LAYER_CREATE 'lycr'
|
||||
#define LAYER_DELETE 'lydl'
|
||||
#define LAYER_ADD_CHILD 'lyac'
|
||||
#define LAYER_REMOVE_CHILD 'lyrc'
|
||||
#define LAYER_REMOVE_SELF 'lyrs'
|
||||
#define LAYER_SHOW 'lysh'
|
||||
#define LAYER_HIDE 'lyhd'
|
||||
#define LAYER_MOVE 'lymv'
|
||||
#define LAYER_RESIZE 'lyre'
|
||||
#define LAYER_INVALIDATE 'lyin'
|
||||
#define LAYER_DRAW 'lydr'
|
||||
|
||||
#define BEGIN_RECT_TRACKING 'rtbg'
|
||||
#define END_RECT_TRACKING 'rten'
|
||||
|
||||
#define VIEW_GET_TOKEN 'vgtk'
|
||||
#define VIEW_ADD 'vadd'
|
||||
#define VIEW_REMOVE 'vrem'
|
||||
#endif
|
||||
Reference in New Issue
Block a user