Skip to content

Commit

Permalink
feature: implementation of xdg_activation_v1 because I want my auto f…
Browse files Browse the repository at this point in the history
…ocuses (#3639)

[Screencast from 2024-10-16
16-21-05.webm](https://github.com/user-attachments/assets/86f9b0bf-181c-4aab-acfd-4ceb1e4e2c38)

## What's new?
- Added the xdg_activation_v1 protocol
- Implemented the xdg_activation_v1 protocol

## To test
- Run `miral-shell`
- Open `gnome-terminal`
- Run `gedit`
- Focus `gnome-terminal` again
- Run `gedit` again
- Note that `gedit` gets focus 🪄

Similarly:
- Open up `emacs`
- Open up `firefox`
- In emacs, write `https://google.com`
- Ctrl + Click the link
- Watch as firefox gets focus!

## Open questions
- The "timeout" is not configurable at the moment, but perhaps it should
be. However, I don't think we do per-protocol options AFAICT

## Todos
- I should probably write some WLCS tests!
  • Loading branch information
AlanGriffiths authored Oct 30, 2024
2 parents 18698c2 + ded0522 commit faa942b
Show file tree
Hide file tree
Showing 8 changed files with 714 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/server/frontend_wayland/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ set(
${PROJECT_SOURCE_DIR}/src/include/server/mir/frontend/buffer_stream.h
wp_viewporter.cpp wp_viewporter.h
fractional_scale_v1.cpp fractional_scale_v1.h
xdg_activation_v1.cpp xdg_activation_v1.h
)

add_custom_command(
Expand Down Expand Up @@ -113,5 +114,6 @@ target_link_libraries(mirfrontend-wayland
mircore
PRIVATE
PkgConfig::GIOUnix
PkgConfig::UUID
)

7 changes: 5 additions & 2 deletions src/server/frontend_wayland/wayland_connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ mf::WaylandConnector::WaylandConnector(
WaylandProtocolExtensionFilter const& extension_filter,
bool enable_key_repeat,
std::shared_ptr<scene::SessionLock> const& session_lock,
std::shared_ptr<mir::DecorationStrategy> const& decoration_strategy)
std::shared_ptr<mir::DecorationStrategy> const& decoration_strategy,
std::shared_ptr<scene::SessionCoordinator> const& session_coordinator)
: extension_filter{extension_filter},
display{wl_display_create(), &cleanup_display},
pause_signal{eventfd(0, EFD_CLOEXEC | EFD_SEMAPHORE)},
Expand Down Expand Up @@ -328,7 +329,9 @@ mf::WaylandConnector::WaylandConnector(
main_loop,
desktop_file_manager,
session_lock_,
decoration_strategy});
decoration_strategy,
session_coordinator,
keyboard_observer_registrar});

shm_global = std::make_unique<WlShm>(display.get(), executor);

Expand Down
6 changes: 5 additions & 1 deletion src/server/frontend_wayland/wayland_connector.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class IdleHub;
class Surface;
class TextInputHub;
class SessionLock;
class SessionCoordinator;
}
namespace time
{
Expand Down Expand Up @@ -113,6 +114,8 @@ class WaylandExtensions
std::shared_ptr<DesktopFileManager> desktop_file_manager;
std::shared_ptr<scene::SessionLock> session_lock;
std::shared_ptr<mir::DecorationStrategy> decoration_strategy;
std::shared_ptr<scene::SessionCoordinator> session_coordinator;
std::shared_ptr<ObserverRegistrar<input::KeyboardObserver>> keyboard_observer_registrar;
};

WaylandExtensions() = default;
Expand Down Expand Up @@ -165,7 +168,8 @@ class WaylandConnector : public Connector
WaylandProtocolExtensionFilter const& extension_filter,
bool enable_key_repeat,
std::shared_ptr<scene::SessionLock> const& session_lock,
std::shared_ptr<DecorationStrategy> const& decoration_strategy);
std::shared_ptr<DecorationStrategy> const& decoration_strategy,
std::shared_ptr<scene::SessionCoordinator> const& session_coordinator);

~WaylandConnector() override;

Expand Down
15 changes: 14 additions & 1 deletion src/server/frontend_wayland/wayland_default_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "wl_seat.h"
#include "wl_shell.h"
#include "wlr_screencopy_v1.h"
#include "xdg_activation_v1.h"
#include "xdg-decoration-unstable-v1_wrapper.h"
#include "xdg_decoration_unstable_v1.h"
#include "xdg_output_v1.h"
Expand Down Expand Up @@ -226,6 +227,16 @@ std::vector<ExtensionBuilder> const internal_extension_builders = {
{
return mf::create_fractional_scale_v1(ctx.display);
}),
make_extension_builder<mw::XdgActivationV1>([](auto const& ctx)
{
return mf::create_xdg_activation_v1(
ctx.display,
ctx.shell,
ctx.session_coordinator,
ctx.main_loop,
ctx.keyboard_observer_registrar,
*ctx.wayland_executor);
}),
};

ExtensionBuilder const xwayland_builder {
Expand Down Expand Up @@ -327,6 +338,7 @@ auto mf::get_standard_extensions() -> std::vector<std::string>
mw::TextInputManagerV3::interface_name,
mw::MirShellV1::interface_name,
mw::XdgDecorationManagerV1::interface_name,
mw::XdgActivationV1::interface_name,
mw::FractionalScaleManagerV1::interface_name};
}

Expand Down Expand Up @@ -384,7 +396,8 @@ std::shared_ptr<mf::Connector>
wayland_extension_filter,
enable_repeat,
the_session_lock(),
the_decoration_strategy());
the_decoration_strategy(),
the_session_coordinator());
});
}

Expand Down
Loading

0 comments on commit faa942b

Please sign in to comment.