GTK does not merge the rectangles, but it does optimise the inclusion test.
In the attached patch I split the selection process into three steps:
1) collect matching objects in a list
2) compute & invalidate bounding box of the list
3) for each object - perform the selection & call registered hooks
In 3) some work is duplicated - o_invalidate is called for each object, but GTK already saw one big invalidated rectangle so the cost is negiligible.
For deselection a GList of affected objects is already available - see above comment. This change is also included in the patch.
GTK does not merge the rectangles, but it does optimise the inclusion test.
In the attached patch I split the selection process into three steps:
1) collect matching objects in a list
2) compute & invalidate bounding box of the list
3) for each object - perform the selection & call registered hooks
In 3) some work is duplicated - o_invalidate is called for each object, but GTK already saw one big invalidated rectangle so the cost is negiligible.
For deselection a GList of affected objects is already available - see above comment. This change is also included in the patch.