-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows windows to become click-through.
- Loading branch information
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<wayfire> | ||
<plugin name="ghost"> | ||
<_short>Ghost Windows</_short> | ||
<category>Window Management</category> | ||
<option name="ghost_match" type="string"> | ||
<_short>Ghosted Windows</_short> | ||
<_long>Automatically ghosts the matched windows.</_long> | ||
<default></default> | ||
</option> | ||
<option name="ghost_window" type="activator"> | ||
<_short>Ghost Window</_short> | ||
<_long>Ghosts the active window.</_long> | ||
<default></default> | ||
</option> | ||
</plugin> | ||
</wayfire> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#include <wayfire/output.hpp> | ||
#include <wayfire/opengl.hpp> | ||
#include <wayfire/core.hpp> | ||
#include <wayfire/plugin.hpp> | ||
#include <wayfire/matcher.hpp> | ||
#include <wayfire/view-transform.hpp> | ||
#include <wayfire/signal-definitions.hpp> | ||
#include <wayfire/toplevel-view.hpp> | ||
#include <wayfire/window-manager.hpp> | ||
#include <wayfire/view-transform.hpp> | ||
#include <wayfire/txn/transaction-manager.hpp> | ||
#include <wayfire/scene-render.hpp> | ||
#include <wayfire/plugins/ipc/ipc-activator.hpp> | ||
|
||
const std::string shade_transformer_name = "ghost_transformer"; | ||
|
||
namespace wf | ||
{ | ||
namespace ghost | ||
{ | ||
using namespace wf::scene; | ||
class ghost_view : public wf::scene::view_2d_transformer_t | ||
{ | ||
wayfire_view view; | ||
|
||
public: | ||
|
||
ghost_view(wayfire_view view) : wf::scene::view_2d_transformer_t(view) | ||
{ | ||
this->view = view; | ||
} | ||
|
||
std::optional<wf::scene::input_node_t> find_node_at(const wf::pointf_t& at) override | ||
{ | ||
return {}; | ||
} | ||
|
||
virtual ~ghost_view() | ||
{} | ||
}; | ||
|
||
class ghost_plugin : public wf::plugin_interface_t | ||
{ | ||
wf::ipc_activator_t ghost_window{"ghost/ghost_window"}; | ||
wf::view_matcher_t ghost_match{"ghost/ghost_match"}; | ||
|
||
void pop_transformer(wayfire_view view) | ||
{ | ||
if (view->get_transformed_node()->get_transformer(shade_transformer_name)) | ||
{ | ||
view->get_transformed_node()->rem_transformer(shade_transformer_name); | ||
} | ||
} | ||
|
||
void remove_shade_transformers() | ||
{ | ||
for (auto& view : wf::get_core().get_all_views()) | ||
{ | ||
pop_transformer(view); | ||
} | ||
} | ||
|
||
std::shared_ptr<wf::ghost::ghost_view> ensure_transformer(wayfire_view view) | ||
{ | ||
auto tmgr = view->get_transformed_node(); | ||
if (auto tr = tmgr->get_transformer<wf::ghost::ghost_view>(shade_transformer_name)) | ||
{ | ||
return tr; | ||
} | ||
|
||
auto node = std::make_shared<wf::ghost::ghost_view>(view); | ||
tmgr->add_transformer(node, wf::TRANSFORMER_2D, shade_transformer_name); | ||
auto tr = tmgr->get_transformer<wf::ghost::ghost_view>(shade_transformer_name); | ||
|
||
return tr; | ||
} | ||
|
||
public: | ||
|
||
void init() override | ||
{ | ||
for (auto& view : wf::get_core().get_all_views()) | ||
{ | ||
if (ghost_match.matches(view)) | ||
{ | ||
ensure_transformer(view); | ||
} | ||
} | ||
|
||
ghost_window.set_handler(ghost_view_cb); | ||
wf::get_core().connect(&on_view_map); | ||
} | ||
|
||
wf::ipc_activator_t::handler_t ghost_view_cb = [=] (wf::output_t *output, wayfire_view view) | ||
{ | ||
ensure_transformer(view); | ||
return true; | ||
}; | ||
|
||
wf::signal::connection_t<wf::view_mapped_signal> on_view_map = [=] (wf::view_mapped_signal *ev) | ||
{ | ||
if (ghost_match.matches(ev->view)) | ||
{ | ||
ensure_transformer(ev->view); | ||
} | ||
}; | ||
|
||
void fini() override | ||
{ | ||
remove_shade_transformers(); | ||
on_view_map.disconnect(); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
DECLARE_WAYFIRE_PLUGIN(wf::ghost::ghost_plugin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters