commit 7b3b1a777a817f8eaae3c527de4473239f667d9f
parent 9471ef55526f246a02fa1a2fe6ec49ad08f063f0
Author: deurzen <max@deurzen.net>
Date: Fri, 27 May 2022 19:16:00 +0200
implements view unmap/destroy handling
Diffstat:
9 files changed, 54 insertions(+), 20 deletions(-)
diff --git a/include/kranewl/model.hh b/include/kranewl/model.hh
@@ -51,6 +51,7 @@ public:
#endif
void register_view(View_ptr);
void unregister_view(View_ptr);
+ void destroy_view(View_ptr);
void map_view(View_ptr);
void unmap_view(View_ptr);
diff --git a/include/kranewl/tree/view.hh b/include/kranewl/tree/view.hh
@@ -75,6 +75,7 @@ typedef struct View {
virtual void focus(bool) = 0;
virtual void moveresize(Region const&, Extents const&, bool) = 0;
+ virtual void kill() = 0;
static bool
is_free(View_ptr view)
diff --git a/include/kranewl/tree/xdg_view.hh b/include/kranewl/tree/xdg_view.hh
@@ -24,6 +24,7 @@ typedef struct XDGView final : public View {
void focus(bool) override;
void moveresize(Region const&, Extents const&, bool) override;
+ void kill() override;
static void handle_foreign_activate_request(struct wl_listener*, void*);
static void handle_foreign_fullscreen_request(struct wl_listener*, void*);
diff --git a/include/kranewl/tree/xwayland_view.hh b/include/kranewl/tree/xwayland_view.hh
@@ -23,6 +23,7 @@ typedef struct XWaylandView final : public View {
void focus(bool) override;
void moveresize(Region const&, Extents const&, bool) override;
+ void kill() override;
static void handle_foreign_activate_request(struct wl_listener*, void*);
static void handle_foreign_fullscreen_request(struct wl_listener*, void*);
diff --git a/src/kranewl/main.cc b/src/kranewl/main.cc
@@ -19,7 +19,7 @@ int
main(int argc, char** argv)
{
#ifndef NDEBUG
- /* wlr_log_init(WLR_DEBUG, nullptr); */
+ wlr_log_init(WLR_DEBUG, nullptr);
#ifdef TRACING_ENABLED
spdlog::set_level(spdlog::level::trace);
#else
diff --git a/src/kranewl/model.cc b/src/kranewl/model.cc
@@ -854,9 +854,8 @@ Model::kill_view(View_ptr view)
{
TRACE();
- if (!view->m_invincible) {
- // TODO: kill view
- }
+ if (!view->m_invincible)
+ view->kill();
}
void
@@ -1593,17 +1592,27 @@ Model::unregister_view(View_ptr view)
{
TRACE();
+ if (view->mp_workspace)
+ view->mp_workspace->remove_view(view);
+
std::stringstream uid_stream;
uid_stream << std::hex << view->m_uid;
+ spdlog::info("Unegistered view 0x{}", uid_stream.str());
+ sync_focus();
+}
- if (view->mp_workspace)
- view->mp_workspace->remove_view(view);
+void
+Model::destroy_view(View_ptr view)
+{
+ TRACE();
+
+ std::stringstream uid_stream;
+ uid_stream << std::hex << view->m_uid;
m_view_map.erase(view->m_uid);
delete view;
- spdlog::info("Unegistered view 0x{}", uid_stream.str());
- sync_focus();
+ spdlog::info("Destroyed view 0x{}", uid_stream.str());
}
bool
diff --git a/src/kranewl/tree/view.cc b/src/kranewl/tree/view.cc
@@ -202,6 +202,7 @@ View::unmap()
TRACE();
wlr_scene_node_destroy(mp_scene);
+ mp_wlr_surface = nullptr;
}
void
diff --git a/src/kranewl/tree/xdg_view.cc b/src/kranewl/tree/xdg_view.cc
@@ -167,6 +167,12 @@ XDGView::moveresize(Region const& region, Extents const& extents, bool interacti
}
void
+XDGView::kill()
+{
+ wlr_xdg_toplevel_send_close(mp_wlr_xdg_surface);
+}
+
+void
XDGView::handle_foreign_activate_request(struct wl_listener* listener, void* data)
{
TRACE();
@@ -279,6 +285,8 @@ XDGView::handle_map(struct wl_listener* listener, void* data)
view->m_preferred_dim.h = wlr_xdg_toplevel->base->surface->current.height;
}
+ view->mp_wlr_surface = wlr_xdg_toplevel->base->surface;
+
Extents const& extents = view->m_free_decoration.extents();
struct wlr_box geometry;
wlr_xdg_surface_get_geometry(wlr_xdg_surface, &geometry);
@@ -342,8 +350,18 @@ XDGView::handle_unmap(struct wl_listener* listener, void* data)
XDGView_ptr view = wl_container_of(listener, view, ml_unmap);
- view->unmap();
view->mp_model->unmap_view(view);
+
+ wl_list_remove(&view->ml_commit.link);
+ wl_list_remove(&view->ml_new_popup.link);
+ wl_list_remove(&view->ml_request_fullscreen.link);
+ wl_list_remove(&view->ml_request_move.link);
+ wl_list_remove(&view->ml_request_resize.link);
+ wl_list_remove(&view->ml_set_title.link);
+ wl_list_remove(&view->ml_set_app_id.link);
+
+ view->unmap();
+ view->mp_model->unregister_view(view);
}
void
@@ -353,18 +371,13 @@ XDGView::handle_destroy(struct wl_listener* listener, void* data)
XDGView_ptr view = wl_container_of(listener, view, ml_destroy);
- view->mp_wlr_xdg_toplevel = nullptr;
- view->mp_model->unregister_view(view);
-
- wl_list_remove(&view->m_events.unmap.listener_list);
- wl_list_remove(&view->ml_commit.link);
- wl_list_remove(&view->ml_new_popup.link);
- wl_list_remove(&view->ml_request_fullscreen.link);
- wl_list_remove(&view->ml_request_move.link);
- wl_list_remove(&view->ml_request_resize.link);
- wl_list_remove(&view->ml_set_title.link);
- wl_list_remove(&view->ml_set_app_id.link);
wl_list_remove(&view->ml_map.link);
wl_list_remove(&view->ml_unmap.link);
wl_list_remove(&view->ml_destroy.link);
+
+ view->mp_wlr_xdg_toplevel = nullptr;
+ view->mp_wlr_xdg_surface = nullptr;
+ view->mp_model->destroy_view(view);
+
+ wl_list_remove(&view->m_events.unmap.listener_list);
}
diff --git a/src/kranewl/tree/xwayland_view.cc b/src/kranewl/tree/xwayland_view.cc
@@ -70,6 +70,13 @@ XWaylandView::moveresize(Region const& region, Extents const& extents, bool inte
}
+void
+XWaylandView::kill()
+{
+ TRACE();
+
+}
+
XWaylandUnmanaged::XWaylandUnmanaged(struct wlr_xwayland_surface* wlr_xwayland_surface)
: mp_wlr_xwayland_surface(wlr_xwayland_surface)
{}