* _Show() and _Hide() must now be called with having all windows locked

(it would do that internally anyway).
* AS_MINIMIZE no longer calls _Show() when being unminimized, but
  Desktop::ActivateWindow(), as this will also bring the window on the screen
  if it's on another workspace (according to its flags).
* Whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28168 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-10-16 12:15:02 +00:00
parent 9f1cce99b9
commit 96c6ee9507
+28 -27
View File
@@ -348,7 +348,9 @@ ServerWindow::ReplaceDecorator()
} }
//! Shows the window's Window /*! Shows the window's Window. You need to have all windows locked when
calling this function.
*/
void void
ServerWindow::_Show() ServerWindow::_Show()
{ {
@@ -358,18 +360,16 @@ ServerWindow::_Show()
if (fQuitting || !fWindow->IsHidden() || fWindow->IsOffscreenWindow()) if (fQuitting || !fWindow->IsHidden() || fWindow->IsOffscreenWindow())
return; return;
// TODO: Maybe we need to dispatch a message to the desktop to show/hide us
// instead of doing it from this thread.
fDesktop->UnlockSingleWindow();
fDesktop->ShowWindow(fWindow); fDesktop->ShowWindow(fWindow);
fDesktop->LockSingleWindow();
if (fDirectWindowData != NULL) if (fDirectWindowData != NULL)
HandleDirectConnection(B_DIRECT_START | B_BUFFER_RESET); HandleDirectConnection(B_DIRECT_START | B_BUFFER_RESET);
} }
//! Hides the window's Window /*! Hides the window's Window. You need to have all windows locked when
calling this function.
*/
void void
ServerWindow::_Hide() ServerWindow::_Hide()
{ {
@@ -382,9 +382,7 @@ ServerWindow::_Hide()
if (fDirectWindowData != NULL) if (fDirectWindowData != NULL)
HandleDirectConnection(B_DIRECT_STOP); HandleDirectConnection(B_DIRECT_STOP);
fDesktop->UnlockSingleWindow();
fDesktop->HideWindow(fWindow); fDesktop->HideWindow(fWindow);
fDesktop->LockSingleWindow();
} }
@@ -648,12 +646,14 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
break; break;
} }
if (minimize && !fWindow->IsHidden()) if (minimize && !fWindow->IsHidden()) {
_Hide(); _Hide();
else if (!minimize && fWindow->IsHidden()) fWindow->SetMinimized(minimize);
_Show(); } else if (!minimize && fWindow->IsHidden()) {
fDesktop->ActivateWindow(fWindow);
// this will unminimize the window for us
}
fWindow->SetMinimized(minimize);
} }
break; break;
} }
@@ -665,12 +665,10 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<bool>(&activate); link.Read<bool>(&activate);
//fDesktop->UnlockSingleWindow();
if (activate) if (activate)
fDesktop->ActivateWindow(fWindow); fDesktop->ActivateWindow(fWindow);
else else
fDesktop->SendWindowBehind(fWindow, NULL); fDesktop->SendWindowBehind(fWindow, NULL);
//fDesktop->LockSingleWindow();
break; break;
} }
case AS_SEND_BEHIND: case AS_SEND_BEHIND:
@@ -2221,7 +2219,7 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
case AS_FILL_BEZIER_GRADIENT: case AS_FILL_BEZIER_GRADIENT:
{ {
GTRACE(("ServerWindow %s: Message AS_FILL_BEZIER_GRADIENT\n", Title())); GTRACE(("ServerWindow %s: Message AS_FILL_BEZIER_GRADIENT\n", Title()));
BPoint pts[4]; BPoint pts[4];
for (int32 i = 0; i < 4; i++) { for (int32 i = 0; i < 4; i++) {
link.Read<BPoint>(&(pts[i])); link.Read<BPoint>(&(pts[i]));
@@ -2249,7 +2247,7 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
case AS_FILL_ELLIPSE_GRADIENT: case AS_FILL_ELLIPSE_GRADIENT:
{ {
GTRACE(("ServerWindow %s: Message AS_FILL_ELLIPSE_GRADIENT\n", Title())); GTRACE(("ServerWindow %s: Message AS_FILL_ELLIPSE_GRADIENT\n", Title()));
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
BGradient* gradient; BGradient* gradient;
@@ -2278,7 +2276,7 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
case AS_FILL_ROUNDRECT_GRADIENT: case AS_FILL_ROUNDRECT_GRADIENT:
{ {
GTRACE(("ServerWindow %s: Message AS_FILL_ROUNDRECT_GRADIENT\n", Title())); GTRACE(("ServerWindow %s: Message AS_FILL_ROUNDRECT_GRADIENT\n", Title()));
BRect rect; BRect rect;
float xrad,yrad; float xrad,yrad;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
@@ -2314,7 +2312,7 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
case AS_FILL_TRIANGLE_GRADIENT: case AS_FILL_TRIANGLE_GRADIENT:
{ {
DTRACE(("ServerWindow %s: Message AS_FILL_TRIANGLE_GRADIENT\n", Title())); DTRACE(("ServerWindow %s: Message AS_FILL_TRIANGLE_GRADIENT\n", Title()));
BPoint pts[3]; BPoint pts[3];
BRect rect; BRect rect;
for (int32 i = 0; i < 3; i++) { for (int32 i = 0; i < 3; i++) {
@@ -2359,13 +2357,13 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
case AS_FILL_POLYGON_GRADIENT: case AS_FILL_POLYGON_GRADIENT:
{ {
DTRACE(("ServerWindow %s: Message AS_FILL_POLYGON_GRADIENT\n", Title())); DTRACE(("ServerWindow %s: Message AS_FILL_POLYGON_GRADIENT\n", Title()));
BRect polyFrame; BRect polyFrame;
bool isClosed = true; bool isClosed = true;
int32 pointCount; int32 pointCount;
link.Read<BRect>(&polyFrame); link.Read<BRect>(&polyFrame);
link.Read<int32>(&pointCount); link.Read<int32>(&pointCount);
BPoint* pointList = new(nothrow) BPoint[pointCount]; BPoint* pointList = new(nothrow) BPoint[pointCount];
if (link.Read(pointList, pointCount * sizeof(BPoint)) >= B_OK) { if (link.Read(pointList, pointCount * sizeof(BPoint)) >= B_OK) {
BGradient* gradient; BGradient* gradient;
@@ -2375,7 +2373,7 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
fCurrentView->ConvertToScreenForDrawing(&pointList[i]); fCurrentView->ConvertToScreenForDrawing(&pointList[i]);
fCurrentView->ConvertToScreenForDrawing(&polyFrame); fCurrentView->ConvertToScreenForDrawing(&polyFrame);
fCurrentView->ConvertToScreenForDrawing(gradient); fCurrentView->ConvertToScreenForDrawing(gradient);
drawingEngine->FillPolygonGradient(pointList, pointCount, drawingEngine->FillPolygonGradient(pointList, pointCount,
polyFrame, *gradient, isClosed && pointCount > 2); polyFrame, *gradient, isClosed && pointCount > 2);
} }
@@ -2419,20 +2417,20 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
case AS_FILL_SHAPE_GRADIENT: case AS_FILL_SHAPE_GRADIENT:
{ {
DTRACE(("ServerWindow %s: Message AS_FILL_SHAPE_GRADIENT\n", Title())); DTRACE(("ServerWindow %s: Message AS_FILL_SHAPE_GRADIENT\n", Title()));
BRect shapeFrame; BRect shapeFrame;
int32 opCount; int32 opCount;
int32 ptCount; int32 ptCount;
link.Read<BRect>(&shapeFrame); link.Read<BRect>(&shapeFrame);
link.Read<int32>(&opCount); link.Read<int32>(&opCount);
link.Read<int32>(&ptCount); link.Read<int32>(&ptCount);
uint32* opList = new(nothrow) uint32[opCount]; uint32* opList = new(nothrow) uint32[opCount];
BPoint* ptList = new(nothrow) BPoint[ptCount]; BPoint* ptList = new(nothrow) BPoint[ptCount];
if (link.Read(opList, opCount * sizeof(uint32)) >= B_OK && if (link.Read(opList, opCount * sizeof(uint32)) >= B_OK &&
link.Read(ptList, ptCount * sizeof(BPoint)) >= B_OK) { link.Read(ptList, ptCount * sizeof(BPoint)) >= B_OK) {
// this might seem a bit weird, but under R5, the shapes // this might seem a bit weird, but under R5, the shapes
// are always offset by the current pen location // are always offset by the current pen location
BPoint penLocation = fCurrentView->CurrentState()->PenLocation(); BPoint penLocation = fCurrentView->CurrentState()->PenLocation();
@@ -2447,7 +2445,7 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
drawingEngine->FillShapeGradient(shapeFrame, opCount, opList, drawingEngine->FillShapeGradient(shapeFrame, opCount, opList,
ptCount, ptList, *gradient); ptCount, ptList, *gradient);
} }
delete[] opList; delete[] opList;
delete[] ptList; delete[] ptList;
break; break;
@@ -2468,7 +2466,7 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code, BPrivate::LinkReceiver &li
case AS_FILL_REGION_GRADIENT: case AS_FILL_REGION_GRADIENT:
{ {
DTRACE(("ServerWindow %s: Message AS_FILL_REGION_GRADIENT\n", Title())); DTRACE(("ServerWindow %s: Message AS_FILL_REGION_GRADIENT\n", Title()));
BRegion region; BRegion region;
if (link.ReadRegion(&region) < B_OK) if (link.ReadRegion(&region) < B_OK)
break; break;
@@ -3431,7 +3429,10 @@ bool
ServerWindow::_MessageNeedsAllWindowsLocked(uint32 code) const ServerWindow::_MessageNeedsAllWindowsLocked(uint32 code) const
{ {
switch (code) { switch (code) {
case AS_SHOW_WINDOW:
case AS_HIDE_WINDOW:
case AS_ACTIVATE_WINDOW: case AS_ACTIVATE_WINDOW:
case AS_MINIMIZE_WINDOW:
case AS_SET_WINDOW_TITLE: case AS_SET_WINDOW_TITLE:
case AS_ADD_TO_SUBSET: case AS_ADD_TO_SUBSET:
case AS_REMOVE_FROM_SUBSET: case AS_REMOVE_FROM_SUBSET: