* Rewrote screen configuration management: VirtualScreen doesn't have anything
to do with the configurations now, instead, there is a separated
ScreenConfigurations class that maintains all known screen_configurations
per workspace (and the Workspace::Private class has two of them, one for the
current modes, one for the stored modes).
* Added Desktop::{Get|Set}ScreenMode() methods, ServerApp now only calls those.
* Getting and setting of anything else than the current screen is now supported.
* This change also fixes that a temporarily set screen mode was not being
restored on workspace switch.
* Also, the Deskbar now seems to have the wrong location a lot, which is
something that should be easily fixable therefore. I will look into this next.
* Got rid of the unhandy screen_id structure server side, and in BPrivateScreen;
we now just use an int32 - the next API break should definitely replace the
screen_id with a simple typedef.
* Some cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32541 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,11 +9,12 @@
|
|||||||
* Axel Dörfler, [email protected]
|
* Axel Dörfler, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
BBitmap objects represent off-screen windows that
|
/*! BBitmap objects represent off-screen windows that
|
||||||
contain bitmap data.
|
contain bitmap data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2006, Haiku Inc.
|
* Copyright 2002-2009, Haiku Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
* Axel Dörfler, [email protected]
|
* Axel Dörfler, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
BPrivateScreen is the class which does the real work for
|
/*! BPrivateScreen is the class which does the real work for
|
||||||
the proxy class BScreen (it interacts with the app_server).
|
the proxy class BScreen (it interacts with the app_server).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -37,10 +37,10 @@ static BObjectList<BPrivateScreen> sScreens(2, true);
|
|||||||
static BLocker sScreenLock("screen lock");
|
static BLocker sScreenLock("screen lock");
|
||||||
|
|
||||||
|
|
||||||
BPrivateScreen *
|
BPrivateScreen*
|
||||||
BPrivateScreen::Get(BWindow *window)
|
BPrivateScreen::Get(BWindow* window)
|
||||||
{
|
{
|
||||||
screen_id id = B_MAIN_SCREEN_ID;
|
int32 id = B_MAIN_SCREEN_ID.id;
|
||||||
|
|
||||||
if (window != NULL) {
|
if (window != NULL) {
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
@@ -49,22 +49,22 @@ BPrivateScreen::Get(BWindow *window)
|
|||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
if (link.FlushWithReply(status) == B_OK && status == B_OK)
|
if (link.FlushWithReply(status) == B_OK && status == B_OK)
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _Get(id, false);
|
return _Get(id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BPrivateScreen *
|
BPrivateScreen*
|
||||||
BPrivateScreen::Get(screen_id id)
|
BPrivateScreen::Get(int32 id)
|
||||||
{
|
{
|
||||||
return _Get(id, true);
|
return _Get(id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BPrivateScreen *
|
BPrivateScreen*
|
||||||
BPrivateScreen::_Get(screen_id id, bool check)
|
BPrivateScreen::_Get(int32 id, bool check)
|
||||||
{
|
{
|
||||||
// Nothing works without an app_server connection
|
// Nothing works without an app_server connection
|
||||||
if (be_app == NULL)
|
if (be_app == NULL)
|
||||||
@@ -77,7 +77,7 @@ BPrivateScreen::_Get(screen_id id, bool check)
|
|||||||
for (int32 i = sScreens.CountItems(); i-- > 0;) {
|
for (int32 i = sScreens.CountItems(); i-- > 0;) {
|
||||||
BPrivateScreen* screen = sScreens.ItemAt(i);
|
BPrivateScreen* screen = sScreens.ItemAt(i);
|
||||||
|
|
||||||
if (screen->ID().id == id.id) {
|
if (screen->ID() == id) {
|
||||||
screen->_Acquire();
|
screen->_Acquire();
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ BPrivateScreen::Put(BPrivateScreen* screen)
|
|||||||
BAutolock locker(sScreenLock);
|
BAutolock locker(sScreenLock);
|
||||||
|
|
||||||
if (screen->_Release()) {
|
if (screen->_Release()) {
|
||||||
if (screen->ID().id != B_MAIN_SCREEN_ID.id) {
|
if (screen->ID() != B_MAIN_SCREEN_ID.id) {
|
||||||
// we always keep the main screen object around - it will
|
// we always keep the main screen object around - it will
|
||||||
// never go away, even if you disconnect all monitors.
|
// never go away, even if you disconnect all monitors.
|
||||||
sScreens.RemoveItem(screen);
|
sScreens.RemoveItem(screen);
|
||||||
@@ -123,9 +123,9 @@ BPrivateScreen::GetNext(BPrivateScreen* screen)
|
|||||||
{
|
{
|
||||||
BAutolock locker(sScreenLock);
|
BAutolock locker(sScreenLock);
|
||||||
|
|
||||||
screen_id id;
|
int32 id;
|
||||||
status_t status = screen->GetNextID(id);
|
status_t status = screen->GetNextID(id);
|
||||||
if (status < B_OK)
|
if (status != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BPrivateScreen* nextScreen = Get(id);
|
BPrivateScreen* nextScreen = Get(id);
|
||||||
@@ -138,11 +138,11 @@ BPrivateScreen::GetNext(BPrivateScreen* screen)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BPrivateScreen::_IsValid(screen_id id)
|
BPrivateScreen::_IsValid(int32 id)
|
||||||
{
|
{
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_VALID_SCREEN_ID);
|
link.StartMessage(AS_VALID_SCREEN_ID);
|
||||||
link.Attach<screen_id>(id);
|
link.Attach<int32>(id);
|
||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
if (link.FlushWithReply(status) != B_OK || status < B_OK)
|
if (link.FlushWithReply(status) != B_OK || status < B_OK)
|
||||||
@@ -193,15 +193,15 @@ BPrivateScreen::IsValid() const
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BPrivateScreen::GetNextID(screen_id& id)
|
BPrivateScreen::GetNextID(int32& id)
|
||||||
{
|
{
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_NEXT_SCREEN_ID);
|
link.StartMessage(AS_GET_NEXT_SCREEN_ID);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ BPrivateScreen::GetNextID(screen_id& id)
|
|||||||
status_t
|
status_t
|
||||||
BPrivateScreen::WaitForRetrace(bigtime_t timeout)
|
BPrivateScreen::WaitForRetrace(bigtime_t timeout)
|
||||||
{
|
{
|
||||||
// Get the retrace semaphore if it's the first time
|
// Get the retrace semaphore if it's the first time
|
||||||
// we are called. Cache the value then.
|
// we are called. Cache the value then.
|
||||||
if (!fRetraceSemValid)
|
if (!fRetraceSemValid)
|
||||||
fRetraceSem = _RetraceSemaphore();
|
fRetraceSem = _RetraceSemaphore();
|
||||||
@@ -230,7 +230,7 @@ BPrivateScreen::WaitForRetrace(bigtime_t timeout)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8
|
uint8
|
||||||
BPrivateScreen::IndexForColor(uint8 red, uint8 green, uint8 blue, uint8 alpha)
|
BPrivateScreen::IndexForColor(uint8 red, uint8 green, uint8 blue, uint8 alpha)
|
||||||
{
|
{
|
||||||
@@ -267,9 +267,9 @@ BPrivateScreen::InvertIndex(uint8 index)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const color_map *
|
|
||||||
|
const color_map*
|
||||||
BPrivateScreen::ColorMap()
|
BPrivateScreen::ColorMap()
|
||||||
{
|
{
|
||||||
if (fColorMap == NULL) {
|
if (fColorMap == NULL) {
|
||||||
@@ -285,11 +285,11 @@ BPrivateScreen::ColorMap()
|
|||||||
// which is contained in a shared area created by the server.
|
// which is contained in a shared area created by the server.
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_SCREEN_GET_COLORMAP);
|
link.StartMessage(AS_SCREEN_GET_COLORMAP);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
||||||
fColorMap = (color_map *)malloc(sizeof(color_map));
|
fColorMap = (color_map*)malloc(sizeof(color_map));
|
||||||
fOwnsColorMap = true;
|
fOwnsColorMap = true;
|
||||||
link.Read<color_map>(fColorMap);
|
link.Read<color_map>(fColorMap);
|
||||||
}
|
}
|
||||||
@@ -300,7 +300,7 @@ BPrivateScreen::ColorMap()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BPrivateScreen::GetBitmap(BBitmap **_bitmap, bool drawCursor, BRect *bounds)
|
BPrivateScreen::GetBitmap(BBitmap**_bitmap, bool drawCursor, BRect* bounds)
|
||||||
{
|
{
|
||||||
if (_bitmap == NULL)
|
if (_bitmap == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -329,7 +329,7 @@ BPrivateScreen::GetBitmap(BBitmap **_bitmap, bool drawCursor, BRect *bounds)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BPrivateScreen::ReadBitmap(BBitmap *bitmap, bool drawCursor, BRect *bounds)
|
BPrivateScreen::ReadBitmap(BBitmap* bitmap, bool drawCursor, BRect* bounds)
|
||||||
{
|
{
|
||||||
if (bitmap == NULL)
|
if (bitmap == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -353,7 +353,7 @@ BPrivateScreen::ReadBitmap(BBitmap *bitmap, bool drawCursor, BRect *bounds)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
rgb_color
|
rgb_color
|
||||||
BPrivateScreen::DesktopColor(uint32 workspace)
|
BPrivateScreen::DesktopColor(uint32 workspace)
|
||||||
{
|
{
|
||||||
@@ -387,18 +387,18 @@ BPrivateScreen::SetDesktopColor(rgb_color color, uint32 workspace,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BPrivateScreen::ProposeMode(display_mode *target,
|
BPrivateScreen::ProposeMode(display_mode* target,
|
||||||
const display_mode *low, const display_mode *high)
|
const display_mode* low, const display_mode* high)
|
||||||
{
|
{
|
||||||
// We can't return B_BAD_VALUE here, because it's used to indicate
|
// We can't return B_BAD_VALUE here, because it's used to indicate
|
||||||
// that the mode returned is supported, but it doesn't fall
|
// that the mode returned is supported, but it doesn't fall
|
||||||
// within the limit (see ProposeMode() documentation)
|
// within the limit (see ProposeMode() documentation)
|
||||||
if (target == NULL || low == NULL || high == NULL)
|
if (target == NULL || low == NULL || high == NULL)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_PROPOSE_MODE);
|
link.StartMessage(AS_PROPOSE_MODE);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
link.Attach<display_mode>(*target);
|
link.Attach<display_mode>(*target);
|
||||||
link.Attach<display_mode>(*low);
|
link.Attach<display_mode>(*low);
|
||||||
link.Attach<display_mode>(*high);
|
link.Attach<display_mode>(*high);
|
||||||
@@ -415,17 +415,17 @@ BPrivateScreen::ProposeMode(display_mode *target,
|
|||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BPrivateScreen::GetModeList(display_mode **_modeList, uint32 *_count)
|
BPrivateScreen::GetModeList(display_mode** _modeList, uint32* _count)
|
||||||
{
|
{
|
||||||
if (_modeList == NULL || _count == NULL)
|
if (_modeList == NULL || _count == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_MODE_LIST);
|
link.StartMessage(AS_GET_MODE_LIST);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
|
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
||||||
@@ -460,7 +460,7 @@ BPrivateScreen::GetMode(uint32 workspace, display_mode *mode)
|
|||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_SCREEN_GET_MODE);
|
link.StartMessage(AS_SCREEN_GET_MODE);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
link.Attach<uint32>(workspace);
|
link.Attach<uint32>(workspace);
|
||||||
|
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
@@ -481,7 +481,7 @@ BPrivateScreen::SetMode(uint32 workspace, display_mode *mode, bool makeDefault)
|
|||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_SCREEN_SET_MODE);
|
link.StartMessage(AS_SCREEN_SET_MODE);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
link.Attach<uint32>(workspace);
|
link.Attach<uint32>(workspace);
|
||||||
link.Attach<display_mode>(*mode);
|
link.Attach<display_mode>(*mode);
|
||||||
link.Attach<bool>(makeDefault);
|
link.Attach<bool>(makeDefault);
|
||||||
@@ -501,7 +501,7 @@ BPrivateScreen::GetDeviceInfo(accelerant_device_info *info)
|
|||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_ACCELERANT_INFO);
|
link.StartMessage(AS_GET_ACCELERANT_INFO);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
|
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
||||||
@@ -521,7 +521,7 @@ BPrivateScreen::GetMonitorInfo(monitor_info* info)
|
|||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_MONITOR_INFO);
|
link.StartMessage(AS_GET_MONITOR_INFO);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
|
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
||||||
@@ -541,7 +541,7 @@ BPrivateScreen::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *hig
|
|||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_PIXEL_CLOCK_LIMITS);
|
link.StartMessage(AS_GET_PIXEL_CLOCK_LIMITS);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
link.Attach<display_mode>(*mode);
|
link.Attach<display_mode>(*mode);
|
||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
@@ -563,7 +563,7 @@ BPrivateScreen::GetTimingConstraints(display_timing_constraints *constraints)
|
|||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_TIMING_CONSTRAINTS);
|
link.StartMessage(AS_GET_TIMING_CONSTRAINTS);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
|
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
||||||
@@ -580,7 +580,7 @@ BPrivateScreen::SetDPMS(uint32 dpmsState)
|
|||||||
{
|
{
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_SET_DPMS);
|
link.StartMessage(AS_SET_DPMS);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
link.Attach<uint32>(dpmsState);
|
link.Attach<uint32>(dpmsState);
|
||||||
|
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
@@ -597,7 +597,7 @@ BPrivateScreen::DPMSState()
|
|||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_DPMS_STATE);
|
link.StartMessage(AS_GET_DPMS_STATE);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
if (link.FlushWithReply(status) == B_OK && status == B_OK)
|
if (link.FlushWithReply(status) == B_OK && status == B_OK)
|
||||||
@@ -614,7 +614,7 @@ BPrivateScreen::DPMSCapabilites()
|
|||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_DPMS_CAPABILITIES);
|
link.StartMessage(AS_GET_DPMS_CAPABILITIES);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
if (link.FlushWithReply(status) == B_OK && status == B_OK)
|
if (link.FlushWithReply(status) == B_OK && status == B_OK)
|
||||||
@@ -645,7 +645,7 @@ BPrivateScreen::BytesPerRow()
|
|||||||
return config.bytes_per_row;
|
return config.bytes_per_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - private methods
|
// #pragma mark - private methods
|
||||||
|
|
||||||
|
|
||||||
@@ -654,7 +654,7 @@ BPrivateScreen::_RetraceSemaphore()
|
|||||||
{
|
{
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_RETRACE_SEMAPHORE);
|
link.StartMessage(AS_GET_RETRACE_SEMAPHORE);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
|
|
||||||
sem_id id = B_BAD_SEM_ID;
|
sem_id id = B_BAD_SEM_ID;
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
@@ -672,7 +672,7 @@ BPrivateScreen::_GetFrameBufferConfig(frame_buffer_config& config)
|
|||||||
{
|
{
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_FRAME_BUFFER_CONFIG);
|
link.StartMessage(AS_GET_FRAME_BUFFER_CONFIG);
|
||||||
link.Attach<screen_id>(ID());
|
link.Attach<int32>(ID());
|
||||||
|
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
if (link.FlushWithReply(status) == B_OK && status == B_OK) {
|
||||||
@@ -684,7 +684,7 @@ BPrivateScreen::_GetFrameBufferConfig(frame_buffer_config& config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BPrivateScreen::BPrivateScreen(screen_id id)
|
BPrivateScreen::BPrivateScreen(int32 id)
|
||||||
:
|
:
|
||||||
fID(id),
|
fID(id),
|
||||||
fColorMap(NULL),
|
fColorMap(NULL),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2007, Haiku Inc.
|
* Copyright 2002-2009, Haiku Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
#include <ObjectList.h>
|
#include <ObjectList.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
|
|
||||||
|
|
||||||
struct color_map;
|
struct color_map;
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
class BApplication;
|
class BApplication;
|
||||||
@@ -24,78 +25,88 @@ class BWindow;
|
|||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
class BPrivateScreen {
|
class BPrivateScreen {
|
||||||
|
public:
|
||||||
// Constructor and destructor are private. Use the static methods
|
// Constructor and destructor are private. Use the static methods
|
||||||
// CheckOut() and Return() instead.
|
// Get() and Put() instead.
|
||||||
public:
|
|
||||||
static BPrivateScreen* Get(BWindow *window);
|
|
||||||
static BPrivateScreen* Get(screen_id id);
|
|
||||||
static void Put(BPrivateScreen *screen);
|
|
||||||
|
|
||||||
static BPrivateScreen* GetNext(BPrivateScreen* screen);
|
static BPrivateScreen* Get(BWindow* window);
|
||||||
|
static BPrivateScreen* Get(int32 id);
|
||||||
|
static void Put(BPrivateScreen* screen);
|
||||||
|
|
||||||
bool IsValid() const;
|
static BPrivateScreen* GetNext(BPrivateScreen* screen);
|
||||||
color_space ColorSpace();
|
|
||||||
BRect Frame();
|
|
||||||
screen_id ID() const { return fID; }
|
|
||||||
status_t GetNextID(screen_id& id);
|
|
||||||
|
|
||||||
status_t WaitForRetrace(bigtime_t timeout);
|
bool IsValid() const;
|
||||||
|
color_space ColorSpace();
|
||||||
|
BRect Frame();
|
||||||
|
int32 ID() const { return fID; }
|
||||||
|
status_t GetNextID(int32& id);
|
||||||
|
|
||||||
uint8 IndexForColor(uint8 red, uint8 green, uint8 blue, uint8 alpha);
|
status_t WaitForRetrace(bigtime_t timeout);
|
||||||
rgb_color ColorForIndex(const uint8 index);
|
|
||||||
uint8 InvertIndex(uint8 index);
|
|
||||||
|
|
||||||
const color_map *ColorMap();
|
uint8 IndexForColor(uint8 red, uint8 green,
|
||||||
|
uint8 blue, uint8 alpha);
|
||||||
|
rgb_color ColorForIndex(const uint8 index);
|
||||||
|
uint8 InvertIndex(uint8 index);
|
||||||
|
|
||||||
status_t GetBitmap(BBitmap **bitmap, bool drawCursor, BRect *bounds);
|
const color_map* ColorMap();
|
||||||
status_t ReadBitmap(BBitmap *bitmap, bool drawCursor, BRect *bounds);
|
|
||||||
|
|
||||||
rgb_color DesktopColor(uint32 index);
|
status_t GetBitmap(BBitmap** bitmap, bool drawCursor,
|
||||||
void SetDesktopColor(rgb_color, uint32, bool);
|
BRect* bounds);
|
||||||
|
status_t ReadBitmap(BBitmap* bitmap, bool drawCursor,
|
||||||
|
BRect* bounds);
|
||||||
|
|
||||||
status_t ProposeMode(display_mode *target, const display_mode *low,
|
rgb_color DesktopColor(uint32 index);
|
||||||
const display_mode *high);
|
void SetDesktopColor(rgb_color, uint32, bool);
|
||||||
|
|
||||||
status_t GetModeList(display_mode **_modeList, uint32 *_count);
|
status_t ProposeMode(display_mode* target,
|
||||||
status_t GetMode(uint32 workspace, display_mode *mode);
|
const display_mode* low,
|
||||||
status_t SetMode(uint32 workspace, display_mode *mode, bool makeDefault);
|
const display_mode* high);
|
||||||
|
|
||||||
status_t GetDeviceInfo(accelerant_device_info *info);
|
status_t GetModeList(display_mode** _modeList,
|
||||||
status_t GetMonitorInfo(monitor_info* info);
|
uint32* _count);
|
||||||
status_t GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high);
|
status_t GetMode(uint32 workspace, display_mode* mode);
|
||||||
status_t GetTimingConstraints(display_timing_constraints *constraints);
|
status_t SetMode(uint32 workspace, display_mode* mode,
|
||||||
|
bool makeDefault);
|
||||||
|
|
||||||
status_t SetDPMS(uint32 dpmsState);
|
status_t GetDeviceInfo(accelerant_device_info* info);
|
||||||
uint32 DPMSState();
|
status_t GetMonitorInfo(monitor_info* info);
|
||||||
uint32 DPMSCapabilites();
|
status_t GetPixelClockLimits(display_mode* mode,
|
||||||
|
uint32* _low, uint32* _high);
|
||||||
|
status_t GetTimingConstraints(
|
||||||
|
display_timing_constraints* constraints);
|
||||||
|
|
||||||
void* BaseAddress();
|
status_t SetDPMS(uint32 dpmsState);
|
||||||
uint32 BytesPerRow();
|
uint32 DPMSState();
|
||||||
|
uint32 DPMSCapabilites();
|
||||||
|
|
||||||
private:
|
void* BaseAddress();
|
||||||
friend class BObjectList<BPrivateScreen>;
|
uint32 BytesPerRow();
|
||||||
|
|
||||||
BPrivateScreen(screen_id id);
|
private:
|
||||||
~BPrivateScreen();
|
friend class BObjectList<BPrivateScreen>;
|
||||||
|
|
||||||
void _Acquire() { fRefCount++; }
|
BPrivateScreen(int32 id);
|
||||||
bool _Release() { return --fRefCount == 0; }
|
~BPrivateScreen();
|
||||||
|
|
||||||
sem_id _RetraceSemaphore();
|
void _Acquire() { fRefCount++; }
|
||||||
status_t _GetFrameBufferConfig(frame_buffer_config& config);
|
bool _Release() { return --fRefCount == 0; }
|
||||||
|
|
||||||
static BPrivateScreen* _Get(screen_id id, bool check);
|
sem_id _RetraceSemaphore();
|
||||||
static bool _IsValid(screen_id id);
|
status_t _GetFrameBufferConfig(
|
||||||
|
frame_buffer_config& config);
|
||||||
|
|
||||||
private:
|
static BPrivateScreen* _Get(int32 id, bool check);
|
||||||
screen_id fID;
|
static bool _IsValid(int32 id);
|
||||||
int32 fRefCount;
|
|
||||||
color_map* fColorMap;
|
private:
|
||||||
sem_id fRetraceSem;
|
int32 fID;
|
||||||
bool fRetraceSemValid;
|
int32 fRefCount;
|
||||||
bool fOwnsColorMap;
|
color_map* fColorMap;
|
||||||
BRect fFrame;
|
sem_id fRetraceSem;
|
||||||
bigtime_t fLastUpdate;
|
bool fRetraceSemValid;
|
||||||
|
bool fOwnsColorMap;
|
||||||
|
BRect fFrame;
|
||||||
|
bigtime_t fLastUpdate;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2007, Haiku Inc.
|
* Copyright 2003-2009, Haiku Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -20,7 +20,8 @@ using namespace BPrivate;
|
|||||||
|
|
||||||
static const uint32 kCurrentWorkspaceIndex = ~0;
|
static const uint32 kCurrentWorkspaceIndex = ~0;
|
||||||
|
|
||||||
/*! \brief Creates a BScreen object which represents the display with the given screen_id
|
/*! \brief Creates a BScreen object which represents the display with the given
|
||||||
|
screen_id
|
||||||
\param id The screen_id of the screen to get.
|
\param id The screen_id of the screen to get.
|
||||||
|
|
||||||
In the current implementation, there is only one display (B_MAIN_SCREEN_ID).
|
In the current implementation, there is only one display (B_MAIN_SCREEN_ID).
|
||||||
@@ -28,7 +29,7 @@ static const uint32 kCurrentWorkspaceIndex = ~0;
|
|||||||
*/
|
*/
|
||||||
BScreen::BScreen(screen_id id)
|
BScreen::BScreen(screen_id id)
|
||||||
{
|
{
|
||||||
fScreen = BPrivateScreen::Get(id);
|
fScreen = BPrivateScreen::Get(id.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -36,21 +37,22 @@ BScreen::BScreen(screen_id id)
|
|||||||
the given BWindow.
|
the given BWindow.
|
||||||
\param window A BWindow.
|
\param window A BWindow.
|
||||||
*/
|
*/
|
||||||
BScreen::BScreen(BWindow *window)
|
BScreen::BScreen(BWindow* window)
|
||||||
{
|
{
|
||||||
fScreen = BPrivateScreen::Get(window);
|
fScreen = BPrivateScreen::Get(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Releases the resources allocated by the constructor.
|
/*! \brief Releases the resources allocated by the constructor.
|
||||||
*/
|
*/
|
||||||
BScreen::~BScreen()
|
BScreen::~BScreen()
|
||||||
{
|
{
|
||||||
BPrivateScreen::Put(fScreen);
|
BPrivateScreen::Put(fScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Checks if the BScreen object represents a real screen connected to the computer.
|
/*! \brief Checks if the BScreen object represents a real screen connected to
|
||||||
|
the computer.
|
||||||
\return \c true if the BScreen object is valid, \c false if not.
|
\return \c true if the BScreen object is valid, \c false if not.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
@@ -90,7 +92,8 @@ BScreen::ColorSpace()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Returns the rectangle that locates the screen in the screen coordinate system.
|
/*! \brief Returns the rectangle that locates the screen in the screen
|
||||||
|
coordinate system.
|
||||||
\return a BRect that locates the screen in the screen coordinate system.
|
\return a BRect that locates the screen in the screen coordinate system.
|
||||||
*/
|
*/
|
||||||
BRect
|
BRect
|
||||||
@@ -98,21 +101,24 @@ BScreen::Frame()
|
|||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->Frame();
|
return fScreen->Frame();
|
||||||
return BRect(0, 0, 0, 0);
|
return BRect(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Returns the identifier for the screen.
|
/*! \brief Returns the identifier for the screen.
|
||||||
\return A screen_id struct that identifies the screen.
|
\return A screen_id struct that identifies the screen.
|
||||||
|
|
||||||
In the current implementation, this function always returns \c B_MAIN_SCREEN_ID,
|
In the current implementation, this function always returns
|
||||||
even if the object is invalid.
|
\c B_MAIN_SCREEN_ID, even if the object is invalid.
|
||||||
*/
|
*/
|
||||||
screen_id
|
screen_id
|
||||||
BScreen::ID()
|
BScreen::ID()
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL) {
|
||||||
return fScreen->ID();
|
screen_id id = { fScreen->ID() };
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
return B_MAIN_SCREEN_ID;
|
return B_MAIN_SCREEN_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +135,8 @@ BScreen::WaitForRetrace()
|
|||||||
|
|
||||||
/*! \brief Blocks until the monitor has finished the current vertical retrace,
|
/*! \brief Blocks until the monitor has finished the current vertical retrace,
|
||||||
or until the given timeout has passed.
|
or until the given timeout has passed.
|
||||||
\param timeout A bigtime_t which indicates the time to wait before returning.
|
\param timeout A bigtime_t which indicates the time to wait before
|
||||||
|
returning.
|
||||||
\return \c B_OK if the monitor has retraced in the given amount of time,
|
\return \c B_OK if the monitor has retraced in the given amount of time,
|
||||||
\c B_ERROR otherwise.
|
\c B_ERROR otherwise.
|
||||||
*/
|
*/
|
||||||
@@ -174,7 +181,8 @@ BScreen::ColorForIndex(const uint8 index)
|
|||||||
|
|
||||||
/*! \brief Returns the "inversion" of the given 8-bit color.
|
/*! \brief Returns the "inversion" of the given 8-bit color.
|
||||||
\param index An 8-bit color index.
|
\param index An 8-bit color index.
|
||||||
\return An 8-bit color index that represents the "inversion" of the given color.
|
\return An 8-bit color index that represents the "inversion" of the given
|
||||||
|
color.
|
||||||
*/
|
*/
|
||||||
uint8
|
uint8
|
||||||
BScreen::InvertIndex(uint8 index)
|
BScreen::InvertIndex(uint8 index)
|
||||||
@@ -198,34 +206,39 @@ BScreen::ColorMap()
|
|||||||
|
|
||||||
|
|
||||||
/*! \brief Copies the screen's contents into the first argument BBitmap.
|
/*! \brief Copies the screen's contents into the first argument BBitmap.
|
||||||
\param screen_shot A pointer to a BBitmap pointer, where the function will allocate a BBitmap for you.
|
\param screen_shot A pointer to a BBitmap pointer, where the function will
|
||||||
|
allocate a BBitmap for you.
|
||||||
\param draw_cursor Specifies if you want the cursor to be drawn.
|
\param draw_cursor Specifies if you want the cursor to be drawn.
|
||||||
\param bound Let you specify the area you want copied. If it's NULL, the entire screen is copied.
|
\param bound Let you specify the area you want copied. If it's NULL, the
|
||||||
|
entire screen is copied.
|
||||||
\return \c B_OK if the operation was succesful, \c B_ERROR on failure.
|
\return \c B_OK if the operation was succesful, \c B_ERROR on failure.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::GetBitmap(BBitmap **screen_shot, bool draw_cursor, BRect *bound)
|
BScreen::GetBitmap(BBitmap** _bitmap, bool drawCursor, BRect* bounds)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->GetBitmap(screen_shot, draw_cursor, bound);
|
return fScreen->GetBitmap(_bitmap, drawCursor, bounds);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Copies the screen's contents into the first argument BBitmap.
|
/*! \brief Copies the screen's contents into the first argument BBitmap.
|
||||||
\param screen_shot A pointer to an allocated BBitmap, where the function will store the screen's content.
|
\param screen_shot A pointer to an allocated BBitmap, where the function
|
||||||
|
will store the screen's content.
|
||||||
\param draw_cursor Specifies if you want the cursor to be drawn.
|
\param draw_cursor Specifies if you want the cursor to be drawn.
|
||||||
\param bound Let you specify the area you want copied. If it's NULL, the entire screen is copied.
|
\param bound Let you specify the area you want copied. If it's NULL, the
|
||||||
|
entire screen is copied.
|
||||||
\return \c B_OK if the operation was succesful, \c B_ERROR on failure.
|
\return \c B_OK if the operation was succesful, \c B_ERROR on failure.
|
||||||
|
|
||||||
The only difference between this method and GetBitmap() is that ReadBitmap requires you
|
The only difference between this method and GetBitmap() is that ReadBitmap
|
||||||
to allocate a BBitmap, while the latter will allocate a BBitmap for you.
|
requires you to allocate a BBitmap, while the latter will allocate a BBitmap
|
||||||
|
for you.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::ReadBitmap(BBitmap *buffer, bool draw_cursor, BRect *bound)
|
BScreen::ReadBitmap(BBitmap* buffer, bool drawCursor, BRect* bounds)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->ReadBitmap(buffer, draw_cursor, bound);
|
return fScreen->ReadBitmap(buffer, drawCursor, bounds);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +258,8 @@ BScreen::DesktopColor()
|
|||||||
|
|
||||||
/*! \brief Returns the color of the desktop in the given workspace.
|
/*! \brief Returns the color of the desktop in the given workspace.
|
||||||
\param workspace The workspace of which you want to have the color.
|
\param workspace The workspace of which you want to have the color.
|
||||||
\return An rgb_color structure which is the color of the desktop in the given workspace.
|
\return An rgb_color structure which is the color of the desktop in the
|
||||||
|
given workspace.
|
||||||
*/
|
*/
|
||||||
rgb_color
|
rgb_color
|
||||||
BScreen::DesktopColor(uint32 workspace)
|
BScreen::DesktopColor(uint32 workspace)
|
||||||
@@ -259,7 +273,8 @@ BScreen::DesktopColor(uint32 workspace)
|
|||||||
|
|
||||||
/*! \brief Set the color of the desktop.
|
/*! \brief Set the color of the desktop.
|
||||||
\param rgb The color you want to paint the desktop background.
|
\param rgb The color you want to paint the desktop background.
|
||||||
\param stick If you pass \c true here, the color will be maintained across boots.
|
\param stick If you pass \c true here, the color will be maintained across
|
||||||
|
boots.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
BScreen::SetDesktopColor(rgb_color rgb, bool stick)
|
BScreen::SetDesktopColor(rgb_color rgb, bool stick)
|
||||||
@@ -272,7 +287,8 @@ BScreen::SetDesktopColor(rgb_color rgb, bool stick)
|
|||||||
/*! \brief Set the color of the desktop in the given workspace.
|
/*! \brief Set the color of the desktop in the given workspace.
|
||||||
\param rgb The color you want to paint the desktop background.
|
\param rgb The color you want to paint the desktop background.
|
||||||
\param index The workspace you want to change the color.
|
\param index The workspace you want to change the color.
|
||||||
\param stick If you pass \c true here, the color will be maintained across boots.
|
\param stick If you pass \c true here, the color will be maintained across
|
||||||
|
boots.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
BScreen::SetDesktopColor(rgb_color rgb, uint32 index, bool stick)
|
BScreen::SetDesktopColor(rgb_color rgb, uint32 index, bool stick)
|
||||||
@@ -287,12 +303,15 @@ BScreen::SetDesktopColor(rgb_color rgb, uint32 index, bool stick)
|
|||||||
\param low The lower limit you want target to be adjusted.
|
\param low The lower limit you want target to be adjusted.
|
||||||
\param high The higher limit you want target to be adjusted.
|
\param high The higher limit you want target to be adjusted.
|
||||||
\return
|
\return
|
||||||
- \c B_OK if target (as returned) is supported and falls into the limits.
|
- \c B_OK if target (as returned) is supported and falls into the
|
||||||
- \c B_BAD_VALUE if target (as returned) is supported but doesn't fall into the limits.
|
limits.
|
||||||
|
- \c B_BAD_VALUE if target (as returned) is supported but doesn't fall
|
||||||
|
into the limits.
|
||||||
- \c B_ERROR if target isn't supported.
|
- \c B_ERROR if target isn't supported.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::ProposeMode(display_mode *target, const display_mode *low, const display_mode *high)
|
BScreen::ProposeMode(display_mode* target, const display_mode* low,
|
||||||
|
const display_mode* high)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->ProposeMode(target, low, high);
|
return fScreen->ProposeMode(target, low, high);
|
||||||
@@ -300,30 +319,30 @@ BScreen::ProposeMode(display_mode *target, const display_mode *low, const displa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief allocates and returns a list of the display_modes
|
/*! \brief allocates and returns a list of the display_modes
|
||||||
that the graphics card supports.
|
that the graphics card supports.
|
||||||
\param mode_list A pointer to a mode_list pointer, where the function will
|
\param mode_list A pointer to a mode_list pointer, where the function will
|
||||||
allocate an array of display_mode structures.
|
allocate an array of display_mode structures.
|
||||||
\param count A pointer to an integer, where the function will store the amount of
|
\param count A pointer to an integer, where the function will store the
|
||||||
available display modes.
|
amount of available display modes.
|
||||||
\return \c B_OK.
|
\return \c B_OK.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::GetModeList(display_mode **mode_list, uint32 *count)
|
BScreen::GetModeList(display_mode** _modeList, uint32* _count)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->GetModeList(mode_list, count);
|
return fScreen->GetModeList(_modeList, _count);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Copies the current display_mode into mode.
|
/*! \brief Copies the current display_mode into mode.
|
||||||
\param mode A pointer to a display_mode structure,
|
\param mode A pointer to a display_mode structure,
|
||||||
where the current display_mode will be copied.
|
where the current display_mode will be copied.
|
||||||
\return \c B_OK if the operation was succesful.
|
\return \c B_OK if the operation was succesful.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::GetMode(display_mode *mode)
|
BScreen::GetMode(display_mode* mode)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->GetMode(kCurrentWorkspaceIndex, mode);
|
return fScreen->GetMode(kCurrentWorkspaceIndex, mode);
|
||||||
@@ -332,12 +351,12 @@ BScreen::GetMode(display_mode *mode)
|
|||||||
|
|
||||||
|
|
||||||
/*! \brief Copies the current display_mode of the given workspace into mode.
|
/*! \brief Copies the current display_mode of the given workspace into mode.
|
||||||
\param mode A pointer to a display_mode structure,
|
\param mode A pointer to a display_mode structure,
|
||||||
where the current display_mode will be copied.
|
where the current display_mode will be copied.
|
||||||
\return \c B_OK if the operation was succesful.
|
\return \c B_OK if the operation was succesful.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::GetMode(uint32 workspace, display_mode *mode)
|
BScreen::GetMode(uint32 workspace, display_mode* mode)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->GetMode(workspace, mode);
|
return fScreen->GetMode(workspace, mode);
|
||||||
@@ -351,7 +370,7 @@ BScreen::GetMode(uint32 workspace, display_mode *mode)
|
|||||||
\return \c B_OK.
|
\return \c B_OK.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::SetMode(display_mode *mode, bool makeDefault)
|
BScreen::SetMode(display_mode* mode, bool makeDefault)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->SetMode(kCurrentWorkspaceIndex, mode, makeDefault);
|
return fScreen->SetMode(kCurrentWorkspaceIndex, mode, makeDefault);
|
||||||
@@ -366,7 +385,7 @@ BScreen::SetMode(display_mode *mode, bool makeDefault)
|
|||||||
\return \c B_OK.
|
\return \c B_OK.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::SetMode(uint32 workspace, display_mode *mode, bool makeDefault)
|
BScreen::SetMode(uint32 workspace, display_mode* mode, bool makeDefault)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->SetMode(workspace, mode, makeDefault);
|
return fScreen->SetMode(workspace, mode, makeDefault);
|
||||||
@@ -375,11 +394,12 @@ BScreen::SetMode(uint32 workspace, display_mode *mode, bool makeDefault)
|
|||||||
|
|
||||||
|
|
||||||
/*! \brief Returns information about the graphics card.
|
/*! \brief Returns information about the graphics card.
|
||||||
\param info An accelerant_device_info struct where to store the retrieved info.
|
\param info An accelerant_device_info struct where to store the retrieved
|
||||||
|
info.
|
||||||
\return \c B_OK if the operation went fine, otherwise an error code.
|
\return \c B_OK if the operation went fine, otherwise an error code.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::GetDeviceInfo(accelerant_device_info *info)
|
BScreen::GetDeviceInfo(accelerant_device_info* info)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->GetDeviceInfo(info);
|
return fScreen->GetDeviceInfo(info);
|
||||||
@@ -396,37 +416,41 @@ BScreen::GetMonitorInfo(monitor_info* info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Returns, in low and high, the minimum and maximum pixel clock rates
|
/*! \brief Returns, in low and high, the minimum and maximum pixel clock rates
|
||||||
that are possible for the given mode.
|
that are possible for the given mode.
|
||||||
\param mode A pointer to a display_mode.
|
\param mode A pointer to a display_mode.
|
||||||
\param low A pointer to an int where the function will store the lowest available pixel clock.
|
\param low A pointer to an int where the function will store the lowest
|
||||||
\param high A pointer to an int where the function wills tore the highest available pixel clock.
|
available pixel clock.
|
||||||
|
\param high A pointer to an int where the function wills tore the highest
|
||||||
|
available pixel clock.
|
||||||
\return \c B_OK if the operation went fine, otherwise an error code.
|
\return \c B_OK if the operation went fine, otherwise an error code.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high)
|
BScreen::GetPixelClockLimits(display_mode* mode, uint32* _low, uint32* _high)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->GetPixelClockLimits(mode, low, high);
|
return fScreen->GetPixelClockLimits(mode, _low, _high);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Fills out the dtc structure with the timing constraints of the current display mode.
|
/*! \brief Fills out the dtc structure with the timing constraints of the
|
||||||
\param dtc A pointer to a display_timing_constraints structure where the function will store
|
current display mode.
|
||||||
the timing constraints of the current mode.
|
\param dtc A pointer to a display_timing_constraints structure where the
|
||||||
|
function will store the timing constraints of the current mode.
|
||||||
\return \c B_OK if the operation went fine, otherwise an error code.
|
\return \c B_OK if the operation went fine, otherwise an error code.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::GetTimingConstraints(display_timing_constraints *dtc)
|
BScreen::GetTimingConstraints(display_timing_constraints* constraints)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->GetTimingConstraints(dtc);
|
return fScreen->GetTimingConstraints(constraints);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Lets you set the VESA Display Power Management Signaling state for the screen.
|
/*! \brief Lets you set the VESA Display Power Management Signaling state for
|
||||||
|
the screen.
|
||||||
\param dpms_state The DPMS state you want to be set.
|
\param dpms_state The DPMS state you want to be set.
|
||||||
valid values are:
|
valid values are:
|
||||||
- \c B_DPMS_ON
|
- \c B_DPMS_ON
|
||||||
@@ -436,10 +460,10 @@ BScreen::GetTimingConstraints(display_timing_constraints *dtc)
|
|||||||
\return \c B_OK if the operation went fine, otherwise an error code.
|
\return \c B_OK if the operation went fine, otherwise an error code.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::SetDPMS(uint32 dpms_state)
|
BScreen::SetDPMS(uint32 dpmsState)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->SetDPMS(dpms_state);
|
return fScreen->SetDPMS(dpmsState);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +494,8 @@ BScreen::DPMSCapabilites()
|
|||||||
|
|
||||||
|
|
||||||
/*! \brief Returns the BPrivateScreen used by the BScreen object.
|
/*! \brief Returns the BPrivateScreen used by the BScreen object.
|
||||||
\return A pointer to the BPrivateScreen class internally used by the BScreen object.
|
\return A pointer to the BPrivateScreen class internally used by the BScreen
|
||||||
|
object.
|
||||||
*/
|
*/
|
||||||
BPrivate::BPrivateScreen*
|
BPrivate::BPrivateScreen*
|
||||||
BScreen::private_screen()
|
BScreen::private_screen()
|
||||||
@@ -482,7 +507,8 @@ BScreen::private_screen()
|
|||||||
/*! \brief Deprecated, use ProposeMode() instead.
|
/*! \brief Deprecated, use ProposeMode() instead.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BScreen::ProposeDisplayMode(display_mode *target, const display_mode *low, const display_mode *high)
|
BScreen::ProposeDisplayMode(display_mode* target, const display_mode* low,
|
||||||
|
const display_mode* high)
|
||||||
{
|
{
|
||||||
return ProposeMode(target, low, high);
|
return ProposeMode(target, low, high);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku.
|
* Copyright 2001-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
* Axel Dörfler, axeld@pinc-software.de
|
* Axel Dörfler, axeld@pinc-software.de
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
Whenever a ServerBitmap associated with a client-side BBitmap needs to be
|
/*! Whenever a ServerBitmap associated with a client-side BBitmap needs to be
|
||||||
created or destroyed, the BitmapManager needs to handle it. It takes care of
|
created or destroyed, the BitmapManager needs to handle it. It takes care of
|
||||||
all memory management related to them.
|
all memory management related to them.
|
||||||
*/
|
*/
|
||||||
@@ -79,8 +79,8 @@ BitmapManager::~BitmapManager()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*! \brief Allocates a new ServerBitmap.
|
||||||
\brief Allocates a new ServerBitmap.
|
|
||||||
\param bounds Size of the bitmap
|
\param bounds Size of the bitmap
|
||||||
\param space Color space of the bitmap
|
\param space Color space of the bitmap
|
||||||
\param flags Bitmap flags as defined in Bitmap.h
|
\param flags Bitmap flags as defined in Bitmap.h
|
||||||
@@ -91,7 +91,7 @@ BitmapManager::~BitmapManager()
|
|||||||
ServerBitmap*
|
ServerBitmap*
|
||||||
BitmapManager::CreateBitmap(ClientMemoryAllocator* allocator,
|
BitmapManager::CreateBitmap(ClientMemoryAllocator* allocator,
|
||||||
HWInterface& hwInterface, BRect bounds, color_space space, uint32 flags,
|
HWInterface& hwInterface, BRect bounds, color_space space, uint32 flags,
|
||||||
int32 bytesPerRow, screen_id screen, uint8* _allocationFlags)
|
int32 bytesPerRow, int32 screen, uint8* _allocationFlags)
|
||||||
{
|
{
|
||||||
BAutolock locker(fLock);
|
BAutolock locker(fLock);
|
||||||
|
|
||||||
@@ -201,8 +201,7 @@ BitmapManager::CreateBitmap(ClientMemoryAllocator* allocator,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*! \brief Deletes a ServerBitmap.
|
||||||
\brief Deletes a ServerBitmap.
|
|
||||||
\param bitmap The bitmap to delete
|
\param bitmap The bitmap to delete
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku.
|
* Copyright 2001-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -15,32 +15,34 @@
|
|||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
|
|
||||||
|
|
||||||
class ClientMemoryAllocator;
|
class ClientMemoryAllocator;
|
||||||
class HWInterface;
|
class HWInterface;
|
||||||
class ServerBitmap;
|
class ServerBitmap;
|
||||||
|
|
||||||
|
|
||||||
class BitmapManager {
|
class BitmapManager {
|
||||||
public:
|
public:
|
||||||
BitmapManager();
|
BitmapManager();
|
||||||
virtual ~BitmapManager();
|
virtual ~BitmapManager();
|
||||||
|
|
||||||
ServerBitmap* CreateBitmap(ClientMemoryAllocator* allocator,
|
ServerBitmap* CreateBitmap(ClientMemoryAllocator* allocator,
|
||||||
HWInterface& hwInterface, BRect bounds,
|
HWInterface& hwInterface, BRect bounds,
|
||||||
color_space space, uint32 flags,
|
color_space space, uint32 flags,
|
||||||
int32 bytesPerRow = -1,
|
int32 bytesPerRow = -1,
|
||||||
screen_id screen = B_MAIN_SCREEN_ID,
|
int32 screen = B_MAIN_SCREEN_ID.id,
|
||||||
uint8* _allocationFlags = NULL);
|
uint8* _allocationFlags = NULL);
|
||||||
void DeleteBitmap(ServerBitmap* bitmap);
|
void DeleteBitmap(ServerBitmap* bitmap);
|
||||||
|
|
||||||
void SuspendOverlays();
|
void SuspendOverlays();
|
||||||
void ResumeOverlays();
|
void ResumeOverlays();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BList fBitmapList;
|
BList fBitmapList;
|
||||||
BList fOverlays;
|
BList fOverlays;
|
||||||
BLocker fLock;
|
BLocker fLock;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern BitmapManager *gBitmapManager;
|
extern BitmapManager* gBitmapManager;
|
||||||
|
|
||||||
#endif /* BITMAP_MANAGER_H */
|
#endif /* BITMAP_MANAGER_H */
|
||||||
|
|||||||
+121
-48
@@ -9,6 +9,7 @@
|
|||||||
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
|
* Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*! Class used to encapsulate desktop management */
|
/*! Class used to encapsulate desktop management */
|
||||||
|
|
||||||
|
|
||||||
@@ -363,7 +364,8 @@ Desktop::Init()
|
|||||||
fWorkspaces[i].RestoreConfiguration(*fSettings->WorkspacesMessage(i));
|
fWorkspaces[i].RestoreConfiguration(*fSettings->WorkspacesMessage(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
fVirtualScreen.RestoreConfiguration(*this, fSettings->WorkspacesMessage(0));
|
fVirtualScreen.SetConfiguration(*this,
|
||||||
|
fWorkspaces[0].CurrentScreenConfiguration());
|
||||||
|
|
||||||
// TODO: temporary workaround, fActiveScreen will be removed
|
// TODO: temporary workaround, fActiveScreen will be removed
|
||||||
fActiveScreen = fVirtualScreen.ScreenAt(0);
|
fActiveScreen = fVirtualScreen.ScreenAt(0);
|
||||||
@@ -827,18 +829,19 @@ Desktop::RedrawBackground()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*! \brief Stores the workspace configuration.
|
||||||
\brief Store the workspace configuration
|
You must hold the window lock when calling this method.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Desktop::StoreWorkspaceConfiguration(int32 index)
|
Desktop::StoreWorkspaceConfiguration(int32 index)
|
||||||
{
|
{
|
||||||
const BMessage *oldSettings = fSettings->WorkspacesMessage(index);
|
// Retrieve settings
|
||||||
// store settings
|
|
||||||
BMessage settings;
|
BMessage settings;
|
||||||
if (oldSettings)
|
|
||||||
settings = *oldSettings;
|
|
||||||
fWorkspaces[index].StoreConfiguration(settings);
|
fWorkspaces[index].StoreConfiguration(settings);
|
||||||
|
|
||||||
|
// and store them
|
||||||
|
|
||||||
fSettings->SetWorkspacesMessage(index, settings);
|
fSettings->SetWorkspacesMessage(index, settings);
|
||||||
fSettings->Save(kWorkspacesSettings);
|
fSettings->Save(kWorkspacesSettings);
|
||||||
}
|
}
|
||||||
@@ -874,8 +877,7 @@ Desktop::SetWorkspacesLayout(int32 newColumns, int32 newRows)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*! Returns the virtual screen frame of the workspace specified by \a index.
|
||||||
Returns the virtual screen frame of the workspace specified by \a index.
|
|
||||||
*/
|
*/
|
||||||
BRect
|
BRect
|
||||||
Desktop::WorkspaceFrame(int32 index) const
|
Desktop::WorkspaceFrame(int32 index) const
|
||||||
@@ -888,7 +890,8 @@ Desktop::WorkspaceFrame(int32 index) const
|
|||||||
int32 width;
|
int32 width;
|
||||||
int32 height;
|
int32 height;
|
||||||
fSettings->WorkspacesMessage(index)->FindMessage("screen", &screenData);
|
fSettings->WorkspacesMessage(index)->FindMessage("screen", &screenData);
|
||||||
if (screenData.FindInt32("width", &width) != B_OK || screenData.FindInt32("height", &height) != B_OK)
|
if (screenData.FindInt32("width", &width) != B_OK
|
||||||
|
|| screenData.FindInt32("height", &height) != B_OK)
|
||||||
frame = fVirtualScreen.Frame();
|
frame = fVirtualScreen.Frame();
|
||||||
else
|
else
|
||||||
frame.Set(0.0, 0.0, width - 1, height - 1);
|
frame.Set(0.0, 0.0, width - 1, height - 1);
|
||||||
@@ -1000,12 +1003,12 @@ Desktop::_SetWorkspace(int32 index)
|
|||||||
// Change the display modes, if needed
|
// Change the display modes, if needed
|
||||||
|
|
||||||
uint32 changedScreens;
|
uint32 changedScreens;
|
||||||
fVirtualScreen.RestoreConfiguration(*this,
|
fVirtualScreen.SetConfiguration(*this,
|
||||||
fSettings->WorkspacesMessage(index), &changedScreens);
|
fWorkspaces[index].CurrentScreenConfiguration(), &changedScreens);
|
||||||
|
|
||||||
for (int32 i = 0; changedScreens != 0; i++, changedScreens /= 2) {
|
for (int32 i = 0; changedScreens != 0; i++, changedScreens /= 2) {
|
||||||
if ((changedScreens & (1 << i)) != 0)
|
if ((changedScreens & (1 << i)) != 0)
|
||||||
ScreenChanged(fVirtualScreen.ScreenAt(i), false);
|
ScreenChanged(fVirtualScreen.ScreenAt(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show windows, and include them in the changed region - but only
|
// Show windows, and include them in the changed region - but only
|
||||||
@@ -1075,8 +1078,10 @@ Desktop::_SetWorkspace(int32 index)
|
|||||||
|
|
||||||
if (window->InWorkspace(previousIndex) || window->IsHidden()
|
if (window->InWorkspace(previousIndex) || window->IsHidden()
|
||||||
|| (window == fMouseEventWindow && fMouseEventWindow->IsNormal())
|
|| (window == fMouseEventWindow && fMouseEventWindow->IsNormal())
|
||||||
|| (!window->IsNormal() && window->HasInSubset(fMouseEventWindow))) {
|
|| (!window->IsNormal()
|
||||||
// this window was visible before, and is already handled in the above loop
|
&& window->HasInSubset(fMouseEventWindow))) {
|
||||||
|
// This window was visible before, and is already handled in the
|
||||||
|
// above loop
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1095,7 +1100,8 @@ Desktop::_SetWorkspace(int32 index)
|
|||||||
|
|
||||||
// Set new focus to the front window, but keep focus to a floating
|
// Set new focus to the front window, but keep focus to a floating
|
||||||
// window if still visible
|
// window if still visible
|
||||||
if (!_Windows(index).HasWindow(FocusWindow()) || !FocusWindow()->IsFloating())
|
if (!_Windows(index).HasWindow(FocusWindow())
|
||||||
|
|| !FocusWindow()->IsFloating())
|
||||||
SetFocusWindow(FrontWindow());
|
SetFocusWindow(FrontWindow());
|
||||||
|
|
||||||
_WindowChanged(NULL);
|
_WindowChanged(NULL);
|
||||||
@@ -1115,15 +1121,108 @@ Desktop::_SetWorkspace(int32 index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
status_t
|
||||||
Desktop::ScreenChanged(Screen* screen, bool makeDefault)
|
Desktop::SetScreenMode(int32 workspace, int32 id, const display_mode& mode,
|
||||||
|
bool makeDefault)
|
||||||
{
|
{
|
||||||
// TODO: confirm that everywhere this is used,
|
// ~0 is used as the current workspace in PrivateScreen
|
||||||
// the Window WriteLock is held
|
if (workspace == ~0)
|
||||||
|
workspace = fCurrentWorkspace;
|
||||||
|
|
||||||
|
if (workspace < 0 || workspace > kMaxWorkspaces)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
AutoWriteLocker _(fWindowLock);
|
||||||
|
|
||||||
|
Screen* screen = fVirtualScreen.ScreenByID(id);
|
||||||
|
if (screen == NULL)
|
||||||
|
return B_NAME_NOT_FOUND;
|
||||||
|
|
||||||
|
// Check if the mode has actually changed
|
||||||
|
|
||||||
|
if (workspace == fCurrentWorkspace) {
|
||||||
|
// retrieve from current screen
|
||||||
|
display_mode oldMode;
|
||||||
|
screen->GetMode(oldMode);
|
||||||
|
|
||||||
|
if (!memcmp(&oldMode, &mode, sizeof(display_mode)))
|
||||||
|
return B_OK;
|
||||||
|
} else {
|
||||||
|
// retrieve from settings
|
||||||
|
screen_configuration* configuration
|
||||||
|
= fWorkspaces[workspace].CurrentScreenConfiguration().CurrentByID(
|
||||||
|
screen->ID());
|
||||||
|
if (configuration != NULL
|
||||||
|
&& !memcmp(&configuration->mode, &mode, sizeof(display_mode)))
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the new one
|
||||||
|
|
||||||
|
status_t status = screen->SetMode(mode);
|
||||||
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
// Update our configurations
|
||||||
|
|
||||||
|
monitor_info info;
|
||||||
|
bool hasInfo = screen->GetMonitorInfo(info) == B_OK;
|
||||||
|
|
||||||
|
fWorkspaces[workspace].CurrentScreenConfiguration().Set(id,
|
||||||
|
hasInfo ? &info : NULL, screen->Frame(), mode);
|
||||||
|
if (makeDefault) {
|
||||||
|
fWorkspaces[workspace].StoredScreenConfiguration().Set(id,
|
||||||
|
hasInfo ? &info : NULL, screen->Frame(), mode);
|
||||||
|
StoreWorkspaceConfiguration(workspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScreenChanged(screen);
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Desktop::GetScreenMode(int32 workspace, int32 id, display_mode& mode)
|
||||||
|
{
|
||||||
|
// ~0 is used as the current workspace in PrivateScreen
|
||||||
|
if (workspace == ~0)
|
||||||
|
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;
|
||||||
|
|
||||||
|
screen->GetMode(mode);
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// retrieve from settings
|
||||||
|
screen_configuration* configuration
|
||||||
|
= fWorkspaces[workspace].CurrentScreenConfiguration().CurrentByID(id);
|
||||||
|
if (configuration == NULL)
|
||||||
|
return B_NAME_NOT_FOUND;
|
||||||
|
|
||||||
|
mode = configuration->mode;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Desktop::ScreenChanged(Screen* screen)
|
||||||
|
{
|
||||||
|
ASSERT(fWindowLock.IsWriteLocked());
|
||||||
|
|
||||||
// the entire screen is dirty, because we're actually
|
// the entire screen is dirty, because we're actually
|
||||||
// operating on an all new buffer in memory
|
// operating on an all new buffer in memory
|
||||||
BRegion dirty(screen->Frame());
|
BRegion dirty(screen->Frame());
|
||||||
|
|
||||||
// update our cached screen region
|
// update our cached screen region
|
||||||
fScreenRegion.Set(screen->Frame());
|
fScreenRegion.Set(screen->Frame());
|
||||||
gInputManager->UpdateScreenBounds(screen->Frame());
|
gInputManager->UpdateScreenBounds(screen->Frame());
|
||||||
@@ -1145,42 +1244,16 @@ Desktop::ScreenChanged(Screen* screen, bool makeDefault)
|
|||||||
update.AddRect("frame", screen->Frame());
|
update.AddRect("frame", screen->Frame());
|
||||||
update.AddInt32("mode", screen->ColorSpace());
|
update.AddInt32("mode", screen->ColorSpace());
|
||||||
|
|
||||||
|
fVirtualScreen.UpdateFrame();
|
||||||
|
|
||||||
// TODO: currently ignores the screen argument!
|
// TODO: currently ignores the screen argument!
|
||||||
for (Window* window = fAllWindows.FirstWindow(); window != NULL;
|
for (Window* window = fAllWindows.FirstWindow(); window != NULL;
|
||||||
window = window->NextWindow(kAllWindowList)) {
|
window = window->NextWindow(kAllWindowList)) {
|
||||||
window->ServerWindow()->ScreenChanged(&update);
|
window->ServerWindow()->ScreenChanged(&update);
|
||||||
window->ServerWindow()->SendMessageToClient(&update);
|
|
||||||
}
|
|
||||||
|
|
||||||
fVirtualScreen.UpdateFrame();
|
|
||||||
|
|
||||||
if (makeDefault) {
|
|
||||||
StoreConfiguration(fCurrentWorkspace);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
Desktop::StoreConfiguration(int32 workspace)
|
|
||||||
{
|
|
||||||
// TODO: This only works because StoreConfiguration is never called
|
|
||||||
// for an inactive workspace. fVirtualScreen has the screen mode
|
|
||||||
// of the current workspace.
|
|
||||||
|
|
||||||
if (workspace >= 0 && workspace < fSettings->WorkspacesCount()) {
|
|
||||||
// store settings
|
|
||||||
BMessage settings;
|
|
||||||
fVirtualScreen.StoreConfiguration(settings);
|
|
||||||
fWorkspaces[workspace].StoreConfiguration(settings);
|
|
||||||
|
|
||||||
fSettings->SetWorkspacesMessage(workspace, settings);
|
|
||||||
fSettings->Save(kWorkspacesSettings);
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// #pragma mark - Methods for Window manipulation
|
// #pragma mark - Methods for Window manipulation
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+27
-13
@@ -33,6 +33,7 @@
|
|||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
#define USE_MULTI_LOCKER 1
|
#define USE_MULTI_LOCKER 1
|
||||||
|
|
||||||
#if USE_MULTI_LOCKER
|
#if USE_MULTI_LOCKER
|
||||||
@@ -41,6 +42,7 @@
|
|||||||
# include <Locker.h>
|
# include <Locker.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class BMessage;
|
class BMessage;
|
||||||
|
|
||||||
class DrawingEngine;
|
class DrawingEngine;
|
||||||
@@ -54,6 +56,7 @@ namespace BPrivate {
|
|||||||
class LinkSender;
|
class LinkSender;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Desktop : public MessageLooper, public ScreenOwner {
|
class Desktop : public MessageLooper, public ScreenOwner {
|
||||||
public:
|
public:
|
||||||
Desktop(uid_t userID);
|
Desktop(uid_t userID);
|
||||||
@@ -71,14 +74,7 @@ class Desktop : public MessageLooper, public ScreenOwner {
|
|||||||
void BroadcastToAllApps(int32 code);
|
void BroadcastToAllApps(int32 code);
|
||||||
void BroadcastToAllWindows(int32 code);
|
void BroadcastToAllWindows(int32 code);
|
||||||
|
|
||||||
// Screen and drawing related methods
|
// Mouse and cursor methods
|
||||||
|
|
||||||
Screen* ScreenAt(int32 index) const
|
|
||||||
{ return fActiveScreen; }
|
|
||||||
Screen* ActiveScreen() const
|
|
||||||
{ return fActiveScreen; }
|
|
||||||
|
|
||||||
CursorManager& GetCursorManager() { return fCursorManager; }
|
|
||||||
|
|
||||||
void SetCursor(ServerCursor* cursor);
|
void SetCursor(ServerCursor* cursor);
|
||||||
ServerCursorReference Cursor() const;
|
ServerCursorReference Cursor() const;
|
||||||
@@ -91,11 +87,22 @@ class Desktop : public MessageLooper, public ScreenOwner {
|
|||||||
void GetLastMouseState(BPoint* position,
|
void GetLastMouseState(BPoint* position,
|
||||||
int32* buttons) const;
|
int32* buttons) const;
|
||||||
// for use by ServerWindow
|
// for use by ServerWindow
|
||||||
void ScreenChanged(Screen* screen, bool makeDefault);
|
|
||||||
void ScreenRemoved(Screen* screen) {}
|
// Screen and drawing related methods
|
||||||
void ScreenAdded(Screen* screen) {}
|
|
||||||
bool ReleaseScreen(Screen* screen) { return false; }
|
Screen* ScreenAt(int32 index) const
|
||||||
status_t StoreConfiguration(int32 workspace);
|
{ return fActiveScreen; }
|
||||||
|
Screen* ActiveScreen() const
|
||||||
|
{ return fActiveScreen; }
|
||||||
|
|
||||||
|
CursorManager& GetCursorManager() { return fCursorManager; }
|
||||||
|
|
||||||
|
status_t SetScreenMode(int32 workspace, int32 id,
|
||||||
|
const display_mode& mode, bool makeDefault);
|
||||||
|
status_t GetScreenMode(int32 workspace, int32 id,
|
||||||
|
display_mode& mode);
|
||||||
|
|
||||||
|
void ScreenChanged(Screen* screen);
|
||||||
|
|
||||||
const ::VirtualScreen& VirtualScreen() const { return fVirtualScreen; }
|
const ::VirtualScreen& VirtualScreen() const { return fVirtualScreen; }
|
||||||
DrawingEngine* GetDrawingEngine() const
|
DrawingEngine* GetDrawingEngine() const
|
||||||
@@ -103,6 +110,11 @@ class Desktop : public MessageLooper, public ScreenOwner {
|
|||||||
::HWInterface* HWInterface() const
|
::HWInterface* HWInterface() const
|
||||||
{ return fVirtualScreen.HWInterface(); }
|
{ return fVirtualScreen.HWInterface(); }
|
||||||
|
|
||||||
|
// ScreenOwner implementation
|
||||||
|
void ScreenRemoved(Screen* screen) {}
|
||||||
|
void ScreenAdded(Screen* screen) {}
|
||||||
|
bool ReleaseScreen(Screen* screen) { return false; }
|
||||||
|
|
||||||
// Workspace methods
|
// Workspace methods
|
||||||
|
|
||||||
void SetWorkspaceAsync(int32 index);
|
void SetWorkspaceAsync(int32 index);
|
||||||
@@ -183,6 +195,8 @@ class Desktop : public MessageLooper, public ScreenOwner {
|
|||||||
{ return fWindowLock.WriteLock(); }
|
{ return fWindowLock.WriteLock(); }
|
||||||
void UnlockAllWindows()
|
void UnlockAllWindows()
|
||||||
{ fWindowLock.WriteUnlock(); }
|
{ fWindowLock.WriteUnlock(); }
|
||||||
|
|
||||||
|
MultiLocker WindowLocker() { return fWindowLock; }
|
||||||
#else // USE_MULTI_LOCKER
|
#else // USE_MULTI_LOCKER
|
||||||
bool LockSingleWindow()
|
bool LockSingleWindow()
|
||||||
{ return fWindowLock.Lock(); }
|
{ return fWindowLock.Lock(); }
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ Server app_server :
|
|||||||
RGBColor.cpp
|
RGBColor.cpp
|
||||||
RegionPool.cpp
|
RegionPool.cpp
|
||||||
Screen.cpp
|
Screen.cpp
|
||||||
|
ScreenConfigurations.cpp
|
||||||
ScreenManager.cpp
|
ScreenManager.cpp
|
||||||
ServerApp.cpp
|
ServerApp.cpp
|
||||||
ServerBitmap.cpp
|
ServerBitmap.cpp
|
||||||
|
|||||||
+123
-110
@@ -1,164 +1,177 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005-2007, Haiku, Inc. All Rights Reserved.
|
* Copyright 2005-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Copyright 1999, Be Incorporated. All Rights Reserved.
|
* Copyright 1999, Be Incorporated. All Rights Reserved.
|
||||||
* This file may be used under the terms of the Be Sample Code License.
|
* This file may be used under the terms of the Be Sample Code License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! multiple-reader single-writer locking class */
|
|
||||||
|
|
||||||
// IMPORTANT:
|
|
||||||
// * nested read locks are not supported
|
|
||||||
// * a reader becomming the write is not supported
|
|
||||||
// * nested write locks are supported
|
|
||||||
// * a writer can do read locks, even nested ones
|
|
||||||
// * in case of problems, #define DEBUG 1 in the .cpp
|
|
||||||
|
|
||||||
#ifndef MULTI_LOCKER_H
|
#ifndef MULTI_LOCKER_H
|
||||||
#define MULTI_LOCKER_H
|
#define MULTI_LOCKER_H
|
||||||
|
|
||||||
|
|
||||||
|
/*! multiple-reader single-writer locking class
|
||||||
|
|
||||||
|
IMPORTANT:
|
||||||
|
* nested read locks are not supported
|
||||||
|
* a reader becoming the write is not supported
|
||||||
|
* nested write locks are supported
|
||||||
|
* a writer can do read locks, even nested ones
|
||||||
|
* in case of problems, #define DEBUG 1 in the .cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
|
|
||||||
#define MULTI_LOCKER_TIMING 0
|
#define MULTI_LOCKER_TIMING 0
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
# define MULTI_LOCKER_DEBUG DEBUG
|
# define MULTI_LOCKER_DEBUG DEBUG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MULTI_LOCKER_DEBUG
|
||||||
|
# define ASSERT_MULTI_LOCKED(x) ((x).IsWriteLocked() || (x).IsReadLocked())
|
||||||
|
# define ASSERT_MULTI_READ_LOCKED(x) ((x).IsReadLocked())
|
||||||
|
# define ASSERT_MULTI_WRITE_LOCKED(x) ((x).IsWriteLocked())
|
||||||
#else
|
#else
|
||||||
# define MULTI_LOCKER_DEBUG 0
|
# define MULTI_LOCKER_DEBUG 0
|
||||||
|
# define ASSERT_MULTI_LOCKED(x) ;
|
||||||
|
# define ASSERT_MULTI_READ_LOCKED(x) ;
|
||||||
|
# define ASSERT_MULTI_WRITE_LOCKED(x) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class MultiLocker {
|
class MultiLocker {
|
||||||
public:
|
public:
|
||||||
MultiLocker(const char* baseName);
|
MultiLocker(const char* baseName);
|
||||||
virtual ~MultiLocker();
|
virtual ~MultiLocker();
|
||||||
|
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
|
|
||||||
// locking for reading or writing
|
|
||||||
bool ReadLock();
|
|
||||||
bool WriteLock();
|
|
||||||
|
|
||||||
// unlocking after reading or writing
|
// locking for reading or writing
|
||||||
bool ReadUnlock();
|
bool ReadLock();
|
||||||
bool WriteUnlock();
|
bool WriteLock();
|
||||||
|
|
||||||
// does the current thread hold a write lock ?
|
// unlocking after reading or writing
|
||||||
bool IsWriteLocked(uint32 *stackBase = NULL,
|
bool ReadUnlock();
|
||||||
thread_id *thread = NULL);
|
bool WriteUnlock();
|
||||||
|
|
||||||
|
// does the current thread hold a write lock ?
|
||||||
|
bool IsWriteLocked(uint32 *stackBase = NULL,
|
||||||
|
thread_id *thread = NULL);
|
||||||
|
|
||||||
#if MULTI_LOCKER_DEBUG
|
#if MULTI_LOCKER_DEBUG
|
||||||
// in DEBUG mode returns whether the lock is held
|
// in DEBUG mode returns whether the lock is held
|
||||||
// in non-debug mode returns true
|
// in non-debug mode returns true
|
||||||
bool IsReadLocked();
|
bool IsReadLocked();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if MULTI_LOCKER_DEBUG
|
#if MULTI_LOCKER_DEBUG
|
||||||
// functions for managing the DEBUG reader array
|
// functions for managing the DEBUG reader array
|
||||||
void _RegisterThread();
|
void _RegisterThread();
|
||||||
void _UnregisterThread();
|
void _UnregisterThread();
|
||||||
|
|
||||||
sem_id fLock;
|
sem_id fLock;
|
||||||
int32* fDebugArray;
|
int32* fDebugArray;
|
||||||
int32 fMaxThreads;
|
int32 fMaxThreads;
|
||||||
#else
|
#else
|
||||||
// readers adjust count and block on fReadSem when a writer
|
// readers adjust count and block on fReadSem when a writer
|
||||||
// hold the lock
|
// hold the lock
|
||||||
int32 fReadCount;
|
int32 fReadCount;
|
||||||
sem_id fReadSem;
|
sem_id fReadSem;
|
||||||
// writers adjust the count and block on fWriteSem
|
// writers adjust the count and block on fWriteSem
|
||||||
// when readers hold the lock
|
// when readers hold the lock
|
||||||
int32 fWriteCount;
|
int32 fWriteCount;
|
||||||
sem_id fWriteSem;
|
sem_id fWriteSem;
|
||||||
// writers must acquire fWriterLock when acquiring a write lock
|
// writers must acquire fWriterLock when acquiring a write lock
|
||||||
int32 fLockCount;
|
int32 fLockCount;
|
||||||
sem_id fWriterLock;
|
sem_id fWriterLock;
|
||||||
#endif // MULTI_LOCKER_DEBUG
|
#endif // MULTI_LOCKER_DEBUG
|
||||||
|
|
||||||
status_t fInit;
|
status_t fInit;
|
||||||
int32 fWriterNest;
|
int32 fWriterNest;
|
||||||
thread_id fWriterThread;
|
thread_id fWriterThread;
|
||||||
uint32 fWriterStackBase;
|
uint32 fWriterStackBase;
|
||||||
|
|
||||||
#if MULTI_LOCKER_TIMING
|
#if MULTI_LOCKER_TIMING
|
||||||
uint32 rl_count;
|
uint32 rl_count;
|
||||||
bigtime_t rl_time;
|
bigtime_t rl_time;
|
||||||
uint32 ru_count;
|
uint32 ru_count;
|
||||||
bigtime_t ru_time;
|
bigtime_t ru_time;
|
||||||
uint32 wl_count;
|
uint32 wl_count;
|
||||||
bigtime_t wl_time;
|
bigtime_t wl_time;
|
||||||
uint32 wu_count;
|
uint32 wu_count;
|
||||||
bigtime_t wu_time;
|
bigtime_t wu_time;
|
||||||
uint32 islock_count;
|
uint32 islock_count;
|
||||||
bigtime_t islock_time;
|
bigtime_t islock_time;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class AutoWriteLocker {
|
class AutoWriteLocker {
|
||||||
public:
|
public:
|
||||||
AutoWriteLocker(MultiLocker* lock)
|
AutoWriteLocker(MultiLocker* lock)
|
||||||
:
|
:
|
||||||
fLock(*lock)
|
fLock(*lock)
|
||||||
{
|
{
|
||||||
fLock.WriteLock();
|
fLock.WriteLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoWriteLocker(MultiLocker& lock)
|
AutoWriteLocker(MultiLocker& lock)
|
||||||
:
|
:
|
||||||
fLock(lock)
|
fLock(lock)
|
||||||
{
|
{
|
||||||
fLock.WriteLock();
|
fLock.WriteLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLocked() const
|
bool IsLocked() const
|
||||||
{
|
{
|
||||||
return fLock.IsWriteLocked();
|
return fLock.IsWriteLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
~AutoWriteLocker()
|
~AutoWriteLocker()
|
||||||
{
|
{
|
||||||
fLock.WriteUnlock();
|
fLock.WriteUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MultiLocker& fLock;
|
MultiLocker& fLock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class AutoReadLocker {
|
class AutoReadLocker {
|
||||||
public:
|
public:
|
||||||
AutoReadLocker(MultiLocker* lock)
|
AutoReadLocker(MultiLocker* lock)
|
||||||
:
|
:
|
||||||
fLock(*lock)
|
fLock(*lock)
|
||||||
{
|
{
|
||||||
fLocked = fLock.ReadLock();
|
fLocked = fLock.ReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoReadLocker(MultiLocker& lock)
|
AutoReadLocker(MultiLocker& lock)
|
||||||
:
|
:
|
||||||
fLock(lock)
|
fLock(lock)
|
||||||
{
|
{
|
||||||
fLocked = fLock.ReadLock();
|
fLocked = fLock.ReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
~AutoReadLocker()
|
~AutoReadLocker()
|
||||||
{
|
{
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Unlock()
|
Unlock()
|
||||||
{
|
{
|
||||||
if (fLocked) {
|
if (fLocked) {
|
||||||
fLock.ReadUnlock();
|
fLock.ReadUnlock();
|
||||||
fLocked = false;
|
fLocked = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MultiLocker& fLock;
|
MultiLocker& fLock;
|
||||||
bool fLocked;
|
bool fLocked;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MULTI_LOCKER_H
|
#endif // MULTI_LOCKER_H
|
||||||
|
|||||||
+30
-26
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2008, Haiku, Inc.
|
* Copyright 2001-2009, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -40,19 +40,19 @@ get_mode_frequency(const display_mode& mode)
|
|||||||
|
|
||||||
|
|
||||||
Screen::Screen(::HWInterface *interface, int32 id)
|
Screen::Screen(::HWInterface *interface, int32 id)
|
||||||
: fID(id),
|
:
|
||||||
fDriver(interface ? new DrawingEngine(interface) : NULL),
|
fID(id),
|
||||||
fHWInterface(interface),
|
fDriver(interface ? new DrawingEngine(interface) : NULL),
|
||||||
fIsDefault(true)
|
fHWInterface(interface)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Screen::Screen()
|
Screen::Screen()
|
||||||
: fID(-1),
|
:
|
||||||
fDriver(NULL),
|
fID(-1),
|
||||||
fHWInterface(NULL),
|
fDriver(NULL),
|
||||||
fIsDefault(true)
|
fHWInterface(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,10 +64,10 @@ Screen::~Screen()
|
|||||||
delete fHWInterface;
|
delete fHWInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! Finds the mode in the mode list that is closest to the mode specified.
|
/*! Finds the mode in the mode list that is closest to the mode specified.
|
||||||
As long as the mode list is not empty, this method will always succeed.
|
As long as the mode list is not empty, this method will always succeed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Screen::Initialize()
|
Screen::Initialize()
|
||||||
{
|
{
|
||||||
@@ -89,13 +89,13 @@ Screen::Shutdown()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Screen::SetMode(const display_mode& mode, bool makeDefault)
|
Screen::SetMode(const display_mode& mode)
|
||||||
{
|
{
|
||||||
display_mode current;
|
display_mode current;
|
||||||
GetMode(¤t);
|
GetMode(current);
|
||||||
if (!memcmp(&mode, ¤t, sizeof(display_mode)))
|
if (!memcmp(&mode, ¤t, sizeof(display_mode)))
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
gBitmapManager->SuspendOverlays();
|
gBitmapManager->SuspendOverlays();
|
||||||
|
|
||||||
status_t status = fHWInterface->SetMode(mode);
|
status_t status = fHWInterface->SetMode(mode);
|
||||||
@@ -103,16 +103,13 @@ Screen::SetMode(const display_mode& mode, bool makeDefault)
|
|||||||
|
|
||||||
gBitmapManager->ResumeOverlays();
|
gBitmapManager->ResumeOverlays();
|
||||||
|
|
||||||
if (status >= B_OK)
|
|
||||||
fIsDefault = makeDefault;
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Screen::SetMode(uint16 width, uint16 height, uint32 colorSpace,
|
Screen::SetMode(uint16 width, uint16 height, uint32 colorSpace,
|
||||||
const display_timing& timing, bool makeDefault)
|
const display_timing& timing)
|
||||||
{
|
{
|
||||||
display_mode mode;
|
display_mode mode;
|
||||||
mode.timing = timing;
|
mode.timing = timing;
|
||||||
@@ -123,7 +120,7 @@ Screen::SetMode(uint16 width, uint16 height, uint32 colorSpace,
|
|||||||
mode.v_display_start = 0;
|
mode.v_display_start = 0;
|
||||||
mode.flags = 0;
|
mode.flags = 0;
|
||||||
|
|
||||||
return SetMode(mode, makeDefault);
|
return SetMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -167,10 +164,10 @@ Screen::SetBestMode(uint16 width, uint16 height, uint32 colorSpace,
|
|||||||
* mode.timing.v_total / 10 * int32(frequency * 10)) / 1000;
|
* mode.timing.v_total / 10 * int32(frequency * 10)) / 1000;
|
||||||
adjusted = true;
|
adjusted = true;
|
||||||
}
|
}
|
||||||
status = SetMode(mode, false);
|
status = SetMode(mode);
|
||||||
if (status < B_OK && adjusted) {
|
if (status != B_OK && adjusted) {
|
||||||
// try again with the unchanged mode
|
// try again with the unchanged mode
|
||||||
status = SetMode(originalMode, false);
|
status = SetMode(originalMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
@@ -182,17 +179,17 @@ Screen::SetPreferredMode()
|
|||||||
{
|
{
|
||||||
display_mode mode;
|
display_mode mode;
|
||||||
status_t status = fHWInterface->GetPreferredMode(&mode);
|
status_t status = fHWInterface->GetPreferredMode(&mode);
|
||||||
if (status < B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
return SetMode(mode, false);
|
return SetMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Screen::GetMode(display_mode* mode) const
|
Screen::GetMode(display_mode& mode) const
|
||||||
{
|
{
|
||||||
fHWInterface->GetMode(mode);
|
fHWInterface->GetMode(&mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -217,6 +214,13 @@ Screen::GetMonitorInfo(monitor_info& info) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Screen::SetFrame(const BRect& rect)
|
||||||
|
{
|
||||||
|
// TODO: multi-monitor support...
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BRect
|
BRect
|
||||||
Screen::Frame() const
|
Screen::Frame() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2008, Haiku, Inc.
|
* Copyright 2001-2009, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -20,7 +20,7 @@ class DrawingEngine;
|
|||||||
class HWInterface;
|
class HWInterface;
|
||||||
|
|
||||||
class Screen {
|
class Screen {
|
||||||
public:
|
public:
|
||||||
Screen(::HWInterface *interface, int32 id);
|
Screen(::HWInterface *interface, int32 id);
|
||||||
Screen();
|
Screen();
|
||||||
virtual ~Screen();
|
virtual ~Screen();
|
||||||
@@ -31,31 +31,30 @@ class Screen {
|
|||||||
int32 ID() const { return fID; }
|
int32 ID() const { return fID; }
|
||||||
status_t GetMonitorInfo(monitor_info& info) const;
|
status_t GetMonitorInfo(monitor_info& info) const;
|
||||||
|
|
||||||
status_t SetMode(const display_mode& mode,
|
status_t SetMode(const display_mode& mode);
|
||||||
bool makeDefault);
|
|
||||||
status_t SetMode(uint16 width, uint16 height,
|
status_t SetMode(uint16 width, uint16 height,
|
||||||
uint32 colorspace,
|
uint32 colorspace,
|
||||||
const display_timing& timing,
|
const display_timing& timing);
|
||||||
bool makeDefault);
|
|
||||||
status_t SetPreferredMode();
|
status_t SetPreferredMode();
|
||||||
status_t SetBestMode(uint16 width, uint16 height,
|
status_t SetBestMode(uint16 width, uint16 height,
|
||||||
uint32 colorspace, float frequency,
|
uint32 colorspace, float frequency,
|
||||||
bool strict = true);
|
bool strict = true);
|
||||||
|
|
||||||
void GetMode(display_mode* mode) const;
|
void GetMode(display_mode& mode) const;
|
||||||
void GetMode(uint16 &width, uint16 &height,
|
void GetMode(uint16 &width, uint16 &height,
|
||||||
uint32 &colorspace, float &frequency) const;
|
uint32 &colorspace, float &frequency) const;
|
||||||
|
|
||||||
|
void SetFrame(const BRect& rect);
|
||||||
|
|
||||||
BRect Frame() const;
|
BRect Frame() const;
|
||||||
color_space ColorSpace() const;
|
color_space ColorSpace() const;
|
||||||
|
|
||||||
bool IsDefaultMode() const { return fIsDefault; }
|
|
||||||
|
|
||||||
inline DrawingEngine* GetDrawingEngine() const
|
inline DrawingEngine* GetDrawingEngine() const
|
||||||
{ return fDriver; }
|
{ return fDriver; }
|
||||||
inline ::HWInterface* HWInterface() const
|
inline ::HWInterface* HWInterface() const
|
||||||
{ return fHWInterface; }
|
{ return fHWInterface; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32 _FindBestMode(const display_mode* modeList,
|
int32 _FindBestMode(const display_mode* modeList,
|
||||||
uint32 count, uint16 width, uint16 height,
|
uint32 count, uint16 width, uint16 height,
|
||||||
uint32 colorspace, float frequency) const;
|
uint32 colorspace, float frequency) const;
|
||||||
@@ -63,7 +62,6 @@ class Screen {
|
|||||||
int32 fID;
|
int32 fID;
|
||||||
DrawingEngine* fDriver;
|
DrawingEngine* fDriver;
|
||||||
::HWInterface* fHWInterface;
|
::HWInterface* fHWInterface;
|
||||||
bool fIsDefault;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SCREEN_H */
|
#endif /* SCREEN_H */
|
||||||
|
|||||||
@@ -0,0 +1,257 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de.
|
||||||
|
* This file may be used under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "ScreenConfigurations.h"
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <Message.h>
|
||||||
|
|
||||||
|
|
||||||
|
ScreenConfigurations::ScreenConfigurations()
|
||||||
|
:
|
||||||
|
fConfigurations(10, true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ScreenConfigurations::~ScreenConfigurations()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
screen_configuration*
|
||||||
|
ScreenConfigurations::CurrentByID(int32 id) const
|
||||||
|
{
|
||||||
|
for (int32 i = fConfigurations.CountItems(); i-- > 0;) {
|
||||||
|
screen_configuration* configuration = fConfigurations.ItemAt(i);
|
||||||
|
|
||||||
|
if (configuration->id == id && configuration->is_current)
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
screen_configuration*
|
||||||
|
ScreenConfigurations::BestFit(int32 id, const monitor_info* info,
|
||||||
|
bool* _exactMatch) const
|
||||||
|
{
|
||||||
|
if (info == NULL) {
|
||||||
|
// only look for a matching ID - this is all we have
|
||||||
|
for (uint32 pass = 0; pass < 2; pass++) {
|
||||||
|
for (int32 i = fConfigurations.CountItems(); i-- > 0;) {
|
||||||
|
screen_configuration* configuration = fConfigurations.ItemAt(i);
|
||||||
|
|
||||||
|
if ((pass != 0 || !configuration->has_info)
|
||||||
|
&& id == configuration->id)
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// look for a configuration that matches the monitor
|
||||||
|
|
||||||
|
bool exactMatch = false;
|
||||||
|
int32 bestScore = 0;
|
||||||
|
int32 bestIndex = -1;
|
||||||
|
BMessage stored;
|
||||||
|
|
||||||
|
for (int32 i = fConfigurations.CountItems(); i-- > 0;) {
|
||||||
|
screen_configuration* configuration = fConfigurations.ItemAt(i);
|
||||||
|
int32 score = 0;
|
||||||
|
|
||||||
|
// TODO: should we ignore unnamed settings here completely?
|
||||||
|
|
||||||
|
if (configuration->id == id)
|
||||||
|
score++;
|
||||||
|
|
||||||
|
if (!strcasecmp(configuration->info.vendor, info->vendor)
|
||||||
|
&& !strcasecmp(configuration->info.name, info->name)
|
||||||
|
&& configuration->info.product_id == info->product_id) {
|
||||||
|
score += 2;
|
||||||
|
if (info->serial_number[0] != '\0'
|
||||||
|
&& !strcmp(configuration->info.serial_number,
|
||||||
|
info->serial_number)) {
|
||||||
|
exactMatch = true;
|
||||||
|
score += 2;
|
||||||
|
}
|
||||||
|
if (configuration->info.produced.year == info->produced.year
|
||||||
|
&& configuration->info.produced.week == info->produced.week)
|
||||||
|
score++;
|
||||||
|
} else
|
||||||
|
score -= 2;
|
||||||
|
|
||||||
|
if (score > bestScore) {
|
||||||
|
bestScore = score;
|
||||||
|
bestIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bestIndex < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (_exactMatch != NULL)
|
||||||
|
*_exactMatch = exactMatch;
|
||||||
|
|
||||||
|
return fConfigurations.ItemAt(bestIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
ScreenConfigurations::Set(int32 id, const monitor_info* info,
|
||||||
|
const BRect& frame, const display_mode& mode)
|
||||||
|
{
|
||||||
|
// Find configuration that we can overwrite
|
||||||
|
|
||||||
|
bool exactMatch;
|
||||||
|
screen_configuration* configuration = BestFit(id, info, &exactMatch);
|
||||||
|
|
||||||
|
if (configuration != NULL && configuration->has_info && !exactMatch) {
|
||||||
|
// only overwrite exact or unspecified configurations
|
||||||
|
configuration->is_current = false;
|
||||||
|
// TODO: provide a more obvious current mechanism...
|
||||||
|
configuration = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configuration == NULL) {
|
||||||
|
// we need a new configuration to store
|
||||||
|
configuration = new (std::nothrow) screen_configuration;
|
||||||
|
if (configuration == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
fConfigurations.AddItem(configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
configuration->id = id;
|
||||||
|
configuration->frame = frame;
|
||||||
|
configuration->is_current = true;
|
||||||
|
|
||||||
|
if (info != NULL) {
|
||||||
|
memcpy(&configuration->info, info, sizeof(monitor_info));
|
||||||
|
configuration->has_info = true;
|
||||||
|
} else
|
||||||
|
configuration->has_info = false;
|
||||||
|
|
||||||
|
memcpy(&configuration->mode, &mode, sizeof(display_mode));
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
ScreenConfigurations::Update(int32 id, const display_mode& mode)
|
||||||
|
{
|
||||||
|
screen_configuration* configuration = CurrentByID(id);
|
||||||
|
if (configuration == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
configuration->is_current = true;
|
||||||
|
|
||||||
|
memcpy(&configuration->mode, &mode, sizeof(display_mode));
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Stores all configurations as separate BMessages into the provided
|
||||||
|
\a settings container.
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
ScreenConfigurations::Store(BMessage& settings) const
|
||||||
|
{
|
||||||
|
// Store the configuration of all current screens
|
||||||
|
|
||||||
|
for (int32 i = 0; i < fConfigurations.CountItems(); i++) {
|
||||||
|
screen_configuration* configuration = fConfigurations.ItemAt(i);
|
||||||
|
|
||||||
|
BMessage screenSettings;
|
||||||
|
screenSettings.AddInt32("id", configuration->id);
|
||||||
|
|
||||||
|
if (configuration->has_info) {
|
||||||
|
screenSettings.AddString("vendor", configuration->info.vendor);
|
||||||
|
screenSettings.AddString("name", configuration->info.name);
|
||||||
|
screenSettings.AddInt32("product id",
|
||||||
|
configuration->info.product_id);
|
||||||
|
screenSettings.AddString("serial",
|
||||||
|
configuration->info.serial_number);
|
||||||
|
screenSettings.AddInt32("produced week",
|
||||||
|
configuration->info.produced.week);
|
||||||
|
screenSettings.AddInt32("produced year",
|
||||||
|
configuration->info.produced.year);
|
||||||
|
}
|
||||||
|
|
||||||
|
screenSettings.AddRect("frame", configuration->frame);
|
||||||
|
screenSettings.AddData("mode", B_RAW_TYPE, &configuration->mode,
|
||||||
|
sizeof(display_mode));
|
||||||
|
|
||||||
|
settings.AddMessage("screen", &screenSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
ScreenConfigurations::Restore(const BMessage& settings)
|
||||||
|
{
|
||||||
|
fConfigurations.MakeEmpty();
|
||||||
|
|
||||||
|
BMessage stored;
|
||||||
|
for (int32 i = 0; settings.FindMessage("screen", i, &stored) == B_OK; i++) {
|
||||||
|
const display_mode* mode;
|
||||||
|
ssize_t size;
|
||||||
|
int32 id;
|
||||||
|
if (stored.FindInt32("id", &id) != B_OK
|
||||||
|
|| stored.FindData("mode", B_RAW_TYPE, (const void**)&mode,
|
||||||
|
&size) != B_OK
|
||||||
|
|| size == sizeof(display_mode))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
screen_configuration* configuration
|
||||||
|
= new(std::nothrow) screen_configuration;
|
||||||
|
if (configuration == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
configuration->id = id;
|
||||||
|
configuration->is_current = false;
|
||||||
|
|
||||||
|
const char* vendor;
|
||||||
|
const char* name;
|
||||||
|
uint32 productID;
|
||||||
|
const char* serial;
|
||||||
|
int32 week, year;
|
||||||
|
if (stored.FindString("vendor", &vendor) == B_OK
|
||||||
|
&& stored.FindString("name", &name) == B_OK
|
||||||
|
&& stored.FindInt32("product id", (int32*)&productID) == B_OK
|
||||||
|
&& stored.FindString("serial", &serial) == B_OK
|
||||||
|
&& stored.FindInt32("produced week", &week) == B_OK
|
||||||
|
&& stored.FindInt32("produced year", &year) == B_OK) {
|
||||||
|
// create monitor info
|
||||||
|
strlcpy(configuration->info.vendor, vendor,
|
||||||
|
sizeof(monitor_info::vendor));
|
||||||
|
strlcpy(configuration->info.name, name, sizeof(monitor_info::name));
|
||||||
|
strlcpy(configuration->info.serial_number, serial,
|
||||||
|
sizeof(monitor_info::serial_number));
|
||||||
|
configuration->info.product_id = productID;
|
||||||
|
configuration->info.produced.week = week;
|
||||||
|
configuration->info.produced.year = year;
|
||||||
|
configuration->has_info = true;
|
||||||
|
} else
|
||||||
|
configuration->has_info = false;
|
||||||
|
|
||||||
|
stored.FindRect("frame", &configuration->frame);
|
||||||
|
memcpy(&configuration->mode, mode, sizeof(display_mode));
|
||||||
|
|
||||||
|
fConfigurations.AddItem(configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
|
||||||
|
* This file may be used under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef SCREEN_CONFIGURATIONS_H
|
||||||
|
#define SCREEN_CONFIGURATIONS_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Accelerant.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
|
||||||
|
#include <ObjectList.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BMessage;
|
||||||
|
|
||||||
|
|
||||||
|
struct screen_configuration {
|
||||||
|
int32 id;
|
||||||
|
monitor_info info;
|
||||||
|
BRect frame;
|
||||||
|
display_mode mode;
|
||||||
|
bool has_info;
|
||||||
|
bool is_current;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ScreenConfigurations {
|
||||||
|
public:
|
||||||
|
ScreenConfigurations();
|
||||||
|
~ScreenConfigurations();
|
||||||
|
|
||||||
|
screen_configuration* CurrentByID(int32 id) const;
|
||||||
|
screen_configuration* BestFit(int32 id, const monitor_info* info,
|
||||||
|
bool* _exactMatch = NULL) const;
|
||||||
|
|
||||||
|
status_t Set(int32 id, const monitor_info* info,
|
||||||
|
const BRect& frame,
|
||||||
|
const display_mode& mode);
|
||||||
|
status_t Update(int32 id, const display_mode& mode);
|
||||||
|
|
||||||
|
status_t Store(BMessage& settings) const;
|
||||||
|
status_t Restore(const BMessage& settings);
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef BObjectList<screen_configuration> ConfigurationList;
|
||||||
|
|
||||||
|
ConfigurationList fConfigurations;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // SCREEN_CONFIGURATIONS_H
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005-2008, Haiku.
|
* Copyright 2005-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -35,7 +35,8 @@ ScreenManager* gScreenManager;
|
|||||||
|
|
||||||
|
|
||||||
ScreenManager::ScreenManager()
|
ScreenManager::ScreenManager()
|
||||||
: BLooper("screen manager"),
|
:
|
||||||
|
BLooper("screen manager"),
|
||||||
fScreenList(4)
|
fScreenList(4)
|
||||||
{
|
{
|
||||||
_ScanDrivers();
|
_ScanDrivers();
|
||||||
@@ -93,7 +94,7 @@ ScreenManager::AcquireScreens(ScreenOwner* owner, int32* wishList,
|
|||||||
// ToDo: don't ignore the wish list
|
// ToDo: don't ignore the wish list
|
||||||
|
|
||||||
for (int32 i = 0; i < fScreenList.CountItems(); i++) {
|
for (int32 i = 0; i < fScreenList.CountItems(); i++) {
|
||||||
screen_item *item = fScreenList.ItemAt(i);
|
screen_item* item = fScreenList.ItemAt(i);
|
||||||
|
|
||||||
if (item->owner == NULL && list.AddItem(item->screen)) {
|
if (item->owner == NULL && list.AddItem(item->screen)) {
|
||||||
item->owner = owner;
|
item->owner = owner;
|
||||||
@@ -111,7 +112,7 @@ ScreenManager::ReleaseScreens(ScreenList& list)
|
|||||||
BAutolock locker(this);
|
BAutolock locker(this);
|
||||||
|
|
||||||
for (int32 i = 0; i < fScreenList.CountItems(); i++) {
|
for (int32 i = 0; i < fScreenList.CountItems(); i++) {
|
||||||
screen_item *item = fScreenList.ItemAt(i);
|
screen_item* item = fScreenList.ItemAt(i);
|
||||||
|
|
||||||
for (int32 j = 0; j < list.CountItems(); j++) {
|
for (int32 j = 0; j < list.CountItems(); j++) {
|
||||||
Screen* screen = list.ItemAt(j);
|
Screen* screen = list.ItemAt(j);
|
||||||
@@ -126,7 +127,7 @@ ScreenManager::ReleaseScreens(ScreenList& list)
|
|||||||
void
|
void
|
||||||
ScreenManager::_ScanDrivers()
|
ScreenManager::_ScanDrivers()
|
||||||
{
|
{
|
||||||
HWInterface *interface = NULL;
|
HWInterface* interface = NULL;
|
||||||
|
|
||||||
// Eventually we will loop through drivers until
|
// Eventually we will loop through drivers until
|
||||||
// one can't initialize in order to support multiple monitors.
|
// one can't initialize in order to support multiple monitors.
|
||||||
@@ -155,7 +156,7 @@ ScreenManager::_ScanDrivers()
|
|||||||
void
|
void
|
||||||
ScreenManager::_AddHWInterface(HWInterface* interface)
|
ScreenManager::_AddHWInterface(HWInterface* interface)
|
||||||
{
|
{
|
||||||
Screen* screen = new(nothrow) Screen(interface, fScreenList.CountItems() + 1);
|
Screen* screen = new(nothrow) Screen(interface, fScreenList.CountItems());
|
||||||
if (screen == NULL) {
|
if (screen == NULL) {
|
||||||
delete interface;
|
delete interface;
|
||||||
return;
|
return;
|
||||||
@@ -184,7 +185,7 @@ ScreenManager::MessageReceived(BMessage* message)
|
|||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case B_NODE_MONITOR:
|
case B_NODE_MONITOR:
|
||||||
// ToDo: handle notification
|
// TODO: handle notification
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -615,7 +615,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
// 2) color_space space
|
// 2) color_space space
|
||||||
// 3) int32 bitmap_flags
|
// 3) int32 bitmap_flags
|
||||||
// 4) int32 bytes_per_row
|
// 4) int32 bytes_per_row
|
||||||
// 5) int32 screen_id::id
|
// 5) int32 screen_id
|
||||||
|
|
||||||
// Reply Data:
|
// Reply Data:
|
||||||
// 1) int32 server token
|
// 1) int32 server token
|
||||||
@@ -630,13 +630,13 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
color_space colorSpace;
|
color_space colorSpace;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
int32 bytesPerRow;
|
int32 bytesPerRow;
|
||||||
screen_id screenID;
|
int32 screenID;
|
||||||
|
|
||||||
link.Read<BRect>(&frame);
|
link.Read<BRect>(&frame);
|
||||||
link.Read<color_space>(&colorSpace);
|
link.Read<color_space>(&colorSpace);
|
||||||
link.Read<uint32>(&flags);
|
link.Read<uint32>(&flags);
|
||||||
link.Read<int32>(&bytesPerRow);
|
link.Read<int32>(&bytesPerRow);
|
||||||
if (link.Read<screen_id>(&screenID) == B_OK) {
|
if (link.Read<int32>(&screenID) == B_OK) {
|
||||||
// TODO: choose the right HWInterface with regards to the
|
// TODO: choose the right HWInterface with regards to the
|
||||||
// screenID
|
// screenID
|
||||||
bitmap = gBitmapManager->CreateBitmap(&fMemoryAllocator,
|
bitmap = gBitmapManager->CreateBitmap(&fMemoryAllocator,
|
||||||
@@ -2218,10 +2218,10 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
case AS_VALID_SCREEN_ID:
|
case AS_VALID_SCREEN_ID:
|
||||||
{
|
{
|
||||||
// Attached data
|
// Attached data
|
||||||
// 1) screen_id screen
|
// 1) int32 screen
|
||||||
screen_id id;
|
int32 id;
|
||||||
if (link.Read<screen_id>(&id) == B_OK
|
if (link.Read<int32>(&id) == B_OK
|
||||||
&& id.id == B_MAIN_SCREEN_ID.id)
|
&& id == B_MAIN_SCREEN_ID.id)
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
else
|
else
|
||||||
fLink.StartMessage(B_ERROR);
|
fLink.StartMessage(B_ERROR);
|
||||||
@@ -2233,9 +2233,9 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
case AS_GET_NEXT_SCREEN_ID:
|
case AS_GET_NEXT_SCREEN_ID:
|
||||||
{
|
{
|
||||||
// Attached data
|
// Attached data
|
||||||
// 1) screen_id screen
|
// 1) int32 screen
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
|
|
||||||
// TODO: for now, just say we're the last one
|
// TODO: for now, just say we're the last one
|
||||||
fLink.StartMessage(B_ENTRY_NOT_FOUND);
|
fLink.StartMessage(B_ENTRY_NOT_FOUND);
|
||||||
@@ -2261,7 +2261,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
if (window->ClientToken() == clientToken) {
|
if (window->ClientToken() == clientToken) {
|
||||||
// got it!
|
// got it!
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
fLink.Attach<screen_id>(B_MAIN_SCREEN_ID);
|
fLink.Attach<int32>(B_MAIN_SCREEN_ID.id);
|
||||||
// TODO: for now...
|
// TODO: for now...
|
||||||
status = B_OK;
|
status = B_OK;
|
||||||
}
|
}
|
||||||
@@ -2278,27 +2278,19 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
{
|
{
|
||||||
STRACE(("ServerApp %s: AS_SCREEN_GET_MODE\n", Signature()));
|
STRACE(("ServerApp %s: AS_SCREEN_GET_MODE\n", Signature()));
|
||||||
// Attached data
|
// Attached data
|
||||||
// 1) screen_id screen
|
// 1) int32 screen
|
||||||
// 2) uint32 workspace index
|
// 2) uint32 workspace index
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
uint32 workspace;
|
uint32 workspace;
|
||||||
link.Read<uint32>(&workspace);
|
link.Read<uint32>(&workspace);
|
||||||
|
|
||||||
display_mode mode;
|
display_mode mode;
|
||||||
if (fDesktop->LockSingleWindow()) {
|
status_t status = fDesktop->GetScreenMode(workspace, id, mode);
|
||||||
// TODO: the display_mode can be different between
|
|
||||||
// the various screens.
|
fLink.StartMessage(status);
|
||||||
// We have the screen_id and the workspace number,
|
if (status == B_OK)
|
||||||
// with these we need to find the corresponding
|
fLink.Attach<display_mode>(mode);
|
||||||
// "driver", and call getmode on it
|
|
||||||
fDesktop->ScreenAt(0)->GetMode(&mode);
|
|
||||||
// actually this isn't still enough as different
|
|
||||||
// workspaces can have different display_modes
|
|
||||||
fDesktop->UnlockSingleWindow();
|
|
||||||
}
|
|
||||||
fLink.StartMessage(B_OK);
|
|
||||||
fLink.Attach<display_mode>(mode);
|
|
||||||
fLink.Flush();
|
fLink.Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2306,13 +2298,13 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
{
|
{
|
||||||
STRACE(("ServerApp %s: AS_SCREEN_SET_MODE\n", Signature()));
|
STRACE(("ServerApp %s: AS_SCREEN_SET_MODE\n", Signature()));
|
||||||
// Attached data
|
// Attached data
|
||||||
// 1) screen_id
|
// 1) int32 screen
|
||||||
// 2) workspace index
|
// 2) workspace index
|
||||||
// 3) display_mode to set
|
// 3) display_mode to set
|
||||||
// 4) 'makeDefault' boolean
|
// 4) 'makeDefault' boolean
|
||||||
|
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
|
|
||||||
uint32 workspace;
|
uint32 workspace;
|
||||||
link.Read<uint32>(&workspace);
|
link.Read<uint32>(&workspace);
|
||||||
@@ -2323,33 +2315,10 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
bool makeDefault = false;
|
bool makeDefault = false;
|
||||||
status_t status = link.Read<bool>(&makeDefault);
|
status_t status = link.Read<bool>(&makeDefault);
|
||||||
|
|
||||||
if (status == B_OK && fDesktop->LockAllWindows()) {
|
if (status == B_OK) {
|
||||||
display_mode oldMode;
|
status = fDesktop->SetScreenMode(workspace, id, mode,
|
||||||
// ~0 is used as the current workspace in PrivateScreen
|
makeDefault);
|
||||||
// TODO: add constant for this
|
}
|
||||||
if (workspace == (uint32)~0
|
|
||||||
|| workspace == (uint32)fDesktop->CurrentWorkspace()) {
|
|
||||||
fDesktop->ScreenAt(0)->GetMode(&oldMode);
|
|
||||||
if (memcmp(&oldMode, &mode, sizeof(display_mode))) {
|
|
||||||
status = fDesktop->ScreenAt(0)->SetMode(mode,
|
|
||||||
makeDefault);
|
|
||||||
if (status == B_OK) {
|
|
||||||
fDesktop->ScreenChanged(fDesktop->ScreenAt(0),
|
|
||||||
makeDefault);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
status = B_OK;
|
|
||||||
} else {
|
|
||||||
// If you don't intend to make the screen mode the default
|
|
||||||
// for the given workspace, then you cannot change the
|
|
||||||
// configuration at all. I.e. non-default (not permanent)
|
|
||||||
// screen modes only work for the current workspace.
|
|
||||||
if (makeDefault)
|
|
||||||
fDesktop->StoreConfiguration(workspace);
|
|
||||||
}
|
|
||||||
fDesktop->UnlockAllWindows();
|
|
||||||
} else
|
|
||||||
status = B_ERROR;
|
|
||||||
|
|
||||||
fLink.StartMessage(status);
|
fLink.StartMessage(status);
|
||||||
fLink.Flush();
|
fLink.Flush();
|
||||||
@@ -2359,14 +2328,15 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
case AS_PROPOSE_MODE:
|
case AS_PROPOSE_MODE:
|
||||||
{
|
{
|
||||||
STRACE(("ServerApp %s: AS_PROPOSE_MODE\n", Signature()));
|
STRACE(("ServerApp %s: AS_PROPOSE_MODE\n", Signature()));
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
|
|
||||||
display_mode target, low, high;
|
display_mode target, low, high;
|
||||||
link.Read<display_mode>(&target);
|
link.Read<display_mode>(&target);
|
||||||
link.Read<display_mode>(&low);
|
link.Read<display_mode>(&low);
|
||||||
link.Read<display_mode>(&high);
|
link.Read<display_mode>(&high);
|
||||||
status_t status = fDesktop->HWInterface()->ProposeMode(&target, &low, &high);
|
status_t status = fDesktop->HWInterface()->ProposeMode(&target,
|
||||||
|
&low, &high);
|
||||||
|
|
||||||
// ProposeMode() returns B_BAD_VALUE to hint that the candidate is
|
// ProposeMode() returns B_BAD_VALUE to hint that the candidate is
|
||||||
// not within the given limits (but is supported)
|
// not within the given limits (but is supported)
|
||||||
@@ -2383,13 +2353,14 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
|
|
||||||
case AS_GET_MODE_LIST:
|
case AS_GET_MODE_LIST:
|
||||||
{
|
{
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
// TODO: use this screen id
|
// TODO: use this screen id
|
||||||
|
|
||||||
display_mode* modeList;
|
display_mode* modeList;
|
||||||
uint32 count;
|
uint32 count;
|
||||||
status_t status = fDesktop->HWInterface()->GetModeList(&modeList, &count);
|
status_t status = fDesktop->HWInterface()->GetModeList(&modeList,
|
||||||
|
&count);
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
fLink.Attach<uint32>(count);
|
fLink.Attach<uint32>(count);
|
||||||
@@ -2407,10 +2378,10 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
{
|
{
|
||||||
STRACE(("ServerApp %s: AS_SCREEN_GET_COLORMAP\n", Signature()));
|
STRACE(("ServerApp %s: AS_SCREEN_GET_COLORMAP\n", Signature()));
|
||||||
|
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
|
|
||||||
const color_map *colorMap = SystemColorMap();
|
const color_map* colorMap = SystemColorMap();
|
||||||
if (colorMap != NULL) {
|
if (colorMap != NULL) {
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
fLink.Attach<color_map>(*colorMap);
|
fLink.Attach<color_map>(*colorMap);
|
||||||
@@ -2493,12 +2464,13 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
STRACE(("ServerApp %s: get accelerant info\n", Signature()));
|
STRACE(("ServerApp %s: get accelerant info\n", Signature()));
|
||||||
|
|
||||||
// We aren't using the screen_id for now...
|
// We aren't using the screen_id for now...
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
|
|
||||||
accelerant_device_info accelerantInfo;
|
accelerant_device_info accelerantInfo;
|
||||||
// TODO: I wonder if there should be a "desktop" lock...
|
// TODO: I wonder if there should be a "desktop" lock...
|
||||||
status_t status = fDesktop->HWInterface()->GetDeviceInfo(&accelerantInfo);
|
status_t status
|
||||||
|
= fDesktop->HWInterface()->GetDeviceInfo(&accelerantInfo);
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
fLink.Attach<accelerant_device_info>(accelerantInfo);
|
fLink.Attach<accelerant_device_info>(accelerantInfo);
|
||||||
@@ -2514,8 +2486,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
STRACE(("ServerApp %s: get monitor info\n", Signature()));
|
STRACE(("ServerApp %s: get monitor info\n", Signature()));
|
||||||
|
|
||||||
// We aren't using the screen_id for now...
|
// We aren't using the screen_id for now...
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
|
|
||||||
monitor_info info;
|
monitor_info info;
|
||||||
// TODO: I wonder if there should be a "desktop" lock...
|
// TODO: I wonder if there should be a "desktop" lock...
|
||||||
@@ -2535,8 +2507,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
STRACE(("ServerApp %s: get frame buffer config\n", Signature()));
|
STRACE(("ServerApp %s: get frame buffer config\n", Signature()));
|
||||||
|
|
||||||
// We aren't using the screen_id for now...
|
// We aren't using the screen_id for now...
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
|
|
||||||
frame_buffer_config config;
|
frame_buffer_config config;
|
||||||
// TODO: I wonder if there should be a "desktop" lock...
|
// TODO: I wonder if there should be a "desktop" lock...
|
||||||
@@ -2556,8 +2528,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
STRACE(("ServerApp %s: get retrace semaphore\n", Signature()));
|
STRACE(("ServerApp %s: get retrace semaphore\n", Signature()));
|
||||||
|
|
||||||
// We aren't using the screen_id for now...
|
// We aren't using the screen_id for now...
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
|
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
fLink.Attach<sem_id>(fDesktop->HWInterface()->RetraceSemaphore());
|
fLink.Attach<sem_id>(fDesktop->HWInterface()->RetraceSemaphore());
|
||||||
@@ -2569,8 +2541,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
{
|
{
|
||||||
STRACE(("ServerApp %s: get timing constraints\n", Signature()));
|
STRACE(("ServerApp %s: get timing constraints\n", Signature()));
|
||||||
// We aren't using the screen_id for now...
|
// We aren't using the screen_id for now...
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
|
|
||||||
display_timing_constraints constraints;
|
display_timing_constraints constraints;
|
||||||
status_t status = fDesktop->HWInterface()->GetTimingConstraints(
|
status_t status = fDesktop->HWInterface()->GetTimingConstraints(
|
||||||
@@ -2589,8 +2561,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
{
|
{
|
||||||
STRACE(("ServerApp %s: get pixel clock limits\n", Signature()));
|
STRACE(("ServerApp %s: get pixel clock limits\n", Signature()));
|
||||||
// We aren't using the screen_id for now...
|
// We aren't using the screen_id for now...
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
display_mode mode;
|
display_mode mode;
|
||||||
link.Read<display_mode>(&mode);
|
link.Read<display_mode>(&mode);
|
||||||
|
|
||||||
@@ -2611,8 +2583,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
case AS_SET_DPMS:
|
case AS_SET_DPMS:
|
||||||
{
|
{
|
||||||
STRACE(("ServerApp %s: AS_SET_DPMS\n", Signature()));
|
STRACE(("ServerApp %s: AS_SET_DPMS\n", Signature()));
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
|
|
||||||
uint32 mode;
|
uint32 mode;
|
||||||
link.Read<uint32>(&mode);
|
link.Read<uint32>(&mode);
|
||||||
@@ -2628,8 +2600,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
{
|
{
|
||||||
STRACE(("ServerApp %s: AS_GET_DPMS_STATE\n", Signature()));
|
STRACE(("ServerApp %s: AS_GET_DPMS_STATE\n", Signature()));
|
||||||
|
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
|
|
||||||
uint32 state = fDesktop->HWInterface()->DPMSMode();
|
uint32 state = fDesktop->HWInterface()->DPMSMode();
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
@@ -2641,8 +2613,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
case AS_GET_DPMS_CAPABILITIES:
|
case AS_GET_DPMS_CAPABILITIES:
|
||||||
{
|
{
|
||||||
STRACE(("ServerApp %s: AS_GET_DPMS_CAPABILITIES\n", Signature()));
|
STRACE(("ServerApp %s: AS_GET_DPMS_CAPABILITIES\n", Signature()));
|
||||||
screen_id id;
|
int32 id;
|
||||||
link.Read<screen_id>(&id);
|
link.Read<int32>(&id);
|
||||||
|
|
||||||
uint32 capabilities = fDesktop->HWInterface()->DPMSCapabilities();
|
uint32 capabilities = fDesktop->HWInterface()->DPMSCapabilities();
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
@@ -2679,8 +2651,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
|
|
||||||
case AS_GET_ACCELERANT_PATH:
|
case AS_GET_ACCELERANT_PATH:
|
||||||
{
|
{
|
||||||
screen_id id;
|
int32 id;
|
||||||
fLink.Read<screen_id>(&id);
|
fLink.Read<int32>(&id);
|
||||||
|
|
||||||
BString path;
|
BString path;
|
||||||
status_t status = fDesktop->HWInterface()->GetAccelerantPath(path);
|
status_t status = fDesktop->HWInterface()->GetAccelerantPath(path);
|
||||||
@@ -2694,8 +2666,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
|
|
||||||
case AS_GET_DRIVER_PATH:
|
case AS_GET_DRIVER_PATH:
|
||||||
{
|
{
|
||||||
screen_id id;
|
int32 id;
|
||||||
fLink.Read<screen_id>(&id);
|
fLink.Read<int32>(&id);
|
||||||
|
|
||||||
BString path;
|
BString path;
|
||||||
status_t status = fDesktop->HWInterface()->GetDriverPath(path);
|
status_t status = fDesktop->HWInterface()->GetDriverPath(path);
|
||||||
|
|||||||
@@ -123,42 +123,48 @@ static profile sRedrawProcessingTime;
|
|||||||
// TODO: Move to another file
|
// TODO: Move to another file
|
||||||
struct BufferState {
|
struct BufferState {
|
||||||
BufferState(const direct_buffer_state &state)
|
BufferState(const direct_buffer_state &state)
|
||||||
: fState(state)
|
:
|
||||||
|
fState(state)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
direct_buffer_state Action() const
|
direct_buffer_state Action() const
|
||||||
{
|
{
|
||||||
return (direct_buffer_state)(fState & B_DIRECT_MODE_MASK);
|
return (direct_buffer_state)(fState & B_DIRECT_MODE_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
direct_buffer_state Reason() const
|
direct_buffer_state Reason() const
|
||||||
{
|
{
|
||||||
return (direct_buffer_state)(fState & ~B_DIRECT_MODE_MASK);
|
return (direct_buffer_state)(fState & ~B_DIRECT_MODE_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
direct_buffer_state fState;
|
direct_buffer_state fState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DirectWindowData {
|
class DirectWindowData {
|
||||||
public:
|
public:
|
||||||
DirectWindowData();
|
DirectWindowData();
|
||||||
~DirectWindowData();
|
~DirectWindowData();
|
||||||
|
|
||||||
|
status_t InitCheck() const;
|
||||||
|
|
||||||
|
status_t GetSyncData(
|
||||||
|
direct_window_sync_data& data) const;
|
||||||
|
status_t SyncronizeWithClient();
|
||||||
|
|
||||||
|
bool SetState(const direct_buffer_state& bufferState,
|
||||||
|
const direct_driver_state& driverState);
|
||||||
|
|
||||||
|
BRect old_window_frame;
|
||||||
|
direct_buffer_info* buffer_info;
|
||||||
|
bool full_screen;
|
||||||
|
|
||||||
status_t InitCheck() const;
|
|
||||||
|
|
||||||
status_t GetSyncData(direct_window_sync_data &data) const;
|
|
||||||
status_t SyncronizeWithClient();
|
|
||||||
|
|
||||||
bool SetState(const direct_buffer_state &bufferState,
|
|
||||||
const direct_driver_state &driverState);
|
|
||||||
|
|
||||||
BRect old_window_frame;
|
|
||||||
direct_buffer_info *buffer_info;
|
|
||||||
bool full_screen;
|
|
||||||
private:
|
private:
|
||||||
sem_id fSem;
|
sem_id fSem;
|
||||||
sem_id fAcknowledgeSem;
|
sem_id fAcknowledgeSem;
|
||||||
area_id fBufferArea;
|
area_id fBufferArea;
|
||||||
direct_buffer_state fPreviousState;
|
direct_buffer_state fPreviousState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -171,7 +177,7 @@ DirectWindowData::DirectWindowData()
|
|||||||
fBufferArea(-1),
|
fBufferArea(-1),
|
||||||
fPreviousState(B_DIRECT_STOP)
|
fPreviousState(B_DIRECT_STOP)
|
||||||
{
|
{
|
||||||
fBufferArea = create_area("direct area", (void **)&buffer_info,
|
fBufferArea = create_area("direct area", (void**)&buffer_info,
|
||||||
B_ANY_ADDRESS, B_PAGE_SIZE, B_NO_LOCK, B_READ_WRITE);
|
B_ANY_ADDRESS, B_PAGE_SIZE, B_NO_LOCK, B_READ_WRITE);
|
||||||
|
|
||||||
buffer_info->buffer_state = B_DIRECT_STOP;
|
buffer_info->buffer_state = B_DIRECT_STOP;
|
||||||
@@ -207,12 +213,12 @@ DirectWindowData::InitCheck() const
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DirectWindowData::GetSyncData(direct_window_sync_data &data) const
|
DirectWindowData::GetSyncData(direct_window_sync_data& data) const
|
||||||
{
|
{
|
||||||
data.area = fBufferArea;
|
data.area = fBufferArea;
|
||||||
data.disable_sem = fSem;
|
data.disable_sem = fSem;
|
||||||
data.disable_sem_ack = fAcknowledgeSem;
|
data.disable_sem_ack = fAcknowledgeSem;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +229,7 @@ DirectWindowData::SyncronizeWithClient()
|
|||||||
// Releasing this semaphore causes the client to call
|
// Releasing this semaphore causes the client to call
|
||||||
// BDirectWindow::DirectConnected()
|
// BDirectWindow::DirectConnected()
|
||||||
status_t status = release_sem(fSem);
|
status_t status = release_sem(fSem);
|
||||||
if (status < B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
// Wait with a timeout of half a second until the client exits
|
// Wait with a timeout of half a second until the client exits
|
||||||
@@ -231,49 +237,69 @@ DirectWindowData::SyncronizeWithClient()
|
|||||||
do {
|
do {
|
||||||
status = acquire_sem_etc(fAcknowledgeSem, 1, B_TIMEOUT, 500000);
|
status = acquire_sem_etc(fAcknowledgeSem, 1, B_TIMEOUT, 500000);
|
||||||
} while (status == B_INTERRUPTED);
|
} while (status == B_INTERRUPTED);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DirectWindowData::SetState(const direct_buffer_state &bufferState,
|
DirectWindowData::SetState(const direct_buffer_state& bufferState,
|
||||||
const direct_driver_state &driverState)
|
const direct_driver_state& driverState)
|
||||||
{
|
{
|
||||||
BufferState inputState(bufferState);
|
BufferState inputState(bufferState);
|
||||||
BufferState currentState(buffer_info->buffer_state);
|
BufferState currentState(buffer_info->buffer_state);
|
||||||
|
|
||||||
// Don't issue a DirectConnected() notification
|
// Don't issue a DirectConnected() notification
|
||||||
// if the connection is stopped, and we are called
|
// if the connection is stopped, and we are called
|
||||||
// with bufferState == B_DIRECT_MODIFY, but save the reason
|
// with bufferState == B_DIRECT_MODIFY, but save the reason
|
||||||
// and combine it for next time we are called with B_DIRECT_START
|
// and combine it for next time we are called with B_DIRECT_START
|
||||||
if (currentState.Action() == B_DIRECT_STOP
|
if (currentState.Action() == B_DIRECT_STOP
|
||||||
&& inputState.Action() != B_DIRECT_START) {
|
&& inputState.Action() != B_DIRECT_START) {
|
||||||
fPreviousState = (direct_buffer_state)(fPreviousState
|
fPreviousState = (direct_buffer_state)(fPreviousState
|
||||||
| inputState.Reason());
|
| inputState.Reason());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_info->buffer_state = (direct_buffer_state)(bufferState
|
buffer_info->buffer_state = (direct_buffer_state)(bufferState
|
||||||
| BufferState(fPreviousState).Reason());
|
| BufferState(fPreviousState).Reason());
|
||||||
|
|
||||||
fPreviousState = B_DIRECT_STOP;
|
fPreviousState = B_DIRECT_STOP;
|
||||||
|
|
||||||
if (driverState != -1)
|
if (driverState != -1)
|
||||||
buffer_info->driver_state = driverState;
|
buffer_info->driver_state = driverState;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef PROFILE_MESSAGE_LOOP
|
||||||
|
static int
|
||||||
|
compare_message_profiles(const void* _a, const void* _b)
|
||||||
|
{
|
||||||
|
profile* a = (profile*)*(void**)_a;
|
||||||
|
profile* b = (profile*)*(void**)_b;
|
||||||
|
if (a->time < b->time)
|
||||||
|
return 1;
|
||||||
|
if (a->time > b->time)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
/*! Sets up the basic BWindow counterpart - you have to call Init() before
|
/*! Sets up the basic BWindow counterpart - you have to call Init() before
|
||||||
you can actually use it, though.
|
you can actually use it, though.
|
||||||
*/
|
*/
|
||||||
ServerWindow::ServerWindow(const char *title, ServerApp *app,
|
ServerWindow::ServerWindow(const char* title, ServerApp* app,
|
||||||
port_id clientPort, port_id looperPort, int32 clientToken)
|
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()),
|
||||||
fServerApp(app),
|
fServerApp(app),
|
||||||
@@ -311,21 +337,6 @@ ServerWindow::ServerWindow(const char *title, ServerApp *app,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef PROFILE_MESSAGE_LOOP
|
|
||||||
static int
|
|
||||||
compare_message_profiles(const void* _a, const void* _b)
|
|
||||||
{
|
|
||||||
profile* a = (profile*)*(void**)_a;
|
|
||||||
profile* b = (profile*)*(void**)_b;
|
|
||||||
if (a->time < b->time)
|
|
||||||
return 1;
|
|
||||||
if (a->time > b->time)
|
|
||||||
return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*! Tears down all connections the main app_server objects, and deletes some
|
/*! Tears down all connections the main app_server objects, and deletes some
|
||||||
internals.
|
internals.
|
||||||
*/
|
*/
|
||||||
@@ -680,7 +691,7 @@ ServerWindow::_CreateView(BPrivate::LinkReceiver& link, View** _parent)
|
|||||||
delete newView;
|
delete newView;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// there is no way of setting this, other than manually :-)
|
// there is no way of setting this, other than manually :-)
|
||||||
newView->SetViewColor(viewColor);
|
newView->SetViewColor(viewColor);
|
||||||
newView->SetHidden(hidden);
|
newView->SetHidden(hidden);
|
||||||
@@ -3544,13 +3555,14 @@ ServerWindow::ScreenChanged(const BMessage *message)
|
|||||||
// TODO: execute the stop notification earlier
|
// TODO: execute the stop notification earlier
|
||||||
//HandleDirectConnection(B_DIRECT_STOP);
|
//HandleDirectConnection(B_DIRECT_STOP);
|
||||||
SendMessageToClient(message);
|
SendMessageToClient(message);
|
||||||
|
|
||||||
if (fDirectWindowData != NULL && fDirectWindowData->full_screen) {
|
if (fDirectWindowData != NULL && fDirectWindowData->full_screen) {
|
||||||
BRect screenFrame = fDesktop->ActiveScreen()->Frame();
|
BRect screenFrame = fDesktop->ActiveScreen()->Frame();
|
||||||
fDesktop->ResizeWindowBy(fWindow,
|
fDesktop->ResizeWindowBy(fWindow,
|
||||||
screenFrame.Width() - fWindow->Frame().Width(),
|
screenFrame.Width() - fWindow->Frame().Width(),
|
||||||
screenFrame.Height() - fWindow->Frame().Height());
|
screenFrame.Height() - fWindow->Frame().Height());
|
||||||
}
|
}
|
||||||
|
|
||||||
//HandleDirectConnection(B_DIRECT_START | B_BUFFER_RESET,
|
//HandleDirectConnection(B_DIRECT_START | B_BUFFER_RESET,
|
||||||
//B_SCREEN_CHANGED);
|
//B_SCREEN_CHANGED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005-2007, Haiku.
|
* Copyright 2005-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
using std::nothrow;
|
|
||||||
|
|
||||||
|
|
||||||
VirtualScreen::VirtualScreen()
|
VirtualScreen::VirtualScreen()
|
||||||
:
|
:
|
||||||
@@ -44,7 +42,6 @@ VirtualScreen::_Reset()
|
|||||||
|
|
||||||
gScreenManager->ReleaseScreens(list);
|
gScreenManager->ReleaseScreens(list);
|
||||||
fScreenList.MakeEmpty();
|
fScreenList.MakeEmpty();
|
||||||
fSettings.MakeEmpty();
|
|
||||||
|
|
||||||
fFrame.Set(0, 0, 0, 0);
|
fFrame.Set(0, 0, 0, 0);
|
||||||
fDrawingEngine = NULL;
|
fDrawingEngine = NULL;
|
||||||
@@ -53,8 +50,8 @@ VirtualScreen::_Reset()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
VirtualScreen::RestoreConfiguration(Desktop& desktop, const BMessage* settings,
|
VirtualScreen::SetConfiguration(Desktop& desktop,
|
||||||
uint32* _changedScreens)
|
ScreenConfigurations& configurations, uint32* _changedScreens)
|
||||||
{
|
{
|
||||||
// Remember previous screen modes
|
// Remember previous screen modes
|
||||||
|
|
||||||
@@ -70,7 +67,7 @@ VirtualScreen::RestoreConfiguration(Desktop& desktop, const BMessage* settings,
|
|||||||
Screen* screen = fScreenList.ItemAt(i)->screen;
|
Screen* screen = fScreenList.ItemAt(i)->screen;
|
||||||
|
|
||||||
display_mode mode;
|
display_mode mode;
|
||||||
screen->GetMode(&mode);
|
screen->GetMode(mode);
|
||||||
|
|
||||||
previousModes.insert(std::make_pair(screen, mode));
|
previousModes.insert(std::make_pair(screen, mode));
|
||||||
}
|
}
|
||||||
@@ -82,10 +79,6 @@ VirtualScreen::RestoreConfiguration(Desktop& desktop, const BMessage* settings,
|
|||||||
|
|
||||||
_Reset();
|
_Reset();
|
||||||
|
|
||||||
// Copy current Desktop workspace settings
|
|
||||||
if (settings)
|
|
||||||
fSettings = *settings;
|
|
||||||
|
|
||||||
ScreenList list;
|
ScreenList list;
|
||||||
status_t status = gScreenManager->AcquireScreens(&desktop, NULL, 0, false,
|
status_t status = gScreenManager->AcquireScreens(&desktop, NULL, 0, false,
|
||||||
list);
|
list);
|
||||||
@@ -97,12 +90,12 @@ VirtualScreen::RestoreConfiguration(Desktop& desktop, const BMessage* settings,
|
|||||||
for (int32 i = 0; i < list.CountItems(); i++) {
|
for (int32 i = 0; i < list.CountItems(); i++) {
|
||||||
Screen* screen = list.ItemAt(i);
|
Screen* screen = list.ItemAt(i);
|
||||||
|
|
||||||
AddScreen(screen);
|
AddScreen(screen, configurations);
|
||||||
|
|
||||||
if (!previousModesFailed && _changedScreens != NULL) {
|
if (!previousModesFailed && _changedScreens != NULL) {
|
||||||
// Figure out which screens have changed their mode
|
// Figure out which screens have changed their mode
|
||||||
display_mode mode;
|
display_mode mode;
|
||||||
screen->GetMode(&mode);
|
screen->GetMode(mode);
|
||||||
|
|
||||||
ScreenModeMap::const_iterator found = previousModes.find(screen);
|
ScreenModeMap::const_iterator found = previousModes.find(screen);
|
||||||
if (found != previousModes.end()
|
if (found != previousModes.end()
|
||||||
@@ -111,84 +104,30 @@ VirtualScreen::RestoreConfiguration(Desktop& desktop, const BMessage* settings,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateFrame();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
VirtualScreen::StoreConfiguration(BMessage& settings)
|
VirtualScreen::AddScreen(Screen* screen, ScreenConfigurations& configurations)
|
||||||
{
|
{
|
||||||
// store the configuration of all current screens
|
screen_item* item = new(std::nothrow) screen_item;
|
||||||
|
|
||||||
for (int32 i = 0; i < fScreenList.CountItems(); i++) {
|
|
||||||
screen_item* item = fScreenList.ItemAt(i);
|
|
||||||
Screen* screen = item->screen;
|
|
||||||
if (!screen->IsDefaultMode())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
BMessage screenSettings;
|
|
||||||
screenSettings.AddInt32("id", screen->ID());
|
|
||||||
|
|
||||||
monitor_info info;
|
|
||||||
if (screen->GetMonitorInfo(info) == B_OK) {
|
|
||||||
screenSettings.AddString("vendor", info.vendor);
|
|
||||||
screenSettings.AddString("name", info.name);
|
|
||||||
screenSettings.AddInt32("product id", info.product_id);
|
|
||||||
screenSettings.AddString("serial", info.serial_number);
|
|
||||||
screenSettings.AddInt32("produced week", info.produced.week);
|
|
||||||
screenSettings.AddInt32("produced year", info.produced.year);
|
|
||||||
}
|
|
||||||
|
|
||||||
screenSettings.AddRect("frame", item->frame);
|
|
||||||
|
|
||||||
display_mode mode;
|
|
||||||
screen->GetMode(&mode);
|
|
||||||
|
|
||||||
screenSettings.AddData("mode", B_RAW_TYPE, &mode,
|
|
||||||
sizeof(display_mode));
|
|
||||||
|
|
||||||
settings.AddMessage("screen", &screenSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
// store the configuration of all monitors currently not attached
|
|
||||||
|
|
||||||
BMessage screenSettings;
|
|
||||||
for (uint32 i = 0; fSettings.FindMessage("screen", i,
|
|
||||||
&screenSettings) == B_OK; i++) {
|
|
||||||
settings.AddMessage("screen", &screenSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
VirtualScreen::AddScreen(Screen* screen)
|
|
||||||
{
|
|
||||||
screen_item* item = new(nothrow) screen_item;
|
|
||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
item->screen = screen;
|
item->screen = screen;
|
||||||
|
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
BMessage settings;
|
display_mode mode;
|
||||||
if (_GetConfiguration(screen, settings) == B_OK) {
|
if (_GetMode(screen, configurations, mode) == B_OK) {
|
||||||
// we found settings for this screen, and try to apply them now
|
// we found settings for this screen, and try to apply them now
|
||||||
const display_mode* mode;
|
status = screen->SetMode(mode);
|
||||||
ssize_t size;
|
|
||||||
if (settings.FindData("mode", B_RAW_TYPE, (const void**)&mode,
|
|
||||||
&size) == B_OK
|
|
||||||
&& size == sizeof(display_mode))
|
|
||||||
status = screen->SetMode(*mode, true);
|
|
||||||
// TODO: named settings will get lost if setting the mode failed!
|
|
||||||
}
|
}
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
status_t status = screen->SetPreferredMode();
|
status_t status = screen->SetPreferredMode();
|
||||||
if (status != B_OK) {
|
if (status != B_OK)
|
||||||
// TODO: more intelligent standard mode (desktop default, ...)
|
|
||||||
status = screen->SetBestMode(1024, 768, B_RGB32, 60.f);
|
status = screen->SetBestMode(1024, 768, B_RGB32, 60.f);
|
||||||
}
|
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
screen->SetBestMode(800, 600, B_RGB32, 60.f, false);
|
screen->SetBestMode(800, 600, B_RGB32, 60.f, false);
|
||||||
}
|
}
|
||||||
@@ -235,8 +174,7 @@ VirtualScreen::UpdateFrame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*! Returns the smallest frame that spans over all screens
|
||||||
Returns the smallest frame that spans over all screens
|
|
||||||
*/
|
*/
|
||||||
BRect
|
BRect
|
||||||
VirtualScreen::Frame() const
|
VirtualScreen::Frame() const
|
||||||
@@ -256,6 +194,20 @@ VirtualScreen::ScreenAt(int32 index) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Screen*
|
||||||
|
VirtualScreen::ScreenByID(int32 id) const
|
||||||
|
{
|
||||||
|
for (int32 i = fScreenList.CountItems(); i-- > 0;) {
|
||||||
|
screen_item* item = fScreenList.ItemAt(i);
|
||||||
|
|
||||||
|
if (item->screen->ID() == id)
|
||||||
|
return item->screen;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BRect
|
BRect
|
||||||
VirtualScreen::ScreenFrameAt(int32 index) const
|
VirtualScreen::ScreenFrameAt(int32 index) const
|
||||||
{
|
{
|
||||||
@@ -275,82 +227,21 @@ VirtualScreen::CountScreens() const
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
VirtualScreen::_GetConfiguration(Screen* screen, BMessage& settings)
|
VirtualScreen::_GetMode(Screen* screen, ScreenConfigurations& configurations,
|
||||||
|
display_mode& mode) const
|
||||||
{
|
{
|
||||||
monitor_info info;
|
monitor_info info;
|
||||||
bool hasInfo = screen->GetMonitorInfo(info) == B_OK;
|
bool hasInfo = screen->GetMonitorInfo(info) == B_OK;
|
||||||
if (!hasInfo) {
|
|
||||||
// only look for a matching ID - this is all we have
|
|
||||||
for (uint32 k = 0; k < 2; k++) {
|
|
||||||
for (uint32 i = 0; fSettings.FindMessage("screen", i,
|
|
||||||
&settings) == B_OK; i++) {
|
|
||||||
int32 id;
|
|
||||||
if (k == 0 && settings.HasString("name")
|
|
||||||
|| settings.FindInt32("id", &id) != B_OK
|
|
||||||
|| screen->ID() != id)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// we found our match, only remove unnamed settings
|
screen_configuration* configuration = configurations.BestFit(screen->ID(),
|
||||||
if (k == 0)
|
hasInfo ? &info : NULL);
|
||||||
fSettings.RemoveData("screen", i);
|
if (configuration == NULL)
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return B_NAME_NOT_FOUND;
|
return B_NAME_NOT_FOUND;
|
||||||
}
|
|
||||||
|
|
||||||
// look for a monitor configuration that matches ours
|
mode = configuration->mode;
|
||||||
|
debug_printf("found configuration! (%d x %d)\n", mode.virtual_width, mode.virtual_height);
|
||||||
|
configuration->is_current = true;
|
||||||
|
|
||||||
bool exactMatch = false;
|
return B_OK;
|
||||||
int32 bestScore = 0;
|
|
||||||
int32 bestIndex = -1;
|
|
||||||
BMessage stored;
|
|
||||||
for (uint32 i = 0; fSettings.FindMessage("screen", i, &stored) == B_OK;
|
|
||||||
i++) {
|
|
||||||
// TODO: should we ignore unnamed settings here completely?
|
|
||||||
int32 score = 0;
|
|
||||||
int32 id;
|
|
||||||
if (stored.FindInt32("id", &id) == B_OK && screen->ID() == id)
|
|
||||||
score++;
|
|
||||||
|
|
||||||
const char* vendor;
|
|
||||||
const char* name;
|
|
||||||
uint32 productID;
|
|
||||||
const char* serial;
|
|
||||||
int32 week, year;
|
|
||||||
if (stored.FindString("vendor", &vendor) == B_OK
|
|
||||||
&& stored.FindString("name", &name) == B_OK
|
|
||||||
&& stored.FindInt32("product id", (int32*)&productID) == B_OK
|
|
||||||
&& stored.FindString("serial", &serial) == B_OK
|
|
||||||
&& stored.FindInt32("produced week", &week) == B_OK
|
|
||||||
&& stored.FindInt32("produced year", &year) == B_OK) {
|
|
||||||
if (!strcasecmp(vendor, info.vendor)
|
|
||||||
&& !strcasecmp(name, info.name)
|
|
||||||
&& productID == info.product_id) {
|
|
||||||
score += 2;
|
|
||||||
if (!strcmp(serial, info.serial_number)) {
|
|
||||||
exactMatch = true;
|
|
||||||
score += 2;
|
|
||||||
}
|
|
||||||
if (info.produced.year == year && info.produced.week == week)
|
|
||||||
score++;
|
|
||||||
} else
|
|
||||||
score -= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (score > bestScore) {
|
|
||||||
settings = stored;
|
|
||||||
bestScore = score;
|
|
||||||
bestIndex = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bestIndex >= 0) {
|
|
||||||
if (exactMatch)
|
|
||||||
fSettings.RemoveData("screen", bestIndex);
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return B_NAME_NOT_FOUND;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005-2007, Haiku.
|
* Copyright 2005-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -9,63 +9,67 @@
|
|||||||
#define VIRTUAL_SCREEN_H
|
#define VIRTUAL_SCREEN_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "ScreenConfigurations.h"
|
||||||
#include "ScreenManager.h"
|
#include "ScreenManager.h"
|
||||||
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
|
||||||
|
|
||||||
class Desktop;
|
class Desktop;
|
||||||
class DrawingEngine;
|
class DrawingEngine;
|
||||||
class HWInterface;
|
class HWInterface;
|
||||||
|
|
||||||
|
|
||||||
class VirtualScreen {
|
class VirtualScreen {
|
||||||
public:
|
public:
|
||||||
VirtualScreen();
|
VirtualScreen();
|
||||||
~VirtualScreen();
|
~VirtualScreen();
|
||||||
|
|
||||||
::DrawingEngine* DrawingEngine() const
|
::DrawingEngine* DrawingEngine() const
|
||||||
{ return fDrawingEngine; }
|
{ return fDrawingEngine; }
|
||||||
// TODO: can we have a multiplexing HWInterface as well?
|
|
||||||
// If not, this would need to be hidden, and only made
|
|
||||||
// available for the Screen class
|
|
||||||
::HWInterface* HWInterface() const
|
|
||||||
{ return fHWInterface; }
|
|
||||||
|
|
||||||
status_t RestoreConfiguration(Desktop& desktop,
|
// TODO: can we have a multiplexing HWInterface as well?
|
||||||
const BMessage* settings,
|
// If not, this would need to be hidden, and only made
|
||||||
uint32* _changedScreens = NULL);
|
// available for the Screen class
|
||||||
status_t StoreConfiguration(BMessage& settings);
|
::HWInterface* HWInterface() const
|
||||||
|
{ return fHWInterface; }
|
||||||
|
|
||||||
status_t AddScreen(Screen* screen);
|
status_t SetConfiguration(Desktop& desktop,
|
||||||
status_t RemoveScreen(Screen* screen);
|
ScreenConfigurations& configurations,
|
||||||
|
uint32* _changedScreens = NULL);
|
||||||
|
|
||||||
void UpdateFrame();
|
status_t AddScreen(Screen* screen,
|
||||||
BRect Frame() const;
|
ScreenConfigurations& configurations);
|
||||||
|
status_t RemoveScreen(Screen* screen);
|
||||||
|
|
||||||
// TODO: we need to play with a real multi-screen configuration to
|
void UpdateFrame();
|
||||||
// figure out the specifics here - possibly in the test environment?
|
BRect Frame() const;
|
||||||
void SetScreenFrame(int32 index, BRect frame);
|
|
||||||
|
|
||||||
Screen* ScreenAt(int32 index) const;
|
// TODO: we need to play with a real multi-screen configuration to
|
||||||
BRect ScreenFrameAt(int32 index) const;
|
// figure out the specifics here
|
||||||
int32 CountScreens() const;
|
void SetScreenFrame(int32 index, BRect frame);
|
||||||
|
|
||||||
private:
|
Screen* ScreenAt(int32 index) const;
|
||||||
status_t _GetConfiguration(Screen* screen,
|
Screen* ScreenByID(int32 id) const;
|
||||||
BMessage& settings);
|
BRect ScreenFrameAt(int32 index) const;
|
||||||
void _Reset();
|
int32 CountScreens() const;
|
||||||
|
|
||||||
struct screen_item {
|
private:
|
||||||
Screen* screen;
|
status_t _GetMode(Screen* screen,
|
||||||
BRect frame;
|
ScreenConfigurations& configurations,
|
||||||
// TODO: do we want to have a different color per screen as well?
|
display_mode& mode) const;
|
||||||
};
|
void _Reset();
|
||||||
|
|
||||||
BMessage fSettings;
|
struct screen_item {
|
||||||
BRect fFrame;
|
Screen* screen;
|
||||||
BObjectList<screen_item> fScreenList;
|
BRect frame;
|
||||||
::DrawingEngine* fDrawingEngine;
|
// TODO: do we want to have a different color per screen as well?
|
||||||
::HWInterface* fHWInterface;
|
};
|
||||||
|
|
||||||
|
BRect fFrame;
|
||||||
|
BObjectList<screen_item> fScreenList;
|
||||||
|
::DrawingEngine* fDrawingEngine;
|
||||||
|
::HWInterface* fHWInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* VIRTUAL_SCREEN_H */
|
#endif /* VIRTUAL_SCREEN_H */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005-2008, Haiku.
|
* Copyright 2005-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -50,16 +50,18 @@ Workspace::Private::RestoreConfiguration(const BMessage& settings)
|
|||||||
rgb_color color;
|
rgb_color color;
|
||||||
if (settings.FindInt32("color", (int32 *)&color) == B_OK)
|
if (settings.FindInt32("color", (int32 *)&color) == B_OK)
|
||||||
fColor = color;
|
fColor = color;
|
||||||
|
|
||||||
|
fStoredScreenConfiguration.Restore(settings);
|
||||||
|
fCurrentScreenConfiguration.Restore(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*! \brief Store the workspace configuration in a message
|
||||||
\brief Store the workspace configuration in a message
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Workspace::Private::StoreConfiguration(BMessage& settings)
|
Workspace::Private::StoreConfiguration(BMessage& settings)
|
||||||
{
|
{
|
||||||
settings.RemoveName("color");
|
fStoredScreenConfiguration.Store(settings);
|
||||||
settings.AddInt32("color", *(int32 *)&fColor);
|
settings.AddInt32("color", *(int32 *)&fColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,18 +82,13 @@ Workspace::Workspace(Desktop& desktop, int32 index)
|
|||||||
fDesktop(desktop),
|
fDesktop(desktop),
|
||||||
fCurrentWorkspace(index == desktop.CurrentWorkspace())
|
fCurrentWorkspace(index == desktop.CurrentWorkspace())
|
||||||
{
|
{
|
||||||
// fDesktop.LockSingleWindow();
|
ASSERT_MULTI_LOCKED(desktop.WindowLocker());
|
||||||
// TODO: in which threads is this being used?
|
|
||||||
// from my investigations, it is used in the
|
|
||||||
// WorkspacesView::Draw(), which would have
|
|
||||||
// to hold the read lock already
|
|
||||||
RewindWindows();
|
RewindWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Workspace::~Workspace()
|
Workspace::~Workspace()
|
||||||
{
|
{
|
||||||
// fDesktop.UnlockSingleWindow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+20
-17
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005-2008, Haiku.
|
* Copyright 2005-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -17,26 +17,29 @@ class Window;
|
|||||||
|
|
||||||
|
|
||||||
class Workspace {
|
class Workspace {
|
||||||
public:
|
public:
|
||||||
Workspace(Desktop& desktop, int32 index);
|
Workspace(Desktop& desktop, int32 index);
|
||||||
~Workspace();
|
~Workspace();
|
||||||
|
|
||||||
const rgb_color& Color() const;
|
const rgb_color& Color() const;
|
||||||
void SetColor(const rgb_color& color, bool makeDefault);
|
void SetColor(const rgb_color& color,
|
||||||
bool IsCurrent() const
|
bool makeDefault);
|
||||||
{ return fCurrentWorkspace; }
|
bool IsCurrent() const
|
||||||
|
{ return fCurrentWorkspace; }
|
||||||
|
|
||||||
status_t GetNextWindow(Window*& _window, BPoint& _leftTop);
|
status_t GetNextWindow(Window*& _window,
|
||||||
status_t GetPreviousWindow(Window*& _window, BPoint& _leftTop);
|
BPoint& _leftTop);
|
||||||
void RewindWindows();
|
status_t GetPreviousWindow(Window*& _window,
|
||||||
|
BPoint& _leftTop);
|
||||||
|
void RewindWindows();
|
||||||
|
|
||||||
class Private;
|
class Private;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Workspace::Private& fWorkspace;
|
Workspace::Private& fWorkspace;
|
||||||
Desktop& fDesktop;
|
Desktop& fDesktop;
|
||||||
Window* fCurrent;
|
Window* fCurrent;
|
||||||
bool fCurrentWorkspace;
|
bool fCurrentWorkspace;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* WORKSPACE_H */
|
#endif /* WORKSPACE_H */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005-2008, Haiku.
|
* Copyright 2005-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#define WORKSPACE_PRIVATE_H
|
#define WORKSPACE_PRIVATE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "ScreenConfigurations.h"
|
||||||
#include "WindowList.h"
|
#include "WindowList.h"
|
||||||
#include "Workspace.h"
|
#include "Workspace.h"
|
||||||
|
|
||||||
@@ -23,40 +24,50 @@ struct display_info {
|
|||||||
display_mode mode;
|
display_mode mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Workspace::Private {
|
class Workspace::Private {
|
||||||
public:
|
public:
|
||||||
Private();
|
Private();
|
||||||
~Private();
|
~Private();
|
||||||
|
|
||||||
int32 Index() const { return fWindows.Index(); }
|
int32 Index() const { return fWindows.Index(); }
|
||||||
|
|
||||||
WindowList& Windows() { return fWindows; }
|
WindowList& Windows() { return fWindows; }
|
||||||
|
|
||||||
// displays
|
// displays
|
||||||
|
|
||||||
void SetDisplaysFromDesktop(Desktop* desktop);
|
void SetDisplaysFromDesktop(Desktop* desktop);
|
||||||
|
|
||||||
int32 CountDisplays() const { return fDisplays.CountItems(); }
|
int32 CountDisplays() const
|
||||||
const display_info* DisplayAt(int32 index) const { return fDisplays.ItemAt(index); }
|
{ return fDisplays.CountItems(); }
|
||||||
|
const display_info* DisplayAt(int32 index) const
|
||||||
|
{ return fDisplays.ItemAt(index); }
|
||||||
|
|
||||||
// configuration
|
// configuration
|
||||||
|
|
||||||
const rgb_color& Color() const { return fColor; }
|
const rgb_color& Color() const { return fColor; }
|
||||||
void SetColor(const rgb_color& color);
|
void SetColor(const rgb_color& color);
|
||||||
|
|
||||||
void RestoreConfiguration(const BMessage& settings);
|
ScreenConfigurations& CurrentScreenConfiguration()
|
||||||
void StoreConfiguration(BMessage& settings);
|
{ return fCurrentScreenConfiguration; }
|
||||||
|
ScreenConfigurations& StoredScreenConfiguration()
|
||||||
|
{ return fStoredScreenConfiguration; }
|
||||||
|
|
||||||
private:
|
void RestoreConfiguration(const BMessage& settings);
|
||||||
void _SetDefaults();
|
void StoreConfiguration(BMessage& settings);
|
||||||
|
|
||||||
WindowList fWindows;
|
private:
|
||||||
Window* fFront;
|
void _SetDefaults();
|
||||||
Window* fFocus;
|
|
||||||
|
|
||||||
BObjectList<display_info> fDisplays;
|
WindowList fWindows;
|
||||||
|
Window* fFront;
|
||||||
|
Window* fFocus;
|
||||||
|
|
||||||
rgb_color fColor;
|
BObjectList<display_info> fDisplays;
|
||||||
|
|
||||||
|
ScreenConfigurations fStoredScreenConfiguration;
|
||||||
|
ScreenConfigurations fCurrentScreenConfiguration;
|
||||||
|
rgb_color fColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* WORKSPACE_PRIVATE_H */
|
#endif /* WORKSPACE_PRIVATE_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user