mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
Center wl shell views
This commit is contained in:
parent
3c6f2f29bf
commit
3774d6c2c0
2 changed files with 26 additions and 2 deletions
|
@ -15,6 +15,10 @@ struct roots_wl_shell_surface {
|
||||||
struct wl_listener request_resize;
|
struct wl_listener request_resize;
|
||||||
struct wl_listener request_set_fullscreen;
|
struct wl_listener request_set_fullscreen;
|
||||||
struct wl_listener request_set_maximized;
|
struct wl_listener request_set_maximized;
|
||||||
|
|
||||||
|
struct wl_listener surface_commit;
|
||||||
|
|
||||||
|
bool initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct roots_xdg_surface_v6 {
|
struct roots_xdg_surface_v6 {
|
||||||
|
|
|
@ -49,6 +49,19 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
view_begin_resize(input, event->cursor, view, e->edges);
|
view_begin_resize(input, event->cursor, view, e->edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
||||||
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
|
wl_container_of(listener, roots_surface, surface_commit);
|
||||||
|
struct roots_view *view = roots_surface->view;
|
||||||
|
|
||||||
|
if (!roots_surface->initialized) {
|
||||||
|
bool centered = view_center(view);
|
||||||
|
if (centered) {
|
||||||
|
roots_surface->initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
static void handle_destroy(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, destroy);
|
wl_container_of(listener, roots_surface, destroy);
|
||||||
|
@ -73,7 +86,9 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
calloc(1, sizeof(struct roots_wl_shell_surface));
|
calloc(1, sizeof(struct roots_wl_shell_surface));
|
||||||
// TODO: all of the trimmings
|
if (!roots_surface) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
wl_list_init(&roots_surface->destroy.link);
|
wl_list_init(&roots_surface->destroy.link);
|
||||||
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);
|
||||||
|
@ -83,9 +98,14 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
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;
|
roots_surface->request_resize.notify = handle_request_resize;
|
||||||
wl_signal_add(&surface->events.request_resize, &roots_surface->request_resize);
|
wl_signal_add(&surface->events.request_resize,
|
||||||
|
&roots_surface->request_resize);
|
||||||
wl_list_init(&roots_surface->request_set_fullscreen.link);
|
wl_list_init(&roots_surface->request_set_fullscreen.link);
|
||||||
wl_list_init(&roots_surface->request_set_maximized.link);
|
wl_list_init(&roots_surface->request_set_maximized.link);
|
||||||
|
wl_list_init(&roots_surface->surface_commit.link);
|
||||||
|
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||||
|
wl_signal_add(&surface->surface->signals.commit,
|
||||||
|
&roots_surface->surface_commit);
|
||||||
|
|
||||||
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
||||||
view->type = ROOTS_WL_SHELL_VIEW;
|
view->type = ROOTS_WL_SHELL_VIEW;
|
||||||
|
|
Loading…
Reference in a new issue