Implemented AS_GET_MODE_LIST server side.

Fixed broken ViewHWInterface::GetModeList() - it did not correctly write into
the allocated memory. Also extended it to be more flexible, has better timing
values, and more resolutions.
ViewHWInterface::SetMode() will now check if the requested mode is in its
list of supported modes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13226 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-06-22 18:14:13 +00:00
parent 05a710320d
commit 2e86adec11
3 changed files with 79 additions and 72 deletions
+17
View File
@@ -1773,6 +1773,23 @@ ServerApp::DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
break; break;
} }
case AS_GET_MODE_LIST:
{
display_mode* modeList;
uint32 count;
if (gDesktop->GetDisplayDriver()->GetModeList(&modeList, &count) == B_OK) {
fLink.StartMessage(SERVER_TRUE);
fLink.Attach<uint32>(count);
fLink.Attach(modeList, sizeof(display_mode) * count);
delete[] modeList;
} else
fLink.StartMessage(SERVER_FALSE);
fLink.Flush();
break;
}
case AS_SCREEN_GET_COLORMAP: case AS_SCREEN_GET_COLORMAP:
{ {
STRACE(("ServerApp %s: AS_SCREEN_GET_COLORMAP\n", fSignature.String())); STRACE(("ServerApp %s: AS_SCREEN_GET_COLORMAP\n", fSignature.String()));
+3 -11
View File
@@ -499,14 +499,14 @@ printf("Adi: create %s\n", fName);
STRACE(("ServerWindow %s: AS_LAYER_DELETE(self)...\n", fName)); STRACE(("ServerWindow %s: AS_LAYER_DELETE(self)...\n", fName));
Layer *parent; Layer *parent;
parent = fCurrentLayer->fParent; parent = fCurrentLayer->fParent;
// here we remove current layer from list. // here we remove current layer from list.
fCurrentLayer->RemoveSelf(); fCurrentLayer->RemoveSelf();
fCurrentLayer->PruneTree(); fCurrentLayer->PruneTree();
if (parent) if (parent)
myRootLayer->GoInvalidate(parent, BRegion(fCurrentLayer->Frame())); myRootLayer->GoInvalidate(parent, BRegion(fCurrentLayer->Frame()));
#ifdef DEBUG_SERVERWINDOW #ifdef DEBUG_SERVERWINDOW
parent->PrintTree(); parent->PrintTree();
#endif #endif
@@ -553,7 +553,6 @@ printf("Adi: create %s\n", fName);
fMsgSender->Attach<BRect>(fCurrentLayer->fFrame.OffsetToCopy(fCurrentLayer->BoundsOrigin())); fMsgSender->Attach<BRect>(fCurrentLayer->fFrame.OffsetToCopy(fCurrentLayer->BoundsOrigin()));
fMsgSender->Flush(); fMsgSender->Flush();
break; break;
} }
case AS_LAYER_SET_MOUSE_EVENT_MASK: case AS_LAYER_SET_MOUSE_EVENT_MASK:
@@ -567,7 +566,6 @@ printf("Adi: create %s\n", fName);
link.Read<uint32>(&options); link.Read<uint32>(&options);
myRootLayer->SetEventMaskLayer(fCurrentLayer, mask, options); myRootLayer->SetEventMaskLayer(fCurrentLayer, mask, options);
break; break;
} }
case AS_LAYER_MOVETO: case AS_LAYER_MOVETO:
@@ -582,7 +580,6 @@ printf("Adi: create %s\n", fName);
float offsetY = y - fCurrentLayer->fFrame.top; float offsetY = y - fCurrentLayer->fFrame.top;
fCurrentLayer->MoveBy(offsetX, offsetY); fCurrentLayer->MoveBy(offsetX, offsetY);
break; break;
} }
case AS_LAYER_RESIZETO: case AS_LAYER_RESIZETO:
@@ -599,7 +596,6 @@ printf("Adi: create %s\n", fName);
float deltaHeight = newHeight - fCurrentLayer->fFrame.Height(); float deltaHeight = newHeight - fCurrentLayer->fFrame.Height();
fCurrentLayer->ResizeBy(deltaWidth, deltaHeight); fCurrentLayer->ResizeBy(deltaWidth, deltaHeight);
break; break;
} }
case AS_LAYER_GET_COORD: case AS_LAYER_GET_COORD:
@@ -612,7 +608,6 @@ printf("Adi: create %s\n", fName);
// convert frame to bounds // convert frame to bounds
fMsgSender->Attach<BRect>(fCurrentLayer->fFrame.OffsetToCopy(fCurrentLayer->BoundsOrigin())); fMsgSender->Attach<BRect>(fCurrentLayer->fFrame.OffsetToCopy(fCurrentLayer->BoundsOrigin()));
fMsgSender->Flush(); fMsgSender->Flush();
break; break;
} }
case AS_LAYER_SET_ORIGIN: case AS_LAYER_SET_ORIGIN:
@@ -624,7 +619,6 @@ printf("Adi: create %s\n", fName);
link.Read<float>(&y); link.Read<float>(&y);
fCurrentLayer->fLayerData->SetOrigin(BPoint(x, y)); fCurrentLayer->fLayerData->SetOrigin(BPoint(x, y));
break; break;
} }
case AS_LAYER_GET_ORIGIN: case AS_LAYER_GET_ORIGIN:
@@ -633,14 +627,12 @@ printf("Adi: create %s\n", fName);
fMsgSender->StartMessage(SERVER_TRUE); fMsgSender->StartMessage(SERVER_TRUE);
fMsgSender->Attach<BPoint>(fCurrentLayer->fLayerData->Origin()); fMsgSender->Attach<BPoint>(fCurrentLayer->fLayerData->Origin());
fMsgSender->Flush(); fMsgSender->Flush();
break; break;
} }
case AS_LAYER_RESIZE_MODE: case AS_LAYER_RESIZE_MODE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",fName, fCurrentLayer->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",fName, fCurrentLayer->fName->String()));
link.Read<uint32>(&(fCurrentLayer->fResizeMode)); link.Read<uint32>(&(fCurrentLayer->fResizeMode));
break; break;
} }
case AS_LAYER_CURSOR: case AS_LAYER_CURSOR:
+59 -61
View File
@@ -403,19 +403,34 @@ ViewHWInterface::SetMode(const display_mode &mode)
{ {
status_t ret = B_OK; status_t ret = B_OK;
// prevent from doing the unnecessary // prevent from doing the unnecessary
if (fBackBuffer && fFrontBuffer && if (fBackBuffer && fFrontBuffer
fDisplayMode.virtual_width == mode.virtual_width && && fDisplayMode.virtual_width == mode.virtual_width
fDisplayMode.virtual_height == mode.virtual_height && && fDisplayMode.virtual_height == mode.virtual_height
fDisplayMode.space == mode.space) { && fDisplayMode.space == mode.space)
return ret; return ret;
}
// TODO: check if the mode is valid even (ie complies to the modes we said we would support)
// or else ret = B_BAD_VALUE
// take on settings // check if we support the mode
fDisplayMode.virtual_width = mode.virtual_width;
fDisplayMode.virtual_height = mode.virtual_height; display_mode *modes;
fDisplayMode.space = mode.space; uint32 modeCount, i;
if (GetModeList(&modes, &modeCount) != B_OK)
return B_NO_MEMORY;
for (i = 0; i < modeCount; i++) {
// we only care for the bare minimum
if (modes[i].virtual_width == mode.virtual_width
&& modes[i].virtual_height == mode.virtual_height
&& modes[i].space == mode.space) {
// take over settings
fDisplayMode = modes[i];
break;
}
}
delete[] modes;
if (i == modeCount)
return B_BAD_VALUE;
BRect frame(0.0, 0.0, BRect frame(0.0, 0.0,
fDisplayMode.virtual_width - 1, fDisplayMode.virtual_width - 1,
@@ -527,66 +542,49 @@ ViewHWInterface::GetDeviceInfo(accelerant_device_info *info)
// GetModeList // GetModeList
status_t status_t
ViewHWInterface::GetModeList(display_mode **modes, uint32 *count) ViewHWInterface::GetModeList(display_mode **_modes, uint32 *_count)
{ {
// DEPRECATED: // DEPRECATED:
// NOTE: Originally, I was going to figure out good timing values to be // NOTE: Originally, I was going to figure out good timing values to be
// returned in each of the modes supported, but I won't bother, being this // returned in each of the modes supported, but I won't bother, being this
// won't be used much longer anyway. // won't be used much longer anyway.
*modes=new display_mode[13];
*count=13;
modes[0]->virtual_width=640; const struct resolution { int32 width, height; } resolutions[] = {
modes[0]->virtual_width=480; {640, 480}, {800, 600}, {1024, 768}, {1152, 864}, {1280, 960},
modes[0]->space=B_CMAP8; {1280, 1024}, {1400, 1050}, {1600, 1200}
modes[1]->virtual_width=640; };
modes[1]->virtual_width=480; uint32 resolutionCount = sizeof(resolutions) / sizeof(resolutions[0]);
modes[1]->space=B_RGB16; const uint32 colors[] = {B_CMAP8, B_RGB15, B_RGB16, B_RGB32};
modes[2]->virtual_width=640; uint32 count = resolutionCount * 4;
modes[2]->virtual_width=480;
modes[2]->space=B_RGB32;
modes[3]->virtual_width=640;
modes[3]->virtual_width=480;
modes[3]->space=B_RGBA32;
modes[4]->virtual_width=800; display_mode *modes = new display_mode[count];
modes[4]->virtual_width=600; if (modes == NULL)
modes[4]->space=B_CMAP8; return B_NO_MEMORY;
modes[5]->virtual_width=800;
modes[5]->virtual_width=600;
modes[5]->space=B_RGB16;
modes[6]->virtual_width=800;
modes[6]->virtual_width=600;
modes[6]->space=B_RGB32;
modes[7]->virtual_width=1024; *_modes = modes;
modes[7]->virtual_width=768; *_count = count;
modes[7]->space=B_CMAP8;;
modes[8]->virtual_width=1024;
modes[8]->virtual_width=768;
modes[8]->space=B_RGB16;
modes[9]->virtual_width=1024;
modes[9]->virtual_width=768;
modes[9]->space=B_RGB32;
modes[10]->virtual_width=1152; int32 index = 0;
modes[10]->virtual_width=864; for (uint32 i = 0; i < resolutionCount; i++) {
modes[10]->space=B_CMAP8; for (uint32 c = 0; c < 4; c++) {
modes[11]->virtual_width=1152; modes[index].virtual_width = resolutions[i].width;
modes[11]->virtual_width=864; modes[index].virtual_height = resolutions[i].height;
modes[11]->space=B_RGB16; modes[index].space = colors[c];
modes[12]->virtual_width=1152;
modes[12]->virtual_width=864; modes[index].h_display_start = 0;
modes[12]->space=B_RGB32; modes[index].v_display_start = 0;
modes[index].timing.h_display = resolutions[i].width;
for(int32 i=0; i<13; i++) modes[index].timing.v_display = resolutions[i].height;
{ modes[index].timing.h_total = 22000;
modes[i]->h_display_start=0; modes[index].timing.v_total = 22000;
modes[i]->v_display_start=0; modes[index].timing.pixel_clock = ((uint32)modes[index].timing.h_total
modes[i]->flags=B_PARALLEL_ACCESS; * modes[index].timing.v_total * 60) / 1000;
modes[index].flags = B_PARALLEL_ACCESS;
index++;
}
} }
return B_OK; return B_OK;
} }