Implemented hook function notifiers
Converted regular ServerWindow messaging to PortMessage usage git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3949 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -223,7 +223,8 @@ int32 AppServer::PollerThread(void *data)
|
||||
{
|
||||
if(!msg->Buffer())
|
||||
break;
|
||||
ServerWindow::HandleMouseEvent(msg->Code(),(int8*)msg->Buffer());
|
||||
// ServerWindow::HandleMouseEvent(msg->Code(),(int8*)msg->Buffer());
|
||||
ServerWindow::HandleMouseEvent(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -251,7 +252,8 @@ int32 AppServer::PollerThread(void *data)
|
||||
if(appserver->_driver)
|
||||
{
|
||||
appserver->_driver->MoveCursorTo(tempx,tempy);
|
||||
ServerWindow::HandleMouseEvent(msg->Code(),(int8*)msg->Buffer());
|
||||
// ServerWindow::HandleMouseEvent(msg->Code(),(int8*)msg->Buffer());
|
||||
ServerWindow::HandleMouseEvent(msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <View.h> // for B_XXXXX_MOUSE_BUTTON defines
|
||||
#include <PortLink.h>
|
||||
#include "AppServer.h"
|
||||
#include "Layer.h"
|
||||
#include "PortLink.h"
|
||||
#include "ServerWindow.h"
|
||||
#include "ServerApp.h"
|
||||
#include "ServerProtocol.h"
|
||||
@@ -282,9 +282,12 @@ bool ServerWindow::HasFocus(void)
|
||||
void ServerWindow::WorkspaceActivated(int32 workspace, bool active)
|
||||
{
|
||||
#ifdef DEBUG_SERVERWINDOW
|
||||
printf("ServerWindow %s: WorkspaceActivated unimplemented\n",_title->String());
|
||||
printf("ServerWindow %s: WorkspaceActivated(%ld,%s)\n",_title->String(),workspace,(active)?"active":"inactive");
|
||||
#endif
|
||||
// TODO: implement
|
||||
_winlink->SetOpCode(AS_WORKSPACE_ACTIVATED);
|
||||
_winlink->Attach(workspace);
|
||||
_winlink->Attach(active);
|
||||
_winlink->Flush();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -295,9 +298,12 @@ printf("ServerWindow %s: WorkspaceActivated unimplemented\n",_title->String());
|
||||
void ServerWindow::WorkspacesChanged(int32 oldone,int32 newone)
|
||||
{
|
||||
#ifdef DEBUG_SERVERWINDOW
|
||||
printf("ServerWindow %s: WorkspaceChanged unimplemented\n",_title->String());
|
||||
printf("ServerWindow %s: WorkspacesChanged(%ld,%ld)\n",_title->String(),oldone,newone);
|
||||
#endif
|
||||
// TODO: implement
|
||||
_winlink->SetOpCode(AS_WORKSPACES_CHANGED);
|
||||
_winlink->Attach(oldone);
|
||||
_winlink->Attach(newone);
|
||||
_winlink->Flush();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -307,9 +313,11 @@ printf("ServerWindow %s: WorkspaceChanged unimplemented\n",_title->String());
|
||||
void ServerWindow::WindowActivated(bool active)
|
||||
{
|
||||
#ifdef DEBUG_SERVERWINDOW
|
||||
printf("ServerWindow %s: WindowActivated unimplemented\n",_title->String());
|
||||
printf("ServerWindow %s: WindowActivated(%s)\n",_title->String(),(active)?"active":"inactive");
|
||||
#endif
|
||||
// TODO: implement
|
||||
_winlink->SetOpCode(AS_WINDOW_ACTIVATED);
|
||||
_winlink->Attach(active);
|
||||
_winlink->Flush();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -320,9 +328,12 @@ printf("ServerWindow %s: WindowActivated unimplemented\n",_title->String());
|
||||
void ServerWindow::ScreenModeChanged(const BRect frame, const color_space cspace)
|
||||
{
|
||||
#ifdef DEBUG_SERVERWINDOW
|
||||
printf("ServerWindow %s: ScreenModeChanged unimplemented\n",_title->String());
|
||||
printf("ServerWindow %s: ScreenModeChanged\n",_title->String());
|
||||
#endif
|
||||
// TODO: implement
|
||||
_winlink->SetOpCode(AS_SCREENMODE_CHANGED);
|
||||
_winlink->Attach(frame);
|
||||
_winlink->Attach(&cspace,sizeof(color_space));
|
||||
_winlink->Flush();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -377,9 +388,9 @@ bool ServerWindow::IsLocked(void)
|
||||
return _locker.IsLocked();
|
||||
}
|
||||
|
||||
void ServerWindow::DispatchMessage(int32 code, int8 *msgbuffer)
|
||||
void ServerWindow::DispatchMessage(PortMessage *msg)
|
||||
{
|
||||
switch(code)
|
||||
switch(msg->Code())
|
||||
{
|
||||
case AS_LAYER_CREATE:
|
||||
{
|
||||
@@ -616,7 +627,7 @@ printf("ServerWindow %s: Message Move_By unimplemented\n",_title->String());
|
||||
}
|
||||
default:
|
||||
{
|
||||
printf("ServerWindow %s received unexpected code %s\n",_title->String(),MsgCodeToString(code));
|
||||
printf("ServerWindow %s received unexpected code %s\n",_title->String(),MsgCodeToString(msg->Code()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1169,6 +1180,8 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
|
||||
int32 ServerWindow::MonitorWin(void *data)
|
||||
{
|
||||
ServerWindow *win=(ServerWindow *)data;
|
||||
PortMessage msg;
|
||||
int32 msgstat;
|
||||
|
||||
int32 msgcode;
|
||||
int8 *msgbuffer=NULL;
|
||||
@@ -1176,19 +1189,11 @@ int32 ServerWindow::MonitorWin(void *data)
|
||||
|
||||
for(;;)
|
||||
{
|
||||
buffersize=port_buffer_size(win->_receiver);
|
||||
msgstat=msg.ReadFromPort(win->_receiver);
|
||||
|
||||
if(buffersize>0)
|
||||
if(msgstat==B_OK)
|
||||
{
|
||||
msgbuffer=new int8[buffersize];
|
||||
bytesread=read_port(win->_receiver,&msgcode,msgbuffer,buffersize);
|
||||
}
|
||||
else
|
||||
bytesread=read_port(win->_receiver,&msgcode,NULL,0);
|
||||
|
||||
if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK)
|
||||
{
|
||||
switch(msgcode)
|
||||
switch(msg.Code())
|
||||
{
|
||||
case B_QUIT_REQUESTED:
|
||||
{
|
||||
@@ -1208,16 +1213,14 @@ printf("ServerWindow %s received Quit request\n",win->Title());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
win->DispatchMessage(msgcode,msgbuffer);
|
||||
// win->DispatchMessage(msgcode,msgbuffer);
|
||||
win->DispatchMessage(&msg);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(buffersize>0)
|
||||
delete[] msgbuffer;
|
||||
|
||||
if(msgcode==B_QUIT_REQUESTED)
|
||||
if(msg.Code()==B_QUIT_REQUESTED)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1230,13 +1233,11 @@ printf("ServerWindow %s received Quit request\n",win->Title());
|
||||
\param code Message code of the mouse message
|
||||
\param buffer Attachment buffer for the mouse message
|
||||
*/
|
||||
void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
|
||||
//void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
|
||||
void ServerWindow::HandleMouseEvent(PortMessage *msg)
|
||||
{
|
||||
#ifdef DEBUG_SERVERWINDOW_MOUSE
|
||||
printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
#endif
|
||||
ServerWindow *mousewin=NULL;
|
||||
int8 *index=buffer;
|
||||
// int8 *index=buffer;
|
||||
|
||||
// Find the window which will receive our mouse event.
|
||||
Layer *root=GetRootLayer(CurrentWorkspace(),ActiveScreen());
|
||||
@@ -1251,7 +1252,8 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
}
|
||||
|
||||
// Dispatch the mouse event to the proper window
|
||||
switch(code)
|
||||
// switch(code)
|
||||
switch(msg->Code())
|
||||
{
|
||||
case B_MOUSE_DOWN:
|
||||
{
|
||||
@@ -1263,13 +1265,16 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
// 5) int32 - buttons down
|
||||
// 6) int32 - clicks
|
||||
|
||||
// int64 time=*((int64*)index);
|
||||
index+=sizeof(int64);
|
||||
float x=*((float*)index); index+=sizeof(float);
|
||||
float y=*((float*)index); index+=sizeof(float);
|
||||
// int32 modifiers=*((int32*)index); index+=sizeof(uint32);
|
||||
// uint32 buttons=*((uint32*)index); index+=sizeof(uint32);
|
||||
// int32 clicks=*((int32*)index);
|
||||
// index+=sizeof(int64);
|
||||
// float x=*((float*)index); index+=sizeof(float);
|
||||
// float y=*((float*)index); index+=sizeof(float);
|
||||
// BPoint pt(x,y);
|
||||
float x;
|
||||
float y;
|
||||
int64 dummy;
|
||||
msg->Read(&dummy);
|
||||
msg->Read(&x);
|
||||
msg->Read(&y);
|
||||
BPoint pt(x,y);
|
||||
|
||||
// If we have clicked on a window,
|
||||
@@ -1277,7 +1282,8 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
if(_winborder)
|
||||
{
|
||||
mousewin=_winborder->Window();
|
||||
_winborder->MouseDown(buffer);
|
||||
// _winborder->MouseDown(buffer);
|
||||
_winborder->MouseDown((int8*)msg->Buffer());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1289,11 +1295,16 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
// 3) float - y coordinate of mouse click
|
||||
// 4) int32 - modifier keys down
|
||||
|
||||
// int64 time=*((int64*)index);
|
||||
index+=sizeof(int64);
|
||||
float x=*((float*)index); index+=sizeof(float);
|
||||
float y=*((float*)index); index+=sizeof(float);
|
||||
// int32 modifiers=*((int32*)index);
|
||||
// index+=sizeof(int64);
|
||||
// float x=*((float*)index); index+=sizeof(float);
|
||||
// float y=*((float*)index); index+=sizeof(float);
|
||||
// BPoint pt(x,y);
|
||||
float x;
|
||||
float y;
|
||||
int64 dummy;
|
||||
msg->Read(&dummy);
|
||||
msg->Read(&x);
|
||||
msg->Read(&y);
|
||||
BPoint pt(x,y);
|
||||
|
||||
set_is_sliding_tab(false);
|
||||
@@ -1307,7 +1318,8 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
|
||||
// Eventually, we will build in MouseUp messages with buttons specified
|
||||
// For now, we just "assume" no mouse specification with a 0.
|
||||
_winborder->MouseUp(buffer);
|
||||
// _winborder->MouseUp(buffer);
|
||||
_winborder->MouseUp((int8*)msg->Buffer());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1318,15 +1330,22 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
// 2) float - x coordinate of mouse click
|
||||
// 3) float - y coordinate of mouse click
|
||||
// 4) int32 - buttons down
|
||||
// int64 time=*((int64*)index);
|
||||
index+=sizeof(int64);
|
||||
float x=*((float*)index); index+=sizeof(float);
|
||||
float y=*((float*)index); index+=sizeof(float);
|
||||
// index+=sizeof(int64);
|
||||
// float x=*((float*)index); index+=sizeof(float);
|
||||
// float y=*((float*)index); index+=sizeof(float);
|
||||
// BPoint pt(x,y);
|
||||
float x;
|
||||
float y;
|
||||
int64 dummy;
|
||||
msg->Read(&dummy);
|
||||
msg->Read(&x);
|
||||
msg->Read(&y);
|
||||
BPoint pt(x,y);
|
||||
|
||||
if(is_moving_window() || is_resizing_window() || is_sliding_tab())
|
||||
{
|
||||
active_winborder->MouseMoved(buffer);
|
||||
// active_winborder->MouseMoved(buffer);
|
||||
active_winborder->MouseMoved((int8*)msg->Buffer());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1334,7 +1353,8 @@ printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
||||
if(_winborder)
|
||||
{
|
||||
mousewin=_winborder->Window();
|
||||
_winborder->MouseMoved(buffer);
|
||||
// _winborder->MouseMoved(buffer);
|
||||
_winborder->MouseMoved((int8*)msg->Buffer());
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1357,9 +1377,16 @@ void ServerWindow::HandleKeyEvent(int32 code, int8 *buffer)
|
||||
printf("ServerWindow::HandleKeyEvent unimplemented\n");
|
||||
#endif
|
||||
/* ServerWindow *keywin=NULL;
|
||||
int8 *index=buffer;
|
||||
|
||||
// Dispatch the key event to the active window
|
||||
keywin=GetActiveWindow();
|
||||
if(keywin)
|
||||
{
|
||||
keywin->Lock();
|
||||
keywin->_winlink->SetOpCode(code);
|
||||
keywin->_winlink
|
||||
keywin->Unlock();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <Rect.h>
|
||||
#include <String.h>
|
||||
#include <Window.h>
|
||||
#include <PortMessage.h>
|
||||
|
||||
class BString;
|
||||
class BMessenger;
|
||||
@@ -84,10 +85,10 @@ public:
|
||||
void Unlock(void);
|
||||
bool IsLocked(void);
|
||||
|
||||
void DispatchMessage(int32 code, int8 *msgbuffer);
|
||||
void DispatchMessage(PortMessage *msg);
|
||||
void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer);
|
||||
static int32 MonitorWin(void *data);
|
||||
static void HandleMouseEvent(int32 code, int8 *buffer);
|
||||
static void HandleMouseEvent(PortMessage *msg);
|
||||
static void HandleKeyEvent(int32 code, int8 *buffer);
|
||||
|
||||
//! Returns the index of the workspaces to which it belongs
|
||||
|
||||
Reference in New Issue
Block a user