diff options
-rw-r--r-- | include/wlr/types/wlr_xdg_shell_v6.h | 30 | ||||
-rw-r--r-- | types/wlr_xdg_shell_v6.c | 71 |
2 files changed, 95 insertions, 6 deletions
diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 7c912370..3e404b6d 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -77,15 +77,43 @@ struct wlr_xdg_surface_v6 { struct wl_listener surface_commit_listener; struct { - struct wl_signal request_minimize; struct wl_signal commit; struct wl_signal destroy; struct wl_signal ack_configure; + + struct wl_signal request_minimize; + struct wl_signal request_move; + struct wl_signal request_resize; + struct wl_signal request_show_window_menu; } events; void *data; }; +struct wlr_xdg_toplevel_v6_move_event { + struct wl_client *client; + struct wlr_xdg_surface_v6 *surface; + struct wlr_seat_handle *seat_handle; + uint32_t serial; +}; + +struct wlr_xdg_toplevel_v6_resize_event { + struct wl_client *client; + struct wlr_xdg_surface_v6 *surface; + struct wlr_seat_handle *seat_handle; + uint32_t serial; + uint32_t edges; +}; + +struct wlr_xdg_toplevel_v6_show_window_menu_event { + struct wl_client *client; + struct wlr_xdg_surface_v6 *surface; + struct wlr_seat_handle *seat_handle; + uint32_t serial; + uint32_t x; + uint32_t y; +}; + struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display); void wlr_xdg_shell_v6_destroy(struct wlr_xdg_shell_v6 *xdg_shell); diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index d32990db..8c101020 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -7,6 +7,7 @@ #include <wayland-server.h> #include <wlr/types/wlr_xdg_shell_v6.h> #include <wlr/types/wlr_surface.h> +#include <wlr/types/wlr_seat.h> #include <wlr/util/log.h> #include "xdg-shell-unstable-v6-protocol.h" @@ -52,21 +53,78 @@ static void xdg_toplevel_protocol_set_app_id(struct wl_client *client, } static void xdg_toplevel_protocol_show_window_menu(struct wl_client *client, - struct wl_resource *resource, struct wl_resource *seat, uint32_t serial, - int32_t x, int32_t y) { - wlr_log(L_DEBUG, "TODO: toplevel show window menu"); + struct wl_resource *resource, struct wl_resource *seat_resource, + uint32_t serial, int32_t x, int32_t y) { + struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); + struct wlr_seat_handle *seat_handle = + wl_resource_get_user_data(seat_resource); + + struct wlr_xdg_toplevel_v6_show_window_menu_event *event = + calloc(1, sizeof(struct wlr_xdg_toplevel_v6_show_window_menu_event)); + if (event == NULL) { + wl_client_post_no_memory(client); + return; + } + + event->client = client; + event->surface = surface; + event->seat_handle = seat_handle; + event->serial = serial; + event->x = x; + event->y = y; + + wl_signal_emit(&surface->events.request_show_window_menu, event); + + free(event); } static void xdg_toplevel_protocol_move(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat_resource, uint32_t serial) { - wlr_log(L_DEBUG, "TODO: toplevel move"); + struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); + struct wlr_seat_handle *seat_handle = + wl_resource_get_user_data(seat_resource); + + struct wlr_xdg_toplevel_v6_move_event *event = + calloc(1, sizeof(struct wlr_xdg_toplevel_v6_move_event)); + if (event == NULL) { + wl_client_post_no_memory(client); + return; + } + + event->client = client; + event->surface = surface; + event->seat_handle = seat_handle; + event->serial = serial; + + wl_signal_emit(&surface->events.request_move, event); + + free(event); } static void xdg_toplevel_protocol_resize(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat_resource, uint32_t serial, uint32_t edges) { - wlr_log(L_DEBUG, "TODO: toplevel resize"); + struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); + struct wlr_seat_handle *seat_handle = + wl_resource_get_user_data(seat_resource); + + struct wlr_xdg_toplevel_v6_resize_event *event = + calloc(1, sizeof(struct wlr_xdg_toplevel_v6_resize_event)); + if (event == NULL) { + wl_client_post_no_memory(client); + return; + } + + event->client = client; + event->surface = surface; + event->seat_handle = seat_handle; + event->serial = serial; + event->edges = edges; + + wl_signal_emit(&surface->events.request_resize, event); + + free(event); } static void xdg_toplevel_protocol_set_max_size(struct wl_client *client, @@ -458,6 +516,9 @@ static void xdg_shell_get_xdg_surface(struct wl_client *client, wl_list_init(&surface->configure_list); wl_signal_init(&surface->events.request_minimize); + wl_signal_init(&surface->events.request_move); + wl_signal_init(&surface->events.request_resize); + wl_signal_init(&surface->events.request_show_window_menu); wl_signal_init(&surface->events.commit); wl_signal_init(&surface->events.destroy); wl_signal_init(&surface->events.ack_configure); |