1/*
2 * Copyright (c) 2001-2005, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
4 *
5 * Author: DarkWyrm <bpmagic@columbus.rr.com>
6 */
7#ifndef	_HAIKU_APP_SERVER_H_
8#define	_HAIKU_APP_SERVER_H_
9
10#include <OS.h>
11#include <Locker.h>
12#include <List.h>
13#include <Application.h>
14#include <Window.h>
15#include <String.h>
16
17#include "ServerConfig.h"
18
19class Layer;
20class BMessage;
21class ServerApp;
22class DisplayDriver;
23class CursorManager;
24class BitmapManager;
25
26namespace BPrivate {
27	class PortLink;
28};
29
30/*!
31	\class AppServer AppServer.h
32	\brief main manager object for the app_server
33
34	File for the main app_server thread. This particular thread monitors for
35	application start and quit messages. It also starts the housekeeping threads
36	and initializes most of the server's globals.
37*/
38
39class AppServer {
40public:
41	AppServer(void);
42	~AppServer(void);
43
44	static	int32 PollerThread(void *data);
45	static	int32 PicassoThread(void *data);
46	thread_id Run(void);
47	void MainLoop(void);
48
49	bool LoadDecorator(const char *path);
50	void InitDecorators(void);
51
52	void DispatchMessage(int32 code, BPrivate::PortLink &link);
53	void Broadcast(int32 code);
54
55	ServerApp* FindApp(const char *sig);
56
57private:
58	void LaunchCursorThread();
59	void LaunchInputServer();
60
61	port_id	fMessagePort;
62	port_id	fServerInputPort;
63
64	volatile bool fQuittingServer;
65
66	BList *fAppList;
67	thread_id fPicassoThreadID;
68
69	thread_id fISThreadID;
70	thread_id fCursorThreadID;
71	sem_id fCursorSem;
72	area_id	fCursorArea;
73	uint32 *fCursorAddr;
74
75	port_id fISASPort;
76	port_id fISPort;
77
78	sem_id 	fActiveAppLock,
79			fAppListLock,
80			fDecoratorLock;
81
82	DisplayDriver *fDriver;
83};
84
85extern BitmapManager *bitmapmanager;
86extern AppServer *app_server;
87extern port_id gAppServerPort;
88
89#endif	/* _HAIKU_APP_SERVER_H_ */
90