diff --git a/headers/os/interface/Window.h b/headers/os/interface/Window.h index 3be13e99a4..b53a3e819e 100644 --- a/headers/os/interface/Window.h +++ b/headers/os/interface/Window.h @@ -123,7 +123,7 @@ public: void Zoom(); void SetZoomLimits(float maxWidth, float maxHeight); virtual void ScreenChanged(BRect screenSize, - color_space format); + color_space depth); void SetPulseRate(bigtime_t rate); bigtime_t PulseRate() const; @@ -219,7 +219,7 @@ public: virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier, - int32 form, const char* property); + int32 what, const char* property); virtual status_t GetSupportedSuites(BMessage* data); status_t AddToSubset(BWindow* window); diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 06d3c20700..b60935399d 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -440,7 +440,7 @@ BWindow::~BWindow() BArchivable* BWindow::Instantiate(BMessage* data) { - if (!validate_instantiation(data , "BWindow")) + if (!validate_instantiation(data, "BWindow")) return NULL; return new(std::nothrow) BWindow(data); @@ -511,7 +511,7 @@ BWindow::Quit() { if (!IsLocked()) { const char* name = Name(); - if (!name) + if (name == NULL) name = "no-name"; printf("ERROR - you must Lock a looper before calling Quit(), " @@ -718,13 +718,13 @@ BWindow::IsFront() const void -BWindow::MessageReceived(BMessage* msg) +BWindow::MessageReceived(BMessage* message) { - if (!msg->HasSpecifiers()) { - if (msg->what == B_KEY_DOWN) + if (!message->HasSpecifiers()) { + if (message->what == B_KEY_DOWN) _KeyboardNavigation(); - if (msg->what == (int32)kMsgAppServerRestarted) { + if (message->what == (int32)kMsgAppServerRestarted) { fLink->SetSenderPort(BApplication::Private::ServerLink()->SenderPort()); BPrivate::AppServerLink lockLink; @@ -773,7 +773,7 @@ BWindow::MessageReceived(BMessage* msg) _SendShowOrHideMessage(); } - return BLooper::MessageReceived(msg); + return BLooper::MessageReceived(message); } BMessage replyMsg(B_REPLY); @@ -784,54 +784,54 @@ BWindow::MessageReceived(BMessage* msg) const char* prop; int32 index; - if (msg->GetCurrentSpecifier(&index, &specifier, &what, &prop) != B_OK) - return BLooper::MessageReceived(msg); + if (message->GetCurrentSpecifier(&index, &specifier, &what, &prop) != B_OK) + return BLooper::MessageReceived(message); BPropertyInfo propertyInfo(sWindowPropInfo); - switch (propertyInfo.FindMatch(msg, index, &specifier, what, prop)) { + switch (propertyInfo.FindMatch(message, index, &specifier, what, prop)) { case 0: - if (msg->what == B_GET_PROPERTY) { + if (message->what == B_GET_PROPERTY) { replyMsg.AddBool("result", IsActive()); handled = true; - } else if (msg->what == B_SET_PROPERTY) { + } else if (message->what == B_SET_PROPERTY) { bool newActive; - if (msg->FindBool("data", &newActive) == B_OK) { + if (message->FindBool("data", &newActive) == B_OK) { Activate(newActive); handled = true; } } break; case 1: - if (msg->what == B_GET_PROPERTY) { + if (message->what == B_GET_PROPERTY) { replyMsg.AddInt32("result", (uint32)Feel()); handled = true; } else { uint32 newFeel; - if (msg->FindInt32("data", (int32*)&newFeel) == B_OK) { + if (message->FindInt32("data", (int32*)&newFeel) == B_OK) { SetFeel((window_feel)newFeel); handled = true; } } break; case 2: - if (msg->what == B_GET_PROPERTY) { + if (message->what == B_GET_PROPERTY) { replyMsg.AddInt32("result", Flags()); handled = true; } else { uint32 newFlags; - if (msg->FindInt32("data", (int32*)&newFlags) == B_OK) { + if (message->FindInt32("data", (int32*)&newFlags) == B_OK) { SetFlags(newFlags); handled = true; } } break; case 3: - if (msg->what == B_GET_PROPERTY) { + if (message->what == B_GET_PROPERTY) { replyMsg.AddRect("result", Frame()); handled = true; } else { BRect newFrame; - if (msg->FindRect("data", &newFrame) == B_OK) { + if (message->FindRect("data", &newFrame) == B_OK) { MoveTo(newFrame.LeftTop()); ResizeTo(newFrame.Width(), newFrame.Height()); handled = true; @@ -839,12 +839,12 @@ BWindow::MessageReceived(BMessage* msg) } break; case 4: - if (msg->what == B_GET_PROPERTY) { + if (message->what == B_GET_PROPERTY) { replyMsg.AddBool("result", IsHidden()); handled = true; } else { bool hide; - if (msg->FindBool("data", &hide) == B_OK) { + if (message->FindBool("data", &hide) == B_OK) { if (hide) { if (!IsHidden()) Hide(); @@ -855,55 +855,55 @@ BWindow::MessageReceived(BMessage* msg) } break; case 5: - if (msg->what == B_GET_PROPERTY) { + if (message->what == B_GET_PROPERTY) { replyMsg.AddInt32("result", (uint32)Look()); handled = true; } else { uint32 newLook; - if (msg->FindInt32("data", (int32*)&newLook) == B_OK) { + if (message->FindInt32("data", (int32*)&newLook) == B_OK) { SetLook((window_look)newLook); handled = true; } } break; case 6: - if (msg->what == B_GET_PROPERTY) { + if (message->what == B_GET_PROPERTY) { replyMsg.AddString("result", Title()); handled = true; } else { const char* newTitle = NULL; - if (msg->FindString("data", &newTitle) == B_OK) { + if (message->FindString("data", &newTitle) == B_OK) { SetTitle(newTitle); handled = true; } } break; case 7: - if (msg->what == B_GET_PROPERTY) { + if (message->what == B_GET_PROPERTY) { replyMsg.AddInt32( "result", Workspaces()); handled = true; } else { uint32 newWorkspaces; - if (msg->FindInt32("data", (int32*)&newWorkspaces) == B_OK) { + if (message->FindInt32("data", (int32*)&newWorkspaces) == B_OK) { SetWorkspaces(newWorkspaces); handled = true; } } break; case 11: - if (msg->what == B_GET_PROPERTY) { + if (message->what == B_GET_PROPERTY) { replyMsg.AddBool("result", IsMinimized()); handled = true; } else { bool minimize; - if (msg->FindBool("data", &minimize) == B_OK) { + if (message->FindBool("data", &minimize) == B_OK) { Minimize(minimize); handled = true; } } break; case 12: - if (msg->what == B_GET_PROPERTY) { + if (message->what == B_GET_PROPERTY) { BMessage settings; if (GetDecoratorSettings(&settings) == B_OK) { BRect frame; @@ -915,28 +915,28 @@ BWindow::MessageReceived(BMessage* msg) } break; default: - return BLooper::MessageReceived(msg); + return BLooper::MessageReceived(message); } if (handled) { - if (msg->what == B_SET_PROPERTY) + if (message->what == B_SET_PROPERTY) replyMsg.AddInt32("error", B_OK); } else { replyMsg.what = B_MESSAGE_NOT_UNDERSTOOD; replyMsg.AddInt32("error", B_BAD_SCRIPT_SYNTAX); replyMsg.AddString("message", "Didn't understand the specifier(s)"); } - msg->SendReply(&replyMsg); + message->SendReply(&replyMsg); } void -BWindow::DispatchMessage(BMessage* msg, BHandler* target) +BWindow::DispatchMessage(BMessage* message, BHandler* target) { - if (!msg) + if (message == NULL) return; - switch (msg->what) { + switch (message->what) { case B_ZOOM: Zoom(); break; @@ -964,11 +964,11 @@ BWindow::DispatchMessage(BMessage* msg, BHandler* target) case _SWITCH_WORKSPACE_: { int32 deltaX = 0; - msg->FindInt32("delta_x", &deltaX); + message->FindInt32("delta_x", &deltaX); int32 deltaY = 0; - msg->FindInt32("delta_y", &deltaY); + message->FindInt32("delta_y", &deltaY); bool takeMeThere = false; - msg->FindBool("take_me_there", &takeMeThere); + message->FindBool("take_me_there", &takeMeThere); if (deltaX == 0 && deltaY == 0) break; @@ -1012,7 +1012,7 @@ BWindow::DispatchMessage(BMessage* msg, BHandler* target) case B_MINIMIZE: { bool minimize; - if (msg->FindBool("minimize", &minimize) == B_OK) + if (message->FindBool("minimize", &minimize) == B_OK) Minimize(minimize); break; } @@ -1038,8 +1038,8 @@ BWindow::DispatchMessage(BMessage* msg, BHandler* target) case B_WINDOW_RESIZED: { int32 width, height; - if (msg->FindInt32("width", &width) == B_OK - && msg->FindInt32("height", &height) == B_OK) { + if (message->FindInt32("width", &width) == B_OK + && message->FindInt32("height", &height) == B_OK) { // combine with pending resize notifications BMessage* pendingMessage; while ((pendingMessage = MessageQueue()->FindMessage(B_WINDOW_RESIZED, 0))) { @@ -1078,7 +1078,7 @@ FrameResized(width, height); case B_WINDOW_MOVED: { BPoint origin; - if (msg->FindPoint("where", &origin) == B_OK) { + if (message->FindPoint("where", &origin) == B_OK) { if (fFrame.LeftTop() != origin) { // NOTE: we might have already handled the move // in an _UPDATE_ message @@ -1098,12 +1098,12 @@ FrameMoved(origin); case B_WINDOW_ACTIVATED: if (target != this) { - target->MessageReceived(msg); + target->MessageReceived(message); break; } bool active; - if (msg->FindBool("active", &active) != B_OK) + if (message->FindBool("active", &active) != B_OK) break; // find latest activation message @@ -1139,12 +1139,12 @@ FrameMoved(origin); bool inputMethodAware = false; if (fFocus) inputMethodAware = fFocus->Flags() & B_INPUT_METHOD_AWARE; - BMessage msg(inputMethodAware ? IS_FOCUS_IM_AWARE_VIEW : IS_UNFOCUS_IM_AWARE_VIEW); + BMessage message(inputMethodAware ? IS_FOCUS_IM_AWARE_VIEW : IS_UNFOCUS_IM_AWARE_VIEW); BMessenger messenger(fFocus); BMessage reply; if (fFocus) - msg.AddMessenger("view", messenger); - _control_input_server_(&msg, &reply); + message.AddMessenger("view", messenger); + _control_input_server_(&message, &reply); } break; @@ -1152,62 +1152,62 @@ FrameMoved(origin); if (target == this) { BRect frame; uint32 mode; - if (msg->FindRect("frame", &frame) == B_OK - && msg->FindInt32("mode", (int32*)&mode) == B_OK) + if (message->FindRect("frame", &frame) == B_OK + && message->FindInt32("mode", (int32*)&mode) == B_OK) ScreenChanged(frame, (color_space)mode); } else - target->MessageReceived(msg); + target->MessageReceived(message); break; case B_WORKSPACE_ACTIVATED: if (target == this) { uint32 workspace; bool active; - if (msg->FindInt32("workspace", (int32*)&workspace) == B_OK - && msg->FindBool("active", &active) == B_OK) + if (message->FindInt32("workspace", (int32*)&workspace) == B_OK + && message->FindBool("active", &active) == B_OK) WorkspaceActivated(workspace, active); } else - target->MessageReceived(msg); + target->MessageReceived(message); break; case B_WORKSPACES_CHANGED: if (target == this) { uint32 oldWorkspace, newWorkspace; - if (msg->FindInt32("old", (int32*)&oldWorkspace) == B_OK - && msg->FindInt32("new", (int32*)&newWorkspace) == B_OK) + if (message->FindInt32("old", (int32*)&oldWorkspace) == B_OK + && message->FindInt32("new", (int32*)&newWorkspace) == B_OK) WorkspacesChanged(oldWorkspace, newWorkspace); } else - target->MessageReceived(msg); + target->MessageReceived(message); break; case B_INVALIDATE: { if (BView* view = dynamic_cast(target)) { BRect rect; - if (msg->FindRect("be:area", &rect) == B_OK) + if (message->FindRect("be:area", &rect) == B_OK) view->Invalidate(rect); else view->Invalidate(); } else - target->MessageReceived(msg); + target->MessageReceived(message); break; } case B_KEY_DOWN: { - if (!_HandleKeyDown(msg)) { + if (!_HandleKeyDown(message)) { if (BView* view = dynamic_cast(target)) { // TODO: cannot use "string" here if we support having // different font encoding per view (it's supposed to be // converted by _HandleKeyDown() one day) const char* string; ssize_t bytes; - if (msg->FindData("bytes", B_STRING_TYPE, + if (message->FindData("bytes", B_STRING_TYPE, (const void**)&string, &bytes) == B_OK) { view->KeyDown(string, bytes - 1); } } else - target->MessageReceived(msg); + target->MessageReceived(message); } break; } @@ -1218,19 +1218,19 @@ FrameMoved(origin); if (BView* view = dynamic_cast(target)) { const char* string; ssize_t bytes; - if (msg->FindData("bytes", B_STRING_TYPE, + if (message->FindData("bytes", B_STRING_TYPE, (const void**)&string, &bytes) == B_OK) { view->KeyUp(string, bytes - 1); } } else - target->MessageReceived(msg); + target->MessageReceived(message); break; } case B_UNMAPPED_KEY_DOWN: { - if (!_HandleUnmappedKeyDown(msg)) - target->MessageReceived(msg); + if (!_HandleUnmappedKeyDown(message)) + target->MessageReceived(message); break; } @@ -1240,10 +1240,10 @@ FrameMoved(origin); if (view != NULL) { BPoint where; - msg->FindPoint("be:view_where", &where); + message->FindPoint("be:view_where", &where); view->MouseDown(where); } else - target->MessageReceived(msg); + target->MessageReceived(message); break; } @@ -1252,11 +1252,11 @@ FrameMoved(origin); { if (BView* view = dynamic_cast(target)) { BPoint where; - msg->FindPoint("be:view_where", &where); + message->FindPoint("be:view_where", &where); view->fMouseEventOptions = 0; view->MouseUp(where); } else - target->MessageReceived(msg); + target->MessageReceived(message); break; } @@ -1270,11 +1270,11 @@ FrameMoved(origin); bool dropIfLate = !(eventOptions & B_FULL_POINTER_HISTORY); bigtime_t eventTime; - if (msg->FindInt64("when", (int64*)&eventTime) < B_OK) + if (message->FindInt64("when", (int64*)&eventTime) < B_OK) eventTime = system_time(); uint32 transit; - msg->FindInt32("be:transit", (int32*)&transit); + message->FindInt32("be:transit", (int32*)&transit); // don't drop late messages with these important transit values if (transit == B_ENTERED_VIEW || transit == B_EXITED_VIEW) dropIfLate = false; @@ -1299,7 +1299,7 @@ FrameMoved(origin); BMessage* moved; for (int32 i = 0; (moved = queue->FindMessage(i)) != NULL; i++) { - if (moved != msg && moved->what == B_MOUSE_MOVED) { + if (moved != message && moved->what == B_MOUSE_MOVED) { // there is a newer mouse moved message in the // queue, just ignore the current one, the newer one // will be handled here eventually @@ -1312,8 +1312,8 @@ FrameMoved(origin); BPoint where; uint32 buttons; - msg->FindPoint("be:view_where", &where); - msg->FindInt32("buttons", (int32*)&buttons); + message->FindPoint("be:view_where", &where); + message->FindInt32("buttons", (int32*)&buttons); delete fIdleMouseRunner; @@ -1331,9 +1331,9 @@ FrameMoved(origin); } BMessage* dragMessage = NULL; - if (msg->HasMessage("be:drag_message")) { + if (message->HasMessage("be:drag_message")) { dragMessage = new BMessage(); - if (msg->FindMessage("be:drag_message", dragMessage) + if (message->FindMessage("be:drag_message", dragMessage) != B_OK) { delete dragMessage; dragMessage = NULL; @@ -1343,7 +1343,7 @@ FrameMoved(origin); view->MouseMoved(where, transit, dragMessage); delete dragMessage; } else - target->MessageReceived(msg); + target->MessageReceived(message); break; } @@ -1353,7 +1353,7 @@ FrameMoved(origin); fTopView->_Pulse(); fLink->Flush(); } else - target->MessageReceived(msg); + target->MessageReceived(message); break; case _UPDATE_: @@ -1468,10 +1468,10 @@ FrameMoved(origin); case B_WINDOW_MOVE_BY: { BPoint offset; - if (msg->FindPoint("data", &offset) == B_OK) + if (message->FindPoint("data", &offset) == B_OK) MoveBy(offset.x, offset.y); else - msg->SendReply(B_MESSAGE_NOT_UNDERSTOOD); + message->SendReply(B_MESSAGE_NOT_UNDERSTOOD); break; } @@ -1479,10 +1479,10 @@ FrameMoved(origin); case B_WINDOW_MOVE_TO: { BPoint origin; - if (msg->FindPoint("data", &origin) == B_OK) + if (message->FindPoint("data", &origin) == B_OK) MoveTo(origin); else - msg->SendReply(B_MESSAGE_NOT_UNDERSTOOD); + message->SendReply(B_MESSAGE_NOT_UNDERSTOOD); break; } @@ -1493,14 +1493,14 @@ FrameMoved(origin); } default: - BLooper::DispatchMessage(msg, target); + BLooper::DispatchMessage(message, target); break; } } void -BWindow::FrameMoved(BPoint new_position) +BWindow::FrameMoved(BPoint newPosition) { // does nothing // Hook function @@ -1508,7 +1508,7 @@ BWindow::FrameMoved(BPoint new_position) void -BWindow::FrameResized(float new_width, float new_height) +BWindow::FrameResized(float newWidth, float newHeight) { // does nothing // Hook function @@ -1516,7 +1516,7 @@ BWindow::FrameResized(float new_width, float new_height) void -BWindow::WorkspacesChanged(uint32 old_ws, uint32 new_ws) +BWindow::WorkspacesChanged(uint32 oldWorkspaces, uint32 newWorkspaces) { // does nothing // Hook function @@ -1524,7 +1524,7 @@ BWindow::WorkspacesChanged(uint32 old_ws, uint32 new_ws) void -BWindow::WorkspaceActivated(int32 ws, bool state) +BWindow::WorkspaceActivated(int32 workspace, bool state) { // does nothing // Hook function @@ -1599,16 +1599,6 @@ BWindow::GetSizeLimits(float* _minWidth, float* _maxWidth, float* _minHeight, } -/*! Updates the window's size limits from the minimum and maximum sizes of its - top view. - - Is a no-op, unless the \c B_AUTO_UPDATE_SIZE_LIMITS window flag is set. - - The method is called automatically after a layout invalidation. Since it is - invoked asynchronously, calling this method manually is necessary, if it is - desired to adjust the limits (and as a possible side effect the window size) - earlier (e.g. before the first Show()). -*/ void BWindow::UpdateSizeLimits() { @@ -1709,11 +1699,11 @@ BWindow::SetZoomLimits(float maxWidth, float maxHeight) void -BWindow::Zoom(BPoint leftTop, float width, float height) +BWindow::Zoom(BPoint origin, float width, float height) { // the default implementation of this hook function // just does the obvious: - MoveTo(leftTop); + MoveTo(origin); ResizeTo(width, height); } @@ -1781,7 +1771,7 @@ BWindow::Zoom() void -BWindow::ScreenChanged(BRect screen_size, color_space depth) +BWindow::ScreenChanged(BRect screenSize, color_space depth) { // Hook function } @@ -2584,10 +2574,7 @@ BWindow::ResizeTo(float width, float height) } -/*! - \brief Center the window in the passed in \a rect. - \param rect The rectangle to center the window in. -*/ +// Center the window in the passed in rect. void BWindow::CenterIn(const BRect& rect) { @@ -2600,9 +2587,7 @@ BWindow::CenterIn(const BRect& rect) } -/*! - \brief Centers the window on the screen the window is currently on. -*/ +// Centers the window on the screen the window is currently on. void BWindow::CenterOnScreen() { @@ -2610,9 +2595,7 @@ BWindow::CenterOnScreen() } -/*! - \brief Centers the window on the screen with the passed in \a id. -*/ +// Centers the window on the screen with the passed in id. void BWindow::CenterOnScreen(screen_id id) { @@ -2738,35 +2721,35 @@ BWindow::GetSupportedSuites(BMessage* data) BHandler* -BWindow::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier, - int32 what, const char* property) +BWindow::ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier, + int32 what, const char* property) { - if (msg->what == B_WINDOW_MOVE_BY - || msg->what == B_WINDOW_MOVE_TO) + if (message->what == B_WINDOW_MOVE_BY + || message->what == B_WINDOW_MOVE_TO) return this; BPropertyInfo propertyInfo(sWindowPropInfo); - if (propertyInfo.FindMatch(msg, index, specifier, what, property) >= 0) { - if (!strcmp(property, "View")) { + if (propertyInfo.FindMatch(message, index, specifier, what, property) >= 0) { + if (strcmp(property, "View") == 0) { // we will NOT pop the current specifier return fTopView; - } else if (!strcmp(property, "MenuBar")) { + } else if (strcmp(property, "MenuBar") == 0) { if (fKeyMenuBar) { - msg->PopSpecifier(); + message->PopSpecifier(); return fKeyMenuBar; } else { BMessage replyMsg(B_MESSAGE_NOT_UNDERSTOOD); replyMsg.AddInt32("error", B_NAME_NOT_FOUND); replyMsg.AddString("message", "This window doesn't have a main MenuBar"); - msg->SendReply(&replyMsg); + message->SendReply(&replyMsg); return NULL; } } else return this; } - return BLooper::ResolveSpecifier(msg, index, specifier, what, property); + return BLooper::ResolveSpecifier(message, index, specifier, what, property); } @@ -3072,7 +3055,7 @@ BWindow::task_looper() if (!Lock()) break; - if (!fLastMessage) { + if (fLastMessage == NULL) { // No more messages: Unlock the looper and terminate the // dispatch loop. dispatchNextMessage = false; @@ -3512,7 +3495,7 @@ BWindow::_SanitizeMessage(BMessage* message, BHandler* target, bool usePreferred BView* view = dynamic_cast(target); - if (!view || message->what == B_MOUSE_MOVED) { + if (view == NULL || message->what == B_MOUSE_MOVED) { // add local window coordinates, only // for regular mouse moved messages message->AddPoint("where", ConvertFromScreen(where)); @@ -3969,7 +3952,7 @@ BWindow::_FindView(BView* view, BPoint point) const { // point is assumed to be already in view's coordinates if (!view->IsHidden() && view->Bounds().Contains(point)) { - if (!view->fFirstChild) + if (view->fFirstChild == NULL) return view; else { BView* child = view->fFirstChild;