-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement xdg-activation v1 protocol plugin
- Loading branch information
Showing
4 changed files
with
77 additions
and
1 deletion.
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
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,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> |
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,67 @@ | ||
#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/nonstd/wlroots-full.hpp> | ||
#include <wayfire/window-manager.hpp> | ||
#include "config.h" | ||
|
||
extern "C" | ||
{ | ||
#include <wlr/types/wlr_xdg_activation_v1.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) | ||
{ | ||
LOGI("Could not get view"); | ||
return; | ||
} | ||
|
||
if (!event->token->seat) | ||
{ | ||
LOGI("Denying focus request, seat wasn't supplied"); | ||
return; | ||
} | ||
|
||
if (!view->get_output()) | ||
{ | ||
LOGI("View has no output"); | ||
return; | ||
} | ||
|
||
LOGI("Activating view"); | ||
view->get_output()->focus_view(view, true); | ||
} | ||
|
||
struct wlr_xdg_activation_v1 *xdg_activation; | ||
struct wl_listener xdg_activation_request_activate; | ||
}; | ||
|
||
DECLARE_WAYFIRE_PLUGIN(wayfire_xdg_activation_protocol_impl); |