More code written on ServerWindow
Added skeleton of new_decorator() git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2695 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -747,6 +747,12 @@ ServerApp *AppServer::FindApp(const char *sig)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel,
|
||||||
|
int32 wflags, DisplayDriver *ddriver)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Entry function to run the entire server
|
\brief Entry function to run the entire server
|
||||||
\param argc Number of command-line arguments present
|
\param argc Number of command-line arguments present
|
||||||
@@ -764,3 +770,4 @@ int main( int argc, char** argv )
|
|||||||
delete app_server;
|
delete app_server;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,11 @@ public:
|
|||||||
void HandleKeyMessage(int32 code, int8 *buffer);
|
void HandleKeyMessage(int32 code, int8 *buffer);
|
||||||
ServerApp *FindApp(const char *sig);
|
ServerApp *FindApp(const char *sig);
|
||||||
|
|
||||||
create_decorator *make_decorator; // global function pointer
|
|
||||||
private:
|
private:
|
||||||
friend Decorator *instantiate_decorator(Layer *lay, const char *title, uint32 dflags, uint32 wlook);
|
friend Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel,
|
||||||
|
int32 wflags, DisplayDriver *ddriver);
|
||||||
|
|
||||||
|
create_decorator *make_decorator; // global function pointer
|
||||||
|
|
||||||
port_id _messageport,_mouseport;
|
port_id _messageport,_mouseport;
|
||||||
image_id _decorator_id;
|
image_id _decorator_id;
|
||||||
@@ -52,6 +54,6 @@ private:
|
|||||||
DisplayDriver *_driver;
|
DisplayDriver *_driver;
|
||||||
};
|
};
|
||||||
|
|
||||||
Decorator *instantiate_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel,
|
Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel,
|
||||||
int32 wflags, DisplayDriver *ddriver);
|
int32 wflags, DisplayDriver *ddriver);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
|
|||||||
|
|
||||||
// Create the ServerWindow object for this window
|
// Create the ServerWindow object for this window
|
||||||
ServerWindow *newwin=new ServerWindow(rect,(const char *)index,
|
ServerWindow *newwin=new ServerWindow(rect,(const char *)index,
|
||||||
winlook, winfeel, winflags,workspace,this,win_port);
|
winlook, winfeel, winflags,this,win_port,workspace);
|
||||||
_winlist->AddItem(newwin);
|
_winlist->AddItem(newwin);
|
||||||
|
|
||||||
// Window looper is waiting for our reply. Send back the
|
// Window looper is waiting for our reply. Send back the
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public:
|
|||||||
void PostMessage(int32 code, size_t size=0, int8 *buffer=NULL);
|
void PostMessage(int32 code, size_t size=0, int8 *buffer=NULL);
|
||||||
protected:
|
protected:
|
||||||
friend AppServer;
|
friend AppServer;
|
||||||
|
friend ServerWindow;
|
||||||
void DispatchMessage(int32 code, int8 *buffer);
|
void DispatchMessage(int32 code, int8 *buffer);
|
||||||
|
|
||||||
port_id _sender,_receiver;
|
port_id _sender,_receiver;
|
||||||
|
|||||||
@@ -1,3 +1,29 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2001-2002, OpenBeOS
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
// File Name: ServerWindow.cpp
|
||||||
|
// Author: DarkWyrm <[email protected]>
|
||||||
|
// Description: Shadow BWindow class
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
#include <AppDefs.h>
|
#include <AppDefs.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -10,152 +36,195 @@
|
|||||||
#include "ServerWindow.h"
|
#include "ServerWindow.h"
|
||||||
#include "ServerApp.h"
|
#include "ServerApp.h"
|
||||||
#include "ServerProtocol.h"
|
#include "ServerProtocol.h"
|
||||||
|
// TODO: uncomment this when we have WindowBorder.h
|
||||||
// TODO: include when we have WindowBorder.h
|
|
||||||
//#include "WindowBorder.h"
|
//#include "WindowBorder.h"
|
||||||
#include "Desktop.h"
|
#include "Desktop.h"
|
||||||
|
#include "TokenHandler.h"
|
||||||
|
|
||||||
// defined in WindowBorder.cpp locking not necessary - the only
|
//! Handler to get BWindow tokens from
|
||||||
// thread which accesses them is the Poller thread
|
TokenHandler win_token_handler;
|
||||||
extern bool is_moving_window,is_resizing_window,is_sliding_tab;
|
|
||||||
|
|
||||||
// Used in window focus management
|
// defined in WindowBorder.cpp. Locking is not necessary - the only
|
||||||
|
// _monitorthread which accesses them is the Poller _monitorthread
|
||||||
|
|
||||||
|
// TODO: Uncomment the extern keyword when we have WindowBorder.h
|
||||||
|
/* extern */bool is_moving_window,is_resizing_window,is_sliding_tab;
|
||||||
|
|
||||||
|
//! Used in window focus management
|
||||||
ServerWindow *active_serverwindow=NULL;
|
ServerWindow *active_serverwindow=NULL;
|
||||||
|
|
||||||
ServerWindow::ServerWindow(BRect rect, const char *title, uint32 wlook, uint32 wfeel,
|
/*!
|
||||||
uint32 wflags, int32 workspace, ServerApp *winapp, port_id winport)
|
\brief Contructor
|
||||||
{
|
|
||||||
/* 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;
|
|
||||||
|
|
||||||
|
Sets up a lot of the stuff
|
||||||
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(BRect rect, const char *string, uint32 wlook,
|
||||||
|
uint32 wfeel, uint32 wflags, ServerApp *winapp, port_id winport, uint32 index)
|
||||||
|
{
|
||||||
|
_title=new BString;
|
||||||
|
_title->SetTo( (string)?string:"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
|
||||||
|
_flags=wflags;
|
||||||
|
_look=wlook;
|
||||||
|
_feel=wfeel;
|
||||||
|
|
||||||
|
// TODO: uncomment this when we have WindowBorder.h
|
||||||
|
// _winborder=new WindowBorder(this, _title->String());
|
||||||
|
|
||||||
|
_decorator=new_decorator(_frame,_title->String(),_look,_feel,_flags,GetGfxDriver());
|
||||||
|
// TODO: uncomment this when we have WindowBorder.h
|
||||||
|
// _winborder->SetDecorator(_decorator);
|
||||||
|
|
||||||
|
// _sender is the monitored _app's event port
|
||||||
|
_sender=winport;
|
||||||
|
_winlink=new PortLink(_sender);
|
||||||
|
|
||||||
|
_applink= (winapp)? new PortLink(winapp->_receiver) : 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 _monitorthread
|
||||||
|
_monitorthread=spawn_thread(MonitorWin,_title->String(),B_NORMAL_PRIORITY,this);
|
||||||
|
if(_monitorthread!=B_NO_MORE_THREADS && _monitorthread!=B_NO_MEMORY)
|
||||||
|
resume_thread(_monitorthread);
|
||||||
|
|
||||||
|
_workspace=index;
|
||||||
|
|
||||||
|
AddWindowToDesktop(this,index);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerWindow::~ServerWindow(void)
|
ServerWindow::~ServerWindow(void)
|
||||||
{
|
{
|
||||||
/* RemoveWindowFromDesktop(this);
|
RemoveWindowFromDesktop(this);
|
||||||
if(applink)
|
if(_applink)
|
||||||
{
|
{
|
||||||
delete applink;
|
delete _applink;
|
||||||
applink=NULL;
|
_applink=NULL;
|
||||||
|
delete _title;
|
||||||
delete title;
|
delete _winlink;
|
||||||
delete winlink;
|
delete _decorator;
|
||||||
delete decorator;
|
// TODO: uncomment this when we have WindowBorder.h
|
||||||
delete winborder;
|
// delete _winborder;
|
||||||
}
|
}
|
||||||
kill_thread(thread);
|
kill_thread(_monitorthread);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerWindow::RequestDraw(BRect rect)
|
void ServerWindow::RequestDraw(BRect rect)
|
||||||
{
|
{
|
||||||
/* winlink->SetOpCode(LAYER_DRAW);
|
_winlink->SetOpCode(LAYER_DRAW);
|
||||||
winlink->Attach(&rect,sizeof(BRect));
|
_winlink->Attach(&rect,sizeof(BRect));
|
||||||
winlink->Flush();
|
_winlink->Flush();
|
||||||
*/
|
}
|
||||||
|
|
||||||
|
void ServerWindow::ReplaceDecorator(void)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerWindow::Quit(void)
|
void ServerWindow::Quit(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *ServerWindow::GetTitle(void)
|
||||||
|
{
|
||||||
|
return _title->String();
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerApp *ServerWindow::GetApp(void)
|
||||||
|
{
|
||||||
|
return _app;
|
||||||
|
}
|
||||||
|
|
||||||
void ServerWindow::Show(void)
|
void ServerWindow::Show(void)
|
||||||
{
|
{
|
||||||
/* if(winborder)
|
if(_winborder)
|
||||||
{
|
{
|
||||||
winborder->ShowLayer();
|
// TODO: uncomment this when we have WindowBorder.h
|
||||||
|
// _winborder->ShowLayer();
|
||||||
ActivateWindow(this);
|
ActivateWindow(this);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerWindow::Hide(void)
|
void ServerWindow::Hide(void)
|
||||||
{
|
{
|
||||||
// if(winborder)
|
// TODO: uncomment this when we have WindowBorder.h
|
||||||
// winborder->HideLayer();
|
// if(_winborder)
|
||||||
|
// _winborder->HideLayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ServerWindow::IsHidden(void)
|
||||||
|
{
|
||||||
|
return (_hidecount==0)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerWindow::SetFocus(bool value)
|
void ServerWindow::SetFocus(bool value)
|
||||||
{
|
{
|
||||||
/* if(active!=value)
|
if(_active!=value)
|
||||||
{
|
{
|
||||||
active=value;
|
_active=value;
|
||||||
decorator->SetFocus(value);
|
_decorator->SetFocus(value);
|
||||||
decorator->Draw();
|
_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)
|
bool ServerWindow::HasFocus(void)
|
||||||
|
{
|
||||||
|
return _active;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerWindow::WorkspaceActivated(int32 newworkspace, const BPoint reso, color_space cspace)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerWindow::WindowActivated(bool active)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerWindow::ScreenModeChanged(const BPoint res, color_space cspace)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerWindow::SetFrame(const BRect &rect)
|
||||||
|
{
|
||||||
|
_frame=rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRect ServerWindow::Frame(void)
|
||||||
|
{
|
||||||
|
return _frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t ServerWindow::Lock(void)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_SERVERWIN
|
||||||
|
printf("%s::Lock()\n",_title->String());
|
||||||
|
#endif
|
||||||
|
return _locker.Lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerWindow::Unlock(void)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_SERVERWIN
|
||||||
|
printf("%s::Unlock()\n",_title->String());
|
||||||
|
#endif
|
||||||
|
_locker.Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ServerWindow::IsLocked(void)
|
||||||
|
{
|
||||||
|
return _locker.IsLocked();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerWindow::Loop(void)
|
||||||
{
|
{
|
||||||
/* ServerWindow *win=(ServerWindow *)data;
|
|
||||||
// Message-dispatching loop for the ServerWindow
|
// Message-dispatching loop for the ServerWindow
|
||||||
int32 msgcode;
|
int32 msgcode;
|
||||||
int8 *msgbuffer=NULL;
|
int8 *msgbuffer=NULL;
|
||||||
@@ -163,15 +232,15 @@ int32 ServerWindow::MonitorWin(void *data)
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
buffersize=port_buffer_size(receiver);
|
buffersize=port_buffer_size(_receiver);
|
||||||
|
|
||||||
if(buffersize>0)
|
if(buffersize>0)
|
||||||
{
|
{
|
||||||
msgbuffer=new int8[buffersize];
|
msgbuffer=new int8[buffersize];
|
||||||
bytesread=read_port(receiver,&msgcode,msgbuffer,buffersize);
|
bytesread=read_port(_receiver,&msgcode,msgbuffer,buffersize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
bytesread=read_port(receiver,&msgcode,NULL,0);
|
bytesread=read_port(_receiver,&msgcode,NULL,0);
|
||||||
|
|
||||||
if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK)
|
if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK)
|
||||||
{
|
{
|
||||||
@@ -182,15 +251,17 @@ int32 ServerWindow::MonitorWin(void *data)
|
|||||||
// Received when a view is attached to a window. This will require
|
// 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
|
// 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
|
// the area in which the new layer resides assuming that it is
|
||||||
// visible
|
// visible.
|
||||||
|
|
||||||
// Attached Data:
|
// Attached Data:
|
||||||
// 1) (int32) id of the parent view
|
// 1) (int32) id of the parent view
|
||||||
// 2) (int32) id of the child view
|
// 2) (BRect) frame in parent's coordinates
|
||||||
// 3) (BRect) frame in parent's coordinates
|
// 3) (int32) resize flags
|
||||||
// 4) (int32) resize flags
|
// 4) (int32) view flags
|
||||||
// 5) (int32) view flags
|
// 5) (uint16) view's hide level
|
||||||
// 6) (uint16) view's hide level
|
|
||||||
|
// This is a synchronous call, so reply immediately with the ID of the layer
|
||||||
|
// so the BView can identify itself
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -219,22 +290,9 @@ int32 ServerWindow::MonitorWin(void *data)
|
|||||||
{
|
{
|
||||||
// Received from our window when it is told to quit, so tell our
|
// Received from our window when it is told to quit, so tell our
|
||||||
// application to delete this object
|
// application to delete this object
|
||||||
applink->SetOpCode(DELETE_WINDOW);
|
_applink->SetOpCode(DELETE_WINDOW);
|
||||||
applink->Attach((int32)thread);
|
_applink->Attach((int32)_monitorthread);
|
||||||
applink->Flush();
|
_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;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -250,18 +308,39 @@ int32 ServerWindow::MonitorWin(void *data)
|
|||||||
if(msgcode==B_QUIT_REQUESTED)
|
if(msgcode==B_QUIT_REQUESTED)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
}
|
||||||
|
|
||||||
|
void ServerWindow::DispatchMessage(int32 code, int8 *msgbuffer)
|
||||||
|
{
|
||||||
|
switch(code)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_SERVERWIN
|
||||||
|
printf("%s::ServerWindow(): Received unexpected code: ",_title->String());
|
||||||
|
PrintMessageCode(code);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 ServerWindow::MonitorWin(void *data)
|
||||||
|
{
|
||||||
|
ServerWindow *win=(ServerWindow *)data;
|
||||||
|
win->Loop();
|
||||||
|
exit_thread(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
|
void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
|
||||||
{
|
{
|
||||||
/* ServerWindow *mousewin=NULL;
|
ServerWindow *mousewin=NULL;
|
||||||
int8 *index=buffer;
|
int8 *index=buffer;
|
||||||
|
|
||||||
// Find the window which will receive our mouse event.
|
// Find the window which will receive our mouse event.
|
||||||
Layer *root=GetRootLayer();
|
Layer *root=GetRootLayer();
|
||||||
WindowBorder *winborder;
|
WindowBorder *_winborder;
|
||||||
|
|
||||||
// activeborder is used to remember windows when resizing/moving windows
|
// activeborder is used to remember windows when resizing/moving windows
|
||||||
// or sliding a tab
|
// or sliding a tab
|
||||||
@@ -294,12 +373,12 @@ void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
|
|||||||
BPoint pt(x,y);
|
BPoint pt(x,y);
|
||||||
|
|
||||||
// If we have clicked on a window,
|
// If we have clicked on a window,
|
||||||
winborder=(WindowBorder*)root->GetChildAt(pt);
|
_winborder=(WindowBorder*)root->GetChildAt(pt);
|
||||||
if(winborder)
|
if(_winborder)
|
||||||
{
|
{
|
||||||
mousewin=winborder->Window();
|
// TODO: Uncomment when we have WindowBorder.h
|
||||||
ASSERT(mousewin!=NULL);
|
// mousewin=_winborder->Window();
|
||||||
winborder->MouseDown(pt,buttons,modifiers);
|
// _winborder->MouseDown(pt,buttons,modifiers);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -321,17 +400,16 @@ void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
|
|||||||
BPoint pt(x,y);
|
BPoint pt(x,y);
|
||||||
|
|
||||||
is_moving_window=false;
|
is_moving_window=false;
|
||||||
winborder=(WindowBorder*)root->GetChildAt(pt);
|
_winborder=(WindowBorder*)root->GetChildAt(pt);
|
||||||
if(winborder)
|
if(_winborder)
|
||||||
{
|
{
|
||||||
mousewin=winborder->Window();
|
// TODO: Uncomment when we have WindowBorder.h
|
||||||
ASSERT(mousewin!=NULL);
|
// mousewin=_winborder->Window();
|
||||||
|
|
||||||
// Eventually, we will build in MouseUp messages with buttons specified
|
// Eventually, we will build in MouseUp messages with buttons specified
|
||||||
// For now, we just "assume" no mouse specification with a 0.
|
// For now, we just "assume" no mouse specification with a 0.
|
||||||
winborder->MouseUp(pt,0,0);
|
// _winborder->MouseUp(pt,0,0);
|
||||||
|
|
||||||
// Do cool mouse stuff here
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -354,19 +432,17 @@ void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
|
|||||||
if(is_moving_window || is_resizing_window || is_sliding_tab)
|
if(is_moving_window || is_resizing_window || is_sliding_tab)
|
||||||
{
|
{
|
||||||
mousewin=active_serverwindow;
|
mousewin=active_serverwindow;
|
||||||
ASSERT(mousewin!=NULL);
|
// TODO: Uncomment when we have WindowBorder.h
|
||||||
|
// mousewin->_winborder->MouseMoved(pt,buttons,0);
|
||||||
mousewin->winborder->MouseMoved(pt,buttons,0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
winborder=(WindowBorder*)root->GetChildAt(pt);
|
_winborder=(WindowBorder*)root->GetChildAt(pt);
|
||||||
if(winborder)
|
if(_winborder)
|
||||||
{
|
{
|
||||||
mousewin=winborder->Window();
|
// TODO: Uncomment when we have WindowBorder.h
|
||||||
ASSERT(mousewin!=NULL);
|
// mousewin=_winborder->Window();
|
||||||
|
// _winborder->MouseMoved(pt,buttons,0);
|
||||||
winborder->MouseMoved(pt,buttons,0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -376,17 +452,15 @@ void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivateWindow(ServerWindow *win)
|
void ActivateWindow(ServerWindow *win)
|
||||||
{
|
{
|
||||||
/* if(active_serverwindow==win)
|
if(active_serverwindow==win)
|
||||||
return;
|
return;
|
||||||
if(active_serverwindow)
|
if(active_serverwindow)
|
||||||
active_serverwindow->SetFocus(false);
|
active_serverwindow->SetFocus(false);
|
||||||
active_serverwindow=win;
|
active_serverwindow=win;
|
||||||
if(win)
|
if(win)
|
||||||
win->SetFocus(true);
|
win->SetFocus(true);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,29 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2001-2002, OpenBeOS
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
// File Name: ServerWindow.h
|
||||||
|
// Author: DarkWyrm <[email protected]>
|
||||||
|
// Description: Shadow BWindow class
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
#ifndef _SERVERWIN_H_
|
#ifndef _SERVERWIN_H_
|
||||||
#define _SERVERWIN_H_
|
#define _SERVERWIN_H_
|
||||||
|
|
||||||
@@ -9,6 +35,7 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
class BString;
|
class BString;
|
||||||
|
class BMessenger;
|
||||||
class BPoint;
|
class BPoint;
|
||||||
class ServerApp;
|
class ServerApp;
|
||||||
class Decorator;
|
class Decorator;
|
||||||
@@ -18,55 +45,58 @@ class WindowBorder;
|
|||||||
class ServerWindow
|
class ServerWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServerWindow(BRect rect, const char *title, uint32 wlook, uint32 wfeel,
|
ServerWindow(BRect rect, const char *string, uint32 wlook, uint32 wfeel,
|
||||||
uint32 wflags, int32 workspace, ServerApp *winapp, port_id winport);
|
uint32 wflags, ServerApp *winapp, port_id winport, uint32 index);
|
||||||
~ServerWindow(void);
|
~ServerWindow(void);
|
||||||
|
|
||||||
|
void ReplaceDecorator(void);
|
||||||
|
void Quit(void);
|
||||||
|
const char *GetTitle(void);
|
||||||
|
ServerApp *GetApp(void);
|
||||||
void Show(void);
|
void Show(void);
|
||||||
void Hide(void);
|
void Hide(void);
|
||||||
bool IsHidden(void) { return (_hidecount==0)?true:false; }
|
bool IsHidden(void);
|
||||||
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);
|
void SetFocus(bool value);
|
||||||
bool HasFocus(void);
|
bool HasFocus(void);
|
||||||
|
void RequestDraw(BRect rect);
|
||||||
|
|
||||||
void WorkspaceActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace);
|
void WorkspaceActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace);
|
||||||
void WindowActivated(bool Active);
|
void WindowActivated(bool Active);
|
||||||
void ScreenModeChanged(const BPoint Resolution, color_space CSpace);
|
void ScreenModeChanged(const BPoint Resolution, color_space CSpace);
|
||||||
|
|
||||||
|
void SetFrame(const BRect &rect);
|
||||||
|
BRect Frame(void);
|
||||||
|
|
||||||
|
status_t Lock(void);
|
||||||
|
void Unlock(void);
|
||||||
|
bool IsLocked(void);
|
||||||
|
|
||||||
|
void DispatchMessage(int32 code, int8 *msgbuffer);
|
||||||
|
static int32 MonitorWin(void *data);
|
||||||
static void HandleMouseEvent(int32 code, int8 *buffer);
|
static void HandleMouseEvent(int32 code, int8 *buffer);
|
||||||
|
static void HandleKeyEvent(int32 code, int8 *buffer);
|
||||||
|
void Loop(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend ServerApp;
|
friend ServerApp;
|
||||||
|
|
||||||
BString *_title;
|
BString *_title;
|
||||||
int32 _look, _feel, _flags;
|
int32 _look, _feel, _flags;
|
||||||
int32 _workspace;
|
int32 _workspace;
|
||||||
bool _active;
|
bool _active;
|
||||||
|
|
||||||
ServerApp *_app;
|
ServerApp *_app;
|
||||||
|
|
||||||
Decorator *_decorator;
|
Decorator *_decorator;
|
||||||
WindowBorder *_winborder;
|
WindowBorder *_winborder;
|
||||||
bigtime_t _lasthit;
|
|
||||||
|
|
||||||
thread_id _monitorthread;
|
thread_id _monitorthread;
|
||||||
port_id _receiver;
|
port_id _receiver; // Messages from window
|
||||||
port_id _sender;
|
port_id _sender; // Messages to window
|
||||||
PortLink *_winlink,*_applink;
|
PortLink *_winlink,*_applink;
|
||||||
|
BLocker _locker;
|
||||||
BRect _frame;
|
BRect _frame;
|
||||||
uint8 _hidecount;
|
uint8 _hidecount;
|
||||||
|
uint32 _token;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ActivateWindow(ServerWindow *win);
|
void ActivateWindow(ServerWindow *win);
|
||||||
|
|||||||
Reference in New Issue
Block a user