view_move_resize(view, geometry);
}
-static void
-view_apply_region_geometry(struct view *view)
+struct wlr_box
+view_get_region_snap_box(struct view *view, struct region *region)
{
- assert(view);
- assert(view->tiled_region || view->tiled_region_evacuate);
- struct output *output = view->output;
- assert(output_is_usable(output));
-
- if (view->tiled_region_evacuate) {
- /* View was evacuated from a destroying output */
- /* Get new output local region, may be NULL */
- view->tiled_region = regions_from_name(
- view->tiled_region_evacuate, output);
-
- /* Get rid of the evacuate instruction */
- zfree(view->tiled_region_evacuate);
-
- if (!view->tiled_region) {
- /* Existing region name doesn't exist in rc.xml anymore */
- view_set_untiled(view);
- view_apply_natural_geometry(view);
- return;
- }
- }
-
- /* Create a copy of the original region geometry */
- struct wlr_box geo = view->tiled_region->geo;
+ struct wlr_box geo = region->geo;
/* Adjust for rc.gap */
if (rc.gap) {
.height = -rc.gap
};
struct wlr_box usable =
- output_usable_area_in_layout_coords(output);
+ output_usable_area_in_layout_coords(region->output);
if (geo.x == usable.x) {
offset.x += half_gap;
offset.width -= half_gap;
}
/* And adjust for current view */
- struct border margin = ssd_get_margin(view->ssd);
- geo.x += margin.left;
- geo.y += margin.top;
- geo.width -= margin.left + margin.right;
- geo.height -= margin.top + margin.bottom;
+ if (view) {
+ struct border margin = ssd_get_margin(view->ssd);
+ geo.x += margin.left;
+ geo.y += margin.top;
+ geo.width -= margin.left + margin.right;
+ geo.height -= margin.top + margin.bottom;
+ }
+
+ return geo;
+}
+
+static void
+view_apply_region_geometry(struct view *view)
+{
+ assert(view);
+ assert(view->tiled_region || view->tiled_region_evacuate);
+ struct output *output = view->output;
+ assert(output_is_usable(output));
+
+ if (view->tiled_region_evacuate) {
+ /* View was evacuated from a destroying output */
+ /* Get new output local region, may be NULL */
+ view->tiled_region = regions_from_name(
+ view->tiled_region_evacuate, output);
+
+ /* Get rid of the evacuate instruction */
+ zfree(view->tiled_region_evacuate);
+
+ if (!view->tiled_region) {
+ /* Existing region name doesn't exist in rc.xml anymore */
+ view_set_untiled(view);
+ view_apply_natural_geometry(view);
+ return;
+ }
+ }
+ struct wlr_box geo = view_get_region_snap_box(view, view->tiled_region);
view_move_resize(view, geo);
}