little fixes here and there.

This commit is contained in:
Andrea Blankenstijn 2021-08-24 00:00:28 +02:00
parent f6ae2c51e8
commit dc243a9fdf
3 changed files with 7 additions and 11 deletions

View File

@ -37,7 +37,7 @@ namespace bwidgets
const std::string what {w == "unknown" ? SDL_GetError() : w};
if (code < 0) throw E(what);
}
else if (success(code)) throw E(w);
else if (!success(code)) throw E(w.data());
return code;
}

View File

@ -119,14 +119,9 @@ auto Font::find(const std::string_view pat) -> std::string
"pattern parsing failed"),
[](auto* ptr) { FcPatternDestroy(ptr); });
// Don't check for error because it looks like it returns an error code when
// used with this way. But neverless things doesn't work well without
// calling it.
// TODO: get it to work properly!
/* success_or_throw<FCError, FcBool>( */
FcConfigSubstitute((*conf)(), (*pattern)(),
FcMatchPattern); //, "FcConfigSubstitute failed",
/* [](auto code) { return code == FcFalse; }); */
success_or_throw<FCError, FcBool>(
FcConfigSubstitute((*conf)(), (*pattern)(), FcMatchPattern),
"FcConfigSubstitute failed", [](auto code) { return code == FcTrue; });
return pattern;
}();

View File

@ -29,9 +29,10 @@ void MouseHandlerImpl::enable_mouse_handler(const SDL_Rect& rel_area,
_add_event_handler({SDL_MOUSEBUTTONUP, [this, mouse_in_rect](const SDL_Event& ev) {
if (_pushed) {
_on_push(_pushed = false);
_click_handler(ev.button);
if (mouse_in_rect({ev.button.x, ev.button.y}))
if (mouse_in_rect({ev.button.x, ev.button.y})) {
focus(true);
_click_handler(ev.button);
}
}
}});
_add_event_handler({SDL_MOUSEMOTION, [this, mouse_in_rect](const SDL_Event& ev) {