* Forgot to update Screen.h with the last commit...

* Introduced and implemented AS_GET_SCREEN_ID_FROM_WINDOW - it only returns B_MAIN_SCREEN_ID,
  though.
* renamed ServerWindow::fHandlerToken to fClientToken.
* The BScreen(BWindow *) constructor now really asks the server for the screen ID.
* ServerApp::fWindowList is now a BObjectList.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14910 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-14 12:08:21 +00:00
parent ef9b2fc28b
commit d9525baaf5
7 changed files with 64 additions and 19 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ private:
void* BaseAddress(); void* BaseAddress();
uint32 BytesPerRow(); uint32 BytesPerRow();
BPrivateScreen *screen; BPrivateScreen *fScreen;
}; };
+4 -3
View File
@@ -143,23 +143,24 @@ enum {
AS_SCREEN_SET_MODE, AS_SCREEN_SET_MODE,
AS_PROPOSE_MODE, AS_PROPOSE_MODE,
AS_GET_MODE_LIST, AS_GET_MODE_LIST,
AS_GET_PIXEL_CLOCK_LIMITS, AS_GET_PIXEL_CLOCK_LIMITS,
AS_GET_TIMING_CONSTRAINTS, AS_GET_TIMING_CONSTRAINTS,
AS_SCREEN_GET_COLORMAP, AS_SCREEN_GET_COLORMAP,
AS_GET_DESKTOP_COLOR, AS_GET_DESKTOP_COLOR,
AS_SET_DESKTOP_COLOR, AS_SET_DESKTOP_COLOR,
AS_GET_SCREEN_ID_FROM_WINDOW,
AS_READ_BITMAP, AS_READ_BITMAP,
AS_GET_RETRACE_SEMAPHORE, AS_GET_RETRACE_SEMAPHORE,
AS_GET_ACCELERANT_INFO, AS_GET_ACCELERANT_INFO,
AS_SET_DPMS, AS_SET_DPMS,
AS_GET_DPMS_STATE, AS_GET_DPMS_STATE,
AS_GET_DPMS_CAPABILITIES, AS_GET_DPMS_CAPABILITIES,
// Global function call defs // Global function call defs
AS_SET_UI_COLORS, AS_SET_UI_COLORS,
AS_GET_UI_COLORS, AS_GET_UI_COLORS,
+14 -2
View File
@@ -12,6 +12,7 @@
*/ */
#include "AppMisc.h"
#include "AppServerLink.h" #include "AppServerLink.h"
#include "PrivateScreen.h" #include "PrivateScreen.h"
#include "ServerProtocol.h" #include "ServerProtocol.h"
@@ -47,8 +48,19 @@ using namespace BPrivate;
BPrivateScreen * BPrivateScreen *
BPrivateScreen::CheckOut(BWindow *window) BPrivateScreen::CheckOut(BWindow *window)
{ {
// TODO: get screen ID from window! screen_id id = B_MAIN_SCREEN_ID;
return CheckOut(B_MAIN_SCREEN_ID);
if (window != NULL) {
BPrivate::AppServerLink link;
link.StartMessage(AS_GET_SCREEN_ID_FROM_WINDOW);
link.Attach<int32>(_get_object_token_(window));
status_t status;
if (link.FlushWithReply(status) == B_OK && status == B_OK)
link.Read<screen_id>(&id);
}
return CheckOut(id);
} }
+35 -4
View File
@@ -146,7 +146,7 @@ ServerApp::~ServerApp(void)
// quit all server windows // quit all server windows
for (int32 i = fWindowList.CountItems(); i-- > 0;) { for (int32 i = fWindowList.CountItems(); i-- > 0;) {
ServerWindow* window = (ServerWindow*)fWindowList.ItemAt(i); ServerWindow* window = fWindowList.ItemAt(i);
window->Quit(); window->Quit();
} }
int32 tries = fWindowList.CountItems() + 1; int32 tries = fWindowList.CountItems() + 1;
@@ -177,7 +177,7 @@ ServerApp::~ServerApp(void)
fWindowListLock.Lock(); fWindowListLock.Lock();
for (int32 i = 0; i < fWindowList.CountItems(); i++) { 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()); printf("kill window \"%s\"\n", window->Title());
kill_thread(window->Thread()); kill_thread(window->Thread());
@@ -650,7 +650,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
STRACE(("ServerApp %s: Received decorator update notification\n", Signature())); STRACE(("ServerApp %s: Received decorator update notification\n", Signature()));
for (int32 i = 0; i < fWindowList.CountItems(); i++) { for (int32 i = 0; i < fWindowList.CountItems(); i++) {
ServerWindow *window = (ServerWindow*)fWindowList.ItemAt(i); ServerWindow *window = fWindowList.ItemAt(i);
window->Lock(); window->Lock();
const_cast<WinBorder *>(window->GetWinBorder())->UpdateDecorator(); const_cast<WinBorder *>(window->GetWinBorder())->UpdateDecorator();
window->Unlock(); window->Unlock();
@@ -1968,7 +1968,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
} }
} }
for (int32 i=0; i<numStrings; i++) for (int32 i = 0; i < numStrings; i++)
free(stringArray[i]); free(stringArray[i]);
if (!success) if (!success)
@@ -1980,6 +1980,37 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
/* screen commands */ /* screen commands */
case AS_GET_SCREEN_ID_FROM_WINDOW:
{
status_t status = B_ENTRY_NOT_FOUND;
// Attached data
// 1) int32 - window client token
int32 clientToken;
if (link.Read<int32>(&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<screen_id>(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: case AS_SCREEN_GET_MODE:
{ {
STRACE(("ServerApp %s: AS_SCREEN_GET_MODE\n", Signature())); STRACE(("ServerApp %s: AS_SCREEN_GET_MODE\n", Signature()));
+4 -2
View File
@@ -17,17 +17,19 @@
#include "SubWindowList.h" #include "SubWindowList.h"
#include "BGet++.h" #include "BGet++.h"
#include <ObjectList.h>
#include <String.h> #include <String.h>
class AreaPool; class AreaPool;
class BMessage; class BMessage;
class BList; class BList;
class Desktop;
class DrawingEngine; class DrawingEngine;
class ServerPicture; class ServerPicture;
class ServerCursor; class ServerCursor;
class ServerBitmap; class ServerBitmap;
class Desktop; class ServerWindow;
namespace BPrivate { namespace BPrivate {
class PortLink; class PortLink;
@@ -93,7 +95,7 @@ class ServerApp : public MessageLooper {
team_id fClientTeam; team_id fClientTeam;
BLocker fWindowListLock; BLocker fWindowListLock;
BList fWindowList; BObjectList<ServerWindow> fWindowList;
// TODO: // TODO:
// - Are really Bitmaps and Pictures stored per application and not globally ? // - Are really Bitmaps and Pictures stored per application and not globally ?
+3 -3
View File
@@ -131,7 +131,7 @@ struct dw_sync_data {
monitor thread. monitor thread.
*/ */
ServerWindow::ServerWindow(const char *title, ServerApp *app, 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"), : MessageLooper(title && *title ? title : "Unnamed Window"),
fTitle(NULL), fTitle(NULL),
fDesktop(app->GetDesktop()), fDesktop(app->GetDesktop()),
@@ -142,7 +142,7 @@ ServerWindow::ServerWindow(const char *title, ServerApp *app,
fClientReplyPort(clientPort), fClientReplyPort(clientPort),
fClientLooperPort(looperPort), fClientLooperPort(looperPort),
fClientViewsWithInvalidCoords(B_VIEW_RESIZED), fClientViewsWithInvalidCoords(B_VIEW_RESIZED),
fHandlerToken(handlerID), fClientToken(clientToken),
fCurrentLayer(NULL), fCurrentLayer(NULL),
fDirectWindowData(NULL) fDirectWindowData(NULL)
{ {
@@ -208,7 +208,7 @@ ServerWindow::Run()
// Send a reply to our window - it is expecting fMessagePort // Send a reply to our window - it is expecting fMessagePort
// port and some other info // port and some other info
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(B_OK);
fLink.Attach<port_id>(fMessagePort); fLink.Attach<port_id>(fMessagePort);
float minWidth, maxWidth, minHeight, maxHeight; float minWidth, maxWidth, minHeight, maxHeight;
+3 -4
View File
@@ -50,7 +50,7 @@ class ServerWindow : public MessageLooper {
public: public:
ServerWindow(const char *title, ServerApp *app, ServerWindow(const char *title, ServerApp *app,
port_id clientPort, port_id looperPort, port_id clientPort, port_id looperPort,
int32 handlerID); int32 clientToken);
virtual ~ServerWindow(); virtual ~ServerWindow();
status_t Init(BRect frame, uint32 look, status_t Init(BRect frame, uint32 look,
@@ -97,8 +97,7 @@ public:
void HandleDirectConnection(int bufferState = -1, int driverState = -1); void HandleDirectConnection(int bufferState = -1, int driverState = -1);
// server "private" - try not to use. inline int32 ClientToken() const { return fClientToken; }
inline int32 ClientToken() const { return fHandlerToken; }
inline int32 ServerToken() const { return fServerToken; } inline int32 ServerToken() const { return fServerToken; }
void GetInfo(window_info& info); void GetInfo(window_info& info);
@@ -143,7 +142,7 @@ private:
BMessage fClientViewsWithInvalidCoords; BMessage fClientViewsWithInvalidCoords;
int32 fServerToken; int32 fServerToken;
int32 fHandlerToken; int32 fClientToken;
Layer* fCurrentLayer; Layer* fCurrentLayer;