From 0f107fa327085cc8d2767566c6675e3420d289f9 Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Thu, 19 Sep 2002 23:56:12 +0000 Subject: [PATCH] Added Desktop, TokenHandler, and WinBorder class specs git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1094 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- docs/develop/servers/app_server/Desktop.htm | 101 +++++ .../servers/app_server/TokenHandler.htm | 135 ++++++ docs/develop/servers/app_server/WinBorder.htm | 423 ++++++++++++++++++ docs/develop/servers/app_server/toc.htm | 4 +- 4 files changed, 661 insertions(+), 2 deletions(-) create mode 100644 docs/develop/servers/app_server/Desktop.htm create mode 100644 docs/develop/servers/app_server/TokenHandler.htm create mode 100644 docs/develop/servers/app_server/WinBorder.htm diff --git a/docs/develop/servers/app_server/Desktop.htm b/docs/develop/servers/app_server/Desktop.htm new file mode 100644 index 0000000000..28b60e63bb --- /dev/null +++ b/docs/develop/servers/app_server/Desktop.htm @@ -0,0 +1,101 @@ + + +Desktop.htm + + + +
+

Desktop module

+


+

+

There are no globally accessible objects in this section of code, but many function definitions to work with workspaces, screen attributes, and other such things. These functions work with the private desktop classes Screen and Workspace.

+


+

+

+


+

+

Global Functions

+


+void InitDesktop(void)

+

void ShutdownDesktop(void)

+


+void AddWorkspace(int32 index=-1)

+

void DeleteWorkspace(int32 index)

+

int32 CountWorkspaces(void)

+

void SetWorkspaceCount(int32 count)

+

int32 CurrentWorkspace(screen_id screen=B_MAIN_SCREEN_ID)

+

void SetWorkspace(int32 workspace, screen_id screen=B_MAIN_SCREEN_ID)

+


+void SetScreen(screen_id id)

+

int32 CountScreens(void)

+

screen_id ActiveScreen(void)

+

DisplayDriver *GetGfxDriver(screen_id screen=B_MAIN_SCREEN_ID)

+

status_t SetSpace(int32 index, int32 res, bool stick=true, screen_id screen=B_MAIN_SCREEN_ID)

+


+void AddWindowToDesktop(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)

+

void RemoveWindowFromDesktop(ServerWindow *win)

+

ServerWindow *GetActiveWindow(void)

+

void SetActiveWindow(ServerWindow *win)

+

Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)

+


+


+

+

void InitDesktop(void)

+


+Sets up all the stuff necessary for the system's desktop.

+


+1) Create a graphics module list by looping through allocation and initialization of display modules until failure is returned. If app_server exists, just create a ViewDriver module

+

2) Create and populate Screen list, pointing each Screen instance to its Driver instance

+

3) Create layer and workspace locks

+

4) Set screen 0 to active

+


+void ShutdownDesktop(void)

+


+Undoes everything done in InitDesktop().

+


+1) Delete all locks

+

2) Delete all screens in the list

+


+void AddWorkspace(int32 index=-1)

+

void DeleteWorkspace(int32 index)

+

int32 CountWorkspaces(void)

+

void SetWorkspaceCount(int32 count)

+

int32 CurrentWorkspace(screen_id screen=B_MAIN_SCREEN_ID)

+

void SetWorkspace(int32 workspace, screen_id screen=B_MAIN_SCREEN_ID)

+


+Each of these calls the appropriate method in the Screen class. Add and Delete workspace functions operate on all screens.

+


+void SetScreen(screen_id id)

+

int32 CountScreens(void)

+

screen_id ActiveScreen(void)

+

DisplayDriver *GetGfxDriver(screen_id screen=B_MAIN_SCREEN_ID)

+

status_t SetSpace(int32 index, int32 res, bool stick=true, screen_id screen=B_MAIN_SCREEN_ID)

+


+Each of these calls operate on the objects in the Screen list, calling methods as appropriate.

+


+void AddWindowToDesktop(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)

+

void RemoveWindowFromDesktop(ServerWindow *win)

+

ServerWindow *GetActiveWindow(void)

+

void SetActiveWindow(ServerWindow *win)

+

Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)

+


+These operate on the layer structure in the active Screen object, calling methods as appropriate.

+


+

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

TokenHandler class

+


+This is a simple way to provide tokens for various reasons.

+


+


+

+


+Member Functions

+


+

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

TokenHandler(void)

+
+

~TokenHandler(void)

+
+

int32 GetToken(void)

+
+

void Reset(void)

+
+

void ExcludeValue(int32 value)

+
+

void ResetExcludes(void)

+
+

bool IsExclude(int32 value)

+
+   +
+   + +   +
+


+
+


+

+

TokenHandler(void)

+


+1) Initialize the index to -1

+

2) create the access semaphore

+

3) create the exclude list with no items

+


+
+~TokenHandler(void)

+


+1) delete the access lock

+

2) call ResetExcludes and delete the exclude list

+


+
+int32 GetToken(void)

+


+Returns a unique token which is not equal to any excluded values

+


+1) create a local variable to return the new token

+

2) acquire the access semaphore

+

3) Increment the internal index

+

4) while IsExclude(index) is true, increment the index

+

5) assign it to the local variable

+

6) release the access semaphore

+

7) return the local variable

+


+
+void Reset(void)

+


+1) acquire the access semaphore

+

2) set the internal index to -1

+

3) release the access semaphore

+


+
+void ExcludeValue(int32 value)

+


+1) acquire the access semaphore

+

2) if IsExclude(value) is false, add it to the exclude list

+

3) release the access semaphore

+


+
+void ResetExcludes(void)

+


+1) acquire the access semaphore

+

2) Iterate through the exclude list, removing and deleting each item

+

3) release the access semaphore

+


+
+bool IsExclude(int32 value)

+


+1) create a boolean match flag and set it to false

+

2) acquire the access semaphore

+

3) iterate through the exclude list and see if the value matches any in the list

+

4) If there is a match, set the match flag to true and exit the loop

+

5) release the access semaphore

+

6) return the match flag

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

WinBorder class : public Layer

+


+

+

WinBorder objects provide window management functionality and ensure that the border for each window is drawn.

+


+
+


+

+


+Member Functions

+


+

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

WinBorder(BRect r, const char *name, int32 resize, int32 flags, ServerWindow *win)

+
+

~WinBorder(void)

+
+

void RequestDraw(void)

+
+

void MoveBy(BPoint pt)

+
+

void MoveBy(float x, float y)

+
+

void ResizeBy(BPoint pt)

+
+

void ResizeBy(float x, float y)

+
+

void MouseDown(int8 *buffer)

+
+

void MouseUp(int8 *buffer)

+
+

void MouseMoved(int8 *buffer)

+
+

void UpdateDecorator(void)

+
+

void UpdateColors(void)

+
+

void UpdateFont(void)

+
+

void UpdateScreen(void)

+
+

void RebuildRegions(bool recursive=true)

+
+

void Activate(bool state)

+
+


+
+Global Functions

+


+bool is_moving_window(void)

+

void set_is_moving_window(bool state)

+

bool is_resizing_window(void)

+

void set_is_resizing_window(bool state)

+

void set_active_winborder(WinBorder *win)

+

WinBorder * get_active_winborder(void)

+


+Namespaces

+


+winborder_private {

+

bool is_moving_a_window

+

bool is_resizing_a_window

+

WinBorder *active_winborder

+

}

+


+


+

+

WinBorder(BRect r, const char *name, int32 resize, int32 flags, ServerWindow *win)

+


+1) Pass parameters to Layer constructor

+

2) Instantiate a decorator

+

3) Initialize visible and full regions via Decorator::GetFootprint()

+


+
+~WinBorder(void)

+


+1) Delete decorator instance

+


+
+void RequestDraw(void)

+


+Reimplements Layer::RequestDraw() because it has no corresponding BView

+


+1) if IsDirty()==false, return

+

2) Iterate through each BRect in the invalid region and call Decorator::Draw(BRect) for each invalid rectangle

+

3) Perform recursive child calls as in Layer::RequestDraw()

+


+
+void MoveBy(BPoint pt)

+

void MoveBy(float x, float y)

+


+Moves the WinBorder's position on screen - reimplements Layer::MoveBy()

+


+1) Call the decorator's MoveBy()

+

2) Call Layer::MoveBy()

+


+
+void ResizeBy(BPoint pt)

+

void ResizeBy(float x, float y)

+


+Resizes the WinBorder - reimplements Layer::MoveBy()

+


+1) Call the decorator's ResizeBy()

+

2) Call Layer::ResizeBy()

+


+
+void MouseDown(int8 *buffer)

+


+Figures out what to do with B_MOUSE_DOWN messages sent to the window's border.

+


+1) Extract data from the buffer

+

2) Call the decorator's Clicked() function

+

3) Feed return value to a switch() function (table below)

+

4) Call the ServerWindow's Activate() function

+


+

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

CLICK_MOVETOBACK

+
+

call MoveToBack()

+
+

CLICK_MOVETOFRONT

+
+

call MoveToFront()

+
+

CLICK_CLOSE

+
+

1) call SetCloseButton(true)

+

2) call decorator->DrawClose

+
+

CLICK_ZOOM

+
+

1) call SetZoomButton(true)

+

2) call decorator->DrawZoom

+
+

CLICK_MINIMIZE

+
+

1) call SetMinimizeButton(true)

+

2) call decorator->DrawMinimize

+
+

CLICK_DRAG

+
+

1) call MoveToFront()

+

2) call set_is_win_moving(true)

+

3) Save the mouse position

+
+

CLICK_RESIZE

+
+

1) call MoveToFront()

+

2) call set_is_win_resizing(true)

+
+

CLICK_NONE

+
+

do nothing

+
+

default:

+
+

Spew an error to stderr and return

+
+


+
+
+void MouseUp(int8 *buffer)

+


+Figures out what to do with B_MOUSE_UP messages sent to the window's border.

+


+1) Extract data from the buffer

+

2) Call the decorator's Clicked() function

+

3) Feed return value to a switch() function (table below)

+

4) if is_resizing_window, call set_is_resizing_window(false)

+

5) if is_moving_window, call set_is_moving_window(false)

+

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

CLICK_MOVETOBACK

+
+

call MoveToBack()

+
+

CLICK_MOVETOFRONT

+
+

call MoveToFront()

+
+

CLICK_CLOSE

+
+

1) call SetCloseButton(false)

+

2) call decorator->DrawClose

+

3) send B_QUIT_REQUESTED to the target BWindow

+
+

CLICK_ZOOM

+
+

1) call SetZoomButton(false)

+

2) call decorator->DrawZoom

+

3) send B_ZOOM to the target BWindow

+
+

CLICK_MINIMIZE

+
+

1) call SetMinimizeButton(false)

+

2) call decorator->DrawMinimize

+

3) send B_MINIMIZE to the target BWindow

+
+

CLICK_DRAG

+
+

call set_is_win_moving(false)

+
+

CLICK_RESIZE

+
+

call set_is_win_resizing(false)

+
+

CLICK_NONE

+
+

do nothing

+
+

default:

+
+

Spew an error to stderr

+
+


+
+
+void MouseMoved(int8 *buffer)

+


+Figures out what to do with B_MOUSE_MOVED messages sent to the window's border.

+


+1) Extract data from the buffer

+

2) Call the decorator's Clicked() function

+

3) If not CLICK_CLOSE and decorator->GetClose is true, call SetClose(false) and DrawClose()

+

4) If not CLICK_ZOOM and decorator->GetZoom is true, call SetZoom(false) and DrawZoom()

+

5) If not CLICK_MINIMIZE and decorator->GetMinimize is true, call SetMinimize(false) and DrawMinimize()

+

6) if CLICK_RESIZE or its variants, call CursorManager::SetCursor() with the appropriate system cursor.

+

7) if is_moving_window() is true, calculate the amount the mouse has moved and call decorator->MoveBy() followed by Layer::MoveBy()

+

8) if is_resizing_window() is true, calculate the amount the mouse has moved and call decorator->ResizeBy() followed by Layer::ResizeBy()

+


+
+void UpdateDecorator(void)

+


+Hook function called by the WinBorder's ServerWindow when the decorator used is changed.

+


+1) Delete the current decorator

+

2) Call instantiate_decorator

+

3) Get the new decorator's footprint region and assign it to the full and visible regions

+

4) Call RebuildRegions and then RequestDraw

+


+
+void UpdateColors(void)

+


+Hook function called by the WinBorder's ServerWindow when system colors change

+


+1) Call the decorator's SetColors(), passing the SystemPalette's GetGUIColors() value

+


+
+void UpdateFont(void)

+


+Hook function called by the WinBorder's ServerWindow when system fonts change

+


+TODO: implementation details

+


+
+void UpdateScreen(void)

+


+Hook function called by the WinBorder's ServerWindow when screen attributes change

+


+1) Call the decorator's UpdateScreen and then RequestDraw

+


+
+void RebuildRegions(bool recursive=true)

+


+Reimplementation of Layer::RebuildRegions which changes it such that lower siblings are clipped to the footprint instead of the frame.

+


+
+void Activate(bool state)

+


+This function is never directly called except from within set_active_winborder. It exists to force redraw and set the internal state information to the proper values for when a window receives or loses focus.

+


+1) call the decorator's SetFocus(state)

+

2) set the internal is_active flag to state

+

3) iterate through each rectangle in the visible region and call the decorator's Draw on it.

+


+
+bool is_moving_window(void)

+

void set_is_moving_window(bool state)

+


+These two functions set and return the variable winborder_private::is_moving_a_window.

+


+
+bool is_resizing_window(void)

+

void set_is_resizing_window(bool state)

+


+These two functions set and return the variable winborder_private::is_resizing_a_window.

+


+
+void set_active_winborder(WinBorder *win)

+

WinBorder * get_active_winborder(void)

+


+These two functions set and return the variable winborder_private::active_winborder

+
+
+
+ + diff --git a/docs/develop/servers/app_server/toc.htm b/docs/develop/servers/app_server/toc.htm index 3584e15879..8eee454d2e 100644 --- a/docs/develop/servers/app_server/toc.htm +++ b/docs/develop/servers/app_server/toc.htm @@ -13,6 +13,7 @@
  • AppServer
  • DebugTools
  • ServerApp
  • +
  • TokenHandler
  • Graphics Management
    @@ -24,10 +25,9 @@
  • DisplayDriver
  • PatternHandler
  • RGBColor
  • -
  • SPoint
  • -
  • SRect
  • ServerBitmap
  • SystemPalette
  • +
  • WinBorder
  • Other Documents