* the check for a valid feel was wrong, reported by Michael Lotz.
* also followed Michael's suggestion (more or less) and moved the look/feel/flags checks into separate methods. * on construction, invalid look/feel/flags values are now corrected. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15269 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6b86db1c42
commit
aecd5eefaf
@ -293,12 +293,10 @@ ServerWindow::Show()
|
||||
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
||||
STRACE(("ServerWindow %s: Show\n", Title()));
|
||||
|
||||
if (fQuitting || !fWindowLayer->IsHidden())
|
||||
if (fQuitting || !fWindowLayer->IsHidden() || fWindowLayer->IsOffscreenWindow())
|
||||
return;
|
||||
|
||||
// TODO: that check is just there for offscreen-windows - this should be made better
|
||||
if (fWindowLayer->GetRootLayer() != NULL)
|
||||
fDesktop->ShowWindow(fWindowLayer);
|
||||
fDesktop->ShowWindow(fWindowLayer);
|
||||
|
||||
if (fDirectWindowData != NULL)
|
||||
HandleDirectConnection(B_DIRECT_START | B_BUFFER_RESET);
|
||||
@ -312,15 +310,13 @@ ServerWindow::Hide()
|
||||
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
||||
STRACE(("ServerWindow %s: Hide\n", Title()));
|
||||
|
||||
if (fWindowLayer->IsHidden())
|
||||
if (fWindowLayer->IsHidden() || fWindowLayer->IsOffscreenWindow())
|
||||
return;
|
||||
|
||||
if (fDirectWindowData != NULL)
|
||||
HandleDirectConnection(B_DIRECT_STOP);
|
||||
|
||||
// TODO: that check is just there for offscreen-windows - this should be made better
|
||||
if (fWindowLayer->GetRootLayer() != NULL)
|
||||
fDesktop->HideWindow(fWindowLayer);
|
||||
fDesktop->HideWindow(fWindowLayer);
|
||||
}
|
||||
|
||||
|
||||
@ -1323,19 +1319,18 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_SET_LOOK\n", Title()));
|
||||
|
||||
status_t status = B_ERROR;
|
||||
int32 look;
|
||||
if (link.Read<int32>(&look) != B_OK) {
|
||||
fLink.StartMessage(B_ERROR);
|
||||
fLink.Flush();
|
||||
break;
|
||||
if (link.Read<int32>(&look) == B_OK) {
|
||||
// test if look is valid
|
||||
status = WindowLayer::IsValidLook((window_look)look)
|
||||
? B_OK : B_BAD_VALUE;
|
||||
}
|
||||
|
||||
// TODO: filter out invalid looks
|
||||
|
||||
if (!fWindowLayer->IsOffscreenWindow())
|
||||
if (status == B_OK && !fWindowLayer->IsOffscreenWindow())
|
||||
fDesktop->SetWindowLook(fWindowLayer, (window_look)look);
|
||||
|
||||
fLink.StartMessage(B_OK);
|
||||
fLink.StartMessage(status);
|
||||
fLink.Flush();
|
||||
break;
|
||||
}
|
||||
@ -1346,18 +1341,9 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
status_t status = B_ERROR;
|
||||
int32 feel;
|
||||
if (link.Read<int32>(&feel) == B_OK) {
|
||||
// test if "feel" is valid
|
||||
status = (feel == B_NORMAL_WINDOW_FEEL
|
||||
|| feel == B_MODAL_SUBSET_WINDOW_FEEL
|
||||
|| feel == B_MODAL_APP_WINDOW_FEEL
|
||||
|| feel == B_MODAL_ALL_WINDOW_FEEL
|
||||
|| feel == B_FLOATING_SUBSET_WINDOW_FEEL
|
||||
|| feel == B_FLOATING_APP_WINDOW_FEEL
|
||||
|| feel == B_FLOATING_ALL_WINDOW_FEEL
|
||||
|| feel == kDesktopWindowFeel
|
||||
|| feel == kMenuWindowFeel
|
||||
|| feel == kWindowScreenFeel)
|
||||
? B_BAD_VALUE : B_OK;
|
||||
// test if feel is valid
|
||||
status = WindowLayer::IsValidFeel((window_feel)feel)
|
||||
? B_OK : B_BAD_VALUE;
|
||||
}
|
||||
|
||||
if (status == B_OK && !fWindowLayer->IsOffscreenWindow())
|
||||
@ -1365,25 +1351,26 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
|
||||
fLink.StartMessage(status);
|
||||
fLink.Flush();
|
||||
break;
|
||||
}
|
||||
case AS_SET_FLAGS:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_SET_LOOK\n", Title()));
|
||||
|
||||
status_t status = B_ERROR;
|
||||
uint32 flags;
|
||||
if (link.Read<uint32>(&flags) != B_OK) {
|
||||
fLink.StartMessage(B_ERROR);
|
||||
fLink.Flush();
|
||||
break;
|
||||
if (link.Read<uint32>(&flags) == B_OK) {
|
||||
// test if flags are valid
|
||||
status = (flags & ~WindowLayer::ValidWindowFlags()) != 0
|
||||
? B_OK : B_BAD_VALUE;
|
||||
}
|
||||
|
||||
// TODO: filter out invalid flags
|
||||
|
||||
if (!fWindowLayer->IsOffscreenWindow())
|
||||
if (status == B_OK && !fWindowLayer->IsOffscreenWindow())
|
||||
fDesktop->SetWindowFlags(fWindowLayer, flags);
|
||||
|
||||
fLink.StartMessage(B_OK);
|
||||
fLink.StartMessage(status);
|
||||
fLink.Flush();
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
case AS_SET_ALIGNMENT:
|
||||
|
@ -89,6 +89,13 @@ WindowLayer::WindowLayer(const BRect &frame,
|
||||
fMinHeight(1.0),
|
||||
fMaxHeight(32768.0)
|
||||
{
|
||||
// make sure our arguments are valid
|
||||
if (!IsValidLook(fLook))
|
||||
fLook = B_TITLED_WINDOW_LOOK;
|
||||
if (!IsValidFeel(fFeel))
|
||||
fFeel = B_NORMAL_WINDOW_FEEL;
|
||||
fFlags &= ValidWindowFlags();
|
||||
|
||||
// unlike BViews, windows start off as hidden
|
||||
fHidden = true;
|
||||
fWindow = window;
|
||||
@ -853,3 +860,53 @@ WindowLayer::SetTopLayer(Layer* layer)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*static*/
|
||||
bool
|
||||
WindowLayer::IsValidLook(window_look look)
|
||||
{
|
||||
return look == B_TITLED_WINDOW_LOOK
|
||||
|| look == B_DOCUMENT_WINDOW_LOOK
|
||||
|| look == B_MODAL_WINDOW_LOOK
|
||||
|| look == B_FLOATING_WINDOW_LOOK
|
||||
|| look == B_BORDERED_WINDOW_LOOK
|
||||
|| look == B_NO_BORDER_WINDOW_LOOK
|
||||
|| look == kDesktopWindowLook
|
||||
|| look == kLeftTitledWindowLook;
|
||||
}
|
||||
|
||||
|
||||
/*static*/
|
||||
bool
|
||||
WindowLayer::IsValidFeel(window_feel feel)
|
||||
{
|
||||
return feel == B_NORMAL_WINDOW_FEEL
|
||||
|| feel == B_MODAL_SUBSET_WINDOW_FEEL
|
||||
|| feel == B_MODAL_APP_WINDOW_FEEL
|
||||
|| feel == B_MODAL_ALL_WINDOW_FEEL
|
||||
|| feel == B_FLOATING_SUBSET_WINDOW_FEEL
|
||||
|| feel == B_FLOATING_APP_WINDOW_FEEL
|
||||
|| feel == B_FLOATING_ALL_WINDOW_FEEL
|
||||
|| feel == kDesktopWindowFeel
|
||||
|| feel == kMenuWindowFeel
|
||||
|| feel == kWindowScreenFeel;
|
||||
}
|
||||
|
||||
|
||||
/*static*/
|
||||
uint32
|
||||
WindowLayer::ValidWindowFlags()
|
||||
{
|
||||
return B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE
|
||||
| B_NOT_MINIMIZABLE | B_NOT_RESIZABLE
|
||||
| B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE
|
||||
| B_AVOID_FRONT | B_AVOID_FOCUS
|
||||
| B_WILL_ACCEPT_FIRST_CLICK | B_OUTLINE_RESIZE
|
||||
| B_NO_WORKSPACE_ACTIVATION
|
||||
| B_NOT_ANCHORED_ON_ACTIVATE
|
||||
| B_ASYNCHRONOUS_CONTROLS
|
||||
| B_QUIT_ON_WINDOW_CLOSE
|
||||
| kWorkspacesWindowFlag
|
||||
| kWindowScreenFlag;
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,10 @@ class WindowLayer : public Layer {
|
||||
inline Layer* TopLayer() const
|
||||
{ return fTopLayer; }
|
||||
|
||||
static bool IsValidLook(window_look look);
|
||||
static bool IsValidFeel(window_feel feel);
|
||||
static uint32 ValidWindowFlags();
|
||||
|
||||
protected:
|
||||
virtual void _AllRedraw(const BRegion& invalid);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user