* 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,11 +293,9 @@ ServerWindow::Show()
|
|||||||
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
||||||
STRACE(("ServerWindow %s: Show\n", Title()));
|
STRACE(("ServerWindow %s: Show\n", Title()));
|
||||||
|
|
||||||
if (fQuitting || !fWindowLayer->IsHidden())
|
if (fQuitting || !fWindowLayer->IsHidden() || fWindowLayer->IsOffscreenWindow())
|
||||||
return;
|
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)
|
if (fDirectWindowData != NULL)
|
||||||
@ -312,14 +310,12 @@ ServerWindow::Hide()
|
|||||||
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
// NOTE: if you do something else, other than sending a port message, PLEASE lock
|
||||||
STRACE(("ServerWindow %s: Hide\n", Title()));
|
STRACE(("ServerWindow %s: Hide\n", Title()));
|
||||||
|
|
||||||
if (fWindowLayer->IsHidden())
|
if (fWindowLayer->IsHidden() || fWindowLayer->IsOffscreenWindow())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fDirectWindowData != NULL)
|
if (fDirectWindowData != NULL)
|
||||||
HandleDirectConnection(B_DIRECT_STOP);
|
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()));
|
STRACE(("ServerWindow %s: Message AS_SET_LOOK\n", Title()));
|
||||||
|
|
||||||
|
status_t status = B_ERROR;
|
||||||
int32 look;
|
int32 look;
|
||||||
if (link.Read<int32>(&look) != B_OK) {
|
if (link.Read<int32>(&look) == B_OK) {
|
||||||
fLink.StartMessage(B_ERROR);
|
// test if look is valid
|
||||||
fLink.Flush();
|
status = WindowLayer::IsValidLook((window_look)look)
|
||||||
break;
|
? B_OK : B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: filter out invalid looks
|
if (status == B_OK && !fWindowLayer->IsOffscreenWindow())
|
||||||
|
|
||||||
if (!fWindowLayer->IsOffscreenWindow())
|
|
||||||
fDesktop->SetWindowLook(fWindowLayer, (window_look)look);
|
fDesktop->SetWindowLook(fWindowLayer, (window_look)look);
|
||||||
|
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(status);
|
||||||
fLink.Flush();
|
fLink.Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1346,18 +1341,9 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
int32 feel;
|
int32 feel;
|
||||||
if (link.Read<int32>(&feel) == B_OK) {
|
if (link.Read<int32>(&feel) == B_OK) {
|
||||||
// test if "feel" is valid
|
// test if feel is valid
|
||||||
status = (feel == B_NORMAL_WINDOW_FEEL
|
status = WindowLayer::IsValidFeel((window_feel)feel)
|
||||||
|| feel == B_MODAL_SUBSET_WINDOW_FEEL
|
? B_OK : B_BAD_VALUE;
|
||||||
|| 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == B_OK && !fWindowLayer->IsOffscreenWindow())
|
if (status == B_OK && !fWindowLayer->IsOffscreenWindow())
|
||||||
@ -1365,25 +1351,26 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
|
|
||||||
fLink.StartMessage(status);
|
fLink.StartMessage(status);
|
||||||
fLink.Flush();
|
fLink.Flush();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case AS_SET_FLAGS:
|
case AS_SET_FLAGS:
|
||||||
{
|
{
|
||||||
STRACE(("ServerWindow %s: Message AS_SET_LOOK\n", Title()));
|
STRACE(("ServerWindow %s: Message AS_SET_LOOK\n", Title()));
|
||||||
|
|
||||||
|
status_t status = B_ERROR;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
if (link.Read<uint32>(&flags) != B_OK) {
|
if (link.Read<uint32>(&flags) == B_OK) {
|
||||||
fLink.StartMessage(B_ERROR);
|
// test if flags are valid
|
||||||
fLink.Flush();
|
status = (flags & ~WindowLayer::ValidWindowFlags()) != 0
|
||||||
break;
|
? B_OK : B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: filter out invalid flags
|
if (status == B_OK && !fWindowLayer->IsOffscreenWindow())
|
||||||
|
|
||||||
if (!fWindowLayer->IsOffscreenWindow())
|
|
||||||
fDesktop->SetWindowFlags(fWindowLayer, flags);
|
fDesktop->SetWindowFlags(fWindowLayer, flags);
|
||||||
|
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(status);
|
||||||
fLink.Flush();
|
fLink.Flush();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
case AS_SET_ALIGNMENT:
|
case AS_SET_ALIGNMENT:
|
||||||
|
@ -89,6 +89,13 @@ WindowLayer::WindowLayer(const BRect &frame,
|
|||||||
fMinHeight(1.0),
|
fMinHeight(1.0),
|
||||||
fMaxHeight(32768.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
|
// unlike BViews, windows start off as hidden
|
||||||
fHidden = true;
|
fHidden = true;
|
||||||
fWindow = window;
|
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
|
inline Layer* TopLayer() const
|
||||||
{ return fTopLayer; }
|
{ return fTopLayer; }
|
||||||
|
|
||||||
|
static bool IsValidLook(window_look look);
|
||||||
|
static bool IsValidFeel(window_feel feel);
|
||||||
|
static uint32 ValidWindowFlags();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void _AllRedraw(const BRegion& invalid);
|
virtual void _AllRedraw(const BRegion& invalid);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user