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 76dfd2df672e01573e309dbfe66797fddb459128
parent e75f96ea3604a6a9ef9b2b8402100f1f046b4957
Author: deurzen <m.deurzen@tum.de>
Date:   Fri, 20 May 2022 16:55:11 +0200

refactors code

Diffstat:
Minclude/kranewl/common.hh | 3+--
Minclude/kranewl/conf/options.hh | 8++++----
Minclude/kranewl/context.hh | 3+--
Minclude/kranewl/cycle.hh | 21++++++++-------------
Minclude/kranewl/cycle.t.hh | 1-
Minclude/kranewl/decoration.hh | 26+++++++++++++-------------
Minclude/kranewl/input/keyboard.hh | 10+++++-----
Minclude/kranewl/tree/client.hh | 135++++++++++++++++++++++++++++++++++++++-----------------------------------------
Minclude/version.hh | 4++--
Msrc/kranewl/layout.cc | 12++++++------
Msrc/kranewl/model.cc | 3+--
Msrc/kranewl/server.cc | 174++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/kranewl/tree/client.cc | 120++++++++++++++++++++++++++++++++++++++-----------------------------------------
13 files changed, 251 insertions(+), 269 deletions(-)

diff --git a/include/kranewl/common.hh b/include/kranewl/common.hh @@ -27,8 +27,7 @@ enum class Corner { BottomRight, }; -enum class Toggle -{ +enum class Toggle { On, Off, Reverse, diff --git a/include/kranewl/conf/options.hh b/include/kranewl/conf/options.hh @@ -5,11 +5,11 @@ struct Options final { Options( - std::string const&& _config_path, - std::optional<std::string> _autostart_path + std::string const&& config_path_, + std::optional<std::string> autostart_path_ ) - : config_path(_config_path), - autostart_path(_autostart_path) + : config_path(config_path_), + autostart_path(autostart_path_) {} std::string config_path; diff --git a/include/kranewl/context.hh b/include/kranewl/context.hh @@ -9,8 +9,7 @@ typedef class Client* Client_ptr; typedef class Workspace* Workspace_ptr; typedef class Output* Output_ptr; -typedef class Context final -{ +typedef class Context final { public: Context(Index index, std::string name) : m_index(index), diff --git a/include/kranewl/cycle.hh b/include/kranewl/cycle.hh @@ -9,15 +9,13 @@ #include <unordered_map> #include <variant> -enum class StackAction -{ +enum class StackAction { Insert, Remove }; template <typename T> -class HistoryStack final -{ +class HistoryStack final { static_assert(std::is_pointer<T>::value, "Only pointer types may be stored in a history stack."); @@ -40,8 +38,7 @@ private: }; template <typename T> -class Cycle final -{ +class Cycle final { static_assert(std::is_pointer<T>::value, "Only pointer types may be stored in a cycle."); @@ -183,17 +180,15 @@ public: } private: - Index m_index; + void sync_active(); + void push_index_to_stack(std::optional<Index>); + void push_active_to_stack(); + std::optional<T> get_active_from_stack(); + Index m_index; std::deque<T> m_elements; bool m_unwindable; HistoryStack<T> m_stack; - void sync_active(); - - void push_index_to_stack(std::optional<Index>); - void push_active_to_stack(); - std::optional<T> get_active_from_stack(); - }; diff --git a/include/kranewl/cycle.t.hh b/include/kranewl/cycle.t.hh @@ -648,4 +648,3 @@ Cycle<T>::stack() const { return m_stack.as_vector(); } - diff --git a/include/kranewl/decoration.hh b/include/kranewl/decoration.hh @@ -5,8 +5,8 @@ #include <optional> struct RGBA final { - RGBA(unsigned _hex) - : hex(_hex) + RGBA(unsigned hex_) + : hex(hex_) { values[0] = static_cast<float>(hex & 0xff) / 255.f; values[1] = static_cast<float>((hex >> 8) & 0xff) / 255.f; @@ -14,16 +14,16 @@ struct RGBA final { values[3] = static_cast<float>((hex >> 24) & 0xff) / 255.f; } - RGBA(const float _values[4]) - : hex(((static_cast<unsigned>(_values[3] * 255.f) & 0xff) << 24) + - ((static_cast<unsigned>(_values[2] * 255.f) & 0xff) << 16) + - ((static_cast<unsigned>(_values[1] * 255.f) & 0xff) << 8) + - ((static_cast<unsigned>(_values[0] * 255.f) & 0xff))) + RGBA(const float values_[4]) + : hex(((static_cast<unsigned>(values_[3] * 255.f) & 0xff) << 24) + + ((static_cast<unsigned>(values_[2] * 255.f) & 0xff) << 16) + + ((static_cast<unsigned>(values_[1] * 255.f) & 0xff) << 8) + + ((static_cast<unsigned>(values_[0] * 255.f) & 0xff))) { - values[0] = _values[0]; - values[1] = _values[1]; - values[2] = _values[2]; - values[3] = _values[3]; + values[0] = values_[0]; + values[1] = values_[1]; + values[2] = values_[2]; + values[3] = values_[3]; } unsigned hex; @@ -72,8 +72,8 @@ const Decoration NO_DECORATION = Decoration{ }; const Decoration FREE_DECORATION = Decoration{ - Frame { - Extents{ 3, 1, 1, 1 }, + Frame{ + Extents{3, 1, 1, 1}, DEFAULT_COLOR_SCHEME } }; diff --git a/include/kranewl/input/keyboard.hh b/include/kranewl/input/keyboard.hh @@ -10,13 +10,13 @@ extern "C" { typedef class Server* Server_ptr; struct Keyboard { - Server_ptr p_server; + Server_ptr mp_server; - struct wl_list link; - struct wlr_input_device* p_device; + struct wl_list m_link; + struct wlr_input_device* mp_device; - struct wl_listener l_modifiers; - struct wl_listener l_key; + struct wl_listener ml_modifiers; + struct wl_listener ml_key; }; struct KeyboardInput { diff --git a/include/kranewl/tree/client.hh b/include/kranewl/tree/client.hh @@ -37,9 +37,9 @@ typedef struct Client final { static bool is_free(Client_ptr client) { - return (client->floating && (!client->fullscreen || client->contained)) - || !client->managed - || client->disowned; + return (client->m_floating && (!client->m_fullscreen || client->m_contained)) + || !client->m_managed + || client->m_disowned; } Client( @@ -80,68 +80,63 @@ typedef struct Client final { void set_tile_decoration(Decoration const&) noexcept; void set_free_decoration(Decoration const&) noexcept; - Server_ptr p_server; - - Uid uid; - Surface surface; - - struct wlr_scene_node* p_scene; - struct wlr_scene_node* p_scene_surface; - struct wlr_scene_rect* protrusions[4]; // top, bottom, left, right - - std::string title; - - Output_ptr p_output; - Context_ptr p_context; - Workspace_ptr p_workspace; - - Region free_region; - Region tile_region; - Region active_region; - Region previous_region; - Region inner_region; - - Decoration tile_decoration; - Decoration free_decoration; - Decoration active_decoration; - - Client_ptr p_parent; - std::vector<Client_ptr> children; - Client_ptr p_producer; - std::vector<Client_ptr> consumers; - - bool focused; - bool mapped; - bool managed; - bool urgent; - bool floating; - bool fullscreen; - bool contained; - bool invincible; - bool sticky; - bool iconifyable; - bool iconified; - bool disowned; - bool producing; - bool attaching; - - std::chrono::time_point<std::chrono::steady_clock> last_focused; - std::chrono::time_point<std::chrono::steady_clock> managed_since; - - struct wl_listener l_commit; - struct wl_listener l_map; - struct wl_listener l_unmap; - struct wl_listener l_destroy; - struct wl_listener l_set_title; - struct wl_listener l_fullscreen; - struct wl_listener l_request_move; - struct wl_listener l_request_resize; + Server_ptr mp_server; + + Uid m_uid; + Surface m_surface; + + struct wlr_scene_node* mp_scene; + struct wlr_scene_node* mp_scene_surface; + struct wlr_scene_rect* m_protrusions[4]; // top, bottom, left, right + + std::string m_title; + + Output_ptr mp_output; + Context_ptr mp_context; + Workspace_ptr mp_workspace; + + Region m_free_region; + Region m_tile_region; + Region m_active_region; + Region m_previous_region; + Region m_inner_region; + + Decoration m_tile_decoration; + Decoration m_free_decoration; + Decoration m_active_decoration; + + bool m_focused; + bool m_mapped; + bool m_managed; + bool m_urgent; + bool m_floating; + bool m_fullscreen; + bool m_contained; + bool m_invincible; + bool m_sticky; + bool m_iconifyable; + bool m_iconified; + bool m_disowned; + bool m_producing; + bool m_attaching; + + std::chrono::time_point<std::chrono::steady_clock> m_last_focused; + std::chrono::time_point<std::chrono::steady_clock> m_managed_since; + + struct wl_listener ml_commit; + struct wl_listener ml_map; + struct wl_listener ml_unmap; + struct wl_listener ml_destroy; + struct wl_listener ml_set_title; + struct wl_listener ml_fullscreen; + struct wl_listener ml_request_move; + struct wl_listener ml_request_resize; #ifdef XWAYLAND - struct wl_listener l_request_activate; - struct wl_listener l_request_configure; - struct wl_listener l_set_hints; + struct wl_listener ml_request_activate; + struct wl_listener ml_request_configure; + struct wl_listener ml_set_hints; #else - struct wl_listener l_new_xdg_popup; + struct wl_listener ml_new_xdg_popup; #endif private: @@ -155,14 +150,14 @@ private: inline bool operator==(Client const& lhs, Client const& rhs) { - if (lhs.surface.type != rhs.surface.type) + if (lhs.m_surface.type != rhs.m_surface.type) return false; - switch (lhs.surface.type) { + switch (lhs.m_surface.type) { case SurfaceType::XDGShell: // fallthrough - case SurfaceType::LayerShell: return lhs.surface.xdg == rhs.surface.xdg; + case SurfaceType::LayerShell: return lhs.m_surface.xdg == rhs.m_surface.xdg; case SurfaceType::X11Managed: // fallthrough - case SurfaceType::X11Unmanaged: return lhs.surface.xwayland == rhs.surface.xwayland; + case SurfaceType::X11Unmanaged: return lhs.m_surface.xwayland == rhs.m_surface.xwayland; } } @@ -174,13 +169,13 @@ namespace std std::size_t operator()(Client const& client) const { - switch (client.surface.type) { + switch (client.m_surface.type) { case SurfaceType::XDGShell: // fallthrough case SurfaceType::LayerShell: - return std::hash<wlr_xdg_surface*>{}(client.surface.xdg); + return std::hash<wlr_xdg_surface*>{}(client.m_surface.xdg); case SurfaceType::X11Managed: // fallthrough case SurfaceType::X11Unmanaged: - return std::hash<wlr_xwayland_surface*>{}(client.surface.xwayland); + return std::hash<wlr_xwayland_surface*>{}(client.m_surface.xwayland); } } diff --git a/include/version.hh b/include/version.hh @@ -1 +1 @@ -#define VERSION "master/41f3026+" -\ No newline at end of file +#define VERSION "master/e75f96e+" +\ No newline at end of file diff --git a/src/kranewl/layout.cc b/src/kranewl/layout.cc @@ -512,7 +512,7 @@ LayoutHandler::arrange_float( mp_layout->config.method, client, mp_layout->config.decoration, - client->free_region + client->m_free_region }; } ); @@ -546,7 +546,7 @@ LayoutHandler::arrange_single_float( mp_layout->config.method, client, mp_layout->config.decoration, - client->focused ? std::optional(client->free_region) : std::nullopt + client->m_focused ? std::optional(client->m_free_region) : std::nullopt }; } ); @@ -935,15 +935,15 @@ LayoutHandler::arrange_paper( begin, end, [&contains_active](const Client_ptr lhs, const Client_ptr rhs) { - if (lhs->focused) { + if (lhs->m_focused) { contains_active = true; return false; - } else if (rhs->focused) { + } else if (rhs->m_focused) { contains_active = true; return true; } - return lhs->last_focused < rhs->last_focused; + return lhs->m_last_focused < rhs->m_last_focused; } ); @@ -957,7 +957,7 @@ LayoutHandler::arrange_paper( [=,this,&after_active,&i](Client_ptr client) -> Placement { int x = screen_region.pos.x + static_cast<int>(i++ * w); - if ((!contains_active && *last_active == client) || client->focused) { + if ((!contains_active && *last_active == client) || client->m_focused) { after_active = true; return Placement { diff --git a/src/kranewl/model.cc b/src/kranewl/model.cc @@ -96,8 +96,7 @@ Model::run() Output_ptr Model::create_output(Surface) { - Output_ptr output = new Output(); - + /* Output_ptr output = new Output(); */ } void diff --git a/src/kranewl/server.cc b/src/kranewl/server.cc @@ -254,11 +254,11 @@ Server::new_output(struct wl_listener* listener, void* data) } Output* output = reinterpret_cast<Output*>(calloc(1, sizeof(Output))); - output->wlr_output = wlr_output; - output->server = server; + output->mp_wlr_output = wlr_output; + output->mp_server = server; output->ml_frame.notify = Server::output_frame; wl_signal_add(&wlr_output->events.frame, &output->ml_frame); - wl_list_insert(&server->m_outputs, &output->link); + /* wl_list_insert(&server->m_outputs, &output->m_link); */ wlr_output_layout_add_auto(server->m_output_layout, wlr_output); } @@ -308,26 +308,26 @@ Server::new_xdg_surface(struct wl_listener* listener, void* data) nullptr ); - xdg_surface->data = client->scene; - client->scene = wlr_scene_xdg_surface_create( - &client->server->m_scene->node, - client->surface.xdg + xdg_surface->data = client->mp_scene; + client->mp_scene = wlr_scene_xdg_surface_create( + &client->mp_server->m_scene->node, + client->m_surface.xdg ); - client->scene->data = client; + client->mp_scene->data = client; - client->l_map.notify = xdg_toplevel_map; - wl_signal_add(&xdg_surface->events.map, &client->l_map); - client->l_unmap.notify = xdg_toplevel_unmap; - wl_signal_add(&xdg_surface->events.unmap, &client->l_unmap); - client->l_destroy.notify = xdg_toplevel_destroy; - wl_signal_add(&xdg_surface->events.destroy, &client->l_destroy); + client->ml_map.notify = xdg_toplevel_map; + wl_signal_add(&xdg_surface->events.map, &client->ml_map); + client->ml_unmap.notify = xdg_toplevel_unmap; + wl_signal_add(&xdg_surface->events.unmap, &client->ml_unmap); + client->ml_destroy.notify = xdg_toplevel_destroy; + wl_signal_add(&xdg_surface->events.destroy, &client->ml_destroy); struct wlr_xdg_toplevel* toplevel = xdg_surface->toplevel; - client->l_request_move.notify = xdg_toplevel_request_move; - wl_signal_add(&toplevel->events.request_move, &client->l_request_move); - client->l_request_resize.notify = xdg_toplevel_request_resize; - wl_signal_add(&toplevel->events.request_resize, &client->l_request_resize); + client->ml_request_move.notify = xdg_toplevel_request_move; + wl_signal_add(&toplevel->events.request_move, &client->ml_request_move); + client->ml_request_resize.notify = xdg_toplevel_request_resize; + wl_signal_add(&toplevel->events.request_resize, &client->ml_request_resize); } void @@ -376,8 +376,8 @@ void Server::new_keyboard(Server_ptr server, struct wlr_input_device* device) { Keyboard* keyboard = reinterpret_cast<Keyboard*>(calloc(1, sizeof(Keyboard))); - keyboard->server = server; - keyboard->device = device; + keyboard->mp_server = server; + keyboard->mp_device = device; struct xkb_context* context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); struct xkb_keymap* keymap = xkb_keymap_new_from_names( @@ -391,13 +391,13 @@ Server::new_keyboard(Server_ptr server, struct wlr_input_device* device) xkb_context_unref(context); wlr_keyboard_set_repeat_info(device->keyboard, 25, 600); - keyboard->l_modifiers.notify = keyboard_handle_modifiers; - wl_signal_add(&device->keyboard->events.modifiers, &keyboard->l_modifiers); - keyboard->l_key.notify = keyboard_handle_key; - wl_signal_add(&device->keyboard->events.key, &keyboard->l_key); + keyboard->ml_modifiers.notify = keyboard_handle_modifiers; + wl_signal_add(&device->keyboard->events.modifiers, &keyboard->ml_modifiers); + keyboard->ml_key.notify = keyboard_handle_key; + wl_signal_add(&device->keyboard->events.key, &keyboard->ml_key); wlr_seat_set_keyboard(server->m_seat, device); - wl_list_insert(&server->m_keyboards, &keyboard->link); + wl_list_insert(&server->m_keyboards, &keyboard->m_link); } void @@ -564,13 +564,13 @@ Server::cursor_process_move(Server_ptr server, uint32_t time) { Client_ptr client = server->m_grabbed_client; - client->active_region.pos.x = server->m_cursor->x - server->m_grab_x; - client->active_region.pos.y = server->m_cursor->y - server->m_grab_y; + client->m_active_region.pos.x = server->m_cursor->x - server->m_grab_x; + client->m_active_region.pos.y = server->m_cursor->y - server->m_grab_y; wlr_scene_node_set_position( - client->scene, - client->active_region.pos.x, - client->active_region.pos.y + client->mp_scene, + client->m_active_region.pos.x, + client->m_active_region.pos.y ); } @@ -612,22 +612,22 @@ Server::cursor_process_resize(Server_ptr server, uint32_t time) } struct wlr_box geo_box; - wlr_xdg_surface_get_geometry(client->surface.xdg, &geo_box); + wlr_xdg_surface_get_geometry(client->m_surface.xdg, &geo_box); - client->active_region.pos.x = new_left - geo_box.x; - client->active_region.pos.y = new_top - geo_box.y; + client->m_active_region.pos.x = new_left - geo_box.x; + client->m_active_region.pos.y = new_top - geo_box.y; wlr_scene_node_set_position( - client->scene, - client->active_region.pos.x, - client->active_region.pos.y + client->mp_scene, + client->m_active_region.pos.x, + client->m_active_region.pos.y ); int new_width = new_right - new_left; int new_height = new_bottom - new_top; wlr_xdg_toplevel_set_size( - client->surface.xdg, + client->m_surface.xdg, new_width, new_height ); @@ -648,20 +648,20 @@ Server::start_drag(struct wl_listener*, void*) void Server::keyboard_handle_modifiers(struct wl_listener* listener, void* data) { - Keyboard* keyboard = wl_container_of(listener, keyboard, l_modifiers); + Keyboard* keyboard = wl_container_of(listener, keyboard, ml_modifiers); - wlr_seat_set_keyboard(keyboard->server->m_seat, keyboard->device); + wlr_seat_set_keyboard(keyboard->mp_server->m_seat, keyboard->mp_device); wlr_seat_keyboard_notify_modifiers( - keyboard->server->m_seat, - &keyboard->device->keyboard->modifiers + keyboard->mp_server->m_seat, + &keyboard->mp_device->keyboard->modifiers ); } void Server::keyboard_handle_key(struct wl_listener* listener, void* data) { - Keyboard* keyboard = wl_container_of(listener, keyboard, l_key); - Server_ptr server = keyboard->server; + Keyboard* keyboard = wl_container_of(listener, keyboard, ml_key); + Server_ptr server = keyboard->mp_server; struct wlr_event_keyboard_key* event = reinterpret_cast<struct wlr_event_keyboard_key*>(data); @@ -671,13 +671,13 @@ Server::keyboard_handle_key(struct wl_listener* listener, void* data) const xkb_keysym_t* syms; int nsyms = xkb_state_key_get_syms( - keyboard->device->keyboard->xkb_state, + keyboard->mp_device->keyboard->xkb_state, keycode, &syms ); bool handled = false; - uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->device->keyboard); + uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->mp_device->keyboard); if ((modifiers & WLR_MODIFIER_ALT) && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) { for (int i = 0; i < nsyms; i++) @@ -685,7 +685,7 @@ Server::keyboard_handle_key(struct wl_listener* listener, void* data) } if (!handled) { - wlr_seat_set_keyboard(seat, keyboard->device); + wlr_seat_set_keyboard(seat, keyboard->mp_device); wlr_seat_keyboard_notify_key( seat, event->time_msec, @@ -763,10 +763,10 @@ void Server::output_frame(struct wl_listener* listener, void* data) { Output* output = wl_container_of(listener, output, ml_frame); - struct wlr_scene* scene = output->m_server->m_scene; + struct wlr_scene* scene = output->mp_server->m_scene; struct wlr_scene_output* scene_output - = wlr_scene_get_scene_output(scene, output->m_wlr_output); + = wlr_scene_get_scene_output(scene, output->mp_wlr_output); wlr_scene_output_commit(scene_output); @@ -808,7 +808,7 @@ Server::focus_client(Client_ptr client, struct wlr_surface* surface) if (!client) return; - Server_ptr server = client->server; + Server_ptr server = client->mp_server; struct wlr_seat* seat = server->m_seat; struct wlr_surface* prev_surface = seat->keyboard_state.focused_surface; @@ -825,14 +825,14 @@ Server::focus_client(Client_ptr client, struct wlr_surface* surface) struct wlr_keyboard* keyboard = wlr_seat_get_keyboard(seat); - if (client->scene) - wlr_scene_node_raise_to_top(client->scene); + if (client->mp_scene) + wlr_scene_node_raise_to_top(client->mp_scene); /* wl_list_remove(&client->link); */ /* wl_list_insert(&server->m_clients, &client->link); */ - if (client->surface.type == SurfaceType::XDGShell || client->surface.type == SurfaceType::LayerShell) - wlr_xdg_toplevel_set_activated(client->surface.xdg, true); + if (client->m_surface.type == SurfaceType::XDGShell || client->m_surface.type == SurfaceType::LayerShell) + wlr_xdg_toplevel_set_activated(client->m_surface.xdg, true); wlr_seat_keyboard_notify_enter( seat, @@ -846,7 +846,7 @@ Server::focus_client(Client_ptr client, struct wlr_surface* surface) void Server::xdg_toplevel_map(struct wl_listener* listener, void* data) { - Client_ptr client = wl_container_of(listener, client, l_map); + Client_ptr client = wl_container_of(listener, client, ml_map); /* wl_list_insert(&client->server->m_clients, &client->link); */ focus_client(client, client->get_surface()); @@ -855,20 +855,20 @@ Server::xdg_toplevel_map(struct wl_listener* listener, void* data) void Server::xdg_toplevel_unmap(struct wl_listener* listener, void* data) { - Client_ptr client = wl_container_of(listener, client, l_unmap); + Client_ptr client = wl_container_of(listener, client, ml_unmap); /* wl_list_remove(&client->link); */ } void Server::xdg_toplevel_destroy(struct wl_listener* listener, void* data) { - Client_ptr client = wl_container_of(listener, client, l_destroy); + Client_ptr client = wl_container_of(listener, client, ml_destroy); - wl_list_remove(&client->l_map.link); - wl_list_remove(&client->l_unmap.link); - wl_list_remove(&client->l_destroy.link); - wl_list_remove(&client->l_request_move.link); - wl_list_remove(&client->l_request_resize.link); + wl_list_remove(&client->ml_map.link); + wl_list_remove(&client->ml_unmap.link); + wl_list_remove(&client->ml_destroy.link); + wl_list_remove(&client->ml_request_move.link); + wl_list_remove(&client->ml_request_resize.link); delete client; } @@ -876,7 +876,7 @@ Server::xdg_toplevel_destroy(struct wl_listener* listener, void* data) void Server::xdg_toplevel_request_move(struct wl_listener* listener, void* data) { - Client_ptr client = wl_container_of(listener, client, l_request_move); + Client_ptr client = wl_container_of(listener, client, ml_request_move); xdg_toplevel_handle_moveresize(client, Server::CursorMode::Move, 0); } @@ -886,7 +886,7 @@ Server::xdg_toplevel_request_resize(struct wl_listener* listener, void* data) struct wlr_xdg_toplevel_resize_event* event = reinterpret_cast<struct wlr_xdg_toplevel_resize_event*>(data); - Client_ptr client = wl_container_of(listener, client, l_request_resize); + Client_ptr client = wl_container_of(listener, client, ml_request_resize); xdg_toplevel_handle_moveresize(client, Server::CursorMode::Resize, event->edges); } @@ -897,7 +897,7 @@ Server::xdg_toplevel_handle_moveresize( uint32_t edges ) { - Server_ptr server = client->server; + Server_ptr server = client->mp_server; if (client->get_surface() != wlr_surface_get_root_surface(server->m_seat->pointer_state.focused_surface)) @@ -910,26 +910,26 @@ Server::xdg_toplevel_handle_moveresize( switch (mode) { case Server::CursorMode::Move: - server->m_grab_x = server->m_cursor->x - client->active_region.pos.x; - server->m_grab_y = server->m_cursor->y - client->active_region.pos.y; + server->m_grab_x = server->m_cursor->x - client->m_active_region.pos.x; + server->m_grab_y = server->m_cursor->y - client->m_active_region.pos.y; return; case Server::CursorMode::Resize: { struct wlr_box geo_box; - wlr_xdg_surface_get_geometry(client->surface.xdg, &geo_box); + wlr_xdg_surface_get_geometry(client->m_surface.xdg, &geo_box); - double border_x = (client->active_region.pos.x + geo_box.x) + + double border_x = (client->m_active_region.pos.x + geo_box.x) + ((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0); - double border_y = (client->active_region.pos.y + geo_box.y) + + double border_y = (client->m_active_region.pos.y + geo_box.y) + ((edges & WLR_EDGE_BOTTOM) ? geo_box.height : 0); server->m_grab_x = server->m_cursor->x - border_x; server->m_grab_y = server->m_cursor->y - border_y; server->m_grab_geobox = geo_box; - server->m_grab_geobox.x += client->active_region.pos.x; - server->m_grab_geobox.y += client->active_region.pos.y; + server->m_grab_geobox.x += client->m_active_region.pos.x; + server->m_grab_geobox.y += client->m_active_region.pos.y; server->m_resize_edges = edges; } @@ -986,22 +986,22 @@ Server::new_xwayland_surface(struct wl_listener* listener, void* data) xwayland_surface->data = client; - client->l_map = { .notify = Server::xdg_toplevel_map }; - client->l_unmap = { .notify = Server::xdg_toplevel_unmap }; - client->l_destroy = { .notify = Server::xdg_toplevel_destroy }; - // TODO: client->l_set_title = { .notify = Server::... }; - // TODO: client->l_fullscreen = { .notify = Server::... }; - client->l_request_activate = { .notify = Server::xwayland_request_activate }; - client->l_request_configure = { .notify = Server::xwayland_request_configure }; - client->l_set_hints = { .notify = Server::xwayland_set_hints }; - // TODO: client->l_new_xdg_popup = { .notify = Server::... }; - - wl_signal_add(&xwayland_surface->events.map, &client->l_map); - wl_signal_add(&xwayland_surface->events.unmap, &client->l_unmap); - wl_signal_add(&xwayland_surface->events.destroy, &client->l_destroy); - wl_signal_add(&xwayland_surface->events.request_activate, &client->l_request_activate); - wl_signal_add(&xwayland_surface->events.request_configure, &client->l_request_configure); - wl_signal_add(&xwayland_surface->events.set_hints, &client->l_set_hints); + client->ml_map = { .notify = Server::xdg_toplevel_map }; + client->ml_unmap = { .notify = Server::xdg_toplevel_unmap }; + client->ml_destroy = { .notify = Server::xdg_toplevel_destroy }; + // TODO: client->ml_set_title = { .notify = Server::... }; + // TODO: client->ml_fullscreen = { .notify = Server::... }; + client->ml_request_activate = { .notify = Server::xwayland_request_activate }; + client->ml_request_configure = { .notify = Server::xwayland_request_configure }; + client->ml_set_hints = { .notify = Server::xwayland_set_hints }; + // TODO: client->ml_new_xdg_popup = { .notify = Server::... }; + + wl_signal_add(&xwayland_surface->events.map, &client->ml_map); + wl_signal_add(&xwayland_surface->events.unmap, &client->ml_unmap); + wl_signal_add(&xwayland_surface->events.destroy, &client->ml_destroy); + wl_signal_add(&xwayland_surface->events.request_activate, &client->ml_request_activate); + wl_signal_add(&xwayland_surface->events.request_configure, &client->ml_request_configure); + wl_signal_add(&xwayland_surface->events.set_hints, &client->ml_set_hints); } void diff --git a/src/kranewl/tree/client.cc b/src/kranewl/tree/client.cc @@ -22,40 +22,36 @@ Client::Client( Context_ptr context, Workspace_ptr workspace ) - : uid{surface.uid()}, - server{server}, - surface{surface}, - output{output}, - context{context}, - workspace{workspace}, - free_region{{}}, - tile_region{{}}, - active_region{{}}, - previous_region{{}}, - inner_region{{}}, - tile_decoration{{}}, - free_decoration{{}}, - active_decoration{{}}, - parent{nullptr}, - children{{}}, - producer{nullptr}, - consumers{{}}, - focused{false}, - mapped{false}, - managed{true}, - urgent{false}, - floating{false}, - fullscreen{false}, - contained{false}, - invincible{false}, - sticky{false}, - iconifyable{true}, - iconified{false}, - disowned{false}, - producing{true}, - attaching{false}, - last_focused{std::chrono::steady_clock::now()}, - managed_since{std::chrono::steady_clock::now()}, + : m_uid{surface.uid()}, + mp_server{server}, + m_surface{surface}, + mp_output{output}, + mp_context{context}, + mp_workspace{workspace}, + m_free_region{{}}, + m_tile_region{{}}, + m_active_region{{}}, + m_previous_region{{}}, + m_inner_region{{}}, + m_tile_decoration{{}}, + m_free_decoration{{}}, + m_active_decoration{{}}, + m_focused{false}, + m_mapped{false}, + m_managed{true}, + m_urgent{false}, + m_floating{false}, + m_fullscreen{false}, + m_contained{false}, + m_invincible{false}, + m_sticky{false}, + m_iconifyable{true}, + m_iconified{false}, + m_disowned{false}, + m_producing{true}, + m_attaching{false}, + m_last_focused{std::chrono::steady_clock::now()}, + m_managed_since{std::chrono::steady_clock::now()}, m_outside_state{OutsideState::Unfocused} {} @@ -65,7 +61,7 @@ Client::~Client() Client::OutsideState Client::get_outside_state() const noexcept { - if (urgent) + if (m_urgent) return Client::OutsideState::Urgent; return m_outside_state; @@ -74,11 +70,11 @@ Client::get_outside_state() const noexcept struct wlr_surface* Client::get_surface() noexcept { - switch (surface.type) { + switch (m_surface.type) { case SurfaceType::XDGShell: //fallthrough - case SurfaceType::LayerShell: return surface.xdg->surface; + case SurfaceType::LayerShell: return m_surface.xdg->surface; case SurfaceType::X11Managed: //fallthrough - case SurfaceType::X11Unmanaged: return surface.xwayland->surface; + case SurfaceType::X11Unmanaged: return m_surface.xwayland->surface; } return nullptr; @@ -87,8 +83,8 @@ Client::get_surface() noexcept void Client::focus() noexcept { - focused = true; - last_focused = std::chrono::steady_clock::now(); + m_focused = true; + m_last_focused = std::chrono::steady_clock::now(); switch (m_outside_state) { case OutsideState::Unfocused: m_outside_state = OutsideState::Focused; return; @@ -101,7 +97,7 @@ Client::focus() noexcept void Client::unfocus() noexcept { - focused = false; + m_focused = false; switch (m_outside_state) { case OutsideState::Focused: m_outside_state = OutsideState::Unfocused; return; @@ -114,7 +110,7 @@ Client::unfocus() noexcept void Client::stick() noexcept { - sticky = true; + m_sticky = true; switch (m_outside_state) { case OutsideState::Focused: m_outside_state = OutsideState::FocusedSticky; return; @@ -126,7 +122,7 @@ Client::stick() noexcept void Client::unstick() noexcept { - sticky = false; + m_sticky = false; switch (m_outside_state) { case OutsideState::FocusedSticky: m_outside_state = OutsideState::Focused; return; @@ -138,7 +134,7 @@ Client::unstick() noexcept void Client::disown() noexcept { - disowned = true; + m_disowned = true; switch (m_outside_state) { case OutsideState::Focused: m_outside_state = OutsideState::FocusedDisowned; return; @@ -150,7 +146,7 @@ Client::disown() noexcept void Client::reclaim() noexcept { - disowned = false; + m_disowned = false; switch (m_outside_state) { case OutsideState::FocusedDisowned: m_outside_state = OutsideState::Focused; return; @@ -162,52 +158,52 @@ Client::reclaim() noexcept void Client::set_tile_region(Region& region) noexcept { - tile_region = region; + m_tile_region = region; set_active_region(region); } void Client::set_free_region(Region& region) noexcept { - free_region = region; + m_free_region = region; set_active_region(region); } void Client::set_active_region(Region& region) noexcept { - previous_region = active_region; + m_previous_region = m_active_region; set_inner_region(region); - active_region = region; + m_active_region = region; } void Client::set_tile_decoration(Decoration const& decoration) noexcept { - tile_decoration = decoration; - active_decoration = decoration; + m_tile_decoration = decoration; + m_active_decoration = decoration; } void Client::set_free_decoration(Decoration const& decoration) noexcept { - free_decoration = decoration; - active_decoration = decoration; + m_free_decoration = decoration; + m_active_decoration = decoration; } void Client::set_inner_region(Region& region) noexcept { - if (active_decoration.frame) { - Frame const& frame = *active_decoration.frame; + if (m_active_decoration.frame) { + Frame const& frame = *m_active_decoration.frame; - inner_region.pos.x = frame.extents.left; - inner_region.pos.y = frame.extents.top; - inner_region.dim.w = region.dim.w - frame.extents.left - frame.extents.right; - inner_region.dim.h = region.dim.h - frame.extents.top - frame.extents.bottom; + m_inner_region.pos.x = frame.extents.left; + m_inner_region.pos.y = frame.extents.top; + m_inner_region.dim.w = region.dim.w - frame.extents.left - frame.extents.right; + m_inner_region.dim.h = region.dim.h - frame.extents.top - frame.extents.bottom; } else { - inner_region.pos.x = 0; - inner_region.pos.y = 0; - inner_region.dim = region.dim; + m_inner_region.pos.x = 0; + m_inner_region.pos.y = 0; + m_inner_region.dim = region.dim; } }