Skip to content

Commit

Permalink
feature: adding wayland-surface-title option for the wayland platform
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkae committed Sep 25, 2024
1 parent 15575c6 commit e626d5d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/platforms/wayland/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ mgw::Display::Display(
std::shared_ptr<WlDisplayProvider> provider,
std::shared_ptr<GLConfig> const&,
std::shared_ptr<DisplayReport> const& report,
std::optional<std::string> const& app_id) :
DisplayClient{wl_display, std::move(provider), app_id},
std::optional<std::string> const& app_id,
std::optional<std::string> const& title) :
DisplayClient{wl_display, std::move(provider), app_id, title},
report{report},
shutdown_signal{::eventfd(0, EFD_CLOEXEC)},
flush_signal{::eventfd(0, EFD_SEMAPHORE)},
Expand Down
3 changes: 2 additions & 1 deletion src/platforms/wayland/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class Display : public mir::graphics::Display,
std::shared_ptr<WlDisplayProvider> provider,
std::shared_ptr<GLConfig> const& gl_config,
std::shared_ptr<DisplayReport> const& report,
std::optional<std::string> const& app_id);
std::optional<std::string> const& app_id,
std::optional<std::string> const& title);

~Display();

Expand Down
6 changes: 5 additions & 1 deletion src/platforms/wayland/displayclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ void mgw::DisplayClient::Output::done()
xdg_toplevel_set_fullscreen(shell_toplevel, output);
if (owner_->app_id)
xdg_toplevel_set_app_id(shell_toplevel, owner_->app_id.value().c_str());
if (owner_->title)
xdg_toplevel_set_title(shell_toplevel, owner_->title.value().c_str());
wl_surface_set_buffer_scale(surface, host_scale);
wl_surface_commit(surface);

Expand Down Expand Up @@ -450,10 +452,12 @@ void mgw::DisplayClient::Output::set_next_image(std::unique_ptr<Framebuffer> con
mgw::DisplayClient::DisplayClient(
wl_display* display,
std::shared_ptr<WlDisplayProvider> provider,
std::optional<std::string> const& app_id) :
std::optional<std::string> const& app_id,
std::optional<std::string> const& title) :
display{display},
provider{std::move(provider)},
app_id{app_id},
title{title},
keyboard_context_{xkb_context_new(XKB_CONTEXT_NO_FLAGS)},
registry{nullptr, [](auto){}}
{
Expand Down
4 changes: 3 additions & 1 deletion src/platforms/wayland/displayclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class DisplayClient
DisplayClient(
wl_display* display,
std::shared_ptr<WlDisplayProvider> provider,
std::optional<std::string> const& app_id);
std::optional<std::string> const& app_id,
std::optional<std::string> const& title);

virtual ~DisplayClient();

Expand All @@ -64,6 +65,7 @@ class DisplayClient
wl_display* const display;
std::shared_ptr<WlDisplayProvider> const provider;
std::optional<std::string> const app_id;
std::optional<std::string> const title;

auto display_configuration() const -> std::unique_ptr<DisplayConfiguration>;
void for_each_display_sync_group(const std::function<void(DisplaySyncGroup&)>& f);
Expand Down
6 changes: 4 additions & 2 deletions src/platforms/wayland/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ auto make_initialised_egl_display(struct wl_display* wl_display) -> EGLDisplay
mgw::Platform::Platform(
struct wl_display* const wl_display,
std::shared_ptr<mg::DisplayReport> const& report,
std::optional<std::string> const& app_id) :
std::optional<std::string> const& app_id,
std::optional<std::string> const& title) :
wl_display{wl_display},
report{report},
app_id{app_id},
title{title},
provider{std::make_shared<WlDisplayProvider>(make_initialised_egl_display(wl_display))}
{
}
Expand All @@ -83,7 +85,7 @@ mir::UniqueModulePtr<mg::Display> mgw::Platform::create_display(
std::shared_ptr<DisplayConfigurationPolicy> const&,
std::shared_ptr<GLConfig> const& gl_config)
{
return mir::make_module_ptr<mgw::Display>(wl_display, provider, gl_config, report, app_id);
return mir::make_module_ptr<mgw::Display>(wl_display, provider, gl_config, report, app_id, title);
}

auto mgw::Platform::maybe_create_provider(const DisplayProvider::Tag& type_tag) -> std::shared_ptr<DisplayProvider>
Expand Down
4 changes: 3 additions & 1 deletion src/platforms/wayland/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class Platform : public graphics::DisplayPlatform
public:
Platform(struct wl_display* const wl_display,
std::shared_ptr<DisplayReport> const& report,
std::optional<std::string> const& app_id);
std::optional<std::string> const& app_id,
std::optional<std::string> const& title);
~Platform() = default;

UniqueModulePtr<Display> create_display(
Expand All @@ -50,6 +51,7 @@ class Platform : public graphics::DisplayPlatform
struct wl_display* const wl_display;
std::shared_ptr<DisplayReport> const report;
std::optional<std::string> const app_id;
std::optional<std::string> const title;

std::shared_ptr<WlDisplayProvider> const provider;
};
Expand Down
17 changes: 14 additions & 3 deletions src/platforms/wayland/platform_symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ mir::ModuleProperties const description = {
mir::libname()
};

char const* wayland_surface_app_id_option{"wayland-surface-app-id"};
char const* wayland_surface_app_id_option_description{"Defines the XdgToplevel app id on the surface created by the wayland platform"};
const char* const wayland_surface_app_id_option{"wayland-surface-app-id"};
const char* const wayland_surface_app_id_option_description{"Defines the XdgToplevel app id on the surface created by the wayland platform"};

const char* const wayland_surface_title_option{"wayland-surface-title"};
const char* const wayland_surface_title_option_description{"Defines the XdgTopLevel title on the surface created by the wayland platform"};
}

mir::UniqueModulePtr<mg::DisplayPlatform> create_display_platform(
Expand All @@ -55,8 +58,12 @@ mir::UniqueModulePtr<mg::DisplayPlatform> create_display_platform(
if (options->is_set(wayland_surface_app_id_option))
app_id = options->get<std::string>(wayland_surface_app_id_option);

std::optional<std::string> title;
if (options->is_set(wayland_surface_title_option))
app_id = options->get<std::string>(wayland_surface_title_option);

mir::assert_entry_point_signature<mg::CreateDisplayPlatform>(&create_display_platform);
return mir::make_module_ptr<mgw::Platform>(mpw::connection(*options), report, app_id);
return mir::make_module_ptr<mgw::Platform>(mpw::connection(*options), report, app_id, title);
}

void add_graphics_platform_options(boost::program_options::options_description& config)
Expand All @@ -67,6 +74,10 @@ void add_graphics_platform_options(boost::program_options::options_description&
(wayland_surface_app_id_option,
boost::program_options::value<std::string>(),
wayland_surface_app_id_option_description);
config.add_options()
(wayland_surface_title_option,
boost::program_options::value<std::string>(),
wayland_surface_title_option_description);
}

auto probe_graphics_platform(
Expand Down

0 comments on commit e626d5d

Please sign in to comment.