diff --git a/src/view/layer-shell/layer-shell.cpp b/src/view/layer-shell/layer-shell.cpp index 35ac4cf5d..ef046a20b 100644 --- a/src/view/layer-shell/layer-shell.cpp +++ b/src/view/layer-shell/layer-shell.cpp @@ -54,6 +54,7 @@ class wayfire_layer_shell_view : public wf::view_interface_t std::string app_id; friend class wf::tracking_allocator_t; wayfire_layer_shell_view(wlr_layer_surface_v1 *lsurf); + bool keyboard_focus_enabled = true; public: wlr_layer_surface_v1 *lsurface; @@ -110,7 +111,7 @@ class wayfire_layer_shell_view : public wf::view_interface_t wlr_surface *get_keyboard_focus_surface() override { - if (is_mapped() && priv->keyboard_focus_enabled) + if (is_mapped() && keyboard_focus_enabled) { return priv->wsurface; } @@ -502,7 +503,7 @@ void wayfire_layer_shell_view::map() on_surface_commit.connect(&lsurface->surface->events.commit); /* Read initial data */ - priv->keyboard_focus_enabled = lsurface->current.keyboard_interactive; + keyboard_focus_enabled = lsurface->current.keyboard_interactive; wf::scene::add_front(get_output()->node_for_layer(get_layer()), get_root_node()); wf_layer_shell_manager::get_instance().handle_map(this); @@ -544,7 +545,7 @@ void wayfire_layer_shell_view::commit() auto state = &lsurface->current; /* Update the keyboard focus enabled state. If a refocusing is needed, i.e * the view state changed, then this will happen when arranging layers */ - priv->keyboard_focus_enabled = state->keyboard_interactive; + keyboard_focus_enabled = state->keyboard_interactive; if (state->committed) { diff --git a/src/view/view-impl.hpp b/src/view/view-impl.hpp index 9e0d0738d..b9bf84eca 100644 --- a/src/view/view-impl.hpp +++ b/src/view/view-impl.hpp @@ -30,11 +30,9 @@ namespace wf class view_interface_t::view_priv_impl { public: - wlr_surface *wsurface = nullptr; - size_t last_view_cnt = 0; - - bool keyboard_focus_enabled = true; - uint32_t allowed_actions = VIEW_ALLOW_ALL; + wlr_surface *wsurface = nullptr; + size_t last_view_cnt = 0; + uint32_t allowed_actions = VIEW_ALLOW_ALL; uint32_t edges = 0; wlr_box minimize_hint = {0, 0, 0, 0}; diff --git a/src/view/view.cpp b/src/view/view.cpp index b510d8bf0..fb83d66c3 100644 --- a/src/view/view.cpp +++ b/src/view/view.cpp @@ -84,7 +84,7 @@ wlr_box wf::view_interface_t::get_bounding_box() bool wf::view_interface_t::is_focusable() const { - return priv->keyboard_focus_enabled; + return true; } void wf::view_interface_t::damage() diff --git a/src/view/xdg-shell.cpp b/src/view/xdg-shell.cpp index b7ac09299..d50d92617 100644 --- a/src/view/xdg-shell.cpp +++ b/src/view/xdg-shell.cpp @@ -41,7 +41,6 @@ wayfire_xdg_popup::wayfire_xdg_popup(wlr_xdg_popup *popup) : wf::view_interface_ this->popup_parent = wf::wl_surface_to_wayfire_view(popup->parent->resource).get(); this->popup = popup; this->role = wf::VIEW_ROLE_UNMANAGED; - this->priv->keyboard_focus_enabled = false; if (!dynamic_cast(popup_parent.get())) { @@ -374,3 +373,8 @@ void wf::init_xdg_shell() on_xdg_created.connect(&xdg_handle->events.new_surface); } } + +bool wayfire_xdg_popup::is_focusable() const +{ + return false; +} diff --git a/src/view/xdg-shell.hpp b/src/view/xdg-shell.hpp index 644a10f3a..8358e3e0c 100644 --- a/src/view/xdg-shell.hpp +++ b/src/view/xdg-shell.hpp @@ -47,6 +47,8 @@ class wayfire_xdg_popup : public wf::view_interface_t std::string get_app_id() override final; std::string get_title() override final; + bool is_focusable() const override final; + void move(int x, int y); wf::geometry_t get_geometry(); virtual wlr_surface *get_keyboard_focus_surface() override; diff --git a/src/view/xwayland/xwayland-unmanaged-view.hpp b/src/view/xwayland/xwayland-unmanaged-view.hpp index 94a7d44b2..1b604af47 100644 --- a/src/view/xwayland/xwayland-unmanaged-view.hpp +++ b/src/view/xwayland/xwayland-unmanaged-view.hpp @@ -164,12 +164,12 @@ class wayfire_unmanaged_xwayland_view : public wayfire_xwayland_view_internal_ba * plugins can detect that this view can have keyboard focus. * * Note: only actual override-redirect views should get their focus disabled */ - priv->keyboard_focus_enabled = (!xw->override_redirect || + kb_focus_enabled = (!xw->override_redirect || wlr_xwayland_or_surface_wants_focus(xw)); wf::scene::readd_front(get_output()->node_for_layer(wf::scene::layer::UNMANAGED), get_root_node()); - if (priv->keyboard_focus_enabled) + if (kb_focus_enabled) { wf::get_core().default_wm->focus_request(self()); }