Implemented more desktop functions

ServerWindow API tweaks


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2782 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-02-20 13:13:01 +00:00
parent 4128579144
commit 0258e5900f
3 changed files with 79 additions and 13 deletions

View File

@ -48,7 +48,7 @@ namespace desktop_private {
BLocker draglock,
layerlock,
workspacelock;
BList *desktop_private::screenlist=NULL;
BList *screenlist=NULL;
Screen *activescreen=NULL;
}
@ -320,24 +320,55 @@ void RemoveWindowFromDesktop(ServerWindow *win)
{
}
/*!
\brief Returns the active window in the current workspace of the active screen
\return The active window in the current workspace of the active screen
*/
ServerWindow *GetActiveWindow(void)
{
return NULL;
desktop_private::workspacelock.Lock();
ServerWindow *w=desktop_private::activescreen->ActiveWindow();
desktop_private::workspacelock.Unlock();
return w;
}
/*!
\brief Sets the active window in the current workspace of the active screen
\param win The window to activate
If the window is not in the current workspace of the active screen, this call fails
*/
void SetActiveWindow(ServerWindow *win)
{
desktop_private::workspacelock.Lock();
Workspace *w=desktop_private::activescreen->GetActiveWorkspace();
if(win->GetWorkspace()!=w)
{
desktop_private::workspacelock.Unlock();
return;
}
ServerWindow *oldwin=desktop_private::activescreen->ActiveWindow();
ActivateWindow(oldwin,win);
desktop_private::workspacelock.Unlock();
}
/*!
\brief Returns the root layer for the specified workspace
\param workspace Index of the workspace to use
\param screen Index of the screen to use
\param screen Index of the screen to use. Currently ignored.
\return The root layer or NULL if there was an invalid parameter.
*/
Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID)
{
return NULL;
desktop_private::workspacelock.Lock();
Layer *r=desktop_private::activescreen->GetRootLayer();
desktop_private::workspacelock.Unlock();
return r;
}
/*!
@ -354,6 +385,17 @@ Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN
*/
void set_drag_message(int32 size, int8 *flattened)
{
desktop_private::draglock.Lock();
if(desktop_private::dragmessage)
{
desktop_private::draglock.Unlock();
return;
}
desktop_private::dragmessage=flattened;
desktop_private::dragmessagesize=size;
desktop_private::draglock.Unlock();
}
/*!
@ -368,11 +410,29 @@ void set_drag_message(int32 size, int8 *flattened)
*/
int8 *get_drag_message(int32 *size)
{
return NULL;
int8 *ptr=NULL;
desktop_private::draglock.Lock();
if(desktop_private::dragmessage)
{
ptr=desktop_private::dragmessage;
*size=desktop_private::dragmessagesize;
}
desktop_private::draglock.Unlock();
return ptr;
}
//! Empties current drag data and allows for new data to be assigned
void empty_drag_message(void)
{
desktop_private::draglock.Lock();
if(desktop_private::dragmessage)
delete desktop_private::dragmessage;
desktop_private::dragmessage=NULL;
desktop_private::dragmessagesize=0;
desktop_private::draglock.Unlock();
}

View File

@ -90,7 +90,7 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
if(_monitorthread!=B_NO_MORE_THREADS && _monitorthread!=B_NO_MEMORY)
resume_thread(_monitorthread);
_workspace=index;
_workspace_index=index;
AddWindowToDesktop(this,index);
}
@ -138,12 +138,12 @@ ServerApp *ServerWindow::GetApp(void)
void ServerWindow::Show(void)
{
if(_winborder)
/* if(_winborder)
{
// TODO: uncomment this when we have WinBorder.h
// _winborder->ShowLayer();
_winborder->ShowLayer();
ActivateWindow(this);
}
*/
}
void ServerWindow::Hide(void)
@ -448,13 +448,14 @@ void ServerWindow::HandleKeyEvent(int32 code, int8 *buffer)
{
}
void ActivateWindow(ServerWindow *win)
void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin)
{
if(active_serverwindow==win)
/* if(active_serverwindow==win)
return;
if(active_serverwindow)
active_serverwindow->SetFocus(false);
active_serverwindow=win;
if(win)
win->SetFocus(true);
*/
}

View File

@ -41,6 +41,7 @@ class ServerApp;
class Decorator;
class PortLink;
class WinBorder;
class Workspace;
class ServerWindow
{
@ -76,6 +77,9 @@ public:
static void HandleMouseEvent(int32 code, int8 *buffer);
static void HandleKeyEvent(int32 code, int8 *buffer);
void Loop(void);
int32 GetWorkspaceIndex(void) { return _workspace_index; }
Workspace *GetWorkspace(void) { return _workspace; }
protected:
friend ServerApp;
@ -83,7 +87,8 @@ protected:
BString *_title;
int32 _look, _feel, _flags;
int32 _workspace;
int32 _workspace_index;
Workspace *_workspace;
bool _active;
ServerApp *_app;
@ -101,7 +106,7 @@ protected:
uint32 _token;
};
void ActivateWindow(ServerWindow *win);
void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin);
#endif