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 5f353e8f5025d881f63fe3f319be0c3716bb6577
parent 62c017932fd1ccc95c8232ffadd7de316ff2406a
Author: deurzen <max@deurzen.net>
Date:   Thu,  2 Jun 2022 16:30:30 +0200

implements output configuration update management

Diffstat:
Minclude/kranewl/model.hh | 4++++
Minclude/kranewl/tree/output.hh | 4++++
Msrc/kranewl/model.cc | 18++++++++++++++++++
Msrc/kranewl/server.cc | 25+++++++++++++++++++++++++
Msrc/kranewl/tree/output.cc | 3+++
5 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/include/kranewl/model.hh b/include/kranewl/model.hh @@ -49,6 +49,10 @@ public: Context_ptr context(Index) const; Output_ptr output(Index) const; + Cycle<Output_ptr> const& outputs() const; + Cycle<Context_ptr> const& contexts() const; + Cycle<Workspace_ptr> const& workspaces() const; + KeyBindings const& key_bindings() const; CursorBindings const& cursor_bindings() const; diff --git a/include/kranewl/tree/output.hh b/include/kranewl/tree/output.hh @@ -72,6 +72,10 @@ public: Model_ptr mp_model; Seat_ptr mp_seat; + std::vector<struct wlr_output_mode*> m_modes; + struct wlr_output_mode* mp_current_mode; + + bool m_enabled; bool m_dirty; struct wlr_output* mp_wlr_output; diff --git a/src/kranewl/model.cc b/src/kranewl/model.cc @@ -167,6 +167,24 @@ Model::output(Index index) const return nullptr; } +Cycle<Output_ptr> const& +Model::outputs() const +{ + return m_outputs; +} + +Cycle<Context_ptr> const& +Model::contexts() const +{ + return m_contexts; +} + +Cycle<Workspace_ptr> const& +Model::workspaces() const +{ + return m_workspaces; +} + KeyBindings const& Model::key_bindings() const { diff --git a/src/kranewl/server.cc b/src/kranewl/server.cc @@ -340,6 +340,30 @@ Server::relinquish_focus() wlr_seat_keyboard_notify_clear_focus(mp_seat->mp_wlr_seat); } + +static inline void +update_output_manager_config(Server_ptr server, Model_ptr model) +{ + struct wlr_output_configuration_v1* config + = wlr_output_configuration_v1_create(); + + for (Output_ptr output : model->outputs()) { + struct wlr_output_configuration_head_v1* config_head + = wlr_output_configuration_head_v1_create(config, output->mp_wlr_output); + + struct wlr_box output_box + = *wlr_output_layout_get_box(server->mp_output_layout, output->mp_wlr_output); + + config_head->state.enabled = output->mp_current_mode && output->m_enabled; + config_head->state.mode = output->mp_current_mode; + + if (!wlr_box_empty(&output_box)) { + config_head->state.x = output_box.x; + config_head->state.y = output_box.y; + } + } + + wlr_output_manager_v1_set_configuration(server->mp_output_manager, config); } void @@ -399,6 +423,7 @@ Server::handle_new_output(struct wl_listener* listener, void* data) ); wlr_output->data = output; + update_output_manager_config(server, server->mp_model); } void diff --git a/src/kranewl/tree/output.cc b/src/kranewl/tree/output.cc @@ -38,6 +38,9 @@ Output::Output( mp_server(server), mp_model(model), mp_seat(seat), + m_modes({wlr_output->pending.mode}), + mp_current_mode(wlr_output->pending.mode), + m_enabled(true), m_dirty(true), m_cursor_focus_on_present(false), m_layer_map{