]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: Add view_evacuate_region() helper
authorJohn Lindgren <john@jlindgren.net>
Thu, 16 Feb 2023 16:54:18 +0000 (11:54 -0500)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 17 Feb 2023 03:47:15 +0000 (04:47 +0100)
v2: Modify asserts as suggested by Consolatis

include/view.h
src/regions.c
src/view.c

index dc8a94c95957340d3ee2a7e3af21ffb468dbca65..e6501a9060b910ce83d600cd49480a01f7d35911 100644 (file)
@@ -162,6 +162,7 @@ void view_reload_ssd(struct view *view);
 void view_impl_map(struct view *view);
 void view_adjust_size(struct view *view, int *w, int *h);
 
+void view_evacuate_region(struct view *view);
 void view_on_output_destroy(struct view *view);
 void view_destroy(struct view *view);
 
index 7ca2d9d234547d3e520b784944ac9e99cdf45cb2..8587055a6d40d805bd7a8c71682bda3a0036f1cb 100644 (file)
@@ -219,12 +219,7 @@ regions_evacuate_output(struct output *output)
        wl_list_for_each(view, &output->server->views, link) {
                wl_list_for_each(region, &output->regions, link) {
                        if (view->tiled_region == region) {
-                               if (!view->tiled_region_evacuate) {
-                                       view->tiled_region_evacuate =
-                                               xstrdup(region->name);
-                               }
-                               /* Prevent carrying around a dangling pointer */
-                               view->tiled_region = NULL;
+                               view_evacuate_region(view);
                                break;
                        }
                }
index 5966f5f9f5c927a98b1744c0908661be0ffefdae..8c166bea3cefce3b514ca4c9e55431f8eb723dce 100644 (file)
@@ -774,6 +774,17 @@ view_discover_output(struct view *view)
        view->output = view_output(view);
 }
 
+void
+view_evacuate_region(struct view *view)
+{
+       assert(view);
+       assert(view->tiled_region);
+       if (!view->tiled_region_evacuate) {
+               view->tiled_region_evacuate = xstrdup(view->tiled_region->name);
+       }
+       view->tiled_region = NULL;
+}
+
 void
 view_on_output_destroy(struct view *view)
 {