mirror of
https://github.com/labwc/labwc.git
synced 2026-03-22 05:33:57 -04: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
|
|
@ -345,9 +345,6 @@ void view_child_finish(struct view_child *child);
|
||||||
void subsurface_create(struct view *view, struct wlr_subsurface *wlr_subsurface);
|
void subsurface_create(struct view *view, struct wlr_subsurface *wlr_subsurface);
|
||||||
|
|
||||||
void view_set_activated(struct view *view, bool activated);
|
void view_set_activated(struct view *view, bool activated);
|
||||||
void resistance_move_apply(struct view *view, double *x, double *y, bool screen_edge);
|
|
||||||
void resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo,
|
|
||||||
bool screen_edge);
|
|
||||||
struct border view_border(struct view *view);
|
struct border view_border(struct view *view);
|
||||||
void view_move_resize(struct view *view, struct wlr_box geo);
|
void view_move_resize(struct view *view, struct wlr_box geo);
|
||||||
void view_move(struct view *view, double x, double y);
|
void view_move(struct view *view, double x, double y);
|
||||||
|
|
|
||||||
8
include/resistance.h
Normal file
8
include/resistance.h
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef __RESISTANCE_H
|
||||||
|
#define __RESISTANCE_H
|
||||||
|
#include "labwc.h"
|
||||||
|
|
||||||
|
void resistance_move_apply(struct view *view, double *x, double *y);
|
||||||
|
void resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo);
|
||||||
|
|
||||||
|
#endif /* __RESISTANCE_H */
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "menu/menu.h"
|
#include "menu/menu.h"
|
||||||
|
#include "resistance.h"
|
||||||
#include "ssd.h"
|
#include "ssd.h"
|
||||||
#include "config/mousebind.h"
|
#include "config/mousebind.h"
|
||||||
#include <wlr/types/wlr_primary_selection.h>
|
#include <wlr/types/wlr_primary_selection.h>
|
||||||
|
|
@ -81,7 +82,7 @@ process_cursor_move(struct server *server, uint32_t time)
|
||||||
/* Move the grabbed view to the new position. */
|
/* Move the grabbed view to the new position. */
|
||||||
dx += server->grab_box.x;
|
dx += server->grab_box.x;
|
||||||
dy += server->grab_box.y;
|
dy += server->grab_box.y;
|
||||||
resistance_move_apply(view, &dx, &dy, true);
|
resistance_move_apply(view, &dx, &dy);
|
||||||
view_move(view, dx, dy);
|
view_move(view, dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,7 +126,7 @@ process_cursor_resize(struct server *server, uint32_t time)
|
||||||
new_view_geo.width = server->grab_box.width + dx;
|
new_view_geo.width = server->grab_box.width + dx;
|
||||||
}
|
}
|
||||||
|
|
||||||
resistance_resize_apply(view, &new_view_geo, true);
|
resistance_resize_apply(view, &new_view_geo);
|
||||||
view_move_resize(view, new_view_geo);
|
view_move_resize(view, new_view_geo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "config/rcxml.h"
|
#include "config/rcxml.h"
|
||||||
|
|
||||||
|
|
@ -30,7 +31,7 @@ is_within_resistance_range(struct edges view, struct edges target,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 server *server = view->server;
|
||||||
struct wlr_box mgeom;
|
struct wlr_box mgeom;
|
||||||
|
|
@ -51,7 +52,6 @@ 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.right = *x + view->w + border.right + rc.gap;
|
||||||
target_edges.bottom = *y + view->h + border.bottom + rc.gap;
|
target_edges.bottom = *y + view->h + border.bottom + rc.gap;
|
||||||
|
|
||||||
if (screen_edge) {
|
|
||||||
if (!rc.screen_edge_strength) {
|
if (!rc.screen_edge_strength) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -77,19 +77,17 @@ resistance_move_apply(struct view *view, double *x, double *y, bool screen_edge)
|
||||||
if (flags.top == 1) {
|
if (flags.top == 1) {
|
||||||
*y = other_edges.top + border.top + rc.gap;
|
*y = other_edges.top + border.top + rc.gap;
|
||||||
} else if (flags.bottom == 1) {
|
} else if (flags.bottom == 1) {
|
||||||
*y = other_edges.bottom - view->h
|
*y = other_edges.bottom - view->h - border.bottom
|
||||||
- border.bottom - rc.gap;
|
- rc.gap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset the flags */
|
/* reset the flags */
|
||||||
flags.left = flags.top = flags.right = flags.bottom = 0;
|
flags.left = flags.top = flags.right = flags.bottom = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo,
|
resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo)
|
||||||
bool screen_edge)
|
|
||||||
{
|
{
|
||||||
struct server *server = view->server;
|
struct server *server = view->server;
|
||||||
struct output *output;
|
struct output *output;
|
||||||
|
|
@ -112,7 +110,6 @@ resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo,
|
||||||
target_edges.bottom = new_view_geo->y + new_view_geo->height
|
target_edges.bottom = new_view_geo->y + new_view_geo->height
|
||||||
+ border.bottom + rc.gap;
|
+ border.bottom + rc.gap;
|
||||||
|
|
||||||
if (screen_edge) {
|
|
||||||
if (!rc.screen_edge_strength) {
|
if (!rc.screen_edge_strength) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -142,17 +139,16 @@ resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo,
|
||||||
|
|
||||||
if (server->resize_edges & WLR_EDGE_TOP) {
|
if (server->resize_edges & WLR_EDGE_TOP) {
|
||||||
if (flags.top == 1) {
|
if (flags.top == 1) {
|
||||||
new_view_geo->y = other_edges.top
|
new_view_geo->y = other_edges.top + border.top
|
||||||
+ border.top + rc.gap;
|
+ rc.gap;
|
||||||
new_view_geo->height = view->h;
|
new_view_geo->height = view->h;
|
||||||
}
|
}
|
||||||
} else if (server->resize_edges & WLR_EDGE_BOTTOM) {
|
} else if (server->resize_edges & WLR_EDGE_BOTTOM) {
|
||||||
if (flags.bottom == 1) {
|
if (flags.bottom == 1) {
|
||||||
new_view_geo->height =
|
new_view_geo->height =
|
||||||
other_edges.bottom
|
other_edges.bottom - view_edges.top
|
||||||
- view_edges.top - border.bottom
|
- border.bottom - border.top
|
||||||
- border.top - rc.gap * 2;
|
- rc.gap * 2;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue