mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-23 06:59:44 -05:00
Merge pull request #524 from acrisci/role-committed
[wip] Role committed
This commit is contained in:
commit
a79dc7df51
12 changed files with 50 additions and 44 deletions
|
|
@ -651,7 +651,7 @@ static void wlr_drag_icon_destroy(struct wlr_drag_icon *icon) {
|
|||
return;
|
||||
}
|
||||
wl_signal_emit(&icon->events.destroy, icon);
|
||||
wl_list_remove(&icon->surface_commit.link);
|
||||
wlr_surface_set_role_committed(icon->surface, NULL, NULL);
|
||||
wl_list_remove(&icon->surface_destroy.link);
|
||||
wl_list_remove(&icon->seat_client_destroy.link);
|
||||
wl_list_remove(&icon->link);
|
||||
|
|
@ -665,10 +665,9 @@ static void handle_drag_icon_surface_destroy(struct wl_listener *listener,
|
|||
wlr_drag_icon_destroy(icon);
|
||||
}
|
||||
|
||||
static void handle_drag_icon_surface_commit(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct wlr_drag_icon *icon =
|
||||
wl_container_of(listener, icon, surface_commit);
|
||||
static void handle_drag_icon_surface_commit(struct wlr_surface *surface,
|
||||
void *role_data) {
|
||||
struct wlr_drag_icon *icon = role_data;
|
||||
icon->sx += icon->surface->current->sx;
|
||||
icon->sy += icon->surface->current->sy;
|
||||
}
|
||||
|
|
@ -701,8 +700,8 @@ static struct wlr_drag_icon *wlr_drag_icon_create(
|
|||
wl_signal_add(&icon->surface->events.destroy, &icon->surface_destroy);
|
||||
icon->surface_destroy.notify = handle_drag_icon_surface_destroy;
|
||||
|
||||
wl_signal_add(&icon->surface->events.commit, &icon->surface_commit);
|
||||
icon->surface_commit.notify = handle_drag_icon_surface_commit;
|
||||
wlr_surface_set_role_committed(icon->surface,
|
||||
handle_drag_icon_surface_commit, icon);
|
||||
|
||||
wl_signal_add(&client->events.destroy, &icon->seat_client_destroy);
|
||||
icon->seat_client_destroy.notify = handle_drag_icon_seat_client_destroy;
|
||||
|
|
|
|||
|
|
@ -428,6 +428,10 @@ static void wlr_surface_commit_pending(struct wlr_surface *surface) {
|
|||
}
|
||||
}
|
||||
|
||||
if (surface->role_committed) {
|
||||
surface->role_committed(surface, surface->role_data);
|
||||
}
|
||||
|
||||
// TODO: add the invalid bitfield to this callback
|
||||
wl_signal_emit(&surface->events.commit, surface);
|
||||
}
|
||||
|
|
@ -943,3 +947,10 @@ void wlr_surface_send_frame_done(struct wlr_surface *surface,
|
|||
wl_resource_destroy(cb->resource);
|
||||
}
|
||||
}
|
||||
|
||||
void wlr_surface_set_role_committed(struct wlr_surface *surface,
|
||||
void (*role_committed)(struct wlr_surface *surface, void *role_data),
|
||||
void *role_data) {
|
||||
surface->role_committed = role_committed;
|
||||
surface->role_data = role_data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ static void shell_surface_destroy(struct wlr_wl_shell_surface *surface) {
|
|||
|
||||
wl_list_remove(&surface->link);
|
||||
wl_list_remove(&surface->surface_destroy_listener.link);
|
||||
wl_list_remove(&surface->surface_commit_listener.link);
|
||||
wlr_surface_set_role_committed(surface->surface, NULL, NULL);
|
||||
wl_event_source_remove(surface->ping_timer);
|
||||
free(surface->transient_state);
|
||||
free(surface->title);
|
||||
|
|
@ -439,10 +439,9 @@ static void handle_wlr_surface_destroyed(struct wl_listener *listener,
|
|||
wl_container_of(listener, surface, surface_destroy_listener);
|
||||
shell_surface_destroy(surface);
|
||||
}
|
||||
static void handle_wlr_surface_committed(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct wlr_wl_shell_surface *surface =
|
||||
wl_container_of(listener, surface, surface_commit_listener);
|
||||
static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface,
|
||||
void *role_data) {
|
||||
struct wlr_wl_shell_surface *surface = role_data;
|
||||
if (!surface->configured &&
|
||||
wlr_surface_has_buffer(surface->surface) &&
|
||||
surface->state != WLR_WL_SHELL_SURFACE_STATE_NONE) {
|
||||
|
|
@ -459,8 +458,6 @@ static void handle_wlr_surface_committed(struct wl_listener *listener,
|
|||
surface->popup_state->seat);
|
||||
shell_pointer_grab_maybe_end(&grab->pointer_grab);
|
||||
}
|
||||
|
||||
wl_signal_emit(&surface->events.commit, surface);
|
||||
}
|
||||
|
||||
static int shell_surface_ping_timeout(void *user_data) {
|
||||
|
|
@ -511,7 +508,6 @@ static void shell_protocol_get_shell_surface(struct wl_client *client,
|
|||
wl_surface->resource);
|
||||
|
||||
wl_signal_init(&wl_surface->events.destroy);
|
||||
wl_signal_init(&wl_surface->events.commit);
|
||||
wl_signal_init(&wl_surface->events.ping_timeout);
|
||||
wl_signal_init(&wl_surface->events.request_move);
|
||||
wl_signal_init(&wl_surface->events.request_resize);
|
||||
|
|
@ -525,9 +521,8 @@ static void shell_protocol_get_shell_surface(struct wl_client *client,
|
|||
&wl_surface->surface_destroy_listener);
|
||||
wl_surface->surface_destroy_listener.notify = handle_wlr_surface_destroyed;
|
||||
|
||||
wl_signal_add(&wl_surface->surface->events.commit,
|
||||
&wl_surface->surface_commit_listener);
|
||||
wl_surface->surface_commit_listener.notify = handle_wlr_surface_committed;
|
||||
wlr_surface_set_role_committed(surface, handle_wlr_surface_committed,
|
||||
wl_surface);
|
||||
|
||||
struct wl_display *display = wl_client_get_display(client);
|
||||
struct wl_event_loop *loop = wl_display_get_event_loop(display);
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ static void xdg_surface_destroy(struct wlr_xdg_surface_v6 *surface) {
|
|||
wl_resource_set_user_data(surface->resource, NULL);
|
||||
wl_list_remove(&surface->link);
|
||||
wl_list_remove(&surface->surface_destroy_listener.link);
|
||||
wl_list_remove(&surface->surface_commit_listener.link);
|
||||
wlr_surface_set_role_committed(surface->surface, NULL, NULL);
|
||||
free(surface->geometry);
|
||||
free(surface->next_geometry);
|
||||
free(surface->title);
|
||||
|
|
@ -1048,10 +1048,9 @@ static void wlr_xdg_surface_v6_popup_committed(
|
|||
}
|
||||
}
|
||||
|
||||
static void handle_wlr_surface_committed(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct wlr_xdg_surface_v6 *surface =
|
||||
wl_container_of(listener, surface, surface_commit_listener);
|
||||
static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface,
|
||||
void *role_data) {
|
||||
struct wlr_xdg_surface_v6 *surface = role_data;
|
||||
|
||||
if (wlr_surface_has_buffer(surface->surface) && !surface->configured) {
|
||||
wl_resource_post_error(surface->resource,
|
||||
|
|
@ -1086,8 +1085,6 @@ static void handle_wlr_surface_committed(struct wl_listener *listener,
|
|||
surface->added = true;
|
||||
wl_signal_emit(&surface->client->shell->events.new_surface, surface);
|
||||
}
|
||||
|
||||
wl_signal_emit(&surface->events.commit, surface);
|
||||
}
|
||||
|
||||
static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
||||
|
|
@ -1149,7 +1146,6 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
|||
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.ping_timeout);
|
||||
|
||||
|
|
@ -1157,9 +1153,8 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
|||
&surface->surface_destroy_listener);
|
||||
surface->surface_destroy_listener.notify = handle_wlr_surface_destroyed;
|
||||
|
||||
wl_signal_add(&surface->surface->events.commit,
|
||||
&surface->surface_commit_listener);
|
||||
surface->surface_commit_listener.notify = handle_wlr_surface_committed;
|
||||
wlr_surface_set_role_committed(surface->surface,
|
||||
handle_wlr_surface_committed, surface);
|
||||
|
||||
wlr_log(L_DEBUG, "new xdg_surface %p (res %p)", surface, surface->resource);
|
||||
wl_resource_set_implementation(surface->resource,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue