mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
use wlr_surface on shell struct and listen to events
This commit is contained in:
parent
b2c71287f2
commit
9d2dc8447a
3 changed files with 16 additions and 6 deletions
|
@ -102,7 +102,7 @@ static void handle_output_frame(struct output_state *output,
|
||||||
struct wlr_xdg_surface_v6 *xdg_surface;
|
struct wlr_xdg_surface_v6 *xdg_surface;
|
||||||
wl_list_for_each(xdg_surface, &sample->xdg_shell->surfaces, link) {
|
wl_list_for_each(xdg_surface, &sample->xdg_shell->surfaces, link) {
|
||||||
output_frame_handle_surface(sample, wlr_output, ts,
|
output_frame_handle_surface(sample, wlr_output, ts,
|
||||||
xdg_surface->surface);
|
xdg_surface->surface->resource);
|
||||||
}
|
}
|
||||||
struct wlr_x11_window *x11_window;
|
struct wlr_x11_window *x11_window;
|
||||||
wl_list_for_each(x11_window, &sample->xwayland->displayable_windows, link) {
|
wl_list_for_each(x11_window, &sample->xwayland->displayable_windows, link) {
|
||||||
|
|
|
@ -18,11 +18,12 @@ enum wlr_xdg_surface_v6_role {
|
||||||
|
|
||||||
struct wlr_xdg_surface_v6 {
|
struct wlr_xdg_surface_v6 {
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
struct wl_resource *surface;
|
struct wlr_surface *surface;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
enum wlr_xdg_surface_v6_role role;
|
enum wlr_xdg_surface_v6_role role;
|
||||||
|
|
||||||
struct wl_listener surface_destroy_listener;
|
struct wl_listener surface_destroy_listener;
|
||||||
|
struct wl_listener surface_commit_listener;
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
|
@ -104,6 +104,7 @@ static void xdg_surface_destroy(struct wlr_xdg_surface_v6 *surface) {
|
||||||
wl_resource_set_user_data(surface->resource, NULL);
|
wl_resource_set_user_data(surface->resource, NULL);
|
||||||
wl_list_remove(&surface->link);
|
wl_list_remove(&surface->link);
|
||||||
wl_list_remove(&surface->surface_destroy_listener.link);
|
wl_list_remove(&surface->surface_destroy_listener.link);
|
||||||
|
wl_list_remove(&surface->surface_commit_listener.link);
|
||||||
free(surface);
|
free(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,9 +119,8 @@ static void xdg_surface_get_toplevel(struct wl_client *client,
|
||||||
struct wl_resource *resource, uint32_t id) {
|
struct wl_resource *resource, uint32_t id) {
|
||||||
// TODO: Flesh out
|
// TODO: Flesh out
|
||||||
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
||||||
struct wlr_surface *wsurface = wl_resource_get_user_data(surface->surface);
|
|
||||||
|
|
||||||
if (wlr_surface_set_role(wsurface, wlr_desktop_xdg_toplevel_role,
|
if (wlr_surface_set_role(surface->surface, wlr_desktop_xdg_toplevel_role,
|
||||||
resource, ZXDG_SHELL_V6_ERROR_ROLE)) {
|
resource, ZXDG_SHELL_V6_ERROR_ROLE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -173,6 +173,11 @@ static void handle_wlr_surface_destroyed(struct wl_listener *listener,
|
||||||
xdg_surface_destroy(xdg_surface);
|
xdg_surface_destroy(xdg_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_wlr_surface_committed(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
wlr_log(L_DEBUG, "TODO: handle wlr surface committed");
|
||||||
|
}
|
||||||
|
|
||||||
static void xdg_shell_get_xdg_surface(struct wl_client *client,
|
static void xdg_shell_get_xdg_surface(struct wl_client *client,
|
||||||
struct wl_resource *_xdg_shell, uint32_t id,
|
struct wl_resource *_xdg_shell, uint32_t id,
|
||||||
struct wl_resource *_surface) {
|
struct wl_resource *_surface) {
|
||||||
|
@ -182,14 +187,18 @@ static void xdg_shell_get_xdg_surface(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
surface->role = WLR_XDG_SURFACE_V6_ROLE_NONE;
|
surface->role = WLR_XDG_SURFACE_V6_ROLE_NONE;
|
||||||
surface->surface = _surface;
|
surface->surface = wl_resource_get_user_data(_surface);
|
||||||
surface->resource = wl_resource_create(client,
|
surface->resource = wl_resource_create(client,
|
||||||
&zxdg_surface_v6_interface, wl_resource_get_version(_xdg_shell), id);
|
&zxdg_surface_v6_interface, wl_resource_get_version(_xdg_shell), id);
|
||||||
|
|
||||||
wl_signal_add(&_surface->destroy_signal,
|
wl_signal_add(&surface->surface->signals.destroy,
|
||||||
&surface->surface_destroy_listener);
|
&surface->surface_destroy_listener);
|
||||||
surface->surface_destroy_listener.notify = handle_wlr_surface_destroyed;
|
surface->surface_destroy_listener.notify = handle_wlr_surface_destroyed;
|
||||||
|
|
||||||
|
wl_signal_add(&surface->surface->signals.commit,
|
||||||
|
&surface->surface_commit_listener);
|
||||||
|
surface->surface_commit_listener.notify = handle_wlr_surface_committed;
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "new xdg_surface %p (res %p)", surface, surface->resource);
|
wlr_log(L_DEBUG, "new xdg_surface %p (res %p)", surface, surface->resource);
|
||||||
wl_resource_set_implementation(surface->resource,
|
wl_resource_set_implementation(surface->resource,
|
||||||
&zxdg_surface_v6_implementation, surface, xdg_surface_resource_destroy);
|
&zxdg_surface_v6_implementation, surface, xdg_surface_resource_destroy);
|
||||||
|
|
Loading…
Reference in a new issue