mirror of
https://github.com/labwc/labwc.git
synced 2025-11-06 13:29:58 -05:00
Merge pull request #1491 from Consolatis/feature/fix_invisible_resize_area
src/ssd: allow invisible resize area across outputs
This commit is contained in:
commit
8b9ea7b343
4 changed files with 97 additions and 21 deletions
|
|
@ -124,7 +124,7 @@ struct view {
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The output that the view is displayed on. Specifically:
|
* The primary output that the view is displayed on. Specifically:
|
||||||
*
|
*
|
||||||
* - For floating views, this is the output nearest to the
|
* - For floating views, this is the output nearest to the
|
||||||
* center of the view. It is computed automatically when the
|
* center of the view. It is computed automatically when the
|
||||||
|
|
@ -139,6 +139,16 @@ struct view {
|
||||||
* by calling view_set_output() beforehand.
|
* by calling view_set_output() beforehand.
|
||||||
*/
|
*/
|
||||||
struct output *output;
|
struct output *output;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The outputs that the view is displayed on.
|
||||||
|
* This is used to notify the foreign toplevel
|
||||||
|
* implementation and to update the SSD invisible
|
||||||
|
* resize area.
|
||||||
|
* It is a bitset of output->scene_output->index.
|
||||||
|
*/
|
||||||
|
uint64_t outputs;
|
||||||
|
|
||||||
struct workspace *workspace;
|
struct workspace *workspace;
|
||||||
struct wlr_surface *surface;
|
struct wlr_surface *surface;
|
||||||
struct wlr_scene_tree *scene_tree;
|
struct wlr_scene_tree *scene_tree;
|
||||||
|
|
@ -460,6 +470,7 @@ void view_move_to_front(struct view *view);
|
||||||
void view_move_to_back(struct view *view);
|
void view_move_to_back(struct view *view);
|
||||||
struct view *view_get_root(struct view *view);
|
struct view *view_get_root(struct view *view);
|
||||||
void view_append_children(struct view *view, struct wl_array *children);
|
void view_append_children(struct view *view, struct wl_array *children);
|
||||||
|
bool view_on_output(struct view *view, struct output *output);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* view_is_related() - determine if view and surface are owned by the
|
* view_is_related() - determine if view and surface are owned by the
|
||||||
|
|
|
||||||
|
|
@ -107,11 +107,10 @@ void
|
||||||
foreign_toplevel_update_outputs(struct view *view)
|
foreign_toplevel_update_outputs(struct view *view)
|
||||||
{
|
{
|
||||||
assert(view->toplevel.handle);
|
assert(view->toplevel.handle);
|
||||||
struct wlr_output_layout *layout = view->server->output_layout;
|
|
||||||
struct output *output;
|
struct output *output;
|
||||||
wl_list_for_each(output, &view->server->outputs, link) {
|
wl_list_for_each(output, &view->server->outputs, link) {
|
||||||
if (output_is_usable(output) && wlr_output_layout_intersects(
|
if (view_on_output(view, output)) {
|
||||||
layout, output->wlr_output, &view->current)) {
|
|
||||||
wlr_foreign_toplevel_handle_v1_output_enter(
|
wlr_foreign_toplevel_handle_v1_output_enter(
|
||||||
view->toplevel.handle, output->wlr_output);
|
view->toplevel.handle, output->wlr_output);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
|
#include <pixman.h>
|
||||||
#include "common/mem.h"
|
#include "common/mem.h"
|
||||||
#include "common/scene-helpers.h"
|
#include "common/scene-helpers.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
|
|
@ -100,11 +101,6 @@ ssd_extents_update(struct ssd *ssd)
|
||||||
if (!view->output) {
|
if (!view->output) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct wlr_output_layout_output *l_output = wlr_output_layout_get(
|
|
||||||
view->server->output_layout, view->output->wlr_output);
|
|
||||||
if (!l_output) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct theme *theme = view->server->theme;
|
struct theme *theme = view->server->theme;
|
||||||
|
|
||||||
|
|
@ -127,10 +123,25 @@ ssd_extents_update(struct ssd *ssd)
|
||||||
-(theme->border_width + extended_area),
|
-(theme->border_width + extended_area),
|
||||||
-(ssd->titlebar.height + theme->border_width + extended_area));
|
-(ssd->titlebar.height + theme->border_width + extended_area));
|
||||||
|
|
||||||
/* Convert usable area into layout coordinates */
|
/*
|
||||||
struct wlr_box usable_area = view->output->usable_area;
|
* Convert all output usable areas that the
|
||||||
usable_area.x += l_output->x;
|
* view is currently on into a pixman region
|
||||||
usable_area.y += l_output->y;
|
*/
|
||||||
|
int nrects;
|
||||||
|
pixman_region32_t usable;
|
||||||
|
pixman_region32_t intersection;
|
||||||
|
pixman_region32_init(&usable);
|
||||||
|
pixman_region32_init(&intersection);
|
||||||
|
struct output *output;
|
||||||
|
wl_list_for_each(output, &view->server->outputs, link) {
|
||||||
|
if (!view_on_output(view, output)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
struct wlr_box usable_area =
|
||||||
|
output_usable_area_in_layout_coords(output);
|
||||||
|
pixman_region32_union_rect(&usable, &usable, usable_area.x,
|
||||||
|
usable_area.y, usable_area.width, usable_area.height);
|
||||||
|
}
|
||||||
|
|
||||||
/* Remember base layout coordinates */
|
/* Remember base layout coordinates */
|
||||||
int base_x, base_y;
|
int base_x, base_y;
|
||||||
|
|
@ -176,11 +187,40 @@ ssd_extents_update(struct ssd *ssd)
|
||||||
part_box.height = target->height;
|
part_box.height = target->height;
|
||||||
|
|
||||||
/* Constrain part to output->usable_area */
|
/* Constrain part to output->usable_area */
|
||||||
if (!wlr_box_intersection(&result_box, &part_box, &usable_area)) {
|
pixman_region32_clear(&intersection);
|
||||||
|
pixman_region32_intersect_rect(&intersection, &usable,
|
||||||
|
part_box.x, part_box.y, part_box.width, part_box.height);
|
||||||
|
const pixman_box32_t *inter_rects =
|
||||||
|
pixman_region32_rectangles(&intersection, &nrects);
|
||||||
|
|
||||||
|
if (nrects == 0) {
|
||||||
/* Not visible */
|
/* Not visible */
|
||||||
wlr_scene_node_set_enabled(part->node, false);
|
wlr_scene_node_set_enabled(part->node, false);
|
||||||
continue;
|
continue;
|
||||||
} else if (!part->node->enabled) {
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For each edge, the invisible grab area is resized
|
||||||
|
* to not cover layer-shell clients such as panels.
|
||||||
|
* However, only one resize operation is used per edge,
|
||||||
|
* so if a window is in the unlikely position that it
|
||||||
|
* is near a panel but also overspills onto another screen,
|
||||||
|
* the invisible grab-area on the other screen would be
|
||||||
|
* smaller than would normally be the case.
|
||||||
|
*
|
||||||
|
* Thus only use the first intersecting rect, this is
|
||||||
|
* a compromise as it doesn't require us to create
|
||||||
|
* multiple scene rects for a given extent edge
|
||||||
|
* and still works in 95% of the cases.
|
||||||
|
*/
|
||||||
|
result_box = (struct wlr_box) {
|
||||||
|
.x = inter_rects[0].x1,
|
||||||
|
.y = inter_rects[0].y1,
|
||||||
|
.width = inter_rects[0].x2 - inter_rects[0].x1,
|
||||||
|
.height = inter_rects[0].y2 - inter_rects[0].y1
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!part->node->enabled) {
|
||||||
wlr_scene_node_set_enabled(part->node, true);
|
wlr_scene_node_set_enabled(part->node, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,6 +244,8 @@ ssd_extents_update(struct ssd *ssd)
|
||||||
wlr_scene_rect_set_size(rect, target->width, target->height);
|
wlr_scene_rect_set_size(rect, target->width, target->height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pixman_region32_fini(&intersection);
|
||||||
|
pixman_region32_fini(&usable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
36
src/view.c
36
src/view.c
|
|
@ -333,6 +333,34 @@ view_close(struct view *view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
view_update_outputs(struct view *view)
|
||||||
|
{
|
||||||
|
struct output *output;
|
||||||
|
struct wlr_output_layout *layout = view->server->output_layout;
|
||||||
|
|
||||||
|
view->outputs = 0;
|
||||||
|
wl_list_for_each(output, &view->server->outputs, link) {
|
||||||
|
if (output_is_usable(output) && wlr_output_layout_intersects(
|
||||||
|
layout, output->wlr_output, &view->current)) {
|
||||||
|
view->outputs |= (1ull << output->scene_output->index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view->toplevel.handle) {
|
||||||
|
foreign_toplevel_update_outputs(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
view_on_output(struct view *view, struct output *output)
|
||||||
|
{
|
||||||
|
assert(view);
|
||||||
|
assert(output);
|
||||||
|
return output->scene_output
|
||||||
|
&& (view->outputs & (1ull << output->scene_output->index));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
view_move(struct view *view, int x, int y)
|
view_move(struct view *view, int x, int y)
|
||||||
{
|
{
|
||||||
|
|
@ -358,11 +386,9 @@ view_moved(struct view *view)
|
||||||
if (view_is_floating(view)) {
|
if (view_is_floating(view)) {
|
||||||
view_discover_output(view, NULL);
|
view_discover_output(view, NULL);
|
||||||
}
|
}
|
||||||
|
view_update_outputs(view);
|
||||||
ssd_update_geometry(view->ssd);
|
ssd_update_geometry(view->ssd);
|
||||||
cursor_update_focus(view->server);
|
cursor_update_focus(view->server);
|
||||||
if (view->toplevel.handle) {
|
|
||||||
foreign_toplevel_update_outputs(view);
|
|
||||||
}
|
|
||||||
if (rc.resize_indicator && view->server->grabbed_view == view) {
|
if (rc.resize_indicator && view->server->grabbed_view == view) {
|
||||||
resize_indicator_update(view);
|
resize_indicator_update(view);
|
||||||
}
|
}
|
||||||
|
|
@ -1467,9 +1493,7 @@ view_adjust_for_layout_change(struct view *view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view->toplevel.handle) {
|
view_update_outputs(view);
|
||||||
foreign_toplevel_update_outputs(view);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue