2003-02-12 04:11:55 +03:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// 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 <bpmagic@columbus.rr.com>
|
|
|
|
// Description: Shadow BWindow class
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
2003-02-07 15:53:57 +03:00
|
|
|
#include <AppDefs.h>
|
|
|
|
#include <Rect.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.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"
|
2003-02-14 04:53:53 +03:00
|
|
|
#include "WinBorder.h"
|
2003-02-07 15:53:57 +03:00
|
|
|
#include "Desktop.h"
|
2003-02-24 18:47:06 +03:00
|
|
|
#include "DesktopClasses.h"
|
2003-02-12 04:11:55 +03:00
|
|
|
#include "TokenHandler.h"
|
2003-06-24 17:55:18 +04:00
|
|
|
#include "Utils.h"
|
2003-02-12 04:11:55 +03:00
|
|
|
|
2003-06-28 23:06:30 +04:00
|
|
|
//#define DEBUG_SERVERWINDOW
|
2003-03-23 23:52:37 +03:00
|
|
|
//#define DEBUG_SERVERWINDOW_MOUSE
|
|
|
|
//#define DEBUG_SERVERWINDOW_KEYBOARD
|
|
|
|
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
|
|
|
|
2003-02-12 04:11:55 +03:00
|
|
|
//! Handler to get BWindow tokens from
|
|
|
|
TokenHandler win_token_handler;
|
|
|
|
|
2003-06-28 23:06:30 +04:00
|
|
|
//! Active winborder - used for tracking windows during moves, resizes, and tab slides
|
|
|
|
WinBorder *active_winborder=NULL;
|
|
|
|
|
2003-07-05 01:13:48 +04:00
|
|
|
template<class Type> Type
|
|
|
|
read_from_buffer(int8 **_buffer)
|
|
|
|
{
|
|
|
|
Type *typedBuffer = (Type *)(*_buffer);
|
|
|
|
Type value = *typedBuffer;
|
|
|
|
|
|
|
|
typedBuffer++;
|
|
|
|
*_buffer = (int8 *)(typedBuffer);
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int8 *read_pattern_from_buffer(int8 **_buffer)
|
|
|
|
{
|
|
|
|
int8 *pattern = *_buffer;
|
|
|
|
|
|
|
|
*_buffer += AS_PATTERN_SIZE;
|
|
|
|
|
|
|
|
return pattern;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Type> void
|
|
|
|
write_to_buffer(int8 **_buffer, Type value)
|
|
|
|
{
|
|
|
|
Type *typedBuffer = (Type *)(*_buffer);
|
|
|
|
|
|
|
|
*typedBuffer = value;
|
|
|
|
typedBuffer++;
|
|
|
|
|
|
|
|
*_buffer = (int8 *)(typedBuffer);
|
|
|
|
}
|
|
|
|
|
2003-02-12 04:11:55 +03:00
|
|
|
/*!
|
|
|
|
\brief Contructor
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
Does a lot of stuff to set up for the window - new decorator, new winborder, spawn a
|
|
|
|
monitor thread.
|
2003-02-12 04:11:55 +03:00
|
|
|
*/
|
|
|
|
ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
|
2003-03-19 04:12:53 +03:00
|
|
|
uint32 wfeel, uint32 wflags, ServerApp *winapp, port_id winport, uint32 index, int32 handlerID)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-02-12 04:11:55 +03:00
|
|
|
_title=new BString;
|
2003-03-12 21:32:27 +03:00
|
|
|
if(string)
|
|
|
|
_title->SetTo(string);
|
2003-02-12 04:11:55 +03:00
|
|
|
_frame=rect;
|
|
|
|
_flags=wflags;
|
|
|
|
_look=wlook;
|
|
|
|
_feel=wfeel;
|
2003-03-19 04:12:53 +03:00
|
|
|
_handlertoken=handlerID;
|
2003-02-07 15:53:57 +03:00
|
|
|
|
2003-03-12 21:32:27 +03:00
|
|
|
_winborder=new WinBorder(_frame,_title->String(),wlook,wfeel,wflags,this);
|
2003-02-07 15:53:57 +03:00
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
// _sender is the monitored window's event port
|
2003-02-12 04:11:55 +03:00
|
|
|
_sender=winport;
|
|
|
|
_winlink=new PortLink(_sender);
|
2003-02-07 15:53:57 +03:00
|
|
|
|
2003-02-12 04:11:55 +03:00
|
|
|
_applink= (winapp)? new PortLink(winapp->_receiver) : NULL;
|
2003-02-07 15:53:57 +03:00
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
// _receiver is the port to which the app sends messages for the server
|
2003-02-12 04:11:55 +03:00
|
|
|
_receiver=create_port(30,_title->String());
|
2003-02-07 15:53:57 +03:00
|
|
|
|
2003-02-12 04:11:55 +03:00
|
|
|
_active=false;
|
|
|
|
|
|
|
|
// 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);
|
2003-02-07 15:53:57 +03:00
|
|
|
|
2003-02-20 16:13:01 +03:00
|
|
|
_workspace_index=index;
|
2003-02-20 21:05:35 +03:00
|
|
|
_workspace=NULL;
|
2003-02-07 15:53:57 +03:00
|
|
|
|
2003-03-12 22:34:47 +03:00
|
|
|
_token=win_token_handler.GetToken();
|
|
|
|
|
2003-04-05 05:51:35 +04:00
|
|
|
AddWindowToDesktop(this,index,ActiveScreen());
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s:\n",_title->String());
|
|
|
|
printf("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom);
|
|
|
|
printf("\tPort: %ld\n",_receiver);
|
|
|
|
printf("\tWorkspace: %ld\n",index);
|
|
|
|
#endif
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
//!Tears down all connections with the user application, kills the monitoring thread.
|
2003-02-07 15:53:57 +03:00
|
|
|
ServerWindow::~ServerWindow(void)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s:~ServerWindow()\n",_title->String());
|
|
|
|
#endif
|
2003-02-12 04:11:55 +03:00
|
|
|
RemoveWindowFromDesktop(this);
|
|
|
|
if(_applink)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-02-12 04:11:55 +03:00
|
|
|
delete _applink;
|
|
|
|
_applink=NULL;
|
|
|
|
delete _title;
|
|
|
|
delete _winlink;
|
2003-02-24 18:47:06 +03:00
|
|
|
delete _winborder;
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
2003-02-12 04:11:55 +03:00
|
|
|
kill_thread(_monitorthread);
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Requests an update of the specified rectangle
|
|
|
|
\param rect The area to update, in the parent's coordinates
|
|
|
|
|
|
|
|
This could be considered equivalent to BView::Invalidate()
|
|
|
|
*/
|
2003-02-07 15:53:57 +03:00
|
|
|
void ServerWindow::RequestDraw(BRect rect)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Request Draw\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
_winlink->SetOpCode(AS_LAYER_DRAW);
|
2003-02-12 04:11:55 +03:00
|
|
|
_winlink->Attach(&rect,sizeof(BRect));
|
|
|
|
_winlink->Flush();
|
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
//! Requests an update for the entire window
|
|
|
|
void ServerWindow::RequestDraw(void)
|
|
|
|
{
|
|
|
|
RequestDraw(_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Forces the window border to update its decorator
|
2003-02-12 04:11:55 +03:00
|
|
|
void ServerWindow::ReplaceDecorator(void)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Replace Decorator\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
_winborder->UpdateDecorator();
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
//! Requests that the ServerWindow's BWindow quit
|
2003-02-07 15:53:57 +03:00
|
|
|
void ServerWindow::Quit(void)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Quit\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
_winlink->SetOpCode(B_QUIT_REQUESTED);
|
|
|
|
_winlink->Flush();
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Gets the title for the window
|
|
|
|
\return The title for the window
|
|
|
|
*/
|
2003-02-12 04:11:55 +03:00
|
|
|
const char *ServerWindow::GetTitle(void)
|
|
|
|
{
|
|
|
|
return _title->String();
|
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Gets the window's ServerApp
|
|
|
|
\return The ServerApp for the window
|
|
|
|
*/
|
2003-02-12 04:11:55 +03:00
|
|
|
ServerApp *ServerWindow::GetApp(void)
|
|
|
|
{
|
|
|
|
return _app;
|
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
//! Shows the window's WinBorder
|
2003-02-07 15:53:57 +03:00
|
|
|
void ServerWindow::Show(void)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Show\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
if(_winborder)
|
2003-03-31 01:09:39 +04:00
|
|
|
{
|
2003-02-24 18:47:06 +03:00
|
|
|
_winborder->Show();
|
2003-03-31 01:09:39 +04:00
|
|
|
_winborder->UpdateRegions(true);
|
|
|
|
}
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
//! Hides the window's WinBorder
|
2003-02-07 15:53:57 +03:00
|
|
|
void ServerWindow::Hide(void)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Hide\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
if(_winborder)
|
|
|
|
_winborder->Hide();
|
2003-02-12 04:11:55 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*
|
|
|
|
\brief Determines whether the window is hidden or not
|
|
|
|
\return true if hidden, false if not
|
|
|
|
*/
|
2003-02-12 04:11:55 +03:00
|
|
|
bool ServerWindow::IsHidden(void)
|
|
|
|
{
|
2003-02-24 18:47:06 +03:00
|
|
|
if(_winborder)
|
|
|
|
return _winborder->IsHidden();
|
|
|
|
return true;
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Handles focus and redrawing when changing focus states
|
|
|
|
|
|
|
|
The ServerWindow is set to (in)active and its decorator is redrawn based on its active status
|
|
|
|
*/
|
2003-02-07 15:53:57 +03:00
|
|
|
void ServerWindow::SetFocus(bool value)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Set Focus to %s\n",_title->String(),value?"true":"false");
|
|
|
|
#endif
|
2003-02-12 04:11:55 +03:00
|
|
|
if(_active!=value)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-02-12 04:11:55 +03:00
|
|
|
_active=value;
|
2003-02-24 18:47:06 +03:00
|
|
|
_winborder->RequestDraw();
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Determines whether or not the window is active
|
|
|
|
\return true if active, false if not
|
|
|
|
*/
|
2003-02-12 04:11:55 +03:00
|
|
|
bool ServerWindow::HasFocus(void)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-02-12 04:11:55 +03:00
|
|
|
return _active;
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Notifies window of workspace (de)activation
|
|
|
|
\param workspace Index of the workspace changed
|
|
|
|
\param active New active status of the workspace
|
|
|
|
*/
|
|
|
|
void ServerWindow::WorkspaceActivated(int32 workspace, bool active)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: WorkspaceActivated unimplemented\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
// TODO: implement
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Notifies window of a workspace switch
|
|
|
|
\param oldone index of the previous workspace
|
|
|
|
\param newone index of the new workspace
|
|
|
|
*/
|
|
|
|
void ServerWindow::WorkspacesChanged(int32 oldone,int32 newone)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: WorkspaceChanged unimplemented\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
// TODO: implement
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Notifies window of a change in focus
|
|
|
|
\param active New active status of the window
|
|
|
|
*/
|
2003-02-12 04:11:55 +03:00
|
|
|
void ServerWindow::WindowActivated(bool active)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: WindowActivated unimplemented\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
// TODO: implement
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Notifies window of a change in screen resolution
|
|
|
|
\param frame Size of the new resolution
|
|
|
|
\param color_space Color space of the new screen mode
|
|
|
|
*/
|
|
|
|
void ServerWindow::ScreenModeChanged(const BRect frame, const color_space cspace)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: ScreenModeChanged unimplemented\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
// TODO: implement
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*
|
|
|
|
\brief Sets the frame size of the window
|
|
|
|
\rect New window size
|
|
|
|
*/
|
2003-02-12 04:11:55 +03:00
|
|
|
void ServerWindow::SetFrame(const BRect &rect)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Set Frame to (%.1f,%.1f,%.1f,%.1f)\n",_title->String(),
|
|
|
|
rect.left,rect.top,rect.right,rect.bottom);
|
|
|
|
#endif
|
2003-02-12 04:11:55 +03:00
|
|
|
_frame=rect;
|
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Returns the frame of the window in screen coordinates
|
|
|
|
\return The frame of the window in screen coordinates
|
|
|
|
*/
|
2003-02-12 04:11:55 +03:00
|
|
|
BRect ServerWindow::Frame(void)
|
|
|
|
{
|
|
|
|
return _frame;
|
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Locks the window
|
|
|
|
\return B_OK if everything is ok, B_ERROR if something went wrong
|
|
|
|
*/
|
2003-02-12 04:11:55 +03:00
|
|
|
status_t ServerWindow::Lock(void)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Lock\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
return (_locker.Lock())?B_OK:B_ERROR;
|
2003-02-12 04:11:55 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
//! Unlocks the window
|
2003-02-12 04:11:55 +03:00
|
|
|
void ServerWindow::Unlock(void)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Unlock\n",_title->String());
|
|
|
|
#endif
|
2003-02-12 04:11:55 +03:00
|
|
|
_locker.Unlock();
|
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Determines whether or not the window is locked
|
|
|
|
\return True if locked, false if not.
|
|
|
|
*/
|
2003-02-12 04:11:55 +03:00
|
|
|
bool ServerWindow::IsLocked(void)
|
|
|
|
{
|
|
|
|
return _locker.IsLocked();
|
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
void ServerWindow::DispatchMessage(int32 code, int8 *msgbuffer)
|
|
|
|
{
|
|
|
|
switch(code)
|
|
|
|
{
|
|
|
|
case AS_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) (BRect) frame in parent's coordinates
|
|
|
|
// 3) (int32) resize flags
|
|
|
|
// 4) (int32) view flags
|
|
|
|
// 5) (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
|
|
|
|
|
|
|
|
// TODO: Implement
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Create_Layer unimplemented\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_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
|
|
|
|
|
|
|
|
// TODO: Implement
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Delete_Layer unimplemented\n",_title->String());
|
2003-06-24 17:55:18 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_CREATE_ROOT:
|
|
|
|
{
|
|
|
|
// Received when a window creates its internal top view
|
|
|
|
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Create_Layer_Root unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_DELETE_ROOT:
|
|
|
|
{
|
|
|
|
// Received when a window deletes its internal top view
|
|
|
|
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Delete_Layer_Root unimplemented\n",_title->String());
|
2003-03-23 23:52:37 +03:00
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_SHOW_WINDOW:
|
|
|
|
{
|
|
|
|
Show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_HIDE_WINDOW:
|
|
|
|
{
|
|
|
|
Hide();
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_SEND_BEHIND:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Send_Behind unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_ENABLE_UPDATES:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Enable_Updates unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_DISABLE_UPDATES:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Disable_Updates unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_NEEDS_UPDATE:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Needs_Update unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_WINDOW_TITLE:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Set_Title unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_ADD_TO_SUBSET:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Add_To_Subset unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_REM_FROM_SUBSET:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Remove_From_Subset unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_SET_LOOK:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Set_Look unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_SET_FLAGS:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Set_Flags unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_SET_FEEL:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Set_Feel unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_SET_ALIGNMENT:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Set_Alignment unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_GET_ALIGNMENT:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Get_Alignment unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_GET_WORKSPACES:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Get_Workspaces unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_SET_WORKSPACES:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Set_Workspaces unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-04-18 23:58:43 +04:00
|
|
|
case AS_WINDOW_RESIZE:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
2003-04-18 23:58:43 +04:00
|
|
|
printf("ServerWindow %s: Message Resize unimplemented\n",_title->String());
|
2003-03-23 23:52:37 +03:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
case B_MINIMIZE:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Minimize unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
case B_WINDOW_ACTIVATED:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Window_Activated unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
case B_ZOOM:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Zoom unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
case B_WINDOW_MOVE_TO:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Move_To unimplemented\n",_title->String());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
case B_WINDOW_MOVE_BY:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Message Move_By unimplemented\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
break;
|
2003-03-23 23:52:37 +03:00
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
default:
|
|
|
|
{
|
2003-06-24 17:55:18 +04:00
|
|
|
printf("ServerWindow %s received unexpected code %s\n",_title->String(),MsgCodeToString(code));
|
2003-02-24 18:47:06 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-19 04:12:53 +03:00
|
|
|
/*!
|
|
|
|
\brief Iterator for graphics update messages
|
|
|
|
\param msgsize Size of the buffer containing the graphics messages
|
|
|
|
\param msgbuffer Buffer containing the graphics message
|
|
|
|
*/
|
|
|
|
void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
|
|
|
|
{
|
2003-07-05 01:13:48 +04:00
|
|
|
Layer *layer;
|
2003-06-23 06:53:55 +04:00
|
|
|
LayerData *layerdata;
|
|
|
|
int32 code;
|
2003-07-05 01:13:48 +04:00
|
|
|
int32 view_token;
|
|
|
|
uint32 sizeRemaining = (uint32)msgsize;
|
2003-06-24 04:14:33 +04:00
|
|
|
|
2003-06-23 06:53:55 +04:00
|
|
|
if ( !msgsize || !msgbuffer )
|
|
|
|
return;
|
2003-03-19 04:12:53 +03:00
|
|
|
|
2003-07-05 01:13:48 +04:00
|
|
|
// We need to decide whether coordinates are specified in view or root coordinates.
|
|
|
|
// For now, we assume root level coordinates.
|
|
|
|
while (sizeRemaining > 2*sizeof(int32))
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
2003-07-05 01:13:48 +04:00
|
|
|
code = read_from_buffer<int32>(&msgbuffer);
|
|
|
|
view_token = read_from_buffer<int32>(&msgbuffer);
|
|
|
|
layer = _workspace->GetRoot()->FindLayer(view_token);
|
|
|
|
if ( layer )
|
|
|
|
layerdata = layer->GetLayerData();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
layerdata = NULL;
|
|
|
|
printf("ServerWindow %s received invalid view token %lx",_title->String(),view_token);
|
|
|
|
}
|
2003-06-23 06:53:55 +04:00
|
|
|
switch (code)
|
|
|
|
{
|
|
|
|
case AS_SET_HIGH_COLOR:
|
|
|
|
{
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_SET_COLOR_MSG_SIZE )
|
|
|
|
{
|
|
|
|
uint8 r, g, b, a;
|
|
|
|
r = read_from_buffer<uint8>(&msgbuffer);
|
|
|
|
g = read_from_buffer<uint8>(&msgbuffer);
|
|
|
|
b = read_from_buffer<uint8>(&msgbuffer);
|
|
|
|
a = read_from_buffer<uint8>(&msgbuffer);
|
|
|
|
if ( layerdata )
|
|
|
|
layerdata->highcolor.SetColor(r,g,b,a);
|
|
|
|
sizeRemaining -= AS_SET_COLOR_MSG_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
|
|
|
sizeRemaining = 0;
|
|
|
|
}
|
2003-06-23 06:53:55 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_SET_LOW_COLOR:
|
|
|
|
{
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_SET_COLOR_MSG_SIZE )
|
|
|
|
{
|
|
|
|
uint8 r, g, b, a;
|
|
|
|
r = read_from_buffer<uint8>(&msgbuffer);
|
|
|
|
g = read_from_buffer<uint8>(&msgbuffer);
|
|
|
|
b = read_from_buffer<uint8>(&msgbuffer);
|
|
|
|
a = read_from_buffer<uint8>(&msgbuffer);
|
|
|
|
if ( layerdata )
|
|
|
|
layerdata->lowcolor.SetColor(r,g,b,a);
|
|
|
|
sizeRemaining -= AS_SET_COLOR_MSG_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
|
|
|
sizeRemaining = 0;
|
|
|
|
}
|
2003-06-23 06:53:55 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_SET_VIEW_COLOR:
|
|
|
|
{
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_SET_COLOR_MSG_SIZE )
|
|
|
|
{
|
|
|
|
uint8 r, g, b, a;
|
|
|
|
r = read_from_buffer<uint8>(&msgbuffer);
|
|
|
|
g = read_from_buffer<uint8>(&msgbuffer);
|
|
|
|
b = read_from_buffer<uint8>(&msgbuffer);
|
|
|
|
a = read_from_buffer<uint8>(&msgbuffer);
|
|
|
|
if ( layerdata )
|
|
|
|
layerdata->viewcolor.SetColor(r,g,b,a);
|
|
|
|
sizeRemaining -= AS_SET_COLOR_MSG_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
|
|
|
sizeRemaining = 0;
|
|
|
|
}
|
2003-06-23 06:53:55 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_ARC:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_STROKE_ARC_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
float left, top, right, bottom, angle, span;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
|
|
|
|
|
|
|
left = read_from_buffer<float>(&msgbuffer);
|
|
|
|
top = read_from_buffer<float>(&msgbuffer);
|
|
|
|
right = read_from_buffer<float>(&msgbuffer);
|
|
|
|
bottom = read_from_buffer<float>(&msgbuffer);
|
|
|
|
angle = read_from_buffer<float>(&msgbuffer);
|
|
|
|
span = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
BRect rect(left,top,right,bottom);
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->StrokeArc(rect,angle,span,layerdata,pattern);
|
|
|
|
sizeRemaining -= AS_STROKE_ARC_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_BEZIER:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_STROKE_BEZIER_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
BPoint *pts;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
2003-06-23 06:53:55 +04:00
|
|
|
int i;
|
|
|
|
pts = new BPoint[4];
|
|
|
|
for (i=0; i<4; i++)
|
|
|
|
{
|
2003-07-05 01:13:48 +04:00
|
|
|
pts[i].x = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pts[i].y = read_from_buffer<float>(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
2003-07-05 01:13:48 +04:00
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->StrokeBezier(pts,layerdata,pattern);
|
2003-06-23 06:53:55 +04:00
|
|
|
delete[] pts;
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining -= AS_STROKE_BEZIER_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_ELLIPSE:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_STROKE_ELLIPSE_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
float left, top, right, bottom;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
|
|
|
left = read_from_buffer<float>(&msgbuffer);
|
|
|
|
top = read_from_buffer<float>(&msgbuffer);
|
|
|
|
right = read_from_buffer<float>(&msgbuffer);
|
|
|
|
bottom = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
BRect rect(left,top,right,bottom);
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->StrokeEllipse(rect,layerdata,pattern);
|
|
|
|
sizeRemaining -= AS_STROKE_ELLIPSE_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_LINE:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_STROKE_LINE_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
float x1, y1, x2, y2;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
|
|
|
x1 = read_from_buffer<float>(&msgbuffer);
|
|
|
|
y1 = read_from_buffer<float>(&msgbuffer);
|
|
|
|
x2 = read_from_buffer<float>(&msgbuffer);
|
|
|
|
y2 = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
BPoint p1(x1,y1);
|
|
|
|
BPoint p2(x2,y2);
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->StrokeLine(p1,p2,layerdata,pattern);
|
|
|
|
sizeRemaining -= AS_STROKE_LINE_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_LINEARRAY:
|
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_POLYGON:
|
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_RECT:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_STROKE_RECT_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
float left, top, right, bottom;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
|
|
|
left = read_from_buffer<float>(&msgbuffer);
|
|
|
|
top = read_from_buffer<float>(&msgbuffer);
|
|
|
|
right = read_from_buffer<float>(&msgbuffer);
|
|
|
|
bottom = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
BRect rect(left,top,right,bottom);
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->StrokeRect(rect,layerdata,pattern);
|
|
|
|
sizeRemaining -= AS_STROKE_RECT_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_ROUNDRECT:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_STROKE_ROUNDRECT_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
float left, top, right, bottom, xrad, yrad;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
|
|
|
left = read_from_buffer<float>(&msgbuffer);
|
|
|
|
top = read_from_buffer<float>(&msgbuffer);
|
|
|
|
right = read_from_buffer<float>(&msgbuffer);
|
|
|
|
bottom = read_from_buffer<float>(&msgbuffer);
|
|
|
|
xrad = read_from_buffer<float>(&msgbuffer);
|
|
|
|
yrad = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
BRect rect(left,top,right,bottom);
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->StrokeRoundRect(rect,xrad,yrad,layerdata,pattern);
|
|
|
|
sizeRemaining -= AS_STROKE_ROUNDRECT_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_SHAPE:
|
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_TRIANGLE:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_STROKE_TRIANGLE_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
BPoint *pts;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
2003-06-23 06:53:55 +04:00
|
|
|
float left, top, right, bottom;
|
|
|
|
int i;
|
|
|
|
pts = new BPoint[3];
|
|
|
|
for (i=0; i<3; i++)
|
|
|
|
{
|
2003-07-05 01:13:48 +04:00
|
|
|
pts[i].x = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pts[i].y = read_from_buffer<float>(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
2003-07-05 01:13:48 +04:00
|
|
|
left = read_from_buffer<float>(&msgbuffer);
|
|
|
|
top = read_from_buffer<float>(&msgbuffer);
|
|
|
|
right = read_from_buffer<float>(&msgbuffer);
|
|
|
|
bottom = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
BRect rect(left,top,right,bottom);
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->StrokeTriangle(pts,rect,layerdata,pattern);
|
2003-06-23 06:53:55 +04:00
|
|
|
delete[] pts;
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining -= AS_STROKE_TRIANGLE_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_ARC:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_FILL_ARC_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
float left, top, right, bottom, angle, span;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
|
|
|
left = read_from_buffer<float>(&msgbuffer);
|
|
|
|
top = read_from_buffer<float>(&msgbuffer);
|
|
|
|
right = read_from_buffer<float>(&msgbuffer);
|
|
|
|
bottom = read_from_buffer<float>(&msgbuffer);
|
|
|
|
angle = read_from_buffer<float>(&msgbuffer);
|
|
|
|
span = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
BRect rect(left,top,right,bottom);
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->FillArc(rect,angle,span,layerdata,pattern);
|
|
|
|
sizeRemaining -= AS_FILL_ARC_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_BEZIER:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_FILL_BEZIER_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
BPoint *pts;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
2003-06-23 06:53:55 +04:00
|
|
|
int i;
|
|
|
|
pts = new BPoint[4];
|
|
|
|
for (i=0; i<4; i++)
|
|
|
|
{
|
2003-07-05 01:13:48 +04:00
|
|
|
pts[i].x = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pts[i].y = read_from_buffer<float>(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
2003-07-05 01:13:48 +04:00
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->FillBezier(pts,layerdata,pattern);
|
2003-06-23 06:53:55 +04:00
|
|
|
delete[] pts;
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining -= AS_FILL_BEZIER_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_ELLIPSE:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_FILL_ELLIPSE_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
float left, top, right, bottom;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
|
|
|
left = read_from_buffer<float>(&msgbuffer);
|
|
|
|
top = read_from_buffer<float>(&msgbuffer);
|
|
|
|
right = read_from_buffer<float>(&msgbuffer);
|
|
|
|
bottom = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
BRect rect(left,top,right,bottom);
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->FillEllipse(rect,layerdata,pattern);
|
|
|
|
sizeRemaining -= AS_FILL_ELLIPSE_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_POLYGON:
|
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_RECT:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_FILL_RECT_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
float left, top, right, bottom;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
|
|
|
left = read_from_buffer<float>(&msgbuffer);
|
|
|
|
top = read_from_buffer<float>(&msgbuffer);
|
|
|
|
right = read_from_buffer<float>(&msgbuffer);
|
|
|
|
bottom = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
BRect rect(left,top,right,bottom);
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->FillRect(rect,layerdata,pattern);
|
|
|
|
sizeRemaining -= AS_FILL_RECT_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_REGION:
|
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_ROUNDRECT:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_FILL_ROUNDRECT_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
float left, top, right, bottom, xrad, yrad;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
|
|
|
left = read_from_buffer<float>(&msgbuffer);
|
|
|
|
top = read_from_buffer<float>(&msgbuffer);
|
|
|
|
right = read_from_buffer<float>(&msgbuffer);
|
|
|
|
bottom = read_from_buffer<float>(&msgbuffer);
|
|
|
|
xrad = read_from_buffer<float>(&msgbuffer);
|
|
|
|
yrad = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
BRect rect(left,top,right,bottom);
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->FillRoundRect(rect,xrad,yrad,layerdata,pattern);
|
|
|
|
sizeRemaining -= AS_FILL_ROUNDRECT_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_SHAPE:
|
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_TRIANGLE:
|
|
|
|
{
|
|
|
|
// TODO:: Add clipping
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( sizeRemaining >= AS_FILL_TRIANGLE_MSG_SIZE )
|
2003-06-23 06:53:55 +04:00
|
|
|
{
|
|
|
|
BPoint *pts;
|
2003-07-05 01:13:48 +04:00
|
|
|
int8 *pattern;
|
2003-06-23 06:53:55 +04:00
|
|
|
float left, top, right, bottom;
|
|
|
|
int i;
|
|
|
|
pts = new BPoint[3];
|
|
|
|
for (i=0; i<3; i++)
|
|
|
|
{
|
2003-07-05 01:13:48 +04:00
|
|
|
pts[i].x = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pts[i].y = read_from_buffer<float>(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
2003-07-05 01:13:48 +04:00
|
|
|
left = read_from_buffer<float>(&msgbuffer);
|
|
|
|
top = read_from_buffer<float>(&msgbuffer);
|
|
|
|
right = read_from_buffer<float>(&msgbuffer);
|
|
|
|
bottom = read_from_buffer<float>(&msgbuffer);
|
|
|
|
pattern = read_pattern_from_buffer(&msgbuffer);
|
2003-06-23 06:53:55 +04:00
|
|
|
BRect rect(left,top,right,bottom);
|
2003-07-05 01:13:48 +04:00
|
|
|
if ( layerdata )
|
|
|
|
_app->_driver->FillTriangle(pts,rect,layerdata,pattern);
|
2003-06-23 06:53:55 +04:00
|
|
|
delete[] pts;
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining -= AS_FILL_TRIANGLE_MSG_SIZE;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code);
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining = 0;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_MOVEPENBY:
|
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_MOVEPENTO:
|
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_SETPENSIZE:
|
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_DRAW_STRING:
|
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_SET_FONT:
|
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_SET_FONT_SIZE:
|
|
|
|
{
|
|
|
|
// TODO: Implement
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2003-07-05 01:13:48 +04:00
|
|
|
sizeRemaining -= sizeof(int32);
|
2003-06-23 06:53:55 +04:00
|
|
|
printf("ServerWindow %s received unexpected graphics code %lx",_title->String(),code);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Message-dispatching loop for the ServerWindow
|
|
|
|
|
|
|
|
MonitorWin() watches the ServerWindow's message port and dispatches as necessary
|
|
|
|
\param data The thread's ServerWindow
|
|
|
|
\return Throwaway code. Always 0.
|
|
|
|
*/
|
|
|
|
int32 ServerWindow::MonitorWin(void *data)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-02-24 18:47:06 +03:00
|
|
|
ServerWindow *win=(ServerWindow *)data;
|
|
|
|
|
2003-02-07 15:53:57 +03:00
|
|
|
int32 msgcode;
|
|
|
|
int8 *msgbuffer=NULL;
|
|
|
|
ssize_t buffersize,bytesread;
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
2003-02-24 18:47:06 +03:00
|
|
|
buffersize=port_buffer_size(win->_receiver);
|
2003-02-07 15:53:57 +03:00
|
|
|
|
|
|
|
if(buffersize>0)
|
|
|
|
{
|
|
|
|
msgbuffer=new int8[buffersize];
|
2003-02-24 18:47:06 +03:00
|
|
|
bytesread=read_port(win->_receiver,&msgcode,msgbuffer,buffersize);
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
else
|
2003-02-24 18:47:06 +03:00
|
|
|
bytesread=read_port(win->_receiver,&msgcode,NULL,0);
|
2003-02-07 15:53:57 +03:00
|
|
|
|
|
|
|
if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK)
|
|
|
|
{
|
|
|
|
switch(msgcode)
|
|
|
|
{
|
2003-02-24 18:47:06 +03:00
|
|
|
case B_QUIT_REQUESTED:
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s received Quit request\n",win->Title());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
// Our BWindow sent us this message when it quit.
|
|
|
|
// We need to ask its ServerApp to delete our monitor
|
|
|
|
win->_applink->SetOpCode(AS_DELETE_WINDOW);
|
|
|
|
win->_applink->Attach((int32)win->_token);
|
|
|
|
win->_applink->Flush();
|
2003-02-07 15:53:57 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_BEGIN_UPDATE:
|
|
|
|
{
|
|
|
|
win->DispatchGraphicsMessage(buffersize,msgbuffer);
|
|
|
|
break;
|
|
|
|
}
|
2003-02-07 15:53:57 +03:00
|
|
|
default:
|
2003-02-24 18:47:06 +03:00
|
|
|
win->DispatchMessage(msgcode,msgbuffer);
|
2003-02-07 15:53:57 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(buffersize>0)
|
2003-06-23 06:53:55 +04:00
|
|
|
delete[] msgbuffer;
|
2003-02-07 15:53:57 +03:00
|
|
|
|
|
|
|
if(msgcode==B_QUIT_REQUESTED)
|
|
|
|
break;
|
|
|
|
}
|
2003-02-12 04:11:55 +03:00
|
|
|
|
|
|
|
exit_thread(0);
|
2003-02-07 15:53:57 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Passes mouse event messages to the appropriate window
|
|
|
|
\param code Message code of the mouse message
|
|
|
|
\param buffer Attachment buffer for the mouse message
|
|
|
|
*/
|
2003-02-07 15:53:57 +03:00
|
|
|
void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW_MOUSE
|
|
|
|
printf("ServerWindow::HandleMouseEvent unimplemented\n");
|
|
|
|
#endif
|
2003-04-05 05:51:35 +04:00
|
|
|
ServerWindow *mousewin=NULL;
|
2003-02-07 15:53:57 +03:00
|
|
|
int8 *index=buffer;
|
|
|
|
|
|
|
|
// Find the window which will receive our mouse event.
|
2003-04-05 05:51:35 +04:00
|
|
|
Layer *root=GetRootLayer(CurrentWorkspace(),ActiveScreen());
|
2003-02-14 04:53:53 +03:00
|
|
|
WinBorder *_winborder;
|
2003-02-07 15:53:57 +03:00
|
|
|
|
|
|
|
// activeborder is used to remember windows when resizing/moving windows
|
|
|
|
// or sliding a tab
|
2003-04-05 05:51:35 +04:00
|
|
|
if(!root)
|
|
|
|
{
|
|
|
|
printf("ERROR: HandleMouseEvent has NULL root layer!!!\n");
|
|
|
|
return;
|
|
|
|
}
|
2003-02-07 15:53:57 +03:00
|
|
|
|
|
|
|
// 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);
|
2003-04-05 05:51:35 +04:00
|
|
|
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);
|
2003-02-07 15:53:57 +03:00
|
|
|
// int32 clicks=*((int32*)index);
|
|
|
|
BPoint pt(x,y);
|
|
|
|
|
|
|
|
// If we have clicked on a window,
|
2003-06-28 23:06:30 +04:00
|
|
|
active_winborder=_winborder=(WinBorder*)root->GetChildAt(pt);
|
2003-02-12 04:11:55 +03:00
|
|
|
if(_winborder)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-02-14 04:53:53 +03:00
|
|
|
mousewin=_winborder->Window();
|
2003-04-05 05:51:35 +04:00
|
|
|
_winborder->MouseDown(buffer);
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
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);
|
2003-04-05 05:51:35 +04:00
|
|
|
float x=*((float*)index); index+=sizeof(float);
|
|
|
|
float y=*((float*)index); index+=sizeof(float);
|
2003-02-07 15:53:57 +03:00
|
|
|
// int32 modifiers=*((int32*)index);
|
|
|
|
BPoint pt(x,y);
|
|
|
|
|
2003-06-28 23:06:30 +04:00
|
|
|
set_is_sliding_tab(false);
|
2003-02-14 04:53:53 +03:00
|
|
|
set_is_moving_window(false);
|
2003-06-28 23:06:30 +04:00
|
|
|
set_is_resizing_window(false);
|
2003-02-14 04:53:53 +03:00
|
|
|
_winborder=(WinBorder*)root->GetChildAt(pt);
|
2003-06-28 23:06:30 +04:00
|
|
|
active_winborder=NULL;
|
2003-02-12 04:11:55 +03:00
|
|
|
if(_winborder)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-02-14 04:53:53 +03:00
|
|
|
mousewin=_winborder->Window();
|
2003-02-07 15:53:57 +03:00
|
|
|
|
|
|
|
// Eventually, we will build in MouseUp messages with buttons specified
|
|
|
|
// For now, we just "assume" no mouse specification with a 0.
|
2003-04-05 05:51:35 +04:00
|
|
|
_winborder->MouseUp(buffer);
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
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);
|
2003-04-05 05:51:35 +04:00
|
|
|
float x=*((float*)index); index+=sizeof(float);
|
|
|
|
float y=*((float*)index); index+=sizeof(float);
|
2003-02-07 15:53:57 +03:00
|
|
|
BPoint pt(x,y);
|
|
|
|
|
2003-06-28 23:06:30 +04:00
|
|
|
if(is_moving_window() || is_resizing_window() || is_sliding_tab())
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-06-28 23:06:30 +04:00
|
|
|
active_winborder->MouseMoved(buffer);
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-06-28 23:06:30 +04:00
|
|
|
_winborder=(WinBorder*)root->GetChildAt(pt);
|
2003-02-12 04:11:55 +03:00
|
|
|
if(_winborder)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-02-14 04:53:53 +03:00
|
|
|
mousewin=_winborder->Window();
|
2003-04-05 05:51:35 +04:00
|
|
|
_winborder->MouseMoved(buffer);
|
2003-06-28 23:06:30 +04:00
|
|
|
}
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Passes key event messages to the appropriate window
|
|
|
|
\param code Message code of the key message
|
|
|
|
\param buffer Attachment buffer for the key message
|
|
|
|
*/
|
2003-02-14 04:53:53 +03:00
|
|
|
void ServerWindow::HandleKeyEvent(int32 code, int8 *buffer)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW_KEYBOARD
|
|
|
|
printf("ServerWindow::HandleKeyEvent unimplemented\n");
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
/* ServerWindow *keywin=NULL;
|
|
|
|
int8 *index=buffer;
|
|
|
|
|
|
|
|
// Dispatch the key event to the active window
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Returns the Workspace object to which the window belongs
|
|
|
|
|
|
|
|
If the window belongs to all workspaces, it returns the current workspace
|
|
|
|
*/
|
|
|
|
Workspace *ServerWindow::GetWorkspace(void)
|
|
|
|
{
|
|
|
|
if(_workspace_index==B_ALL_WORKSPACES)
|
|
|
|
return _workspace->GetScreen()->GetActiveWorkspace();
|
|
|
|
|
|
|
|
return _workspace;
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Assign the window to a particular workspace object
|
|
|
|
\param The ServerWindow's new workspace
|
|
|
|
*/
|
2003-02-20 21:05:35 +03:00
|
|
|
void ServerWindow::SetWorkspace(Workspace *wkspc)
|
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ServerWindow %s: Set Workspace\n",_title->String());
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
_workspace=wkspc;
|
2003-02-20 21:05:35 +03:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Handles window activation stuff. Called by Desktop functions
|
|
|
|
*/
|
2003-02-20 16:13:01 +03:00
|
|
|
void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
|
|
|
printf("ActivateWindow: old=%s, new=%s\n",oldwin?oldwin->Title():"NULL",newwin?newwin->Title():"NULL");
|
|
|
|
#endif
|
2003-02-24 18:47:06 +03:00
|
|
|
if(oldwin==newwin)
|
2003-02-07 15:53:57 +03:00
|
|
|
return;
|
2003-02-24 18:47:06 +03:00
|
|
|
|
|
|
|
if(oldwin)
|
|
|
|
oldwin->SetFocus(false);
|
|
|
|
|
|
|
|
if(newwin)
|
|
|
|
newwin->SetFocus(true);
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|