* Added a new AS_GET_SCREEN_FRAME function, as getting the frame via

AS_SCREEN_GET_MODE won't work with multi-screen support anymore, and is also
  more overhead than needed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32559 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-08-21 10:23:01 +00:00
parent f7e005eb83
commit e18224cdf4
5 changed files with 67 additions and 5 deletions

View File

@ -149,6 +149,7 @@ enum {
AS_SCREEN_SET_MODE,
AS_PROPOSE_MODE,
AS_GET_MODE_LIST,
AS_GET_SCREEN_FRAME,
AS_GET_PIXEL_CLOCK_LIMITS,
AS_GET_TIMING_CONSTRAINTS,

View File

@ -175,10 +175,14 @@ BPrivateScreen::Frame()
if (system_time() > fLastUpdate + 10000) {
// invalidate the settings after 10 msecs
display_mode mode;
if (GetMode(B_CURRENT_WORKSPACE_INDEX, &mode) == B_OK) {
fFrame.Set(0, 0, (float)mode.virtual_width - 1,
(float)mode.virtual_height - 1);
BPrivate::AppServerLink link;
link.StartMessage(AS_GET_SCREEN_FRAME);
link.Attach<int32>(ID());
link.Attach<uint32>(B_CURRENT_WORKSPACE_INDEX);
status_t status = B_ERROR;
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
link.Read<BRect>(&fFrame);
fLastUpdate = system_time();
}
}

View File

@ -1214,6 +1214,38 @@ Desktop::GetScreenMode(int32 workspace, int32 id, display_mode& mode)
}
status_t
Desktop::GetScreenFrame(int32 workspace, int32 id, BRect& frame)
{
if (workspace == B_CURRENT_WORKSPACE_INDEX)
workspace = fCurrentWorkspace;
if (workspace < 0 || workspace > kMaxWorkspaces)
return B_BAD_VALUE;
AutoReadLocker _(fWindowLock);
if (workspace == fCurrentWorkspace) {
// retrieve from current screen
Screen* screen = fVirtualScreen.ScreenByID(id);
if (screen == NULL)
return B_NAME_NOT_FOUND;
frame = screen->Frame();
return B_OK;
}
// retrieve from settings
screen_configuration* configuration
= fWorkspaces[workspace].CurrentScreenConfiguration().CurrentByID(id);
if (configuration == NULL)
return B_NAME_NOT_FOUND;
frame = configuration->frame;
return B_OK;
}
void
Desktop::ScreenChanged(Screen* screen)
{

View File

@ -101,6 +101,8 @@ class Desktop : public MessageLooper, public ScreenOwner {
const display_mode& mode, bool makeDefault);
status_t GetScreenMode(int32 workspace, int32 id,
display_mode& mode);
status_t GetScreenFrame(int32 workspace, int32 id,
BRect& frame);
void ScreenChanged(Screen* screen);

View File

@ -2280,6 +2280,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
// Attached data
// 1) int32 screen
// 2) uint32 workspace index
int32 id;
link.Read<int32>(&id);
uint32 workspace;
@ -2305,7 +2306,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
int32 id;
link.Read<int32>(&id);
uint32 workspace;
link.Read<uint32>(&workspace);
@ -2374,6 +2374,29 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
break;
}
case AS_GET_SCREEN_FRAME:
{
STRACE(("ServerApp %s: AS_GET_SCREEN_FRAME\n", Signature()));
// Attached data
// 1) int32 screen
// 2) uint32 workspace index
int32 id;
link.Read<int32>(&id);
uint32 workspace;
link.Read<uint32>(&workspace);
BRect frame;
status_t status = fDesktop->GetScreenFrame(workspace, id, frame);
fLink.StartMessage(status);
if (status == B_OK)
fLink.Attach<BRect>(frame);
fLink.Flush();
break;
}
case AS_SCREEN_GET_COLORMAP:
{
STRACE(("ServerApp %s: AS_SCREEN_GET_COLORMAP\n", Signature()));