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 d3a808a507083b08272a3b9bbcf659e2e8e552ba
parent a00db66c3a103cc78ea399549c96fb056d86823e
Author: deurzen <max@deurzen.net>
Date:   Mon, 29 Aug 2022 04:48:54 +0200

fixes focus bug on new-layer view initialization

Diffstat:
Minclude/kranewl/model.hh | 2+-
Minclude/kranewl/workspace.hh | 4++--
Msrc/kranewl/model.cc | 6+++---
Msrc/kranewl/workspace.cc | 18++++++++++++------
4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/include/kranewl/model.hh b/include/kranewl/model.hh @@ -113,7 +113,7 @@ public: void relayer_views(Workspace_ptr); void relayer_views(Context_ptr); void relayer_views(Output_ptr); - void move_view_to_track(View_ptr, SceneLayer); + void move_view_to_track(View_ptr, SceneLayer, bool = false); void reverse_views(); void rotate_views(Direction); diff --git a/include/kranewl/workspace.hh b/include/kranewl/workspace.hh @@ -108,9 +108,9 @@ public: void toggle_track(); bool cycle_track(Direction); - void add_view_to_track(View_ptr, SceneLayer); + void add_view_to_track(View_ptr, SceneLayer, bool = false); void remove_view_from_track(View_ptr, SceneLayer); - void change_view_track(View_ptr, SceneLayer); + void change_view_track(View_ptr, SceneLayer, bool = false); Cycle<View_ptr> const& views() const; std::vector<View_ptr> stack_after_focus() const; diff --git a/src/kranewl/model.cc b/src/kranewl/model.cc @@ -604,11 +604,11 @@ Model::relayer_views(Output_ptr output) } void -Model::move_view_to_track(View_ptr view, SceneLayer layer) +Model::move_view_to_track(View_ptr view, SceneLayer layer, bool shift_focus) { TRACE(); - view->mp_workspace->change_view_track(view, layer); + view->mp_workspace->change_view_track(view, layer, shift_focus); view->relayer(layer); } @@ -2177,7 +2177,7 @@ Model::initialize_view(View_ptr view, Workspace_ptr workspace) if (rules.do_fullscreen) set_fullscreen_view(*rules.do_fullscreen ? Toggle::On : Toggle::Off, view); - move_view_to_track(view, view->scene_layer()); + move_view_to_track(view, view->scene_layer(), true); } XDGView_ptr diff --git a/src/kranewl/workspace.cc b/src/kranewl/workspace.cc @@ -229,7 +229,7 @@ Workspace::cycle_track(Direction direction) } void -Workspace::add_view_to_track(View_ptr view, SceneLayer layer) +Workspace::add_view_to_track(View_ptr view, SceneLayer layer, bool shift_focus) { TRACE(); @@ -238,10 +238,10 @@ Workspace::add_view_to_track(View_ptr view, SceneLayer layer) m_tracks[layer]->insert_at_back(view); - if (m_tracks[m_track_layer]->empty()) + if (shift_focus || m_tracks[m_track_layer]->empty()) m_track_layer = layer; - if (layer == m_track_layer) + if (shift_focus || layer == m_track_layer) mp_active = view; } @@ -263,15 +263,21 @@ Workspace::remove_view_from_track(View_ptr view, SceneLayer layer) } void -Workspace::change_view_track(View_ptr view, SceneLayer layer) +Workspace::change_view_track(View_ptr view, SceneLayer layer, bool shift_focus) { TRACE(); - if (view->scene_layer() == layer) + if (view->scene_layer() == layer) { + if (shift_focus) { + m_track_layer = layer; + mp_active = view; + } + return; + } remove_view_from_track(view, view->scene_layer()); - add_view_to_track(view, layer); + add_view_to_track(view, layer, shift_focus); }