Add view_impl .close

This commit is contained in:
Johan Malm 2020-09-02 21:00:28 +01:00
parent b99977368d
commit 625722cb66
4 changed files with 19 additions and 4 deletions

View file

@ -106,6 +106,7 @@ enum deco_part {
struct view_impl {
void (*configure)(struct view *view, struct wlr_box geo);
void (*close)(struct view *view);
};
struct view {

View file

@ -198,6 +198,9 @@ void cursor_button(struct wl_listener *listener, void *data)
/* Focus that client if the button was _pressed_ */
view_focus(view);
switch (view_area) {
case LAB_DECO_BUTTON_CLOSE:
view->impl->close(view);
break;
case LAB_DECO_PART_TITLE:
interactive_begin(view, LAB_CURSOR_MOVE, 0);
break;

View file

@ -137,8 +137,14 @@ static void xdg_toplevel_view_configure(struct view *view, struct wlr_box geo)
(uint32_t)geo.height);
}
static void xdg_toplevel_view_close(struct view *view)
{
wlr_xdg_toplevel_send_close(view->xdg_surface);
}
static const struct view_impl xdg_toplevel_view_impl = {
.configure = xdg_toplevel_view_configure,
.close = xdg_toplevel_view_close,
};
void xdg_surface_new(struct wl_listener *listener, void *data)

View file

@ -82,14 +82,19 @@ void xwl_surface_configure(struct wl_listener *listener, void *data)
static void xwl_view_configure(struct view *view, struct wlr_box geo)
{
return wlr_xwayland_surface_configure(view->xwayland_surface,
(int16_t)geo.x, (int16_t)geo.y,
(uint16_t)geo.width,
(uint16_t)geo.height);
wlr_xwayland_surface_configure(view->xwayland_surface, (int16_t)geo.x,
(int16_t)geo.y, (uint16_t)geo.width,
(uint16_t)geo.height);
}
static void xwl_view_close(struct view *view)
{
wlr_xwayland_surface_close(view->xwayland_surface);
}
static const struct view_impl xwl_view_impl = {
.configure = xwl_view_configure,
.close = xwl_view_close,
};
void xwl_surface_new(struct wl_listener *listener, void *data)