IK: Propagate B_WORKSPACE_ACTIVATED to child views

... and B_WORKSPACES_CHANGED too.

hrev50148 propagated B_SCREEN_CHANGED messages to
children allowing them to respond to screen changes
fixing #8035 back in 2016.

This does the same thing for workspace messages only
I spelled propagate correctly this time.

Add private _PropagateMessageToChildViews() convinience
method to BWindow to do this work.

Call PostMessage() instead of calling MessageReceived()
directly which can work better in certain circumstances.

Change-Id: I5978c3fe674bbe75d9eafb7afb654a49ee3e0c11
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5516
Reviewed-by: Axel Dörfler <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
John Scipione
2022-08-08 15:32:47 +00:00
committed by waddlesplash
parent a3d8402537
commit 3ef6915cf3
3 changed files with 32 additions and 12 deletions
+1
View File
@@ -365,6 +365,7 @@ private:
void _GetDecoratorSize(float* _borderWidth,
float* _tabHeight) const;
void _SendShowOrHideMessage();
void _PropagateMessageToChildViews(BMessage*);
private:
char* fTitle;
+8 -2
View File
@@ -5122,13 +5122,19 @@ BView::MessageReceived(BMessage* message)
break;
case B_SCREEN_CHANGED:
case B_WORKSPACE_ACTIVATED:
case B_WORKSPACES_CHANGED:
{
// propegate message to child views
BWindow* window = Window();
if (window == NULL)
break;
// propagate message to child views
int32 childCount = CountChildren();
for (int32 i = 0; i < childCount; i++) {
BView* view = ChildAt(i);
if (view != NULL)
view->MessageReceived(message);
window->PostMessage(message, view);
}
break;
}
+23 -10
View File
@@ -1113,13 +1113,7 @@ FrameMoved(origin);
uint32 mode;
if (message->FindRect("frame", &frame) == B_OK
&& message->FindInt32("mode", (int32*)&mode) == B_OK) {
// propegate message to child views
int32 childCount = CountChildren();
for (int32 i = 0; i < childCount; i++) {
BView* view = ChildAt(i);
if (view != NULL)
view->MessageReceived(message);
}
_PropagateMessageToChildViews(message);
// call hook method
ScreenChanged(frame, (color_space)mode);
}
@@ -1132,18 +1126,25 @@ FrameMoved(origin);
uint32 workspace;
bool active;
if (message->FindInt32("workspace", (int32*)&workspace) == B_OK
&& message->FindBool("active", &active) == B_OK)
&& message->FindBool("active", &active) == B_OK) {
_PropagateMessageToChildViews(message);
// call hook method
WorkspaceActivated(workspace, active);
}
} else
target->MessageReceived(message);
break;
case B_WORKSPACES_CHANGED:
if (target == this) {
uint32 oldWorkspace, newWorkspace;
uint32 oldWorkspace;
uint32 newWorkspace;
if (message->FindInt32("old", (int32*)&oldWorkspace) == B_OK
&& message->FindInt32("new", (int32*)&newWorkspace) == B_OK)
&& message->FindInt32("new", (int32*)&newWorkspace) == B_OK) {
_PropagateMessageToChildViews(message);
// call hook method
WorkspacesChanged(oldWorkspace, newWorkspace);
}
} else
target->MessageReceived(message);
break;
@@ -4083,6 +4084,18 @@ BWindow::_SendShowOrHideMessage()
}
void
BWindow::_PropagateMessageToChildViews(BMessage* message)
{
int32 childrenCount = CountChildren();
for (int32 index = 0; index < childrenCount; index++) {
BView* view = ChildAt(index);
if (view != NULL)
PostMessage(message, view);
}
}
// #pragma mark - C++ binary compatibility kludge