kranewl

A wlroots-based dynamic Wayland compositor, written in C++, configurable with Lua
git clone git://git.deurzen.net/kranewl
Log | Files | Refs | LICENSE

commit ec0a8ba81c947462274ba3764cb37b7167b8ce23
parent 5ee13d18263275c597f44b4e23e7ffc209be9243
Author: deurzen <max@deurzen.net>
Date:   Sun, 29 May 2022 09:29:20 +0200

sets debug-friendly formatted view uid

Diffstat:
Minclude/kranewl/layer.hh | 2--
Minclude/kranewl/model.hh | 6------
Minclude/kranewl/tree/view.hh | 3+++
Msrc/kranewl/model.cc | 57+++++----------------------------------------------------
Msrc/kranewl/tree/view.cc | 16++++++++++++++++
Msrc/kranewl/tree/xdg_view.cc | 2++
6 files changed, 26 insertions(+), 60 deletions(-)

diff --git a/include/kranewl/layer.hh b/include/kranewl/layer.hh @@ -1,7 +1,5 @@ #pragma once -#include <cstdlib> - enum Layer : short { None = -1, Background = 0, diff --git a/include/kranewl/model.hh b/include/kranewl/model.hh @@ -54,12 +54,6 @@ public: void unregister_view(View_ptr); void destroy_view(View_ptr); - void map_view(View_ptr); - void unmap_view(View_ptr); - void iconify_view(View_ptr); - void deiconify_view(View_ptr); - void disown_view(View_ptr); - void reclaim_view(View_ptr); void focus_view(View_ptr); void place_view(Placement&); diff --git a/include/kranewl/tree/view.hh b/include/kranewl/tree/view.hh @@ -143,6 +143,7 @@ typedef struct View { void set_tile_decoration(Decoration const&); void touch() { m_last_touched = std::chrono::steady_clock::now(); } + void format_uid(); static bool is_free(View_ptr view) @@ -155,6 +156,8 @@ typedef struct View { OutsideState outside_state() const; Uid m_uid; + std::string m_uid_formatted; + Type m_type; Server_ptr mp_server; diff --git a/src/kranewl/model.cc b/src/kranewl/model.cc @@ -198,30 +198,8 @@ Model::unregister_output(Output_ptr output) m_outputs.remove_element(output); delete output; -} - -void -Model::iconify_view(View_ptr) -{ - TRACE(); -} - -void -Model::deiconify_view(View_ptr) -{ - TRACE(); -} -void -Model::disown_view(View_ptr) -{ - TRACE(); -} - -void -Model::reclaim_view(View_ptr) -{ - TRACE(); + mp_output = m_outputs.active_element().value_or(nullptr); } void @@ -1561,17 +1539,9 @@ Model::register_view(View_ptr view, Workspace_ptr workspace) { TRACE(); - std::stringstream uid_ss; - uid_ss << std::hex << view->m_uid; - spdlog::info( - "Registered view 0x{} [{}, PID {}]", - uid_ss.str(), - view->m_title, - view->m_pid - ); - + view->format_uid(); move_view_to_workspace(view, workspace); - + spdlog::info("Registered view {}", view->m_uid_formatted); sync_focus(); } @@ -1585,15 +1555,7 @@ Model::unregister_view(View_ptr view) apply_layout(view->mp_workspace); } - std::stringstream uid_ss; - uid_ss << std::hex << view->m_uid; - spdlog::info( - "Unregistered view 0x{} [{}, PID {}]", - uid_ss.str(), - view->m_title, - view->m_pid - ); - + spdlog::info("Unregistered view {}", view->m_uid_formatted); mp_output->focus_at_cursor(); sync_focus(); } @@ -1604,17 +1566,8 @@ Model::destroy_view(View_ptr view) TRACE(); m_view_map.erase(view->m_uid); - - std::stringstream uid_ss; - uid_ss << std::hex << view->m_uid; - spdlog::info( - "Destroyed view 0x{} [{}, PID {}]", - uid_ss.str(), - view->m_title, - view->m_pid - ); - delete view; + spdlog::info("Destroyed view {}", view->m_uid_formatted); } bool diff --git a/src/kranewl/tree/view.cc b/src/kranewl/tree/view.cc @@ -31,6 +31,11 @@ View::View( struct wlr_surface* wlr_surface ) : m_uid(uid), + m_uid_formatted([uid]() { + std::stringstream uid_ss; + uid_ss << "0x" << std::hex << uid; + return uid_ss.str(); + }()), m_type(Type::XDGShell), mp_server(server), mp_model(model), @@ -485,6 +490,17 @@ View::set_tile_decoration(Decoration const& decoration) m_active_decoration = decoration; } +void +View::format_uid() +{ + std::stringstream uid_ss; + uid_ss << "0x" << std::hex << m_uid << std::dec; + uid_ss << " [" << m_title; + uid_ss << ", " << m_pid << "]"; + uid_ss << " (" << (m_type == Type::XDGShell ? "W" : "X") << ")"; + m_uid_formatted = uid_ss.str(); +} + View::OutsideState View::outside_state() const { diff --git a/src/kranewl/tree/xdg_view.cc b/src/kranewl/tree/xdg_view.cc @@ -297,6 +297,7 @@ XDGView::handle_set_title(struct wl_listener* listener, void* data) XDGView_ptr view = wl_container_of(listener, view, ml_set_title); view->m_title = view->mp_wlr_xdg_toplevel->title; view->m_title_formatted = view->m_title; + view->format_uid(); } void @@ -306,6 +307,7 @@ XDGView::handle_set_app_id(struct wl_listener* listener, void* data) XDGView_ptr view = wl_container_of(listener, view, ml_set_app_id); view->m_app_id = view->mp_wlr_xdg_toplevel->app_id; + view->format_uid(); } void