2003-02-12 04:11:55 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2005-05-26 17:56:42 +04:00
|
|
|
// Copyright (c) 2001-2005, Haiku, Inc.
|
2003-02-12 04:11:55 +03:00
|
|
|
//
|
|
|
|
// 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>
|
2004-04-03 19:05:49 +04:00
|
|
|
// Adi Oanca <adioanca@mymail.ro>
|
2003-02-12 04:11:55 +03:00
|
|
|
// Description: Shadow BWindow class
|
2005-05-26 17:56:42 +04:00
|
|
|
//
|
2003-02-12 04:11:55 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2005-05-26 17:56:42 +04:00
|
|
|
|
2003-02-07 15:53:57 +03:00
|
|
|
#include <AppDefs.h>
|
|
|
|
#include <Rect.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2004-09-21 02:50:02 +04:00
|
|
|
#include <malloc.h>
|
2005-01-23 18:39:01 +03:00
|
|
|
#include <View.h>
|
2003-09-25 16:31:11 +04:00
|
|
|
#include <Message.h>
|
2003-09-09 01:18:39 +04:00
|
|
|
#include <GraphicsDefs.h>
|
2003-07-11 00:22:07 +04:00
|
|
|
#include <PortLink.h>
|
2004-10-16 06:02:27 +04:00
|
|
|
#include <ViewAux.h>
|
2003-02-07 15:53:57 +03:00
|
|
|
#include "AppServer.h"
|
2004-10-16 06:02:27 +04:00
|
|
|
#include "BGet++.h"
|
2005-05-26 03:59:23 +04:00
|
|
|
#include "DebugInfoManager.h"
|
2004-10-16 06:02:27 +04:00
|
|
|
#include "Desktop.h"
|
2003-02-07 15:53:57 +03:00
|
|
|
#include "Layer.h"
|
2004-10-16 06:02:27 +04:00
|
|
|
#include "RAMLinkMsgReader.h"
|
2003-08-31 21:38:34 +04:00
|
|
|
#include "RootLayer.h"
|
2003-02-07 15:53:57 +03:00
|
|
|
#include "ServerWindow.h"
|
|
|
|
#include "ServerApp.h"
|
|
|
|
#include "ServerProtocol.h"
|
2003-02-14 04:53:53 +03:00
|
|
|
#include "WinBorder.h"
|
2003-02-12 04:11:55 +03:00
|
|
|
#include "TokenHandler.h"
|
2003-06-24 17:55:18 +04:00
|
|
|
#include "Utils.h"
|
2003-08-31 21:38:34 +04:00
|
|
|
#include "DisplayDriver.h"
|
2005-04-18 23:16:11 +04:00
|
|
|
#include "ServerBitmap.h"
|
2003-09-25 16:31:11 +04:00
|
|
|
#include "ServerPicture.h"
|
2004-01-13 03:56:36 +03:00
|
|
|
#include "Workspace.h"
|
2005-02-07 03:45:59 +03:00
|
|
|
#include "MessagePrivate.h"
|
2003-02-12 04:11:55 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
//#define DEBUG_SERVERWINDOW
|
|
|
|
//#define DEBUG_SERVERWINDOW_GRAPHICS
|
2003-03-23 23:52:37 +03:00
|
|
|
|
2003-09-09 01:18:39 +04:00
|
|
|
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
2003-09-09 01:18:39 +04:00
|
|
|
# include <stdio.h>
|
|
|
|
# define STRACE(x) printf x
|
|
|
|
#else
|
|
|
|
# define STRACE(x) ;
|
|
|
|
#endif
|
|
|
|
|
2005-01-19 18:12:35 +03:00
|
|
|
#ifdef DEBUG_SERVERWINDOW_GRAPHICS
|
|
|
|
# include <stdio.h>
|
|
|
|
# define DTRACE(x) printf x
|
|
|
|
#else
|
|
|
|
# define DTRACE(x) ;
|
|
|
|
#endif
|
|
|
|
|
2004-06-19 14:23:14 +04:00
|
|
|
//------------------------------------------------------------------------------
|
2003-06-28 23:06:30 +04:00
|
|
|
|
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;
|
|
|
|
}
|
2004-06-19 14:23:14 +04:00
|
|
|
//------------------------------------------------------------------------------
|
2004-09-14 04:51:51 +04:00
|
|
|
/*
|
2003-07-05 01:13:48 +04:00
|
|
|
static int8 *read_pattern_from_buffer(int8 **_buffer)
|
|
|
|
{
|
|
|
|
int8 *pattern = *_buffer;
|
|
|
|
|
|
|
|
*_buffer += AS_PATTERN_SIZE;
|
|
|
|
|
|
|
|
return pattern;
|
|
|
|
}
|
2004-09-14 04:51:51 +04:00
|
|
|
*/
|
2004-06-19 14:23:14 +04:00
|
|
|
//------------------------------------------------------------------------------
|
2003-07-05 01:13:48 +04:00
|
|
|
template<class Type> void
|
|
|
|
write_to_buffer(int8 **_buffer, Type value)
|
|
|
|
{
|
|
|
|
Type *typedBuffer = (Type *)(*_buffer);
|
|
|
|
|
|
|
|
*typedBuffer = value;
|
|
|
|
typedBuffer++;
|
|
|
|
|
|
|
|
*_buffer = (int8 *)(typedBuffer);
|
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark -
|
|
|
|
|
2003-02-12 04:11:55 +03:00
|
|
|
/*!
|
2005-05-26 19:04:45 +04:00
|
|
|
\brief Constructor
|
2003-02-12 04:11:55 +03:00
|
|
|
|
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
|
|
|
*/
|
2005-05-26 19:04:45 +04:00
|
|
|
ServerWindow::ServerWindow(const char *string, ServerApp *winapp,
|
|
|
|
port_id winport, port_id looperPort, int32 handlerID)
|
2005-04-16 17:30:49 +04:00
|
|
|
: fServerApp(winapp),
|
|
|
|
// fClientWinPort is the port to which the app awaits messages from the server
|
|
|
|
fClientWinPort(winport),
|
|
|
|
fClientLooperPort(looperPort),
|
2005-05-18 16:16:15 +04:00
|
|
|
fClientViewsWithInvalidCoords(B_VIEW_RESIZED),
|
|
|
|
fHandlerToken(handlerID)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow(%s)::ServerWindow()\n", string));
|
2004-01-20 01:18:37 +03:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
if (string) {
|
|
|
|
strncpy(fName, string, sizeof(fName) - 1);
|
|
|
|
fName[sizeof(fName) - 1] = '\0';
|
|
|
|
} else
|
2005-04-16 17:30:49 +04:00
|
|
|
strcpy(fName, "Unnamed Window");
|
2005-05-26 17:56:42 +04:00
|
|
|
|
|
|
|
fClientTeamID = winapp->ClientTeamID();
|
|
|
|
fWinBorder = NULL;
|
|
|
|
fCurrentLayer = NULL;
|
|
|
|
|
2004-01-20 01:18:37 +03:00
|
|
|
// fMessagePort is the port to which the app sends messages for the server
|
2005-05-26 17:56:42 +04:00
|
|
|
fMessagePort = create_port(30, fName);
|
|
|
|
|
|
|
|
fMsgSender = new LinkMsgSender(fClientWinPort);
|
|
|
|
fMsgReader = new LinkMsgReader(fMessagePort);
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2004-01-20 01:18:37 +03:00
|
|
|
// Send a reply to our window - it is expecting fMessagePort port.
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
|
|
|
fMsgSender->Attach<port_id>(fMessagePort);
|
|
|
|
fMsgSender->Flush();
|
2004-04-03 19:05:49 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow %s Created\n", fName));
|
2004-03-28 19:00:31 +04:00
|
|
|
}
|
2005-05-26 17:56:42 +04:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ServerWindow::Init(BRect frame, uint32 wlook,
|
|
|
|
uint32 wfeel, uint32 wflags, uint32 wwksindex)
|
2004-06-11 18:47:36 +04:00
|
|
|
{
|
2005-05-26 19:04:45 +04:00
|
|
|
char name[60];
|
|
|
|
snprintf(name, sizeof(name), "%ld: %s", fClientTeamID, fName);
|
|
|
|
|
|
|
|
fWinBorder = new WinBorder(frame, name, wlook, wfeel, wflags,
|
2005-05-28 17:43:13 +04:00
|
|
|
wwksindex, this, gDesktop->GetDisplayDriver());
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2004-06-11 18:47:36 +04:00
|
|
|
// Spawn our message-monitoring thread
|
2005-04-16 17:30:49 +04:00
|
|
|
fMonitorThreadID = spawn_thread(MonitorWin, fName, B_NORMAL_PRIORITY, this);
|
2005-05-26 19:04:45 +04:00
|
|
|
if (fMonitorThreadID >= B_OK)
|
2004-01-20 01:18:37 +03:00
|
|
|
resume_thread(fMonitorThreadID);
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
|
|
|
|
2004-06-19 17:04:50 +04:00
|
|
|
//!Tears down all connections the main app_server objects, and deletes some internals.
|
2003-02-07 15:53:57 +03:00
|
|
|
ServerWindow::~ServerWindow(void)
|
|
|
|
{
|
2005-05-26 19:04:45 +04:00
|
|
|
STRACE(("*ServerWindow (%s):~ServerWindow()\n", fName));
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-05-26 19:04:45 +04:00
|
|
|
delete fWinBorder;
|
|
|
|
delete fMsgSender;
|
|
|
|
delete fMsgReader;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("#ServerWindow(%s) will exit NOW\n", fName));
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
//! Forces the window border to update its decorator
|
2005-05-26 19:04:45 +04:00
|
|
|
void
|
|
|
|
ServerWindow::ReplaceDecorator(void)
|
2003-02-12 04:11:55 +03:00
|
|
|
{
|
2004-06-19 14:23:14 +04:00
|
|
|
if (!IsLocked())
|
|
|
|
debugger("you must lock a ServerWindow object before calling ::ReplaceDecorator()\n");
|
|
|
|
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Replace Decorator\n",fName));
|
2004-01-20 01:18:37 +03:00
|
|
|
fWinBorder->UpdateDecorator();
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
//! Requests that the ServerWindow's BWindow quit
|
2005-05-26 19:04:45 +04:00
|
|
|
void
|
|
|
|
ServerWindow::Quit(void)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2005-03-17 20:41:00 +03:00
|
|
|
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Quit\n",fName));
|
2005-05-26 19:04:45 +04:00
|
|
|
|
|
|
|
BMessage msg(B_QUIT_REQUESTED);
|
2003-12-07 08:40:51 +03:00
|
|
|
SendMessageToClient(&msg);
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
//! Shows the window's WinBorder
|
2005-05-26 19:04:45 +04:00
|
|
|
void
|
|
|
|
ServerWindow::Show(void)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2005-03-17 20:41:00 +03:00
|
|
|
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Show\n",fName));
|
2004-06-19 14:23:14 +04:00
|
|
|
|
2005-05-26 19:04:45 +04:00
|
|
|
if (!fWinBorder->IsHidden())
|
2004-01-14 18:55:10 +03:00
|
|
|
return;
|
|
|
|
|
2005-01-22 00:18:25 +03:00
|
|
|
fWinBorder->GetRootLayer()->ShowWinBorder(fWinBorder);
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
//! Hides the window's WinBorder
|
2005-05-26 19:04:45 +04:00
|
|
|
void
|
|
|
|
ServerWindow::Hide(void)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2005-03-17 20:41:00 +03:00
|
|
|
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Hide\n",fName));
|
2004-06-19 14:23:14 +04:00
|
|
|
|
2005-05-26 19:04:45 +04:00
|
|
|
if (fWinBorder->IsHidden())
|
2004-01-14 18:55:10 +03:00
|
|
|
return;
|
|
|
|
|
2005-01-22 00:18:25 +03:00
|
|
|
fWinBorder->GetRootLayer()->HideWinBorder(fWinBorder);
|
2003-02-12 04:11:55 +03:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ServerWindow::Minimize(bool status)
|
2004-06-11 18:47:36 +04:00
|
|
|
{
|
2005-03-17 20:41:00 +03:00
|
|
|
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
2004-06-15 00:32:21 +04:00
|
|
|
// This function doesn't need much -- check to make sure that we should and
|
|
|
|
// send the message to the client. According to the BeBook, the BWindow hook function
|
|
|
|
// does all the heavy lifting for us. :)
|
2004-06-11 18:47:36 +04:00
|
|
|
bool sendMessages = false;
|
2003-11-15 03:28:40 +03:00
|
|
|
|
2005-05-26 19:04:45 +04:00
|
|
|
if (status) {
|
|
|
|
if (!fWinBorder->IsHidden()) {
|
2003-11-15 03:28:40 +03:00
|
|
|
Hide();
|
2004-06-11 18:47:36 +04:00
|
|
|
sendMessages = true;
|
2003-11-15 03:28:40 +03:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
} else {
|
|
|
|
if (fWinBorder->IsHidden()) {
|
2003-11-15 03:28:40 +03:00
|
|
|
Show();
|
2004-06-11 18:47:36 +04:00
|
|
|
sendMessages = true;
|
2003-11-15 03:28:40 +03:00
|
|
|
}
|
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
|
|
|
if (sendMessages) {
|
2004-06-15 00:32:21 +04:00
|
|
|
BMessage msg;
|
|
|
|
msg.what = B_MINIMIZE;
|
2003-11-15 03:28:40 +03:00
|
|
|
msg.AddInt64("when", real_time_clock_usecs());
|
2003-12-07 08:40:51 +03:00
|
|
|
msg.AddBool("minimize", status);
|
2005-05-26 19:04:45 +04:00
|
|
|
|
2003-12-07 08:40:51 +03:00
|
|
|
SendMessageToClient(&msg);
|
2003-11-15 03:28:40 +03:00
|
|
|
}
|
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
|
|
|
//! Sends a message to the client to perform a Zoom
|
|
|
|
void
|
|
|
|
ServerWindow::Zoom(void)
|
2004-06-11 18:47:36 +04:00
|
|
|
{
|
2005-03-17 20:41:00 +03:00
|
|
|
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
2005-05-26 19:04:45 +04:00
|
|
|
BMessage msg(B_ZOOM);
|
2004-06-11 06:46:48 +04:00
|
|
|
SendMessageToClient(&msg);
|
2003-11-15 03:28:40 +03:00
|
|
|
}
|
2005-05-26 19:04:45 +04: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
|
|
|
|
*/
|
2005-05-26 19:04:45 +04:00
|
|
|
void
|
|
|
|
ServerWindow::ScreenModeChanged(const BRect frame, const color_space colorSpace)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2005-05-26 19:04:45 +04:00
|
|
|
STRACE(("ServerWindow %s: ScreenModeChanged\n", fName));
|
|
|
|
|
|
|
|
BMessage msg(B_SCREEN_CHANGED);
|
2003-09-25 16:31:11 +04:00
|
|
|
msg.AddRect("frame", frame);
|
2005-05-26 19:04:45 +04:00
|
|
|
msg.AddInt32("mode", (int32)colorSpace);
|
|
|
|
|
2003-12-07 08:40:51 +03:00
|
|
|
SendMessageToClient(&msg);
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
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
|
|
|
|
*/
|
2005-05-26 19:04:45 +04:00
|
|
|
status_t
|
|
|
|
ServerWindow::Lock(void)
|
2003-02-12 04:11:55 +03:00
|
|
|
{
|
2005-05-26 19:04:45 +04:00
|
|
|
STRACE(("\nServerWindow %s: Lock\n", fName));
|
|
|
|
|
|
|
|
return fLocker.Lock() ? B_OK : B_ERROR;
|
2003-02-12 04:11:55 +03:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
//! Unlocks the window
|
2005-05-26 19:04:45 +04:00
|
|
|
void
|
|
|
|
ServerWindow::Unlock(void)
|
2003-02-12 04:11:55 +03:00
|
|
|
{
|
2005-05-26 19:04:45 +04:00
|
|
|
STRACE(("ServerWindow %s: Unlock\n\n", fName));
|
|
|
|
|
2004-01-20 01:18:37 +03:00
|
|
|
fLocker.Unlock();
|
2003-02-12 04:11:55 +03:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
/*!
|
|
|
|
\brief Determines whether or not the window is locked
|
|
|
|
\return True if locked, false if not.
|
|
|
|
*/
|
2005-05-26 19:04:45 +04:00
|
|
|
bool
|
|
|
|
ServerWindow::IsLocked(void) const
|
2003-02-12 04:11:55 +03:00
|
|
|
{
|
2004-01-20 01:18:37 +03:00
|
|
|
return fLocker.IsLocked();
|
2003-02-12 04:11:55 +03:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
2004-06-11 18:47:36 +04:00
|
|
|
/*!
|
|
|
|
\brief Sets the font state for a layer
|
|
|
|
\param layer The layer to set the font
|
|
|
|
*/
|
2005-04-16 17:30:49 +04:00
|
|
|
inline
|
2005-05-26 19:04:45 +04:00
|
|
|
void
|
|
|
|
ServerWindow::SetLayerFontState(Layer *layer, LinkMsgReader &link)
|
2004-06-11 18:47:36 +04:00
|
|
|
{
|
2005-02-23 04:45:48 +03:00
|
|
|
STRACE(("ServerWindow %s: SetLayerFontStateMessage for layer %s\n",
|
2005-04-16 17:30:49 +04:00
|
|
|
fName, layer->fName->String()));
|
2004-06-19 14:23:14 +04:00
|
|
|
// NOTE: no need to check for a lock. This is a private method.
|
2004-03-28 19:00:31 +04:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
layer->fLayerData->ReadFontFromLink(link);
|
2004-03-28 19:00:31 +04:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
|
|
|
|
2005-04-16 17:30:49 +04:00
|
|
|
inline
|
2005-05-26 19:04:45 +04:00
|
|
|
void
|
|
|
|
ServerWindow::SetLayerState(Layer *layer, LinkMsgReader &link)
|
2004-06-11 18:47:36 +04:00
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: SetLayerState for layer %s\n",fName,
|
2005-02-23 04:45:48 +03:00
|
|
|
layer->fName->String()));
|
2004-06-19 14:23:14 +04:00
|
|
|
// NOTE: no need to check for a lock. This is a private method.
|
2004-03-28 19:00:31 +04:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
layer->fLayerData->ReadFromLink(link);
|
|
|
|
// TODO: Rebuild clipping here?
|
2004-03-28 19:00:31 +04:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
|
|
|
|
2005-04-16 17:30:49 +04:00
|
|
|
inline
|
2005-05-26 19:04:45 +04:00
|
|
|
Layer *
|
|
|
|
ServerWindow::CreateLayerTree(Layer *localRoot, LinkMsgReader &link)
|
2004-06-11 18:47:36 +04:00
|
|
|
{
|
2004-06-19 14:23:14 +04:00
|
|
|
// NOTE: no need to check for a lock. This is a private method.
|
2004-06-11 18:47:36 +04:00
|
|
|
|
|
|
|
int32 token;
|
|
|
|
BRect frame;
|
|
|
|
uint32 resizeMask;
|
2005-03-21 23:29:24 +03:00
|
|
|
uint32 eventMask;
|
|
|
|
uint32 eventOptions;
|
2004-06-11 18:47:36 +04:00
|
|
|
uint32 flags;
|
|
|
|
bool hidden;
|
|
|
|
int32 childCount;
|
2004-07-30 19:16:59 +04:00
|
|
|
char *name = NULL;
|
2005-05-26 19:04:45 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int32>(&token);
|
|
|
|
link.ReadString(&name);
|
|
|
|
link.Read<BRect>(&frame);
|
|
|
|
link.Read<uint32>(&resizeMask);
|
2005-03-21 23:29:24 +03:00
|
|
|
link.Read<uint32>(&eventMask);
|
|
|
|
link.Read<uint32>(&eventOptions);
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<uint32>(&flags);
|
|
|
|
link.Read<bool>(&hidden);
|
|
|
|
link.Read<int32>(&childCount);
|
2005-05-26 19:04:45 +04:00
|
|
|
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow(%s)::CreateLayerTree()-> layer %s, token %ld\n", fName,name,token));
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-05-26 19:04:45 +04:00
|
|
|
Layer *newLayer = new Layer(frame, name, token, resizeMask,
|
2005-05-28 17:43:13 +04:00
|
|
|
flags, gDesktop->GetDisplayDriver());
|
2005-05-26 19:04:45 +04:00
|
|
|
|
|
|
|
free(name);
|
2004-03-28 19:00:31 +04:00
|
|
|
|
2004-06-11 18:47:36 +04:00
|
|
|
// there is no way of setting this, other than manually :-)
|
2005-05-26 19:04:45 +04:00
|
|
|
newLayer->fHidden = hidden;
|
|
|
|
newLayer->fEventMask = eventMask;
|
|
|
|
newLayer->fEventOptions = eventOptions;
|
|
|
|
newLayer->fOwner = fWinBorder;
|
2004-03-28 19:00:31 +04:00
|
|
|
|
|
|
|
// add the new Layer to the tree structure.
|
2005-05-26 19:04:45 +04:00
|
|
|
if (localRoot)
|
2004-06-16 10:40:26 +04:00
|
|
|
localRoot->AddChild(newLayer, NULL);
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2004-04-03 19:05:49 +04:00
|
|
|
return newLayer;
|
2004-03-28 19:00:31 +04:00
|
|
|
}
|
2005-05-26 19:04:45 +04:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
2003-02-24 18:47:06 +03:00
|
|
|
{
|
2005-05-26 19:04:45 +04:00
|
|
|
if (fCurrentLayer == NULL && code != AS_LAYER_CREATE_ROOT) {
|
2005-04-16 17:30:49 +04:00
|
|
|
printf("ServerWindow %s received unexpected code - message offset %ld before top_view attached.\n",fName, code - SERVER_TRUE);
|
2004-07-30 19:16:59 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-01-22 23:51:12 +03:00
|
|
|
|
2005-05-26 19:04:45 +04:00
|
|
|
RootLayer *myRootLayer = fWinBorder->GetRootLayer();
|
2005-01-22 23:51:12 +03:00
|
|
|
|
2005-05-26 19:04:45 +04:00
|
|
|
switch (code) {
|
2003-12-07 08:40:51 +03:00
|
|
|
//--------- BView Messages -----------------
|
2005-04-27 21:26:57 +04:00
|
|
|
case AS_LAYER_SCROLL:
|
2005-03-27 09:25:59 +04:00
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SCROLL: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
2005-04-27 21:26:57 +04:00
|
|
|
float dh;
|
|
|
|
float dv;
|
2005-04-19 22:55:46 +04:00
|
|
|
|
2005-04-27 21:26:57 +04:00
|
|
|
link.Read<float>(&dh);
|
|
|
|
link.Read<float>(&dv);
|
2005-04-26 17:50:34 +04:00
|
|
|
|
2005-04-27 21:26:57 +04:00
|
|
|
// scroll visually by using the CopyBits() implementation
|
|
|
|
// this will also take care of invalidating previously invisible
|
|
|
|
// areas (areas scrolled into view)
|
2005-05-26 17:56:42 +04:00
|
|
|
BRect src = fCurrentLayer->Bounds();
|
2005-04-27 21:26:57 +04:00
|
|
|
BRect dst = src;
|
|
|
|
// NOTE: if we scroll down, the contents are moved *up*
|
|
|
|
dst.OffsetBy(-dh, -dv);
|
2005-04-26 17:50:34 +04:00
|
|
|
|
|
|
|
// TODO: Are origin and scale handled in this conversion?
|
2005-05-26 17:56:42 +04:00
|
|
|
src = fCurrentLayer->ConvertToTop(src);
|
|
|
|
dst = fCurrentLayer->ConvertToTop(dst);
|
2005-04-26 17:50:34 +04:00
|
|
|
|
|
|
|
int32 xOffset = (int32)(dst.left - src.left);
|
|
|
|
int32 yOffset = (int32)(dst.top - src.top);
|
|
|
|
|
2005-04-27 21:26:57 +04:00
|
|
|
// this little detail is where it differs from CopyBits()
|
|
|
|
// -> it will invalidate areas previously out of screen
|
|
|
|
dst = dst | src;
|
2005-04-26 17:50:34 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
_CopyBits(myRootLayer, fCurrentLayer, src, dst, xOffset, yOffset);
|
2005-04-26 17:50:34 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->OffsetOrigin(BPoint(dh, dv));
|
2005-04-26 17:50:34 +04:00
|
|
|
|
2005-04-27 21:26:57 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_COPY_BITS:
|
|
|
|
{
|
|
|
|
BRect src;
|
|
|
|
BRect dst;
|
2005-04-26 17:50:34 +04:00
|
|
|
|
2005-04-27 21:26:57 +04:00
|
|
|
link.Read<BRect>(&src);
|
|
|
|
link.Read<BRect>(&dst);
|
2005-04-26 17:50:34 +04:00
|
|
|
|
2005-04-27 21:26:57 +04:00
|
|
|
// TODO: Are origin and scale handled in this conversion?
|
2005-05-26 17:56:42 +04:00
|
|
|
src = fCurrentLayer->ConvertToTop(src);
|
|
|
|
dst = fCurrentLayer->ConvertToTop(dst);
|
2005-04-27 21:26:57 +04:00
|
|
|
|
|
|
|
int32 xOffset = (int32)(dst.left - src.left);
|
|
|
|
int32 yOffset = (int32)(dst.top - src.top);
|
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
_CopyBits(myRootLayer, fCurrentLayer, src, dst, xOffset, yOffset);
|
2005-04-19 22:55:46 +04:00
|
|
|
|
2005-03-27 09:25:59 +04:00
|
|
|
break;
|
|
|
|
}
|
2003-09-09 01:18:39 +04:00
|
|
|
case AS_SET_CURRENT_LAYER:
|
|
|
|
{
|
2003-12-07 08:40:51 +03:00
|
|
|
int32 token;
|
2003-09-09 01:18:39 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int32>(&token);
|
2003-09-09 01:18:39 +04:00
|
|
|
|
2005-04-16 17:30:49 +04:00
|
|
|
// Layer *current = FindLayer(fWinBorder->fTopLayer, token);
|
|
|
|
Layer *current = fWinBorder->FindLayer(token);
|
2005-02-23 04:45:48 +03:00
|
|
|
if(current)
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: %s, token %ld\n", fName, current->fName->String(), token));
|
2005-02-23 04:45:48 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: layer not found, token %ld\n", fName, token));
|
2005-02-23 04:45:48 +03:00
|
|
|
}
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2003-09-09 01:18:39 +04:00
|
|
|
if (current)
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer=current;
|
2003-09-09 01:18:39 +04:00
|
|
|
else // hope this NEVER happens! :-)
|
2005-05-26 03:59:23 +04:00
|
|
|
CRITICAL("Server PANIC: window cannot find Layer with ID\n");
|
2003-09-09 01:18:39 +04:00
|
|
|
break;
|
|
|
|
}
|
2004-07-30 19:16:59 +04:00
|
|
|
|
|
|
|
case AS_LAYER_CREATE_ROOT:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_LAYER_CREATE_ROOT\n", fName));
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
// Start receiving top_view data -- pass NULL as the parent view.
|
|
|
|
// This should be the *only* place where this happens.
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer != NULL)
|
2004-07-30 19:16:59 +04:00
|
|
|
break;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
// fWinBorder->fTopLayer = CreateLayerTree(NULL);
|
|
|
|
fWinBorder->fTopLayer = CreateLayerTree(NULL, link);
|
2004-07-30 19:16:59 +04:00
|
|
|
fWinBorder->fTopLayer->SetAsTopLayer(true);
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer = fWinBorder->fTopLayer;
|
2004-07-30 19:16:59 +04:00
|
|
|
|
|
|
|
// connect decorator and top layer.
|
|
|
|
fWinBorder->AddChild(fWinBorder->fTopLayer, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
case AS_LAYER_CREATE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_LAYER_CREATE: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
2004-06-16 10:40:26 +04:00
|
|
|
Layer *newLayer;
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer == NULL)
|
2004-07-30 19:16:59 +04:00
|
|
|
break;
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
// newLayer = CreateLayerTree(NULL);
|
|
|
|
newLayer = CreateLayerTree(NULL, link);
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->AddChild(newLayer, this);
|
2004-06-16 10:40:26 +04:00
|
|
|
|
|
|
|
if (!(newLayer->IsHidden())){
|
2005-01-22 23:51:12 +03:00
|
|
|
myRootLayer->GoInvalidate(newLayer, newLayer->fFull);
|
2004-06-16 10:40:26 +04:00
|
|
|
}
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
break;
|
2004-03-28 19:00:31 +04:00
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
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
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: AS_LAYER_DELETE(self)...\n", fName));
|
2004-06-11 18:47:36 +04:00
|
|
|
Layer *parent;
|
2005-05-26 17:56:42 +04:00
|
|
|
parent = fCurrentLayer->fParent;
|
2003-02-24 18:47:06 +03:00
|
|
|
|
2004-01-20 05:02:01 +03:00
|
|
|
// here we remove current layer from list.
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->RemoveSelf();
|
|
|
|
fCurrentLayer->PruneTree();
|
2004-08-08 00:30:58 +04:00
|
|
|
|
2005-01-22 23:51:12 +03:00
|
|
|
if (parent)
|
2005-05-26 17:56:42 +04:00
|
|
|
myRootLayer->GoInvalidate(parent, BRegion(fCurrentLayer->Frame()));
|
2004-08-08 00:30:58 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_SERVERWINDOW
|
2003-09-15 23:14:45 +04:00
|
|
|
parent->PrintTree();
|
2004-08-08 00:30:58 +04:00
|
|
|
#endif
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("DONE: ServerWindow %s: Message AS_DELETE_LAYER: Parent: %s Layer: %s\n", fName, parent->fName->String(), fCurrentLayer->fName->String()));
|
2003-06-24 17:55:18 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
delete fCurrentLayer;
|
2003-09-15 23:14:45 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer=parent;
|
2003-06-24 17:55:18 +04:00
|
|
|
break;
|
|
|
|
}
|
2003-09-09 01:18:39 +04:00
|
|
|
case AS_LAYER_SET_STATE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_STATE: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
|
|
|
// SetLayerState(fCurrentLayer);
|
|
|
|
SetLayerState(fCurrentLayer, link);
|
2005-04-19 04:42:42 +04:00
|
|
|
// TODO: should this be moved into SetLayerState?
|
|
|
|
// If it _always_ needs to be done afterwards, then yes!
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->RebuildFullRegion();
|
2003-09-15 23:14:45 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_SET_FONT_STATE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
|
|
|
// SetLayerFontState(fCurrentLayer);
|
|
|
|
SetLayerFontState(fCurrentLayer, link);
|
|
|
|
fCurrentLayer->RebuildFullRegion();
|
2003-09-15 23:14:45 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_GET_STATE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
2005-04-19 04:42:42 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
2005-04-19 04:42:42 +04:00
|
|
|
|
|
|
|
// attach state data
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->WriteToLink(*fMsgSender);
|
2005-04-19 04:42:42 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fMsgSender->Attach<float>(fCurrentLayer->fFrame.left);
|
|
|
|
fMsgSender->Attach<float>(fCurrentLayer->fFrame.top);
|
|
|
|
fMsgSender->Attach<BRect>(fCurrentLayer->fFrame.OffsetToCopy(fCurrentLayer->BoundsOrigin()));
|
2005-04-19 04:42:42 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->Flush();
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2003-09-09 01:18:39 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-05-23 21:23:20 +04:00
|
|
|
case AS_LAYER_SET_MOUSE_EVENT_MASK:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_LAYER_SET_MOUSE_EVENT_MASK: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
2005-05-23 21:23:20 +04:00
|
|
|
|
|
|
|
uint32 mask;
|
|
|
|
uint32 options;
|
|
|
|
|
|
|
|
link.Read<uint32>(&mask);
|
|
|
|
link.Read<uint32>(&options);
|
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
myRootLayer->SetEventMaskLayer(fCurrentLayer, mask, options);
|
2005-05-23 21:23:20 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2003-09-25 16:31:11 +04:00
|
|
|
case AS_LAYER_MOVETO:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_LAYER_MOVETO: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
2004-06-11 18:47:36 +04:00
|
|
|
float x, y;
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<float>(&x);
|
|
|
|
link.Read<float>(&y);
|
2005-04-28 13:44:29 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
float offsetX = x - fCurrentLayer->fFrame.left;
|
|
|
|
float offsetY = y - fCurrentLayer->fFrame.top;
|
2005-04-28 13:44:29 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->MoveBy(offsetX, offsetY);
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_RESIZETO:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZETO: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
2004-06-11 18:47:36 +04:00
|
|
|
float newWidth, newHeight;
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<float>(&newWidth);
|
|
|
|
link.Read<float>(&newHeight);
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
// TODO: If fCurrentLayer is a window, check for minimum size allowed.
|
2005-04-28 13:44:29 +04:00
|
|
|
// Need WinBorder::GetSizeLimits
|
2005-05-26 17:56:42 +04:00
|
|
|
float deltaWidth = newWidth - fCurrentLayer->fFrame.Width();
|
|
|
|
float deltaHeight = newHeight - fCurrentLayer->fFrame.Height();
|
2005-04-28 13:44:29 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->ResizeBy(deltaWidth, deltaHeight);
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_GET_COORD:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
2005-04-28 03:20:29 +04:00
|
|
|
// our offset in the parent -> will be originX and originY in BView
|
2005-05-26 17:56:42 +04:00
|
|
|
fMsgSender->Attach<float>(fCurrentLayer->fFrame.left);
|
|
|
|
fMsgSender->Attach<float>(fCurrentLayer->fFrame.top);
|
2005-04-28 03:20:29 +04:00
|
|
|
// convert frame to bounds
|
2005-05-26 17:56:42 +04:00
|
|
|
fMsgSender->Attach<BRect>(fCurrentLayer->fFrame.OffsetToCopy(fCurrentLayer->BoundsOrigin()));
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->Flush();
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
2003-09-25 21:25:38 +04:00
|
|
|
case AS_LAYER_SET_ORIGIN:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_LAYER_SET_ORIGIN: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-06-11 18:47:36 +04:00
|
|
|
float x, y;
|
2003-09-25 21:25:38 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<float>(&x);
|
|
|
|
link.Read<float>(&y);
|
2003-09-25 21:25:38 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetOrigin(BPoint(x, y));
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2003-09-25 21:25:38 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_GET_ORIGIN:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
2005-05-26 17:56:42 +04:00
|
|
|
fMsgSender->Attach<BPoint>(fCurrentLayer->fLayerData->Origin());
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->Flush();
|
2003-09-25 21:25:38 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_RESIZE_MODE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
|
|
|
link.Read<uint32>(&(fCurrentLayer->fResizeMode));
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2003-09-25 21:25:38 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_CURSOR:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: Layer: %s - NOT IMPLEMENTED\n",fName, fCurrentLayer->fName->String()));
|
2004-06-11 18:47:36 +04:00
|
|
|
int32 token;
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int32>(&token);
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2005-01-19 21:00:05 +03:00
|
|
|
// TODO: implement; I think each Layer should have a member pointing
|
|
|
|
// to this requested cursor.
|
|
|
|
|
2003-09-25 21:25:38 +04:00
|
|
|
break;
|
|
|
|
}
|
2003-09-25 16:31:11 +04:00
|
|
|
case AS_LAYER_SET_FLAGS:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
link.Read<uint32>(&(fCurrentLayer->fFlags));
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_HIDE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_LAYER_HIDE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
|
|
|
fCurrentLayer->Hide();
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_SHOW:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_LAYER_SHOW: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
|
|
|
fCurrentLayer->Show();
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_SET_LINE_MODE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_LINE_MODE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-06-11 18:47:36 +04:00
|
|
|
int8 lineCap, lineJoin;
|
2005-04-19 04:42:42 +04:00
|
|
|
float miterLimit;
|
2004-01-20 01:18:37 +03:00
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Look into locking scheme relating to Layers and modifying redraw-related members
|
2004-01-20 01:18:37 +03:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int8>(&lineCap);
|
|
|
|
link.Read<int8>(&lineJoin);
|
2005-04-19 04:42:42 +04:00
|
|
|
link.Read<float>(&miterLimit);
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetLineCapMode((cap_mode)lineCap);
|
|
|
|
fCurrentLayer->fLayerData->SetLineJoinMode((join_mode)lineJoin);
|
|
|
|
fCurrentLayer->fLayerData->SetMiterLimit(miterLimit);
|
2003-09-25 16:31:11 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_GET_LINE_MODE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
2005-05-26 17:56:42 +04:00
|
|
|
fMsgSender->Attach<int8>((int8)(fCurrentLayer->fLayerData->LineCapMode()));
|
|
|
|
fMsgSender->Attach<int8>((int8)(fCurrentLayer->fLayerData->LineJoinMode()));
|
|
|
|
fMsgSender->Attach<float>(fCurrentLayer->fLayerData->MiterLimit());
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->Flush();
|
2003-09-25 16:31:11 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_PUSH_STATE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2005-04-19 04:42:42 +04:00
|
|
|
// TODO: refactor, put this in Layer
|
2004-06-11 18:47:36 +04:00
|
|
|
LayerData *ld = new LayerData();
|
2005-05-26 17:56:42 +04:00
|
|
|
ld->prevState = fCurrentLayer->fLayerData;
|
|
|
|
fCurrentLayer->fLayerData = ld;
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->RebuildFullRegion();
|
2003-09-25 16:31:11 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_POP_STATE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
|
|
|
if (!(fCurrentLayer->fLayerData->prevState))
|
2004-06-11 18:47:36 +04:00
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", fName, fCurrentLayer->fName->String()));
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-04-19 04:42:42 +04:00
|
|
|
// TODO: refactor, put this in Layer
|
2005-05-26 17:56:42 +04:00
|
|
|
LayerData *ld = fCurrentLayer->fLayerData;
|
|
|
|
fCurrentLayer->fLayerData = fCurrentLayer->fLayerData->prevState;
|
2005-01-28 02:16:28 +03:00
|
|
|
ld->prevState = NULL;
|
2003-09-25 16:31:11 +04:00
|
|
|
delete ld;
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->RebuildFullRegion();
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_SET_SCALE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2005-04-19 04:42:42 +04:00
|
|
|
float scale;
|
|
|
|
link.Read<float>(&scale);
|
|
|
|
// TODO: The BeBook says, if you call SetScale() it will be
|
|
|
|
// multiplied with the scale from all previous states on the stack
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetScale(scale);
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_GET_SCALE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_SCALE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
|
|
|
LayerData *ld = fCurrentLayer->fLayerData;
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
// TODO: And here, we're taking that into account, but not above
|
|
|
|
// -> refactor put scale into Layer, or better yet, when the
|
|
|
|
// state stack is within Layer, PushState() should multiply
|
|
|
|
// by the previous last states scale. Would fix the problem above too.
|
|
|
|
float scale = ld->Scale();
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
while ((ld = ld->prevState))
|
|
|
|
scale *= ld->Scale();
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
|
|
|
fMsgSender->Attach<float>(scale);
|
|
|
|
fMsgSender->Flush();
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_SET_PEN_LOC:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_LOC: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2003-09-25 16:31:11 +04:00
|
|
|
float x, y;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<float>(&x);
|
|
|
|
link.Read<float>(&y);
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetPenLocation(BPoint(x, y));
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_GET_PEN_LOC:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
2005-05-26 17:56:42 +04:00
|
|
|
fMsgSender->Attach<BPoint>(fCurrentLayer->fLayerData->PenLocation());
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->Flush();
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_SET_PEN_SIZE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2005-04-19 04:42:42 +04:00
|
|
|
float penSize;
|
|
|
|
link.Read<float>(&penSize);
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetPenSize(penSize);
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_GET_PEN_SIZE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
2005-05-26 17:56:42 +04:00
|
|
|
fMsgSender->Attach<float>(fCurrentLayer->fLayerData->PenSize());
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->Flush();
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_SET_VIEW_COLOR:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_VIEW_COLOR: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-06-11 18:47:36 +04:00
|
|
|
rgb_color c;
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read(&c, sizeof(rgb_color));
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetViewColor(RGBColor(c));
|
2005-04-19 04:42:42 +04:00
|
|
|
|
|
|
|
// TODO: this should not trigger redraw, no?!?
|
2005-05-26 17:56:42 +04:00
|
|
|
myRootLayer->GoRedraw(fCurrentLayer, fCurrentLayer->fVisible);
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_GET_COLORS:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-06-11 18:47:36 +04:00
|
|
|
rgb_color highColor, lowColor, viewColor;
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
highColor = fCurrentLayer->fLayerData->HighColor().GetColor32();
|
|
|
|
lowColor = fCurrentLayer->fLayerData->LowColor().GetColor32();
|
|
|
|
viewColor = fCurrentLayer->fLayerData->ViewColor().GetColor32();
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
|
|
|
fMsgSender->Attach(&highColor, sizeof(rgb_color));
|
|
|
|
fMsgSender->Attach(&lowColor, sizeof(rgb_color));
|
|
|
|
fMsgSender->Attach(&viewColor, sizeof(rgb_color));
|
|
|
|
fMsgSender->Flush();
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_SET_BLEND_MODE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_BLEND_MODE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-06-11 18:47:36 +04:00
|
|
|
int8 srcAlpha, alphaFunc;
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int8>(&srcAlpha);
|
|
|
|
link.Read<int8>(&alphaFunc);
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetBlendingMode((source_alpha)srcAlpha,
|
2005-04-19 04:42:42 +04:00
|
|
|
(alpha_function)alphaFunc);
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_GET_BLEND_MODE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
2005-05-26 17:56:42 +04:00
|
|
|
fMsgSender->Attach<int8>((int8)(fCurrentLayer->fLayerData->AlphaSrcMode()));
|
|
|
|
fMsgSender->Attach<int8>((int8)(fCurrentLayer->fLayerData->AlphaFncMode()));
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->Flush();
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_SET_DRAW_MODE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_DRAW_MODE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-06-11 18:47:36 +04:00
|
|
|
int8 drawingMode;
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int8>(&drawingMode);
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetDrawingMode((drawing_mode)drawingMode);
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_GET_DRAW_MODE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
2005-05-26 17:56:42 +04:00
|
|
|
fMsgSender->Attach<int8>((int8)(fCurrentLayer->fLayerData->GetDrawingMode()));
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->Flush();
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_PRINT_ALIASING:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2005-04-19 04:42:42 +04:00
|
|
|
bool fontAliasing;
|
|
|
|
link.Read<bool>(&fontAliasing);
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetFontAntiAliasing(!fontAliasing);
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_CLIP_TO_PICTURE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2005-03-19 21:58:47 +03:00
|
|
|
|
|
|
|
// TODO: you are not allowed to use Layer regions here!!!
|
|
|
|
// If there is no other way, then first lock RootLayer object first.
|
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Watch out for the coordinate system in AS_LAYER_CLIP_TO_PICTURE
|
2004-06-11 18:47:36 +04:00
|
|
|
int32 pictureToken;
|
|
|
|
BPoint where;
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int32>(&pictureToken);
|
|
|
|
link.Read<BPoint>(&where);
|
2004-06-11 18:47:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
BRegion reg;
|
|
|
|
bool redraw = false;
|
|
|
|
|
|
|
|
// if we had a picture to clip to, include the FULL visible region(if any) in the area to be redrawn
|
|
|
|
// in other words: invalidate what ever is visible for this layer and his children.
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer->clipToPicture && fCurrentLayer->fFullVisible.CountRects() > 0)
|
2004-06-11 18:47:36 +04:00
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
reg.Include(&fCurrentLayer->fFullVisible);
|
2003-11-14 03:15:29 +03:00
|
|
|
redraw = true;
|
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
|
|
|
|
// search for a picture with the specified token.
|
2005-05-14 20:04:49 +04:00
|
|
|
ServerPicture *sp = fServerApp->FindPicture(pictureToken);
|
2005-05-14 17:22:26 +04:00
|
|
|
// TODO: Increase that picture's reference count.(~ allocate a picture)
|
|
|
|
if (sp == NULL)
|
|
|
|
break;
|
2005-05-26 17:56:42 +04:00
|
|
|
|
2004-06-11 18:47:36 +04:00
|
|
|
// we have a new picture to clip to, so rebuild our full region
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer->clipToPicture) {
|
|
|
|
fCurrentLayer->clipToPictureInverse = false;
|
|
|
|
fCurrentLayer->RebuildFullRegion();
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2005-05-26 17:56:42 +04:00
|
|
|
|
2004-06-11 18:47:36 +04:00
|
|
|
// we need to rebuild the visible region, we may have a valid one.
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer->fParent && !fCurrentLayer->fHidden) {
|
|
|
|
//fCurrentLayer->fParent->RebuildChildRegions(fCurrentLayer->fFull.Frame(), fCurrentLayer);
|
|
|
|
} else {
|
2004-06-11 18:47:36 +04:00
|
|
|
// will this happen? Maybe...
|
2005-05-26 17:56:42 +04:00
|
|
|
//fCurrentLayer->RebuildRegions(fCurrentLayer->fFull.Frame());
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
|
|
|
|
// include our full visible region in the region to be redrawn
|
2005-05-26 17:56:42 +04:00
|
|
|
if (!fCurrentLayer->fHidden && (fCurrentLayer->fFullVisible.CountRects() > 0)) {
|
|
|
|
reg.Include(&(fCurrentLayer->fFullVisible));
|
|
|
|
redraw = true;
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2005-05-26 17:56:42 +04:00
|
|
|
|
2004-06-11 18:47:36 +04:00
|
|
|
// redraw if we previously had or if we have acquired a picture to clip to.
|
2005-04-19 04:42:42 +04:00
|
|
|
// TODO: Are you sure about triggering a redraw?
|
2004-06-11 18:47:36 +04:00
|
|
|
if (redraw)
|
2005-05-26 17:56:42 +04:00
|
|
|
myRootLayer->GoRedraw(fCurrentLayer, reg);
|
2003-09-25 16:31:11 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_CLIP_TO_INVERSE_PICTURE:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Watch out for the coordinate system in AS_LAYER_CLIP_TO_INVERSE_PICTURE
|
2004-06-11 18:47:36 +04:00
|
|
|
int32 pictureToken;
|
|
|
|
BPoint where;
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int32>(&pictureToken);
|
|
|
|
link.Read<BPoint>(&where);
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-05-14 17:22:26 +04:00
|
|
|
// TODO: Increase that picture's reference count.(~ allocate a picture)
|
2005-05-14 20:04:49 +04:00
|
|
|
ServerPicture *sp = fServerApp->FindPicture(pictureToken);
|
2005-05-14 17:22:26 +04:00
|
|
|
if (sp == NULL)
|
|
|
|
break;
|
|
|
|
|
2004-06-11 18:47:36 +04:00
|
|
|
// if a picture has been found...
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer->clipToPicture) {
|
|
|
|
fCurrentLayer->clipToPictureInverse = true;
|
|
|
|
fCurrentLayer->RebuildFullRegion();
|
|
|
|
//fCurrentLayer->RequestDraw(fCurrentLayer->clipToPicture->Frame());
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_GET_CLIP_REGION:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-08-29 19:01:44 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
// if this Layer is hidden, it is clear that its visible region is void.
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer->IsHidden())
|
2004-08-29 19:01:44 +04:00
|
|
|
{
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
|
|
|
fMsgSender->Attach<int32>(0L);
|
|
|
|
fMsgSender->Flush();
|
2004-06-16 10:40:26 +04:00
|
|
|
}
|
2004-08-29 19:01:44 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// TODO: Watch out for the coordinate system in AS_LAYER_GET_CLIP_REGION
|
2004-06-16 10:40:26 +04:00
|
|
|
BRegion reg;
|
|
|
|
LayerData *ld;
|
|
|
|
int32 noOfRects;
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
ld = fCurrentLayer->fLayerData;
|
|
|
|
reg = fCurrentLayer->ConvertFromParent(&(fCurrentLayer->fVisible));
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
if (ld->ClippingRegion())
|
|
|
|
reg.IntersectWith(ld->ClippingRegion());
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
// TODO: This could also be done more reliably in the Layer,
|
|
|
|
// when the State stack is implemented there. There should be
|
|
|
|
// DrawData::fCulmulatedClippingRegion...
|
|
|
|
// TODO: the DrawData clipping region should be in local view coords.
|
|
|
|
while ((ld = ld->prevState)) {
|
|
|
|
if (ld->ClippingRegion())
|
|
|
|
reg.IntersectWith(ld->ClippingRegion());
|
2004-06-16 10:40:26 +04:00
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
noOfRects = reg.CountRects();
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
|
|
|
fMsgSender->Attach<int32>(noOfRects);
|
2004-06-16 10:40:26 +04:00
|
|
|
|
|
|
|
for(int i = 0; i < noOfRects; i++)
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->Attach<BRect>(reg.RectAt(i));
|
2004-06-16 10:40:26 +04:00
|
|
|
}
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_SET_CLIP_REGION:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-08-29 19:01:44 +04:00
|
|
|
|
|
|
|
// TODO: Watch out for the coordinate system in AS_LAYER_SET_CLIP_REGION
|
2004-06-11 18:47:36 +04:00
|
|
|
int32 noOfRects;
|
|
|
|
BRect r;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int32>(&noOfRects);
|
2005-04-19 04:42:42 +04:00
|
|
|
|
|
|
|
BRegion region;
|
2004-06-11 18:47:36 +04:00
|
|
|
for(int i = 0; i < noOfRects; i++)
|
|
|
|
{
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&r);
|
2005-04-19 04:42:42 +04:00
|
|
|
region.Include(r);
|
2003-09-25 16:31:11 +04:00
|
|
|
}
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetClippingRegion(region);
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->RebuildFullRegion();
|
|
|
|
if (!(fCurrentLayer->IsHidden()))
|
|
|
|
myRootLayer->GoInvalidate(fCurrentLayer, fCurrentLayer->fFull);
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2003-09-25 16:31:11 +04:00
|
|
|
break;
|
|
|
|
}
|
2003-09-25 21:25:38 +04:00
|
|
|
case AS_LAYER_INVAL_RECT:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-08-29 19:01:44 +04:00
|
|
|
|
2005-04-15 04:31:39 +04:00
|
|
|
// TODO: handle transformation (origin and scale) prior to converting to top
|
2003-09-25 21:25:38 +04:00
|
|
|
BRect invalRect;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&invalRect);
|
2005-05-26 17:56:42 +04:00
|
|
|
BRect converted(fCurrentLayer->ConvertToTop(invalRect.LeftTop()),
|
|
|
|
fCurrentLayer->ConvertToTop(invalRect.RightBottom()));
|
2005-01-22 23:51:12 +03:00
|
|
|
|
2005-04-15 20:03:16 +04:00
|
|
|
myRootLayer->GoRedraw(fWinBorder, BRegion(converted));
|
2003-09-25 21:25:38 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_INVAL_REGION:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-08-29 19:01:44 +04:00
|
|
|
|
2005-04-19 04:42:42 +04:00
|
|
|
// TODO: handle transformation (origin and scale) prior to converting to top
|
|
|
|
// TODO: Handle conversion to top
|
2004-06-11 18:47:36 +04:00
|
|
|
BRegion invalReg;
|
|
|
|
int32 noOfRects;
|
|
|
|
BRect rect;
|
2003-09-25 21:25:38 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int32>(&noOfRects);
|
2003-09-25 21:25:38 +04:00
|
|
|
|
2004-06-11 18:47:36 +04:00
|
|
|
for(int i = 0; i < noOfRects; i++)
|
|
|
|
{
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&rect);
|
2003-12-07 08:40:51 +03:00
|
|
|
invalReg.Include(rect);
|
2003-09-25 21:25:38 +04:00
|
|
|
}
|
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
myRootLayer->GoRedraw(fCurrentLayer, invalReg);
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2003-09-25 21:25:38 +04:00
|
|
|
break;
|
|
|
|
}
|
2004-07-06 00:37:13 +04:00
|
|
|
case AS_BEGIN_UPDATE:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindowo %s: AS_BEGIN_UPDATE\n",fName));
|
2005-03-31 00:06:50 +04:00
|
|
|
fWinBorder->GetRootLayer()->Lock();
|
2005-03-31 20:48:51 +04:00
|
|
|
fWinBorder->UpdateStart();
|
2005-03-31 00:06:50 +04:00
|
|
|
fWinBorder->GetRootLayer()->Unlock();
|
2004-07-06 00:37:13 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_END_UPDATE:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindowo %s: AS_END_UPDATE\n",fName));
|
2005-03-31 02:13:26 +04:00
|
|
|
fWinBorder->GetRootLayer()->Lock();
|
2005-03-31 20:48:51 +04:00
|
|
|
fWinBorder->UpdateEnd();
|
2005-03-31 02:13:26 +04:00
|
|
|
fWinBorder->GetRootLayer()->Unlock();
|
2004-07-06 00:37:13 +04:00
|
|
|
break;
|
|
|
|
}
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2004-06-11 18:47:36 +04:00
|
|
|
// ********** END: BView Messages ***********
|
2003-09-09 01:18:39 +04:00
|
|
|
|
2004-06-11 18:47:36 +04:00
|
|
|
// ********* BWindow Messages ***********
|
2003-06-24 17:55:18 +04:00
|
|
|
case AS_LAYER_DELETE_ROOT:
|
|
|
|
{
|
|
|
|
// Received when a window deletes its internal top view
|
|
|
|
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement AS_LAYER_DELETE_ROOT
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Delete_Layer_Root unimplemented\n",fName));
|
2003-02-24 18:47:06 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_SHOW_WINDOW:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_SHOW_WINDOW\n",fName));
|
2003-02-24 18:47:06 +03:00
|
|
|
Show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_HIDE_WINDOW:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_HIDE_WINDOW\n",fName));
|
2003-02-24 18:47:06 +03:00
|
|
|
Hide();
|
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_SEND_BEHIND:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement AS_SEND_BEHIND
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Send_Behind unimplemented\n",fName));
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_ENABLE_UPDATES:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement AS_ENABLE_UPDATES
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Enable_Updates unimplemented\n",fName));
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_DISABLE_UPDATES:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement AS_DISABLE_UPDATES
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Disable_Updates unimplemented\n",fName));
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_NEEDS_UPDATE:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement AS_NEEDS_UPDATE
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Needs_Update unimplemented\n",fName));
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_WINDOW_TITLE:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement AS_WINDOW_TITLE
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Set_Title unimplemented\n",fName));
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_ADD_TO_SUBSET:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_ADD_TO_SUBSET\n",fName));
|
2004-06-11 18:47:36 +04:00
|
|
|
WinBorder *wb;
|
|
|
|
int32 mainToken;
|
|
|
|
team_id teamID;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int32>(&mainToken);
|
|
|
|
link.Read(&teamID, sizeof(team_id));
|
2004-01-14 03:26:15 +03:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
wb = gDesktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID);
|
2004-06-11 18:47:36 +04:00
|
|
|
if(wb)
|
|
|
|
{
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
|
|
|
fMsgSender->Flush();
|
2005-03-14 01:54:01 +03:00
|
|
|
|
|
|
|
BPortLink msg(-1, -1);
|
|
|
|
msg.StartMessage(AS_ROOTLAYER_ADD_TO_SUBSET);
|
|
|
|
msg.Attach<WinBorder*>(fWinBorder);
|
|
|
|
msg.Attach<WinBorder*>(wb);
|
|
|
|
fWinBorder->GetRootLayer()->EnqueueMessage(msg);
|
2004-01-14 03:26:15 +03:00
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
else
|
|
|
|
{
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_FALSE);
|
|
|
|
fMsgSender->Flush();
|
2004-01-14 03:26:15 +03:00
|
|
|
}
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_REM_FROM_SUBSET:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_REM_FROM_SUBSET\n",fName));
|
2004-06-11 18:47:36 +04:00
|
|
|
WinBorder *wb;
|
|
|
|
int32 mainToken;
|
|
|
|
team_id teamID;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int32>(&mainToken);
|
|
|
|
link.Read(&teamID, sizeof(team_id));
|
2004-01-17 19:33:22 +03:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
wb = gDesktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID);
|
2004-06-11 18:47:36 +04:00
|
|
|
if(wb)
|
|
|
|
{
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
|
|
|
fMsgSender->Flush();
|
2004-01-17 19:33:22 +03:00
|
|
|
|
2005-03-18 22:00:45 +03:00
|
|
|
BPortLink msg(-1, -1);
|
|
|
|
msg.StartMessage(AS_ROOTLAYER_REMOVE_FROM_SUBSET);
|
|
|
|
msg.Attach<WinBorder*>(fWinBorder);
|
|
|
|
msg.Attach<WinBorder*>(wb);
|
|
|
|
fWinBorder->GetRootLayer()->EnqueueMessage(msg);
|
2004-01-17 19:33:22 +03:00
|
|
|
}
|
2004-06-11 18:47:36 +04:00
|
|
|
else
|
|
|
|
{
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_FALSE);
|
|
|
|
fMsgSender->Flush();
|
2004-01-17 19:33:22 +03:00
|
|
|
}
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_SET_LOOK:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement AS_SET_LOOK
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Set_Look unimplemented\n",fName));
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_SET_FLAGS:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement AS_SET_FLAGS
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Set_Flags unimplemented\n",fName));
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_SET_FEEL:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2005-04-21 22:57:34 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_SET_FEEL\n",fName));
|
|
|
|
int32 newFeel;
|
|
|
|
link.Read<int32>(&newFeel);
|
|
|
|
myRootLayer->GoChangeWinBorderFeel(fWinBorder, newFeel);
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_SET_ALIGNMENT:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement AS_SET_ALIGNMENT
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Set_Alignment unimplemented\n",fName));
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_GET_ALIGNMENT:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement AS_GET_ALIGNMENT
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Get_Alignment unimplemented\n",fName));
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_GET_WORKSPACES:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Get_Workspaces unimplemented\n",fName));
|
2005-04-10 23:04:06 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
2005-04-16 17:30:49 +04:00
|
|
|
fMsgSender->Attach<uint32>(fWinBorder->Workspaces());
|
2005-04-10 23:04:06 +04:00
|
|
|
fMsgSender->Flush();
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-03-19 04:12:53 +03:00
|
|
|
case AS_SET_WORKSPACES:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement AS_SET_WORKSPACES
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Set_Workspaces unimplemented\n",fName));
|
|
|
|
uint32 newWorkspaces;
|
|
|
|
link.Read<uint32>(&newWorkspaces);
|
2005-04-10 23:04:06 +04:00
|
|
|
|
|
|
|
BPortLink msg(-1, -1);
|
|
|
|
msg.StartMessage(AS_ROOTLAYER_WINBORDER_SET_WORKSPACES);
|
|
|
|
msg.Attach<WinBorder*>(fWinBorder);
|
2005-04-16 17:30:49 +04:00
|
|
|
msg.Attach<uint32>(fWinBorder->Workspaces());
|
|
|
|
msg.Attach<uint32>(newWorkspaces);
|
2005-04-10 23:04:06 +04:00
|
|
|
fWinBorder->GetRootLayer()->EnqueueMessage(msg);
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-04-18 23:58:43 +04:00
|
|
|
case AS_WINDOW_RESIZE:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-06-11 18:47:36 +04:00
|
|
|
float xResizeBy;
|
|
|
|
float yResizeBy;
|
2004-05-16 23:24:18 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<float>(&xResizeBy);
|
|
|
|
link.Read<float>(&yResizeBy);
|
2005-04-28 16:31:25 +04:00
|
|
|
|
|
|
|
STRACE(("ServerWindow %s: Message AS_WINDOW_RESIZE %.1f, %.1f\n",fName, xResizeBy, yResizeBy));
|
2004-05-16 23:24:18 +04:00
|
|
|
|
|
|
|
fWinBorder->ResizeBy(xResizeBy, yResizeBy);
|
2004-06-11 18:47:36 +04:00
|
|
|
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-06-18 23:13:06 +04:00
|
|
|
case AS_WINDOW_MOVE:
|
|
|
|
{
|
|
|
|
float xMoveBy;
|
|
|
|
float yMoveBy;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<float>(&xMoveBy);
|
|
|
|
link.Read<float>(&yMoveBy);
|
2004-06-18 23:13:06 +04:00
|
|
|
|
2005-04-28 16:31:25 +04:00
|
|
|
STRACE(("ServerWindow %s: Message AS_WINDOW_MOVE: %.1f, %.1f\n",fName, xMoveBy, yMoveBy));
|
|
|
|
|
2004-06-18 23:13:06 +04:00
|
|
|
fWinBorder->MoveBy(xMoveBy, yMoveBy);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2004-08-08 00:30:58 +04:00
|
|
|
case AS_SET_SIZE_LIMITS:
|
|
|
|
{
|
|
|
|
// Attached Data:
|
|
|
|
// 1) float minimum width
|
|
|
|
// 2) float maximum width
|
|
|
|
// 3) float minimum height
|
|
|
|
// 4) float maximum height
|
|
|
|
|
|
|
|
float wmin,wmax,hmin,hmax;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<float>(&wmin);
|
|
|
|
link.Read<float>(&wmax);
|
|
|
|
link.Read<float>(&hmin);
|
|
|
|
link.Read<float>(&hmax);
|
2004-08-08 00:30:58 +04:00
|
|
|
|
|
|
|
fWinBorder->SetSizeLimits(wmin,wmax,hmin,hmax);
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
|
|
|
fMsgSender->Flush();
|
2004-08-08 00:30:58 +04:00
|
|
|
break;
|
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
case B_MINIMIZE:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement B_MINIMIZE
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Minimize unimplemented\n",fName));
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
case B_WINDOW_ACTIVATED:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement B_WINDOW_ACTIVATED
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Window_Activated unimplemented\n",fName));
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
case B_ZOOM:
|
2003-03-23 23:52:37 +03:00
|
|
|
{
|
2004-08-29 19:01:44 +04:00
|
|
|
// TODO: Implement B_ZOOM
|
2005-04-16 17:30:49 +04:00
|
|
|
STRACE(("ServerWindow %s: Message Zoom unimplemented\n",fName));
|
2003-03-23 23:52:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-05-20 04:09:59 +04:00
|
|
|
// Some BView drawing messages, but which don't need clipping
|
2004-09-15 02:21:26 +04:00
|
|
|
case AS_LAYER_SET_HIGH_COLOR:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_HIGH_COLOR: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-09-15 02:21:26 +04:00
|
|
|
rgb_color c;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read(&c, sizeof(rgb_color));
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetHighColor(RGBColor(c));
|
2004-09-15 02:21:26 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_SET_LOW_COLOR:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_LOW_COLOR: Layer: %s\n",fName, fCurrentLayer->fName->String()));
|
2004-09-15 02:21:26 +04:00
|
|
|
rgb_color c;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read(&c, sizeof(rgb_color));
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetLowColor(RGBColor(c));
|
2004-09-15 02:21:26 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2005-03-27 08:08:33 +04:00
|
|
|
case AS_LAYER_SET_PATTERN:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_PATTERN: Layer: %s\n", fName, fCurrentLayer->fName->String()));
|
2005-03-27 08:08:33 +04:00
|
|
|
pattern pat;
|
|
|
|
|
|
|
|
link.Read(&pat, sizeof(pattern));
|
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetPattern(Pattern(pat));
|
2005-03-27 08:08:33 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2005-05-20 04:09:59 +04:00
|
|
|
case AS_MOVEPENTO:
|
|
|
|
{
|
|
|
|
DTRACE(("ServerWindow %s: Message AS_MOVEPENTO\n",fName));
|
|
|
|
|
|
|
|
float x,y;
|
|
|
|
|
|
|
|
link.Read<float>(&x);
|
|
|
|
link.Read<float>(&y);
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
|
|
|
fCurrentLayer->fLayerData->SetPenLocation(BPoint(x, y));
|
2005-05-20 04:09:59 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_SETPENSIZE:
|
|
|
|
{
|
|
|
|
DTRACE(("ServerWindow %s: Message AS_SETPENSIZE\n",fName));
|
|
|
|
float size;
|
|
|
|
|
|
|
|
link.Read<float>(&size);
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
|
|
|
fCurrentLayer->fLayerData->SetPenSize(size);
|
2005-05-20 04:09:59 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_SET_FONT:
|
|
|
|
{
|
|
|
|
DTRACE(("ServerWindow %s: Message AS_SET_FONT\n",fName));
|
|
|
|
// TODO: Implement AS_SET_FONT?
|
|
|
|
// Confusing!! But it works already!
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_SET_FONT_SIZE:
|
|
|
|
{
|
|
|
|
DTRACE(("ServerWindow %s: Message AS_SET_FONT_SIZE\n",fName));
|
|
|
|
// TODO: Implement AS_SET_FONT_SIZE?
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_AREA_MESSAGE:
|
|
|
|
{
|
|
|
|
STRACE(("ServerWindow %s: Message AS_AREA_MESSAGE\n",fName));
|
|
|
|
// This occurs in only one kind of case: a message is too big to send over a port. This
|
|
|
|
// is really an edge case, so this shouldn't happen *too* often
|
|
|
|
|
|
|
|
// Attached Data:
|
|
|
|
// 1) area_id id of an area already owned by the server containing the message
|
|
|
|
// 2) size_t offset of the pointer in the area
|
|
|
|
// 3) size_t size of the message
|
|
|
|
|
|
|
|
area_id area;
|
|
|
|
size_t offset;
|
|
|
|
size_t msgsize;
|
|
|
|
area_info ai;
|
|
|
|
int8 *msgpointer;
|
|
|
|
|
|
|
|
link.Read<area_id>(&area);
|
|
|
|
link.Read<size_t>(&offset);
|
|
|
|
link.Read<size_t>(&msgsize);
|
|
|
|
|
|
|
|
// Part sanity check, part get base pointer :)
|
|
|
|
if(get_area_info(area,&ai)!=B_OK)
|
|
|
|
break;
|
|
|
|
|
|
|
|
msgpointer=(int8*)ai.address + offset;
|
|
|
|
|
|
|
|
RAMLinkMsgReader mlink(msgpointer);
|
|
|
|
DispatchMessage(mlink.Code(),mlink);
|
|
|
|
|
|
|
|
// This is a very special case in the sense that when ServerMemIO is used for this
|
|
|
|
// purpose, it will be set to NOT automatically free the memory which it had
|
|
|
|
// requested. This is the server's job once the message has been dispatched.
|
|
|
|
fServerApp->AppAreaPool()->ReleaseBuffer(msgpointer);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_SYNC:
|
|
|
|
{
|
|
|
|
// TODO: AS_SYNC is a no-op for now, just to get things working
|
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
|
|
|
fMsgSender->Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_DRAG_IMAGE:
|
|
|
|
{
|
|
|
|
// TODO: Implement AS_LAYER_DRAG_IMAGE
|
|
|
|
STRACE(("ServerWindow %s: Message AS_DRAG_IMAGE unimplemented\n",fName));
|
|
|
|
DTRACE(("ServerWindow %s: Message AS_DRAG_IMAGE unimplemented\n",fName));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_DRAG_RECT:
|
|
|
|
{
|
|
|
|
// TODO: Implement AS_LAYER_DRAG_RECT
|
|
|
|
STRACE(("ServerWindow %s: Message AS_DRAG_RECT unimplemented\n",fName));
|
|
|
|
DTRACE(("ServerWindow %s: Message AS_DRAG_RECT unimplemented\n",fName));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_GET_MOUSE_COORDS:
|
|
|
|
{
|
2005-05-20 06:42:52 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_GET_MOUSE_COORDS\n", fName));
|
|
|
|
|
|
|
|
fMsgSender->StartMessage(SERVER_TRUE);
|
|
|
|
|
2005-05-20 04:09:59 +04:00
|
|
|
// Returns
|
|
|
|
// 1) BPoint mouse location
|
|
|
|
// 2) int32 button state
|
2005-05-20 06:42:52 +04:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
fMsgSender->Attach<BPoint>(gDesktop->GetDisplayDriver()->GetCursorPosition());
|
|
|
|
fMsgSender->Attach<int32>(gDesktop->ActiveRootLayer()->Buttons());
|
2005-05-20 06:42:52 +04:00
|
|
|
|
|
|
|
fMsgSender->Flush();
|
2005-05-20 04:09:59 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-05-20 06:42:52 +04:00
|
|
|
|
2005-05-20 04:09:59 +04:00
|
|
|
default:
|
|
|
|
DispatchGraphicsMessage(code, link);
|
2005-05-20 06:42:52 +04:00
|
|
|
break;
|
2005-05-20 04:09:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -------------------- Graphics messages ----------------------------------
|
|
|
|
inline
|
2005-05-26 17:56:42 +04:00
|
|
|
void
|
|
|
|
ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
2005-05-20 04:09:59 +04:00
|
|
|
{
|
|
|
|
fWinBorder->GetRootLayer()->Lock();
|
2005-05-26 17:56:42 +04:00
|
|
|
BRegion rreg(fCurrentLayer->fVisible);
|
2005-05-20 04:09:59 +04:00
|
|
|
if (fWinBorder->fInUpdate)
|
|
|
|
rreg.IntersectWith(&fWinBorder->yUpdateReg);
|
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->ConstrainClippingRegion(&rreg);
|
2005-05-26 17:56:42 +04:00
|
|
|
// rgb_color rrr = fCurrentLayer->fLayerData->viewcolor.GetColor32();
|
2005-05-20 04:09:59 +04:00
|
|
|
// RGBColor c(rand()%255,rand()%255,rand()%255);
|
2005-05-28 17:43:13 +04:00
|
|
|
// gDesktop->GetDisplayDriver()->FillRect(BRect(0,0,639,479), c);
|
2005-05-20 04:09:59 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
switch (code) {
|
2004-09-14 04:51:51 +04:00
|
|
|
case AS_STROKE_LINE:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_STROKE_LINE\n",fName));
|
2005-05-26 17:56:42 +04:00
|
|
|
|
2004-09-14 04:51:51 +04:00
|
|
|
float x1, y1, x2, y2;
|
2005-05-26 17:56:42 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<float>(&x1);
|
|
|
|
link.Read<float>(&y1);
|
|
|
|
link.Read<float>(&x2);
|
|
|
|
link.Read<float>(&y2);
|
2005-05-26 17:56:42 +04:00
|
|
|
|
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData) {
|
2004-09-14 04:51:51 +04:00
|
|
|
BPoint p1(x1,y1);
|
|
|
|
BPoint p2(x2,y2);
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->StrokeLine(fCurrentLayer->ConvertToTop(p1),
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->ConvertToTop(p2),
|
|
|
|
fCurrentLayer->fLayerData);
|
2004-10-17 02:42:08 +04:00
|
|
|
|
|
|
|
// We update the pen here because many DisplayDriver calls which do not update the
|
|
|
|
// pen position actually call StrokeLine
|
2005-04-19 04:42:42 +04:00
|
|
|
|
|
|
|
// TODO: Decide where to put this, for example, it cannot be done
|
|
|
|
// for DrawString(), also there needs to be a decision, if penlocation
|
|
|
|
// is in View coordinates (I think it should be) or in screen coordinates.
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData->SetPenLocation(p2);
|
2004-09-14 04:51:51 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-01-21 05:01:28 +03:00
|
|
|
case AS_LAYER_INVERT_RECT:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_INVERT_RECT\n",fName));
|
2005-01-21 05:01:28 +03:00
|
|
|
|
|
|
|
BRect rect;
|
|
|
|
link.Read<BRect>(&rect);
|
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->InvertRect(fCurrentLayer->ConvertToTop(rect));
|
2005-01-21 05:01:28 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-09-15 02:21:26 +04:00
|
|
|
case AS_STROKE_RECT:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_STROKE_RECT\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-15 02:21:26 +04:00
|
|
|
float left, top, right, bottom;
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<float>(&left);
|
|
|
|
link.Read<float>(&top);
|
|
|
|
link.Read<float>(&right);
|
|
|
|
link.Read<float>(&bottom);
|
2004-09-15 02:21:26 +04:00
|
|
|
BRect rect(left,top,right,bottom);
|
2005-01-19 18:12:35 +03:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->StrokeRect(fCurrentLayer->ConvertToTop(rect),fCurrentLayer->fLayerData);
|
2004-10-17 02:42:08 +04:00
|
|
|
break;
|
2004-09-15 02:21:26 +04:00
|
|
|
}
|
|
|
|
case AS_FILL_RECT:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_FILL_RECT\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-15 02:21:26 +04:00
|
|
|
BRect rect;
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&rect);
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->FillRect(fCurrentLayer->ConvertToTop(rect),fCurrentLayer->fLayerData);
|
2004-10-17 02:42:08 +04:00
|
|
|
break;
|
2004-09-15 02:21:26 +04:00
|
|
|
}
|
2005-05-20 04:09:59 +04:00
|
|
|
case AS_LAYER_DRAW_BITMAP_SYNC_AT_POINT:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_DRAW_BITMAP_SYNC_AT_POINT: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
2005-05-20 04:09:59 +04:00
|
|
|
int32 bitmapToken;
|
|
|
|
BPoint point;
|
|
|
|
|
|
|
|
link.Read<int32>(&bitmapToken);
|
|
|
|
link.Read<BPoint>(&point);
|
|
|
|
|
|
|
|
ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken);
|
|
|
|
if (sbmp) {
|
|
|
|
|
|
|
|
BRect src = sbmp->Bounds();
|
2005-05-26 17:56:42 +04:00
|
|
|
BRect dst = fCurrentLayer->fParent->ConvertFromParent(fCurrentLayer->fFull.Frame());
|
2005-05-20 04:09:59 +04:00
|
|
|
dst.OffsetBy(point);
|
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->GetDisplayDriver()->DrawBitmap(sbmp, src, dst, fCurrentLayer->fLayerData);
|
2005-05-20 04:09:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Adi -- shouldn't AS_LAYER_DRAW_BITMAP_SYNC_AT_POINT sync with the client?
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_DRAW_BITMAP_ASYNC_AT_POINT:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_DRAW_BITMAP_ASYNC_AT_POINT: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
2005-05-20 04:09:59 +04:00
|
|
|
int32 bitmapToken;
|
|
|
|
BPoint point;
|
|
|
|
|
|
|
|
link.Read<int32>(&bitmapToken);
|
|
|
|
link.Read<BPoint>(&point);
|
|
|
|
|
|
|
|
ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken);
|
|
|
|
if (sbmp) {
|
|
|
|
|
|
|
|
BRect src = sbmp->Bounds();
|
2005-05-26 17:56:42 +04:00
|
|
|
BRect dst = fCurrentLayer->fParent->ConvertFromParent(fCurrentLayer->fFull.Frame());
|
2005-05-20 04:09:59 +04:00
|
|
|
dst.OffsetBy(point);
|
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->GetDisplayDriver()->DrawBitmap(sbmp, src, dst, fCurrentLayer->fLayerData);
|
2005-05-20 04:09:59 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_DRAW_BITMAP_SYNC_IN_RECT:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_DRAW_BITMAP_SYNC_IN_RECT: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
2005-05-20 04:09:59 +04:00
|
|
|
int32 bitmapToken;
|
|
|
|
BRect srcRect, dstRect;
|
|
|
|
|
|
|
|
link.Read<int32>(&bitmapToken);
|
|
|
|
link.Read<BRect>(&dstRect);
|
|
|
|
link.Read<BRect>(&srcRect);
|
|
|
|
|
|
|
|
ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken);
|
|
|
|
if (sbmp) {
|
2005-05-26 17:56:42 +04:00
|
|
|
BRect dst = fCurrentLayer->fParent->ConvertFromParent(fCurrentLayer->fFull.Frame());
|
2005-05-20 04:09:59 +04:00
|
|
|
dstRect.OffsetBy(dst.left, dst.top);
|
|
|
|
// TODO: why is this not working:
|
2005-05-26 17:56:42 +04:00
|
|
|
// fCurrentLayer->ConvertToTop(dstRect);
|
2005-05-20 04:09:59 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->GetDisplayDriver()->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->fLayerData);
|
2005-05-20 04:09:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Adi -- shouldn't AS_LAYER_DRAW_BITMAP_SYNC_IN_RECT sync with the client?
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_LAYER_DRAW_BITMAP_ASYNC_IN_RECT:
|
|
|
|
{
|
2005-05-26 17:56:42 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_LAYER_DRAW_BITMAP_ASYNC_IN_RECT: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
2005-05-20 04:09:59 +04:00
|
|
|
int32 bitmapToken;
|
|
|
|
BRect srcRect, dstRect;
|
|
|
|
|
|
|
|
link.Read<int32>(&bitmapToken);
|
|
|
|
link.Read<BRect>(&dstRect);
|
|
|
|
link.Read<BRect>(&srcRect);
|
|
|
|
|
|
|
|
ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken);
|
|
|
|
if (sbmp) {
|
2005-05-26 17:56:42 +04:00
|
|
|
BRect dst = fCurrentLayer->fParent->ConvertFromParent(fCurrentLayer->fFull.Frame());
|
2005-05-20 04:09:59 +04:00
|
|
|
dstRect.OffsetBy(dst.left, dst.top);
|
|
|
|
// TODO: why is this not working:
|
2005-05-26 17:56:42 +04:00
|
|
|
// fCurrentLayer->ConvertToTop(dstRect);
|
2005-05-20 04:09:59 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->GetDisplayDriver()->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->fLayerData);
|
2005-05-20 04:09:59 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2004-09-15 02:21:26 +04:00
|
|
|
case AS_STROKE_ARC:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_STROKE_ARC\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-15 02:21:26 +04:00
|
|
|
float angle, span;
|
|
|
|
BRect r;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&r);
|
|
|
|
link.Read<float>(&angle);
|
|
|
|
link.Read<float>(&span);
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->StrokeArc(fCurrentLayer->ConvertToTop(r),angle,span,fCurrentLayer->fLayerData);
|
2004-09-15 02:21:26 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_ARC:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_FILL_ARC\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-15 02:21:26 +04:00
|
|
|
float angle, span;
|
|
|
|
BRect r;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&r);
|
|
|
|
link.Read<float>(&angle);
|
|
|
|
link.Read<float>(&span);
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->FillArc(fCurrentLayer->ConvertToTop(r),angle,span,fCurrentLayer->fLayerData);
|
2004-09-15 02:21:26 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_BEZIER:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_STROKE_BEZIER\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-15 02:21:26 +04:00
|
|
|
BPoint *pts;
|
|
|
|
int i;
|
|
|
|
pts = new BPoint[4];
|
|
|
|
|
|
|
|
for (i=0; i<4; i++)
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BPoint>(&(pts[i]));
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2004-09-15 02:21:26 +04:00
|
|
|
{
|
|
|
|
for (i=0; i<4; i++)
|
2005-05-26 17:56:42 +04:00
|
|
|
pts[i]=fCurrentLayer->ConvertToTop(pts[i]);
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->StrokeBezier(pts,fCurrentLayer->fLayerData);
|
2004-09-15 02:21:26 +04:00
|
|
|
}
|
|
|
|
delete [] pts;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_BEZIER:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_FILL_BEZIER\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-15 02:21:26 +04:00
|
|
|
BPoint *pts;
|
|
|
|
int i;
|
|
|
|
pts = new BPoint[4];
|
|
|
|
|
|
|
|
for (i=0; i<4; i++)
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BPoint>(&(pts[i]));
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2004-09-15 02:21:26 +04:00
|
|
|
{
|
|
|
|
for (i=0; i<4; i++)
|
2005-05-26 17:56:42 +04:00
|
|
|
pts[i]=fCurrentLayer->ConvertToTop(pts[i]);
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->FillBezier(pts,fCurrentLayer->fLayerData);
|
2004-09-15 02:21:26 +04:00
|
|
|
}
|
|
|
|
delete [] pts;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_ELLIPSE:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_STROKE_ELLIPSE\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-15 02:21:26 +04:00
|
|
|
BRect rect;
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&rect);
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->StrokeEllipse(fCurrentLayer->ConvertToTop(rect),fCurrentLayer->fLayerData);
|
2004-09-15 02:21:26 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_ELLIPSE:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_FILL_ELLIPSE\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-15 02:21:26 +04:00
|
|
|
BRect rect;
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&rect);
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->FillEllipse(fCurrentLayer->ConvertToTop(rect),fCurrentLayer->fLayerData);
|
2004-09-15 02:21:26 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_ROUNDRECT:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_STROKE_ROUNDRECT\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-15 02:21:26 +04:00
|
|
|
BRect rect;
|
|
|
|
float xrad,yrad;
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&rect);
|
|
|
|
link.Read<float>(&xrad);
|
|
|
|
link.Read<float>(&yrad);
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->StrokeRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad,fCurrentLayer->fLayerData);
|
2004-09-15 02:21:26 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_ROUNDRECT:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_FILL_ROUNDRECT\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-15 02:21:26 +04:00
|
|
|
BRect rect;
|
|
|
|
float xrad,yrad;
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&rect);
|
|
|
|
link.Read<float>(&xrad);
|
|
|
|
link.Read<float>(&yrad);
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->FillRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad,fCurrentLayer->fLayerData);
|
2004-09-15 02:21:26 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_TRIANGLE:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_STROKE_TRIANGLE\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-15 02:21:26 +04:00
|
|
|
BPoint pts[3];
|
|
|
|
BRect rect;
|
|
|
|
|
|
|
|
for (int i=0; i<3; i++)
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BPoint>(&(pts[i]));
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&rect);
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2004-09-15 02:21:26 +04:00
|
|
|
{
|
|
|
|
for(int i=0;i<3;i++)
|
2005-05-26 17:56:42 +04:00
|
|
|
pts[i]=fCurrentLayer->ConvertToTop(pts[i]);
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->StrokeTriangle(pts,fCurrentLayer->ConvertToTop(rect),fCurrentLayer->fLayerData);
|
2004-09-15 02:21:26 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_TRIANGLE:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_FILL_TRIANGLE\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-15 02:21:26 +04:00
|
|
|
BPoint pts[3];
|
|
|
|
BRect rect;
|
|
|
|
|
|
|
|
for (int i=0; i<3; i++)
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BPoint>(&(pts[i]));
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&rect);
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2004-09-15 02:21:26 +04:00
|
|
|
{
|
|
|
|
for(int i=0;i<3;i++)
|
2005-05-26 17:56:42 +04:00
|
|
|
pts[i]=fCurrentLayer->ConvertToTop(pts[i]);
|
2004-09-15 02:21:26 +04:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->FillTriangle(pts,fCurrentLayer->ConvertToTop(rect),fCurrentLayer->fLayerData);
|
2004-09-15 02:21:26 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-04-19 04:42:42 +04:00
|
|
|
// TODO: get rid of all this code duplication!!
|
2004-09-17 14:27:58 +04:00
|
|
|
case AS_STROKE_POLYGON:
|
2003-02-24 18:47:06 +03:00
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_STROKE_POLYGON\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-17 14:27:58 +04:00
|
|
|
BRect polyframe;
|
|
|
|
bool isclosed;
|
|
|
|
int32 pointcount;
|
|
|
|
BPoint *pointlist;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&polyframe);
|
|
|
|
link.Read<bool>(&isclosed);
|
|
|
|
link.Read<int32>(&pointcount);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
|
|
|
pointlist=new BPoint[pointcount];
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read(pointlist, sizeof(BPoint)*pointcount);
|
2004-09-21 02:50:02 +04:00
|
|
|
|
2004-09-17 14:27:58 +04:00
|
|
|
for(int32 i=0; i<pointcount; i++)
|
2005-05-26 17:56:42 +04:00
|
|
|
pointlist[i]=fCurrentLayer->ConvertToTop(pointlist[i]);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->StrokePolygon(pointlist,pointcount,polyframe,
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->fLayerData,isclosed);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
|
|
|
delete [] pointlist;
|
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-09-17 14:27:58 +04:00
|
|
|
case AS_FILL_POLYGON:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_FILL_POLYGON\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-17 14:27:58 +04:00
|
|
|
BRect polyframe;
|
|
|
|
int32 pointcount;
|
|
|
|
BPoint *pointlist;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&polyframe);
|
|
|
|
link.Read<int32>(&pointcount);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
|
|
|
pointlist=new BPoint[pointcount];
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read(pointlist, sizeof(BPoint)*pointcount);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
|
|
|
for(int32 i=0; i<pointcount; i++)
|
2005-05-26 17:56:42 +04:00
|
|
|
pointlist[i]=fCurrentLayer->ConvertToTop(pointlist[i]);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->FillPolygon(pointlist,pointcount,polyframe,fCurrentLayer->fLayerData);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
|
|
|
delete [] pointlist;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_STROKE_SHAPE:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_STROKE_SHAPE\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-17 14:27:58 +04:00
|
|
|
BRect shaperect;
|
|
|
|
int32 opcount;
|
|
|
|
int32 ptcount;
|
|
|
|
int32 *oplist;
|
|
|
|
BPoint *ptlist;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&shaperect);
|
|
|
|
link.Read<int32>(&opcount);
|
|
|
|
link.Read<int32>(&ptcount);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
|
|
|
oplist=new int32[opcount];
|
|
|
|
ptlist=new BPoint[ptcount];
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read(oplist,sizeof(int32)*opcount);
|
|
|
|
link.Read(ptlist,sizeof(BPoint)*ptcount);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
|
|
|
for(int32 i=0; i<ptcount; i++)
|
2005-05-26 17:56:42 +04:00
|
|
|
ptlist[i]=fCurrentLayer->ConvertToTop(ptlist[i]);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->StrokeShape(shaperect, opcount, oplist, ptcount, ptlist, fCurrentLayer->fLayerData);
|
2004-09-17 14:27:58 +04:00
|
|
|
delete oplist;
|
|
|
|
delete ptlist;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_SHAPE:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_FILL_SHAPE\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-17 14:27:58 +04:00
|
|
|
BRect shaperect;
|
|
|
|
int32 opcount;
|
|
|
|
int32 ptcount;
|
|
|
|
int32 *oplist;
|
|
|
|
BPoint *ptlist;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BRect>(&shaperect);
|
|
|
|
link.Read<int32>(&opcount);
|
|
|
|
link.Read<int32>(&ptcount);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
|
|
|
oplist=new int32[opcount];
|
|
|
|
ptlist=new BPoint[ptcount];
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read(oplist,sizeof(int32)*opcount);
|
|
|
|
link.Read(ptlist,sizeof(BPoint)*ptcount);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
|
|
|
for(int32 i=0; i<ptcount; i++)
|
2005-05-26 17:56:42 +04:00
|
|
|
ptlist[i]=fCurrentLayer->ConvertToTop(ptlist[i]);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->FillShape(shaperect, opcount, oplist, ptcount, ptlist, fCurrentLayer->fLayerData);
|
2004-08-29 19:01:44 +04:00
|
|
|
|
2004-09-17 14:27:58 +04:00
|
|
|
delete oplist;
|
|
|
|
delete ptlist;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_FILL_REGION:
|
2003-07-09 06:28:33 +04:00
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_FILL_REGION\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-09-17 14:27:58 +04:00
|
|
|
int32 rectcount;
|
|
|
|
BRect *rectlist;
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<int32>(&rectcount);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
|
|
|
rectlist=new BRect[rectcount];
|
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read(rectlist, sizeof(BRect)*rectcount);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
|
|
|
// Between the client-side conversion to BRects from clipping_rects to the overhead
|
|
|
|
// in repeatedly calling FillRect(), this is definitely in need of optimization. At
|
|
|
|
// least it works for now. :)
|
|
|
|
for(int32 i=0; i<rectcount; i++)
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->FillRect(fCurrentLayer->ConvertToTop(rectlist[i]),fCurrentLayer->fLayerData);
|
2004-09-17 14:27:58 +04:00
|
|
|
|
|
|
|
delete [] rectlist;
|
|
|
|
|
|
|
|
// TODO: create support for clipping_rect usage for faster BRegion display.
|
|
|
|
// Tweaks to DisplayDriver are necessary along with conversion routines in Layer
|
|
|
|
|
|
|
|
break;
|
2003-07-09 06:28:33 +04:00
|
|
|
}
|
2004-09-17 14:27:58 +04:00
|
|
|
case AS_STROKE_LINEARRAY:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_STROKE_LINEARRAY\n",fName));
|
2004-10-17 02:42:08 +04:00
|
|
|
|
2004-10-16 06:02:27 +04:00
|
|
|
// Attached Data:
|
|
|
|
// 1) int32 Number of lines in the array
|
|
|
|
// 2) array of struct _array_data_ objects, as defined in ViewAux.h
|
|
|
|
|
|
|
|
int32 linecount;
|
|
|
|
|
|
|
|
link.Read<int32>(&linecount);
|
|
|
|
if(linecount>0)
|
|
|
|
{
|
|
|
|
LineArrayData linedata[linecount], *index;
|
|
|
|
|
|
|
|
for(int32 i=0; i<linecount; i++)
|
|
|
|
{
|
|
|
|
index=&linedata[i];
|
|
|
|
|
|
|
|
link.Read<float>(&(index->pt1.x));
|
|
|
|
link.Read<float>(&(index->pt1.y));
|
|
|
|
link.Read<float>(&(index->pt2.x));
|
|
|
|
link.Read<float>(&(index->pt2.y));
|
|
|
|
link.Read<rgb_color>(&(index->color));
|
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
index->pt1=fCurrentLayer->ConvertToTop(index->pt1);
|
|
|
|
index->pt2=fCurrentLayer->ConvertToTop(index->pt2);
|
2004-10-17 02:42:08 +04:00
|
|
|
}
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->StrokeLineArray(linecount,linedata,fCurrentLayer->fLayerData);
|
2004-10-16 06:02:27 +04:00
|
|
|
}
|
2004-09-17 14:27:58 +04:00
|
|
|
break;
|
|
|
|
}
|
2004-09-21 02:50:02 +04:00
|
|
|
case AS_DRAW_STRING:
|
2003-07-05 01:13:48 +04:00
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
DTRACE(("ServerWindow %s: Message AS_DRAW_STRING\n",fName));
|
2004-09-21 02:50:02 +04:00
|
|
|
char *string;
|
|
|
|
int32 length;
|
|
|
|
BPoint location;
|
|
|
|
escapement_delta delta;
|
|
|
|
|
2004-10-17 02:42:08 +04:00
|
|
|
link.Read<int32>(&length);
|
2004-10-16 06:02:27 +04:00
|
|
|
link.Read<BPoint>(&location);
|
|
|
|
link.Read<escapement_delta>(&delta);
|
|
|
|
link.ReadString(&string);
|
2004-09-21 02:50:02 +04:00
|
|
|
|
2005-05-26 17:56:42 +04:00
|
|
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->DrawString(string, length,
|
2005-05-26 17:56:42 +04:00
|
|
|
fCurrentLayer->ConvertToTop(location),
|
|
|
|
fCurrentLayer->fLayerData);
|
2004-09-21 02:50:02 +04:00
|
|
|
|
|
|
|
free(string);
|
2004-09-17 14:27:58 +04:00
|
|
|
break;
|
2003-07-05 01:13:48 +04:00
|
|
|
}
|
2004-09-17 14:27:58 +04:00
|
|
|
default:
|
|
|
|
{
|
2005-04-16 17:30:49 +04:00
|
|
|
printf("ServerWindow %s received unexpected code - message offset %ld\n",fName, code - SERVER_TRUE);
|
2004-09-17 14:27:58 +04:00
|
|
|
break;
|
2003-06-23 06:53:55 +04:00
|
|
|
}
|
|
|
|
}
|
2005-03-31 00:06:50 +04:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->GetDisplayDriver()->ConstrainClippingRegion(NULL);
|
2005-03-31 00:06:50 +04:00
|
|
|
fWinBorder->GetRootLayer()->Unlock();
|
2003-03-19 04:12:53 +03:00
|
|
|
}
|
2005-05-26 19:04:45 +04: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.
|
|
|
|
*/
|
2005-05-26 19:04:45 +04:00
|
|
|
int32
|
|
|
|
ServerWindow::MonitorWin(void *data)
|
2003-02-07 15:53:57 +03:00
|
|
|
{
|
2005-05-26 19:04:45 +04:00
|
|
|
ServerWindow *win = (ServerWindow *)data;
|
2004-10-16 06:02:27 +04:00
|
|
|
LinkMsgReader *ses = win->fMsgReader;
|
2005-05-26 19:04:45 +04:00
|
|
|
|
|
|
|
bool quitting = false;
|
|
|
|
int32 code;
|
|
|
|
status_t err = B_OK;
|
|
|
|
|
|
|
|
while (!quitting) {
|
2005-01-17 00:35:02 +03:00
|
|
|
// printf("info: ServerWindow::MonitorWin listening on port %ld.\n", win->fMessagePort);
|
2004-06-19 14:23:14 +04:00
|
|
|
code = AS_CLIENT_DEAD;
|
2004-10-16 06:02:27 +04:00
|
|
|
err = ses->GetNextMessage(&code);
|
2004-07-30 19:16:59 +04:00
|
|
|
if (err < B_OK)
|
|
|
|
return err;
|
2004-01-20 05:02:01 +03:00
|
|
|
|
2004-06-19 14:23:14 +04:00
|
|
|
win->Lock();
|
|
|
|
|
2005-05-26 19:04:45 +04:00
|
|
|
switch (code) {
|
2004-06-19 17:04:50 +04:00
|
|
|
case AS_DELETE_WINDOW:
|
2004-06-19 14:23:14 +04:00
|
|
|
case AS_CLIENT_DEAD:
|
2004-01-20 01:18:37 +03:00
|
|
|
{
|
2004-01-13 03:56:36 +03:00
|
|
|
// this means the client has been killed
|
2004-06-19 17:04:50 +04:00
|
|
|
STRACE(("ServerWindow %s received 'AS_CLIENT_DEAD/AS_DELETE_WINDOW' message code\n",win->Title()));
|
2005-01-22 23:51:12 +03:00
|
|
|
|
2005-05-26 19:04:45 +04:00
|
|
|
//RootLayer *rootLayer = fWinBorder->GetRootLayer();
|
2005-01-22 23:51:12 +03:00
|
|
|
|
|
|
|
// we are preparing to delete a ServerWindow, RootLayer should be aware
|
|
|
|
// of that and stop for a moment.
|
|
|
|
// also we must wait a bit for the associated WinBorder to become hidden
|
2005-05-26 19:04:45 +04:00
|
|
|
//while(1) {
|
|
|
|
// myRootLayer->Lock();
|
|
|
|
// if (IsHidden())
|
|
|
|
// break;
|
|
|
|
// else
|
|
|
|
// rootLayer->Unlock();
|
|
|
|
//}
|
|
|
|
|
2004-06-19 17:04:50 +04:00
|
|
|
// ServerWindow's destructor takes care of pulling this object off the desktop.
|
2005-04-16 17:30:49 +04:00
|
|
|
if (!win->fWinBorder->IsHidden())
|
2005-05-26 03:59:23 +04:00
|
|
|
CRITICAL("ServerWindow: a window must be hidden before it's deleted\n");
|
2005-01-22 23:51:12 +03:00
|
|
|
|
2005-05-26 19:04:45 +04:00
|
|
|
delete win;
|
|
|
|
// rootLayer->Unlock();
|
|
|
|
|
2005-01-22 23:51:12 +03:00
|
|
|
exit_thread(0);
|
2004-01-13 03:56:36 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-01-20 01:18:37 +03:00
|
|
|
case B_QUIT_REQUESTED:
|
|
|
|
{
|
2004-01-13 03:56:36 +03:00
|
|
|
STRACE(("ServerWindow %s received Quit request\n",win->Title()));
|
2005-01-22 23:51:12 +03:00
|
|
|
win->Quit();
|
2004-01-13 03:56:36 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-01-20 01:18:37 +03:00
|
|
|
default:
|
|
|
|
{
|
2004-10-16 06:02:27 +04:00
|
|
|
win->DispatchMessage(code, *ses);
|
2004-01-13 03:56:36 +03:00
|
|
|
break;
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
2003-08-31 21:38:34 +04:00
|
|
|
}
|
2004-06-19 14:23:14 +04:00
|
|
|
|
|
|
|
win->Unlock();
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
2004-07-30 19:16:59 +04:00
|
|
|
return err;
|
2003-02-07 15:53:57 +03:00
|
|
|
}
|
2005-04-27 21:26:57 +04:00
|
|
|
|
|
|
|
// _CopyBits
|
|
|
|
void
|
|
|
|
ServerWindow::_CopyBits(RootLayer* rootLayer, Layer* layer,
|
|
|
|
BRect& src, BRect& dst,
|
|
|
|
int32 xOffset, int32 yOffset) const
|
|
|
|
{
|
|
|
|
// NOTE: The correct behaviour is this:
|
|
|
|
// * The region that is copied is the
|
|
|
|
// src rectangle, no matter if it fits
|
|
|
|
// into the dst rectangle. It is copied
|
|
|
|
// by the offset dst.LeftTop() - src.LeftTop()
|
|
|
|
// * The dst rectangle is used for invalidation:
|
|
|
|
// Any area in the dst rectangle that could
|
|
|
|
// not be copied from src (because either the
|
|
|
|
// src rectangle was not big enough, or because there
|
|
|
|
// were parts cut off by the current layer clipping),
|
|
|
|
// are triggering BView::Draw() to be called
|
|
|
|
// and for these parts only.
|
|
|
|
|
|
|
|
// the region that is going to be copied
|
|
|
|
BRegion copyRegion(src);
|
|
|
|
// apply the current clipping of the layer
|
|
|
|
copyRegion.IntersectWith(&layer->fVisible);
|
|
|
|
|
|
|
|
// offset the region to the destination
|
|
|
|
// and apply the current clipping there as well
|
|
|
|
copyRegion.OffsetBy(xOffset, yOffset);
|
|
|
|
copyRegion.IntersectWith(&layer->fVisible);
|
|
|
|
|
|
|
|
// the region at the destination that needs invalidation
|
|
|
|
BRegion invalidRegion(dst);
|
|
|
|
// exclude the region drawn by the copy operation
|
|
|
|
invalidRegion.Exclude(©Region);
|
|
|
|
// apply the current clipping as well
|
|
|
|
invalidRegion.IntersectWith(&layer->fVisible);
|
|
|
|
|
|
|
|
// move the region back for the actual operation
|
|
|
|
copyRegion.OffsetBy(-xOffset, -yOffset);
|
|
|
|
|
2005-05-14 20:04:49 +04:00
|
|
|
layer->GetDisplayDriver()->CopyRegion(©Region, xOffset, yOffset);
|
2005-04-27 21:26:57 +04:00
|
|
|
|
|
|
|
// trigger the redraw
|
|
|
|
rootLayer->GoRedraw(fWinBorder, invalidRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-26 19:04:45 +04:00
|
|
|
void
|
|
|
|
ServerWindow::SendMessageToClient(const BMessage* msg, int32 target, bool usePreferred) const
|
2004-01-20 01:18:37 +03:00
|
|
|
{
|
2005-05-04 01:42:37 +04:00
|
|
|
ssize_t size = msg->FlattenedSize();
|
|
|
|
char* buffer = new char[size];
|
|
|
|
|
|
|
|
if (msg->Flatten(buffer, size) == B_OK) {
|
|
|
|
// BMessage::Private::SendFlattenedMessage(buffer, size,
|
|
|
|
// fClientLooperPort, target, usePreferred, B_INFINITE_TIMEOUT);
|
|
|
|
status_t ret = BMessage::Private::SendFlattenedMessage(buffer, size,
|
|
|
|
fClientLooperPort, target, usePreferred, 100000);
|
|
|
|
if (ret < B_OK)
|
|
|
|
fprintf(stderr, "ServerWindow::SendMessageToClient(): %s\n", strerror(ret));
|
|
|
|
} else
|
2005-04-16 17:30:49 +04:00
|
|
|
printf("PANIC: ServerWindow %s: can't flatten message in 'SendMessageToClient()'\n", fName);
|
2003-09-25 16:31:11 +04:00
|
|
|
|
2005-05-04 01:42:37 +04:00
|
|
|
delete[] buffer;
|
2003-09-25 16:31:11 +04:00
|
|
|
}
|
2003-09-09 01:18:39 +04:00
|
|
|
|