Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions metadata/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ install_data('zoom.xml', install_dir: conf_data.get('PLUGIN_XML_DIR'))
install_data('scale-title-filter.xml', install_dir: conf_data.get('PLUGIN_XML_DIR'))
install_data('wsets.xml', install_dir: conf_data.get('PLUGIN_XML_DIR'))
install_data('wayfire-shell.xml', install_dir: conf_data.get('PLUGIN_XML_DIR'))
install_data('xdg-activation.xml', install_dir: conf_data.get('PLUGIN_XML_DIR'))
8 changes: 8 additions & 0 deletions metadata/xdg-activation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<wayfire>
<plugin name="xdg-activation">
<_short>XDG Activation Protocol</_short>
<_long>An implementation of the xdg-activation-v1 protocol.</_long>
<category>Utility</category>
</plugin>
</wayfire>
2 changes: 1 addition & 1 deletion plugins/protocols/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
protocol_plugins = [
'foreign-toplevel', 'gtk-shell', 'wayfire-shell',
'foreign-toplevel', 'gtk-shell', 'wayfire-shell', 'xdg-activation',
]

all_include_dirs = [wayfire_api_inc, wayfire_conf_inc, plugins_common_inc]
Expand Down
64 changes: 64 additions & 0 deletions plugins/protocols/xdg-activation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "wayfire/core.hpp"
#include "wayfire/signal-definitions.hpp"
#include "wayfire/view.hpp"
#include <memory>
#include <wayfire/plugin.hpp>
#include <wayfire/view.hpp>
#include <wayfire/toplevel-view.hpp>
#include <wayfire/nonstd/wlroots-full.hpp>
#include <wayfire/window-manager.hpp>
#include "config.h"

class wayfire_xdg_activation_protocol_impl : public wf::plugin_interface_t
{
public:
void init() override
{
xdg_activation = wlr_xdg_activation_v1_create(wf::get_core().display);
xdg_activation_request_activate.notify = xdg_activation_handle_request_activate;

wl_signal_add(&xdg_activation->events.request_activate, &xdg_activation_request_activate);
}

void fini() override
{}

bool is_unloadable() override
{
return false;
}

private:
static void xdg_activation_handle_request_activate(struct wl_listener *listener, void *data)
{
auto event = static_cast<const struct wlr_xdg_activation_v1_request_activate_event*>(data);

wayfire_view view = wf::wl_surface_to_wayfire_view(event->surface->resource);
if (!view)
{
LOGE("Could not get view");
return;
}

auto toplevel = wf::toplevel_cast(view);
if (!toplevel)
{
LOGE("Could not get toplevel view");
return;
}

if (!event->token->seat)
{
LOGI("Denying focus request, seat wasn't supplied");
return;
}

LOGI("Activating view");
wf::get_core().default_wm->focus_request(toplevel);
}

struct wlr_xdg_activation_v1 *xdg_activation;
struct wl_listener xdg_activation_request_activate;
};

DECLARE_WAYFIRE_PLUGIN(wayfire_xdg_activation_protocol_impl);
3 changes: 3 additions & 0 deletions src/api/wayfire/nonstd/wlroots-full.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,7 @@ extern "C"
#include <wlr/types/wlr_relative_pointer_v1.h>
#include <wlr/types/wlr_text_input_v3.h>
#include <wlr/types/wlr_primary_selection_v1.h>

// Activation plugin
#include <wlr/types/wlr_xdg_activation_v1.h>
}