bool minimized;
bool maximized;
uint32_t tiled; /* private, enum view_edge in src/view.c */
+ struct region *tiled_region;
struct wlr_output *fullscreen;
/* geometry of the wlr_surface contained within the view */
void view_move_to_edge(struct view *view, const char *direction);
void view_snap_to_edge(struct view *view, const char *direction,
bool store_natural_geometry);
+void view_snap_to_region(struct view *view, struct region *region,
+ bool store_natural_geometry);
const char *view_get_string_prop(struct view *view, const char *prop);
void view_update_title(struct view *view);
void view_update_app_id(struct view *view);
#include "common/scene-helpers.h"
#include "labwc.h"
#include "menu/menu.h"
+#include "regions.h"
#include "ssd.h"
#include "view.h"
#include "workspaces.h"
view_store_natural_geometry(struct view *view)
{
assert(view);
- if (view->maximized || view->tiled) {
+ if (view->maximized || view->tiled || view->tiled_region) {
/* Do not overwrite the stored geometry with special cases */
return;
}
}
}
+static void
+view_apply_region_geometry(struct view *view)
+{
+ assert(view);
+ assert(view->tiled_region);
+
+ /* Create a copy of the original region geometry */
+ struct wlr_box geo = view->tiled_region->geo;
+
+ /* 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->w == geo.width && view->h == geo.height) {
+ /* move horizontally/vertically without changing size */
+ view_move(view, geo.x, geo.y);
+ } else {
+ view_move_resize(view, geo);
+ }
+}
+
static void
view_apply_tiled_geometry(struct view *view, struct output *output)
{
view_apply_maximized_geometry(view);
} else if (view->tiled) {
view_apply_tiled_geometry(view, NULL);
+ } else if (view->tiled_region) {
+ view_apply_region_geometry(view);
} else {
return false;
}
{
assert(view);
view->tiled = VIEW_EDGE_INVALID;
+ view->tiled_region = NULL;
}
void
view_apply_tiled_geometry(view, output);
}
+void
+view_snap_to_region(struct view *view, struct region *region,
+ bool store_natural_geometry)
+{
+ assert(view);
+ assert(region);
+ if (view->fullscreen) {
+ return;
+ }
+ if (view->maximized) {
+ /* Unmaximize + keep using existing natural_geometry */
+ view_maximize(view, false, /*store_natural_geometry*/ false);
+ } else if (store_natural_geometry) {
+ /* store current geometry as new natural_geometry */
+ view_store_natural_geometry(view);
+ }
+ view_set_untiled(view);
+ view->tiled_region = region;
+ view_apply_region_geometry(view);
+}
+
const char *
view_get_string_prop(struct view *view, const char *prop)
{