Browse Source

Platform: port *XApplication away from std::string.

ktx1-detection
Vladimír Vondruš 4 years ago
parent
commit
59989fa3ea
  1. 5
      src/Magnum/Platform/AbstractXApplication.cpp
  2. 23
      src/Magnum/Platform/AbstractXApplication.h
  3. 8
      src/Magnum/Platform/Test/GlxApplicationTest.cpp
  4. 8
      src/Magnum/Platform/Test/XEglApplicationTest.cpp

5
src/Magnum/Platform/AbstractXApplication.cpp

@ -37,6 +37,8 @@
namespace Magnum { namespace Platform {
using namespace Containers::Literals;
AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler<GLConfiguration, Display*, VisualID, Window>* contextHandler, const Arguments& arguments, const Configuration& configuration, const GLConfiguration& glConfiguration): AbstractXApplication{contextHandler, arguments, NoCreate} {
create(configuration, glConfiguration);
}
@ -202,7 +204,8 @@ AbstractXApplication::GLConfiguration::GLConfiguration(): _version(GL::Version::
AbstractXApplication::GLConfiguration::~GLConfiguration() = default;
AbstractXApplication::Configuration::Configuration():
_title("Magnum X Application"), _size(800, 600) {}
_title{Containers::String::nullTerminatedGlobalView("Magnum X Application"_s)},
_size(800, 600) {}
AbstractXApplication::Configuration::~Configuration() = default;
}}

23
src/Magnum/Platform/AbstractXApplication.h

@ -33,10 +33,10 @@
#include "Magnum/configure.h"
#ifdef MAGNUM_TARGET_GL
#include <string>
#include <Corrade/Containers/EnumSet.h>
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@ -64,6 +64,11 @@ typedef int Bool;
#include "Magnum/Math/Vector2.h"
#include "Magnum/Platform/GLContext.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* Some APIs used to take or return a std::string before */
#include <Corrade/Containers/StringStl.h>
#endif
namespace Magnum { namespace Platform {
namespace Implementation {
@ -457,8 +462,14 @@ class AbstractXApplication::Configuration {
/*implicit*/ Configuration();
~Configuration();
/** @brief Window title */
std::string title() const { return _title; }
/**
* @brief Window title
*
* The returned view is always
* @relativeref{Corrade,Containers::StringViewFlag::NullTerminated} and
* is valid until the next call to @ref setTitle().
*/
Containers::StringView title() const { return _title; }
/**
* @brief Set window title
@ -466,8 +477,8 @@ class AbstractXApplication::Configuration {
*
* Default is @cpp "Magnum X Application" @ce.
*/
Configuration& setTitle(std::string title) {
_title = std::move(title);
Configuration& setTitle(Containers::StringView title) {
_title = Containers::String::nullTerminatedGlobalView(title);
return *this;
}
@ -486,7 +497,7 @@ class AbstractXApplication::Configuration {
}
private:
std::string _title;
Containers::String _title;
Vector2i _size;
};

8
src/Magnum/Platform/Test/GlxApplicationTest.cpp

@ -29,6 +29,8 @@
namespace Magnum { namespace Platform { namespace Test { namespace {
using namespace Containers::Literals;
struct GlxApplicationTest: Platform::Application {
explicit GlxApplicationTest(const Arguments& arguments);
@ -50,10 +52,12 @@ GlxApplicationTest::GlxApplicationTest(const Arguments& arguments): Platform::Ap
return;
}
Configuration conf;
conf.setTitle("Window title that should have no exclamation mark!!"_s.exceptSuffix(2));
if(args.isSet("quiet"))
create(Configuration{}, GLConfiguration{}.addFlags(GLConfiguration::Flag::QuietLog));
create(conf, GLConfiguration{}.addFlags(GLConfiguration::Flag::QuietLog));
else
create();
create(conf);
}
}}}}

8
src/Magnum/Platform/Test/XEglApplicationTest.cpp

@ -29,6 +29,8 @@
namespace Magnum { namespace Platform { namespace Test { namespace {
using namespace Containers::Literals;
struct XEglApplicationTest: Platform::Application {
explicit XEglApplicationTest(const Arguments& arguments);
@ -50,10 +52,12 @@ XEglApplicationTest::XEglApplicationTest(const Arguments& arguments): Platform::
return;
}
Configuration conf;
conf.setTitle("Window title that should have no exclamation mark!!"_s.exceptSuffix(2));
if(args.isSet("quiet"))
create(Configuration{}, GLConfiguration{}.addFlags(GLConfiguration::Flag::QuietLog));
create(conf, GLConfiguration{}.addFlags(GLConfiguration::Flag::QuietLog));
else
create();
create(conf);
}
}}}}

Loading…
Cancel
Save