From e9318266f992dd09fd0afe756a57ca1f620814ee Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Thu, 20 Feb 2003 18:05:35 +0000 Subject: [PATCH] Finished Desktop functions and associated documentation git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2783 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/server/Desktop.cpp | 36 +++++++++++++++++++++++-- src/servers/app/server/ServerWindow.cpp | 5 ++++ src/servers/app/server/ServerWindow.h | 1 + 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/servers/app/server/Desktop.cpp b/src/servers/app/server/Desktop.cpp index 9a1da29173..7aa525eefe 100644 --- a/src/servers/app/server/Desktop.cpp +++ b/src/servers/app/server/Desktop.cpp @@ -302,22 +302,54 @@ DisplayDriver *GetGfxDriver(screen_id screen=B_MAIN_SCREEN_ID) \param index The workspace to change \param res Resolution constant from GraphicsDefs.h \param stick If false, resolution will revert to its old value on next boot - \param screen ID of the screen to change + \param screen ID of the screen to change. Currently unused. \return B_OK if successful, B_ERROR if not. Because of the lack of outside multimonitor support, the screen ID is ignored for now. */ status_t SetSpace(int32 index, int32 res, bool stick=true, screen_id screen=B_MAIN_SCREEN_ID) { - return B_ERROR; + desktop_private::workspacelock.Lock(); + status_t stat=desktop_private::activescreen->SetSpace(index,res,stick); + desktop_private::workspacelock.Unlock(); + return stat; } +/*! + \brief Adds a window to the desktop so that it will be displayed + \param win Window to add + \param workspace index of the workspace to add the window to + \param screen Optional screen specifier. Currently unused. +*/ void AddWindowToDesktop(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE, screen_id screen=B_MAIN_SCREEN_ID) { + // Workspace() will be non-NULL if it has already been added to the desktop + if(!win || win->GetWorkspace()) + return; + + desktop_private::workspacelock.Lock(); + desktop_private::layerlock.Lock(); + + Workspace *w=desktop_private::activescreen->GetActiveWorkspace(); + win->SetWorkspace(w); + + desktop_private::layerlock.Unlock(); + desktop_private::workspacelock.Unlock(); } +/*! + \brief Removes a window from the desktop + \param win Window to remove +*/ void RemoveWindowFromDesktop(ServerWindow *win) { + desktop_private::workspacelock.Lock(); + desktop_private::layerlock.Lock(); + + win->SetWorkspace(NULL); + + desktop_private::layerlock.Unlock(); + desktop_private::workspacelock.Unlock(); } /*! diff --git a/src/servers/app/server/ServerWindow.cpp b/src/servers/app/server/ServerWindow.cpp index e6609866b2..26b56fcdbd 100644 --- a/src/servers/app/server/ServerWindow.cpp +++ b/src/servers/app/server/ServerWindow.cpp @@ -91,6 +91,7 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, resume_thread(_monitorthread); _workspace_index=index; + _workspace=NULL; AddWindowToDesktop(this,index); } @@ -448,6 +449,10 @@ void ServerWindow::HandleKeyEvent(int32 code, int8 *buffer) { } +void ServerWindow::SetWorkspace(Workspace *wkspc) +{ +} + void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin) { /* if(active_serverwindow==win) diff --git a/src/servers/app/server/ServerWindow.h b/src/servers/app/server/ServerWindow.h index da91c812ae..ce03de35dd 100644 --- a/src/servers/app/server/ServerWindow.h +++ b/src/servers/app/server/ServerWindow.h @@ -80,6 +80,7 @@ public: int32 GetWorkspaceIndex(void) { return _workspace_index; } Workspace *GetWorkspace(void) { return _workspace; } + void SetWorkspace(Workspace *wkspc); protected: friend ServerApp;