MCPcopy Create free account
hub / github.com/WayfireWM/wayfire / find_resizing_pair

Method find_resizing_pair

plugins/tile/tree-controller.cpp:186–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186resize_view_controller_t::resizing_pair_t resize_view_controller_t::find_resizing_pair(bool horiz)
187{
188 split_insertion_t direction;
189
190 /* Calculate the direction in which we are looking for the resizing pair */
191 if (horiz)
192 {
193 if (this->resizing_edges & WLR_EDGE_TOP)
194 {
195 direction = INSERT_ABOVE;
196 } else
197 {
198 direction = INSERT_BELOW;
199 }
200 } else
201 {
202 if (this->resizing_edges & WLR_EDGE_LEFT)
203 {
204 direction = INSERT_LEFT;
205 } else
206 {
207 direction = INSERT_RIGHT;
208 }
209 }
210
211 /* Find a view in the resizing direction, then look for the least common
212 * ancestor(LCA) of the grabbed view and the found view.
213 *
214 * Then the resizing pair is a pair of children of the LCA */
215 auto pair_view =
216 find_first_view_in_direction(this->grabbed_view, direction);
217
218 if (!pair_view) // no pair
219 {
220 return {nullptr, grabbed_view};
221 }
222
223 /* Calculate all ancestors of the grabbed view */
224 std::set<nonstd::observer_ptr<tree_node_t>> grabbed_view_ancestors;
225
226 nonstd::observer_ptr<tree_node_t> ancestor = grabbed_view;
227 while (ancestor)
228 {
229 grabbed_view_ancestors.insert(ancestor);
230 ancestor = ancestor->parent;
231 }
232
233 /* Find the LCA: this is the first ancestor of the pair_view which is also
234 * an ancestor of the grabbed view */
235 nonstd::observer_ptr<tree_node_t> lca = pair_view;
236 /* The child of lca we came from the second time */
237 nonstd::observer_ptr<tree_node_t> lca_successor = nullptr;
238 while (lca && !grabbed_view_ancestors.count({lca}))
239 {
240 lca_successor = lca;
241 lca = lca->parent;
242 }
243

Callers 1

Calls 3

swapFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected