mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
resistance: remove bool, add resistance.h + license
This commit is contained in:
parent
4d5b4be608
commit
91a9f1dec9
4 changed files with 77 additions and 75 deletions
136
src/resistance.c
136
src/resistance.c
|
|
@ -1,3 +1,4 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
#include "labwc.h"
|
||||
#include "config/rcxml.h"
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ is_within_resistance_range(struct edges view, struct edges target,
|
|||
}
|
||||
|
||||
void
|
||||
resistance_move_apply(struct view *view, double *x, double *y, bool screen_edge)
|
||||
resistance_move_apply(struct view *view, double *x, double *y)
|
||||
{
|
||||
struct server *server = view->server;
|
||||
struct wlr_box mgeom;
|
||||
|
|
@ -51,45 +52,42 @@ resistance_move_apply(struct view *view, double *x, double *y, bool screen_edge)
|
|||
target_edges.right = *x + view->w + border.right + rc.gap;
|
||||
target_edges.bottom = *y + view->h + border.bottom + rc.gap;
|
||||
|
||||
if (screen_edge) {
|
||||
if (!rc.screen_edge_strength) {
|
||||
return;
|
||||
if (!rc.screen_edge_strength) {
|
||||
return;
|
||||
}
|
||||
|
||||
wl_list_for_each(output, &server->outputs, link) {
|
||||
mgeom = output_usable_area_in_layout_coords(output);
|
||||
|
||||
other_edges.left = mgeom.x;
|
||||
other_edges.top = mgeom.y;
|
||||
other_edges.right = mgeom.x + mgeom.width;
|
||||
other_edges.bottom = mgeom.y + mgeom.height;
|
||||
|
||||
is_within_resistance_range(view_edges, target_edges,
|
||||
other_edges, &flags, rc.screen_edge_strength);
|
||||
|
||||
if (flags.left == 1) {
|
||||
*x = other_edges.left + border.left + rc.gap;
|
||||
} else if (flags.right == 1) {
|
||||
*x = other_edges.right - view->w - border.right
|
||||
- rc.gap;
|
||||
}
|
||||
|
||||
wl_list_for_each(output, &server->outputs, link) {
|
||||
mgeom = output_usable_area_in_layout_coords(output);
|
||||
|
||||
other_edges.left = mgeom.x;
|
||||
other_edges.top = mgeom.y;
|
||||
other_edges.right = mgeom.x + mgeom.width;
|
||||
other_edges.bottom = mgeom.y + mgeom.height;
|
||||
|
||||
is_within_resistance_range(view_edges, target_edges,
|
||||
other_edges, &flags, rc.screen_edge_strength);
|
||||
|
||||
if (flags.left == 1) {
|
||||
*x = other_edges.left + border.left + rc.gap;
|
||||
} else if (flags.right == 1) {
|
||||
*x = other_edges.right - view->w - border.right
|
||||
- rc.gap;
|
||||
}
|
||||
|
||||
if (flags.top == 1) {
|
||||
*y = other_edges.top + border.top + rc.gap;
|
||||
} else if (flags.bottom == 1) {
|
||||
*y = other_edges.bottom - view->h
|
||||
- border.bottom - rc.gap;
|
||||
}
|
||||
|
||||
/* reset the flags */
|
||||
flags.left = flags.top = flags.right = flags.bottom = 0;
|
||||
if (flags.top == 1) {
|
||||
*y = other_edges.top + border.top + rc.gap;
|
||||
} else if (flags.bottom == 1) {
|
||||
*y = other_edges.bottom - view->h - border.bottom
|
||||
- rc.gap;
|
||||
}
|
||||
|
||||
/* reset the flags */
|
||||
flags.left = flags.top = flags.right = flags.bottom = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo,
|
||||
bool screen_edge)
|
||||
resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo)
|
||||
{
|
||||
struct server *server = view->server;
|
||||
struct output *output;
|
||||
|
|
@ -112,47 +110,45 @@ resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo,
|
|||
target_edges.bottom = new_view_geo->y + new_view_geo->height
|
||||
+ border.bottom + rc.gap;
|
||||
|
||||
if (screen_edge) {
|
||||
if (!rc.screen_edge_strength) {
|
||||
return;
|
||||
}
|
||||
wl_list_for_each(output, &server->outputs, link) {
|
||||
mgeom = output_usable_area_in_layout_coords(output);
|
||||
other_edges.left = mgeom.x;
|
||||
other_edges.top = mgeom.y;
|
||||
other_edges.right = mgeom.x + mgeom.width;
|
||||
other_edges.bottom = mgeom.y + mgeom.height;
|
||||
if (!rc.screen_edge_strength) {
|
||||
return;
|
||||
}
|
||||
wl_list_for_each(output, &server->outputs, link) {
|
||||
mgeom = output_usable_area_in_layout_coords(output);
|
||||
other_edges.left = mgeom.x;
|
||||
other_edges.top = mgeom.y;
|
||||
other_edges.right = mgeom.x + mgeom.width;
|
||||
other_edges.bottom = mgeom.y + mgeom.height;
|
||||
|
||||
is_within_resistance_range(view_edges, target_edges,
|
||||
other_edges, &flags, rc.screen_edge_strength);
|
||||
is_within_resistance_range(view_edges, target_edges,
|
||||
other_edges, &flags, rc.screen_edge_strength);
|
||||
|
||||
if (server->resize_edges & WLR_EDGE_LEFT) {
|
||||
if (flags.left == 1) {
|
||||
new_view_geo->x = other_edges.left
|
||||
+ border.left + rc.gap;
|
||||
new_view_geo->width = view->w;
|
||||
}
|
||||
} else if (server->resize_edges & WLR_EDGE_RIGHT) {
|
||||
if (flags.right == 1) {
|
||||
new_view_geo->width = other_edges.right
|
||||
- view_edges.left
|
||||
- (border.right + rc.gap) * 2 ;
|
||||
}
|
||||
if (server->resize_edges & WLR_EDGE_LEFT) {
|
||||
if (flags.left == 1) {
|
||||
new_view_geo->x = other_edges.left
|
||||
+ border.left + rc.gap;
|
||||
new_view_geo->width = view->w;
|
||||
}
|
||||
} else if (server->resize_edges & WLR_EDGE_RIGHT) {
|
||||
if (flags.right == 1) {
|
||||
new_view_geo->width = other_edges.right
|
||||
- view_edges.left
|
||||
- (border.right + rc.gap) * 2 ;
|
||||
}
|
||||
}
|
||||
|
||||
if (server->resize_edges & WLR_EDGE_TOP) {
|
||||
if (flags.top == 1) {
|
||||
new_view_geo->y = other_edges.top
|
||||
+ border.top + rc.gap;
|
||||
new_view_geo->height = view->h;
|
||||
}
|
||||
} else if (server->resize_edges & WLR_EDGE_BOTTOM) {
|
||||
if (flags.bottom == 1) {
|
||||
new_view_geo->height =
|
||||
other_edges.bottom
|
||||
- view_edges.top - border.bottom
|
||||
- border.top - rc.gap * 2;
|
||||
}
|
||||
if (server->resize_edges & WLR_EDGE_TOP) {
|
||||
if (flags.top == 1) {
|
||||
new_view_geo->y = other_edges.top + border.top
|
||||
+ rc.gap;
|
||||
new_view_geo->height = view->h;
|
||||
}
|
||||
} else if (server->resize_edges & WLR_EDGE_BOTTOM) {
|
||||
if (flags.bottom == 1) {
|
||||
new_view_geo->height =
|
||||
other_edges.bottom - view_edges.top
|
||||
- border.bottom - border.top
|
||||
- rc.gap * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue