From fb4972044608c6e75e9a35d0cb2c6db5645892f4 Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Mon, 2 Sep 2002 00:14:11 +0000 Subject: [PATCH] Initial checkin git-svn-id: file:///srv/svn/repos/haiku/trunk/current@955 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- docs/develop/servers/app_server/AppServer.htm | 567 ++++++++++++++++++ .../servers/app_server/BitmapManager.htm | 123 ++++ .../develop/servers/app_server/ColorUtils.htm | 123 ++++ .../servers/app_server/CursorManager.htm | 179 ++++++ .../develop/servers/app_server/DebugTools.htm | 50 ++ docs/develop/servers/app_server/Decorator.htm | 385 ++++++++++++ .../servers/app_server/DisplayDriver.htm | 202 +++++++ .../servers/app_server/PatternHandler.htm | 118 ++++ docs/develop/servers/app_server/RGBColor.htm | 189 ++++++ docs/develop/servers/app_server/ServerApp.htm | 330 ++++++++++ .../servers/app_server/ServerBitmap.htm | 118 ++++ .../servers/app_server/SystemPalette.htm | 249 ++++++++ docs/develop/servers/app_server/asis.htm | 271 +++++++++ docs/develop/servers/app_server/toc.htm | 40 ++ 14 files changed, 2944 insertions(+) create mode 100644 docs/develop/servers/app_server/AppServer.htm create mode 100644 docs/develop/servers/app_server/BitmapManager.htm create mode 100644 docs/develop/servers/app_server/ColorUtils.htm create mode 100644 docs/develop/servers/app_server/CursorManager.htm create mode 100644 docs/develop/servers/app_server/DebugTools.htm create mode 100644 docs/develop/servers/app_server/Decorator.htm create mode 100644 docs/develop/servers/app_server/DisplayDriver.htm create mode 100644 docs/develop/servers/app_server/PatternHandler.htm create mode 100644 docs/develop/servers/app_server/RGBColor.htm create mode 100644 docs/develop/servers/app_server/ServerApp.htm create mode 100644 docs/develop/servers/app_server/ServerBitmap.htm create mode 100644 docs/develop/servers/app_server/SystemPalette.htm create mode 100644 docs/develop/servers/app_server/asis.htm create mode 100644 docs/develop/servers/app_server/toc.htm diff --git a/docs/develop/servers/app_server/AppServer.htm b/docs/develop/servers/app_server/AppServer.htm new file mode 100644 index 0000000000..4430dcb101 --- /dev/null +++ b/docs/develop/servers/app_server/AppServer.htm @@ -0,0 +1,567 @@ + + +AppServer.htm + + + +
+

AppServer class

+


+

+

The AppServer class sits at the top of the hierarchy, starting and stopping services, monitoring for messages, and so forth.

+


+
+


+

+


+Member Functions

+


+

+ + + + + + + + + + + + + + + + + + + + + +
+

AppServer(void)

+
+

~AppServer(void)

+
+

static int32 Poller(void *data)

+
+

static int32 Picasso(void *data)

+
+

thread_id Run(void)

+
+

void MainLoop(void)

+
+

bool LoadDecorator(const char *path)

+
+

void DispatchMessage(int32 code, int8 *buffer)

+
+

void Broadcast(int32 code)

+
+

void HandleKeyMessage(int32 code, int8 *buffer)

+
+


+
+Global Functions

+


+Decorator * instantiate_decorator(Layer *owner, uint32 wflags, uint32 wlook)

+


+
+


+

+

AppServer(void)

+


+Create the message and input ports

+

Create any necessary semaphores for regulating the 3 main threads

+

Initialize all member variables

+

Allocate the application BList

+

Read in and process all configuration data

+

Initialize the desktop

+

Spawn the Picasso and Poller threads

+


+
+~AppServer(void)

+


+Shut down the desktop

+

Empty and delete the application list

+

Wait for Picasso and Poller to exit

+

Free any allocated heap space

+


+
+void MainLoop(void)

+


+MainLoop is one large loop used to monitor the main message port in the app_server thread. This is a standard port-monitoring loop code:

+


+1) Call port_buffer_size - which will block if the port is empty

+

2) Allocate a buffer on the heap if the port buffer size is greater than 0

+

3) Read the port

+

4) Pass specified messages to DispatchMessage() for processing, spitting out an error message to stderr if the message's code is unrecognized

+

5) Return from DispatchMessage() and free the message buffer if one was allocated

+

6) If the message code matches the B_QUIT_REQUESTED definition and the quit_server flag is true, fall out of the infinite message-monitoring loop

+


+
+void DispatchMessage(int32 code, int8 *buffer)

+


+DispatchMessage implements all the code necessary to respond to a given message sent to the app_server on its main port. This allows for clearer and more manageable code.

+


+CREATE_APP:

+


+Sent by a new BApplication object via synchronous PortLink messaging. Set up the corresponding ServerApp and reply to the BApplication with the new port to which it will send future communications with the App Server.

+


+Attached Data:

+


+

+

+ + + + + + + + + + + + + +
+

port_id reply_port

+
+

port to which the server is to reply in response to the current message

+
+

port_id app_port

+
+

message port for the requesting BApplication

+
+

const char *signature

+
+

Signature of the requesting BApplication

+
+


+

+


+1) Get all attached data

+

2) Acquire the application list lock

+

3) Allocate a ServerApp object and add it to the list

+

4) Release application list lock

+

5) Acquire active application pointer lock

+

6) Update active application pointer

+

7) Release active application lock

+

8) Send the message SET_SERVER_PORT (with the ServerApp's receiver port attached) to the reply port

+

9) Run() the new ServerApp instance

+


+
+DELETE_APP:

+


+Sent by a ServerApp when told to quit either by its BApplication or the Server itself (during shutdown). It is identified by the unique ID assigned to its thread.

+


+Attached Data:

+


+

+

+ + + + + +
+

thread_id app_thread

+
+

Thread id of the ServerApp sending this message

+
+


+

+


+1) Get app's thread_id

+

2) Acquire application list lock

+

3) Iterate through the application list, searching for the ServerApp object with the sent thread_id

+

4) Remove the object from the list and delete it

+

5) Acquire active application lock

+

6) Check to see if the application is active

+

7) If application is/was active, set it to the previous application in the list or NULL if there are no other active applications

+

8) Release application list lock

+

9) Release active application lock

+


+
+GET_SCREEN_MODE:

+


+Received from the OpenBeOS Input Server when requesting the current screen settings via synchronous PortLink messaging. This is a temporary solution which will be deprecated as soon as the BScreen class is complete.

+


+

+

Attached Data:

+


+

+

+ + + + + +
+

port_id reply_port

+
+

port to which the server is to reply in response to the current message

+
+


+

+


+1) Get height, width, and color depth from the global graphics driver object

+

2) Attach via PortLink and reply to sender

+


+B_QUIT_REQUESTED:

+


+Encountered only under testing situations where the Server is told to quit.

+


+Attached Data: None

+


+1) Set quit_server flag to true

+

2) Call Broadcast(QUIT_APP)

+


+
+SET_DECORATOR:

+


+Received from just about anything when a new window decorator is chosen

+


+

+

Attached Data:

+


+

+

+ + + + + +
+

const char *path

+
+

Path to the proposed new decorator

+
+


+

+


+1) Get the path from the buffer

+

2) Call LoadDecorator()

+


+
+void Run(void)

+


+Run() exists mostly for consistency with other regular applications.

+


+1) Call MainLoop()

+


+
+bool LoadDecorator(const char *path)

+


+Allows for a simple way to change the current window decorator systemwide simply by specifying the path to the desired Decorator addon.

+


+1) Load the passed string as the path to an addon.

+

2) Load all necessary symbols for the decorator

+

3) Return false if things didn't go so well

+

4) Call Broadcast(UPDATE_DECORATOR)

+

5) Return true

+


+static int32 Picasso(void *data)

+


+Picasso is a function, despite its name, dedicated to ensuring that the server deallocates resources to a dead application. It consists of a while(!quit_server) loop as follows:

+


+1) Acquire the appliction list lock

+

2) Iterate through the list, calling each ServerApp object's PingTarget() method.

+

3) If PingTarget returns false, remove the ServerApp from the list and delete it.

+

4) Release the appliction list lock

+

5) snooze for 3 seconds

+


+static int32 Poller(void *data)

+


+Poller is the main workhorse of the AppServer class, polling the Server's input port constantly for any messages from the Input Server and calling the appropriate handlers. Like Picasso, it, too, is mostly a while(!quit_server) loop.

+


+

+

1) Call port_buffer_size_etc() with a timeout of 3 seconds.

+

2) Check to see if the port_buffer_size_etc() timed out and do a continue to next iteration if it did.

+

3) Allocate a buffer on the heap if the port buffer size is greater than 0

+

4) Read the port

+

5) Pass specified messages to DispatchMessage() for processing, spitting out an error message to stderr if the message's code is unrecognized

+

6) Return from DispatchMessage() and free the message buffer if one was allocated

+


+
+


+

+

Decorator * instantiate_decorator(Layer *owner, uint32 wflags, uint32 wlook)

+


+instantiate_decorator returns a new instance of the decorator currently in use. The caller is responsible for the memory allocated for the returned object.

+


+1) Acquire the decorator lock

+

2) If create_decorator is NULL, create a new instance of the default decorator

+

3) If create_decorator is non-NULL, create a new decorator instance by calling AppServer::create_decorator().

+

4) Release the decorator lock

+

5) Return the newly allocated instance

+


+void Broadcast(int32 code)

+


+Broadcast() provides the AppServer class with an easy way to send a quick message to all ServerApps. Primarily, this is called when a font or decorator has changed, or when the server is shutting down. It is not intended to do anything except send a quick message which requires no extra data, such as for some upadate signalling.

+


+

+

1) Acquire application list lock

+

2) Create a PortLink instance and set its message code to the passed parameter.

+

3) Iterate through the application list, targeting the PortLink instance to each ServerApp's message port and calling Flush().

+

4) Release application list lock

+


+void HandleKeyMessage(int32 code, int8 *buffer)

+


+

+

Called from DispatchMessage to filter out App Server events and otherwise send keystrokes to the active application.

+


+B_KEY_DOWN:

+


+Sent when the user presses (or holds down) a key that's been mapped to a character.

+


+Attached Data:

+


+

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

int64 when

+
+

event time in seconds since 1/1/70

+
+

int32 rawcode

+
+

code for the physical key pressed

+
+

int32 repeat_count

+
+

number of times a key has been repeated

+
+

int32 modifiers

+
+

flags signifying the states of the modifier keys

+
+

int32 state_count

+
+

number of bytes to follow containing the state of all keys

+
+

int8 *states

+
+

array of the state of all keys at the time of the event

+
+

int8 utf8data[3]

+
+

UTF-8 data generated

+
+

int8 charcount

+
+

number of bytes to follow containing the string generated (usually 1)

+
+

const char *string

+
+

null-terminated string generated by the keystroke

+
+

int32 raw_char

+
+

modifier-independent ASCII code for the character

+
+


+

+


+1) Get all attached data

+

2) If the command modifier is down, check for Left Ctrl+Left Alt+Left Shift+F12 and reset the workspace to 640 x 480 x 256 @ 60Hz and return if true

+

3) If the command modifier is down, check for Alt+F1 through Alt+F12 and set workspace and return if true

+

4) If the control modifier is true, check for B_CONTROL_KEY+Tab and, if true, find and send to the Deskbar.

+

4) Acquire the active application lock

+

5) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_KEY_DOWN, attach the buffer en masse, and send it to the BApplication.

+

6) Release the active application lock

+


+

+

B_KEY_UP:

+


+

+

Sent when the user releases a key that's been mapped to a character.

+


+Attached Data:

+


+

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

int64 when

+
+

event time in seconds since 1/1/70

+
+

int32 rawcode

+
+

code for the physical key pressed

+
+

int32 modifiers

+
+

flags signifying the states of the modifier keys

+
+

int32 state_count

+
+

number of bytes to follow containing the state of all keys

+
+

int8 *states

+
+

array of the state of all keys at the time of the event

+
+

int8 utf8data[3]

+
+

UTF-8 data generated

+
+

int8 charcount

+
+

number of bytes to follow containing the string generated (usually 1)

+
+

const char *string

+
+

null-terminated string generated by the keystroke

+
+

int32 raw_char

+
+

modifier-independent ASCII code for the character

+
+


+

+


+1) Get all attached data

+

2) Acquire the active application lock

+

3) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_KEY_UP, attach the buffer en masse, and send it to the BApplication.

+

4) Release the active application lock

+


+B_UNMAPPED_KEY_DOWN:

+


+

+

Sent when the user presses a key that has not been mapped to a character.

+


+Attached Data:

+


+

+

+ +
+


+

+


+1) Acquire the active application lock

+

2) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_UNMAPPED_KEY_DOWN, attach the buffer en masse, and send it to the BApplication.

+

3) Release the active application lock

+


+B_UNMAPPED_KEY_UP:

+


+

+

Sent when the user presses a key that has not been mapped to a character.

+


+Attached Data:

+


+

+

?

+


+1) Acquire the active application lock

+

2) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_UNMAPPED_KEY_UP, attach the buffer en masse, and send it to the BApplication.

+

3) Release the active application lock

+


+

+

B_MODIFIERS_CHANGED:

+


+

+

Sent when the user presses or releases one of the modifier keys

+


+Attached Data:

+


+

+

?

+


+1) Acquire the active application lock

+

2) Create a PortLink instance, target the active ServerApp's sender port, set the opcode to B_MODIFIERS_CHANGED, attach the buffer en masse, and send it to the BApplication.

+

3) Release the active application lock

+
+ + diff --git a/docs/develop/servers/app_server/BitmapManager.htm b/docs/develop/servers/app_server/BitmapManager.htm new file mode 100644 index 0000000000..f8ed7a09e8 --- /dev/null +++ b/docs/develop/servers/app_server/BitmapManager.htm @@ -0,0 +1,123 @@ + + +BitmapManager.htm + + + +
+

BitmapManager class

+


+

+

The BitmapManager object handles all ServerBitmap allocation and deallocation. The rest of the server uses CreateBitmap and DeleteBitmap instead of new and delete. It utilizes the outside pool manager BGET.

+


+
+


+

+


+Member Functions

+


+

+ + + + + + + + + +
+

BitmapManager(void)

+
+

~BitmapManager(void)

+
+

ServerBitmap *CreateBitmap(BRect bounds, color_space space, int32 flags, int32 bytes_per_row=-1, screen_id screen=B_MAIN_SCREEN_ID)

+
+

void DeleteBitmap(ServerBitmap *bitmap)

+
+


+
+Global Functions

+


+extern "C" void set_area_buffer_management(void);

+

void * expand_area_storage(long size)

+

void contract_area_storage(void *buffer)

+


+


+

+

BitmapManager(void)

+


+1) Create the bitmap list

+

2) Create the bitmap area

+

3) Allocate the access semaphore

+

4) Call set_buffer_area_management

+

5) Set up the buffer pool via bpool

+


+~BitmapManager(void)

+


+1) Iterate over each item in the bitmap list, removing each item, calling brel() on its buffer, and deleting it.

+

2) Delete the bitmap list

+

3) Delete the bitmap area

+

4) Free the access semaphore

+


+ServerBitmap *CreateBitmap(BRect bounds, color_space space, int32 flags, int32 bytes_per_row=-1, screen_id screen=B_MAIN_SCREEN_ID)

+


+CreateBitmap is called by outside objects to allocate a ServerBitmap object. If a problem occurs, it returns NULL.

+


+1) Acquire the access semaphore

+

2) Verify parameters and if any are invalid, spew an error to stderr and return NULL

+

3) Allocate a new ServerBitmap

+

4) Allocate a buffer for the bitmap via bget() with the bitmap's theoretical buffer length

+

5) If NULL, delete the bitmap and return NULL

+

6) Set the bitmap's area and buffer to the appropriate values (area_for buffer and buffer)

+

7) Add the bitmap to the bitmap list

+

8) Release the access semaphore

+

9) Return the bitmap

+


+void DeleteBitmap(ServerBitmap *bitmap)

+


+Frees a ServerBitmap allocated by CreateBitmap()

+


+1) Acquire the access semaphore

+

2) Find the bitmap in the list

+

3) Remove the bitmap from the list or release the semaphore and return if not found

+

4) call brel() on the bitmap's buffer if it is non-NULL

+

5) delete the bitmap

+

6) Release the access semaphore

+


+
extern "C" void set_area_buffer_management(void)

+


+C function defined externally to point the BGET manager to our homegrown area allocation and deallocation functions.

+


+
void * expand_area_storage(long size)

+


+"Internal" global function accessed only by set_area_buffer_management and BGET to handle the task of adding more area space to make room for more bitmaps.

+


+1) If size is less than B_PAGE_SIZE, set the area size to B_PAGE_SIZE

+

2) If size % B_PAGE_SIZE, set area size to (size/B_PAGE_SIZE)+1)*B_PAGE_SIZE, otherwise setting it to the given size

+

3) Call create_area with the area size.

+

4) If it couldn't allocate an area, write a panic message to stderr and return NULL, otherwise, return the pointer to the area.

+


+void contract_area_storage(void *buffer)

+


+
"Internal" global function accessed only by set_area_buffer_management and BGET to remove the area which was previously used for the bitmap pool

+


+1) Call area_for on the buffer

+

2) If the area_id is not B_ERROR, call delete_area on its area_id.

+
+
+
+ + diff --git a/docs/develop/servers/app_server/ColorUtils.htm b/docs/develop/servers/app_server/ColorUtils.htm new file mode 100644 index 0000000000..72d1e407b3 --- /dev/null +++ b/docs/develop/servers/app_server/ColorUtils.htm @@ -0,0 +1,123 @@ + + +ColorUtils.htm + + + +
+

ColorUtils

+


+

+

These functions are used for general purpose color-related tasks.

+


+
+


+

+

Global Functions

+


+void SetRGBColor32(rgb_color *col, uint8 r, uint8 g, uint8 b, uint8 a=255)

+

void SetRGBAColor32(rgb_color *col, uint16 color16)

+

void SetRGBColor16(uint16 *col, uint8 r, uint8 g, uint8 b)

+

void SetRGBAColor15(uint16 *col, uint8 r, uint8 g, uint8 b, bool opaque=true)

+


+uint8 FindClosestColor(rgb_color *palette,rgb_color col)

+

uint16 FindClosestColor16(rgb_color col)

+

uint16 FindClosestColor15(rgb_color col)

+


+rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position)

+


+


+

+

void SetRGBColor32(rgb_color *col, uint8 r, uint8 g, uint8 b, uint8 a=255)

+


+Simply assigns the passed parameters to the internal members of the passed color

+


+
+void SetRGBAColor32(rgb_color *col, uint16 color16)

+


+Maps a 16-bit color to a 32-bit one.

+


+gggbbbbb arrrrrgg

+

1) Extract component values using the following calculations:

+


+ red16 = (uint8[1] & 124) >> 2

+


+ green16 = ((uint8[0] & 224) >> 5) | ((uint8[1] & 3) << 3)

+


+ blue16 = uint8[0] & 31

+

2) Use cross-multiplication to map each 16-bit color component from 0-31 space to 0-255 space, i.e. red32 = (red16 / 31) * 255

+

3) Assign mapped values to the rgb_color passed to the function

+


+
+void SetRGBColor16(uint16 *col, uint8 r, uint8 g, uint8 b)

+


+Used for easy assignment of opaque (B_RGB16) 16-bit colors.

+


+1) Clip parameters via a bitwise AND with 31 (var &=31)

+

2) Create a uint8 * to the passed color

+

3) Assign as follows and return:

+

a) uint8[0] = ( (g & 7) << 5) | (b & 31)

+

b) uint8[1] = ( (r & 31) << 3) | ( (g & 56) >> 3)

+


+
+void SetRGBAColor15(uint16 *col, uint8 r, uint8 g, uint8 b, bool opaque=true)

+


+Used for easy assignment of alpha-aware (B_RGBA16) 16-bit colors.

+


+1) Clip parameters via a bitwise AND with 31 (var &=31)

+

2) Create a uint8 * to the passed color

+

3) Assign as follows and return:

+

a) uint8[0] = ( (g & 7) << 5) | (b & 31)

+

b) uint8[1] = ( (r & 31) << 2) | ( (g & 24) >> 3) | (a) ? 128 : 0

+


+
+uint8 FindClosestColor(rgb_color *palette,rgb_color col)

+


+Finds the color which most closely resembles the given one in the given palette.

+


+1) Set the saved delta value to 765 (maximum difference)

+

2) Loop through all the colors in the palette. For each color,

+

a) calculate the delta value for each color component and add them together

+

b) compare the new combined delta with the saved one

+

c) if the delta is 0, immediately return the current index

+

d) if the new one is smaller, save it and also the palette index

+


+
+uint16 FindClosestColor16(rgb_color col)

+


+Returns a 16-bit approximation of the given 32-bit color. Alpha values are ignored.

+

1) Create an opaque, 16-bit approximation of col using the following calculations:

+

r16=(31*col.red)/255

+

g16=(31*col.green)/255

+

b16=(31*col.blue)/255

+

2) Assign it to a uint16 using the same code as in SetRGBColor16() and return it.

+


+
+uint16 FindClosestColor15(rgb_color col)

+


+This functions almost exactly like the 16-bit version, but this also takes into account the alpha transparency bit and works in the color space B_RGBA15. Follow the same algorithm as FindClosestColor16(), but assign the return value using SetRGBColor15.

+


+
+rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position)

+


+MakeBlendColor calculates a color that is somewhere between start color col and end color col2, based on position, where 0<= position <= 1. If position is out of these bounds, a color of {0,0,0,0} is returned. If position is 0, the start color is returned. If position is 1, col2 is returned. Otherwise, the color is calculated thus:

+


+1) calculate delta values for each channel, i.e. int16 delta_r=col.red-col2.red

+

2) Based on these delta values, calculate the blend values for each channel, i.e. blend_color.red=uint8(col1.red - (delta_r * position) )

+
+
+
+ + diff --git a/docs/develop/servers/app_server/CursorManager.htm b/docs/develop/servers/app_server/CursorManager.htm new file mode 100644 index 0000000000..366e47585d --- /dev/null +++ b/docs/develop/servers/app_server/CursorManager.htm @@ -0,0 +1,179 @@ + + +CursorManager.htm + + + +
+

CursorManager class

+


+

+

The CursorManager class handles token creation, calling the cursor-related graphics driver functions, and freeing heap memory for all ServerCursor instances.

+


+
+


+

+


+Member Functions

+


+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+

CursorManager(void)

+
+

~CursorManager(void)

+
+

int32 AddCursor(ServerCursor *c)

+
+

void DeleteCursor(int32 token)

+
+

void RemoveAppCursors(ServerApp *a)

+
+

void ShowCursor(void)

+
+

void HideCursor(void)

+
+

void ObscureCursor(void)

+
+

void SetCursor(int32 token)

+
+

ServerCursor *GetCursor(cursor_which which)

+
+

void SetCursor(cursor_which which)

+
+

void ChangeCursor(cursor_which which,

+

int32 token)

+
+


+
+


+

+

CursorManager(void)

+


+
+1) Create the cursor list empty

+

2) Set the token index to 0

+

3) Allocate the default system cursor and pass it to AddCursor

+

4) Initialize the member pointer for the graphics driver

+

5) Create the cursorlock semaphore

+

6) Call SetDefaultCursor

+


+
+~CursorManager(void)

+


+1) Empty and delete the cursor list

+

2) Delete the cursorlock semaphore

+


+
+int32 AddCursor(ServerCursor *sc)

+


+AddCursor() is used to register the cursor in question with the manager, allowing for the user application to have the identifying token, if necessary. The cursor becomes the property of the manager. If a user application deletes a BCursor, its ServerApp will call DeleteCursor().

+


+1) Acquire cursor lock

+

2) Add *sc to the cursor list

+

3) Set sc->token to the current token index value

+

4) Increment the token index

+

5) Assign sc->token to temporary variable

+

6) Release cursor lock

+

7) Return the saved token value

+


+
+void DeleteCursor(int32 ctoken)

+


+1) Acquire cursor lock

+

2) Iterate through the cursor list, looking for ctoken

+

3) If any ServerCursor->token equals ctoken, remove and delete it

+

4) Release cursor lock

+


+
+void RemoveAppCursors(ServerApp *app)

+


+1) Acquire cursor lock

+

2) Iterate through the cursor list, checking each cursor's ServerApp pointer

+

3) If any have a ServerApp pointer which matches the passed pointer, remove and delete them

+

4) Release cursor lock

+


+
+void ShowCursor(void)

+

void HideCursor(void)

+

void ObscureCursor(void)

+


+Simple pass-through functions which call the graphics driver's functions. Note that acquiring the cursor lock will be necessary for all three calls.

+


+
+void SetCursor(int32 token)

+

void SetCursor(cursor_which cursor)

+


+These set the current cursor for the graphics driver to the passed cursor, either one previously added via AddCursor or a system cursor.

+


+1) Acquire cursor lock

+


+Token version:

+

2) Find the cursor in the cursor list and call the graphics driver if non-NULL

+


+cursor_which version:

+

2) determine which cursor to use via a switch statement and call the graphics driver with the internal pointer for the appropriate cursor

+


+3) Release cursor lock

+


+
+ServerCursor *GetCursor(cursor_which which)

+


+GetCursor is intended for use in figuring out what cursor is in use for a particular system cursor.

+


+1) Acquire cursor lock

+

2) use a switch statement to figure which cursor to return and assign a temporary pointer its value

+

3) Release cursor lock

+

4) Return the temporary pointer

+


+
+void ChangeCursor(cursor_which which, int32 token)

+


+Calling ChangeCursor will allow a user to change a system cursor's appearance. Note that in calling this, the cursor changes ownership and belongs to the system. Thus, the BCursor destructor will not ultimately cause the cursor to be deleted.

+


+1) Acquire cursor lock

+

2) Call FindCursor and, if NULL, release the cursor lock and return

+

3) Look up the pointer for the system cursor in question and check to see if it is active. If active, then set the local active flag to true. Set the system cursor pointer to the one looked up.

+

4) If active flag is true, call SetCursor()

+

5) Release cursor lock

+
+
+
+ + diff --git a/docs/develop/servers/app_server/DebugTools.htm b/docs/develop/servers/app_server/DebugTools.htm new file mode 100644 index 0000000000..2045799d71 --- /dev/null +++ b/docs/develop/servers/app_server/DebugTools.htm @@ -0,0 +1,50 @@ + + +DebugTools.htm + + + +
+

DebugUtils

+


+

+

These functions are used to make print-based debugging easier.

+


+
+


+

+

Global Functions

+


+BString TranslateStatusToBString(status_t value)

+

BString TranslateColorSpaceToBString(color_space value)

+

BString TranslateMessageCodeToBString(int32 value)

+


+
+


+

+

BString TranslateStatusToBString(status_t value)

+

BString TranslateColorSpaceToBString(color_space value)

+

BString TranslateMessageCodeToBString(int32 value)

+


+const char * TranslateStatusToString(status_t value)

+

const char * TranslateColorSpaceToString(color_space value)

+

const char * TranslateMessageCodeToString(int32 value)

+


+All of these functions are essentially big switch() statements which assign an appropriate string for the passed parameter and return the assigned string. This way the string can be printed or otherwise easily used.

+
+
+
+ + diff --git a/docs/develop/servers/app_server/Decorator.htm b/docs/develop/servers/app_server/Decorator.htm new file mode 100644 index 0000000000..548e9de689 --- /dev/null +++ b/docs/develop/servers/app_server/Decorator.htm @@ -0,0 +1,385 @@ + + +Decorator.htm + + + +
+

Decorator class

+


+

+

Decorators provide the actual drawing for a window's looks.

+


+
+


+

+


+Member Functions

+


+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Decorator(SRect int32 wlook, int32 wfeel, int32 wflags)

+
+

~Decorator(void)

+
+

void SetColors(color_set colors)

+
+

void SetDriver(DisplayDriver *driver)

+
+

void SetClose(bool is_down)

+
+

void SetMinimize(bool is_down)

+
+

void SetZoom(bool is_down)

+
+

void SetFlags(int32 wflags)

+
+

void SetFeel(int32 wfeel)

+
+

void SetLook(int32 wlook)

+
+

bool GetClose(void)

+
+

bool GetMinimize(void)

+
+

bool GetZoom(void)

+
+

int32 GetLook(void)

+
+

int32 GetFeel(void)

+
+

int32 GetFlags(void)

+
+

void SetTitle(const char *string)

+
+

void SetFont(SFont *sf)

+
+

void _ClipTitle(void)

+
+

void SetFocus(bool is_active)

+
+

bool GetFocus(void)

+
+   +
+


+
+
+Virtual Functions

+


+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

void MoveBy(float x, float y)

+
+

void MoveBy(SPoint pt)

+
+

void ResizeBy(float x, float y)

+
+

void ResizeBy(SPoint pt)

+
+

void Draw(SRect r)

+
+

void Draw(void)

+
+

void DrawClose(void)

+
+

void DrawFrame(void)

+
+

void DrawMinimize(void)

+
+

void DrawTab(void)

+
+

void DrawTitle(void)

+
+

void DrawZoom(void)

+
+

void _DrawClose(SRect r)

+
+

void _DrawFrame(SRect r)

+
+

void _DrawMinimize(SRect r)

+
+

void _DrawTab(SRect r)

+
+

void _DrawTitle(SRect r)

+
+

void _DrawZoom(SRect r)

+
+

SRegion GetFootprint(void)

+
+

click_type Clicked(SPoint pt, int32 buttons, int32 modifiers)

+
+

void _SetFocus(void)

+
+   +
+


+
+_ Indicates a protected member function

+


+Exported C Functions

+


+Decorator *create_decorator(SRect frame, int32 wlook, int32 wfeel, int32 wflags)

+

float get_decorator_version(void)

+


+
+Enumerated Types

+


+click_type {

+

CLICK_NONE

+

CLICK_ZOOM

+

CLICK_CLOSE

+

CLICK_MINIMIZE

+

CLICK_TAB

+

CLICK_MOVE

+

CLICK_MOVETOBACK

+

CLICK_MOVETOFRONT

+

CLICK_RESIZE

+

CLICK_RESIZE_L

+

CLICK_RESIZE_T

+

CLICK_RESIZE_R

+

CLICK_RESIZE_B

+

CLICK_RESIZE_LT

+

CLICK_RESIZE_RT

+

CLICK_RESIZE_LB

+

CLICK_RESIZE_RB

+

}

+


+


+

+

Decorator(SRect int32 wlook, int32 wfeel, int32 wflags)

+


+Sets up internal variables common to all decorators.

+


+1) Assign parameters to respective data members

+


+
+~Decorator(void)

+


+Empty.

+


+void SetColors(color_set colors)

+

void SetDriver(DisplayDriver *driver)

+

void SetClose(bool is_down)

+

void SetMinimize(bool is_down)

+

void SetZoom(bool is_down)

+

void SetFlags(int32 wflags)

+

void SetFeel(int32 wfeel)

+

void SetLook(int32 wlook)

+

bool GetClose(void)

+

bool GetMinimize(void)

+

bool GetZoom(void)

+

int32 GetLook(void)

+

int32 GetFeel(void)

+

int32 GetFlags(void)

+

void SetTitle(const char *string)

+

void SetFont(SFont *sf)

+


+These functions work with the internal members common to all Decorators - assigning them and returning them. Additionally, SetTitle() and SetFont() set the clip_font flag to true.

+


+void ClipTitle(void)

+


+ClipTitle calculates how much of the title will actually be displayed when _DrawTitle() is called.

+


+<To be fleshed out once font subsystem is better understood>

+


+
+void SetFocus(bool is_active)

+


+This is for handling color states when a window receives or loses the focus.

+


+1) Set focus flag to whatever is_active is.

+

2) call hook function _SetFocus()

+


+
+bool GetFocus(void)

+


+Returns the focus state held by the decorator

+


+1) Return the focus flag

+


+
+Virtual Functions

+


+Most of these functions have a default behavior which can be overridden, but are implemented to handle the more common implementations.

+


+void MoveBy(float x, float y)

+

void MoveBy(SPoint pt)

+


+Move all member rectangles of Decorator by the specified amount.

+


+
+void ResizeBy(float x, float y)

+

void ResizeBy(SPoint pt)

+


+Resize the client frame, window frame, and the tab frame (width only) by the specified amount. Button rectangles - close, minimize, and zoom - are not modified.

+


+
+void Draw(SRect r)

+

void Draw(void)

+


+Main drawing call which checks the intersection of the rectangle passed to it and draws all items which intersect it. Draw(void) simply performs drawing calls to draw the entire decorator's footprint area.

+


+1) Check for intersection with SRect which encompasses the decorator's footprint and return if no intersection.

+

2) Call _DrawFrame(intersection)

+

3) Call _DrawTab(intersection)

+


+
+void DrawClose(void)

+

protected: void _DrawClose(SRect r)

+

void DrawMinimize(void)

+

protected: void _DrawMinimize(SRect r)

+

void DrawZoom(void)

+

protected: void _DrawZoom(SRect r)

+


+Each of these is designed to utilize their respective button rectangles. The public (void) versions simply call the internal protected ones with the button rectangle. These protected versions are, by default, empty. The rectangle passed to them is the invalid area to be drawn, which is not necessarily the entire button's rectangle.

+


+void DrawFrame(void)

+

protected: void _DrawFrame(SRect r)

+


+Draws the frame, if any. The public version amounts to _DrawFrame(framerect). The protected version is expected to not cover up the client frame when drawing. Any drawing within the clientrect member will end up being drawn over by the window's child views.

+


+void DrawTab(void)

+

protected: void _DrawTab(SRect r)

+


+Draws the window's tab, if any. DrawTab() amounts to _DrawTab(tabrect). If window titles are displayed, the _DrawTitle call is expected to be made here. Button-drawing calls, assuming that a window's buttons are in the tab, should be made here, as well.

+


+void DrawTitle(void)

+

protected: void _DrawTitle(SRect r)

+


+These cause the window's title to be drawn. DrawTitle() amounts to _DrawTitle(titlerect). _DrawTitle() should check the clip_title flag and call ClipTitle() only if it is true.

+


+<To be fleshed out once font subsystem is better understood>

+


+
+void _SetFocus(void)

+


+This hook function is primarily used to change colors used when a window changes focus states and is called immediately after the state is changed. If, for example, a decorator does not use OpenBeOS' GUI color set, it would change its drawing colors to reflect the change in focus.

+


+
+SRegion GetFootprint(void)

+


+This returns the "footprint" of the decorator, i.e. the area which is occupied by the window which is is the border surrounding the main client rectangle. It is possible to have oddly-shaped window borders, like ellipses and circles, but the resulting performance hit would reduce the said decorator to a novelty and not something useable. All versions are to construct an SRegion which the border occupies. This footprint is permitted to include the client rectangle area, but this area must not be actually drawn upon by the decorator itself. The default version returns the frame which encompasses all other rectangles - the "frame" member which belongs to its window border.

+


+
+click_type Clicked(SPoint pt, int32 buttons, int32 modifiers)

+


+Clicked() performs hit testing for the decorator, given input conditions. This function is required by ALL subclasses expecting to do more than display itself. The return type will cause the server to take the appropriate actions, such as close the window, get ready to move it, etc.

+


+
+extern "C" Decorator *create_decorator(SRect frame, int32 wlook, int32 wfeel, int32 wflags)

+


+Required export function which simply allocates an instance of the decorator and returns it.

+


+extern "C" float get_decorator_version(void)

+


+This should, for now, return 1.00.

+


+

+
+
+
+ + diff --git a/docs/develop/servers/app_server/DisplayDriver.htm b/docs/develop/servers/app_server/DisplayDriver.htm new file mode 100644 index 0000000000..c2192d1787 --- /dev/null +++ b/docs/develop/servers/app_server/DisplayDriver.htm @@ -0,0 +1,202 @@ + + +DisplayDriver.htm + + + +
+

DisplayDriver class

+


+

+

The DisplayDriver class is not a useful class unto itself. It is to provide a consistent interface for the rest of the app_server to whatever rendering context it is utilizing, whether it be a remote screen, a ServerBitmap, installed graphics hardware, or whatever. Documentation below will describe the role of each function.

+


+
+


+

+


+Member Functions

+


+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

DisplayDriver(void)

+
+

~DisplayDriver(void)

+
+

bool Initialize(void)

+
+

void Shutdown(void)

+
+

void DrawBitmap(ServerBitmap *bmp, SRect src, SRect dest)

+
+

void DrawChar(char c, SPoint pt)

+
+

void DrawString(const char *string, int32 length, SPoint pt, escapement_delta *delta=NULL)

+
+

void Stroke/FillBezier(SPoint *pts, layerdata *d, int8 *pat)

+
+

void Stroke/FillEllipse(SRect r, layerdata *d, int8 *pattern)

+
+

void Stroke/FillArc(SRect r, float angle, float span, layerdata *d, int8 *pattern)

+
+

void StrokeLine(SPoint start, SPoint end, layerdata *d, int8 *pattern)

+
+

void StrokePolygon(SPoint *ptlist, int32 numpts, SRect rect, layerdata *d, int8 *pattern, bool is_closed=true)

+
+

void FillPolygon(SPoint *ptlist, int32 numpts, SRect rect, layerdata *d, int8 *pattern)

+
+

void Stroke/FillRect(SRect r, layerdata *d, int8 *pattern)

+
+

void Stroke/FillRoundRect(SRect r, float xrad, float yrad, layerdata *d, int8 *pattern)

+
+

void Stroke/FillShape(SShape *sh, layerdata *d, int8 *pattern)

+
+

void Stroke/FillTriangle(SPoints *pts, SRect r, layerdata *d, int8 *pattern)

+
+

void StrokeLineArray(SPoint *pts, int32 numlines, rgb_color *colors, layerdata *d)

+
+

void DrawPicture(SPicture *pic, SPoint pt)

+
+

void CopyBits(SRect src, SRect dest)

+
+

void InvertRect(SRect r)

+
+

uint8 GetDepth(void)

+
+

uint16 GetHeight(void)

+
+

uint16 GetWidth(void)

+
+

screen_mode GetMode(void)

+
+

void SetMode(screen_mode mode)

+
+

bool DumpToFile(const char *path)

+
+   +
+


+
+
+


+

+

DisplayDriver(void)

+

~DisplayDriver(void)

+

bool Initialize(void)

+

void Shutdown(void)

+


+These four are for general start and stop procedures. The constructor and destructor concern themselves with the internal members common to all drivers, such as the current cursor and the access semaphore. Subclasses will probably end up using these to handle memory allocation-related issues, but likely not much else. Initialize() and Shutdown() are for general setup internal to the module. Note that if Initialize() returns false, the server will not use the module, call Shutdown(), and then delete it as accordingly.

+


+void CopyBits(SRect src, SRect dest)

+

void InvertRect(SRect r)

+

void DrawBitmap(ServerBitmap *bmp, SRect src, SRect dest, render_mode mode)

+

void DrawPicture(SPicture *pic, SPoint pt)

+

void DrawChar(char c, SPoint pt)

+

void DrawString(const char *string, int32 length, SPoint pt, escapement_delta *delta=NULL)

+


+void StrokeArc(SRect r, float angle, float span, layerdata *d, int8 *pattern)

+

void FillArc(SRect r, float angle, float span, layerdata *d, int8 *pattern)

+

void StrokeBezier(SPoint *pts, layerdata *d, int8 *pat)

+

void FillBezier(SPoint *pts, layerdata *d, int8 *pat)

+

void StrokeEllipse(SRect r, layerdata *d, int8 *pattern)

+

void FillEllipse(SRect r, layerdata *d, int8 *pattern)

+

void StrokeLine(SPoint start, SPoint end, layerdata *d, int8 *pattern)

+

void StrokeLineArray(SPoint *pts, int32 numlines, rgb_color *colors, layerdata *d)

+

void StrokePolygon(SPoint *ptlist, int32 numpts, SRect rect, layerdata *d, int8 *pattern, bool is_closed=true)

+

void FillPolygon(SPoint *ptlist, int32 numpts, SRect rect, layerdata *d, int8 *pattern)

+

void StrokeRect(SRect r, layerdata *d, int8 *pattern)

+

void FillRect(SRect r, layerdata *d, int8 *pattern)

+

void StrokeRoundRect(SRect r, float xrad, float yrad, layerdata *d, int8 *pattern)

+

void FillRoundRect(SRect r, float xrad, float yrad, layerdata *d, int8 *pattern)

+

void StrokeShape(SShape *sh, layerdata *d, int8 *pattern)

+

void FillShape(SShape *sh, layerdata *d, int8 *pattern)

+

void StrokeTriangle(SPoints *pts, SRect r, layerdata *d, int8 *pattern)

+

void FillTriangle(SPoints *pts, SRect r, layerdata *d, int8 *pattern)

+


+These drawing functions are the meat and potatoes of the graphics module. Defining any or all of them is completely optional. However, the default versions of these functions will do nothing. Thus, implementing them is likely a good idea, even if not required.

+


+
+uint8 GetDepth(void)

+

uint16 GetHeight(void)

+

uint16 GetWidth(void)

+

screen_mode GetMode(void)

+

void SetMode(screen_mode mode)

+


+These five functions are called internally in order to get information about the current state of the buffer in the module. GetDepth should return 8, 16, or 32, in any event because the server handles RGB color spaces of these depths only.

+


+bool DumpToFile(const char *path)

+


+DumpToFile is completely optional, providing a hook which allows screenshots to be taken. The default version does nothing but return false. If a screenshot is successful, return true.

+
+
+
+ + diff --git a/docs/develop/servers/app_server/PatternHandler.htm b/docs/develop/servers/app_server/PatternHandler.htm new file mode 100644 index 0000000000..6f4ce713c2 --- /dev/null +++ b/docs/develop/servers/app_server/PatternHandler.htm @@ -0,0 +1,118 @@ + + +PatternHandler.htm + + + +
+

PatternHandler class

+


+

+

PatternHandler provides an easy way to integrate pattern support into classes which require it, such as the DisplayDriver class.

+


+
+


+

+


+Member Functions

+


+

+ + + + + + + + + + + + + + + + + +
+

PatternHandler(void)

+
+

~PatternHandler(void)

+
+

void SetTarget(int8 *pattern)

+
+

void SetColors(RGBColor c1, RGBColor c2)

+
+

RGBColor GetColor(SPoint pt)

+
+

RGBColor GetColor(float x, float y)

+
+

bool GetValue(float x, float y)

+
+

bool GetValue(SPoint pt)

+
+


+
+Enumerated Types

+


+pattern_enum

+

{

+

uint64 type64

+

uint8 type8 [8]

+

}

+


+


+

+

PatternHandler()

+


+1) Initialize internal RGBColor variables to black and white, respectively.

+

2) Set internal pattern to B_SOLID_HIGH (all 1's)

+


+
+~PatternHandler()

+


+Empty

+


+
+void SetTarget(int8 *pattern)

+


+Updates the pattern handler's pattern. It copies the pattern passed to it, so it does NOT take responsibility for freeing any memory.

+


+1) cast the passed pointer in such a way to copy it as a uint64 to the pattern_enum.type64 member

+


+void SetColors(RGBColor c1, RGBColor c2)

+


+Sets the internal high and low colors for the pattern handler. These will be the colors returned when GetColor() is called.

+


+1) Assign c1 to high color and c2 to low color

+


+
+RGBColor GetColor(SPoint pt) +RGBColor GetColor (float x, float y)

+


+bool GetValue(SPoint pt) +bool GetValue (float x, float y)

+


+
GetColor returns the color in the pattern at the specified location. GetValue returns true for the high color and false for the low color.

+


+1) xpos = x % 8, ypos = y % 8 +2) value = pointer [ ypos ] & ( 1 << (7 - xpos) )

+

3) GetValue: return (value==0)?false:true

+

GetColor: return (value==0)?lowcolor:highcolor

+
+
+
+ + diff --git a/docs/develop/servers/app_server/RGBColor.htm b/docs/develop/servers/app_server/RGBColor.htm new file mode 100644 index 0000000000..a2bc3ef06f --- /dev/null +++ b/docs/develop/servers/app_server/RGBColor.htm @@ -0,0 +1,189 @@ + + +RGBColor.htm + + + +
+

RGBColor class

+


+

+

RGBColor objects provide a simplified interface to colors for the app_server, especially the DisplayDriver class

+


+
+


+

+


+Member Functions

+


+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)

+
+

RGBColor(rgb_color col)

+
+

RGBColor(uint16 color16)

+
+

RGBColor(uint8 color8)

+
+

RGBColor(const RGBColor &color)

+
+

RGBColor(void)

+
+

void PrintToStream(void)

+
+

uint8 GetColor8(void)

+
+

uint16 GetColor16(void)

+
+

rgb_color GetColor32(void)

+
+

void SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)

+
+

void SetColor(uint16 color16)

+
+

void SetColor(uint8 color 8)

+
+

void SetColor(rgb_color color)

+
+

void SetColor(const RGBColor &col)

+
+

Operators: =,==,!=

+
+

RGBColor MakeBlendColor( RGBColor c, float position)

+
+   +
+


+
+


+

+

RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)

+

RGBColor(rgb_color col)

+

RGBColor(uint16 color16)

+

RGBColor(uint8 color8)

+

RGBColor(const RGBColor &color)

+

RGBColor(void)

+


+1) In all cases, extract the color data by calling SetColor. Void version sets to (0,0,0,0)

+


+
+void PrintToStream(void)

+


+Prints the color values of the color32 member via printf()

+


+uint8 GetColor8(void)

+

uint16 GetColor16(void)

+

rgb_color GetColor32(void)

+


+These are for obtaining space-specific versions of the color assigned to the object.

+


+1) In all cases, return the internal color storage members

+


+
+void SetColor(const RGBColor &color)

+


+Copy all internal members to the current object.

+


+
+
void SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)

+

void SetColor(rgb_color col)

+


+
1) Assign parameters to internal rgb_color

+

2) call SetRGBAColor15()

+

3) call SystemPalette::FindClosestColor()

+


+

+
void SetColor(uint16 color16)

+


+1) Assign parameter to internal uint16

+

2) call SetRGBAColor32()

+

3) call SystemPalette::FindClosestColor()

+


+
+
void SetColor(uint8 color8)

+


+
1) Assign parameter to internal uint8

+

2) Get the 32-bit value from the palette and assign it to the internal rgb_color

+

3) call SetRGBAColor16()

+


+
+
RGBColor & operator=(const RGBColor &from)

+


+Copy all data members over and return the value of this (return *this;)

+


+
bool operator==(const RGBColor &from)

+


+
Compare rgb_colors and if all members are equal, return true. Otherwise, return false.

+


+
bool operator!=(const RGBColor &from)

+


+Compare rgb_colors and if all are equal, return false. Otherwise, return true.

+


+RGBColor MakeBlendColor(RGBColor c, float position)

+


+Returns a color which is (position * 100) of the way from the current color to the one passed to it. This would be an easy way to generate color gradients, for example, but with more control.

+


+1) Clip position to the range 0<=position<=1

+

2) For each color component,

+

a) calculate the delta (delta=int16(c.component-thiscolor.component))

+

b) calculate the modifier (mod=thiscolor.component+(delta * position))

+

c) clip modifier to the range 0 <= modifier <= 255

+

d) assign modifier to the component (thiscolor.component=int8(mod))

+

3) return a new RGBColor constructed around the new color

+


+

+
+
+
+ + diff --git a/docs/develop/servers/app_server/ServerApp.htm b/docs/develop/servers/app_server/ServerApp.htm new file mode 100644 index 0000000000..4099495d7d --- /dev/null +++ b/docs/develop/servers/app_server/ServerApp.htm @@ -0,0 +1,330 @@ + + +ServerApp.htm + + + +
+

ServerApp class

+


+

+

ServerApps are the server-side counterpart to BApplications. They monitor for messages for the BApplication, create BWindows and BBitmaps, and provide a channel for the app_server to send messages to a user application without having a window.

+


+
+


+

+

Member Functions

+


+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+

ServerApp(port_id sendport, port_id rcvport, const char *signature, thread_id thread_bapp)

+
+

~ServerApp(void)

+
+

bool Run(void)

+
+

static int32 MonitorApp(void *data)

+
+

void Lock(void)

+
+

void Unlock(void)

+
+

bool IsLocked(void)

+
+

void WindowBroadcast(int32 code)

+
+

bool IsActive(void)

+
+

bool PingTarget(void)

+
+

void DispatchMessage(int32 code, int8 *buffer)

+
+   +
+


+
+Global Functions

+


+
+


+

+

ServerApp(port_id sendport, port_id rcvport, const char *sig, thread_id thread_bapp)

+


+1) Create the window list as empty

+

2) Save sendport, rcvport, sig, and thread_bapp to the respective ServerApp members

+

3) Set quit_app flag to false

+

4) Create the window list lock

+


+
+~ServerApp(void)

+


+1) Empty and delete window list and accompanying windows

+

2) Wait for the monitoring thread to exit

+

3) Call CursorManager::RemoveAppCursors(this)

+

4) Delete the window list lock

+

5) If monitoring thread still active, kill it (in case app is deleted without a quit message)

+


+
+bool Run(void)

+


+Run() simply makes a ServerApp start monitoring for messages from its BApplication, telling it to quit if there is a problem.

+


+1) Spawn the monitoring thread (which utilizes MonitorApp()) +2) If any error, tell the BApplication to quit, spit an error to stderr, and return false

+

3) Resume the monitoring thread

+

4) Return true

+


+
+static int32 MonitorApp(void *data)

+


+Thread function for monitoring for messages from the ServerApp's BApplication.

+


+1) Call port_buffer_size - which will block if the port is empty

+

2) Allocate a buffer on the heap if the port buffer size is greater than 0

+

3) Read the port

+

4) Pass specified messages to DispatchMessage() for processing, spitting out an error message to stderr if the message's code is unrecognized

+

5) Return from DispatchMessage() and free the message buffer if one was allocated

+

6) If the message code matches the B_QUIT_REQUESTED definition and the quit_app flag is true, fall out of the infinite message-monitoring loop. Otherwise continue to next iteration

+

7) Send a DELETE_APP message to the server's main message to force deleting of the ServerApp instance and exit

+


+
+
+bool IsActive(void)

+


+Used for determining whether the application is the active one. Simply returns the isactive flag.

+


+
+void PingTarget(void)

+


+PingTarget() is called only from the Picasso thread of the app_server in order to determine whether its respective BApplication still exists. BApplications have been known to crash from time to time without the common courtesy of notifying the server of its intentions. ;D

+


+1) Call get_thread_info() with the app's thread_id

+

2) if it returns anything but B_OK, return false. Otherwise, return true.

+


+
+void DispatchMessage(int32 code, int8 *buffer)

+


+DispatchMessage implements all the code necessary to respond to a given message sent to the ServerApp on its receiving message port. This allows for clearer and more manageable code.

+


+CREATE_WINDOW:

+


+Sent by a new BWindow object via synchronous PortLink messaging. Set up the corresponding ServerWindow and reply to the BWindow with the new port to which it will send future communications with the App Server.

+


+Attached Data:

+


+

+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+

port_id reply_port

+
+

port to which the server is to reply in response to the current message

+
+

BRect wframe

+
+

frame of the requesting BWindow

+
+

uint32 wflags

+
+

flag data of the requesting BWindow

+
+

port_id win_port

+
+

receiver port of the requesting BWindow

+
+

uint32 workspaces

+
+

workspaces on which the BWindow is to appear

+
+

const char *title

+
+

title of the requesting BWindow

+
+


+

+


+1) Get all attached data

+

2) Acquire the window list lock

+

3) Allocate a ServerWindow object and add it to the list

+

4) Release window list lock

+

5) Send the message SET_SERVER_PORT (with the ServerWindow's receiver port attached to the reply port

+


+
+DELETE_APP:

+


+Sent by a ServerWindow when told to quit. It is identified by the unique ID assigned to its thread.

+


+Attached Data:

+


+

+

+ + + + + +
+

thread_id win_thread

+
+

Thread id of the ServerWindow sending this message

+
+


+

+


+1) Get window's thread_id

+

2) Acquire window list lock

+

3) Iterate through the window list, searching for the ServerWindow object with the sent thread_id

+

4) Remove the object from the list and delete it

+

5) Release window list lock

+


+
+SET_CURSOR_DATA:

+


+Received from the ServerApp's BApplication when SetCursor(const void *) is called.

+


+

+

Attached Data:

+


+

+

+ + + + + +
+

int8 cursor[68]

+
+

Cursor data in the format as defined in the BeBook

+
+


+

+


+1) Create a ServerCursor from the attached cursor data

+

2) Add the new ServerCursor to the CursorManager and then call CursorManager::SetCursor

+

+

+

SET_CURSOR_BCURSOR:

+


+Received from the ServerApp's BApplication when SetCursor(BCursor *, bool) is called.

+


+

+

Attached Data:

+


+

+

+ + + + + +
+

int32 token

+
+

Token identifier of cursor in the BCursor class

+
+


+

+


+1) Get the attached token and call CursorManager::SetCursor(token)

+


+
+B_QUIT_REQUESTED:

+


+Received from the BApplication when quits, so set the quit flag and ask the server to delete the object

+


+Attached Data: None

+


+1) Set quit_app flag to true

+


+
+UPDATE_DECORATOR:

+


+Received from the poller thread when the window decorator for the system has changed.

+


+Attached Data: None

+


+1) Call WindowBroadcast(UPDATE_DECORATOR)

+


+
+void WindowBroadcast(int32 code)

+


+Similar to AppServer::Broadcast(), this sends a message to all ServerWindows which belong to the ServerApp.

+


+1) Acquire window list lock

+

2) Create a PortLink instance and set its message code to the passed parameter.

+

3) Iterate through the window list, targeting the PortLink instance to each ServerWindow's message port and calling Flush().

+

4) Release window list lock

+


+
+void Lock(void)

+

void Unlock(void)

+

bool IsLocked(void)

+


+These functions are used to regulate access to the ServerApp's data members. Lock() acquires the internal semaphore, Unlock() releases it, and IsLocked returns true only if the semaphore's value is positive.

+
+
+
+ + diff --git a/docs/develop/servers/app_server/ServerBitmap.htm b/docs/develop/servers/app_server/ServerBitmap.htm new file mode 100644 index 0000000000..bb8bbeb3c0 --- /dev/null +++ b/docs/develop/servers/app_server/ServerBitmap.htm @@ -0,0 +1,118 @@ + + +ServerBitmap.htm + + + +
+

ServerBitmap class

+


+

+

ServerBitmaps are the server side counterpart to BBitmap.

+


+
+


+

+


+Member Functions

+


+

+ + + + + + + + + + + + + + + + + +
+

ServerBitmap(SRect r, color_space cspace, int32 flags, int32 bytesperrow=-1, screen_id screen=B_MAIN_SCREEN_ID)

+
+

~ServerBitmap(void)

+
+

uint8 *Buffer(void)

+
+

area_id Area(void)

+
+

uint32 BitsLength(void)

+
+

SRect Bounds(void)

+
+

int32 BytesPerRow(void)

+
+

void _HandleSpace(color_space cs, int32 bytesperline=-1)

+
+


+
+Global Functions

+


+If there are any global functions associated with the class, they are listed here.

+


+
+


+

+

ServerBitmap(SRect r, color_space cspace, int32 flags, int32 bytesperrow=-1, screen_id screen=B_MAIN_SCREEN_ID)

+


+1) Call _HandleSpace()

+

2) Call _HandleFlags()

+

3) Initialize remaining data members to parameters or safe values

+


+
~ServerBitmap(void)

+


+Empty

+


+
+
uint8 *Buffer(void)

+


+Returns the bitmap's buffer member

+


+
+area_id Area(void)

+


+Returns the bitmap's buffer member.

+


+
+uint32 BitsLength(void)

+


+Returns bytes_per_row * height

+


+
+SRect Bounds(void)

+


+returns SRect(width-1,height-1)

+


+
+int32 BytesPerRow(void)

+


+returns the bitmap's bytes_per_row member

+


+
+void _HandleSpace(color_space cs, int32 bytesperline=-1)

+


+Large function which essentially consists of a switch() of the available color spaces and assigns the bits per pixel and bytes per line values based on the color space. If bytesperline is -1, the default is used, otherwise it uses the specified value.

+
+
+
+ + diff --git a/docs/develop/servers/app_server/SystemPalette.htm b/docs/develop/servers/app_server/SystemPalette.htm new file mode 100644 index 0000000000..2211b5df0a --- /dev/null +++ b/docs/develop/servers/app_server/SystemPalette.htm @@ -0,0 +1,249 @@ + + +SystemPalette.htm + + + +
+

SystemPalette class

+


+

+

This object does all the handling for system attribute colors and system palette management.

+


+
+


+

+


+Member Functions

+


+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+

SystemPalette(void)

+
+

~SystemPalette(void)

+
+

void SetPalette(uint8 index, RGBColor col)

+
+

void SetPalette(uint8 index, rgb_color col)

+
+

RGBColor GetPalette(uint8 index)

+
+

void SetGUIColor(color_which which, RGBColor col)

+
+

RGBColor GetGUIColor(color_which which)

+
+

color_set GetGUIColors(void)

+
+

void SetGUIColors(color_set cset)

+
+

void _GenerateSystemPalette(rgb_color *palette)

+
+

void _SetDefaultGUIColors(void)

+
+   +
+


+
+_ Denotes a protected function

+


+Structures

+


+color_set {

+

rgb_color panel_background

+

rgb_color panel_text

+

rgb_color document_background

+

rgb_color document_text

+

rgb_color control_background

+

rgb_color control_text

+

rgb_color control_border

+

rgb_color control_highlight

+

rgb_color tooltip_background

+

rgb_color tooltip_text

+

rgb_color menu_background

+

rgb_color menu_selected_background

+

rgb_color menu_text

+

rgb_color menu_selected_text

+

rgb_color menu_separator

+

rgb_color menu_triggers

+

}

+


+


+

+

SystemPalette(void)

+


+1) Allocate the rgb_color[256] palette on the heap and call _GenerateSystemPalette()

+

2) Initialize attribute variables to the defaults

+


+
+~SystemPalette(void)

+


+1) Free the palette array

+


+
+void SetPalette(uint8 index, RGBColor col)

+

void SetPalette(uint8 index, rgb_color col)

+


+Sets the said index to the passed color value.

+


+
+RGBColor GetPalette(uint8 index)

+


+Returns the color at said index in the palette.

+


+
+void SetGUIColor(color_which which, RGBColor col)

+

RGBColor GetGUIColor(color_which which)

+

color_set GetGUIColors(void)

+

void SetGUIColors(color_set cset)

+


+These tweak or return the system attribute colors, one at a time or all at once.

+


+
+protected: void _GenerateSystemPalette(rgb_color *palette)

+


+Sets the passed palette to the BeOS R5 system colors, which follows.

+

Grays:

+

0,0,0 -> 248,248,248 by increments of 8

+

Blues:

+

0,0,255

+

0,0,229

+

0,0,204

+

0,0,179

+

0,0,154

+

0,0,129

+

0,0,105

+

0,0,80

+

0,0,55

+

0,0,30

+

Reds: as per blues, but red values are 1 less

+

Greens: as per blues, but green values are 1 less

+

0,152,51

+

255,255,255

+


+The following sets use [255, 203, 152, 102, 51, 0] for the blue values, keeping the other colors the same:

+


+203,255, [value]

+

152,255, [value]

+

102,255, [value]

+

51,255, [value]

+

255,152, [value]

+


+0,102,255

+

0,102,203

+


+203,203, [value]

+

152,255, [value]

+

102,255, [value]

+

51,255, [value]

+

255,102, [value]

+


+0,102,152

+

0,102,102

+


+203,152, [value]

+

152,152, [value]

+

102,152, [value]

+

51,152, [value]

+


+230,134,0

+


+255,51, [value excepting 255]

+


+0,102,51

+

0,102,0

+


+203,102, [value]

+

152,102, [value]

+

102,102, [value]

+

51,102, [value]

+

255,0, [value excepting 0]

+


+255,175,19

+

0,51,255

+

0,51,203

+


+203,51, [value]

+

152,51, [value]

+

102,51, [value]

+

51,51, [value]

+


+255,203,102 -> 255,203,255, stepping in the [value] increments

+


+0,51, [value, starting at 152]

+

203,0, [value, excepting 0]

+


+255,227,70

+


+152,0, [value]

+

102,0, [value]

+

51,0, [value]

+


+255,203,51

+

255,203,0

+


+255,255, [values in reverse]

+


+
+protected: void _SetDefaultGUIColors(void)

+


+Sets the internal color_set to the defaults, which is the following:

+


+panel_background: 216,216, 216

+

panel_text: 0,0,0

+

document_background: 255,255,255

+

document_text: 0,0,0

+

control_background: 216,216,216

+

control_text: 0,0,0

+

control_border: 0,0,0

+

control_highlight: 0,0,255

+

tooltip_background:

+

tooltip_text: 0,0,0

+

menu_background: 216,216,216

+

menu_selected_background: 160,160,160

+

menu_text: 0,0,0

+

menu_selected_text: 0,0,0

+

menu_separator_high: 241,241,241

+

menu_separator_low: 186,186,186

+

menu_triggers: 0,0,0

+
+
+
+ + diff --git a/docs/develop/servers/app_server/asis.htm b/docs/develop/servers/app_server/asis.htm new file mode 100644 index 0000000000..821091912f --- /dev/null +++ b/docs/develop/servers/app_server/asis.htm @@ -0,0 +1,271 @@ + + +App Server Interface Spec.htm + + + +
+

App Server Interface Specification v0.3

+


+
Purpose:

+

The app_server provides services to the OpenBeOS by managing processes, filtering and dispatching input from the Input Server to the appropriate applications, and managing all graphics-related tasks.

+


+Tasks:

+

The tasks performed by the app_server are grouped in relation to its purpose.

+


+
Receives and redirects (dispatches) messages from the input server

+


+Responds to messages from apps

+

Receives and consolidates requests from BView, BWindow, BBitmap, and others to draw stuff (draw bitmap, etc)

+

Utilizes ports to communicate with child processes

+

Handles drag & drop messaging

+

Manages the system clipboard

+


+Loads and Kills processes

+

Detects absence of Input Server and restarts when not running

+

Aids in system shutdown

+


+Dynamically loads accelerant portion of graphics driver

+

Creates a connection with BBitmaps requiring a child view

+

Draws the blue desktop screen

+

Provides workspace support

+

Provides functionality to the BeAPI for drawing primitives, such as rectangles, ellipses, and beziers

+

Provides a means for BViews to draw on BBitmaps

+

Manages window behavior with respect to redraw (move to front, minimize, etc)

+

Returns a frame buffer to direct-access classes

+

Caches fonts for screen and printer use

+

Draws text and provides other font API support for the BeAPI classes

+


+
Table of Contents

+


+
Graphics:

+

I. Desktop Initialization

+

II. Window management

+

A. ServerApp

+

B. ServerWindow

+

C. Layer

+

D. WindowBorder

+

E. Decorator

+

III. Screen updates

+

IV. Cursor management

+

V. Display Drivers

+

Process Management:

+

I. BApplication execution

+

II. Non-BApplication execution

+

III. Killing/Exiting applications

+

IV. System Shutdown

+

Input Processing:

+

I. Input Server messages

+

II. Mouse

+

III. Keyboard

+

Messaging:

+

I. Inter-Application messaging

+

II. Drag-and-drop

+

III. Methods

+


+
+
+
+
Graphics:

+

I. Desktop Initialization

+

II. Window management

+

III. Screen updates

+

IV. Cursor management

+


+
I. Desktop Initialization

+


+The graphics hardware is abstracted from the rest of the app_server. When started, the server creates the desktop, which is little more than a collection of workspaces. The desktop actually creates a DisplayDriver and then calls the driver's method Inititialize() before calling a few high-level routines for setup. Below is the process by which the HWDriver class, which is used to access the primary graphics card in the system, followed by the steps taken to set up the desktop.

+


+
Load Accelerant

+

The app_server looks in three paths when scanning for an accelerant:

+

/fd/beos/system/add-ons/app_server

+

/boot/home/config/add-ons/app_server

+

/boot/beos/system/add-ons/app_server

+


+ When the app_server searches a path, it simply prints to the debug stream on the serial port a message akin "Attempting to load accelerant so-and-so" when loading the accelerant. Following this, it is loads the accelerant via load_add_on(), obtains the hook function control_graphics_card is via get_image_symbol, and control_graphics_card(OPEN_GRAPHICS_CARD) is called. If this returns an error, the image is unloaded after a control_graphics_card(CLOSE_GRAPHICS_CARD) is called and the server spits out a message like "So-and-so is not an acceptable driver" to the serial port. Assuming that the OPEN call succeeds, the app_server serial prints "Using so-and-so as accelerant." Hook functions are then acquired through control_graphics_card(B_GET_GRAPHICS_CARD_HOOKS). At this point, it is a good idea to have a palette generated for 8-bit mode (just in case we're going to use it), so the server generates the system palette. The palette on the graphics card is then set through many calls to control_graphics_card(B_SET_INDEXED_COLOR).

+


+Set up workspaces

+

Workspace preferences are read in from disk. If they exist, they are used; otherwise the default of 3 workspace, each with the settings 640x480x256@59.9Hz, is used. Each workspace is initialized to the proper information (preferences or default). Additionally, all settings are checked and possibly "clipped" by information gained through the driver class. With the desktop having been given the proper settings, the default workspace, 0, is activated.

+


+
Display

+

Provided that everything has gone well so far, the screen is filled to the user-set workspace color or RGB(51,102,160) Also, the global clipboard is created, which is nothing more than a BClipboard object. The Input Server will notify the app_server of its existence, at which point the cursor will be set to B_HAND_CURSOR and shown on the screen.

+


+II. Window management

+


+Window management is a complicated issue, requiring the cooperation of a number of different types of elements. Each BApplication, BWindow, and BView has a counterpart in the app_server which has a role to play. These objects are Decorators, ServerApps, ServerWindows, Layers, and WindowBorders.

+


+
A. ServerApps

+


+ServerApp objects are created when a BApplication notifies the app_server of its presence. In acknowledging the BApplication's existence, the server creates a ServerApp which will handle future server-app communications and notifies the BApplication of the port to which it must send future messages.

+


+ServerApps are each an independent thread which has a function similar to that of a BLooper, but with additional tasks. When a BWindow is created, it spawns a ServerWindow object to handle the new window. The same applies to when a window is destroyed. Cursor commands and all other BApplication functions which require server interaction are also handled. B_QUIT_REQUESTED messages are received and passed along to the main thread in order for the ServerApp object to be destroyed. The server's Picasso thread also utilizes ServerApp::PingTarget in order to determine whether the counterpart BApplication is still alive and running.

+


+
B. ServerWindows

+


+ServerWindow objects' purpose is to take care of the needs of BWindows. This includes all calls which require a trip to the server, such as BView graphics calls and sending messages to invoke hook functions within a window.

+


+
C. Layers

+


+Layers are shadowed BViews and are used to handle much BView functionality and also determine invalid screen regions. Hierarchal functions, such as AddChild, are mirrored. Invalid regions are tracked and generate Draw requests which are sent to the application for a specific BView to update its part of the screen.

+


+
D. WindowBorders

+


+WindowBorders are a special kind of Layer with no BView counterpart, designed to handle window management issues, such as click tests, resize and move events, and ensuring that its decorator updates the screen appropriately.

+


+
F. Decorators

+


+Decorators are addons which are intended to do one thing: draw the window frame. The Decorator API and development information is described in the Decorator Development Reference. They are essentially the means by which WindowBorders draw to the screen.

+


+
G. How It All Works

+


+
The app_server is one large, complex beast because of all the tasks it performs. It also utilizes the various objects to accomplish them. Input messages are received from the Input Server and all messages not specific to the server (such as Ctrl-Alt-Shift-Backspace) are passed to the active application, if any. Mouse clicks are passed to the ServerWindow class for hit testing. These hit tests can result in window tabs and buttons being clicked, or mouse click messages being passed to a specific view in a window.

+


+These input messages which are passed to a running application will sometimes cause things to happen inside it, such as button presses, window closings/openings, etc. which will cause messages to be sent to the server. These messages are sent either from a BWindow to a ServerWindow or a BApplication to a ServerApp. When such messages are sent, then the corresponding app_server object performs an appropriate action.

+


+
III. Screen Updates

+


+Screen updates are done entirely through the BView class or some subclass thereof, hereafter referred to as a view. A view's drawing commands will cause its window to store draw command messages in a message packet. At some point Flush() will be called and the command packet will be sent to the window's ServerWindow object inside the server.

+


+The ServerWindow will receive the packet, check to ensure that its size is correct, and begin retrieving each command from the packet and dispatching it, taking the appropriate actions. Actual drawing commands, such as StrokeRect, will involve the ServerWindow object calling the appropriate command in the graphics module for the Layer corresponding to the view which sent the command.

+


+
IV. Cursor Management

+


+The app_server handles all messiness to do with the cursor. The cursor commands which are members of the BApplication class will send a message to its ServerApp, which will then call the DisplayDriver's appropriate function. The DisplayDriver used will actually handle the drawing of the cursor and whether or not to do so at any given time.

+


+OpenBeOS R1 will also include the advent of an extension of the API: SetCursor(BBitmap *), which will accept a BBitmap of color space RGB(A)32, RGBA16, CMAP8, GRAY8, or GRAY1. Thus, color cursors and cursors which are not 16x16 are now supported.

+


+V. Display Drivers

+


+Unlike the BeOS R5 app_server, OpenBeOS' server will have a special feature: a modular graphics driver access class. The class is not actually the graphics driver, but, rather, a generalized interface which is implemented to interact with various destinations for graphics output. This allows the server to draw to a BWindow/BView combination, a BDirectWindow, or the actual frame buffer of a particular graphics card. All that the rest of the server needs to do is call whichever graphics function that is needed.

+


+
Process Management:

+

I. BApplication execution

+

II. Non-BApplication execution

+

III. Killing/Exiting applications

+

IV. System Shutdown

+


+
I. BApplication execution

+


+
Applications will come in two types: those which communicate with the app_server and take advantage of its services, and those which do not. To access the app_server, an application must be derived from BApplication.

+


+When a BApplication (referred to hereafter as a BApp) is executed, the app constructor creates its BLooper message port with the name AppLooperPort. This port's id, by means of BLooper, registers its port_id with the app_server so that the two can communicate with each other most easily.

+


+When the app_server receives notification that an app has been created, the server creates an AppMonitor (with accompanying thread) in its own team to handle messages sent to it and sends a reply with the port_id of the AppMonitor, to which all future messages are sent. These AppMonitor objects are stored in a global BList created for the storage of such things.

+


+
II. non-BApplication execution

+


+
Other applications do not communicate with the app_server. These applications have no access to app services and do not generally pass BMessages. This includes, but is not limited to, UNIX apps. The app_server ignores such applications except when asked to kill them.

+


+While, technically, these are not limited to being non-GUI applications, in practice these applications are command-line-only, for the application would be required to (1) render the app_server unable to access video hardware and (2) reinvent existing graphics code to load and use accelerants and draw onto the video buffer. This is extremely bad style and programming practice, not to mention more work than it is worth except in one case: the OpenBeOS app_server can coexist with the BeOS R5 app_server with some degree of peace because it can utilize extra video cards which the BeOS app_server does not use.

+


+
III. Killing/Exiting Applications

+


+
While the input server handles the Team Monitor window, the app_server actually takes care of shutting down teams, peacefully or not. Exiting an app is done simply by sending a B_QUIT_REQUESTED message to particular app. Killing an app is done via kill_team, but all the messy details are handled by the kernel itself through this call. When the user requests a team die via the Team Monitor, the Input Server sends a message to the app_server to kill the team, attaching the team_id. The app_server responds by happily nuking the respective team and notifies the registrar of its forcible removal from the roster.

+


+IV. System Shutdown

+


+
Although the server maintains an internal list of running GUI applications, when a request to shut down the system is received by the app_server, it will pass the request on to the registrar, which will, in turn, increment its way through the app roster and request each app quit. When each quit request is sent, a timer is started and after timeout, the registrar will ask the server to kill the particular team and continue iterating through the application list.

+


+
Input Processing:

+

I. Input Server messages

+

II. Mouse

+

III. Keyboard

+


+I. Input Server messages

+


+
The Input Server collects information about keyboard and mouse events and forwards them to the app_server via messages. They are sent to port specifically for such messages, and the port is monitored by a thread whose task is to monitor, process, and dispatch them to the appropriate recipients. The Input Server is a regular BApplication, and unlike other applications, it requests a port to which it can send input messages.

+


+
II. Mouse

+


+
Mouse events consist of button changes, mouse movements, and the mouse wheel. The message will consist of the time of the event and attachments appropriate for each message listed below:

+


+B_MOUSE_DOWN

+

when

+

location of the cursor

+

button number

+

modifiers

+

clicks

+

B_MOUSE_UP

+

time

+

buttons' status // not implemented for R5 but included for future expansion

+

location of the cursor

+

modifiers

+

B_MOUSE_MOVED

+

time

+

location of the cursor

+

buttons' status

+

B_MOUSE_WHEEL_CHANGED

+

time

+

location of the cursor

+

transit - in or out

+

x delta

+

y delta

+


+
III. Keyboard

+


+Keyboard events consist of notification when a key is pressed or released. Any keypress or release will evoke a message, regardless of whether or not the key is mapped. The message will consist of the appropriate code and attachments listed below:

+


+B_KEY_DOWN

+

time

+

key code

+

repeat count

+

modifiers

+

states

+

UTF-8 code

+

string generated

+

modifier-independent ASCII code

+

B_KEY_UP

+

time

+

key code

+

modifiers

+

states

+

UTF-8 code

+

string generated

+

modifier-independent ASCII code

+

B_UNMAPPED_KEY_DOWN

+

time

+

key code

+

modifiers

+

states

+

B_UNMAPPED_KEY_UP

+

time

+

key code

+

modifiers

+

states

+

B_MODIFIERS_CHANGED // sent when a modifier key changes

+

time

+

modifier states

+

previous modifier states

+

states

+


+Nearly all keypresses received by the app_server are passed onto the appropriate application. Control-Tab, when held, is sent to the Deskbar for app switching. Command+F?? is intercepted and a workspace is switched. Left Control + Alt + Delete is not even intercepted by the app_server. The Input Server receives it and shows the Team Monitor window.

+


+
Messaging:

+

I. Inter-Application messaging

+

II. Drag-and-drop

+

III. Methods

+


+
I. Inter-Application Messaging

+


+
The details of messaging are depicted under Process Management::BApplication.

+


+
II. Drag-and-drop

+


+III. Methods

+


+
Messaging with the app_server is not done using BMessages because of the overhead required to send them costs time and speed. Instead, ports are utilized indirectly by means of the PortLink class, which simply makes attaching data to a port message easier, but requires very little overhead.

+
+
+
+ + diff --git a/docs/develop/servers/app_server/toc.htm b/docs/develop/servers/app_server/toc.htm new file mode 100644 index 0000000000..3584e15879 --- /dev/null +++ b/docs/develop/servers/app_server/toc.htm @@ -0,0 +1,40 @@ + + + +

OpenBeOS R1 Application Server Specification

+ +

Table of Contents

+ +

Class Descriptions

+ +
Application Management
+ + + +
Graphics Management
+

+

+ +

Other Documents

+ + + + \ No newline at end of file