Move view creation code into view_create
This commit is contained in:
parent
68eec4ae23
commit
2f4c865afc
3 changed files with 30 additions and 6 deletions
|
@ -53,5 +53,6 @@ void kiwmi_view_for_each_surface(
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
|
||||||
void focus_view(struct kiwmi_view *view, struct wlr_surface *surface);
|
void focus_view(struct kiwmi_view *view, struct wlr_surface *surface);
|
||||||
|
struct kiwmi_view *view_create(struct kiwmi_desktop *desktop, enum kiwmi_view_type type, const struct kiwmi_view_impl *impl);
|
||||||
|
|
||||||
#endif /* KIWMI_DESKTOP_VIEW_H */
|
#endif /* KIWMI_DESKTOP_VIEW_H */
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "desktop/view.h"
|
#include "desktop/view.h"
|
||||||
|
|
||||||
|
#include <wlr/util/log.h>
|
||||||
|
|
||||||
|
#include "desktop/output.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -55,3 +59,26 @@ focus_view(struct kiwmi_view *view, struct wlr_surface *surface)
|
||||||
keyboard->num_keycodes,
|
keyboard->num_keycodes,
|
||||||
&keyboard->modifiers);
|
&keyboard->modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct kiwmi_view *
|
||||||
|
view_create(
|
||||||
|
struct kiwmi_desktop *desktop,
|
||||||
|
enum kiwmi_view_type type,
|
||||||
|
const struct kiwmi_view_impl *impl)
|
||||||
|
{
|
||||||
|
struct kiwmi_view *view = malloc(sizeof(*view));
|
||||||
|
if (!view) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to allocate view");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
view->desktop = desktop;
|
||||||
|
view->type = type;
|
||||||
|
view->impl = impl;
|
||||||
|
view->mapped = false;
|
||||||
|
|
||||||
|
view->x = 0;
|
||||||
|
view->y = 0;
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
|
@ -75,17 +75,13 @@ xdg_shell_new_surface_notify(struct wl_listener *listener, void *data)
|
||||||
|
|
||||||
wlr_xdg_surface_ping(xdg_surface);
|
wlr_xdg_surface_ping(xdg_surface);
|
||||||
|
|
||||||
struct kiwmi_view *view = malloc(sizeof(*view));
|
struct kiwmi_view *view =
|
||||||
|
view_create(desktop, KIWMI_VIEW_XDG_SHELL, &xdg_shell_view_impl);
|
||||||
if (!view) {
|
if (!view) {
|
||||||
wlr_log(WLR_ERROR, "Failed to allocate view");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
view->desktop = desktop;
|
|
||||||
view->type = KIWMI_VIEW_XDG_SHELL;
|
|
||||||
view->impl = &xdg_shell_view_impl;
|
|
||||||
view->xdg_surface = xdg_surface;
|
view->xdg_surface = xdg_surface;
|
||||||
view->mapped = false;
|
|
||||||
|
|
||||||
view->map.notify = xdg_surface_map_notify;
|
view->map.notify = xdg_surface_map_notify;
|
||||||
wl_signal_add(&xdg_surface->events.map, &view->map);
|
wl_signal_add(&xdg_surface->events.map, &view->map);
|
||||||
|
|
Loading…
Reference in a new issue