From e18224cdf4738dd04ea4f386aea2efa7bc5aa857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 21 Aug 2009 10:23:01 +0000 Subject: [PATCH] * 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 --- headers/private/app/ServerProtocol.h | 1 + src/kits/interface/PrivateScreen.cpp | 12 +++++++---- src/servers/app/Desktop.cpp | 32 ++++++++++++++++++++++++++++ src/servers/app/Desktop.h | 2 ++ src/servers/app/ServerApp.cpp | 25 +++++++++++++++++++++- 5 files changed, 67 insertions(+), 5 deletions(-) diff --git a/headers/private/app/ServerProtocol.h b/headers/private/app/ServerProtocol.h index 35519135dc..8e16b6ae09 100644 --- a/headers/private/app/ServerProtocol.h +++ b/headers/private/app/ServerProtocol.h @@ -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, diff --git a/src/kits/interface/PrivateScreen.cpp b/src/kits/interface/PrivateScreen.cpp index dd57300a23..7e9d38681c 100644 --- a/src/kits/interface/PrivateScreen.cpp +++ b/src/kits/interface/PrivateScreen.cpp @@ -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(ID()); + link.Attach(B_CURRENT_WORKSPACE_INDEX); + + status_t status = B_ERROR; + if (link.FlushWithReply(status) == B_OK && status == B_OK) { + link.Read(&fFrame); fLastUpdate = system_time(); } } diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index d2c8a7b825..013b173914 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -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) { diff --git a/src/servers/app/Desktop.h b/src/servers/app/Desktop.h index e27b8e863e..d0cee76713 100644 --- a/src/servers/app/Desktop.h +++ b/src/servers/app/Desktop.h @@ -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); diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 98fa6320d7..98848e9e7e 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -2280,6 +2280,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) // Attached data // 1) int32 screen // 2) uint32 workspace index + int32 id; link.Read(&id); uint32 workspace; @@ -2305,7 +2306,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) int32 id; link.Read(&id); - uint32 workspace; link.Read(&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(&id); + uint32 workspace; + link.Read(&workspace); + + BRect frame; + status_t status = fDesktop->GetScreenFrame(workspace, id, frame); + + fLink.StartMessage(status); + if (status == B_OK) + fLink.Attach(frame); + + fLink.Flush(); + break; + } + case AS_SCREEN_GET_COLORMAP: { STRACE(("ServerApp %s: AS_SCREEN_GET_COLORMAP\n", Signature()));