2005-06-08 08:01:59 +04:00
|
|
|
/*
|
2007-01-19 19:41:58 +03:00
|
|
|
* Copyright 2001-2007, Haiku.
|
2005-06-08 08:01:59 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
* Adrian Oanca <adioanca@cotty.iren.ro>
|
|
|
|
* Stephan Aßmus <superstippi@gmx.de>
|
|
|
|
* Stefano Ceccherini (burton666@libero.it)
|
|
|
|
* Axel Dörfler, axeld@pinc-software.de
|
2005-10-31 14:05:52 +03:00
|
|
|
* Jérôme Duval, jerome.duval@free.fr
|
2005-06-08 08:01:59 +04:00
|
|
|
*/
|
|
|
|
|
2005-07-26 01:08:34 +04:00
|
|
|
/*!
|
|
|
|
\class ServerApp ServerApp.h
|
|
|
|
\brief Counterpart to BApplication within the app_server
|
|
|
|
*/
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2004-01-17 21:37:57 +03:00
|
|
|
#include "AppServer.h"
|
2005-06-24 03:46:17 +04:00
|
|
|
#include "BitmapManager.h"
|
2003-01-24 17:36:15 +03:00
|
|
|
#include "CursorManager.h"
|
2005-07-18 04:22:08 +04:00
|
|
|
#include "CursorSet.h"
|
2003-01-24 18:19:27 +03:00
|
|
|
#include "Desktop.h"
|
2005-12-08 15:41:19 +03:00
|
|
|
#include "DebugInfoManager.h"
|
2005-06-24 03:46:17 +04:00
|
|
|
#include "DecorManager.h"
|
2005-11-04 18:54:16 +03:00
|
|
|
#include "DrawingEngine.h"
|
* the new input event dispatcher is now actually used, although it doesn't
distribute any messages to the clients yet.
* removed the working thread from RootLayer - for now, its event handlers are
still called using input filters in the new event dispatcher, though (to
get things started).
* ServerApp is now using a BMessenger to identify its client, and no longer
stores the port/token separately.
* the input_server handshake is a bit simpler now, as it can now just reply
to the app_server message, removed unused code from ServerProtocol.h
* calmed down the MultiLocker (it always printed thread statistics on startup,
because it's compiled in debug mode).
* removed the cursor thread stuff from AppServer.cpp
* the new event dispatcher now uses a cursor thread when supported (only in
native mode, not in the test environment), although it improves cursor
movement under Qemu, the effect is not as good as expected - this might
need some more investigations (might just be a thread priority problem).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15012 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-18 14:30:06 +03:00
|
|
|
#include "EventStream.h"
|
2005-11-02 16:25:39 +03:00
|
|
|
#include "FontManager.h"
|
2005-06-24 03:46:17 +04:00
|
|
|
#include "HWInterface.h"
|
* the new input event dispatcher is now actually used, although it doesn't
distribute any messages to the clients yet.
* removed the working thread from RootLayer - for now, its event handlers are
still called using input filters in the new event dispatcher, though (to
get things started).
* ServerApp is now using a BMessenger to identify its client, and no longer
stores the port/token separately.
* the input_server handshake is a bit simpler now, as it can now just reply
to the app_server message, removed unused code from ServerProtocol.h
* calmed down the MultiLocker (it always printed thread statistics on startup,
because it's compiled in debug mode).
* removed the cursor thread stuff from AppServer.cpp
* the new event dispatcher now uses a cursor thread when supported (only in
native mode, not in the test environment), although it improves cursor
movement under Qemu, the effect is not as good as expected - this might
need some more investigations (might just be a thread priority problem).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15012 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-18 14:30:06 +03:00
|
|
|
#include "InputManager.h"
|
offscreen bitmaps work, tested on Haiku as well, supports all colorspaces that BBitmap::ImportBits() supports. It uses a fallback for non-B_RGB(A)32 bitmaps. Added support for B_SUB_PIXEL_PRECISION view flags, though it is a bit hacky, since I had to add it to LayerData, even though it is not a true part of stack data. Added Layer::SetFlags() to enforce code path and update fLayerData. Cleaned up DisplayDriverPainter and DisplayDriver API (changed some const BRect& rect to simply BRect rect in order to be able to reuse it in the code), moved Painter.h, the test environment only draws the changed part of the frame buffer again - this causes a lot less CPU overhead, Painter special cases stroke width of 1.0 to use square caps, which is similar to R5 implementation and removes a lot of problems with non-straight line drawing, ServerWindow uses the DisplayDriver from it's WinBorder instead of the one from the Desktop (needed for offscreen windows, which have their own DisplayDriverPainter), it also checks for GetRootLayer() == NULL, because offscreen layers are not attached to a RootLayer, there was a fix for scrolling which worked at least in the test environment, it is now defunced, because Adi moved _CopyBits to Layer... I need to reenable it later, LayerData has no more fEscapementDelta, also fixed fFontAliasing (which was thought to overriding the font flags, and now works as such again), Desktop initialises the menu_info and scroll_bar_info stuff, which makes ScrollBars work actually... hope I didn't forget something.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13448 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-07-05 20:17:16 +04:00
|
|
|
#include "OffscreenServerWindow.h"
|
2004-10-14 05:23:00 +04:00
|
|
|
#include "RAMLinkMsgReader.h"
|
2005-11-07 14:02:39 +03:00
|
|
|
#include "ServerApp.h"
|
2003-01-24 17:36:15 +03:00
|
|
|
#include "ServerBitmap.h"
|
|
|
|
#include "ServerConfig.h"
|
2005-06-24 03:46:17 +04:00
|
|
|
#include "ServerCursor.h"
|
|
|
|
#include "ServerPicture.h"
|
|
|
|
#include "ServerScreen.h"
|
2005-11-14 22:46:20 +03:00
|
|
|
#include "ServerTokenSpace.h"
|
2005-06-24 03:46:17 +04:00
|
|
|
#include "ServerWindow.h"
|
2005-06-08 01:32:24 +04:00
|
|
|
#include "SystemPalette.h"
|
2005-11-24 20:45:26 +03:00
|
|
|
#include "WindowLayer.h"
|
2003-03-19 04:12:53 +03:00
|
|
|
|
2007-01-19 19:41:58 +03:00
|
|
|
#include <FontPrivate.h>
|
|
|
|
#include <MessengerPrivate.h>
|
|
|
|
#include <RosterPrivate.h>
|
|
|
|
#include <ServerProtocol.h>
|
|
|
|
#include <WindowPrivate.h>
|
|
|
|
|
2006-03-18 19:42:14 +03:00
|
|
|
#include <AppDefs.h>
|
|
|
|
#include <Autolock.h>
|
|
|
|
#include <List.h>
|
|
|
|
#include <ScrollBar.h>
|
|
|
|
#include <Shape.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
2006-12-18 08:22:13 +03:00
|
|
|
#include <new>
|
2006-03-18 19:42:14 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <syslog.h>
|
2003-09-17 23:28:31 +04:00
|
|
|
|
2006-03-18 19:42:14 +03:00
|
|
|
|
|
|
|
//#define DEBUG_SERVERAPP
|
2003-09-09 01:48:35 +04:00
|
|
|
#ifdef DEBUG_SERVERAPP
|
|
|
|
# define STRACE(x) printf x
|
|
|
|
#else
|
|
|
|
# define STRACE(x) ;
|
|
|
|
#endif
|
2003-01-24 17:36:15 +03:00
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
//#define DEBUG_SERVERAPP_FONT
|
2005-01-19 18:12:35 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG_SERVERAPP_FONT
|
|
|
|
# define FTRACE(x) printf x
|
|
|
|
#else
|
|
|
|
# define FTRACE(x) ;
|
|
|
|
#endif
|
|
|
|
|
2005-11-18 17:20:38 +03:00
|
|
|
using std::nothrow;
|
2005-06-23 21:40:35 +04:00
|
|
|
|
2007-02-21 10:57:21 +03:00
|
|
|
static const uint32 kMsgUpdateShowAllDraggers = '_adg';
|
2005-06-23 21:40:35 +04:00
|
|
|
static const uint32 kMsgAppQuit = 'appQ';
|
|
|
|
|
|
|
|
|
2005-07-26 01:08:34 +04:00
|
|
|
ServerApp::ServerApp(Desktop* desktop, port_id clientReplyPort,
|
2005-12-02 18:42:28 +03:00
|
|
|
port_id clientLooperPort, team_id clientTeam,
|
|
|
|
int32 clientToken, const char* signature)
|
2005-07-23 22:30:48 +04:00
|
|
|
: MessageLooper("application"),
|
2005-12-02 18:42:28 +03:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
fMessagePort(-1),
|
2005-07-23 22:30:48 +04:00
|
|
|
fClientReplyPort(clientReplyPort),
|
2005-07-26 01:08:34 +04:00
|
|
|
fDesktop(desktop),
|
2005-06-08 08:01:59 +04:00
|
|
|
fSignature(signature),
|
2005-06-23 21:40:35 +04:00
|
|
|
fClientTeam(clientTeam),
|
2005-06-23 22:48:10 +04:00
|
|
|
fWindowListLock("window list"),
|
2005-06-08 08:01:59 +04:00
|
|
|
fAppCursor(NULL),
|
2006-03-09 21:37:28 +03:00
|
|
|
fViewCursor(NULL),
|
2006-01-12 14:59:24 +03:00
|
|
|
fCursorHideLevel(0),
|
2005-06-08 08:01:59 +04:00
|
|
|
fIsActive(false),
|
* Implemented a new client allocation method: instead of having all bitmaps of
all teams in serveral server areas, and instead of having to eventually clone
them all several times in BBitmap, we now have one or more areas per team,
and BBitmap will only clone areas once if needed. As a side effect, this
method should be magnitudes faster than the previous version.
* This method is also much more secure: instead of putting the allocation
maintenance structures into those everyone-read-write areas, they are now
separated, so that faulty applications cannot crash the app_server this
way anymore. This should fix bug #172.
* Freeing memory is not yet implemented though! (although all memory will
be freed upon app exit)
* There are now 3 different bitmap allocation strategies: per ClientMemoryAllocator
(ie. via ServerApp), per area (for overlays, not yet implemented), and using
malloc()/free() for server-only bitmaps.
* ServerBitmap now deletes its buffers itself.
* Cleaned up BBitmap and BApplication a bit.
* The test environment currently doesn't build anymore, will fix it next.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16826 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-18 16:43:26 +03:00
|
|
|
fMemoryAllocator(this)
|
2003-01-24 17:36:15 +03:00
|
|
|
{
|
2005-05-08 10:06:55 +04:00
|
|
|
if (fSignature == "")
|
2005-06-23 21:40:35 +04:00
|
|
|
fSignature = "application/no-signature";
|
|
|
|
|
2005-06-23 22:48:10 +04:00
|
|
|
char name[B_OS_NAME_LENGTH];
|
* Implemented a new client allocation method: instead of having all bitmaps of
all teams in serveral server areas, and instead of having to eventually clone
them all several times in BBitmap, we now have one or more areas per team,
and BBitmap will only clone areas once if needed. As a side effect, this
method should be magnitudes faster than the previous version.
* This method is also much more secure: instead of putting the allocation
maintenance structures into those everyone-read-write areas, they are now
separated, so that faulty applications cannot crash the app_server this
way anymore. This should fix bug #172.
* Freeing memory is not yet implemented though! (although all memory will
be freed upon app exit)
* There are now 3 different bitmap allocation strategies: per ClientMemoryAllocator
(ie. via ServerApp), per area (for overlays, not yet implemented), and using
malloc()/free() for server-only bitmaps.
* ServerBitmap now deletes its buffers itself.
* Cleaned up BBitmap and BApplication a bit.
* The test environment currently doesn't build anymore, will fix it next.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16826 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-18 16:43:26 +03:00
|
|
|
snprintf(name, sizeof(name), "a<%ld:%s", clientTeam, SignatureLeaf());
|
2005-06-23 21:40:35 +04:00
|
|
|
|
2005-06-23 22:48:10 +04:00
|
|
|
fMessagePort = create_port(DEFAULT_MONITOR_PORT_SIZE, name);
|
2005-06-23 21:40:35 +04:00
|
|
|
if (fMessagePort < B_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fLink.SetSenderPort(fClientReplyPort);
|
|
|
|
fLink.SetReceiverPort(fMessagePort);
|
|
|
|
|
|
|
|
// we let the application own the port, so that we get aware when it's gone
|
|
|
|
if (set_port_owner(fMessagePort, clientTeam) < B_OK) {
|
|
|
|
delete_port(fMessagePort);
|
|
|
|
fMessagePort = -1;
|
|
|
|
return;
|
|
|
|
}
|
2005-05-26 19:06:31 +04:00
|
|
|
|
2005-11-20 19:24:23 +03:00
|
|
|
BMessenger::Private(fHandlerMessenger).SetTo(fClientTeam,
|
|
|
|
clientLooperPort, clientToken);
|
* the new input event dispatcher is now actually used, although it doesn't
distribute any messages to the clients yet.
* removed the working thread from RootLayer - for now, its event handlers are
still called using input filters in the new event dispatcher, though (to
get things started).
* ServerApp is now using a BMessenger to identify its client, and no longer
stores the port/token separately.
* the input_server handshake is a bit simpler now, as it can now just reply
to the app_server message, removed unused code from ServerProtocol.h
* calmed down the MultiLocker (it always printed thread statistics on startup,
because it's compiled in debug mode).
* removed the cursor thread stuff from AppServer.cpp
* the new event dispatcher now uses a cursor thread when supported (only in
native mode, not in the test environment), although it improves cursor
movement under Qemu, the effect is not as good as expected - this might
need some more investigations (might just be a thread priority problem).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15012 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-18 14:30:06 +03:00
|
|
|
|
2006-01-03 14:39:03 +03:00
|
|
|
fInitialWorkspace = desktop->CurrentWorkspace();
|
|
|
|
// TODO: this should probably be retrieved when the app is loaded!
|
|
|
|
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s:\n", Signature()));
|
2005-06-23 21:40:35 +04:00
|
|
|
STRACE(("\tBApp port: %ld\n", fClientReplyPort));
|
2005-05-08 10:06:55 +04:00
|
|
|
STRACE(("\tReceiver port: %ld\n", fMessagePort));
|
2003-01-24 17:36:15 +03:00
|
|
|
}
|
|
|
|
|
2005-05-08 10:06:55 +04:00
|
|
|
|
2005-12-02 18:42:28 +03:00
|
|
|
ServerApp::~ServerApp()
|
2003-01-24 17:36:15 +03:00
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("*ServerApp %s:~ServerApp()\n", Signature()));
|
2005-06-23 21:40:35 +04:00
|
|
|
|
|
|
|
if (!fQuitting)
|
|
|
|
CRITICAL("ServerApp: destructor called after Run()!\n");
|
|
|
|
|
2005-06-24 03:21:10 +04:00
|
|
|
// quit all server windows
|
|
|
|
|
2005-11-25 16:49:29 +03:00
|
|
|
fWindowListLock.Lock();
|
2005-06-24 03:21:10 +04:00
|
|
|
for (int32 i = fWindowList.CountItems(); i-- > 0;) {
|
2005-11-14 15:08:21 +03:00
|
|
|
ServerWindow* window = fWindowList.ItemAt(i);
|
2005-06-24 03:21:10 +04:00
|
|
|
window->Quit();
|
|
|
|
}
|
|
|
|
fWindowListLock.Unlock();
|
|
|
|
|
|
|
|
// wait for the windows to quit
|
|
|
|
|
2005-11-25 16:49:29 +03:00
|
|
|
snooze(20000);
|
|
|
|
|
|
|
|
fWindowListLock.Lock();
|
|
|
|
for (int32 i = fWindowList.CountItems(); i-- > 0;) {
|
2005-12-29 20:40:18 +03:00
|
|
|
ServerWindow* window = fWindowList.ItemAt(i);
|
|
|
|
|
|
|
|
// a window could have been remove in the mean time (if those 20 millisecs
|
|
|
|
// from above weren't enough)
|
|
|
|
if (window == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
sem_id deathSemaphore = window->DeathSemaphore();
|
2005-06-24 03:21:10 +04:00
|
|
|
fWindowListLock.Unlock();
|
|
|
|
|
2005-11-25 16:49:29 +03:00
|
|
|
// wait 3 seconds for our window to quit - that's quite a long
|
|
|
|
// time, but killing it might have desastrous effects
|
|
|
|
if (MessageLooper::WaitForQuit(deathSemaphore, 3000000) != B_OK) {
|
|
|
|
// This really shouldn't happen, as it shows we're buggy
|
2006-02-02 23:19:29 +03:00
|
|
|
#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST
|
2005-12-12 16:57:49 +03:00
|
|
|
syslog(LOG_ERR, "ServerApp %s: ServerWindow doesn't respond!\n",
|
2005-11-25 16:49:29 +03:00
|
|
|
Signature());
|
offscreen bitmaps work, tested on Haiku as well, supports all colorspaces that BBitmap::ImportBits() supports. It uses a fallback for non-B_RGB(A)32 bitmaps. Added support for B_SUB_PIXEL_PRECISION view flags, though it is a bit hacky, since I had to add it to LayerData, even though it is not a true part of stack data. Added Layer::SetFlags() to enforce code path and update fLayerData. Cleaned up DisplayDriverPainter and DisplayDriver API (changed some const BRect& rect to simply BRect rect in order to be able to reuse it in the code), moved Painter.h, the test environment only draws the changed part of the frame buffer again - this causes a lot less CPU overhead, Painter special cases stroke width of 1.0 to use square caps, which is similar to R5 implementation and removes a lot of problems with non-straight line drawing, ServerWindow uses the DisplayDriver from it's WinBorder instead of the one from the Desktop (needed for offscreen windows, which have their own DisplayDriverPainter), it also checks for GetRootLayer() == NULL, because offscreen layers are not attached to a RootLayer, there was a fix for scrolling which worked at least in the test environment, it is now defunced, because Adi moved _CopyBits to Layer... I need to reenable it later, LayerData has no more fEscapementDelta, also fixed fFontAliasing (which was thought to overriding the font flags, and now works as such again), Desktop initialises the menu_info and scroll_bar_info stuff, which makes ScrollBars work actually... hope I didn't forget something.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13448 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-07-05 20:17:16 +04:00
|
|
|
#else
|
2005-12-12 16:57:49 +03:00
|
|
|
debugger("ServerWindow doesn't respond!\n");
|
offscreen bitmaps work, tested on Haiku as well, supports all colorspaces that BBitmap::ImportBits() supports. It uses a fallback for non-B_RGB(A)32 bitmaps. Added support for B_SUB_PIXEL_PRECISION view flags, though it is a bit hacky, since I had to add it to LayerData, even though it is not a true part of stack data. Added Layer::SetFlags() to enforce code path and update fLayerData. Cleaned up DisplayDriverPainter and DisplayDriver API (changed some const BRect& rect to simply BRect rect in order to be able to reuse it in the code), moved Painter.h, the test environment only draws the changed part of the frame buffer again - this causes a lot less CPU overhead, Painter special cases stroke width of 1.0 to use square caps, which is similar to R5 implementation and removes a lot of problems with non-straight line drawing, ServerWindow uses the DisplayDriver from it's WinBorder instead of the one from the Desktop (needed for offscreen windows, which have their own DisplayDriverPainter), it also checks for GetRootLayer() == NULL, because offscreen layers are not attached to a RootLayer, there was a fix for scrolling which worked at least in the test environment, it is now defunced, because Adi moved _CopyBits to Layer... I need to reenable it later, LayerData has no more fEscapementDelta, also fixed fFontAliasing (which was thought to overriding the font flags, and now works as such again), Desktop initialises the menu_info and scroll_bar_info stuff, which makes ScrollBars work actually... hope I didn't forget something.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13448 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-07-05 20:17:16 +04:00
|
|
|
#endif
|
2005-11-25 16:49:29 +03:00
|
|
|
}
|
|
|
|
fWindowListLock.Lock();
|
2005-06-24 03:21:10 +04:00
|
|
|
}
|
|
|
|
|
2006-10-18 00:40:26 +04:00
|
|
|
for (int32 i = fBitmapList.CountItems(); i-- > 0;) {
|
2005-07-01 12:10:42 +04:00
|
|
|
gBitmapManager->DeleteBitmap(static_cast<ServerBitmap *>(fBitmapList.ItemAt(i)));
|
2005-06-08 08:01:59 +04:00
|
|
|
}
|
2003-01-24 17:36:15 +03:00
|
|
|
|
2006-10-18 00:40:26 +04:00
|
|
|
for (int32 i = fPictureList.CountItems(); i-- > 0;) {
|
2006-01-12 01:27:51 +03:00
|
|
|
delete (ServerPicture*)fPictureList.ItemAtFast(i);
|
2005-06-08 08:01:59 +04:00
|
|
|
}
|
2003-03-21 18:49:28 +03:00
|
|
|
|
2006-02-05 21:14:14 +03:00
|
|
|
fDesktop->GetCursorManager().DeleteCursors(fClientTeam);
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2005-06-24 08:01:16 +04:00
|
|
|
STRACE(("ServerApp %s::~ServerApp(): Exiting\n", Signature()));
|
2003-01-24 17:36:15 +03:00
|
|
|
}
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Checks if the application was initialized correctly
|
|
|
|
*/
|
|
|
|
status_t
|
|
|
|
ServerApp::InitCheck()
|
|
|
|
{
|
|
|
|
if (fMessagePort < B_OK)
|
|
|
|
return fMessagePort;
|
|
|
|
|
|
|
|
if (fClientReplyPort < B_OK)
|
|
|
|
return fClientReplyPort;
|
|
|
|
|
2005-06-23 22:48:10 +04:00
|
|
|
if (fWindowListLock.Sem() < B_OK)
|
|
|
|
return fWindowListLock.Sem();
|
2005-06-23 21:40:35 +04:00
|
|
|
|
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-24 17:36:15 +03:00
|
|
|
/*!
|
|
|
|
\brief Starts the ServerApp monitoring for messages
|
|
|
|
\return false if the application couldn't start, true if everything went OK.
|
|
|
|
*/
|
2005-05-08 10:06:55 +04:00
|
|
|
bool
|
2005-06-23 21:40:35 +04:00
|
|
|
ServerApp::Run()
|
2003-01-24 17:36:15 +03:00
|
|
|
{
|
2005-07-23 22:30:48 +04:00
|
|
|
if (!MessageLooper::Run())
|
2005-06-23 21:40:35 +04:00
|
|
|
return false;
|
|
|
|
|
2005-06-24 02:43:11 +04:00
|
|
|
// Let's tell the client how to talk with us
|
2005-12-08 15:41:19 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2006-04-26 00:12:06 +04:00
|
|
|
fLink.Attach<port_id>(fMessagePort);
|
|
|
|
fLink.Attach<area_id>(fDesktop->SharedReadOnlyArea());
|
2005-06-24 02:43:11 +04:00
|
|
|
fLink.Flush();
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
return true;
|
2003-01-24 17:36:15 +03:00
|
|
|
}
|
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief This quits the application and deletes it. You're not supposed
|
|
|
|
to call its destructor directly.
|
|
|
|
|
|
|
|
At the point you're calling this method, the application should already
|
|
|
|
be removed from the application list.
|
|
|
|
*/
|
|
|
|
void
|
2005-07-01 14:09:11 +04:00
|
|
|
ServerApp::Quit(sem_id shutdownSemaphore)
|
2005-06-23 21:40:35 +04:00
|
|
|
{
|
|
|
|
if (fThread < B_OK) {
|
|
|
|
delete this;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// execute application deletion in the message looper thread
|
|
|
|
|
|
|
|
fQuitting = true;
|
2005-06-24 02:43:11 +04:00
|
|
|
PostMessage(kMsgAppQuit);
|
2005-06-23 21:40:35 +04:00
|
|
|
|
2005-07-01 14:09:11 +04:00
|
|
|
send_data(fThread, 'QUIT', &shutdownSemaphore, sizeof(sem_id));
|
2005-06-23 21:40:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-20 01:18:37 +03:00
|
|
|
/*!
|
|
|
|
\brief Send a message to the ServerApp's BApplication
|
|
|
|
\param msg The message to send
|
2005-05-28 20:58:25 +04:00
|
|
|
*/
|
2005-05-08 10:06:55 +04:00
|
|
|
void
|
* the new input event dispatcher is now actually used, although it doesn't
distribute any messages to the clients yet.
* removed the working thread from RootLayer - for now, its event handlers are
still called using input filters in the new event dispatcher, though (to
get things started).
* ServerApp is now using a BMessenger to identify its client, and no longer
stores the port/token separately.
* the input_server handshake is a bit simpler now, as it can now just reply
to the app_server message, removed unused code from ServerProtocol.h
* calmed down the MultiLocker (it always printed thread statistics on startup,
because it's compiled in debug mode).
* removed the cursor thread stuff from AppServer.cpp
* the new event dispatcher now uses a cursor thread when supported (only in
native mode, not in the test environment), although it improves cursor
movement under Qemu, the effect is not as good as expected - this might
need some more investigations (might just be a thread priority problem).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15012 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-18 14:30:06 +03:00
|
|
|
ServerApp::SendMessageToClient(BMessage *msg) const
|
2004-01-20 01:18:37 +03:00
|
|
|
{
|
2005-11-20 19:24:23 +03:00
|
|
|
status_t status = fHandlerMessenger.SendMessage(msg, (BHandler*)NULL, 100000);
|
|
|
|
if (status != B_OK)
|
|
|
|
printf("app %s send to client failed: %s\n", Signature(), strerror(status));
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
2005-05-28 20:58:25 +04:00
|
|
|
|
2005-07-23 22:30:48 +04:00
|
|
|
|
2006-03-10 01:54:10 +03:00
|
|
|
bool
|
|
|
|
ServerApp::_HasWindowUnderMouse()
|
|
|
|
{
|
|
|
|
BAutolock locker(fWindowListLock);
|
|
|
|
|
|
|
|
for (int32 i = fWindowList.CountItems(); i-- > 0;) {
|
2006-06-20 03:42:22 +04:00
|
|
|
ServerWindow* serverWindow = fWindowList.ItemAt(i);
|
2006-03-10 01:54:10 +03:00
|
|
|
|
2006-06-20 03:42:22 +04:00
|
|
|
if (fDesktop->ViewUnderMouse(serverWindow->Window()) != B_NULL_TOKEN)
|
2006-03-10 01:54:10 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-17 23:28:31 +04:00
|
|
|
/*!
|
|
|
|
\brief Sets the ServerApp's active status
|
|
|
|
\param value The new status of the ServerApp.
|
|
|
|
|
|
|
|
This changes an internal flag and also sets the current cursor to the one specified by
|
|
|
|
the application
|
|
|
|
*/
|
2005-05-08 10:06:55 +04:00
|
|
|
void
|
|
|
|
ServerApp::Activate(bool value)
|
2003-09-17 23:28:31 +04:00
|
|
|
{
|
2006-01-12 01:27:51 +03:00
|
|
|
if (fIsActive == value)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// TODO: send some message to the client?!?
|
|
|
|
|
2005-05-08 10:06:55 +04:00
|
|
|
fIsActive = value;
|
2006-01-12 01:27:51 +03:00
|
|
|
|
2006-03-09 21:37:28 +03:00
|
|
|
if (fIsActive) {
|
2007-01-19 19:41:58 +03:00
|
|
|
// notify registrar about the active app
|
|
|
|
BRoster::Private roster;
|
|
|
|
roster.UpdateActiveApp(ClientTeam());
|
|
|
|
|
2006-03-10 01:54:10 +03:00
|
|
|
if (_HasWindowUnderMouse()) {
|
|
|
|
// Set the cursor to the application cursor, if any
|
|
|
|
fDesktop->SetCursor(CurrentCursor());
|
|
|
|
}
|
2006-03-09 21:37:28 +03:00
|
|
|
fDesktop->HWInterface()->SetCursorVisible(fCursorHideLevel == 0);
|
|
|
|
}
|
2003-09-17 23:28:31 +04:00
|
|
|
}
|
2005-05-28 18:00:15 +04:00
|
|
|
|
|
|
|
|
2005-05-08 10:06:55 +04:00
|
|
|
void
|
2006-03-09 21:37:28 +03:00
|
|
|
ServerApp::SetCurrentCursor(ServerCursor* cursor)
|
2003-09-17 23:28:31 +04:00
|
|
|
{
|
2006-03-09 21:37:28 +03:00
|
|
|
fViewCursor = cursor;
|
|
|
|
fDesktop->SetCursor(CurrentCursor());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ServerCursor*
|
|
|
|
ServerApp::CurrentCursor() const
|
|
|
|
{
|
|
|
|
if (fViewCursor != NULL)
|
|
|
|
return fViewCursor;
|
|
|
|
|
|
|
|
return fAppCursor;
|
2003-09-17 23:28:31 +04:00
|
|
|
}
|
|
|
|
|
2005-05-28 18:00:15 +04:00
|
|
|
|
2005-07-23 22:30:48 +04:00
|
|
|
void
|
|
|
|
ServerApp::_GetLooperName(char* name, size_t length)
|
2005-06-23 21:40:35 +04:00
|
|
|
{
|
* Implemented a new client allocation method: instead of having all bitmaps of
all teams in serveral server areas, and instead of having to eventually clone
them all several times in BBitmap, we now have one or more areas per team,
and BBitmap will only clone areas once if needed. As a side effect, this
method should be magnitudes faster than the previous version.
* This method is also much more secure: instead of putting the allocation
maintenance structures into those everyone-read-write areas, they are now
separated, so that faulty applications cannot crash the app_server this
way anymore. This should fix bug #172.
* Freeing memory is not yet implemented though! (although all memory will
be freed upon app exit)
* There are now 3 different bitmap allocation strategies: per ClientMemoryAllocator
(ie. via ServerApp), per area (for overlays, not yet implemented), and using
malloc()/free() for server-only bitmaps.
* ServerBitmap now deletes its buffers itself.
* Cleaned up BBitmap and BApplication a bit.
* The test environment currently doesn't build anymore, will fix it next.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16826 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-18 16:43:26 +03:00
|
|
|
snprintf(name, length, "a:%ld:%s", ClientTeam(), SignatureLeaf());
|
2005-06-23 21:40:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief The thread function ServerApps use to monitor messages
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ServerApp::_MessageLooper()
|
2003-01-24 17:36:15 +03:00
|
|
|
{
|
|
|
|
// Message-dispatching loop for the ServerApp
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
BPrivate::LinkReceiver &receiver = fLink.Receiver();
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
int32 code;
|
|
|
|
status_t err = B_OK;
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
while (!fQuitting) {
|
|
|
|
STRACE(("info: ServerApp::_MessageLooper() listening on port %ld.\n", fMessagePort));
|
|
|
|
err = receiver.GetNextMessage(code, B_INFINITE_TIMEOUT);
|
|
|
|
if (err < B_OK || code == B_QUIT_REQUESTED) {
|
|
|
|
STRACE(("ServerApp: application seems to be gone...\n"));
|
2005-05-26 19:06:31 +04:00
|
|
|
|
2005-07-26 01:08:34 +04:00
|
|
|
// Tell desktop to quit us
|
|
|
|
BPrivate::LinkSender link(fDesktop->MessagePort());
|
2005-06-08 08:01:59 +04:00
|
|
|
link.StartMessage(AS_DELETE_APP);
|
2005-06-23 21:40:35 +04:00
|
|
|
link.Attach<thread_id>(Thread());
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Flush();
|
2004-07-30 19:16:59 +04:00
|
|
|
break;
|
2005-05-07 02:38:04 +04:00
|
|
|
}
|
2003-10-04 23:10:11 +04:00
|
|
|
|
2005-05-26 19:06:31 +04:00
|
|
|
switch (code) {
|
2005-06-23 21:40:35 +04:00
|
|
|
case kMsgAppQuit:
|
|
|
|
// we receive this from our destructor on quit
|
|
|
|
fQuitting = true;
|
|
|
|
break;
|
|
|
|
|
2003-10-04 23:10:11 +04:00
|
|
|
case AS_QUIT_APP:
|
|
|
|
{
|
2004-01-20 01:18:37 +03:00
|
|
|
// This message is received only when the app_server is asked to shut down in
|
|
|
|
// test/debug mode. Of course, if we are testing while using AccelerantDriver, we do
|
|
|
|
// NOT want to shut down client applications. The server can be quit o in this fashion
|
|
|
|
// through the driver's interface, such as closing the ViewDriver's window.
|
2005-06-23 21:40:35 +04:00
|
|
|
|
|
|
|
STRACE(("ServerApp %s:Server shutdown notification received\n", Signature()));
|
2004-01-20 01:18:37 +03:00
|
|
|
|
2003-10-04 23:10:11 +04:00
|
|
|
// If we are using the real, accelerated version of the
|
2005-11-04 18:54:16 +03:00
|
|
|
// DrawingEngine, we do NOT want the user to be able shut down
|
2003-10-04 23:10:11 +04:00
|
|
|
// the server. The results would NOT be pretty
|
2005-04-18 22:48:19 +04:00
|
|
|
#if TEST_MODE
|
2005-03-29 19:39:08 +04:00
|
|
|
BMessage pleaseQuit(B_QUIT_REQUESTED);
|
2005-06-23 21:40:35 +04:00
|
|
|
SendMessageToClient(&pleaseQuit);
|
2005-03-29 19:39:08 +04:00
|
|
|
#endif
|
2003-10-04 23:10:11 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2003-10-04 23:10:11 +04:00
|
|
|
default:
|
2005-06-23 21:40:35 +04:00
|
|
|
STRACE(("ServerApp %s: Got a Message to dispatch\n", Signature()));
|
|
|
|
_DispatchMessage(code, receiver);
|
2003-10-04 23:10:11 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-06-08 08:01:59 +04:00
|
|
|
}
|
2004-01-20 01:18:37 +03:00
|
|
|
|
2005-06-23 21:40:35 +04:00
|
|
|
// Quit() will send us a message; we're handling the exiting procedure
|
|
|
|
thread_id sender;
|
2005-07-01 14:09:11 +04:00
|
|
|
sem_id shutdownSemaphore;
|
|
|
|
receive_data(&sender, &shutdownSemaphore, sizeof(sem_id));
|
2005-06-23 21:40:35 +04:00
|
|
|
|
|
|
|
delete this;
|
2005-07-01 14:09:11 +04:00
|
|
|
|
|
|
|
if (shutdownSemaphore >= B_OK)
|
|
|
|
release_sem(shutdownSemaphore);
|
2003-01-24 17:36:15 +03:00
|
|
|
}
|
|
|
|
|
2005-05-28 18:00:15 +04:00
|
|
|
|
2003-01-24 17:36:15 +03:00
|
|
|
/*!
|
|
|
|
\brief Handler function for BApplication API messages
|
|
|
|
\param code Identifier code for the message. Equivalent to BMessage::what
|
|
|
|
\param buffer Any attachments
|
* the new input event dispatcher is now actually used, although it doesn't
distribute any messages to the clients yet.
* removed the working thread from RootLayer - for now, its event handlers are
still called using input filters in the new event dispatcher, though (to
get things started).
* ServerApp is now using a BMessenger to identify its client, and no longer
stores the port/token separately.
* the input_server handshake is a bit simpler now, as it can now just reply
to the app_server message, removed unused code from ServerProtocol.h
* calmed down the MultiLocker (it always printed thread statistics on startup,
because it's compiled in debug mode).
* removed the cursor thread stuff from AppServer.cpp
* the new event dispatcher now uses a cursor thread when supported (only in
native mode, not in the test environment), although it improves cursor
movement under Qemu, the effect is not as good as expected - this might
need some more investigations (might just be a thread priority problem).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15012 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-18 14:30:06 +03:00
|
|
|
|
2003-01-24 17:36:15 +03:00
|
|
|
Note that the buffer's exact format is determined by the particular message.
|
|
|
|
All attachments are placed in the buffer via a PortLink, so it will be a
|
|
|
|
matter of casting and incrementing an index variable to access them.
|
|
|
|
*/
|
2005-05-08 10:06:55 +04:00
|
|
|
void
|
* the new input event dispatcher is now actually used, although it doesn't
distribute any messages to the clients yet.
* removed the working thread from RootLayer - for now, its event handlers are
still called using input filters in the new event dispatcher, though (to
get things started).
* ServerApp is now using a BMessenger to identify its client, and no longer
stores the port/token separately.
* the input_server handshake is a bit simpler now, as it can now just reply
to the app_server message, removed unused code from ServerProtocol.h
* calmed down the MultiLocker (it always printed thread statistics on startup,
because it's compiled in debug mode).
* removed the cursor thread stuff from AppServer.cpp
* the new event dispatcher now uses a cursor thread when supported (only in
native mode, not in the test environment), although it improves cursor
movement under Qemu, the effect is not as good as expected - this might
need some more investigations (might just be a thread priority problem).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15012 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-18 14:30:06 +03:00
|
|
|
ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
2003-01-24 17:36:15 +03:00
|
|
|
{
|
2005-06-08 08:01:59 +04:00
|
|
|
switch (code) {
|
2005-11-15 22:59:53 +03:00
|
|
|
case AS_REGISTER_INPUT_SERVER:
|
|
|
|
{
|
2005-11-20 19:24:23 +03:00
|
|
|
EventStream* stream = new (nothrow) InputServerStream(fHandlerMessenger);
|
* the new input event dispatcher is now actually used, although it doesn't
distribute any messages to the clients yet.
* removed the working thread from RootLayer - for now, its event handlers are
still called using input filters in the new event dispatcher, though (to
get things started).
* ServerApp is now using a BMessenger to identify its client, and no longer
stores the port/token separately.
* the input_server handshake is a bit simpler now, as it can now just reply
to the app_server message, removed unused code from ServerProtocol.h
* calmed down the MultiLocker (it always printed thread statistics on startup,
because it's compiled in debug mode).
* removed the cursor thread stuff from AppServer.cpp
* the new event dispatcher now uses a cursor thread when supported (only in
native mode, not in the test environment), although it improves cursor
movement under Qemu, the effect is not as good as expected - this might
need some more investigations (might just be a thread priority problem).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15012 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-18 14:30:06 +03:00
|
|
|
if (stream != NULL
|
|
|
|
&& (!stream->IsValid() || !gInputManager->AddStream(stream))) {
|
|
|
|
delete stream;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: this should be done using notifications (so that an abandoned
|
|
|
|
// stream will get noticed directly)
|
2005-11-18 15:26:20 +03:00
|
|
|
if (fDesktop->EventDispatcher().InitCheck() != B_OK)
|
* the new input event dispatcher is now actually used, although it doesn't
distribute any messages to the clients yet.
* removed the working thread from RootLayer - for now, its event handlers are
still called using input filters in the new event dispatcher, though (to
get things started).
* ServerApp is now using a BMessenger to identify its client, and no longer
stores the port/token separately.
* the input_server handshake is a bit simpler now, as it can now just reply
to the app_server message, removed unused code from ServerProtocol.h
* calmed down the MultiLocker (it always printed thread statistics on startup,
because it's compiled in debug mode).
* removed the cursor thread stuff from AppServer.cpp
* the new event dispatcher now uses a cursor thread when supported (only in
native mode, not in the test environment), although it improves cursor
movement under Qemu, the effect is not as good as expected - this might
need some more investigations (might just be a thread priority problem).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15012 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-18 14:30:06 +03:00
|
|
|
fDesktop->EventDispatcher().SetTo(gInputManager->GetStream());
|
2005-11-15 22:59:53 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-12-02 18:42:28 +03:00
|
|
|
|
2006-06-10 01:46:40 +04:00
|
|
|
case AS_APP_CRASHED:
|
|
|
|
// Allow the debugger to show its window: if needed, remove any
|
|
|
|
// kWindowScreenFeels from the windows of this application
|
|
|
|
if (fWindowListLock.Lock()) {
|
|
|
|
for (int32 i = fWindowList.CountItems(); i-- > 0;) {
|
|
|
|
ServerWindow* serverWindow = fWindowList.ItemAt(i);
|
2006-06-20 03:42:22 +04:00
|
|
|
|
2006-06-10 01:46:40 +04:00
|
|
|
WindowLayer* window = serverWindow->Window();
|
2006-06-20 03:42:22 +04:00
|
|
|
if (window == NULL || window->IsOffscreenWindow())
|
|
|
|
continue;
|
2006-06-10 01:46:40 +04:00
|
|
|
|
|
|
|
if (window->Feel() == kWindowScreenFeel)
|
|
|
|
fDesktop->SetWindowFeel(window, B_NORMAL_WINDOW_FEEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
fWindowListLock.Unlock();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-11-15 22:59:53 +03:00
|
|
|
case AS_CREATE_WINDOW:
|
|
|
|
case AS_CREATE_OFFSCREEN_WINDOW:
|
|
|
|
{
|
2005-12-02 18:42:28 +03:00
|
|
|
port_id clientReplyPort = -1;
|
|
|
|
status_t status = _CreateWindow(code, link, clientReplyPort);
|
2005-11-15 22:59:53 +03:00
|
|
|
|
|
|
|
// if sucessful, ServerWindow::Run() will already have replied
|
|
|
|
if (status < B_OK) {
|
|
|
|
// window creation failed, we need to notify the client
|
|
|
|
BPrivate::LinkSender reply(clientReplyPort);
|
|
|
|
reply.StartMessage(status);
|
|
|
|
reply.Flush();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-07-05 22:14:24 +04:00
|
|
|
case AS_GET_WINDOW_LIST:
|
2005-12-12 00:46:35 +03:00
|
|
|
{
|
2005-07-05 22:14:24 +04:00
|
|
|
team_id team;
|
2006-02-09 21:53:36 +03:00
|
|
|
if (link.Read<team_id>(&team) == B_OK)
|
|
|
|
fDesktop->WriteWindowList(team, fLink.Sender());
|
2005-07-05 22:14:24 +04:00
|
|
|
break;
|
2005-12-12 00:46:35 +03:00
|
|
|
}
|
2005-07-05 22:14:24 +04:00
|
|
|
|
|
|
|
case AS_GET_WINDOW_INFO:
|
2005-12-12 00:46:35 +03:00
|
|
|
{
|
2005-07-05 22:14:24 +04:00
|
|
|
int32 serverToken;
|
2006-02-09 21:53:36 +03:00
|
|
|
if (link.Read<int32>(&serverToken) == B_OK)
|
|
|
|
fDesktop->WriteWindowInfo(serverToken, fLink.Sender());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case AS_MINIMIZE_TEAM:
|
|
|
|
{
|
|
|
|
team_id team;
|
|
|
|
if (link.Read<team_id>(&team) == B_OK)
|
|
|
|
fDesktop->MinimizeApplication(team);
|
|
|
|
break;
|
|
|
|
}
|
2005-07-05 22:14:24 +04:00
|
|
|
|
2006-02-09 21:53:36 +03:00
|
|
|
case AS_BRING_TEAM_TO_FRONT:
|
|
|
|
{
|
|
|
|
team_id team;
|
|
|
|
if (link.Read<team_id>(&team) == B_OK)
|
|
|
|
fDesktop->BringApplicationToFront(team);
|
2005-07-05 22:14:24 +04:00
|
|
|
break;
|
2005-12-12 00:46:35 +03:00
|
|
|
}
|
|
|
|
|
2006-02-28 21:31:16 +03:00
|
|
|
case AS_WINDOW_ACTION:
|
|
|
|
{
|
|
|
|
int32 token;
|
|
|
|
int32 action;
|
|
|
|
|
|
|
|
link.Read<int32>(&token);
|
|
|
|
if (link.Read<int32>(&action) != B_OK)
|
|
|
|
break;
|
|
|
|
|
|
|
|
fDesktop->WindowAction(token, action);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-04-03 15:45:37 +04:00
|
|
|
// Decorator commands
|
|
|
|
|
2005-06-17 23:10:15 +04:00
|
|
|
case AS_SET_DECORATOR:
|
|
|
|
{
|
|
|
|
// Received from an application when the user wants to set the window
|
|
|
|
// decorator to a new one
|
2005-07-26 01:08:34 +04:00
|
|
|
|
2005-06-17 23:10:15 +04:00
|
|
|
// Attached Data:
|
|
|
|
// int32 the index of the decorator to use
|
2005-07-26 01:08:34 +04:00
|
|
|
|
2005-06-17 23:10:15 +04:00
|
|
|
int32 index;
|
|
|
|
link.Read<int32>(&index);
|
2005-07-26 01:08:34 +04:00
|
|
|
if (gDecorManager.SetDecorator(index))
|
|
|
|
fDesktop->BroadcastToAllApps(AS_UPDATE_DECORATOR);
|
2005-06-17 23:10:15 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_COUNT_DECORATORS:
|
|
|
|
{
|
2005-12-08 15:41:19 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-17 23:10:15 +04:00
|
|
|
fLink.Attach<int32>(gDecorManager.CountDecorators());
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_GET_DECORATOR:
|
|
|
|
{
|
2005-12-08 15:41:19 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-17 23:10:15 +04:00
|
|
|
fLink.Attach<int32>(gDecorManager.GetDecorator());
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_GET_DECORATOR_NAME:
|
|
|
|
{
|
|
|
|
int32 index;
|
|
|
|
link.Read<int32>(&index);
|
2005-07-26 01:08:34 +04:00
|
|
|
|
2005-06-17 23:10:15 +04:00
|
|
|
BString str(gDecorManager.GetDecoratorName(index));
|
2005-12-08 15:41:19 +03:00
|
|
|
if (str.CountChars() > 0) {
|
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-17 23:10:15 +04:00
|
|
|
fLink.AttachString(str.String());
|
2005-12-08 15:41:19 +03:00
|
|
|
} else
|
|
|
|
fLink.StartMessage(B_ERROR);
|
|
|
|
|
2005-06-17 23:10:15 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_R5_SET_DECORATOR:
|
|
|
|
{
|
|
|
|
// Sort of supports Tracker's nifty Easter Egg. It was easy to do and
|
|
|
|
// it's kind of neat, so why not?
|
2005-07-26 01:08:34 +04:00
|
|
|
|
2005-06-17 23:10:15 +04:00
|
|
|
// Attached Data:
|
|
|
|
// int32 value of the decorator to use
|
|
|
|
// 0: BeOS
|
|
|
|
// 1: Amiga
|
|
|
|
// 2: Windows
|
|
|
|
// 3: MacOS
|
2005-07-26 01:08:34 +04:00
|
|
|
|
2005-06-17 23:10:15 +04:00
|
|
|
int32 decindex = 0;
|
|
|
|
link.Read<int32>(&decindex);
|
2005-07-26 01:08:34 +04:00
|
|
|
|
|
|
|
if (gDecorManager.SetR5Decorator(decindex))
|
|
|
|
fDesktop->BroadcastToAllApps(AS_UPDATE_DECORATOR);
|
2005-06-17 23:10:15 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2003-03-12 17:29:59 +03:00
|
|
|
case AS_CREATE_BITMAP:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: Received BBitmap creation request\n", Signature()));
|
2003-03-12 17:29:59 +03:00
|
|
|
// Allocate a bitmap for an application
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2005-07-11 01:16:43 +04:00
|
|
|
// Attached Data:
|
2003-10-04 04:56:43 +04:00
|
|
|
// 1) BRect bounds
|
|
|
|
// 2) color_space space
|
|
|
|
// 3) int32 bitmap_flags
|
|
|
|
// 4) int32 bytes_per_row
|
|
|
|
// 5) int32 screen_id::id
|
2003-03-12 17:29:59 +03:00
|
|
|
|
|
|
|
// Reply Data:
|
|
|
|
// 1) int32 server token
|
|
|
|
// 2) area_id id of the area in which the bitmap data resides
|
|
|
|
// 3) int32 area pointer offset used to calculate fBasePtr
|
|
|
|
|
|
|
|
// First, let's attempt to allocate the bitmap
|
2005-06-08 08:01:59 +04:00
|
|
|
ServerBitmap *bitmap = NULL;
|
2006-04-22 20:41:12 +04:00
|
|
|
uint8 allocationFlags = kAllocator;
|
* Implemented a new client allocation method: instead of having all bitmaps of
all teams in serveral server areas, and instead of having to eventually clone
them all several times in BBitmap, we now have one or more areas per team,
and BBitmap will only clone areas once if needed. As a side effect, this
method should be magnitudes faster than the previous version.
* This method is also much more secure: instead of putting the allocation
maintenance structures into those everyone-read-write areas, they are now
separated, so that faulty applications cannot crash the app_server this
way anymore. This should fix bug #172.
* Freeing memory is not yet implemented though! (although all memory will
be freed upon app exit)
* There are now 3 different bitmap allocation strategies: per ClientMemoryAllocator
(ie. via ServerApp), per area (for overlays, not yet implemented), and using
malloc()/free() for server-only bitmaps.
* ServerBitmap now deletes its buffers itself.
* Cleaned up BBitmap and BApplication a bit.
* The test environment currently doesn't build anymore, will fix it next.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16826 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-18 16:43:26 +03:00
|
|
|
|
2005-06-08 08:01:59 +04:00
|
|
|
BRect frame;
|
|
|
|
color_space colorSpace;
|
|
|
|
int32 flags, bytesPerRow;
|
|
|
|
screen_id screenID;
|
|
|
|
|
|
|
|
link.Read<BRect>(&frame);
|
|
|
|
link.Read<color_space>(&colorSpace);
|
|
|
|
link.Read<int32>(&flags);
|
|
|
|
link.Read<int32>(&bytesPerRow);
|
|
|
|
if (link.Read<screen_id>(&screenID) == B_OK) {
|
2006-04-22 00:14:41 +04:00
|
|
|
// TODO: choose the right HWInterface with regards to the screenID
|
|
|
|
bitmap = gBitmapManager->CreateBitmap(&fMemoryAllocator,
|
|
|
|
*fDesktop->HWInterface(), frame, colorSpace, flags, bytesPerRow,
|
2006-04-22 20:41:12 +04:00
|
|
|
screenID, &allocationFlags);
|
2005-06-08 08:01:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
STRACE(("ServerApp %s: Create Bitmap (%.1fx%.1f)\n",
|
2006-04-22 20:41:12 +04:00
|
|
|
Signature(), frame.Width() + 1, frame.Height() + 1));
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2006-03-02 00:20:57 +03:00
|
|
|
if (bitmap != NULL && fBitmapList.AddItem(bitmap)) {
|
2007-06-27 15:29:20 +04:00
|
|
|
bitmap->SetOwner(this);
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Attach<int32>(bitmap->Token());
|
2006-04-22 20:41:12 +04:00
|
|
|
fLink.Attach<uint8>(allocationFlags);
|
* Implemented a new client allocation method: instead of having all bitmaps of
all teams in serveral server areas, and instead of having to eventually clone
them all several times in BBitmap, we now have one or more areas per team,
and BBitmap will only clone areas once if needed. As a side effect, this
method should be magnitudes faster than the previous version.
* This method is also much more secure: instead of putting the allocation
maintenance structures into those everyone-read-write areas, they are now
separated, so that faulty applications cannot crash the app_server this
way anymore. This should fix bug #172.
* Freeing memory is not yet implemented though! (although all memory will
be freed upon app exit)
* There are now 3 different bitmap allocation strategies: per ClientMemoryAllocator
(ie. via ServerApp), per area (for overlays, not yet implemented), and using
malloc()/free() for server-only bitmaps.
* ServerBitmap now deletes its buffers itself.
* Cleaned up BBitmap and BApplication a bit.
* The test environment currently doesn't build anymore, will fix it next.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16826 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-18 16:43:26 +03:00
|
|
|
|
2006-04-22 20:41:12 +04:00
|
|
|
fLink.Attach<area_id>(fMemoryAllocator.Area(bitmap->AllocationCookie()));
|
|
|
|
fLink.Attach<int32>(fMemoryAllocator.AreaOffset(bitmap->AllocationCookie()));
|
|
|
|
|
|
|
|
if (allocationFlags & kFramebuffer)
|
2006-04-22 00:14:41 +04:00
|
|
|
fLink.Attach<int32>(bitmap->BytesPerRow());
|
2007-06-27 15:29:20 +04:00
|
|
|
} else {
|
|
|
|
if (bitmap != NULL)
|
|
|
|
gBitmapManager->DeleteBitmap(bitmap);
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
fLink.StartMessage(B_NO_MEMORY);
|
2007-06-27 15:29:20 +04:00
|
|
|
}
|
2005-06-08 08:01:59 +04:00
|
|
|
|
|
|
|
fLink.Flush();
|
2003-03-12 17:29:59 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_DELETE_BITMAP:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: received BBitmap delete request\n", Signature()));
|
2003-03-12 17:29:59 +03:00
|
|
|
// Delete a bitmap's allocated memory
|
|
|
|
|
|
|
|
// Attached Data:
|
2003-10-04 04:56:43 +04:00
|
|
|
// 1) int32 token
|
2006-03-02 00:20:57 +03:00
|
|
|
int32 token;
|
|
|
|
link.Read<int32>(&token);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2006-03-02 00:20:57 +03:00
|
|
|
ServerBitmap *bitmap = FindBitmap(token);
|
|
|
|
if (bitmap && fBitmapList.RemoveItem(bitmap)) {
|
|
|
|
STRACE(("ServerApp %s: Deleting Bitmap %ld\n", Signature(), token));
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
gBitmapManager->DeleteBitmap(bitmap);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
2003-03-12 17:29:59 +03:00
|
|
|
break;
|
|
|
|
}
|
2006-03-02 00:20:57 +03:00
|
|
|
case AS_GET_BITMAP_OVERLAY_RESTRICTIONS:
|
|
|
|
{
|
|
|
|
overlay_restrictions overlayRestrictions;
|
|
|
|
status_t status = B_ERROR;
|
|
|
|
|
|
|
|
int32 token;
|
|
|
|
if (link.Read<int32>(&token) != B_OK)
|
|
|
|
break;
|
|
|
|
|
|
|
|
ServerBitmap *bitmap = FindBitmap(token);
|
|
|
|
if (bitmap != NULL) {
|
|
|
|
STRACE(("ServerApp %s: Get overlay restrictions for bitmap %ld\n",
|
|
|
|
Signature(), token));
|
|
|
|
|
|
|
|
// TODO: fill overlay restrictions
|
|
|
|
}
|
|
|
|
|
|
|
|
fLink.StartMessage(status);
|
|
|
|
if (status == B_OK)
|
|
|
|
fLink.Attach(&overlayRestrictions, sizeof(overlay_restrictions));
|
|
|
|
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2006-01-05 13:27:29 +03:00
|
|
|
|
2003-03-21 18:49:28 +03:00
|
|
|
case AS_CREATE_PICTURE:
|
|
|
|
{
|
2006-01-05 13:27:29 +03:00
|
|
|
// TODO: Maybe rename this to AS_UPLOAD_PICTURE ?
|
|
|
|
STRACE(("ServerApp %s: Create Picture\n", Signature()));
|
2007-03-01 17:47:10 +03:00
|
|
|
status_t status = B_ERROR;
|
2006-01-05 13:27:29 +03:00
|
|
|
ServerPicture *picture = CreatePicture();
|
2007-03-01 17:47:10 +03:00
|
|
|
if (picture != NULL)
|
|
|
|
status = picture->ImportData(link);
|
|
|
|
|
|
|
|
if (status == B_OK) {
|
2006-01-05 13:27:29 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<int32>(picture->Token());
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(B_ERROR);
|
|
|
|
|
|
|
|
fLink.Flush();
|
2003-03-21 18:49:28 +03:00
|
|
|
break;
|
|
|
|
}
|
2006-01-05 13:27:29 +03:00
|
|
|
|
2003-03-21 18:49:28 +03:00
|
|
|
case AS_DELETE_PICTURE:
|
|
|
|
{
|
2006-01-03 15:44:29 +03:00
|
|
|
STRACE(("ServerApp %s: Delete Picture\n", Signature()));
|
|
|
|
int32 token;
|
|
|
|
if (link.Read<int32>(&token) == B_OK)
|
|
|
|
DeletePicture(token);
|
|
|
|
|
2003-03-21 18:49:28 +03:00
|
|
|
break;
|
|
|
|
}
|
2006-01-03 19:41:00 +03:00
|
|
|
|
2003-03-21 18:49:28 +03:00
|
|
|
case AS_CLONE_PICTURE:
|
|
|
|
{
|
2006-01-03 19:41:00 +03:00
|
|
|
STRACE(("ServerApp %s: Clone Picture\n", Signature()));
|
|
|
|
int32 token;
|
|
|
|
ServerPicture *original = NULL;
|
|
|
|
if (link.Read<int32>(&token) == B_OK)
|
|
|
|
original = FindPicture(token);
|
|
|
|
|
|
|
|
ServerPicture *cloned = NULL;
|
|
|
|
if (original != NULL)
|
2006-01-04 12:49:47 +03:00
|
|
|
cloned = CreatePicture(original);
|
2006-01-03 19:41:00 +03:00
|
|
|
|
|
|
|
if (cloned != NULL) {
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<int32>(cloned->Token());
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(B_ERROR);
|
|
|
|
|
|
|
|
fLink.Flush();
|
2003-03-21 18:49:28 +03:00
|
|
|
break;
|
|
|
|
}
|
2006-01-05 13:27:29 +03:00
|
|
|
|
2003-03-21 18:49:28 +03:00
|
|
|
case AS_DOWNLOAD_PICTURE:
|
|
|
|
{
|
2006-01-05 13:27:29 +03:00
|
|
|
STRACE(("ServerApp %s: Download Picture\n", Signature()));
|
2006-01-03 15:44:29 +03:00
|
|
|
int32 token;
|
|
|
|
link.Read<int32>(&token);
|
2006-01-05 13:27:29 +03:00
|
|
|
ServerPicture *picture = FindPicture(token);
|
2006-01-03 15:44:29 +03:00
|
|
|
if (picture != NULL) {
|
2007-05-03 18:52:13 +04:00
|
|
|
picture->ExportData(fLink);
|
|
|
|
// ExportData() calls StartMessage() already
|
2006-01-03 15:44:29 +03:00
|
|
|
} else
|
2006-01-05 13:27:29 +03:00
|
|
|
fLink.StartMessage(B_ERROR);
|
2004-08-29 19:01:44 +04:00
|
|
|
|
2006-01-05 13:27:29 +03:00
|
|
|
fLink.Flush();
|
2005-06-17 23:10:15 +04:00
|
|
|
|
2003-03-21 18:49:28 +03:00
|
|
|
break;
|
|
|
|
}
|
2006-01-05 13:27:29 +03:00
|
|
|
|
2005-12-01 01:48:13 +03:00
|
|
|
case AS_COUNT_WORKSPACES:
|
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
if (fDesktop->LockSingleWindow()) {
|
|
|
|
DesktopSettings settings(fDesktop);
|
|
|
|
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<int32>(settings.WorkspacesCount());
|
|
|
|
fDesktop->UnlockSingleWindow();
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(B_ERROR);
|
2005-12-01 01:48:13 +03:00
|
|
|
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case AS_SET_WORKSPACE_COUNT:
|
2003-01-24 17:36:15 +03:00
|
|
|
{
|
2005-12-01 01:48:13 +03:00
|
|
|
int32 newCount;
|
2006-08-26 19:13:08 +04:00
|
|
|
if (link.Read<int32>(&newCount) == B_OK)
|
|
|
|
fDesktop->SetWorkspacesCount(newCount);
|
2005-12-01 01:48:13 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case AS_CURRENT_WORKSPACE:
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: get current workspace\n", Signature()));
|
2005-06-14 02:11:29 +04:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<int32>(fDesktop->CurrentWorkspace());
|
2005-06-14 02:11:29 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
2005-11-29 02:36:59 +03:00
|
|
|
|
2005-06-14 02:11:29 +04:00
|
|
|
case AS_ACTIVATE_WORKSPACE:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: activate workspace\n", Signature()));
|
2006-08-26 19:13:08 +04:00
|
|
|
|
2005-06-14 02:11:29 +04:00
|
|
|
// TODO: See above
|
|
|
|
int32 index;
|
|
|
|
link.Read<int32>(&index);
|
2005-11-29 02:36:59 +03:00
|
|
|
|
|
|
|
fDesktop->SetWorkspace(index);
|
2003-01-24 18:19:27 +03:00
|
|
|
break;
|
2003-01-24 17:36:15 +03:00
|
|
|
}
|
2005-11-29 02:36:59 +03:00
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
case AS_SHOW_CURSOR:
|
2003-01-24 17:36:15 +03:00
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: Show Cursor\n", Signature()));
|
2006-01-12 14:59:24 +03:00
|
|
|
fCursorHideLevel--;
|
|
|
|
if (fCursorHideLevel < 0)
|
|
|
|
fCursorHideLevel = 0;
|
|
|
|
fDesktop->HWInterface()->SetCursorVisible(fCursorHideLevel == 0);
|
2003-01-24 17:36:15 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
case AS_HIDE_CURSOR:
|
2003-01-24 17:36:15 +03:00
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: Hide Cursor\n", Signature()));
|
2006-01-12 14:59:24 +03:00
|
|
|
fCursorHideLevel++;
|
|
|
|
fDesktop->HWInterface()->SetCursorVisible(fCursorHideLevel == 0);
|
2003-01-24 17:36:15 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
case AS_OBSCURE_CURSOR:
|
2003-01-24 17:36:15 +03:00
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: Obscure Cursor\n", Signature()));
|
2006-01-12 14:46:49 +03:00
|
|
|
fDesktop->HWInterface()->ObscureCursor();
|
2003-01-24 17:36:15 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
case AS_QUERY_CURSOR_HIDDEN:
|
2003-02-24 00:40:44 +03:00
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: Received IsCursorHidden request\n", Signature()));
|
2006-01-12 14:59:24 +03:00
|
|
|
fLink.StartMessage(fCursorHideLevel > 0 ? B_OK : B_ERROR);
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
2003-02-24 00:40:44 +03:00
|
|
|
break;
|
|
|
|
}
|
2006-02-05 21:14:14 +03:00
|
|
|
case AS_SET_CURSOR:
|
2003-01-24 17:36:15 +03:00
|
|
|
{
|
2006-02-05 21:14:14 +03:00
|
|
|
STRACE(("ServerApp %s: SetCursor\n", Signature()));
|
2006-03-09 21:37:28 +03:00
|
|
|
|
2003-09-17 23:28:31 +04:00
|
|
|
// Attached data:
|
2003-10-03 04:41:40 +04:00
|
|
|
// 1) bool flag to send a reply
|
|
|
|
// 2) int32 token ID of the cursor to set
|
|
|
|
// 3) port_id port to receive a reply. Only exists if the sync flag is true.
|
|
|
|
bool sync;
|
2006-03-09 19:00:36 +03:00
|
|
|
int32 token;
|
2006-02-05 21:14:14 +03:00
|
|
|
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<bool>(&sync);
|
2006-03-09 19:00:36 +03:00
|
|
|
if (link.Read<int32>(&token) != B_OK)
|
|
|
|
break;
|
2005-08-21 14:28:40 +04:00
|
|
|
|
2006-04-01 20:56:10 +04:00
|
|
|
if (!fDesktop->GetCursorManager().Lock())
|
|
|
|
break;
|
|
|
|
|
2006-03-09 18:51:52 +03:00
|
|
|
ServerCursor* oldCursor = fAppCursor;
|
2006-02-05 21:14:14 +03:00
|
|
|
fAppCursor = fDesktop->GetCursorManager().FindCursor(token);
|
2006-03-09 21:37:28 +03:00
|
|
|
if (fAppCursor != NULL)
|
2006-03-09 18:51:52 +03:00
|
|
|
fAppCursor->Acquire();
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2006-03-10 01:54:10 +03:00
|
|
|
if (_HasWindowUnderMouse())
|
2006-03-09 21:37:28 +03:00
|
|
|
fDesktop->SetCursor(CurrentCursor());
|
2006-03-09 19:00:36 +03:00
|
|
|
|
2006-03-09 18:51:52 +03:00
|
|
|
if (oldCursor != NULL)
|
|
|
|
oldCursor->Release();
|
|
|
|
|
2006-04-01 20:56:10 +04:00
|
|
|
fDesktop->GetCursorManager().Unlock();
|
|
|
|
|
2005-06-08 08:01:59 +04:00
|
|
|
if (sync) {
|
2006-02-05 21:14:14 +03:00
|
|
|
// The application is expecting a reply
|
2005-12-08 15:41:19 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
2003-10-03 04:41:40 +04:00
|
|
|
}
|
2003-09-17 23:28:31 +04:00
|
|
|
break;
|
|
|
|
}
|
2006-02-05 21:14:14 +03:00
|
|
|
case AS_CREATE_CURSOR:
|
2003-09-17 23:28:31 +04:00
|
|
|
{
|
2006-02-05 21:14:14 +03:00
|
|
|
STRACE(("ServerApp %s: Create Cursor\n", Signature()));
|
2003-02-24 18:47:06 +03:00
|
|
|
// Attached data:
|
2004-01-20 01:18:37 +03:00
|
|
|
// 1) 68 bytes of fAppCursor data
|
2003-10-04 04:56:43 +04:00
|
|
|
// 2) port_id reply port
|
2006-02-05 21:14:14 +03:00
|
|
|
|
|
|
|
status_t status = B_ERROR;
|
2006-02-26 21:15:31 +03:00
|
|
|
uint8 cursorData[68];
|
2006-02-05 21:14:14 +03:00
|
|
|
ServerCursor* cursor = NULL;
|
|
|
|
|
2006-02-26 21:15:31 +03:00
|
|
|
// if (link.Read(cursorData, sizeof(cursorData)) >= B_OK) {
|
|
|
|
// cursor = new (nothrow) ServerCursor(cursorData);
|
|
|
|
// if (cursor == NULL)
|
|
|
|
// status = B_NO_MEMORY;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (cursor != NULL) {
|
|
|
|
// cursor->SetOwningTeam(fClientTeam);
|
|
|
|
// fDesktop->GetCursorManager().AddCursor(cursor);
|
|
|
|
//
|
|
|
|
// // Synchronous message - BApplication is waiting on the cursor's ID
|
|
|
|
// fLink.StartMessage(B_OK);
|
|
|
|
// fLink.Attach<int32>(cursor->Token());
|
|
|
|
// } else
|
|
|
|
// fLink.StartMessage(status);
|
|
|
|
|
2006-02-05 21:14:14 +03:00
|
|
|
if (link.Read(cursorData, sizeof(cursorData)) >= B_OK) {
|
2006-02-26 21:15:31 +03:00
|
|
|
cursor = fDesktop->GetCursorManager().CreateCursor(fClientTeam,
|
|
|
|
cursorData);
|
2006-02-05 21:14:14 +03:00
|
|
|
if (cursor == NULL)
|
|
|
|
status = B_NO_MEMORY;
|
|
|
|
}
|
2003-02-24 18:47:06 +03:00
|
|
|
|
2006-02-05 21:14:14 +03:00
|
|
|
if (cursor != NULL) {
|
|
|
|
// Synchronous message - BApplication is waiting on the cursor's ID
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<int32>(cursor->Token());
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(status);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
|
|
|
fLink.Flush();
|
2003-01-24 17:36:15 +03:00
|
|
|
break;
|
|
|
|
}
|
2006-02-05 21:14:14 +03:00
|
|
|
case AS_DELETE_CURSOR:
|
2003-09-17 23:28:31 +04:00
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: Delete BCursor\n", Signature()));
|
2003-09-17 23:28:31 +04:00
|
|
|
// Attached data:
|
|
|
|
// 1) int32 token ID of the cursor to delete
|
2006-02-26 21:15:31 +03:00
|
|
|
int32 token;
|
|
|
|
bool pendingViewCursor;
|
2006-02-05 21:14:14 +03:00
|
|
|
link.Read<int32>(&token);
|
2006-02-26 21:15:31 +03:00
|
|
|
if (link.Read<bool>(&pendingViewCursor) != B_OK)
|
|
|
|
break;
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2006-04-01 20:56:10 +04:00
|
|
|
if (!fDesktop->GetCursorManager().Lock())
|
|
|
|
break;
|
|
|
|
|
2006-02-26 21:15:31 +03:00
|
|
|
ServerCursor* cursor = fDesktop->GetCursorManager().FindCursor(token);
|
|
|
|
if (cursor) {
|
|
|
|
if (pendingViewCursor)
|
|
|
|
cursor->SetPendingViewCursor(true);
|
|
|
|
|
|
|
|
cursor->Release();
|
|
|
|
}
|
2006-04-01 20:56:10 +04:00
|
|
|
fDesktop->GetCursorManager().Unlock();
|
|
|
|
|
2003-09-17 23:28:31 +04:00
|
|
|
break;
|
|
|
|
}
|
2006-01-12 01:27:51 +03:00
|
|
|
|
2003-07-10 21:48:04 +04:00
|
|
|
case AS_GET_SCROLLBAR_INFO:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: Get ScrollBar info\n", Signature()));
|
2006-08-26 19:13:08 +04:00
|
|
|
|
|
|
|
if (fDesktop->LockSingleWindow()) {
|
|
|
|
scroll_bar_info info;
|
|
|
|
DesktopSettings settings(fDesktop);
|
|
|
|
settings.GetScrollBarInfo(info);
|
2003-10-03 04:41:40 +04:00
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<scroll_bar_info>(info);
|
|
|
|
fDesktop->UnlockSingleWindow();
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(B_ERROR);
|
|
|
|
|
|
|
|
fLink.Flush();
|
2003-07-10 21:48:04 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_SET_SCROLLBAR_INFO:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: Set ScrollBar info\n", Signature()));
|
2003-07-10 21:48:04 +04:00
|
|
|
// Attached Data:
|
|
|
|
// 1) scroll_bar_info scroll bar info structure
|
2005-06-08 08:01:59 +04:00
|
|
|
scroll_bar_info info;
|
2005-07-17 20:25:48 +04:00
|
|
|
if (link.Read<scroll_bar_info>(&info) == B_OK) {
|
2006-08-26 19:13:08 +04:00
|
|
|
LockedDesktopSettings settings(fDesktop);
|
2005-07-17 20:25:48 +04:00
|
|
|
settings.SetScrollBarInfo(info);
|
|
|
|
}
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-07-11 01:16:43 +04:00
|
|
|
fLink.Flush();
|
2003-07-10 21:48:04 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-07-17 20:25:48 +04:00
|
|
|
|
|
|
|
case AS_GET_MENU_INFO:
|
2003-07-10 21:48:04 +04:00
|
|
|
{
|
2005-07-17 20:25:48 +04:00
|
|
|
STRACE(("ServerApp %s: Get menu info\n", Signature()));
|
2006-08-26 19:13:08 +04:00
|
|
|
if (fDesktop->LockSingleWindow()) {
|
|
|
|
menu_info info;
|
|
|
|
DesktopSettings settings(fDesktop);
|
|
|
|
settings.GetMenuInfo(info);
|
|
|
|
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<menu_info>(info);
|
|
|
|
|
|
|
|
fDesktop->UnlockSingleWindow();
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(B_ERROR);
|
2003-10-03 04:41:40 +04:00
|
|
|
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
2003-07-10 21:48:04 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-07-17 20:25:48 +04:00
|
|
|
case AS_SET_MENU_INFO:
|
2003-07-10 21:48:04 +04:00
|
|
|
{
|
2005-07-17 20:25:48 +04:00
|
|
|
STRACE(("ServerApp %s: Set menu info\n", Signature()));
|
|
|
|
menu_info info;
|
|
|
|
if (link.Read<menu_info>(&info) == B_OK) {
|
2006-08-26 19:13:08 +04:00
|
|
|
LockedDesktopSettings settings(fDesktop);
|
2005-07-17 20:25:48 +04:00
|
|
|
settings.SetMenuInfo(info);
|
|
|
|
// TODO: SetMenuInfo() should do some validity check, so
|
|
|
|
// that the answer we're giving can actually be useful
|
|
|
|
}
|
|
|
|
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Flush();
|
2003-07-10 21:48:04 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-07-17 20:25:48 +04:00
|
|
|
|
2003-07-10 21:48:04 +04:00
|
|
|
case AS_SET_MOUSE_MODE:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: Set Focus Follows Mouse mode\n", Signature()));
|
2003-07-10 21:48:04 +04:00
|
|
|
// Attached Data:
|
|
|
|
// 1) enum mode_mouse FFM mouse mode
|
2005-07-17 20:25:48 +04:00
|
|
|
mode_mouse mouseMode;
|
|
|
|
if (link.Read<mode_mouse>(&mouseMode) == B_OK) {
|
2006-08-26 19:13:08 +04:00
|
|
|
LockedDesktopSettings settings(fDesktop);
|
2005-07-17 20:25:48 +04:00
|
|
|
settings.SetMouseMode(mouseMode);
|
|
|
|
}
|
2003-07-10 21:48:04 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_GET_MOUSE_MODE:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: Get Focus Follows Mouse mode\n", Signature()));
|
2007-02-21 10:57:21 +03:00
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
if (fDesktop->LockSingleWindow()) {
|
|
|
|
DesktopSettings settings(fDesktop);
|
|
|
|
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<mode_mouse>(settings.MouseMode());
|
|
|
|
|
|
|
|
fDesktop->UnlockSingleWindow();
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(B_ERROR);
|
2004-01-17 21:37:57 +03:00
|
|
|
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
2003-07-10 21:48:04 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-07-17 20:25:48 +04:00
|
|
|
|
2007-02-21 10:57:21 +03:00
|
|
|
case AS_GET_SHOW_ALL_DRAGGERS:
|
|
|
|
{
|
|
|
|
STRACE(("ServerApp %s: Get Show All Draggers\n", Signature()));
|
|
|
|
|
|
|
|
if (fDesktop->LockSingleWindow()) {
|
|
|
|
DesktopSettings settings(fDesktop);
|
|
|
|
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<bool>(settings.ShowAllDraggers());
|
|
|
|
|
|
|
|
fDesktop->UnlockSingleWindow();
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(B_ERROR);
|
|
|
|
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case AS_SET_SHOW_ALL_DRAGGERS:
|
|
|
|
{
|
|
|
|
STRACE(("ServerApp %s: Set Show All Draggers\n", Signature()));
|
|
|
|
|
|
|
|
bool changed = false;
|
|
|
|
bool show;
|
|
|
|
if (link.Read<bool>(&show) == B_OK) {
|
|
|
|
LockedDesktopSettings settings(fDesktop);
|
|
|
|
if (show != settings.ShowAllDraggers()) {
|
|
|
|
settings.SetShowAllDraggers(show);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed)
|
|
|
|
fDesktop->BroadcastToAllApps(kMsgUpdateShowAllDraggers);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kMsgUpdateShowAllDraggers:
|
|
|
|
{
|
|
|
|
bool show = false;
|
|
|
|
if (fDesktop->LockSingleWindow()) {
|
|
|
|
DesktopSettings settings(fDesktop);
|
|
|
|
show = settings.ShowAllDraggers();
|
|
|
|
fDesktop->UnlockSingleWindow();
|
|
|
|
}
|
|
|
|
BMessage update(_SHOW_DRAG_HANDLES_);
|
|
|
|
update.AddBool("show", show);
|
|
|
|
|
|
|
|
SendMessageToClient(&update);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
/* font messages */
|
|
|
|
|
2005-11-09 22:14:13 +03:00
|
|
|
case AS_SET_SYSTEM_FONT:
|
|
|
|
{
|
|
|
|
// gets:
|
|
|
|
// 1) string - font type ("plain", ...)
|
|
|
|
// 2) string - family
|
|
|
|
// 3) string - style
|
|
|
|
// 4) float - size
|
2006-10-12 16:34:19 +04:00
|
|
|
|
2005-11-09 22:14:13 +03:00
|
|
|
char type[B_OS_NAME_LENGTH];
|
|
|
|
font_family familyName;
|
|
|
|
font_style styleName;
|
|
|
|
float size;
|
|
|
|
|
|
|
|
if (link.ReadString(type, sizeof(type)) == B_OK
|
|
|
|
&& link.ReadString(familyName, sizeof(familyName)) == B_OK
|
|
|
|
&& link.ReadString(styleName, sizeof(styleName)) == B_OK
|
|
|
|
&& link.Read<float>(&size) == B_OK) {
|
2006-10-12 16:34:19 +04:00
|
|
|
gFontManager->Lock();
|
2005-11-09 22:14:13 +03:00
|
|
|
|
|
|
|
FontStyle* style = gFontManager->GetStyle(familyName, styleName);
|
|
|
|
if (style != NULL) {
|
|
|
|
ServerFont font(*style, size);
|
2006-10-12 16:34:19 +04:00
|
|
|
gFontManager->Unlock();
|
|
|
|
// We must not have locked the font manager when
|
|
|
|
// locking the desktop (through LockedDesktopSettings
|
|
|
|
// below)
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
LockedDesktopSettings settings(fDesktop);
|
2005-11-09 22:14:13 +03:00
|
|
|
|
|
|
|
if (!strcmp(type, "plain"))
|
|
|
|
settings.SetDefaultPlainFont(font);
|
|
|
|
else if (!strcmp(type, "bold"))
|
|
|
|
settings.SetDefaultBoldFont(font);
|
|
|
|
else if (!strcmp(type, "fixed"))
|
|
|
|
settings.SetDefaultFixedFont(font);
|
2006-10-12 16:34:19 +04:00
|
|
|
} else
|
|
|
|
gFontManager->Unlock();
|
2005-11-09 22:14:13 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-11-09 21:34:48 +03:00
|
|
|
case AS_GET_SYSTEM_DEFAULT_FONT:
|
|
|
|
{
|
|
|
|
// input:
|
|
|
|
// 1) string - font type ("plain", ...)
|
|
|
|
|
2005-11-09 22:22:21 +03:00
|
|
|
ServerFont font;
|
2005-11-09 21:34:48 +03:00
|
|
|
|
|
|
|
char type[B_OS_NAME_LENGTH];
|
|
|
|
status_t status = link.ReadString(type, sizeof(type));
|
|
|
|
if (status == B_OK) {
|
|
|
|
if (!strcmp(type, "plain")) {
|
2005-11-09 22:22:21 +03:00
|
|
|
font = *gFontManager->DefaultPlainFont();
|
2005-11-09 21:34:48 +03:00
|
|
|
} else if (!strcmp(type, "bold")) {
|
2005-11-09 22:22:21 +03:00
|
|
|
font = *gFontManager->DefaultBoldFont();
|
2005-11-09 21:34:48 +03:00
|
|
|
} else if (!strcmp(type, "fixed")) {
|
2005-11-09 22:22:21 +03:00
|
|
|
font = *gFontManager->DefaultFixedFont();
|
2005-11-09 21:34:48 +03:00
|
|
|
} else
|
|
|
|
status = B_BAD_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status == B_OK) {
|
|
|
|
// returns:
|
|
|
|
// 1) string - family
|
|
|
|
// 2) string - style
|
|
|
|
// 3) float - size
|
|
|
|
|
|
|
|
fLink.StartMessage(B_OK);
|
2005-11-09 23:10:40 +03:00
|
|
|
fLink.AttachString(font.Family());
|
|
|
|
fLink.AttachString(font.Style());
|
2005-11-09 22:22:21 +03:00
|
|
|
fLink.Attach<float>(font.Size());
|
2005-11-09 21:34:48 +03:00
|
|
|
} else
|
|
|
|
fLink.StartMessage(status);
|
|
|
|
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_GET_SYSTEM_FONTS:
|
|
|
|
{
|
|
|
|
FTRACE(("ServerApp %s: AS_GET_SYSTEM_FONTS\n", Signature()));
|
|
|
|
// Returns:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
|
|
|
// 3) float - size in points
|
|
|
|
// 4) uint16 - face flags
|
|
|
|
// 5) uint32 - font flags
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
if (!fDesktop->LockSingleWindow()) {
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-11-09 21:34:48 +03:00
|
|
|
DesktopSettings settings(fDesktop);
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
|
|
|
|
for (int32 i = 0; i < 3; i++) {
|
|
|
|
ServerFont font;
|
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
settings.GetDefaultPlainFont(font);
|
|
|
|
fLink.AttachString("plain");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
settings.GetDefaultBoldFont(font);
|
|
|
|
fLink.AttachString("bold");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
settings.GetDefaultFixedFont(font);
|
|
|
|
fLink.AttachString("fixed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fLink.Attach<uint16>(font.FamilyID());
|
|
|
|
fLink.Attach<uint16>(font.StyleID());
|
|
|
|
fLink.Attach<float>(font.Size());
|
|
|
|
fLink.Attach<uint16>(font.Face());
|
|
|
|
fLink.Attach<uint32>(font.Flags());
|
|
|
|
}
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
fDesktop->UnlockSingleWindow();
|
2005-11-09 21:34:48 +03:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-07 19:19:40 +03:00
|
|
|
case AS_GET_FONT_LIST_REVISION:
|
2005-01-17 05:05:50 +03:00
|
|
|
{
|
2005-11-07 19:19:40 +03:00
|
|
|
STRACE(("ServerApp %s: AS_GET_FONT_LIST_REVISION\n", Signature()));
|
2005-11-03 20:03:36 +03:00
|
|
|
|
2005-11-07 19:19:40 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<int32>(gFontManager->CheckRevision(fDesktop->UserID()));
|
|
|
|
fLink.Flush();
|
2005-01-17 05:05:50 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-11-07 19:19:40 +03:00
|
|
|
case AS_GET_FAMILY_AND_STYLES:
|
2005-01-17 05:05:50 +03:00
|
|
|
{
|
2005-11-07 19:19:40 +03:00
|
|
|
FTRACE(("ServerApp %s: AS_GET_FAMILY_AND_STYLES\n", Signature()));
|
2005-01-17 05:05:50 +03:00
|
|
|
// Attached Data:
|
2005-11-01 19:28:01 +03:00
|
|
|
// 1) int32 the index of the font family to get
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
// Returns:
|
2005-11-07 19:19:40 +03:00
|
|
|
// 1) string - name of family
|
2005-01-17 05:05:50 +03:00
|
|
|
// 2) uint32 - flags of font family (B_IS_FIXED || B_HAS_TUNED_FONT)
|
2005-11-07 19:19:40 +03:00
|
|
|
// 3) count of styles in that family
|
|
|
|
// For each style:
|
|
|
|
// 1) string - name of style
|
|
|
|
// 2) uint16 - face of style
|
|
|
|
// 3) uint32 - flags of style
|
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
int32 index;
|
|
|
|
link.Read<int32>(&index);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
gFontManager->Lock();
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2005-11-07 19:19:40 +03:00
|
|
|
FontFamily* family = gFontManager->FamilyAt(index);
|
2005-11-01 19:28:01 +03:00
|
|
|
if (family) {
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.AttachString(family->Name());
|
|
|
|
fLink.Attach<uint32>(family->Flags());
|
2005-11-07 19:19:40 +03:00
|
|
|
|
|
|
|
int32 count = family->CountStyles();
|
|
|
|
fLink.Attach<int32>(count);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-07 19:19:40 +03:00
|
|
|
for (int32 i = 0; i < count; i++) {
|
|
|
|
FontStyle* style = family->StyleAt(i);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-07 19:19:40 +03:00
|
|
|
fLink.AttachString(style->Name());
|
|
|
|
fLink.Attach<uint16>(style->Face());
|
|
|
|
fLink.Attach<uint32>(style->Flags());
|
|
|
|
}
|
2005-06-08 08:01:59 +04:00
|
|
|
} else
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(B_BAD_VALUE);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
gFontManager->Unlock();
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.Flush();
|
2005-01-17 05:05:50 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_GET_FAMILY_AND_STYLE:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
FTRACE(("ServerApp %s: AS_GET_FAMILY_AND_STYLE\n", Signature()));
|
2005-01-17 05:05:50 +03:00
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
// Returns:
|
|
|
|
// 1) font_family The name of the font family
|
|
|
|
// 2) font_style - name of the style
|
2005-11-01 02:21:36 +03:00
|
|
|
uint16 familyID, styleID;
|
|
|
|
link.Read<uint16>(&familyID);
|
|
|
|
link.Read<uint16>(&styleID);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
gFontManager->Lock();
|
2005-11-02 12:50:51 +03:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
FontStyle *fontStyle = gFontManager->GetStyle(familyID, styleID);
|
2005-11-01 02:21:36 +03:00
|
|
|
if (fontStyle != NULL) {
|
|
|
|
fLink.StartMessage(B_OK);
|
2005-11-02 12:50:51 +03:00
|
|
|
fLink.AttachString(fontStyle->Family()->Name());
|
|
|
|
fLink.AttachString(fontStyle->Name());
|
2005-06-08 08:01:59 +04:00
|
|
|
} else
|
2005-11-01 02:21:36 +03:00
|
|
|
fLink.StartMessage(B_BAD_VALUE);
|
|
|
|
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
2005-11-02 16:25:39 +03:00
|
|
|
gFontManager->Unlock();
|
2005-01-17 05:05:50 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-11-09 21:34:48 +03:00
|
|
|
case AS_GET_FAMILY_AND_STYLE_IDS:
|
|
|
|
{
|
|
|
|
FTRACE(("ServerApp %s: AS_GET_FAMILY_AND_STYLE_IDS\n", Signature()));
|
|
|
|
// Attached Data:
|
|
|
|
// 1) font_family - name of font family to use
|
|
|
|
// 2) font_style - name of style in family
|
|
|
|
// 3) family ID - only used if 1) is empty
|
|
|
|
// 4) style ID - only used if 2) is empty
|
|
|
|
// 5) face - the font's current face
|
|
|
|
|
|
|
|
// Returns:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
|
|
|
// 3) uint16 - face
|
|
|
|
|
|
|
|
font_family family;
|
|
|
|
font_style style;
|
|
|
|
uint16 familyID, styleID;
|
|
|
|
uint16 face;
|
|
|
|
if (link.ReadString(family, sizeof(font_family)) == B_OK
|
|
|
|
&& link.ReadString(style, sizeof(font_style)) == B_OK
|
|
|
|
&& link.Read<uint16>(&familyID) == B_OK
|
|
|
|
&& link.Read<uint16>(&styleID) == B_OK
|
|
|
|
&& link.Read<uint16>(&face) == B_OK) {
|
|
|
|
// get the font and return IDs and face
|
|
|
|
gFontManager->Lock();
|
|
|
|
|
|
|
|
FontStyle *fontStyle = gFontManager->GetStyle(family, style,
|
|
|
|
familyID, styleID, face);
|
|
|
|
|
|
|
|
if (fontStyle != NULL) {
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<uint16>(fontStyle->Family()->ID());
|
|
|
|
fLink.Attach<uint16>(fontStyle->ID());
|
|
|
|
|
|
|
|
// we try to keep the font face close to what we got
|
|
|
|
face = fontStyle->PreservedFace(face);
|
|
|
|
|
|
|
|
fLink.Attach<uint16>(face);
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(B_NAME_NOT_FOUND);
|
|
|
|
|
|
|
|
gFontManager->Unlock();
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(B_BAD_VALUE);
|
|
|
|
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-01 21:21:04 +03:00
|
|
|
case AS_GET_FONT_FILE_FORMAT:
|
|
|
|
{
|
|
|
|
FTRACE(("ServerApp %s: AS_GET_FONT_FILE_FORMAT\n", Signature()));
|
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
|
|
|
|
|
|
|
// Returns:
|
|
|
|
// 1) uint16 font_file_format of font
|
|
|
|
|
|
|
|
int32 familyID, styleID;
|
|
|
|
link.Read<int32>(&familyID);
|
|
|
|
link.Read<int32>(&styleID);
|
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
gFontManager->Lock();
|
2005-11-01 21:21:04 +03:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
FontStyle *fontStyle = gFontManager->GetStyle(familyID, styleID);
|
2005-11-01 21:21:04 +03:00
|
|
|
if (fontStyle) {
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<uint16>((uint16)fontStyle->FileFormat());
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(B_BAD_VALUE);
|
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
gFontManager->Unlock();
|
2005-11-01 21:21:04 +03:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-08-24 18:50:41 +04:00
|
|
|
case AS_GET_STRING_WIDTHS:
|
2005-02-06 01:46:54 +03:00
|
|
|
{
|
2005-08-24 18:50:41 +04:00
|
|
|
FTRACE(("ServerApp %s: AS_GET_STRING_WIDTHS\n", Signature()));
|
2005-02-06 01:46:54 +03:00
|
|
|
// Attached Data:
|
2005-08-24 18:50:41 +04:00
|
|
|
// 1) uint16 ID of family
|
|
|
|
// 2) uint16 ID of style
|
|
|
|
// 3) float point size of font
|
|
|
|
// 4) uint8 spacing to use
|
|
|
|
// 5) int32 numStrings
|
|
|
|
// 6) int32 string length to measure (numStrings times)
|
|
|
|
// 7) string String to measure (numStrings times)
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2005-02-06 01:46:54 +03:00
|
|
|
// Returns:
|
2005-08-24 18:50:41 +04:00
|
|
|
// 1) float - width of the string in pixels (numStrings times)
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2005-06-08 08:01:59 +04:00
|
|
|
uint16 family, style;
|
2005-08-24 18:50:41 +04:00
|
|
|
float size;
|
2005-02-06 01:46:54 +03:00
|
|
|
uint8 spacing;
|
2005-06-08 08:01:59 +04:00
|
|
|
|
|
|
|
link.Read<uint16>(&family);
|
|
|
|
link.Read<uint16>(&style);
|
|
|
|
link.Read<float>(&size);
|
|
|
|
link.Read<uint8>(&spacing);
|
2005-08-24 18:50:41 +04:00
|
|
|
int32 numStrings;
|
2006-02-27 16:09:37 +03:00
|
|
|
if (link.Read<int32>(&numStrings) != B_OK) {
|
|
|
|
// this results in a B_BAD_VALUE return
|
|
|
|
numStrings = 0;
|
|
|
|
size = 0.0f;
|
|
|
|
}
|
2005-08-24 18:50:41 +04:00
|
|
|
|
|
|
|
float widthArray[numStrings];
|
|
|
|
int32 lengthArray[numStrings];
|
|
|
|
char *stringArray[numStrings];
|
2005-11-01 02:21:36 +03:00
|
|
|
for (int32 i = 0; i < numStrings; i++) {
|
2006-12-18 08:22:13 +03:00
|
|
|
// TODO: who allocates the strings?!? If the link does it then we are leaking
|
|
|
|
// everywhere else!!
|
2006-02-27 16:09:37 +03:00
|
|
|
link.ReadString(&stringArray[i], (size_t *)&lengthArray[i]);
|
2005-08-24 18:50:41 +04:00
|
|
|
}
|
2005-04-19 04:42:42 +04:00
|
|
|
|
|
|
|
ServerFont font;
|
|
|
|
|
2006-02-27 16:09:37 +03:00
|
|
|
if (font.SetFamilyAndStyle(family, style) == B_OK && size > 0) {
|
2005-04-19 04:42:42 +04:00
|
|
|
font.SetSize(size);
|
|
|
|
font.SetSpacing(spacing);
|
|
|
|
|
2005-11-02 17:37:17 +03:00
|
|
|
for (int32 i = 0; i < numStrings; i++) {
|
2005-08-24 18:50:41 +04:00
|
|
|
if (!stringArray[i] || lengthArray[i] <= 0)
|
|
|
|
widthArray[i] = 0.0;
|
2005-11-02 17:37:17 +03:00
|
|
|
else {
|
2005-12-21 01:39:54 +03:00
|
|
|
widthArray[i] = fDesktop->GetDrawingEngine()->StringWidth(stringArray[i], lengthArray[i], font);
|
2005-11-02 17:37:17 +03:00
|
|
|
// NOTE: The line below will return the exact same thing. However,
|
|
|
|
// the line above uses the AGG rendering backend, for which glyph caching
|
|
|
|
// actually works. It is about 20 times faster!
|
|
|
|
// TODO: I've disabled the AGG version for now, as it produces a dead lock
|
|
|
|
// (font use), that I am currently too lazy to investigate...
|
2005-12-21 01:39:54 +03:00
|
|
|
// widthArray[i] = font.StringWidth(stringArray[i], lengthArray[i]);
|
2005-11-02 17:37:17 +03:00
|
|
|
}
|
|
|
|
}
|
2005-05-20 21:36:55 +04:00
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-08-24 18:50:41 +04:00
|
|
|
fLink.Attach(widthArray, sizeof(widthArray));
|
2005-06-08 08:01:59 +04:00
|
|
|
} else
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(B_BAD_VALUE);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
|
|
|
fLink.Flush();
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
for (int32 i = 0; i < numStrings; i++) {
|
2005-11-01 04:57:52 +03:00
|
|
|
free(stringArray[i]);
|
2005-08-24 18:50:41 +04:00
|
|
|
}
|
2005-01-17 05:05:50 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_GET_FONT_BOUNDING_BOX:
|
|
|
|
{
|
2005-06-08 08:01:59 +04:00
|
|
|
FTRACE(("ServerApp %s: AS_GET_BOUNDING_BOX unimplemented\n",
|
2005-07-01 12:48:51 +04:00
|
|
|
Signature()));
|
2005-01-17 05:05:50 +03:00
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
// Returns:
|
|
|
|
// 1) BRect - box holding entire font
|
2005-06-08 08:01:59 +04:00
|
|
|
|
|
|
|
// ToDo: implement me!
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(B_ERROR);
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
2005-01-17 05:05:50 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_GET_TUNED_COUNT:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
FTRACE(("ServerApp %s: AS_GET_TUNED_COUNT\n", Signature()));
|
2005-01-17 05:05:50 +03:00
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
// Returns:
|
|
|
|
// 1) int32 - number of font strikes available
|
2005-11-01 19:28:01 +03:00
|
|
|
uint16 familyID, styleID;
|
|
|
|
link.Read<uint16>(&familyID);
|
|
|
|
link.Read<uint16>(&styleID);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
gFontManager->Lock();
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
FontStyle *fontStyle = gFontManager->GetStyle(familyID, styleID);
|
2005-11-01 19:28:01 +03:00
|
|
|
if (fontStyle != NULL) {
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<int32>(fontStyle->TunedCount());
|
2005-06-08 08:01:59 +04:00
|
|
|
} else
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(B_BAD_VALUE);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
gFontManager->Unlock();
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.Flush();
|
2005-01-17 05:05:50 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_GET_TUNED_INFO:
|
|
|
|
{
|
2005-06-08 08:01:59 +04:00
|
|
|
FTRACE(("ServerApp %s: AS_GET_TUNED_INFO unimplmemented\n",
|
2005-07-01 12:48:51 +04:00
|
|
|
Signature()));
|
2005-01-17 05:05:50 +03:00
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
|
|
|
// 3) uint32 - index of the particular font strike
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
// Returns:
|
|
|
|
// 1) tuned_font_info - info on the strike specified
|
2005-06-08 08:01:59 +04:00
|
|
|
// ToDo: implement me!
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(B_ERROR);
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
2005-01-17 05:05:50 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-11-07 14:02:39 +03:00
|
|
|
case AS_GET_EXTRA_FONT_FLAGS:
|
2005-01-17 05:05:50 +03:00
|
|
|
{
|
2005-11-07 14:02:39 +03:00
|
|
|
FTRACE(("ServerApp %s: AS_GET_EXTRA_FONT_FLAGS\n",
|
2005-07-01 12:48:51 +04:00
|
|
|
Signature()));
|
2005-01-17 05:05:50 +03:00
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
// Returns:
|
2005-11-07 14:02:39 +03:00
|
|
|
// 1) uint32 - extra font flags
|
2005-11-01 19:28:01 +03:00
|
|
|
uint16 familyID, styleID;
|
|
|
|
link.Read<uint16>(&familyID);
|
|
|
|
link.Read<uint16>(&styleID);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
gFontManager->Lock();
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
FontStyle *fontStyle = gFontManager->GetStyle(familyID, styleID);
|
2005-11-01 19:28:01 +03:00
|
|
|
if (fontStyle != NULL) {
|
|
|
|
fLink.StartMessage(B_OK);
|
2005-11-07 19:19:40 +03:00
|
|
|
fLink.Attach<uint32>(fontStyle->Flags());
|
2005-06-08 08:01:59 +04:00
|
|
|
} else
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(B_BAD_VALUE);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
gFontManager->Unlock();
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.Flush();
|
2005-01-17 05:05:50 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-01-17 23:08:40 +03:00
|
|
|
case AS_GET_FONT_HEIGHT:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
FTRACE(("ServerApp %s: AS_GET_FONT_HEIGHT\n", Signature()));
|
2005-01-17 23:08:40 +03:00
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 family ID
|
|
|
|
// 2) uint16 style ID
|
|
|
|
// 3) float size
|
2005-11-01 19:28:01 +03:00
|
|
|
uint16 familyID, styleID;
|
|
|
|
float size;
|
|
|
|
link.Read<uint16>(&familyID);
|
|
|
|
link.Read<uint16>(&styleID);
|
|
|
|
link.Read<float>(&size);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
gFontManager->Lock();
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
FontStyle *fontStyle = gFontManager->GetStyle(familyID, styleID);
|
2005-11-01 19:28:01 +03:00
|
|
|
if (fontStyle != NULL) {
|
2005-11-03 16:10:28 +03:00
|
|
|
font_height height;
|
|
|
|
fontStyle->GetHeight(size, height);
|
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-11-03 16:10:28 +03:00
|
|
|
fLink.Attach<font_height>(height);
|
2005-06-08 08:01:59 +04:00
|
|
|
} else
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(B_BAD_VALUE);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
gFontManager->Unlock();
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.Flush();
|
2005-01-17 05:05:50 +03:00
|
|
|
break;
|
|
|
|
}
|
2005-04-01 11:00:32 +04:00
|
|
|
case AS_GET_GLYPH_SHAPES:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
FTRACE(("ServerApp %s: AS_GET_GLYPH_SHAPES\n", Signature()));
|
2005-04-01 11:00:32 +04:00
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
|
|
|
// 3) float - point size
|
|
|
|
// 4) float - shear
|
|
|
|
// 5) float - rotation
|
2006-12-18 08:22:13 +03:00
|
|
|
// 6) float - false bold width
|
2005-04-01 11:00:32 +04:00
|
|
|
// 6) uint32 - flags
|
|
|
|
// 7) int32 - numChars
|
2006-02-05 01:20:00 +03:00
|
|
|
// 8) int32 - numBytes
|
|
|
|
// 8) char - chars (bytesInBuffer times)
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-04-01 11:00:32 +04:00
|
|
|
// Returns:
|
2005-04-01 13:18:25 +04:00
|
|
|
// 1) BShape - glyph shape
|
2005-04-01 11:00:32 +04:00
|
|
|
// numChars times
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
uint16 familyID, styleID;
|
2005-04-01 11:00:32 +04:00
|
|
|
uint32 flags;
|
2006-12-18 08:22:13 +03:00
|
|
|
float size, shear, rotation, falseBoldWidth;
|
2005-11-01 19:28:01 +03:00
|
|
|
|
|
|
|
link.Read<uint16>(&familyID);
|
|
|
|
link.Read<uint16>(&styleID);
|
|
|
|
link.Read<float>(&size);
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<float>(&shear);
|
|
|
|
link.Read<float>(&rotation);
|
2006-12-18 08:22:13 +03:00
|
|
|
link.Read<float>(&falseBoldWidth);
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<uint32>(&flags);
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2006-02-05 01:20:00 +03:00
|
|
|
int32 numChars, numBytes;
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<int32>(&numChars);
|
2006-02-05 01:20:00 +03:00
|
|
|
link.Read<int32>(&numBytes);
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2006-12-18 08:22:13 +03:00
|
|
|
char* charArray = new (nothrow) char[numBytes];
|
2006-02-06 02:36:59 +03:00
|
|
|
link.Read(charArray, numBytes);
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2005-04-01 11:00:32 +04:00
|
|
|
ServerFont font;
|
2005-11-01 19:28:01 +03:00
|
|
|
status_t status = font.SetFamilyAndStyle(familyID, styleID);
|
|
|
|
if (status == B_OK) {
|
|
|
|
font.SetSize(size);
|
2005-04-01 11:00:32 +04:00
|
|
|
font.SetShear(shear);
|
|
|
|
font.SetRotation(rotation);
|
2006-12-18 08:22:13 +03:00
|
|
|
font.SetFalseBoldWidth(falseBoldWidth);
|
2005-04-01 11:00:32 +04:00
|
|
|
font.SetFlags(flags);
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2006-12-18 08:22:13 +03:00
|
|
|
BShape** shapes = new (nothrow) BShape*[numChars];
|
2006-02-06 02:36:59 +03:00
|
|
|
status = font.GetGlyphShapes(charArray, numChars, shapes);
|
|
|
|
if (status == B_OK) {
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-04-01 13:18:25 +04:00
|
|
|
for (int32 i = 0; i < numChars; i++) {
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.AttachShape(*shapes[i]);
|
2005-04-01 13:18:25 +04:00
|
|
|
delete shapes[i];
|
|
|
|
}
|
2005-06-08 08:01:59 +04:00
|
|
|
} else
|
2006-02-06 02:36:59 +03:00
|
|
|
fLink.StartMessage(status);
|
2006-12-18 08:22:13 +03:00
|
|
|
|
|
|
|
delete[] shapes;
|
2005-06-08 08:01:59 +04:00
|
|
|
} else
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(status);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2006-02-06 02:36:59 +03:00
|
|
|
delete[] charArray;
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
2005-04-01 13:18:25 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-07-19 19:22:55 +04:00
|
|
|
case AS_GET_HAS_GLYPHS:
|
|
|
|
{
|
|
|
|
FTRACE(("ServerApp %s: AS_GET_HAS_GLYPHS\n", Signature()));
|
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
|
|
|
// 3) int32 - numChars
|
2006-02-05 01:20:00 +03:00
|
|
|
// 4) int32 - numBytes
|
|
|
|
// 5) char - the char buffer with size numBytes
|
2005-11-01 19:28:01 +03:00
|
|
|
|
|
|
|
uint16 familyID, styleID;
|
|
|
|
link.Read<uint16>(&familyID);
|
|
|
|
link.Read<uint16>(&styleID);
|
|
|
|
|
2006-02-05 01:20:00 +03:00
|
|
|
int32 numChars, numBytes;
|
2005-07-19 19:22:55 +04:00
|
|
|
link.Read<int32>(&numChars);
|
2006-02-05 01:20:00 +03:00
|
|
|
link.Read<int32>(&numBytes);
|
2006-12-18 08:22:13 +03:00
|
|
|
char* charArray = new (nothrow) char[numBytes];
|
2005-08-24 01:47:41 +04:00
|
|
|
link.Read(charArray, numBytes);
|
2006-02-05 01:20:00 +03:00
|
|
|
|
2005-07-19 19:22:55 +04:00
|
|
|
ServerFont font;
|
2005-11-01 19:28:01 +03:00
|
|
|
status_t status = font.SetFamilyAndStyle(familyID, styleID);
|
|
|
|
if (status == B_OK) {
|
2005-07-19 19:22:55 +04:00
|
|
|
bool hasArray[numChars];
|
2006-02-06 02:36:59 +03:00
|
|
|
status = font.GetHasGlyphs(charArray, numChars, hasArray);
|
|
|
|
if (status == B_OK) {
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach(hasArray, sizeof(hasArray));
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(status);
|
2005-07-19 19:22:55 +04:00
|
|
|
} else
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(status);
|
|
|
|
|
|
|
|
delete[] charArray;
|
2005-07-19 19:22:55 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-08-24 18:50:41 +04:00
|
|
|
case AS_GET_EDGES:
|
|
|
|
{
|
|
|
|
FTRACE(("ServerApp %s: AS_GET_EDGES\n", Signature()));
|
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
|
|
|
// 3) int32 - numChars
|
|
|
|
// 4) int32 - numBytes
|
|
|
|
// 5) char - the char buffer with size numBytes
|
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
uint16 familyID, styleID;
|
|
|
|
link.Read<uint16>(&familyID);
|
|
|
|
link.Read<uint16>(&styleID);
|
|
|
|
|
2005-08-24 18:50:41 +04:00
|
|
|
int32 numChars;
|
|
|
|
link.Read<int32>(&numChars);
|
|
|
|
|
|
|
|
uint32 numBytes;
|
|
|
|
link.Read<uint32>(&numBytes);
|
2006-12-18 08:22:13 +03:00
|
|
|
char* charArray = new (nothrow) char[numBytes];
|
2005-08-24 18:50:41 +04:00
|
|
|
link.Read(charArray, numBytes);
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2005-08-24 18:50:41 +04:00
|
|
|
ServerFont font;
|
2005-11-01 19:28:01 +03:00
|
|
|
status_t status = font.SetFamilyAndStyle(familyID, styleID);
|
|
|
|
if (status == B_OK) {
|
2005-08-24 18:50:41 +04:00
|
|
|
edge_info edgeArray[numChars];
|
2006-02-06 02:36:59 +03:00
|
|
|
status = font.GetEdges(charArray, numChars, edgeArray);
|
|
|
|
if (status == B_OK) {
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach(edgeArray, sizeof(edgeArray));
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(status);
|
2005-08-24 18:50:41 +04:00
|
|
|
} else
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(status);
|
|
|
|
|
|
|
|
delete[] charArray;
|
2005-08-24 18:50:41 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-04-01 13:18:25 +04:00
|
|
|
case AS_GET_ESCAPEMENTS:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
FTRACE(("ServerApp %s: AS_GET_ESCAPEMENTS\n", Signature()));
|
2005-04-01 13:18:25 +04:00
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
|
|
|
// 3) float - point size
|
2006-10-03 15:46:55 +04:00
|
|
|
// 4) uint8 - spacing
|
|
|
|
// 5) float - rotation
|
|
|
|
// 6) uint32 - flags
|
|
|
|
// 7) int32 - numChars
|
|
|
|
// 8) char - char -\ both
|
|
|
|
// 9) BPoint - offset -/ (numChars times)
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-04-01 13:18:25 +04:00
|
|
|
// Returns:
|
|
|
|
// 1) BPoint - escapement
|
|
|
|
// numChars times
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
uint16 familyID, styleID;
|
2005-04-01 13:18:25 +04:00
|
|
|
uint32 flags;
|
2005-11-01 19:28:01 +03:00
|
|
|
float size, rotation;
|
2006-10-03 15:46:55 +04:00
|
|
|
uint8 spacing;
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
link.Read<uint16>(&familyID);
|
|
|
|
link.Read<uint16>(&styleID);
|
|
|
|
link.Read<float>(&size);
|
2006-10-03 15:46:55 +04:00
|
|
|
link.Read<uint8>(&spacing);
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<float>(&rotation);
|
|
|
|
link.Read<uint32>(&flags);
|
|
|
|
|
2006-02-06 02:36:59 +03:00
|
|
|
escapement_delta delta;
|
|
|
|
link.Read<float>(&delta.nonspace);
|
|
|
|
link.Read<float>(&delta.space);
|
|
|
|
|
|
|
|
bool wantsOffsets;
|
|
|
|
link.Read<bool>(&wantsOffsets);
|
|
|
|
|
2005-04-01 13:18:25 +04:00
|
|
|
int32 numChars;
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<int32>(&numChars);
|
|
|
|
|
2006-02-06 02:36:59 +03:00
|
|
|
uint32 numBytes;
|
|
|
|
link.Read<uint32>(&numBytes);
|
2006-12-18 08:22:13 +03:00
|
|
|
char *charArray = new (nothrow) char[numBytes];
|
2006-02-06 02:36:59 +03:00
|
|
|
link.Read(charArray, numBytes);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-04-01 13:18:25 +04:00
|
|
|
ServerFont font;
|
2005-11-01 19:28:01 +03:00
|
|
|
status_t status = font.SetFamilyAndStyle(familyID, styleID);
|
|
|
|
if (status == B_OK) {
|
|
|
|
font.SetSize(size);
|
2006-10-03 15:46:55 +04:00
|
|
|
font.SetSpacing(spacing);
|
2005-04-01 13:18:25 +04:00
|
|
|
font.SetRotation(rotation);
|
|
|
|
font.SetFlags(flags);
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2006-12-18 08:22:13 +03:00
|
|
|
BPoint *escapements = new (nothrow) BPoint[numChars];
|
2006-02-06 02:36:59 +03:00
|
|
|
BPoint *offsets = NULL;
|
|
|
|
if (wantsOffsets)
|
2006-12-18 08:22:13 +03:00
|
|
|
offsets = new (nothrow) BPoint[numChars];
|
2006-02-06 02:36:59 +03:00
|
|
|
|
|
|
|
status = font.GetEscapements(charArray, numChars, delta,
|
|
|
|
escapements, offsets);
|
|
|
|
|
|
|
|
if (status == B_OK) {
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2006-02-06 02:36:59 +03:00
|
|
|
for (int32 i = 0; i < numChars; i++)
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.Attach<BPoint>(escapements[i]);
|
|
|
|
|
2006-02-06 02:36:59 +03:00
|
|
|
if (wantsOffsets) {
|
|
|
|
for (int32 i = 0; i < numChars; i++)
|
|
|
|
fLink.Attach<BPoint>(offsets[i]);
|
|
|
|
}
|
2005-06-08 08:01:59 +04:00
|
|
|
} else
|
2006-02-06 02:36:59 +03:00
|
|
|
fLink.StartMessage(status);
|
2006-12-18 08:22:13 +03:00
|
|
|
|
|
|
|
delete[] escapements;
|
|
|
|
delete[] offsets;
|
|
|
|
|
2005-06-08 08:01:59 +04:00
|
|
|
} else
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(status);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2006-02-06 02:36:59 +03:00
|
|
|
delete[] charArray;
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
2005-04-01 11:00:32 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-05-07 21:11:30 +04:00
|
|
|
case AS_GET_ESCAPEMENTS_AS_FLOATS:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
FTRACE(("ServerApp %s: AS_GET_ESCAPEMENTS_AS_FLOATS\n", Signature()));
|
2005-05-07 21:11:30 +04:00
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
|
|
|
// 3) float - point size
|
2006-10-03 15:46:55 +04:00
|
|
|
// 4) uint8 - spacing
|
|
|
|
// 5) float - rotation
|
|
|
|
// 6) uint32 - flags
|
2005-05-12 19:09:30 +04:00
|
|
|
|
2006-10-03 15:46:55 +04:00
|
|
|
// 7) float - additional "nonspace" delta
|
|
|
|
// 8) float - additional "space" delta
|
2005-05-12 19:09:30 +04:00
|
|
|
|
2006-10-03 15:46:55 +04:00
|
|
|
// 9) int32 - numChars
|
|
|
|
// 10) int32 - numBytes
|
|
|
|
// 11) char - the char buffer with size numBytes
|
2005-05-12 19:09:30 +04:00
|
|
|
|
2005-05-07 21:11:30 +04:00
|
|
|
// Returns:
|
2005-05-12 19:09:30 +04:00
|
|
|
// 1) float - escapement buffer with numChar entries
|
2005-05-07 21:11:30 +04:00
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
uint16 familyID, styleID;
|
2005-05-07 21:11:30 +04:00
|
|
|
uint32 flags;
|
2005-11-01 19:28:01 +03:00
|
|
|
float size, rotation;
|
2006-10-03 15:46:55 +04:00
|
|
|
uint8 spacing;
|
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
link.Read<uint16>(&familyID);
|
|
|
|
link.Read<uint16>(&styleID);
|
|
|
|
link.Read<float>(&size);
|
2006-10-03 15:46:55 +04:00
|
|
|
link.Read<uint8>(&spacing);
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<float>(&rotation);
|
|
|
|
link.Read<uint32>(&flags);
|
2005-05-12 19:09:30 +04:00
|
|
|
|
|
|
|
escapement_delta delta;
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<float>(&delta.nonspace);
|
|
|
|
link.Read<float>(&delta.space);
|
2005-05-07 21:11:30 +04:00
|
|
|
|
|
|
|
int32 numChars;
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<int32>(&numChars);
|
2005-05-12 19:09:30 +04:00
|
|
|
|
|
|
|
uint32 numBytes;
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<uint32>(&numBytes);
|
2006-12-18 08:22:13 +03:00
|
|
|
char* charArray = new (nothrow) char[numBytes];
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read(charArray, numBytes);
|
2005-05-12 19:09:30 +04:00
|
|
|
|
2006-12-18 08:22:13 +03:00
|
|
|
float* escapements = new (nothrow) float[numChars];
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2005-05-12 19:09:30 +04:00
|
|
|
// figure out escapements
|
|
|
|
|
|
|
|
ServerFont font;
|
2005-11-01 19:28:01 +03:00
|
|
|
status_t status = font.SetFamilyAndStyle(familyID, styleID);
|
|
|
|
if (status == B_OK) {
|
|
|
|
font.SetSize(size);
|
2006-10-03 15:46:55 +04:00
|
|
|
font.SetSpacing(spacing);
|
2005-05-12 19:09:30 +04:00
|
|
|
font.SetRotation(rotation);
|
|
|
|
font.SetFlags(flags);
|
|
|
|
|
2006-02-06 02:36:59 +03:00
|
|
|
status = font.GetEscapements(charArray, numChars, delta,
|
|
|
|
escapements);
|
|
|
|
|
|
|
|
if (status == B_OK) {
|
2005-11-01 19:28:01 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Attach(escapements, numChars * sizeof(float));
|
2006-02-06 02:36:59 +03:00
|
|
|
}
|
2005-05-12 19:09:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
delete[] charArray;
|
|
|
|
delete[] escapements;
|
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
if (status != B_OK)
|
|
|
|
fLink.StartMessage(status);
|
2005-05-12 19:09:30 +04:00
|
|
|
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
2005-05-07 21:11:30 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-08-25 19:21:34 +04:00
|
|
|
case AS_GET_BOUNDINGBOXES_CHARS:
|
|
|
|
{
|
|
|
|
FTRACE(("ServerApp %s: AS_GET_BOUNDINGBOXES_CHARS\n", Signature()));
|
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
|
|
|
// 3) float - point size
|
|
|
|
// 4) float - rotation
|
2005-08-26 12:47:17 +04:00
|
|
|
// 5) float - shear
|
2006-12-18 08:22:13 +03:00
|
|
|
// 6) float - false bold width
|
|
|
|
// 7) uint8 - spacing
|
|
|
|
// 8) uint32 - flags
|
2005-08-25 19:21:34 +04:00
|
|
|
|
2006-12-18 08:22:13 +03:00
|
|
|
// 9) font_metric_mode - mode
|
|
|
|
// 10) bool - string escapement
|
2005-08-25 19:21:34 +04:00
|
|
|
|
2006-12-18 08:22:13 +03:00
|
|
|
// 11) escapement_delta - additional delta
|
2005-08-25 19:21:34 +04:00
|
|
|
|
2006-12-18 08:22:13 +03:00
|
|
|
// 12) int32 - numChars
|
|
|
|
// 13) int32 - numBytes
|
|
|
|
// 14) char - the char buffer with size numBytes
|
2005-08-25 19:21:34 +04:00
|
|
|
|
|
|
|
// Returns:
|
|
|
|
// 1) BRect - rects with numChar entries
|
|
|
|
|
|
|
|
uint16 famid, styid;
|
|
|
|
uint32 flags;
|
2006-12-18 08:22:13 +03:00
|
|
|
float ptsize, rotation, shear, falseBoldWidth;
|
2005-08-26 12:47:17 +04:00
|
|
|
uint8 spacing;
|
2005-08-25 19:21:34 +04:00
|
|
|
font_metric_mode mode;
|
2005-08-26 12:40:24 +04:00
|
|
|
bool string_escapement;
|
2005-08-25 19:21:34 +04:00
|
|
|
|
|
|
|
link.Read<uint16>(&famid);
|
|
|
|
link.Read<uint16>(&styid);
|
|
|
|
link.Read<float>(&ptsize);
|
|
|
|
link.Read<float>(&rotation);
|
2005-08-26 12:40:24 +04:00
|
|
|
link.Read<float>(&shear);
|
2006-12-18 08:22:13 +03:00
|
|
|
link.Read<float>(&falseBoldWidth);
|
2005-08-26 12:47:17 +04:00
|
|
|
link.Read<uint8>(&spacing);
|
2005-08-25 19:21:34 +04:00
|
|
|
link.Read<uint32>(&flags);
|
|
|
|
link.Read<font_metric_mode>(&mode);
|
2005-08-26 12:40:24 +04:00
|
|
|
link.Read<bool>(&string_escapement);
|
2005-08-25 19:21:34 +04:00
|
|
|
|
|
|
|
escapement_delta delta;
|
|
|
|
link.Read<escapement_delta>(&delta);
|
|
|
|
|
|
|
|
int32 numChars;
|
|
|
|
link.Read<int32>(&numChars);
|
|
|
|
|
|
|
|
uint32 numBytes;
|
|
|
|
link.Read<uint32>(&numBytes);
|
|
|
|
|
2006-12-18 08:22:13 +03:00
|
|
|
char *charArray = new (nothrow) char[numBytes];
|
2005-08-25 19:21:34 +04:00
|
|
|
link.Read(charArray, numBytes);
|
|
|
|
|
2005-08-26 12:40:24 +04:00
|
|
|
BRect rectArray[numChars];
|
2005-08-25 19:21:34 +04:00
|
|
|
// figure out escapements
|
|
|
|
|
|
|
|
ServerFont font;
|
|
|
|
bool success = false;
|
|
|
|
if (font.SetFamilyAndStyle(famid, styid) == B_OK) {
|
|
|
|
font.SetSize(ptsize);
|
|
|
|
font.SetRotation(rotation);
|
2005-08-26 12:40:24 +04:00
|
|
|
font.SetShear(shear);
|
2006-12-18 08:22:13 +03:00
|
|
|
font.SetFalseBoldWidth(falseBoldWidth);
|
2005-08-26 12:47:17 +04:00
|
|
|
font.SetSpacing(spacing);
|
2005-08-25 19:21:34 +04:00
|
|
|
font.SetFlags(flags);
|
|
|
|
|
2005-08-26 12:40:24 +04:00
|
|
|
// TODO implement for real
|
2006-02-06 02:36:59 +03:00
|
|
|
if (font.GetBoundingBoxesAsString(charArray, numChars,
|
|
|
|
rectArray, string_escapement, mode, delta) == B_OK) {
|
2005-12-08 15:41:19 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-08-25 19:21:34 +04:00
|
|
|
fLink.Attach(rectArray, sizeof(rectArray));
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!success)
|
2005-12-08 15:41:19 +03:00
|
|
|
fLink.StartMessage(B_ERROR);
|
2005-08-25 19:21:34 +04:00
|
|
|
|
2006-02-06 02:36:59 +03:00
|
|
|
delete[] charArray;
|
2005-08-25 19:21:34 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AS_GET_BOUNDINGBOXES_STRINGS:
|
|
|
|
{
|
|
|
|
FTRACE(("ServerApp %s: AS_GET_BOUNDINGBOXES_STRINGS\n", Signature()));
|
|
|
|
// Attached Data:
|
|
|
|
// 1) uint16 - family ID
|
|
|
|
// 2) uint16 - style ID
|
|
|
|
// 3) float - point size
|
|
|
|
// 4) float - rotation
|
2005-08-26 12:40:24 +04:00
|
|
|
// 5) float - shear
|
2006-12-18 08:22:13 +03:00
|
|
|
// 6) float - false bold width
|
|
|
|
// 7) uint8 - spacing
|
|
|
|
// 8) uint32 - flags
|
2005-08-25 19:21:34 +04:00
|
|
|
|
2006-12-18 08:22:13 +03:00
|
|
|
// 9) font_metric_mode - mode
|
|
|
|
// 10) int32 numStrings
|
2005-08-25 19:21:34 +04:00
|
|
|
|
2006-12-18 08:22:13 +03:00
|
|
|
// 11) escapement_delta - additional delta (numStrings times)
|
|
|
|
// 12) int32 string length to measure (numStrings times)
|
|
|
|
// 13) string - string (numStrings times)
|
2005-08-25 19:21:34 +04:00
|
|
|
|
|
|
|
// Returns:
|
|
|
|
// 1) BRect - rects with numStrings entries
|
|
|
|
|
|
|
|
uint16 famid, styid;
|
|
|
|
uint32 flags;
|
2006-12-18 08:22:13 +03:00
|
|
|
float ptsize, rotation, shear, falseBoldWidth;
|
2005-08-26 12:47:17 +04:00
|
|
|
uint8 spacing;
|
2005-08-25 19:21:34 +04:00
|
|
|
font_metric_mode mode;
|
|
|
|
|
|
|
|
link.Read<uint16>(&famid);
|
|
|
|
link.Read<uint16>(&styid);
|
|
|
|
link.Read<float>(&ptsize);
|
|
|
|
link.Read<float>(&rotation);
|
2005-08-26 12:40:24 +04:00
|
|
|
link.Read<float>(&shear);
|
2006-12-18 08:22:13 +03:00
|
|
|
link.Read<float>(&falseBoldWidth);
|
2005-08-26 12:47:17 +04:00
|
|
|
link.Read<uint8>(&spacing);
|
2005-08-25 19:21:34 +04:00
|
|
|
link.Read<uint32>(&flags);
|
|
|
|
link.Read<font_metric_mode>(&mode);
|
|
|
|
|
|
|
|
int32 numStrings;
|
|
|
|
link.Read<int32>(&numStrings);
|
|
|
|
|
|
|
|
escapement_delta deltaArray[numStrings];
|
|
|
|
char *stringArray[numStrings];
|
|
|
|
int32 lengthArray[numStrings];
|
|
|
|
for(int32 i=0; i<numStrings; i++) {
|
|
|
|
link.Read<int32>(&lengthArray[i]);
|
|
|
|
link.Read<escapement_delta>(&deltaArray[i]);
|
|
|
|
link.ReadString(&stringArray[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
BRect rectArray[numStrings];
|
|
|
|
|
|
|
|
ServerFont font;
|
|
|
|
bool success = false;
|
|
|
|
if (font.SetFamilyAndStyle(famid, styid) == B_OK) {
|
|
|
|
font.SetSize(ptsize);
|
|
|
|
font.SetRotation(rotation);
|
2005-08-26 12:40:24 +04:00
|
|
|
font.SetShear(shear);
|
2006-12-18 08:22:13 +03:00
|
|
|
font.SetFalseBoldWidth(falseBoldWidth);
|
2005-08-26 12:47:17 +04:00
|
|
|
font.SetSpacing(spacing);
|
2005-08-25 19:21:34 +04:00
|
|
|
font.SetFlags(flags);
|
|
|
|
|
2005-08-26 12:40:24 +04:00
|
|
|
// TODO implement for real
|
2006-02-06 02:36:59 +03:00
|
|
|
if (font.GetBoundingBoxesForStrings(stringArray, lengthArray,
|
|
|
|
numStrings, rectArray, mode, deltaArray) == B_OK) {
|
2005-12-08 15:41:19 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-08-25 19:21:34 +04:00
|
|
|
fLink.Attach(rectArray, sizeof(rectArray));
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-14 15:08:21 +03:00
|
|
|
for (int32 i = 0; i < numStrings; i++)
|
2005-11-01 04:41:40 +03:00
|
|
|
free(stringArray[i]);
|
2005-08-25 19:21:34 +04:00
|
|
|
|
|
|
|
if (!success)
|
2005-12-08 15:41:19 +03:00
|
|
|
fLink.StartMessage(B_ERROR);
|
2005-08-25 19:21:34 +04:00
|
|
|
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2005-11-09 21:34:48 +03:00
|
|
|
/* screen commands */
|
|
|
|
|
2005-11-14 17:36:12 +03:00
|
|
|
case AS_VALID_SCREEN_ID:
|
|
|
|
{
|
|
|
|
// Attached data
|
|
|
|
// 1) screen_id screen
|
|
|
|
screen_id id;
|
|
|
|
if (link.Read<screen_id>(&id) == B_OK
|
|
|
|
&& id.id == B_MAIN_SCREEN_ID.id)
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
else
|
|
|
|
fLink.StartMessage(B_ERROR);
|
|
|
|
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case AS_GET_NEXT_SCREEN_ID:
|
|
|
|
{
|
|
|
|
// Attached data
|
|
|
|
// 1) screen_id screen
|
|
|
|
screen_id id;
|
|
|
|
link.Read<screen_id>(&id);
|
|
|
|
|
|
|
|
// TODO: for now, just say we're the last one
|
|
|
|
fLink.StartMessage(B_ENTRY_NOT_FOUND);
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-11-14 15:08:21 +03:00
|
|
|
case AS_GET_SCREEN_ID_FROM_WINDOW:
|
|
|
|
{
|
|
|
|
status_t status = B_ENTRY_NOT_FOUND;
|
|
|
|
|
|
|
|
// Attached data
|
|
|
|
// 1) int32 - window client token
|
|
|
|
int32 clientToken;
|
|
|
|
if (link.Read<int32>(&clientToken) != B_OK)
|
|
|
|
status = B_BAD_DATA;
|
|
|
|
else {
|
|
|
|
BAutolock locker(fWindowListLock);
|
|
|
|
|
|
|
|
for (int32 i = fWindowList.CountItems(); i-- > 0;) {
|
|
|
|
ServerWindow* window = fWindowList.ItemAt(i);
|
|
|
|
|
|
|
|
if (window->ClientToken() == clientToken) {
|
|
|
|
// got it!
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<screen_id>(B_MAIN_SCREEN_ID);
|
|
|
|
// TODO: for now...
|
|
|
|
status = B_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status != B_OK)
|
|
|
|
fLink.StartMessage(status);
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-04-30 11:04:27 +04:00
|
|
|
case AS_SCREEN_GET_MODE:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: AS_SCREEN_GET_MODE\n", Signature()));
|
2005-04-30 11:04:27 +04:00
|
|
|
// Attached data
|
2005-07-11 01:16:43 +04:00
|
|
|
// 1) screen_id screen
|
|
|
|
// 2) uint32 workspace index
|
2005-04-30 11:04:27 +04:00
|
|
|
screen_id id;
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<screen_id>(&id);
|
2005-04-30 11:04:27 +04:00
|
|
|
uint32 workspace;
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<uint32>(&workspace);
|
|
|
|
|
2005-04-30 11:04:27 +04:00
|
|
|
// TODO: the display_mode can be different between
|
|
|
|
// the various screens.
|
|
|
|
// We have the screen_id and the workspace number, with these
|
|
|
|
// we need to find the corresponding "driver", and call getmode on it
|
|
|
|
display_mode mode;
|
2005-07-26 01:08:34 +04:00
|
|
|
fDesktop->ScreenAt(0)->GetMode(&mode);
|
2005-04-30 11:04:27 +04:00
|
|
|
// actually this isn't still enough as different workspaces can
|
|
|
|
// have different display_modes
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-14 14:01:02 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Attach<display_mode>(mode);
|
|
|
|
fLink.Flush();
|
2005-04-30 11:04:27 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-05-01 10:26:49 +04:00
|
|
|
case AS_SCREEN_SET_MODE:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: AS_SCREEN_SET_MODE\n", Signature()));
|
2005-05-01 10:26:49 +04:00
|
|
|
// Attached data
|
2005-07-11 01:16:43 +04:00
|
|
|
// 1) screen_id
|
|
|
|
// 2) workspace index
|
|
|
|
// 3) display_mode to set
|
2007-02-02 19:20:16 +03:00
|
|
|
// 4) 'makeDefault' boolean
|
2005-05-05 11:38:39 +04:00
|
|
|
// TODO: See above: workspaces support, etc.
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-05-01 10:26:49 +04:00
|
|
|
screen_id id;
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<screen_id>(&id);
|
|
|
|
|
2005-05-01 10:26:49 +04:00
|
|
|
uint32 workspace;
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<uint32>(&workspace);
|
|
|
|
|
2005-05-01 10:26:49 +04:00
|
|
|
display_mode mode;
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<display_mode>(&mode);
|
|
|
|
|
2006-02-06 16:36:46 +03:00
|
|
|
bool makeDefault = false;
|
|
|
|
status_t status = link.Read<bool>(&makeDefault);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2006-02-06 16:36:46 +03:00
|
|
|
if (status == B_OK && fDesktop->LockAllWindows()) {
|
2007-02-02 19:20:16 +03:00
|
|
|
display_mode oldMode;
|
|
|
|
fDesktop->ScreenAt(0)->GetMode(&oldMode);
|
|
|
|
if (memcmp(&oldMode, &mode, sizeof(display_mode))) {
|
|
|
|
status = fDesktop->ScreenAt(0)->SetMode(mode, makeDefault);
|
|
|
|
if (status == B_OK) {
|
|
|
|
gInputManager->UpdateScreenBounds(fDesktop->ScreenAt(0)->Frame());
|
|
|
|
fDesktop->ScreenChanged(fDesktop->ScreenAt(0), makeDefault);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
status = B_OK;
|
2005-12-12 13:41:31 +03:00
|
|
|
fDesktop->UnlockAllWindows();
|
2006-02-06 16:36:46 +03:00
|
|
|
} else
|
|
|
|
status = B_ERROR;
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-11-14 14:01:02 +03:00
|
|
|
fLink.StartMessage(status);
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
2005-05-01 10:26:49 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-06-25 09:58:43 +04:00
|
|
|
case AS_PROPOSE_MODE:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: AS_PROPOSE_MODE\n", Signature()));
|
2005-06-25 09:58:43 +04:00
|
|
|
screen_id id;
|
|
|
|
link.Read<screen_id>(&id);
|
|
|
|
|
|
|
|
display_mode target, low, high;
|
|
|
|
link.Read<display_mode>(&target);
|
|
|
|
link.Read<display_mode>(&low);
|
|
|
|
link.Read<display_mode>(&high);
|
2005-11-18 15:26:20 +03:00
|
|
|
status_t status = fDesktop->HWInterface()->ProposeMode(&target, &low, &high);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
|
|
|
// ProposeMode() returns B_BAD_VALUE to hint that the candidate is
|
|
|
|
// not within the given limits (but is supported)
|
|
|
|
if (status == B_OK || status == B_BAD_VALUE) {
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<display_mode>(target);
|
|
|
|
fLink.Attach<bool>(status == B_OK);
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(status);
|
|
|
|
|
2005-06-25 09:58:43 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-22 22:14:13 +04:00
|
|
|
case AS_GET_MODE_LIST:
|
|
|
|
{
|
2005-07-11 01:16:43 +04:00
|
|
|
screen_id id;
|
|
|
|
link.Read<screen_id>(&id);
|
|
|
|
// TODO: use this screen id
|
|
|
|
|
2005-06-22 22:14:13 +04:00
|
|
|
display_mode* modeList;
|
|
|
|
uint32 count;
|
2005-11-18 15:26:20 +03:00
|
|
|
status_t status = fDesktop->HWInterface()->GetModeList(&modeList, &count);
|
2005-11-14 14:01:02 +03:00
|
|
|
if (status == B_OK) {
|
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-22 22:14:13 +04:00
|
|
|
fLink.Attach<uint32>(count);
|
|
|
|
fLink.Attach(modeList, sizeof(display_mode) * count);
|
|
|
|
|
|
|
|
delete[] modeList;
|
|
|
|
} else
|
2005-11-14 14:01:02 +03:00
|
|
|
fLink.StartMessage(status);
|
2005-06-22 22:14:13 +04:00
|
|
|
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-06-08 01:32:24 +04:00
|
|
|
case AS_SCREEN_GET_COLORMAP:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: AS_SCREEN_GET_COLORMAP\n", Signature()));
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-06-08 01:32:24 +04:00
|
|
|
screen_id id;
|
2005-06-08 08:01:59 +04:00
|
|
|
link.Read<screen_id>(&id);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-25 17:58:55 +04:00
|
|
|
const color_map *colorMap = SystemColorMap();
|
|
|
|
if (colorMap != NULL) {
|
2005-11-14 14:01:02 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-25 17:58:55 +04:00
|
|
|
fLink.Attach<color_map>(*colorMap);
|
|
|
|
} else
|
2005-11-14 14:01:02 +03:00
|
|
|
fLink.StartMessage(B_ERROR);
|
|
|
|
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
2005-06-08 01:32:24 +04:00
|
|
|
break;
|
|
|
|
}
|
2005-06-08 08:01:59 +04:00
|
|
|
|
2005-06-08 17:24:40 +04:00
|
|
|
case AS_GET_DESKTOP_COLOR:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: get desktop color\n", Signature()));
|
2005-06-08 17:24:40 +04:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
uint32 index;
|
|
|
|
link.Read<uint32>(&index);
|
2005-06-08 17:24:40 +04:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fDesktop->Lock();
|
2005-11-14 14:01:02 +03:00
|
|
|
|
|
|
|
// we're nice to our children (and also take the default case
|
|
|
|
// into account which asks for the current workspace)
|
2005-11-29 02:36:59 +03:00
|
|
|
if (index >= (uint32)kMaxWorkspaces)
|
|
|
|
index = fDesktop->CurrentWorkspace();
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-11-30 22:56:44 +03:00
|
|
|
Workspace workspace(*fDesktop, index);
|
2005-11-29 02:36:59 +03:00
|
|
|
fLink.Attach<rgb_color>(workspace.Color().GetColor32());
|
2005-06-08 17:24:40 +04:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
fDesktop->Unlock();
|
2005-06-08 17:24:40 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-12-29 21:09:07 +03:00
|
|
|
case AS_SET_DESKTOP_COLOR:
|
|
|
|
{
|
|
|
|
STRACE(("ServerApp %s: set desktop color\n", Signature()));
|
|
|
|
|
|
|
|
rgb_color color;
|
|
|
|
uint32 index;
|
|
|
|
bool makeDefault;
|
|
|
|
|
|
|
|
link.Read<rgb_color>(&color);
|
|
|
|
link.Read<uint32>(&index);
|
|
|
|
if (link.Read<bool>(&makeDefault) != B_OK)
|
|
|
|
break;
|
|
|
|
|
|
|
|
fDesktop->Lock();
|
|
|
|
|
|
|
|
// we're nice to our children (and also take the default case
|
|
|
|
// into account which asks for the current workspace)
|
|
|
|
if (index >= (uint32)kMaxWorkspaces)
|
|
|
|
index = fDesktop->CurrentWorkspace();
|
|
|
|
|
|
|
|
Workspace workspace(*fDesktop, index);
|
|
|
|
workspace.SetColor(color, makeDefault);
|
|
|
|
|
|
|
|
fDesktop->Unlock();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-06-24 22:02:01 +04:00
|
|
|
case AS_GET_ACCELERANT_INFO:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: get accelerant info\n", Signature()));
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-24 22:02:01 +04:00
|
|
|
// We aren't using the screen_id for now...
|
|
|
|
screen_id id;
|
|
|
|
link.Read<screen_id>(&id);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-24 22:02:01 +04:00
|
|
|
accelerant_device_info accelerantInfo;
|
|
|
|
// TODO: I wonder if there should be a "desktop" lock...
|
2005-11-18 15:26:20 +03:00
|
|
|
status_t status = fDesktop->HWInterface()->GetDeviceInfo(&accelerantInfo);
|
2005-11-14 14:01:02 +03:00
|
|
|
if (status == B_OK) {
|
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-24 22:02:01 +04:00
|
|
|
fLink.Attach<accelerant_device_info>(accelerantInfo);
|
|
|
|
} else
|
2005-11-14 14:01:02 +03:00
|
|
|
fLink.StartMessage(status);
|
|
|
|
|
2005-06-24 22:02:01 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-11-14 17:36:12 +03:00
|
|
|
case AS_GET_FRAME_BUFFER_CONFIG:
|
|
|
|
{
|
|
|
|
STRACE(("ServerApp %s: get frame buffer config\n", Signature()));
|
|
|
|
|
|
|
|
// We aren't using the screen_id for now...
|
|
|
|
screen_id id;
|
|
|
|
link.Read<screen_id>(&id);
|
|
|
|
|
|
|
|
frame_buffer_config config;
|
|
|
|
// TODO: I wonder if there should be a "desktop" lock...
|
2005-11-18 15:26:20 +03:00
|
|
|
status_t status = fDesktop->HWInterface()->GetFrameBufferConfig(config);
|
2005-11-14 17:36:12 +03:00
|
|
|
if (status == B_OK) {
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<frame_buffer_config>(config);
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(status);
|
|
|
|
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-06-24 22:02:01 +04:00
|
|
|
case AS_GET_RETRACE_SEMAPHORE:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: get retrace semaphore\n", Signature()));
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-24 22:02:01 +04:00
|
|
|
// We aren't using the screen_id for now...
|
|
|
|
screen_id id;
|
|
|
|
link.Read<screen_id>(&id);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2006-04-29 20:46:21 +04:00
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
fLink.Attach<sem_id>(fDesktop->HWInterface()->RetraceSemaphore());
|
2005-06-24 22:02:01 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-25 10:30:09 +04:00
|
|
|
case AS_GET_TIMING_CONSTRAINTS:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: get timing constraints\n", Signature()));
|
2005-06-25 10:30:09 +04:00
|
|
|
// We aren't using the screen_id for now...
|
|
|
|
screen_id id;
|
|
|
|
link.Read<screen_id>(&id);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-25 10:30:09 +04:00
|
|
|
display_timing_constraints constraints;
|
2005-11-18 15:26:20 +03:00
|
|
|
status_t status = fDesktop->HWInterface()->GetTimingConstraints(
|
2005-11-14 14:01:02 +03:00
|
|
|
&constraints);
|
|
|
|
if (status == B_OK) {
|
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-25 10:30:09 +04:00
|
|
|
fLink.Attach<display_timing_constraints>(constraints);
|
|
|
|
} else
|
2005-11-14 14:01:02 +03:00
|
|
|
fLink.StartMessage(status);
|
|
|
|
|
2005-06-25 10:30:09 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-25 10:30:09 +04:00
|
|
|
case AS_GET_PIXEL_CLOCK_LIMITS:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: get pixel clock limits\n", Signature()));
|
2005-06-25 10:30:09 +04:00
|
|
|
// We aren't using the screen_id for now...
|
|
|
|
screen_id id;
|
|
|
|
link.Read<screen_id>(&id);
|
|
|
|
display_mode mode;
|
|
|
|
link.Read<display_mode>(&mode);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-25 10:30:09 +04:00
|
|
|
uint32 low, high;
|
2005-11-18 15:26:20 +03:00
|
|
|
status_t status = fDesktop->HWInterface()->GetPixelClockLimits(&mode,
|
2005-11-14 14:01:02 +03:00
|
|
|
&low, &high);
|
|
|
|
if (status == B_OK) {
|
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-25 10:30:09 +04:00
|
|
|
fLink.Attach<uint32>(low);
|
|
|
|
fLink.Attach<uint32>(high);
|
|
|
|
} else
|
2005-11-14 14:01:02 +03:00
|
|
|
fLink.StartMessage(status);
|
|
|
|
|
2005-06-25 10:30:09 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-25 17:53:48 +04:00
|
|
|
case AS_SET_DPMS:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: AS_SET_DPMS\n", Signature()));
|
2005-06-25 17:53:48 +04:00
|
|
|
screen_id id;
|
|
|
|
link.Read<screen_id>(&id);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-25 17:53:48 +04:00
|
|
|
uint32 mode;
|
|
|
|
link.Read<uint32>(&mode);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-11-18 15:26:20 +03:00
|
|
|
status_t status = fDesktop->HWInterface()->SetDPMSMode(mode);
|
2005-11-14 14:01:02 +03:00
|
|
|
fLink.StartMessage(status);
|
|
|
|
|
2005-06-25 17:53:48 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-25 17:53:48 +04:00
|
|
|
case AS_GET_DPMS_STATE:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: AS_GET_DPMS_STATE\n", Signature()));
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-25 17:53:48 +04:00
|
|
|
screen_id id;
|
|
|
|
link.Read<screen_id>(&id);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-11-18 15:26:20 +03:00
|
|
|
uint32 state = fDesktop->HWInterface()->DPMSMode();
|
2005-11-14 14:01:02 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-25 17:53:48 +04:00
|
|
|
fLink.Attach<uint32>(state);
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-06-25 17:53:48 +04:00
|
|
|
case AS_GET_DPMS_CAPABILITIES:
|
|
|
|
{
|
2005-07-01 12:48:51 +04:00
|
|
|
STRACE(("ServerApp %s: AS_GET_DPMS_CAPABILITIES\n", Signature()));
|
2005-06-25 17:53:48 +04:00
|
|
|
screen_id id;
|
|
|
|
link.Read<screen_id>(&id);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-11-18 15:26:20 +03:00
|
|
|
uint32 capabilities = fDesktop->HWInterface()->DPMSCapabilities();
|
2005-11-14 14:01:02 +03:00
|
|
|
fLink.StartMessage(B_OK);
|
2005-06-25 17:53:48 +04:00
|
|
|
fLink.Attach<uint32>(capabilities);
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-07-14 02:33:52 +04:00
|
|
|
case AS_READ_BITMAP:
|
|
|
|
{
|
|
|
|
STRACE(("ServerApp %s: AS_READ_BITMAP\n", Signature()));
|
|
|
|
int32 bitmapToken;
|
|
|
|
link.Read<int32>(&bitmapToken);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-07-14 02:33:52 +04:00
|
|
|
bool drawCursor = true;
|
|
|
|
link.Read<bool>(&drawCursor);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-07-14 02:33:52 +04:00
|
|
|
BRect bounds;
|
|
|
|
link.Read<BRect>(&bounds);
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2005-07-14 02:33:52 +04:00
|
|
|
ServerBitmap *bitmap = FindBitmap(bitmapToken);
|
|
|
|
if (bitmap != NULL) {
|
2006-03-03 02:50:06 +03:00
|
|
|
if (fDesktop->GetDrawingEngine()->ReadBitmap(bitmap,
|
|
|
|
drawCursor, bounds) == B_OK) {
|
|
|
|
fLink.StartMessage(B_OK);
|
|
|
|
} else
|
|
|
|
fLink.StartMessage(B_BAD_VALUE);
|
2005-07-14 02:33:52 +04:00
|
|
|
} else
|
2005-11-14 14:01:02 +03:00
|
|
|
fLink.StartMessage(B_BAD_VALUE);
|
|
|
|
|
2005-07-14 02:33:52 +04:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-12-24 19:25:47 +03:00
|
|
|
|
|
|
|
case AS_GET_ACCELERANT_PATH:
|
|
|
|
{
|
|
|
|
int32 index;
|
|
|
|
fLink.Read<int32>(&index);
|
|
|
|
|
|
|
|
BString path;
|
|
|
|
status_t status = fDesktop->HWInterface()->GetAccelerantPath(path);
|
|
|
|
fLink.StartMessage(status);
|
|
|
|
if (status == B_OK)
|
|
|
|
fLink.AttachString(path.String());
|
|
|
|
|
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case AS_GET_DRIVER_PATH:
|
|
|
|
{
|
|
|
|
int32 index;
|
|
|
|
fLink.Read<int32>(&index);
|
2006-05-03 00:17:45 +04:00
|
|
|
|
2005-12-24 19:25:47 +03:00
|
|
|
BString path;
|
|
|
|
status_t status = fDesktop->HWInterface()->GetDriverPath(path);
|
|
|
|
fLink.StartMessage(status);
|
|
|
|
if (status == B_OK)
|
|
|
|
fLink.AttachString(path.String());
|
2006-05-03 00:17:45 +04:00
|
|
|
|
2005-12-24 19:25:47 +03:00
|
|
|
fLink.Flush();
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 14:01:02 +03:00
|
|
|
|
2003-01-24 17:36:15 +03:00
|
|
|
default:
|
2005-11-09 21:34:48 +03:00
|
|
|
printf("ServerApp %s received unhandled message code %ld\n",
|
|
|
|
Signature(), code);
|
2005-06-08 08:01:59 +04:00
|
|
|
|
|
|
|
if (link.NeedsReply()) {
|
|
|
|
// the client is now blocking and waiting for a reply!
|
2005-12-08 15:41:19 +03:00
|
|
|
fLink.StartMessage(B_ERROR);
|
2005-06-08 08:01:59 +04:00
|
|
|
fLink.Flush();
|
|
|
|
} else
|
|
|
|
puts("message doesn't need a reply!");
|
2003-01-24 17:36:15 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-03-12 17:29:59 +03:00
|
|
|
|
2005-05-14 17:22:26 +04:00
|
|
|
|
2005-12-02 18:42:28 +03:00
|
|
|
status_t
|
|
|
|
ServerApp::_CreateWindow(int32 code, BPrivate::LinkReceiver& link,
|
|
|
|
port_id& clientReplyPort)
|
|
|
|
{
|
|
|
|
// Attached data:
|
|
|
|
// 1) int32 bitmap token (only for AS_CREATE_OFFSCREEN_WINDOW)
|
|
|
|
// 2) BRect window frame
|
|
|
|
// 3) uint32 window look
|
|
|
|
// 4) uint32 window feel
|
|
|
|
// 5) uint32 window flags
|
|
|
|
// 6) uint32 workspace index
|
|
|
|
// 7) int32 BHandler token of the window
|
|
|
|
// 8) port_id window's reply port
|
|
|
|
// 9) port_id window's looper port
|
|
|
|
// 10) const char * title
|
|
|
|
|
|
|
|
BRect frame;
|
|
|
|
int32 bitmapToken;
|
|
|
|
uint32 look;
|
|
|
|
uint32 feel;
|
|
|
|
uint32 flags;
|
|
|
|
uint32 workspaces;
|
|
|
|
int32 token;
|
|
|
|
port_id looperPort;
|
|
|
|
char* title;
|
|
|
|
|
|
|
|
if (code == AS_CREATE_OFFSCREEN_WINDOW)
|
|
|
|
link.Read<int32>(&bitmapToken);
|
|
|
|
|
|
|
|
link.Read<BRect>(&frame);
|
|
|
|
link.Read<uint32>(&look);
|
|
|
|
link.Read<uint32>(&feel);
|
|
|
|
link.Read<uint32>(&flags);
|
|
|
|
link.Read<uint32>(&workspaces);
|
|
|
|
link.Read<int32>(&token);
|
|
|
|
link.Read<port_id>(&clientReplyPort);
|
|
|
|
link.Read<port_id>(&looperPort);
|
|
|
|
if (link.ReadString(&title) != B_OK)
|
|
|
|
return B_ERROR;
|
|
|
|
|
|
|
|
if (!frame.IsValid()) {
|
|
|
|
// make sure we pass a valid rectangle to ServerWindow
|
|
|
|
frame.right = frame.left + 1;
|
|
|
|
frame.bottom = frame.top + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t status = B_ERROR;
|
|
|
|
ServerWindow *window = NULL;
|
|
|
|
|
|
|
|
if (code == AS_CREATE_OFFSCREEN_WINDOW) {
|
|
|
|
ServerBitmap* bitmap = FindBitmap(bitmapToken);
|
|
|
|
|
|
|
|
if (bitmap != NULL) {
|
2006-12-18 08:22:13 +03:00
|
|
|
window = new (nothrow) OffscreenServerWindow(title, this, clientReplyPort,
|
2005-12-02 18:42:28 +03:00
|
|
|
looperPort, token, bitmap);
|
|
|
|
}
|
|
|
|
} else {
|
2006-12-18 08:22:13 +03:00
|
|
|
window = new (nothrow) ServerWindow(title, this, clientReplyPort, looperPort, token);
|
2005-12-02 18:42:28 +03:00
|
|
|
STRACE(("\nServerApp %s: New Window %s (%g:%g, %g:%g)\n",
|
2006-04-06 14:02:17 +04:00
|
|
|
Signature(), title, frame.left, frame.top,
|
2005-12-02 18:42:28 +03:00
|
|
|
frame.right, frame.bottom));
|
|
|
|
}
|
|
|
|
|
|
|
|
free(title);
|
|
|
|
|
|
|
|
// NOTE: the reply to the client is handled in ServerWindow::Run()
|
|
|
|
if (window != NULL) {
|
|
|
|
status = window->Init(frame, (window_look)look, (window_feel)feel,
|
|
|
|
flags, workspaces);
|
2006-03-11 22:39:03 +03:00
|
|
|
if (status == B_OK && !window->Run()) {
|
2006-04-22 02:43:23 +04:00
|
|
|
fprintf(stderr, "ServerApp::_CreateWindow() - failed to run the window thread\n");
|
2005-12-02 18:42:28 +03:00
|
|
|
status = B_ERROR;
|
2006-03-11 22:39:03 +03:00
|
|
|
}
|
2005-12-02 18:42:28 +03:00
|
|
|
|
2006-04-22 02:43:23 +04:00
|
|
|
if (status < B_OK)
|
2005-12-02 18:42:28 +03:00
|
|
|
delete window;
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-22 02:43:23 +04:00
|
|
|
bool
|
|
|
|
ServerApp::AddWindow(ServerWindow* window)
|
|
|
|
{
|
|
|
|
BAutolock locker(fWindowListLock);
|
|
|
|
|
|
|
|
return fWindowList.AddItem(window);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-23 22:48:10 +04:00
|
|
|
void
|
|
|
|
ServerApp::RemoveWindow(ServerWindow* window)
|
|
|
|
{
|
|
|
|
BAutolock locker(fWindowListLock);
|
|
|
|
|
|
|
|
fWindowList.RemoveItem(window);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-02 18:42:28 +03:00
|
|
|
bool
|
2005-12-09 16:17:43 +03:00
|
|
|
ServerApp::InWorkspace(int32 index) const
|
2005-12-02 18:42:28 +03:00
|
|
|
{
|
|
|
|
BAutolock locker(fWindowListLock);
|
|
|
|
|
|
|
|
// we could cache this, but then we'd have to recompute the cached
|
|
|
|
// value everytime a window has closed or changed workspaces
|
|
|
|
|
2005-12-09 16:17:43 +03:00
|
|
|
// TODO: support initial application workspace!
|
|
|
|
|
2005-12-02 18:42:28 +03:00
|
|
|
for (int32 i = fWindowList.CountItems(); i-- > 0;) {
|
2006-06-20 03:42:22 +04:00
|
|
|
ServerWindow* serverWindow = fWindowList.ItemAt(i);
|
|
|
|
|
|
|
|
const WindowLayer* window = serverWindow->Window();
|
|
|
|
if (window == NULL || window->IsOffscreenWindow())
|
|
|
|
continue;
|
2005-12-02 18:42:28 +03:00
|
|
|
|
2005-12-09 16:17:43 +03:00
|
|
|
// only normal and unhidden windows count
|
2005-12-02 18:42:28 +03:00
|
|
|
|
2006-06-20 03:42:22 +04:00
|
|
|
if (window->IsNormal() && !window->IsHidden() && window->InWorkspace(index))
|
2005-12-02 18:42:28 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-09 16:17:43 +03:00
|
|
|
uint32
|
|
|
|
ServerApp::Workspaces() const
|
|
|
|
{
|
|
|
|
uint32 workspaces = 0;
|
|
|
|
|
|
|
|
BAutolock locker(fWindowListLock);
|
|
|
|
|
|
|
|
// we could cache this, but then we'd have to recompute the cached
|
|
|
|
// value everytime a window has closed or changed workspaces
|
|
|
|
|
|
|
|
for (int32 i = fWindowList.CountItems(); i-- > 0;) {
|
2006-06-20 03:42:22 +04:00
|
|
|
ServerWindow* serverWindow = fWindowList.ItemAt(i);
|
|
|
|
|
|
|
|
const WindowLayer* window = serverWindow->Window();
|
|
|
|
if (window == NULL || window->IsOffscreenWindow())
|
|
|
|
continue;
|
2005-12-09 16:17:43 +03:00
|
|
|
|
|
|
|
// only normal and unhidden windows count
|
|
|
|
|
2006-06-20 03:42:22 +04:00
|
|
|
if (window->IsNormal() && !window->IsHidden())
|
|
|
|
workspaces |= window->Workspaces();
|
2005-12-09 16:17:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: add initial application workspace!
|
|
|
|
return workspaces;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-14 17:22:26 +04:00
|
|
|
int32
|
|
|
|
ServerApp::CountBitmaps() const
|
|
|
|
{
|
2005-06-23 21:40:35 +04:00
|
|
|
return fBitmapList.CountItems();
|
2005-05-14 17:22:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-12 17:29:59 +03:00
|
|
|
/*!
|
|
|
|
\brief Looks up a ServerApp's ServerBitmap in its list
|
|
|
|
\param token ID token of the bitmap to find
|
|
|
|
\return The bitmap having that ID or NULL if not found
|
|
|
|
*/
|
offscreen bitmaps work, tested on Haiku as well, supports all colorspaces that BBitmap::ImportBits() supports. It uses a fallback for non-B_RGB(A)32 bitmaps. Added support for B_SUB_PIXEL_PRECISION view flags, though it is a bit hacky, since I had to add it to LayerData, even though it is not a true part of stack data. Added Layer::SetFlags() to enforce code path and update fLayerData. Cleaned up DisplayDriverPainter and DisplayDriver API (changed some const BRect& rect to simply BRect rect in order to be able to reuse it in the code), moved Painter.h, the test environment only draws the changed part of the frame buffer again - this causes a lot less CPU overhead, Painter special cases stroke width of 1.0 to use square caps, which is similar to R5 implementation and removes a lot of problems with non-straight line drawing, ServerWindow uses the DisplayDriver from it's WinBorder instead of the one from the Desktop (needed for offscreen windows, which have their own DisplayDriverPainter), it also checks for GetRootLayer() == NULL, because offscreen layers are not attached to a RootLayer, there was a fix for scrolling which worked at least in the test environment, it is now defunced, because Adi moved _CopyBits to Layer... I need to reenable it later, LayerData has no more fEscapementDelta, also fixed fFontAliasing (which was thought to overriding the font flags, and now works as such again), Desktop initialises the menu_info and scroll_bar_info stuff, which makes ScrollBars work actually... hope I didn't forget something.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13448 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-07-05 20:17:16 +04:00
|
|
|
ServerBitmap*
|
2005-05-08 10:06:55 +04:00
|
|
|
ServerApp::FindBitmap(int32 token) const
|
2003-03-12 17:29:59 +03:00
|
|
|
{
|
2005-11-14 22:46:20 +03:00
|
|
|
// TODO: we need to make sure the bitmap is ours?!
|
|
|
|
ServerBitmap* bitmap;
|
|
|
|
if (gTokenSpace.GetToken(token, kBitmapToken, (void**)&bitmap) == B_OK)
|
|
|
|
return bitmap;
|
2006-04-23 18:28:48 +04:00
|
|
|
|
2003-03-12 17:29:59 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-09-17 23:28:31 +04:00
|
|
|
|
2005-05-07 19:56:15 +04:00
|
|
|
|
2005-05-14 17:22:26 +04:00
|
|
|
int32
|
|
|
|
ServerApp::CountPictures() const
|
|
|
|
{
|
2005-06-23 21:40:35 +04:00
|
|
|
return fPictureList.CountItems();
|
2005-05-14 17:22:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ServerPicture *
|
2006-01-04 12:49:47 +03:00
|
|
|
ServerApp::CreatePicture(const ServerPicture *original)
|
2006-01-03 11:08:20 +03:00
|
|
|
{
|
2006-01-04 12:49:47 +03:00
|
|
|
ServerPicture *picture;
|
|
|
|
if (original != NULL)
|
|
|
|
picture = new (nothrow) ServerPicture(*original);
|
|
|
|
else
|
|
|
|
picture = new (nothrow) ServerPicture();
|
|
|
|
|
|
|
|
if (picture != NULL)
|
2006-01-03 11:08:20 +03:00
|
|
|
fPictureList.AddItem(picture);
|
2006-01-03 15:44:29 +03:00
|
|
|
|
2006-01-03 11:08:20 +03:00
|
|
|
return picture;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ServerPicture *
|
|
|
|
ServerApp::FindPicture(const int32 &token) const
|
2005-05-14 17:22:26 +04:00
|
|
|
{
|
2005-11-14 22:46:20 +03:00
|
|
|
// TODO: we need to make sure the picture is ours?!
|
|
|
|
ServerPicture* picture;
|
|
|
|
if (gTokenSpace.GetToken(token, kPictureToken, (void**)&picture) == B_OK)
|
|
|
|
return picture;
|
|
|
|
|
2005-05-14 17:22:26 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-03 11:08:20 +03:00
|
|
|
|
|
|
|
bool
|
|
|
|
ServerApp::DeletePicture(const int32 &token)
|
|
|
|
{
|
|
|
|
ServerPicture *picture = FindPicture(token);
|
|
|
|
if (picture == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!fPictureList.RemoveItem(picture))
|
|
|
|
return false;
|
2005-05-14 17:22:26 +04:00
|
|
|
|
2006-01-03 11:08:20 +03:00
|
|
|
delete picture;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-07 19:56:15 +04:00
|
|
|
team_id
|
2005-06-23 21:40:35 +04:00
|
|
|
ServerApp::ClientTeam() const
|
2004-01-20 01:18:37 +03:00
|
|
|
{
|
2005-06-23 21:40:35 +04:00
|
|
|
return fClientTeam;
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
2004-07-30 19:16:59 +04:00
|
|
|
|