Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[x11-platform] Make window title a configuration option #2349

Merged
merged 14 commits into from Mar 3, 2022
12 changes: 6 additions & 6 deletions src/platforms/x11/graphics/display.cpp
Expand Up @@ -79,7 +79,7 @@ class XGLContext : public mir::renderer::gl::Context
}

mgx::X11Window::X11Window(mx::X11Resources* x11_resources,
std::string* title,
std::string title,
EGLDisplay egl_dpy,
geom::Size const size,
EGLConfig const egl_cfg)
Expand Down Expand Up @@ -119,12 +119,12 @@ mgx::X11Window::X11Window(mx::X11Resources* x11_resources,
char buffer[128] = { '\0' };
if (gethostname(buffer, sizeof buffer - 1) == 0)
{
*title += " - ";
*title += buffer;
title += " - ";
title += buffer;
}
}

conn->change_property(win, x11_resources->_NET_WM_NAME, x11_resources->UTF8_STRING, 8, title->size(), title->c_str());
conn->change_property(win, x11_resources->_NET_WM_NAME, x11_resources->UTF8_STRING, 8, title.size(), title.c_str());

conn->map_window(win);
}
Expand All @@ -145,7 +145,7 @@ unsigned long mgx::X11Window::red_mask() const
}

mgx::Display::Display(std::shared_ptr<mir::X::X11Resources> const& x11_resources,
std::shared_ptr<std::string> const& title,
std::string const title,
std::vector<X11OutputConfig> const& requested_sizes,
std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
std::shared_ptr<GLConfig> const& gl_config,
Expand All @@ -164,7 +164,7 @@ mgx::Display::Display(std::shared_ptr<mir::X::X11Resources> const& x11_resources
auto actual_size = requested_size.size;
auto window = std::make_unique<X11Window>(
x11_resources.get(),
title.get(),
title,
shared_egl.display(),
actual_size,
shared_egl.config());
Expand Down
6 changes: 3 additions & 3 deletions src/platforms/x11/graphics/display.h
Expand Up @@ -53,7 +53,7 @@ class X11Window
{
public:
X11Window(mir::X::X11Resources* x11_resources,
std::string* title,
std::string title,
EGLDisplay egl_dpy,
geometry::Size const size,
EGLConfig const egl_cfg);
Expand All @@ -64,7 +64,7 @@ class X11Window

private:
mir::X::X11Resources* const x11_resources;
std::string* const title;
std::string const title;
graysonguarino marked this conversation as resolved.
Show resolved Hide resolved
xcb_window_t win;
unsigned long r_mask;
};
Expand All @@ -73,7 +73,7 @@ class Display : public graphics::Display
{
public:
explicit Display(std::shared_ptr<mir::X::X11Resources> const& x11_resources,
std::shared_ptr<std::string> const& title,
std::string const title,
std::vector<X11OutputConfig> const& requested_size,
std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
std::shared_ptr<GLConfig> const& gl_config,
Expand Down
3 changes: 1 addition & 2 deletions src/platforms/x11/graphics/graphics.cpp
Expand Up @@ -62,7 +62,7 @@ mir::UniqueModulePtr<mg::DisplayPlatform> create_display_platform(

return mir::make_module_ptr<mgx::Platform>(
std::move(x11_resources),
std::move(std::make_shared<std::string>(title)),
std::move(title),
move(output_sizes),
report
);
Expand All @@ -86,7 +86,6 @@ void add_graphics_platform_options(boost::program_options::options_description&
"[mir-on-X specific] Colon separated list of WIDTHxHEIGHT sizes for \"output\" windows."
" ^SCALE may also be appended to any output");

mir::assert_entry_point_signature<mg::AddPlatformOptions>(&add_graphics_platform_options);
config.add_options()
(x11_window_title_option_name,
boost::program_options::value<std::string>()->default_value("Mir on X"),
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/x11/graphics/platform.cpp
Expand Up @@ -108,7 +108,7 @@ auto mgx::Platform::parse_output_sizes(std::string output_sizes) -> std::vector<
}

mgx::Platform::Platform(std::shared_ptr<mir::X::X11Resources> const& x11_resources,
std::shared_ptr<std::string> const& title,
std::string const title,
std::vector<X11OutputConfig> output_sizes,
std::shared_ptr<mg::DisplayReport> const& report)
: x11_resources{x11_resources},
Expand Down
4 changes: 2 additions & 2 deletions src/platforms/x11/graphics/platform.h
Expand Up @@ -61,7 +61,7 @@ class Platform : public graphics::DisplayPlatform
static auto parse_output_sizes(std::string output_sizes) -> std::vector<X11OutputConfig>;

explicit Platform(std::shared_ptr<mir::X::X11Resources> const& x11_resources,
std::shared_ptr<std::string> const& title,
std::string const title,
std::vector<X11OutputConfig> output_sizes,
std::shared_ptr<DisplayReport> const& report);
~Platform() = default;
Expand All @@ -72,7 +72,7 @@ class Platform : public graphics::DisplayPlatform
std::shared_ptr<GLConfig> const& gl_config) override;
private:
std::shared_ptr<mir::X::X11Resources> const x11_resources;
std::shared_ptr<std::string> const title;
std::string const title;
std::shared_ptr<DisplayReport> const report;
std::vector<X11OutputConfig> const output_sizes;
};
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/platforms/x11/test_display.cpp
Expand Up @@ -103,7 +103,7 @@ class X11DisplayTest : public ::testing::Test
{
return std::make_shared<mgx::Display>(
mt::fake_shared(x11_resources),
std::make_shared<std::string>("Mir on X"),
std::string("Mir on X"),
graysonguarino marked this conversation as resolved.
Show resolved Hide resolved
sizes,
mt::fake_shared(null_display_configuration_policy),
mt::fake_shared(mock_gl_config),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/platforms/x11/test_display_generic.cpp
Expand Up @@ -91,7 +91,7 @@ class DisplayTestGeneric : public ::testing::Test
{
auto const platform = std::make_shared<mg::X::Platform>(
std::make_shared<mtd::MockX11Resources>(),
std::make_shared<std::string>("Mir on X"),
std::string("Mir on X"),
std::vector<mg::X::X11OutputConfig>{{{1280, 1024}}},
std::make_shared<mir::report::null::DisplayReport>());
return platform->create_display(
Expand Down
4 changes: 2 additions & 2 deletions tests/unit-tests/platforms/x11/test_platform.cpp
Expand Up @@ -69,7 +69,7 @@ class X11GraphicsPlatformTest : public ::testing::Test
{
return std::make_shared<mg::X::Platform>(
std::make_shared<mtd::MockX11Resources>(),
std::make_shared<std::string>("Mir on X"),
std::string("Mir on X"),
graysonguarino marked this conversation as resolved.
Show resolved Hide resolved
std::vector<mg::X::X11OutputConfig>{{{1280, 1024}}},
std::make_shared<mir::report::null::DisplayReport>());
}
Expand All @@ -89,7 +89,7 @@ TEST_F(X11GraphicsPlatformTest, failure_to_open_x11_display_results_in_an_error)
{
std::make_shared<mg::X::Platform>(
nullptr,
std::make_shared<std::string>("Mir on X"),
std::string("Mir on X"),
graysonguarino marked this conversation as resolved.
Show resolved Hide resolved
std::vector<mg::X::X11OutputConfig>{{{1280, 1024}}},
std::make_shared<mir::report::null::DisplayReport>());
}, std::exception);
Expand Down