mirror of
https://github.com/labwc/labwc.git
synced 2026-03-01 01:40:24 -05:00
Partial screen_edge_strength
This commit is contained in:
parent
0cf4579aa9
commit
e1c8b3c641
3 changed files with 56 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ struct rcxml {
|
||||||
bool xdg_shell_server_side_deco;
|
bool xdg_shell_server_side_deco;
|
||||||
int gap;
|
int gap;
|
||||||
bool adaptive_sync;
|
bool adaptive_sync;
|
||||||
|
int strength;
|
||||||
|
|
||||||
/* focus */
|
/* focus */
|
||||||
bool focus_follow_mouse;
|
bool focus_follow_mouse;
|
||||||
|
|
|
||||||
|
|
@ -322,6 +322,8 @@ entry(xmlNode *node, char *nodename, char *content)
|
||||||
rc.repeat_rate = atoi(content);
|
rc.repeat_rate = atoi(content);
|
||||||
} else if (!strcasecmp(nodename, "repeatDelay.keyboard")) {
|
} else if (!strcasecmp(nodename, "repeatDelay.keyboard")) {
|
||||||
rc.repeat_delay = atoi(content);
|
rc.repeat_delay = atoi(content);
|
||||||
|
} else if (!strcasecmp(nodename, "screenEdgeStrength.core")) {
|
||||||
|
rc.strength = atoi(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -417,6 +419,7 @@ rcxml_init()
|
||||||
rc.doubleclick_time = 500;
|
rc.doubleclick_time = 500;
|
||||||
rc.repeat_rate = 25;
|
rc.repeat_rate = 25;
|
||||||
rc.repeat_delay = 600;
|
rc.repeat_delay = 600;
|
||||||
|
rc.strength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
|
|
||||||
52
src/view.c
52
src/view.c
|
|
@ -16,6 +16,8 @@ view_set_activated(struct view *view, bool activated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void view_move_resistance(struct view *view, double *x, double *y);
|
||||||
|
|
||||||
void
|
void
|
||||||
view_move_resize(struct view *view, struct wlr_box geo)
|
view_move_resize(struct view *view, struct wlr_box geo)
|
||||||
{
|
{
|
||||||
|
|
@ -29,6 +31,7 @@ void
|
||||||
view_move(struct view *view, double x, double y)
|
view_move(struct view *view, double x, double y)
|
||||||
{
|
{
|
||||||
if (view->impl->move) {
|
if (view->impl->move) {
|
||||||
|
view_move_resistance(view, &x, &y);
|
||||||
view->impl->move(view, x, y);
|
view->impl->move(view, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -423,6 +426,55 @@ view_snap_to_edge(struct view *view, const char *direction)
|
||||||
view_move_resize(view, dst);
|
view_move_resize(view, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
view_move_resistance(struct view *view, double *x, double *y)
|
||||||
|
{
|
||||||
|
struct wlr_box mgeom;
|
||||||
|
struct output *output;
|
||||||
|
struct border border = view_border(view);
|
||||||
|
int l, r, t, b; /* The edges of the current view */
|
||||||
|
int tl, tr, tt, tb; /* The desired edges */
|
||||||
|
int ml, mr, mt, mb; /* The edges of the Monitor */
|
||||||
|
|
||||||
|
if (!rc.strength) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
output = view_output(view);
|
||||||
|
if (!output) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
l = view->x - border.left - rc.gap;
|
||||||
|
t = view->y - border.top - rc.gap;
|
||||||
|
r = view->x + view->w + border.right + rc.gap;
|
||||||
|
b = view->y + view->h + border.bottom + rc.gap;
|
||||||
|
|
||||||
|
tl = *x - border.left - rc.gap;
|
||||||
|
tt = *y - border.top - rc.gap;
|
||||||
|
tr = *x + view->w + border.right + rc.gap;
|
||||||
|
tb = *y + view->h + border.bottom + rc.gap;
|
||||||
|
|
||||||
|
mgeom = output_usable_area_in_layout_coords(output);
|
||||||
|
|
||||||
|
ml = mgeom.x;
|
||||||
|
mt = mgeom.y;
|
||||||
|
mr = mgeom.x + mgeom.width;
|
||||||
|
mb = mgeom.y + mgeom.height;
|
||||||
|
|
||||||
|
if (l >= ml && tl < ml && tl >= ml - rc.strength) {
|
||||||
|
*x = ml + border.left + rc.gap;
|
||||||
|
} else if (r <= mr && tr > mr && tr <= mr + rc.strength) {
|
||||||
|
*x = mr - view->w - border.right - rc.gap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t >= mt && tt < mt && tt >= mt - rc.strength) {
|
||||||
|
*y = mt + border.top + rc.gap;
|
||||||
|
} else if (b <= mb && tb > mb && tb <= mb + rc.strength) {
|
||||||
|
*y = mb - view->h - border.bottom - rc.gap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
view_get_string_prop(struct view *view, const char *prop)
|
view_get_string_prop(struct view *view, const char *prop)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue