mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-09 15:05:58 +01:00
React to xdg shell resize requests
This commit is contained in:
parent
0c48ef5ad8
commit
97679b8e12
5 changed files with 39 additions and 4 deletions
|
@ -110,5 +110,7 @@ const struct roots_input_event *get_input_event(struct roots_input *input,
|
||||||
uint32_t serial);
|
uint32_t serial);
|
||||||
void view_begin_move(struct roots_input *input, struct wlr_cursor *cursor,
|
void view_begin_move(struct roots_input *input, struct wlr_cursor *cursor,
|
||||||
struct roots_view *view);
|
struct roots_view *view);
|
||||||
|
void view_begin_resize(struct roots_input *input, struct wlr_cursor *cursor,
|
||||||
|
struct roots_view *view);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,6 +29,14 @@ void view_begin_move(struct roots_input *input, struct wlr_cursor *cursor,
|
||||||
wlr_seat_pointer_clear_focus(input->wl_seat);
|
wlr_seat_pointer_clear_focus(input->wl_seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void view_begin_resize(struct roots_input *input, struct wlr_cursor *cursor,
|
||||||
|
struct roots_view *view) {
|
||||||
|
input->mode = ROOTS_CURSOR_RESIZE;
|
||||||
|
input->offs_x = cursor->x - view->x;
|
||||||
|
input->offs_y = cursor->y - view->y;
|
||||||
|
wlr_seat_pointer_clear_focus(input->wl_seat);
|
||||||
|
}
|
||||||
|
|
||||||
void cursor_update_position(struct roots_input *input, uint32_t time) {
|
void cursor_update_position(struct roots_input *input, uint32_t time) {
|
||||||
struct roots_desktop *desktop = input->server->desktop;
|
struct roots_desktop *desktop = input->server->desktop;
|
||||||
struct roots_view *view;
|
struct roots_view *view;
|
||||||
|
@ -53,6 +61,10 @@ void cursor_update_position(struct roots_input *input, uint32_t time) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ROOTS_CURSOR_RESIZE:
|
case ROOTS_CURSOR_RESIZE:
|
||||||
|
// TODO: this is just for testing
|
||||||
|
if (input->active_view && input->active_view->type == ROOTS_XDG_SHELL_V6_VIEW) {
|
||||||
|
wlr_xdg_toplevel_v6_set_size(input->active_view->xdg_surface_v6, input->cursor->x - input->offs_x, input->cursor->y - input->offs_y);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ROOTS_CURSOR_ROTATE:
|
case ROOTS_CURSOR_ROTATE:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "rootston/server.h"
|
#include "rootston/server.h"
|
||||||
#include "rootston/input.h"
|
#include "rootston/input.h"
|
||||||
|
|
||||||
static void handle_move(struct wl_listener *listener, void *data) {
|
static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, request_move);
|
wl_container_of(listener, roots_surface, request_move);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = roots_surface->view;
|
||||||
|
@ -53,7 +53,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
|
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
|
||||||
wl_list_init(&roots_surface->ping_timeout.link);
|
wl_list_init(&roots_surface->ping_timeout.link);
|
||||||
wl_list_init(&roots_surface->request_move.link);
|
wl_list_init(&roots_surface->request_move.link);
|
||||||
roots_surface->request_move.notify = handle_move;
|
roots_surface->request_move.notify = handle_request_move;
|
||||||
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
|
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
|
||||||
wl_list_init(&roots_surface->request_resize.link);
|
wl_list_init(&roots_surface->request_resize.link);
|
||||||
wl_list_init(&roots_surface->request_set_fullscreen.link);
|
wl_list_init(&roots_surface->request_set_fullscreen.link);
|
||||||
|
|
|
@ -14,6 +14,11 @@ static void get_input_bounds(struct roots_view *view, struct wlr_box *box) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
||||||
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
|
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
|
||||||
memcpy(box, surf->geometry, sizeof(struct wlr_box));
|
memcpy(box, surf->geometry, sizeof(struct wlr_box));
|
||||||
|
// TODO: real input bounds
|
||||||
|
box->x -= 10;
|
||||||
|
box->y -= 10;
|
||||||
|
box->width += 20;
|
||||||
|
box->height += 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void activate(struct roots_view *view, bool active) {
|
static void activate(struct roots_view *view, bool active) {
|
||||||
|
@ -37,6 +42,19 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||||
view_begin_move(input, event->cursor, view);
|
view_begin_move(input, event->cursor, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
|
wl_container_of(listener, roots_xdg_surface, request_resize);
|
||||||
|
struct roots_view *view = roots_xdg_surface->view;
|
||||||
|
struct roots_input *input = view->desktop->server->input;
|
||||||
|
struct wlr_xdg_toplevel_v6_resize_event *e = data;
|
||||||
|
const struct roots_input_event *event = get_input_event(input, e->serial);
|
||||||
|
if (!event || input->mode != ROOTS_CURSOR_PASSTHROUGH) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
view_begin_resize(input, event->cursor, view);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, destroy);
|
wl_container_of(listener, roots_xdg_surface, destroy);
|
||||||
|
@ -71,6 +89,9 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->request_move.notify = handle_request_move;
|
roots_surface->request_move.notify = handle_request_move;
|
||||||
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
|
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
|
||||||
wl_list_init(&roots_surface->request_resize.link);
|
wl_list_init(&roots_surface->request_resize.link);
|
||||||
|
roots_surface->request_resize.notify = handle_request_resize;
|
||||||
|
wl_signal_add(&surface->events.request_resize,
|
||||||
|
&roots_surface->request_resize);
|
||||||
wl_list_init(&roots_surface->request_show_window_menu.link);
|
wl_list_init(&roots_surface->request_show_window_menu.link);
|
||||||
|
|
||||||
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
||||||
|
|
|
@ -17,7 +17,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
free(roots_surface);
|
free(roots_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_configure(struct wl_listener *listener, void *data) {
|
static void handle_request_configure(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, request_configure);
|
wl_container_of(listener, roots_surface, request_configure);
|
||||||
struct wlr_xwayland_surface *xwayland_surface =
|
struct wlr_xwayland_surface *xwayland_surface =
|
||||||
|
@ -58,7 +58,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->destroy.notify = handle_destroy;
|
roots_surface->destroy.notify = handle_destroy;
|
||||||
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
|
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
|
||||||
wl_list_init(&roots_surface->request_configure.link);
|
wl_list_init(&roots_surface->request_configure.link);
|
||||||
roots_surface->request_configure.notify = handle_configure;
|
roots_surface->request_configure.notify = handle_request_configure;
|
||||||
wl_signal_add(&surface->events.request_configure,
|
wl_signal_add(&surface->events.request_configure,
|
||||||
&roots_surface->request_configure);
|
&roots_surface->request_configure);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue