]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add view_impl .close
authorJohan Malm <jgm323@gmail.com>
Wed, 2 Sep 2020 20:00:28 +0000 (21:00 +0100)
committerJohan Malm <jgm323@gmail.com>
Wed, 2 Sep 2020 20:00:28 +0000 (21:00 +0100)
include/labwc.h
src/cursor.c
src/xdg.c
src/xwl.c

index cbcabafd504baebf08ddb48be4eb3d7752ceac9b..ed8b2a07ecbcadb04f48a6235ce3d2842914edc4 100644 (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 {
index bde8183989cc6a8e2da8fccffdbd69caa81b8e29..5c0abc3708781c90131bd4cf049b147e06ef6aa5 100644 (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;
index 5129c1a6bffdaf72c265113eb7b877bc6d12cb03..81cbe703f5e77c0d760249f58699502eb89033e9 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -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)
index 91925446527d3c25bbdf4ff2b09ab721f88d593e..960dc960acf7a760d323d37263d25a59f49b2118 100644 (file)
--- a/src/xwl.c
+++ b/src/xwl.c
@@ -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)