A little unclear to me but I think this is your request.
Work with layers Layers -> Mask -> Add layer mask then you can choose various types white / black..and others
A layer mask will isolate a part of the layer that is visible.
One layer and layer mask for inside a shape. (for blue)
Another layer and layer mask for outside the shape. (for green)
For your question, essentially the same layer mask, inverted colours defining areas.
The attached .xcf as an example.
Work with layers Layers -> Mask -> Add layer mask then you can choose various types white / black..and others
A layer mask will isolate a part of the layer that is visible.
One layer and layer mask for inside a shape. (for blue)
Another layer and layer mask for outside the shape. (for green)
For your question, essentially the same layer mask, inverted colours defining areas.
The attached .xcf as an example.