1 #include "wayfire/output.hpp" 2 #include "plugin-loader.hpp" 3 #include "../core/seat/bindings-repository.hpp" 4 5 #include <unordered_set> 6 #include <wayfire/nonstd/safe-list.hpp> 7 8 namespace wf 9 { 10 class output_impl_t : public output_t 11 { 12 private: 13 std::unordered_multiset<wf::plugin_grab_interface_t*> active_plugins; 14 std::unique_ptr<plugin_manager> plugin; 15 std::unique_ptr<wf::bindings_repository_t> bindings; 16 17 signal_callback_t view_disappeared_cb; 18 bool inhibited = false; 19 20 enum focus_view_flags_t 21 { 22 /* Raise the view which is being focused */ 23 FOCUS_VIEW_RAISE = (1 << 0), 24 /* Close popups of non-focused views */ 25 FOCUS_VIEW_CLOSE_POPUPS = (1 << 1), 26 }; 27 28 /** 29 * Set the given view as the active view. 30 * If the output has focus, try to focus the view as well. 31 * 32 * @param flags bitmask of @focus_view_flags_t 33 */ 34 void update_active_view(wayfire_view view, uint32_t flags); 35 36 /** 37 * Close all popups on the output which do not belong to the active view. 38 */ 39 void close_popups(); 40 41 /** @param flags bitmask of @focus_view_flags_t */ 42 void focus_view(wayfire_view view, uint32_t flags); 43 44 wf::dimensions_t effective_size; 45 46 public: 47 output_impl_t(wlr_output *output, const wf::dimensions_t& effective_size); 48 /** 49 * Start all the plugins on this output. 50 */ 51 void start_plugins(); 52 53 virtual ~output_impl_t(); 54 wayfire_view active_view; 55 56 /** 57 * Implementations of the public APIs 58 */ 59 bool can_activate_plugin(const plugin_grab_interface_uptr& owner, 60 uint32_t flags = 0) override; 61 bool can_activate_plugin(uint32_t caps, uint32_t flags = 0) override; 62 bool activate_plugin(const plugin_grab_interface_uptr& owner, 63 uint32_t flags = 0) override; 64 bool deactivate_plugin(const plugin_grab_interface_uptr& owner) override; 65 void cancel_active_plugins() override; 66 bool is_plugin_active(std::string owner_name) const override; 67 bool call_plugin(const std::string& activator, 68 const wf::activator_data_t& data) const override; 69 wayfire_view get_active_view() const override; 70 void focus_view(wayfire_view v, bool raise) override; 71 void refocus(wayfire_view skip_view, uint32_t layers) override; 72 wf::dimensions_t get_screen_size() const override; 73 74 wf::binding_t *add_key(option_sptr_t<keybinding_t> key, 75 wf::key_callback*) override; 76 wf::binding_t *add_axis(option_sptr_t<keybinding_t> axis, 77 wf::axis_callback*) override; 78 wf::binding_t *add_button(option_sptr_t<buttonbinding_t> button, 79 wf::button_callback*) override; 80 wf::binding_t *add_activator(option_sptr_t<activatorbinding_t> activator, 81 wf::activator_callback*) override; 82 void rem_binding(wf::binding_t *binding) override; 83 void rem_binding(void *callback) override; 84 85 /** 86 * Set the output as inhibited, so that no plugins can be activated 87 * except those that ignore inhibitions. 88 */ 89 void inhibit_plugins(); 90 91 /** 92 * Uninhibit the output. 93 */ 94 void uninhibit_plugins(); 95 96 /** @return true if the output is inhibited */ 97 bool is_inhibited() const; 98 99 /** 100 * @return The currently active input grab interface, or nullptr if none 101 */ 102 plugin_grab_interface_t *get_input_grab_interface(); 103 104 /** @return The bindings repository of the output */ 105 bindings_repository_t& get_bindings(); 106 107 /** Set the effective resolution of the output */ 108 void set_effective_size(const wf::dimensions_t& size); 109 }; 110 } 111