Unify view events naming, remove client from event structs

This commit is contained in:
emersion 2017-11-21 09:50:00 +01:00
parent a268f57ed5
commit 17d9e2ce35
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
6 changed files with 55 additions and 111 deletions

View File

@ -12,8 +12,8 @@ struct roots_wl_shell_surface {
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener request_move; struct wl_listener request_move;
struct wl_listener request_resize; struct wl_listener request_resize;
struct wl_listener request_set_maximized; struct wl_listener request_maximize;
struct wl_listener request_set_fullscreen; struct wl_listener request_fullscreen;
struct wl_listener set_state; struct wl_listener set_state;
struct wl_listener surface_commit; struct wl_listener surface_commit;

View File

@ -81,8 +81,8 @@ struct wlr_wl_shell_surface {
struct wl_signal request_move; struct wl_signal request_move;
struct wl_signal request_resize; struct wl_signal request_resize;
struct wl_signal request_set_fullscreen; struct wl_signal request_fullscreen;
struct wl_signal request_set_maximized; struct wl_signal request_maximize;
struct wl_signal set_state; struct wl_signal set_state;
struct wl_signal set_title; struct wl_signal set_title;
@ -93,14 +93,12 @@ struct wlr_wl_shell_surface {
}; };
struct wlr_wl_shell_surface_move_event { struct wlr_wl_shell_surface_move_event {
struct wl_client *client;
struct wlr_wl_shell_surface *surface; struct wlr_wl_shell_surface *surface;
struct wlr_seat_client *seat; struct wlr_seat_client *seat;
uint32_t serial; uint32_t serial;
}; };
struct wlr_wl_shell_surface_resize_event { struct wlr_wl_shell_surface_resize_event {
struct wl_client *client;
struct wlr_wl_shell_surface *surface; struct wlr_wl_shell_surface *surface;
struct wlr_seat_client *seat; struct wlr_seat_client *seat;
uint32_t serial; uint32_t serial;
@ -108,15 +106,13 @@ struct wlr_wl_shell_surface_resize_event {
}; };
struct wlr_wl_shell_surface_set_fullscreen_event { struct wlr_wl_shell_surface_set_fullscreen_event {
struct wl_client *client;
struct wlr_wl_shell_surface *surface; struct wlr_wl_shell_surface *surface;
enum wl_shell_surface_fullscreen_method method; enum wl_shell_surface_fullscreen_method method;
uint32_t framerate; uint32_t framerate;
struct wlr_output *output; struct wlr_output *output;
}; };
struct wlr_wl_shell_surface_set_maximized_event { struct wlr_wl_shell_surface_maximize_event {
struct wl_client *client;
struct wlr_wl_shell_surface *surface; struct wlr_wl_shell_surface *surface;
struct wlr_output *output; struct wlr_output *output;
}; };

View File

@ -138,14 +138,12 @@ struct wlr_xdg_surface_v6 {
}; };
struct wlr_xdg_toplevel_v6_move_event { struct wlr_xdg_toplevel_v6_move_event {
struct wl_client *client;
struct wlr_xdg_surface_v6 *surface; struct wlr_xdg_surface_v6 *surface;
struct wlr_seat_client *seat; struct wlr_seat_client *seat;
uint32_t serial; uint32_t serial;
}; };
struct wlr_xdg_toplevel_v6_resize_event { struct wlr_xdg_toplevel_v6_resize_event {
struct wl_client *client;
struct wlr_xdg_surface_v6 *surface; struct wlr_xdg_surface_v6 *surface;
struct wlr_seat_client *seat; struct wlr_seat_client *seat;
uint32_t serial; uint32_t serial;
@ -153,19 +151,16 @@ struct wlr_xdg_toplevel_v6_resize_event {
}; };
struct wlr_xdg_toplevel_v6_set_fullscreen_event { struct wlr_xdg_toplevel_v6_set_fullscreen_event {
struct wl_client *client;
struct wlr_xdg_surface_v6 *surface; struct wlr_xdg_surface_v6 *surface;
bool fullscreen; bool fullscreen;
struct wlr_output *output; struct wlr_output *output;
}; };
struct wlr_xdg_toplevel_v6_show_window_menu_event { struct wlr_xdg_toplevel_v6_show_window_menu_event {
struct wl_client *client;
struct wlr_xdg_surface_v6 *surface; struct wlr_xdg_surface_v6 *surface;
struct wlr_seat_client *seat; struct wlr_seat_client *seat;
uint32_t serial; uint32_t serial;
uint32_t x; uint32_t x, y;
uint32_t y;
}; };
struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display); struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display);

View File

@ -50,23 +50,21 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
roots_seat_begin_resize(seat, view, e->edges); roots_seat_begin_resize(seat, view, e->edges);
} }
static void handle_request_set_maximized(struct wl_listener *listener, static void handle_request_maximize(struct wl_listener *listener,
void *data) { void *data) {
struct roots_wl_shell_surface *roots_surface = struct roots_wl_shell_surface *roots_surface =
wl_container_of(listener, roots_surface, request_set_maximized); wl_container_of(listener, roots_surface, request_maximize);
struct roots_view *view = roots_surface->view; struct roots_view *view = roots_surface->view;
//struct wlr_wl_shell_surface_set_maximized_event *e = data; //struct wlr_wl_shell_surface_maximize_event *e = data;
view_maximize(view, true); view_maximize(view, true);
} }
static void handle_request_set_fullscreen(struct wl_listener *listener, static void handle_request_fullscreen(struct wl_listener *listener,
void *data) { void *data) {
struct roots_wl_shell_surface *roots_surface = struct roots_wl_shell_surface *roots_surface =
wl_container_of(listener, roots_surface, request_set_fullscreen); wl_container_of(listener, roots_surface, request_fullscreen);
struct roots_view *view = roots_surface->view; struct roots_view *view = roots_surface->view;
struct wlr_wl_shell_surface_set_fullscreen_event *e = data; struct wlr_wl_shell_surface_set_fullscreen_event *e = data;
// TODO: support e->method, e->framerate
view_set_fullscreen(view, true, e->output); view_set_fullscreen(view, true, e->output);
} }
@ -95,8 +93,8 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
wl_list_remove(&roots_surface->destroy.link); wl_list_remove(&roots_surface->destroy.link);
wl_list_remove(&roots_surface->request_move.link); wl_list_remove(&roots_surface->request_move.link);
wl_list_remove(&roots_surface->request_resize.link); wl_list_remove(&roots_surface->request_resize.link);
wl_list_remove(&roots_surface->request_set_maximized.link); wl_list_remove(&roots_surface->request_maximize.link);
wl_list_remove(&roots_surface->request_set_fullscreen.link); wl_list_remove(&roots_surface->request_fullscreen.link);
wl_list_remove(&roots_surface->set_state.link); wl_list_remove(&roots_surface->set_state.link);
wl_list_remove(&roots_surface->surface_commit.link); wl_list_remove(&roots_surface->surface_commit.link);
wl_list_remove(&roots_surface->view->link); wl_list_remove(&roots_surface->view->link);
@ -125,13 +123,13 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
roots_surface->request_resize.notify = handle_request_resize; roots_surface->request_resize.notify = handle_request_resize;
wl_signal_add(&surface->events.request_resize, wl_signal_add(&surface->events.request_resize,
&roots_surface->request_resize); &roots_surface->request_resize);
roots_surface->request_set_maximized.notify = handle_request_set_maximized; roots_surface->request_maximize.notify = handle_request_maximize;
wl_signal_add(&surface->events.request_set_maximized, wl_signal_add(&surface->events.request_maximize,
&roots_surface->request_set_maximized); &roots_surface->request_maximize);
roots_surface->request_set_fullscreen.notify = roots_surface->request_fullscreen.notify =
handle_request_set_fullscreen; handle_request_fullscreen;
wl_signal_add(&surface->events.request_set_fullscreen, wl_signal_add(&surface->events.request_fullscreen,
&roots_surface->request_set_fullscreen); &roots_surface->request_fullscreen);
roots_surface->set_state.notify = handle_set_state; roots_surface->set_state.notify = handle_set_state;
wl_signal_add(&surface->events.set_state, &roots_surface->set_state); wl_signal_add(&surface->events.set_state, &roots_surface->set_state);
roots_surface->surface_commit.notify = handle_surface_commit; roots_surface->surface_commit.notify = handle_surface_commit;

View File

@ -108,25 +108,17 @@ static void shell_surface_protocol_pong(struct wl_client *client,
static void shell_surface_protocol_move(struct wl_client *client, static void shell_surface_protocol_move(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *seat_resource, struct wl_resource *resource, struct wl_resource *seat_resource,
uint32_t serial) { uint32_t serial) {
wlr_log(L_DEBUG, "got shell surface move");
struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource);
struct wlr_seat_client *seat = struct wlr_seat_client *seat =
wl_resource_get_user_data(seat_resource); wl_resource_get_user_data(seat_resource);
struct wlr_wl_shell_surface_move_event *event = struct wlr_wl_shell_surface_move_event event = {
calloc(1, sizeof(struct wlr_wl_shell_surface_move_event)); .surface = surface,
if (event == NULL) { .seat = seat,
wl_client_post_no_memory(client); .serial = serial,
return; };
}
event->client = client;
event->surface = surface;
event->seat = seat;
event->serial = serial;
wl_signal_emit(&surface->events.request_move, event); wl_signal_emit(&surface->events.request_move, &event);
free(event);
} }
static struct wlr_wl_shell_popup_grab *shell_popup_grab_from_seat( static struct wlr_wl_shell_popup_grab *shell_popup_grab_from_seat(
@ -174,26 +166,18 @@ static void shell_surface_destroy_popup_state(
static void shell_surface_protocol_resize(struct wl_client *client, static void shell_surface_protocol_resize(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *seat_resource, struct wl_resource *resource, struct wl_resource *seat_resource,
uint32_t serial, enum wl_shell_surface_resize edges) { uint32_t serial, enum wl_shell_surface_resize edges) {
wlr_log(L_DEBUG, "got shell surface resize");
struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource);
struct wlr_seat_client *seat = struct wlr_seat_client *seat =
wl_resource_get_user_data(seat_resource); wl_resource_get_user_data(seat_resource);
struct wlr_wl_shell_surface_resize_event *event = struct wlr_wl_shell_surface_resize_event event = {
calloc(1, sizeof(struct wlr_wl_shell_surface_resize_event)); .surface = surface,
if (event == NULL) { .seat = seat,
wl_client_post_no_memory(client); .serial = serial,
return; .edges = edges,
} };
event->client = client;
event->surface = surface;
event->seat = seat;
event->serial = serial;
event->edges = edges;
wl_signal_emit(&surface->events.request_resize, event); wl_signal_emit(&surface->events.request_resize, &event);
free(event);
} }
static void shell_surface_set_state(struct wlr_wl_shell_surface *surface, static void shell_surface_set_state(struct wlr_wl_shell_surface *surface,
@ -279,7 +263,6 @@ static void shell_surface_protocol_set_fullscreen(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
enum wl_shell_surface_fullscreen_method method, uint32_t framerate, enum wl_shell_surface_fullscreen_method method, uint32_t framerate,
struct wl_resource *output_resource) { struct wl_resource *output_resource) {
wlr_log(L_DEBUG, "got shell surface fullscreen");
struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource);
struct wlr_output *output = NULL; struct wlr_output *output = NULL;
if (output_resource != NULL) { if (output_resource != NULL) {
@ -289,24 +272,16 @@ static void shell_surface_protocol_set_fullscreen(struct wl_client *client,
shell_surface_set_state(surface, WLR_WL_SHELL_SURFACE_STATE_FULLSCREEN, shell_surface_set_state(surface, WLR_WL_SHELL_SURFACE_STATE_FULLSCREEN,
NULL, NULL); NULL, NULL);
struct wlr_wl_shell_surface_set_fullscreen_event *event = struct wlr_wl_shell_surface_set_fullscreen_event event = {
calloc(1, sizeof(struct wlr_wl_shell_surface_set_fullscreen_event)); .surface = surface,
if (event == NULL) { .method = method,
wl_client_post_no_memory(client); .framerate = framerate,
return; .output = output,
} };
event->client = client;
event->surface = surface;
event->method = method;
event->framerate = framerate;
event->output = output;
wl_signal_emit(&surface->events.request_set_fullscreen, event); wl_signal_emit(&surface->events.request_fullscreen, &event);
free(event);
} }
static void shell_surface_protocol_set_popup(struct wl_client *client, static void shell_surface_protocol_set_popup(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *seat_resource, struct wl_resource *resource, struct wl_resource *seat_resource,
uint32_t serial, struct wl_resource *parent_resource, int32_t x, uint32_t serial, struct wl_resource *parent_resource, int32_t x,
@ -368,7 +343,6 @@ static void shell_surface_protocol_set_popup(struct wl_client *client,
static void shell_surface_protocol_set_maximized(struct wl_client *client, static void shell_surface_protocol_set_maximized(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *output_resource) { struct wl_resource *resource, struct wl_resource *output_resource) {
wlr_log(L_DEBUG, "got shell surface maximized");
struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource);
struct wlr_output *output = NULL; struct wlr_output *output = NULL;
if (output_resource != NULL) { if (output_resource != NULL) {
@ -378,19 +352,12 @@ static void shell_surface_protocol_set_maximized(struct wl_client *client,
shell_surface_set_state(surface, WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED, shell_surface_set_state(surface, WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED,
NULL, NULL); NULL, NULL);
struct wlr_wl_shell_surface_set_maximized_event *event = struct wlr_wl_shell_surface_maximize_event event = {
calloc(1, sizeof(struct wlr_wl_shell_surface_set_maximized_event)); .surface = surface,
if (event == NULL) { .output = output,
wl_client_post_no_memory(client); };
return;
}
event->client = client;
event->surface = surface;
event->output = output;
wl_signal_emit(&surface->events.request_set_maximized, event); wl_signal_emit(&surface->events.request_maximize, &event);
free(event);
} }
static void shell_surface_protocol_set_title(struct wl_client *client, static void shell_surface_protocol_set_title(struct wl_client *client,
@ -545,8 +512,8 @@ static void shell_protocol_get_shell_surface(struct wl_client *client,
wl_signal_init(&wl_surface->events.ping_timeout); wl_signal_init(&wl_surface->events.ping_timeout);
wl_signal_init(&wl_surface->events.request_move); wl_signal_init(&wl_surface->events.request_move);
wl_signal_init(&wl_surface->events.request_resize); wl_signal_init(&wl_surface->events.request_resize);
wl_signal_init(&wl_surface->events.request_set_fullscreen); wl_signal_init(&wl_surface->events.request_fullscreen);
wl_signal_init(&wl_surface->events.request_set_maximized); wl_signal_init(&wl_surface->events.request_maximize);
wl_signal_init(&wl_surface->events.set_state); wl_signal_init(&wl_surface->events.set_state);
wl_signal_init(&wl_surface->events.set_title); wl_signal_init(&wl_surface->events.set_title);
wl_signal_init(&wl_surface->events.set_class); wl_signal_init(&wl_surface->events.set_class);

View File

@ -564,23 +564,15 @@ static void xdg_toplevel_protocol_show_window_menu(struct wl_client *client,
return; return;
} }
struct wlr_xdg_toplevel_v6_show_window_menu_event *event = struct wlr_xdg_toplevel_v6_show_window_menu_event event = {
calloc(1, sizeof(struct wlr_xdg_toplevel_v6_show_window_menu_event)); .surface = surface,
if (event == NULL) { .seat = seat,
wl_client_post_no_memory(client); .serial = serial,
return; .x = x,
} .y = y,
};
event->client = client; wl_signal_emit(&surface->events.request_show_window_menu, &event);
event->surface = surface;
event->seat = seat;
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, static void xdg_toplevel_protocol_move(struct wl_client *client,
@ -598,7 +590,6 @@ static void xdg_toplevel_protocol_move(struct wl_client *client,
} }
struct wlr_xdg_toplevel_v6_move_event event = { struct wlr_xdg_toplevel_v6_move_event event = {
.client = client,
.surface = surface, .surface = surface,
.seat = seat, .seat = seat,
.serial = serial, .serial = serial,
@ -622,7 +613,6 @@ static void xdg_toplevel_protocol_resize(struct wl_client *client,
} }
struct wlr_xdg_toplevel_v6_resize_event event = { struct wlr_xdg_toplevel_v6_resize_event event = {
.client = client,
.surface = surface, .surface = surface,
.seat = seat, .seat = seat,
.serial = serial, .serial = serial,
@ -672,7 +662,6 @@ static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
surface->toplevel_state->next.fullscreen = true; surface->toplevel_state->next.fullscreen = true;
struct wlr_xdg_toplevel_v6_set_fullscreen_event event = { struct wlr_xdg_toplevel_v6_set_fullscreen_event event = {
.client = client,
.surface = surface, .surface = surface,
.fullscreen = true, .fullscreen = true,
.output = output, .output = output,
@ -688,7 +677,6 @@ static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
surface->toplevel_state->next.fullscreen = false; surface->toplevel_state->next.fullscreen = false;
struct wlr_xdg_toplevel_v6_set_fullscreen_event event = { struct wlr_xdg_toplevel_v6_set_fullscreen_event event = {
.client = client,
.surface = surface, .surface = surface,
.fullscreen = false, .fullscreen = false,
.output = NULL, .output = NULL,