Added ServerWindow skeleton

Uncommented most ServerWindow dependencies in other files
Implemented and documented almost all of Layer class


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2646 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-02-07 12:53:57 +00:00
parent 79e622060c
commit 70acf9f9fb
7 changed files with 675 additions and 95 deletions

View File

@ -32,6 +32,7 @@
#include "ServerApp.h"
#include "ServerConfig.h"
#include "ServerProtocol.h"
#include "ServerWindow.h"
/*!
\brief Constructor
@ -167,8 +168,7 @@ int32 AppServer::PollerThread(void *data)
{
if(!msgbuffer)
break;
// TODO: Uncomment when we have ServerWindow.h
//ServerWindow::HandleMouseEvent(msgcode,msgbuffer);
ServerWindow::HandleMouseEvent(msgcode,msgbuffer);
break;
}
@ -195,9 +195,7 @@ int32 AppServer::PollerThread(void *data)
index+=sizeof(float);
appserver->_driver->MoveCursorTo(tempx,tempy);
// TODO: Uncomment when we have ServerWindow.h
//ServerWindow::HandleMouseEvent(msgcode,msgbuffer);
ServerWindow::HandleMouseEvent(msgcode,msgbuffer);
break;
}
case B_KEY_DOWN:

View File

@ -21,6 +21,7 @@ Server app_server :
CursorManager.cpp
Desktop.cpp
ServerApp.cpp
ServerWindow.cpp
# Font Classes
FontFamily.cpp

View File

@ -25,20 +25,33 @@
// view on screen and also for window decorators
//
//------------------------------------------------------------------------------
#include "Layer.h"
#include "RectUtils.h"
//#include "ServerWindow.h"
#include "PortLink.h"
#include <View.h>
#include <string.h>
#include <stdio.h>
#include "Layer.h"
#include "RectUtils.h"
#include "ServerWindow.h"
#include "PortLink.h"
#include "TokenHandler.h"
//! TokenHandler object used to provide IDs for all Layers and, thus, BViews
TokenHandler view_token_handler;
/*!
\brief Constructor
\param frame Size and placement of the Layer
\param name Name of the layer
\param resize Resizing flags as defined in View.h
\param flags BView flags as defined in View.h
\param win ServerWindow to which the Layer belongs
*/
Layer::Layer(BRect frame, const char *name, int32 resize, int32 flags,ServerWindow *win)
{
/* // frame is in _parent layer's coordinates
// frame is in _parent layer's coordinates
if(frame.IsValid())
_frame=frame;
else
_frame.Set(0,0,1,1);
_frame.Set(0,0,5,5);
_name=new BString(name);
@ -55,8 +68,8 @@ Layer::Layer(BRect frame, const char *name, int32 resize, int32 flags,ServerWind
_serverwin=win;
// TODO: Can't remember why we have these... Find out why
_view_token=0;
// We have view tokens to be able to identify BViews
_view_token=view_token_handler.GetToken();
_flags=flags;
@ -66,12 +79,12 @@ Layer::Layer(BRect frame, const char *name, int32 resize, int32 flags,ServerWind
_level=0;
_layerdata=new LayerData;
*/
}
//! Destructor frees all allocated heap space
Layer::~Layer(void)
{
/* if(_visible)
if(_visible)
{
delete _visible;
_visible=NULL;
@ -96,16 +109,21 @@ Layer::~Layer(void)
delete _layerdata;
_layerdata=NULL;
}
*/
}
// Tested for adding children with 1 and 2 child cases, but not more
/*!
\brief Adds a child to the back of the a layer's child stack.
\param layer The layer to add as a child
\param before Add the child in front of this layer
\param rebuild Flag to fully rebuild all visibility regions
*/
void Layer::AddChild(Layer *layer, Layer *before=NULL, bool rebuild)
{
/* // Adds a layer to the top of the layer's children
// TODO: Add before support
if(layer->_parent!=NULL)
{
printf("ERROR: AddChild(): View already has a _parent\n");
printf("ERROR: AddChild(): Layer already has a _parent\n");
return;
}
layer->_parent=this;
@ -151,21 +169,26 @@ void Layer::AddChild(Layer *layer, Layer *before=NULL, bool rebuild)
_bottomchild=layer;
_topchild=layer;
layer->_level=_level+1;
*/
if(rebuild)
RebuildRegions(true);
}
// Tested for cases with 1 and 2 children, but no more than that
/*!
\brief Removes a layer from the child stack
\param layer The layer to remove
\param rebuild Flag to rebuild all visibility regions
*/
void Layer::RemoveChild(Layer *layer, bool rebuild)
{
/* // Remove a layer from the tree
if(layer->_parent==NULL)
{
printf("ERROR: RemoveChild(): View doesn't have a _parent\n");
printf("ERROR: RemoveChild(): Layer doesn't have a _parent\n");
return;
}
if(layer->_parent!=this)
{
printf("ERROR: RemoveChild(): View is not a child of this layer\n");
printf("ERROR: RemoveChild(): Layer is not a child of this layer\n");
return;
}
@ -191,30 +214,43 @@ void Layer::RemoveChild(Layer *layer, bool rebuild)
layer->_uppersibling=NULL;
layer->_lowersibling=NULL;
RebuildRegions();
*/
if(rebuild)
RebuildRegions(true);
}
/*!
\brief Removes the layer from its parent's child stack
\param rebuild Flag to rebuild visibility regions
*/
void Layer::RemoveSelf(bool rebuild)
{
/* // A Layer removes itself from the tree (duh)
// A Layer removes itself from the tree (duh)
if(_parent==NULL)
{
printf("ERROR: RemoveSelf(): View doesn't have a _parent\n");
printf("ERROR: RemoveSelf(): Layer doesn't have a _parent\n");
return;
}
Layer *p=_parent;
_parent->RemoveChild(this);
*/
if(rebuild)
p->RebuildRegions(true);
}
/*!
\brief Finds the first child at a given point.
\param pt Point to look for a child
\param recursive Flag to look for the bottom-most child
\return non-NULL if found, NULL if not
Find out which child gets hit if we click at a certain spot. Returns NULL
if there are no _visible children or if the click does not hit a child layer
If recursive==true, then it will continue to call until it reaches a layer
which has no children, i.e. a layer that is at the top of its 'branch' in
the layer tree
*/
Layer *Layer::GetChildAt(BPoint pt, bool recursive=false)
{
/* // Find out which child gets hit if we click at a certain spot. Returns NULL
// if there are no _visible children or if the click does not hit a child layer
// If recursive==true, then it will continue to call until it reaches a layer
// which has no children, i.e. a layer that is at the top of its 'branch' in
// the layer tree
Layer *child;
if(recursive)
{
@ -236,29 +272,38 @@ Layer *Layer::GetChildAt(BPoint pt, bool recursive=false)
{
if(child->_hidecount>0)
continue;
// if(child->_visible && child->_visible->Contains(ConvertFromTop(pt)))
// printf("child hit by mouse. News at 11\n");
if(child->_frame.Contains(pt))
return child;
}
}
*/ return NULL;
return NULL;
}
/*!
\brief Returns the size of the layer
\return the size of the layer
*/
BRect Layer::Bounds(void)
{
return _frame.OffsetToCopy(0,0);
}
/*!
\brief Returns the layer's size and position in its parent coordinates
\return The layer's size and position in its parent coordinates
*/
BRect Layer::Frame(void)
{
return _frame;
}
/*!
\brief recursively deletes all children (and grandchildren, etc) of the layer
This is mostly used for server shutdown or deleting a workspace
*/
void Layer::PruneTree(void)
{
/* // recursively deletes all children (and grandchildren, etc) of the passed layer
// This is mostly used for server shutdown or deleting a workspace
Layer *lay,*nextlay;
lay=_topchild;
@ -268,7 +313,6 @@ void Layer::PruneTree(void)
{
if(lay->_topchild!=NULL)
{
// lay->_topchild->PruneTree();
lay->PruneTree();
}
nextlay=lay->_lowersibling;
@ -277,12 +321,15 @@ void Layer::PruneTree(void)
lay=nextlay;
}
// Man, this thing is short. Elegant, ain't it? :P
*/
}
/*!
\brief Finds a layer based on its token ID
\return non-NULL if found, NULL if not
*/
Layer *Layer::FindLayer(int32 token)
{
/* // recursive search for a layer based on its view token
// recursive search for a layer based on its view token
Layer *lay, *trylay;
// Search child layers first
@ -301,13 +348,19 @@ Layer *Layer::FindLayer(int32 token)
}
// Well, we got this far in the function, so apparently there is no match to be found
*/ return NULL;
return NULL;
}
// Tested
/*!
\brief Sets a region as invalid and, thus, needing to be drawn
\param The region to invalidate
All children of the layer also receive this call, so only 1 Invalidate call is
needed to set a section as invalid on the screen.
*/
void Layer::Invalidate(BRegion region)
{
/* int32 i;
int32 i;
BRect r;
// See if the region intersects with our current area
@ -342,23 +395,24 @@ void Layer::Invalidate(BRegion region)
delete reg;
}
}
*/
}
// Tested
/*!
\brief Sets a rectangle as invalid and, thus, needing to be drawn
\param The rectangle to invalidate
All children of the layer also receive this call, so only 1 Invalidate call is
needed to set a section as invalid on the screen.
*/
void Layer::Invalidate(BRect rect)
{
/* // Make our own section dirty and pass it on to any children, if necessary....
// Make our own section dirty and pass it on to any children, if necessary....
// YES, WE ARE SHARING DIRT! Mudpies anyone? :D
// if(Frame().Intersects(rect) || Frame().Contains(rect))
if(TestRectIntersection(Frame(),rect))
{
// Clip the rectangle to the _visible region of the layer
// if(_visible->Intersects(rect))
if(TestRegionIntersection(_visible,rect))
{
// BRegion reg(rect);
// reg.IntersectWith(_visible);
BRegion reg(*_visible);
IntersectRegionWith(&reg,rect);
if(reg.CountRects()>0)
@ -379,9 +433,12 @@ void Layer::Invalidate(BRect rect)
}
for(Layer *lay=_topchild;lay!=NULL; lay=lay->_lowersibling)
lay->Invalidate(lay->ConvertFromParent(rect));
*/
}
/*!
\brief Ask the layer's BView to draw itself
\param r The area that needs to be drawn
*/
void Layer::RequestDraw(const BRect &r)
{
// TODO: Implement and fix
@ -406,15 +463,19 @@ void Layer::RequestDraw(const BRect &r)
*/
}
/*!
\brief Determines whether the layer needs to be redrawn
\return True if the layer needs to be redrawn, false if not
*/
bool Layer::IsDirty(void) const
{
// return _is_dirty;
return (!_invalid)?true:false;
}
//! Show the layer. Operates just like the BView call with the same name
void Layer::Show(void)
{
/* if(_hidecount==0)
if(_hidecount==0)
return;
_hidecount--;
@ -429,12 +490,12 @@ void Layer::Show(void)
Layer *child;
for(child=_topchild; child!=NULL; child=child->_lowersibling)
child->Show();
*/
}
//! Hide the layer. Operates just like the BView call with the same name
void Layer::Hide(void)
{
/* if(_hidecount==0)
if(_hidecount==0)
{
BRegion *reg=new BRegion(ConvertToParent(_visible));
_parent->_visible->Include(reg);
@ -447,13 +508,15 @@ void Layer::Hide(void)
Layer *child;
for(child=_topchild; child!=NULL; child=child->_lowersibling)
child->Hide();
*/
}
// Tested
/*!
\brief Counts the number of children the layer has
\return the number of children the layer has, not including grandchildren
*/
uint32 Layer::CountChildren(void)
{
/* uint32 i=0;
uint32 i=0;
Layer *lay=_topchild;
while(lay!=NULL)
{
@ -461,12 +524,16 @@ uint32 Layer::CountChildren(void)
i++;
}
return i;
*/ return 0;
}
/*!
\brief Moves a layer in its parent coordinate space
\param x X offset
\param y Y offset
*/
void Layer::MoveBy(float x, float y)
{
/* BRect oldframe(_frame);
BRect oldframe(_frame);
_frame.OffsetBy(x,y);
if(_parent)
@ -480,31 +547,42 @@ void Layer::MoveBy(float x, float y)
// for(Layer *lay=_topchild; lay!=NULL; lay=lay->_lowersibling)
// lay->MoveBy(x,y);
// Invalidate(Frame());
*/
}
/*!
\brief Resizes the layer.
\param x X offset
\param y Y offset
This resizes the layer itself and resizes any children based on their resize
flags.
*/
void Layer::ResizeBy(float x, float y)
{
/* BRect oldframe=_frame;
// TODO: Implement and test child resizing based on flags
BRect oldframe=_frame;
_frame.right+=x;
_frame.bottom+=y;
if(_parent)
_parent->RebuildRegions();
else
RebuildRegions();
// for(Layer *lay=_topchild; lay!=NULL; lay=lay->_lowersibling)
// lay->ResizeBy(x,y);
if(_parent)
_parent->RebuildRegions(true);
else
RebuildRegions(true);
if(x<0 || y<0)
_parent->Invalidate(oldframe);
// Invalidate(Frame());
*/
}
/*!
\brief Rebuilds visibility regions
\param include_children Flag to rebuild all children and subchildren
*/
void Layer::RebuildRegions(bool include_children=true)
{
/* BRegion *reg,*reg2;
BRegion *reg,*reg2;
if(_full)
_full->Include(Bounds());
else
@ -562,9 +640,9 @@ void Layer::RebuildRegions(bool include_children=true)
lay->RebuildRegions(true);
}
}
*/
}
//! Prints all relevant layer data to stdout
void Layer::PrintToStream(void)
{
printf("-----------\nLayer %s\n",_name->String());
@ -606,6 +684,7 @@ void Layer::PrintToStream(void)
printf("Is updating = %s\n",(_is_updating)?"yes":"no");
}
//! Prints hierarchy data to stdout
void Layer::PrintNode(void)
{
printf("-----------\nLayer %s\n",_name->String());
@ -637,13 +716,21 @@ void Layer::PrintNode(void)
printf("Visible Areas: NULL\n");
}
// Tested
/*!
\brief Converts the rectangle to the layer's parent coordinates
\param the rectangle to convert
\return the converted rectangle
*/
BRect Layer::ConvertToParent(BRect rect)
{
return (rect.OffsetByCopy(_frame.LeftTop()));
}
// Tested
/*!
\brief Converts the region to the layer's parent coordinates
\param the region to convert
\return the converted region
*/
BRegion Layer::ConvertToParent(BRegion *reg)
{
BRegion newreg;
@ -652,13 +739,21 @@ BRegion Layer::ConvertToParent(BRegion *reg)
return BRegion(newreg);
}
// Tested
/*!
\brief Converts the rectangle from the layer's parent coordinates
\param the rectangle to convert
\return the converted rectangle
*/
BRect Layer::ConvertFromParent(BRect rect)
{
return (rect.OffsetByCopy(_frame.left*-1,_frame.top*-1));
}
// Tested
/*!
\brief Converts the region from the layer's parent coordinates
\param the region to convert
\return the converted region
*/
BRegion Layer::ConvertFromParent(BRegion *reg)
{
BRegion newreg;
@ -667,7 +762,11 @@ BRegion Layer::ConvertFromParent(BRegion *reg)
return BRegion(newreg);
}
// Tested
/*!
\brief Converts the region to screen coordinates
\param the region to convert
\return the converted region
*/
BRegion Layer::ConvertToTop(BRegion *reg)
{
BRegion newreg;
@ -676,7 +775,11 @@ BRegion Layer::ConvertToTop(BRegion *reg)
return BRegion(newreg);
}
// Tested
/*!
\brief Converts the rectangle to screen coordinates
\param the rectangle to convert
\return the converted rectangle
*/
BRect Layer::ConvertToTop(BRect rect)
{
if (_parent!=NULL)
@ -685,7 +788,11 @@ BRect Layer::ConvertToTop(BRect rect)
return(rect);
}
// Tested
/*!
\brief Converts the region from screen coordinates
\param the region to convert
\return the converted region
*/
BRegion Layer::ConvertFromTop(BRegion *reg)
{
BRegion newreg;
@ -694,7 +801,11 @@ BRegion Layer::ConvertFromTop(BRegion *reg)
return BRegion(newreg);
}
// Tested
/*!
\brief Converts the rectangle from screen coordinates
\param the rectangle to convert
\return the converted rectangle
*/
BRect Layer::ConvertFromTop(BRect rect)
{
if (_parent!=NULL)

View File

@ -21,8 +21,7 @@
//
// File Name: Layer.h
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Class used for rendering to the frame buffer. One layer per
// view on screen and also for window decorators
// Description: Shadow BView class
//
//------------------------------------------------------------------------------
#ifndef _LAYER_H_
@ -39,6 +38,14 @@
class ServerWindow;
class PortLink;
/*!
\class Layer Layer.h
\brief Shadow BView class
Layers provide all sorts of functionality. They are the shadow class for BViews,
but they also provide the base class for other classes which handle drawing to
the frame buffer, like RootLayer and WindowBorder.
*/
class Layer
{
public:

View File

@ -36,7 +36,7 @@
#include "DisplayDriver.h"
#include "FontServer.h"
#include "ServerApp.h"
//#include "ServerWindow.h"
#include "ServerWindow.h"
#include "ServerCursor.h"
#include "ServerBitmap.h"
#include "ServerProtocol.h"
@ -89,7 +89,7 @@ ServerApp::~ServerApp(void)
int32 i;
// TODO: Enable this when we have ServerWindow implemented
/* ServerWindow *tempwin;
ServerWindow *tempwin;
for(i=0;i<_winlist->CountItems();i++)
{
tempwin=(ServerWindow*)_winlist->ItemAt(i);
@ -98,7 +98,7 @@ ServerApp::~ServerApp(void)
}
_winlist->MakeEmpty();
delete _winlist;
*/
ServerBitmap *tempbmp;
for(i=0;i<_bmplist->CountItems();i++)
{
@ -303,8 +303,6 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
}
case CREATE_WINDOW:
{
// TODO: Uncomment when ServerWindow has been implemented
/*
// Create the ServerWindow to node monitor a new OBWindow
// Attached data:
@ -328,7 +326,7 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
// Create the ServerWindow object for this window
ServerWindow *newwin=new ServerWindow(rect,(const char *)index,
winlook, winfeel, winflags,this,win_port,workspace);
winlook, winfeel, winflags,workspace,this,win_port);
_winlist->AddItem(newwin);
// Window looper is waiting for our reply. Send back the
@ -339,12 +337,10 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
replylink->Flush();
delete replylink;
*/ break;
break;
}
case DELETE_WINDOW:
{
// TODO: Uncomment when ServerWindow has been implemented
/*
// Received from a ServerWindow when its window quits
// Attached data:
@ -354,14 +350,14 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
for(int32 i=0;i<_winlist->CountItems();i++)
{
w=(ServerWindow*)_winlist->ItemAt(i);
if(w->thread==winid)
if(w->_monitorthread==winid)
{
_winlist->RemoveItem(w);
delete w;
break;
}
}
*/ break;
break;
}
case GFX_SET_SCREEN_MODE:
{

View File

@ -0,0 +1,392 @@
#include <AppDefs.h>
#include <Rect.h>
#include <string.h>
#include <stdio.h>
#include <Debug.h>
#include <View.h> // for B_XXXXX_MOUSE_BUTTON defines
#include "AppServer.h"
#include "Layer.h"
#include "PortLink.h"
#include "ServerWindow.h"
#include "ServerApp.h"
#include "ServerProtocol.h"
// TODO: include when we have WindowBorder.h
//#include "WindowBorder.h"
#include "Desktop.h"
// defined in WindowBorder.cpp locking not necessary - the only
// thread which accesses them is the Poller thread
extern bool is_moving_window,is_resizing_window,is_sliding_tab;
// Used in window focus management
ServerWindow *active_serverwindow=NULL;
ServerWindow::ServerWindow(BRect rect, const char *title, uint32 wlook, uint32 wfeel,
uint32 wflags, int32 workspace, ServerApp *winapp, port_id winport)
{
/* title=new BString;
if(string)
title->SetTo(string);
else
title->SetTo("Window");
// This must happen before the WindowBorder object - it needs this object's frame
// to be valid
frame=rect;
// set these early also - the decorator will also need them
winflags=wflags;
winlook=wlook;
winfeel=wfeel;
winborder=new WindowBorder(this, title->String());
// hard code this for now - window look also needs to be attached and sent to
// server by BWindow constructor
decorator=instantiate_decorator(frame,title->String(),winlook,winfeel,winflags,get_gfxdriver());
winborder->SetDecorator(decorator);
// sender is the monitored app's event port
sender=winport;
winlink=new PortLink(sender);
if(winapp!=NULL)
applink=new PortLink(winapp->receiver);
else
applink=NULL;
// receiver is the port to which the app sends messages for the server
receiver=create_port(30,title->String());
active=false;
hidecount=0;
// Spawn our message monitoring thread
thread=spawn_thread(MonitorWin,title->String(),B_NORMAL_PRIORITY,this);
if(thread!=B_NO_MORE_THREADS && thread!=B_NO_MEMORY)
resume_thread(thread);
workspace=index;
AddWindowToDesktop(this,index);
*/
}
ServerWindow::~ServerWindow(void)
{
/* RemoveWindowFromDesktop(this);
if(applink)
{
delete applink;
applink=NULL;
delete title;
delete winlink;
delete decorator;
delete winborder;
}
kill_thread(thread);
*/
}
void ServerWindow::RequestDraw(BRect rect)
{
/* winlink->SetOpCode(LAYER_DRAW);
winlink->Attach(&rect,sizeof(BRect));
winlink->Flush();
*/
}
void ServerWindow::Quit(void)
{
}
void ServerWindow::Show(void)
{
/* if(winborder)
{
winborder->ShowLayer();
ActivateWindow(this);
}
*/
}
void ServerWindow::Hide(void)
{
// if(winborder)
// winborder->HideLayer();
}
void ServerWindow::SetFocus(bool value)
{
/* if(active!=value)
{
active=value;
decorator->SetFocus(value);
decorator->Draw();
}
*/
}
void ServerWindow::WorkspaceActivated(int32 NewWorkspace, const BPoint Resolution, color_space CSpace)
{
}
void ServerWindow::WindowActivated(bool Active)
{
}
void ServerWindow::ScreenModeChanged(const BPoint Resolustion, color_space CSpace)
{
}
void ServerWindow::DispatchMessage(int32 code, int8 *msgbuffer)
{
switch(code)
{
default:
{
break;
}
}
}
int32 ServerWindow::MonitorWin(void *data)
{
/* ServerWindow *win=(ServerWindow *)data;
// Message-dispatching loop for the ServerWindow
int32 msgcode;
int8 *msgbuffer=NULL;
ssize_t buffersize,bytesread;
for(;;)
{
buffersize=port_buffer_size(receiver);
if(buffersize>0)
{
msgbuffer=new int8[buffersize];
bytesread=read_port(receiver,&msgcode,msgbuffer,buffersize);
}
else
bytesread=read_port(receiver,&msgcode,NULL,0);
if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK)
{
switch(msgcode)
{
case LAYER_CREATE:
{
// Received when a view is attached to a window. This will require
// us to attach a layer in the tree in the same manner and invalidate
// the area in which the new layer resides assuming that it is
// visible
// Attached Data:
// 1) (int32) id of the parent view
// 2) (int32) id of the child view
// 3) (BRect) frame in parent's coordinates
// 4) (int32) resize flags
// 5) (int32) view flags
// 6) (uint16) view's hide level
break;
}
case LAYER_DELETE:
{
// Received when a view is detached from a window. This is definitely
// the less taxing operation - we call PruneTree() on the removed
// layer, detach the layer itself, delete it, and invalidate the
// area assuming that the view was visible when removed
// Attached Data:
// 1) (int32) id of the removed view
break;
}
case SHOW_WINDOW:
{
Show();
break;
}
case HIDE_WINDOW:
{
Hide();
break;
}
case DELETE_WINDOW:
{
// Received from our window when it is told to quit, so tell our
// application to delete this object
applink->SetOpCode(DELETE_WINDOW);
applink->Attach((int32)thread);
applink->Flush();
break;
}
case VIEW_GET_TOKEN:
{
// Request to get a view identifier - this is synchronous, so reply
// immediately
// Attached data:
// 1) port_id reply port
port_id reply_port=*((port_id*)msgbuffer);
PortLink *link=new PortLink(reply_port);
link->Attach(view_counter++);
link->Flush();
break;
}
default:
DispatchMessage(msgcode,msgbuffer);
break;
}
}
if(buffersize>0)
delete msgbuffer;
if(msgcode==B_QUIT_REQUESTED)
break;
}
*/
return 0;
}
void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
{
/* ServerWindow *mousewin=NULL;
int8 *index=buffer;
// Find the window which will receive our mouse event.
Layer *root=GetRootLayer();
WindowBorder *winborder;
// activeborder is used to remember windows when resizing/moving windows
// or sliding a tab
ASSERT(root!=NULL);
// Dispatch the mouse event to the proper window
switch(code)
{
case B_MOUSE_DOWN:
{
// Attached data:
// 1) int64 - time of mouse click
// 2) float - x coordinate of mouse click
// 3) float - y coordinate of mouse click
// 4) int32 - modifier keys down
// 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);
BPoint pt(x,y);
// If we have clicked on a window,
winborder=(WindowBorder*)root->GetChildAt(pt);
if(winborder)
{
mousewin=winborder->Window();
ASSERT(mousewin!=NULL);
winborder->MouseDown(pt,buttons,modifiers);
}
break;
}
case B_MOUSE_UP:
{
// Attached data:
// 1) int64 - time of mouse click
// 2) float - x coordinate of mouse click
// 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);
BPoint pt(x,y);
is_moving_window=false;
winborder=(WindowBorder*)root->GetChildAt(pt);
if(winborder)
{
mousewin=winborder->Window();
ASSERT(mousewin!=NULL);
// Eventually, we will build in MouseUp messages with buttons specified
// For now, we just "assume" no mouse specification with a 0.
winborder->MouseUp(pt,0,0);
// Do cool mouse stuff here
}
break;
}
case B_MOUSE_MOVED:
{
// Attached data:
// 1) int64 - time of mouse click
// 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);
uint32 buttons=*((uint32*)index);
BPoint pt(x,y);
if(is_moving_window || is_resizing_window || is_sliding_tab)
{
mousewin=active_serverwindow;
ASSERT(mousewin!=NULL);
mousewin->winborder->MouseMoved(pt,buttons,0);
}
else
{
winborder=(WindowBorder*)root->GetChildAt(pt);
if(winborder)
{
mousewin=winborder->Window();
ASSERT(mousewin!=NULL);
winborder->MouseMoved(pt,buttons,0);
}
}
break;
}
default:
{
break;
}
}
*/
}
void ActivateWindow(ServerWindow *win)
{
/* if(active_serverwindow==win)
return;
if(active_serverwindow)
active_serverwindow->SetFocus(false);
active_serverwindow=win;
if(win)
win->SetFocus(true);
*/
}

View File

@ -0,0 +1,75 @@
#ifndef _SERVERWIN_H_
#define _SERVERWIN_H_
#include <SupportDefs.h>
#include <GraphicsDefs.h>
#include <OS.h>
#include <Locker.h>
#include <Rect.h>
#include <String.h>
class BString;
class BPoint;
class ServerApp;
class Decorator;
class PortLink;
class WindowBorder;
class ServerWindow
{
public:
ServerWindow(BRect rect, const char *title, uint32 wlook, uint32 wfeel,
uint32 wflags, int32 workspace, ServerApp *winapp, port_id winport);
~ServerWindow(void);
void Show(void);
void Hide(void);
bool IsHidden(void) { return (_hidecount==0)?true:false; }
void RequestDraw(BRect rect);
void DispatchMessage(int32 code, int8 *msgbuffer);
static int32 MonitorWin(void *data);
void DoUpdate(uint32 size, int8 *buffer);
int32 Flags(void) { return _flags; }
int32 Look(void) { return _look; }
int32 Feel(void) { return _feel; }
int32 Workspace(void) { return _workspace; }
const char *Title(void) { return _title->String(); }
ServerApp *App(void) { return _app; }
BRect Frame(void);
void Quit(void);
void SetFocus(bool value);
bool HasFocus(void);
void WorkspaceActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace);
void WindowActivated(bool Active);
void ScreenModeChanged(const BPoint Resolution, color_space CSpace);
static void HandleMouseEvent(int32 code, int8 *buffer);
protected:
friend ServerApp;
BString *_title;
int32 _look, _feel, _flags;
int32 _workspace;
bool _active;
ServerApp *_app;
Decorator *_decorator;
WindowBorder *_winborder;
bigtime_t _lasthit;
thread_id _monitorthread;
port_id _receiver;
port_id _sender;
PortLink *_winlink,*_applink;
BRect _frame;
uint8 _hidecount;
};
void ActivateWindow(ServerWindow *win);
#endif