diff --git a/headers/os/interface/Screen.h b/headers/os/interface/Screen.h index 23e1b6c0b4..7967dbc38b 100644 --- a/headers/os/interface/Screen.h +++ b/headers/os/interface/Screen.h @@ -85,7 +85,7 @@ private: void* BaseAddress(); uint32 BytesPerRow(); - BPrivateScreen *screen; + BPrivateScreen *fScreen; }; diff --git a/headers/private/app/ServerProtocol.h b/headers/private/app/ServerProtocol.h index e2421f7d31..e0a9f60fa3 100644 --- a/headers/private/app/ServerProtocol.h +++ b/headers/private/app/ServerProtocol.h @@ -143,23 +143,24 @@ enum { AS_SCREEN_SET_MODE, AS_PROPOSE_MODE, AS_GET_MODE_LIST, - + AS_GET_PIXEL_CLOCK_LIMITS, AS_GET_TIMING_CONSTRAINTS, AS_SCREEN_GET_COLORMAP, AS_GET_DESKTOP_COLOR, AS_SET_DESKTOP_COLOR, + AS_GET_SCREEN_ID_FROM_WINDOW, AS_READ_BITMAP, - + AS_GET_RETRACE_SEMAPHORE, AS_GET_ACCELERANT_INFO, AS_SET_DPMS, AS_GET_DPMS_STATE, AS_GET_DPMS_CAPABILITIES, - + // Global function call defs AS_SET_UI_COLORS, AS_GET_UI_COLORS, diff --git a/src/kits/interface/PrivateScreen.cpp b/src/kits/interface/PrivateScreen.cpp index 37ef8f745a..289dc7edfc 100644 --- a/src/kits/interface/PrivateScreen.cpp +++ b/src/kits/interface/PrivateScreen.cpp @@ -12,6 +12,7 @@ */ +#include "AppMisc.h" #include "AppServerLink.h" #include "PrivateScreen.h" #include "ServerProtocol.h" @@ -47,8 +48,19 @@ using namespace BPrivate; BPrivateScreen * BPrivateScreen::CheckOut(BWindow *window) { - // TODO: get screen ID from window! - return CheckOut(B_MAIN_SCREEN_ID); + screen_id id = B_MAIN_SCREEN_ID; + + if (window != NULL) { + BPrivate::AppServerLink link; + link.StartMessage(AS_GET_SCREEN_ID_FROM_WINDOW); + link.Attach(_get_object_token_(window)); + + status_t status; + if (link.FlushWithReply(status) == B_OK && status == B_OK) + link.Read(&id); + } + + return CheckOut(id); } diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index fdaa6a078d..1c307b96e0 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -146,7 +146,7 @@ ServerApp::~ServerApp(void) // quit all server windows for (int32 i = fWindowList.CountItems(); i-- > 0;) { - ServerWindow* window = (ServerWindow*)fWindowList.ItemAt(i); + ServerWindow* window = fWindowList.ItemAt(i); window->Quit(); } int32 tries = fWindowList.CountItems() + 1; @@ -177,7 +177,7 @@ ServerApp::~ServerApp(void) fWindowListLock.Lock(); for (int32 i = 0; i < fWindowList.CountItems(); i++) { - ServerWindow* window = (ServerWindow*)fWindowList.ItemAt(i); + ServerWindow* window = fWindowList.ItemAt(i); printf("kill window \"%s\"\n", window->Title()); kill_thread(window->Thread()); @@ -650,7 +650,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) STRACE(("ServerApp %s: Received decorator update notification\n", Signature())); for (int32 i = 0; i < fWindowList.CountItems(); i++) { - ServerWindow *window = (ServerWindow*)fWindowList.ItemAt(i); + ServerWindow *window = fWindowList.ItemAt(i); window->Lock(); const_cast(window->GetWinBorder())->UpdateDecorator(); window->Unlock(); @@ -1968,7 +1968,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) } } - for (int32 i=0; i(&clientToken) != B_OK) + status = B_BAD_DATA; + else { + BAutolock locker(fWindowListLock); + + for (int32 i = fWindowList.CountItems(); i-- > 0;) { + ServerWindow* window = fWindowList.ItemAt(i); + + if (window->ClientToken() == clientToken) { + // got it! + fLink.StartMessage(B_OK); + fLink.Attach(B_MAIN_SCREEN_ID); + // TODO: for now... + status = B_OK; + } + } + } + + if (status != B_OK) + fLink.StartMessage(status); + fLink.Flush(); + break; + } + case AS_SCREEN_GET_MODE: { STRACE(("ServerApp %s: AS_SCREEN_GET_MODE\n", Signature())); diff --git a/src/servers/app/ServerApp.h b/src/servers/app/ServerApp.h index 1decbd6bdc..551a2dcf9f 100644 --- a/src/servers/app/ServerApp.h +++ b/src/servers/app/ServerApp.h @@ -17,17 +17,19 @@ #include "SubWindowList.h" #include "BGet++.h" +#include #include class AreaPool; class BMessage; class BList; +class Desktop; class DrawingEngine; class ServerPicture; class ServerCursor; class ServerBitmap; -class Desktop; +class ServerWindow; namespace BPrivate { class PortLink; @@ -93,7 +95,7 @@ class ServerApp : public MessageLooper { team_id fClientTeam; BLocker fWindowListLock; - BList fWindowList; + BObjectList fWindowList; // TODO: // - Are really Bitmaps and Pictures stored per application and not globally ? diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 27d9d34066..5c2195d4b2 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -131,7 +131,7 @@ struct dw_sync_data { monitor thread. */ ServerWindow::ServerWindow(const char *title, ServerApp *app, - port_id clientPort, port_id looperPort, int32 handlerID) + port_id clientPort, port_id looperPort, int32 clientToken) : MessageLooper(title && *title ? title : "Unnamed Window"), fTitle(NULL), fDesktop(app->GetDesktop()), @@ -142,7 +142,7 @@ ServerWindow::ServerWindow(const char *title, ServerApp *app, fClientReplyPort(clientPort), fClientLooperPort(looperPort), fClientViewsWithInvalidCoords(B_VIEW_RESIZED), - fHandlerToken(handlerID), + fClientToken(clientToken), fCurrentLayer(NULL), fDirectWindowData(NULL) { @@ -208,7 +208,7 @@ ServerWindow::Run() // Send a reply to our window - it is expecting fMessagePort // port and some other info - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach(fMessagePort); float minWidth, maxWidth, minHeight, maxHeight; diff --git a/src/servers/app/ServerWindow.h b/src/servers/app/ServerWindow.h index 4ac592bcdb..679097db6a 100644 --- a/src/servers/app/ServerWindow.h +++ b/src/servers/app/ServerWindow.h @@ -50,7 +50,7 @@ class ServerWindow : public MessageLooper { public: ServerWindow(const char *title, ServerApp *app, port_id clientPort, port_id looperPort, - int32 handlerID); + int32 clientToken); virtual ~ServerWindow(); status_t Init(BRect frame, uint32 look, @@ -97,8 +97,7 @@ public: void HandleDirectConnection(int bufferState = -1, int driverState = -1); - // server "private" - try not to use. - inline int32 ClientToken() const { return fHandlerToken; } + inline int32 ClientToken() const { return fClientToken; } inline int32 ServerToken() const { return fServerToken; } void GetInfo(window_info& info); @@ -143,7 +142,7 @@ private: BMessage fClientViewsWithInvalidCoords; int32 fServerToken; - int32 fHandlerToken; + int32 fClientToken; Layer* fCurrentLayer;