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 5fa10341abe96782477d69416815a6f0c0e976c5
parent 6fcb966919047d15a925410c67f1c2caa27cd878
Author: deurzen <max@deurzen.net>
Date:   Sat,  4 Jun 2022 03:29:47 +0200

has focus-follows-cursor operate on a layer-basis

Diffstat:
Minclude/kranewl/model.hh | 3+++
Msrc/kranewl/input/cursor.cc | 21+++++++++++----------
Msrc/kranewl/model.cc | 16+++++++++++++++-
3 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/include/kranewl/model.hh b/include/kranewl/model.hh @@ -204,6 +204,7 @@ public: void set_focus_follows_cursor(Toggle, Context_ptr); bool is_free(View_ptr) const; + bool belongs_to_track(View_ptr) const; void spawn_external(std::string&&) const; @@ -235,6 +236,8 @@ private: View_ptr mp_focus; View_ptr mp_jumped_from; + SceneLayer m_track; + std::vector<std::tuple<SearchSelector_ptr, Rules>> m_default_rules; const KeyBindings m_key_bindings; diff --git a/src/kranewl/input/cursor.cc b/src/kranewl/input/cursor.cc @@ -388,7 +388,7 @@ cursor_motion_to_client( cursor->mp_seat->mp_wlr_seat ); - if (view && view != prev_view + if (view && view != prev_view && cursor->mp_model->belongs_to_track(view) && view->mp_workspace->focus_follows_cursor() && view->managed()) { cursor->mp_seat->mp_model->focus_view(view); @@ -472,8 +472,8 @@ Cursor::handle_cursor_motion_absolute(struct wl_listener* listener, void* data) cursor->process_cursor_motion(event->time_msec); } -bool -process_cursorbinding(Cursor_ptr cursor, uint32_t button, uint32_t modifiers) +static inline bool +process_cursorbinding(Cursor_ptr cursor, View_ptr view, uint32_t button, uint32_t modifiers) { TRACE(); @@ -488,7 +488,6 @@ process_cursorbinding(Cursor_ptr cursor, uint32_t button, uint32_t modifiers) .modifiers = modifiers }; - View_ptr view = cursor->view_under_cursor(); Model_ptr model = cursor->mp_seat->mp_model; View_ptr focused_view = model->focused_view(); @@ -554,13 +553,14 @@ Cursor::handle_cursor_button(struct wl_listener* listener, void* data) ? wlr_keyboard_get_modifiers(keyboard) : 0; - if (process_cursorbinding(cursor, button, modifiers)) + View_ptr view = cursor->view_under_cursor(); + if (process_cursorbinding(cursor, view, button, modifiers)) return; - if (!cursor->mp_model->mp_workspace->focus_follows_cursor()) { - View_ptr view = cursor->view_under_cursor(); - - if (view && !view->focused() && view->managed()) + if (view && (!cursor->mp_model->mp_workspace->focus_follows_cursor() + || !cursor->mp_model->belongs_to_track(view))) + { + if (!view->focused() && view->managed()) cursor->mp_seat->mp_model->focus_view(view); } @@ -626,7 +626,8 @@ Cursor::handle_cursor_axis(struct wl_listener* listener, void* data) default: break; } - if (!process_cursorbinding(cursor, button, modifiers)) { + View_ptr view = cursor->view_under_cursor(); + if (!process_cursorbinding(cursor, view, button, modifiers)) { wlr_idle_notify_activity(seat->mp_idle, seat->mp_wlr_seat); wlr_seat_pointer_notify_axis( seat->mp_wlr_seat, diff --git a/src/kranewl/model.cc b/src/kranewl/model.cc @@ -56,6 +56,7 @@ Model::Model(Config const& config) m_sticky_views{}, mp_focus(nullptr), mp_jumped_from(nullptr), + m_track(SceneLayer::SCENE_LAYER_TILE), m_key_bindings(Bindings::key_bindings), m_cursor_bindings(Bindings::cursor_bindings) { @@ -307,7 +308,9 @@ Model::focus_view(View_ptr view) view->focus(Toggle::On); view->set_urgent(false); + mp_focus = view; + m_track = view->scene_layer(); if (mp_workspace->layout_is_persistent() || mp_workspace->layout_is_single()) apply_layout(mp_workspace); @@ -553,8 +556,10 @@ Model::relayer_views(Workspace_ptr workspace) } } - if (mp_focus) + if (mp_focus) { mp_focus->raise(); + m_track = mp_focus->scene_layer(); + } } void @@ -2067,6 +2072,9 @@ Model::initialize_view(View_ptr view, Workspace_ptr workspace) snap_view(view, *rules.snap_edges); if (rules.do_fullscreen) set_fullscreen_view(*rules.do_fullscreen ? Toggle::On : Toggle::Off, view); + + if (view == mp_focus) + m_track = view->scene_layer(); } XDGView_ptr @@ -2221,6 +2229,12 @@ Model::is_free(View_ptr view) const )->layout_is_free()); } +bool +Model::belongs_to_track(View_ptr view) const +{ + return m_track == view->scene_layer(); +} + void Model::spawn_external(std::string&& command) const {