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:
committed by
waddlesplash
parent
a3d8402537
commit
3ef6915cf3
@@ -365,6 +365,7 @@ private:
|
|||||||
void _GetDecoratorSize(float* _borderWidth,
|
void _GetDecoratorSize(float* _borderWidth,
|
||||||
float* _tabHeight) const;
|
float* _tabHeight) const;
|
||||||
void _SendShowOrHideMessage();
|
void _SendShowOrHideMessage();
|
||||||
|
void _PropagateMessageToChildViews(BMessage*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char* fTitle;
|
char* fTitle;
|
||||||
|
|||||||
@@ -5122,13 +5122,19 @@ BView::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case B_SCREEN_CHANGED:
|
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();
|
int32 childCount = CountChildren();
|
||||||
for (int32 i = 0; i < childCount; i++) {
|
for (int32 i = 0; i < childCount; i++) {
|
||||||
BView* view = ChildAt(i);
|
BView* view = ChildAt(i);
|
||||||
if (view != NULL)
|
if (view != NULL)
|
||||||
view->MessageReceived(message);
|
window->PostMessage(message, view);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1113,13 +1113,7 @@ FrameMoved(origin);
|
|||||||
uint32 mode;
|
uint32 mode;
|
||||||
if (message->FindRect("frame", &frame) == B_OK
|
if (message->FindRect("frame", &frame) == B_OK
|
||||||
&& message->FindInt32("mode", (int32*)&mode) == B_OK) {
|
&& message->FindInt32("mode", (int32*)&mode) == B_OK) {
|
||||||
// propegate message to child views
|
_PropagateMessageToChildViews(message);
|
||||||
int32 childCount = CountChildren();
|
|
||||||
for (int32 i = 0; i < childCount; i++) {
|
|
||||||
BView* view = ChildAt(i);
|
|
||||||
if (view != NULL)
|
|
||||||
view->MessageReceived(message);
|
|
||||||
}
|
|
||||||
// call hook method
|
// call hook method
|
||||||
ScreenChanged(frame, (color_space)mode);
|
ScreenChanged(frame, (color_space)mode);
|
||||||
}
|
}
|
||||||
@@ -1132,18 +1126,25 @@ FrameMoved(origin);
|
|||||||
uint32 workspace;
|
uint32 workspace;
|
||||||
bool active;
|
bool active;
|
||||||
if (message->FindInt32("workspace", (int32*)&workspace) == B_OK
|
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);
|
WorkspaceActivated(workspace, active);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
target->MessageReceived(message);
|
target->MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_WORKSPACES_CHANGED:
|
case B_WORKSPACES_CHANGED:
|
||||||
if (target == this) {
|
if (target == this) {
|
||||||
uint32 oldWorkspace, newWorkspace;
|
uint32 oldWorkspace;
|
||||||
|
uint32 newWorkspace;
|
||||||
if (message->FindInt32("old", (int32*)&oldWorkspace) == B_OK
|
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);
|
WorkspacesChanged(oldWorkspace, newWorkspace);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
target->MessageReceived(message);
|
target->MessageReceived(message);
|
||||||
break;
|
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
|
// #pragma mark - C++ binary compatibility kludge
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user