diff --git a/src/lib/fcitx-utils/event.cpp b/src/lib/fcitx-utils/event.cpp index 343b74e9f..6d9b913e3 100644 --- a/src/lib/fcitx-utils/event.cpp +++ b/src/lib/fcitx-utils/event.cpp @@ -7,9 +7,8 @@ */ #include "event.h" +#include #include -#include -#include #include #include #include @@ -17,6 +16,10 @@ #include "eventloopinterface.h" #include "macros.h" +#if defined(_WIN32) +#include +#endif + namespace fcitx { class EventLoopPrivate { @@ -69,7 +72,7 @@ bool EventLoop::exec() { void EventLoop::exit() { FCITX_D(); - return d->impl_->exit(); + d->impl_->exit(); } std::unique_ptr EventLoop::addIOEvent(int fd, IOEventFlags flags, diff --git a/src/lib/fcitx-utils/event.h b/src/lib/fcitx-utils/event.h index 1f6f5cdee..2683808a9 100644 --- a/src/lib/fcitx-utils/event.h +++ b/src/lib/fcitx-utils/event.h @@ -7,6 +7,7 @@ #ifndef _FCITX_UTILS_EVENT_H_ #define _FCITX_UTILS_EVENT_H_ +#include #include #include #include @@ -15,6 +16,10 @@ #include #include +#if defined(_WIN32) +#include +#endif + namespace fcitx { using EventLoopFactory = std::function()>; diff --git a/src/lib/fcitx-utils/event_libuv.cpp b/src/lib/fcitx-utils/event_libuv.cpp index 3c9d7d2a1..16b292458 100644 --- a/src/lib/fcitx-utils/event_libuv.cpp +++ b/src/lib/fcitx-utils/event_libuv.cpp @@ -7,6 +7,7 @@ */ #include "event_libuv.h" +#include #include #include #include @@ -21,18 +22,26 @@ #include "log.h" #include "trackableobject.h" +#if defined(_WIN32) +#include +#endif + #define FCITX_LIBUV_DEBUG() FCITX_LOGC(::fcitx::libuv_logcategory, Debug) namespace fcitx { +namespace { + +FCITX_DEFINE_LOG_CATEGORY(libuv_logcategory, "libuv"); + +} + std::unique_ptr createDefaultEventLoop() { return std::make_unique(); } const char *defaultEventLoopImplementation() { return "libuv"; } -FCITX_DEFINE_LOG_CATEGORY(libuv_logcategory, "libuv"); - static int IOEventFlagsToLibUVFlags(IOEventFlags flags) { int result = 0; if (flags & IOEventFlag::In) { diff --git a/src/lib/fcitx-utils/event_libuv.h b/src/lib/fcitx-utils/event_libuv.h index 291d9bf1f..6e67fe133 100644 --- a/src/lib/fcitx-utils/event_libuv.h +++ b/src/lib/fcitx-utils/event_libuv.h @@ -7,6 +7,7 @@ #ifndef _FCITX_UTILS_EVENT_LIBUV_H_ #define _FCITX_UTILS_EVENT_LIBUV_H_ +#include #include #include #include @@ -18,6 +19,10 @@ #include #include +#if defined(_WIN32) +#include +#endif + namespace fcitx { struct UVLoop { @@ -95,9 +100,7 @@ struct LibUVSource : public Interface, public LibUVSourceBase { return state_ == LibUVSourceEnableState::Oneshot; } - inline HandleType *handle() { - return reinterpret_cast(handle_); - } + HandleType *handle() { return reinterpret_cast(handle_); } void init(uv_loop_t *loop) override { handle_ = static_cast(calloc(1, sizeof(HandleType))); diff --git a/src/lib/fcitx-utils/event_sdevent.cpp b/src/lib/fcitx-utils/event_sdevent.cpp index ed5fffdcb..e75d8e955 100644 --- a/src/lib/fcitx-utils/event_sdevent.cpp +++ b/src/lib/fcitx-utils/event_sdevent.cpp @@ -5,6 +5,7 @@ * */ +#include #include #include #include @@ -15,6 +16,7 @@ #include #include #include "eventloopinterface.h" +#include "fs.h" #include "log.h" #include "macros.h" #include "misc_p.h" diff --git a/src/lib/fcitx-utils/eventloopinterface.cpp b/src/lib/fcitx-utils/eventloopinterface.cpp index 0b66801e5..4333975e2 100644 --- a/src/lib/fcitx-utils/eventloopinterface.cpp +++ b/src/lib/fcitx-utils/eventloopinterface.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace fcitx { @@ -39,8 +40,8 @@ uint64_t timespec_load(const struct timespec *ts) { return USEC_INFINITY; } - return (uint64_t)ts->tv_sec * USEC_PER_SEC + - (uint64_t)ts->tv_nsec / NSEC_PER_USEC; + return ((uint64_t)ts->tv_sec * USEC_PER_SEC) + + ((uint64_t)ts->tv_nsec / NSEC_PER_USEC); } uint64_t now(clockid_t clock_id) { diff --git a/src/lib/fcitx-utils/eventloopinterface.h b/src/lib/fcitx-utils/eventloopinterface.h index 63183b363..adb0e5d0f 100644 --- a/src/lib/fcitx-utils/eventloopinterface.h +++ b/src/lib/fcitx-utils/eventloopinterface.h @@ -7,6 +7,7 @@ #ifndef _FCITX_UTILS_EVENTLOOPINTERFACE_H_ #define _FCITX_UTILS_EVENTLOOPINTERFACE_H_ +#include #include #include #include @@ -15,6 +16,10 @@ #include #include +#if defined(_WIN32) +#include +#endif + namespace fcitx { enum class IOEventFlag { diff --git a/test/testcustomeventloop.cpp b/test/testcustomeventloop.cpp index 64ae393bc..2b10f6419 100644 --- a/test/testcustomeventloop.cpp +++ b/test/testcustomeventloop.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -18,6 +19,7 @@ #include "fcitx-utils/event.h" #include "fcitx-utils/eventdispatcher.h" #include "fcitx-utils/eventloopinterface.h" +#include "fcitx-utils/fs.h" #include "fcitx-utils/intrusivelist.h" #include "fcitx-utils/macros.h" #include "fcitx-utils/misc_p.h" @@ -25,6 +27,10 @@ #include "fcitx-utils/unixfd.h" #include "eventlooptests.h" +#if defined(_WIN32) +#include +#endif + using namespace fcitx; // Following is also an example of poll() based event loop