Merge branch 'feature-freebsd-posix' into develop

This commit is contained in:
Jinhao
2018-05-08 04:52:13 +08:00
32 changed files with 509 additions and 255 deletions

View File

@@ -10,7 +10,9 @@
#if defined(NANA_WINDOWS)
#include <windows.h>
#elif defined(NANA_LINUX)
#include <alsa/asoundlib.h>
#include <alsa/asoundlib.h>
#elif defined(NANA_POSIX)
#include <sys/soundcard.h>
#endif
namespace nana{ namespace audio
@@ -34,7 +36,6 @@ namespace nana{ namespace audio
static void __stdcall _m_dev_callback(HWAVEOUT handle, UINT msg, audio_device * self, DWORD_PTR, DWORD_PTR);
#endif
#if defined(NANA_WINDOWS)
HWAVEOUT handle_;
std::recursive_mutex queue_lock_;
@@ -45,6 +46,12 @@ namespace nana{ namespace audio
std::size_t channels_;
std::size_t bytes_per_sample_;
std::size_t bytes_per_frame_;
#elif defined(NANA_POSIX)
int handle_;
int rate_;
int channels_;
int bytes_per_sample_;
int bytes_per_frame_;
#endif
buffer_preparation * buf_prep_;
};
@@ -54,4 +61,4 @@ namespace nana{ namespace audio
}//end namespace nana
#endif //NANA_ENABLE_AUDIO
#endif
#endif

View File

@@ -33,7 +33,7 @@ namespace nana{ namespace audio{
unsigned short wBitsPerSample;
};
#pragma pack()
#elif defined(NANA_LINUX)
#elif defined(NANA_POSIX)
struct master_riff_chunk
{
unsigned ckID; //"RIFF"
@@ -83,4 +83,4 @@ namespace nana{ namespace audio{
}//end namespace audio
}//end namespace nana
#endif //NANA_ENABLE_AUDIO
#endif
#endif

View File

@@ -32,7 +32,7 @@ namespace nana{ namespace audio
public:
#if defined(NANA_WINDOWS)
typedef WAVEHDR meta;
#elif defined(NANA_LINUX)
#elif defined(NANA_POSIX)
struct meta
{
char * buf;
@@ -66,4 +66,4 @@ namespace nana{ namespace audio
}//end namespace audio
}//end namespace nana
#endif //NANA_ENABLE_AUDIO
#endif
#endif

View File

@@ -68,9 +68,16 @@
# endif
#endif
// Set this to "UTF-32" at the command-line for big endian.
#ifndef NANA_UNICODE
// much of the world runs intel compatible processors so default to LE.
#define NANA_UNICODE "UTF-32LE"
#endif
// Select platform ......
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) //Microsoft Windows
#define NANA_WINDOWS
typedef DWORD_PTR thread_t;
// MINGW ...
#if defined(__MINGW32__) || defined(__MINGW64__) || defined(MINGW)
@@ -79,24 +86,23 @@
#elif defined(APPLE) //Mac OS X
//Symbols for MACOS
#define NANA_MACOS
#define NANA_POSIX
#define NANA_X11
typedef unsigned long thread_t;
#elif defined(__FreeBSD__)
#define NANA_POSIX
#define NANA_X11
typedef unsigned long thread_t;
#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) //Linux
#define NANA_LINUX
#define NANA_X11
#else
static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)");
#endif
//Define a symbol for POSIX operating system.
#if defined(NANA_LINUX) || defined(NANA_MACOS)
#define NANA_POSIX
#define NANA_X11
typedef unsigned long thread_t;
#else
static_assert(false, "Only Windows and Linux are supported now (Mac OS and BSD are experimental)");
#endif
// Select compiler ...
#if defined(_MSC_VER) //Microsoft Visual C++
#define _SCL_SECURE_NO_WARNNGS

View File

@@ -20,19 +20,19 @@
namespace nana
{
namespace filesystem_ext
namespace filesystem_ext
{
#if defined(NANA_WINDOWS)
constexpr auto const def_root = "C:";
constexpr auto const def_rootstr = "C:\\";
constexpr auto const def_rootname = "Local Drive(C:)";
#elif defined(NANA_LINUX)
#elif defined(NANA_POSIX)
constexpr auto const def_root = "/";
constexpr auto const def_rootstr = "/";
constexpr auto const def_rootname = "Root/";
#endif
std::experimental::filesystem::path path_user(); ///< extention ?
/// workaround Boost not having path.generic_u8string() - a good point for http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0251r0.pdf
@@ -52,7 +52,7 @@ inline bool is_directory(const std::experimental::filesystem::directory_entry& d
//template<class DI> // DI = directory_iterator from std, boost, or nana : return directory_entry
class directory_only_iterator : public std::experimental::filesystem::directory_iterator
{
{
using directory_iterator = std::experimental::filesystem::directory_iterator;
directory_only_iterator& find_first()
@@ -60,7 +60,7 @@ class directory_only_iterator : public std::experimental::filesystem::directory_
auto end = directory_only_iterator{};
while (*this != end)
{
if (is_directory((**this).status()))
if (is_directory((**this).status()))
return *this;
this->directory_iterator::operator++();
}
@@ -110,7 +110,7 @@ public:
{
find_first();
}
regular_file_only_iterator& operator++()
{
this->directory_iterator::operator++();

View File

@@ -3,8 +3,8 @@
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file nana/gui/detail/basic_window.hpp
@@ -79,7 +79,7 @@ namespace detail
};
/// a window data structure descriptor
/// a window data structure descriptor
struct basic_window
: public events_holder
{
@@ -139,7 +139,7 @@ namespace detail
void _m_init_pos_and_size(basic_window* parent, const rectangle&);
void _m_initialize(basic_window* parent);
public:
#if defined(NANA_LINUX) || defined(NANA_MACOS)
#if defined(NANA_POSIX)
point pos_native;
#endif
point pos_root; ///< coordinates of the root window
@@ -202,7 +202,7 @@ namespace detail
effects::bground_interface * bground;
double bground_fade_rate;
}effect;
struct other_tag
{
#ifndef WIDGET_FRAME_DEPRECATED
@@ -248,7 +248,7 @@ namespace detail
}other;
native_window_type root; ///< root Window handle
unsigned thread_id; ///< the identifier of the thread that created the window.
thread_t thread_id; ///< the identifier of the thread that created the window.
unsigned index;
container children;
};

View File

@@ -46,10 +46,10 @@ namespace detail
~bedrock();
void pump_event(window, bool is_modal);
void flush_surface(core_window_t*, bool forced, const rectangle* update_area = nullptr);
static int inc_window(unsigned tid = 0);
thread_context* open_thread_context(unsigned tid = 0);
thread_context* get_thread_context(unsigned tid = 0);
void remove_thread_context(unsigned tid = 0);
static int inc_window(thread_t tid = 0);
thread_context* open_thread_context(thread_t tid = 0);
thread_context* get_thread_context(thread_t tid = 0);
void remove_thread_context(thread_t tid = 0);
static bedrock& instance();
core_window_t* focus();
@@ -73,7 +73,7 @@ namespace detail
void map_through_widgets(core_window_t*, native_drawable_type);
//Closes the windows which are associated with the specified thread. If the given thread_id is 0, it closes all windows
void close_thread_window(unsigned thread_id);
void close_thread_window(thread_t thread_id);
public:
//Platform-dependent functions

View File

@@ -139,7 +139,7 @@ namespace detail
void enable_tabstop(core_window_t*);
core_window_t* tabstop(core_window_t*, bool forward) const; //forward means move to next in logic.
void remove_trash_handle(unsigned tid);
void remove_trash_handle(thread_t tid);
bool enable_effects_bground(core_window_t*, bool);
@@ -154,7 +154,7 @@ namespace detail
core_window_t* find_shortkey(native_window_type, unsigned long key);
void set_safe_place(core_window_t* wd, std::function<void()>&& fn);
void call_safe_place(unsigned thread_id);
void call_safe_place(thread_t thread_id);
private:
void _m_disengage(core_window_t*, core_window_t* for_new);
void _m_destroy(core_window_t*);

View File

@@ -26,7 +26,7 @@ namespace system
//this_thread_id
//@brief: get the identifier of calling thread.
unsigned long this_thread_id();
thread_t this_thread_id();
//timestamp
//@brief: it retrieves the timestamp at the time the function is called.