Browse Source

EmscriptenApplication: move private static functions to an anonymous namespace

pull/480/head
Pablo Escobar 6 years ago
parent
commit
23ec25d582
  1. 62
      src/Magnum/Platform/EmscriptenApplication.cpp
  2. 4
      src/Magnum/Platform/EmscriptenApplication.h

62
src/Magnum/Platform/EmscriptenApplication.cpp

@ -181,6 +181,36 @@ namespace {
return Key::Unknown; return Key::Unknown;
} }
std::string canvasId() {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
char* id = reinterpret_cast<char*>(EM_ASM_INT({
return allocate(intArrayFromString(Module['canvas'].id), 'i8', ALLOC_NORMAL);
}));
#pragma GCC diagnostic pop
std::string str = id;
std::free(id);
return str;
}
bool checkForDeprecatedEmscriptenTargetBehavior() {
/* Emscripten 1.38.27 changed to generic CSS selectors from element IDs
depending on -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 being
set.
https://github.com/emscripten-core/emscripten/pull/7977
There is no simple way to check for compiler options so check
whether the new CSS selectors are being used. If so, it should find
canvas#[id] which is any canvas with the ID of Module.canvas.
The old target behavior will look for an element with id="canvas#[id]"
which could theoretically exist but that's highly unlikely. */
bool deprecated = true;
Vector2d tempSize;
if(emscripten_get_element_css_size(("canvas#" + canvasId()).data(), &tempSize.x(), &tempSize.y()) >= 0) {
deprecated = false;
}
return deprecated;
}
} }
EmscriptenApplication::EmscriptenApplication(const Arguments& arguments): EmscriptenApplication{arguments, Configuration{}} {} EmscriptenApplication::EmscriptenApplication(const Arguments& arguments): EmscriptenApplication{arguments, Configuration{}} {}
@ -750,38 +780,6 @@ void EmscriptenApplication::exit(int) {
_flags |= Flag::ExitRequested; _flags |= Flag::ExitRequested;
} }
bool EmscriptenApplication::checkForDeprecatedEmscriptenTargetBehavior() {
/* Emscripten 1.38.27 changed to generic CSS selectors from element IDs
depending on -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 being
set.
https://github.com/emscripten-core/emscripten/pull/7977
There is no simple way to check for compiler options so check
whether the new CSS selectors are being used. If so, it should find
canvas#[id] which is any canvas with the ID of Module.canvas.
The old target behavior will look for an element with id="canvas#[id]"
which could theoretically exist but that's highly unlikely. */
bool deprecated = true;
#ifdef EMSCRIPTEN_EVENT_TARGET_WINDOW
Vector2d tempSize;
if(emscripten_get_element_css_size(("canvas#" + canvasId()).data(), &tempSize.x(), &tempSize.y()) >= 0) {
deprecated = false;
}
#endif
return deprecated;
}
std::string EmscriptenApplication::canvasId() {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
char* id = reinterpret_cast<char*>(EM_ASM_INT({
return allocate(intArrayFromString(Module['canvas'].id), 'i8', ALLOC_NORMAL);
}));
#pragma GCC diagnostic pop
std::string str = id;
std::free(id);
return str;
}
EmscriptenApplication::MouseEvent::Button EmscriptenApplication::MouseEvent::button() const { EmscriptenApplication::MouseEvent::Button EmscriptenApplication::MouseEvent::button() const {
return Button(_event.button); return Button(_event.button);
} }

4
src/Magnum/Platform/EmscriptenApplication.h

@ -874,10 +874,6 @@ class EmscriptenApplication {
* @} * @}
*/ */
private:
static bool checkForDeprecatedEmscriptenTargetBehavior();
static std::string canvasId();
private: private:
enum class Flag: UnsignedByte { enum class Flag: UnsignedByte {
Redraw = 1 << 0, Redraw = 1 << 0,

Loading…
Cancel
Save