]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add output_usable_area_scaled() helper
authorAxel Burri <axel@tty0.ch>
Sat, 5 Aug 2023 21:53:01 +0000 (23:53 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 19 Oct 2023 18:09:42 +0000 (19:09 +0100)
Preparatory for snap to window edge framework.

include/labwc.h
src/output.c

index 54fbe96052d3c9e19850663be904f365c42a76f8..598d427053f005cb1b037c5a289fc360eee46993 100644 (file)
@@ -460,6 +460,7 @@ bool output_is_usable(struct output *output);
 void output_update_usable_area(struct output *output);
 void output_update_all_usable_areas(struct server *server, bool layout_changed);
 struct wlr_box output_usable_area_in_layout_coords(struct output *output);
+struct wlr_box output_usable_area_scaled(struct output *output);
 void handle_output_power_manager_set_mode(struct wl_listener *listener,
        void *data);
 
index 9074b94fe7c9a0adcb15377ebcd2af03e394bf3f..eef34629bb1a868b976409e34e2d2627a9e20386 100644 (file)
@@ -565,6 +565,24 @@ output_usable_area_in_layout_coords(struct output *output)
        return box;
 }
 
+struct wlr_box
+output_usable_area_scaled(struct output *output)
+{
+       if (!output) {
+               return (struct wlr_box){0};
+       }
+       struct wlr_box usable = output_usable_area_in_layout_coords(output);
+       if (usable.height == output->wlr_output->height
+                       && output->wlr_output->scale != 1) {
+               usable.height /= output->wlr_output->scale;
+       }
+       if (usable.width == output->wlr_output->width
+                       && output->wlr_output->scale != 1) {
+               usable.width /= output->wlr_output->scale;
+       }
+       return usable;
+}
+
 void
 handle_output_power_manager_set_mode(struct wl_listener *listener, void *data)
 {