Move begin_interactive() to server.c

This commit is contained in:
Johan Malm 2020-05-22 21:13:43 +01:00
parent efd98eaebb
commit 9a0c2b8417
4 changed files with 96 additions and 92 deletions

View file

@ -3,6 +3,49 @@
static bool in_alt_tab_mode;
static struct view *alt_tab_view;
void begin_interactive(struct view *view, enum cursor_mode mode,
uint32_t edges)
{
/* This function sets up an interactive move or resize operation, where
* the compositor stops propegating pointer events to clients and
* instead consumes them itself, to move or resize windows. */
struct server *server = view->server;
server->grabbed_view = view;
server->cursor_mode = mode;
if (mode == TINYWL_CURSOR_MOVE) {
server->grab_x = server->cursor->x - view->x;
server->grab_y = server->cursor->y - view->y;
} else {
struct wlr_box geo_box;
switch (view->type) {
case LAB_XDG_SHELL_VIEW:
wlr_xdg_surface_get_geometry(view->xdg_surface,
&geo_box);
break;
case LAB_XWAYLAND_VIEW:
geo_box.x = view->xwayland_surface->x;
geo_box.y = view->xwayland_surface->y;
geo_box.width = view->xwayland_surface->width;
geo_box.height = view->xwayland_surface->height;
break;
}
double border_x =
(view->x + geo_box.x) +
((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0);
double border_y =
(view->y + geo_box.y) +
((edges & WLR_EDGE_BOTTOM) ? geo_box.height : 0);
server->grab_x = server->cursor->x - border_x;
server->grab_y = server->cursor->y - border_y;
server->grab_box = geo_box;
server->grab_box.x += view->x;
server->grab_box.y += view->y;
server->resize_edges = edges;
}
}
static void keyboard_handle_modifiers(struct wl_listener *listener, void *data)
{
/* This event is raised when a modifier key, such as shift or alt, is