void interactive_begin(struct view *view, enum input_mode mode, uint32_t edges);
void interactive_finish(struct view *view);
void interactive_cancel(struct view *view);
-/* Possibly returns VIEW_EDGE_CENTER if <topMaximize> is yes */
enum view_edge edge_from_cursor(struct seat *seat, struct output **dest_output);
void handle_tearing_new_object(struct wl_listener *listener, void *data);
*/
enum view_edge view_edge_invert(enum view_edge edge);
+/* If view is NULL, the size of SSD is not considered */
+struct wlr_box view_get_edge_snap_box(struct view *view, struct output *output,
+ enum view_edge edge);
+
/**
* view_is_focusable() - Check whether or not a view can be focused
* @view: view to be checked
} else if (cursor_x >= area->x + area->width - snap_range) {
return VIEW_EDGE_RIGHT;
} else if (cursor_y <= area->y + snap_range) {
- if (rc.snap_top_maximize) {
- return VIEW_EDGE_CENTER;
- } else {
- return VIEW_EDGE_UP;
- }
+ return VIEW_EDGE_UP;
} else if (cursor_y >= area->y + area->height - snap_range) {
return VIEW_EDGE_DOWN;
} else {
* Don't store natural geometry here (it was
* stored already in interactive_begin())
*/
- if (edge == VIEW_EDGE_CENTER) {
+ if (edge == VIEW_EDGE_UP && rc.snap_top_maximize) {
/* <topMaximize> */
view_maximize(view, VIEW_AXIS_BOTH,
/*store_natural_geometry*/ false);
show_overlay(seat, &seat->overlay.region_rect, ®ion->geo);
}
-/* TODO: share logic with view_get_edge_snap_box() */
static struct wlr_box get_edge_snap_box(enum view_edge edge, struct output *output)
{
- struct wlr_box box = output_usable_area_in_layout_coords(output);
- switch (edge) {
- case VIEW_EDGE_RIGHT:
- box.x += box.width / 2;
- /* fallthrough */
- case VIEW_EDGE_LEFT:
- box.width /= 2;
- break;
- case VIEW_EDGE_DOWN:
- box.y += box.height / 2;
- /* fallthrough */
- case VIEW_EDGE_UP:
- box.height /= 2;
- break;
- case VIEW_EDGE_CENTER:
- /* <topMaximize> */
- break;
- default:
- /* not reached */
- assert(false);
+ if (edge == VIEW_EDGE_UP && rc.snap_top_maximize) {
+ return output_usable_area_in_layout_coords(output);
+ } else {
+ return view_get_edge_snap_box(NULL, output, edge);
}
- return box;
}
static int
}
}
-static struct wlr_box
+struct wlr_box
view_get_edge_snap_box(struct view *view, struct output *output,
enum view_edge edge)
{
break;
}
- struct border margin = ssd_get_margin(view->ssd);
struct wlr_box dst = {
- .x = x_offset + usable.x + margin.left,
- .y = y_offset + usable.y + margin.top,
- .width = base_width - margin.left - margin.right,
- .height = base_height - margin.top - margin.bottom,
+ .x = x_offset + usable.x,
+ .y = y_offset + usable.y,
+ .width = base_width,
+ .height = base_height,
};
+ if (view) {
+ struct border margin = ssd_get_margin(view->ssd);
+ dst.x += margin.left;
+ dst.y += margin.top;
+ dst.width -= margin.left + margin.right;
+ dst.height -= margin.top + margin.bottom;
+ }
+
return dst;
}