diff options
-rw-r--r-- | .clang-tidy | 2 | ||||
-rw-r--r-- | examples/pugl_vulkan_cpp_demo.cpp | 6 | ||||
-rw-r--r-- | include/pugl/pugl.h | 3 | ||||
-rw-r--r-- | meson.build | 13 | ||||
-rw-r--r-- | src/mac_cairo.m | 4 | ||||
-rw-r--r-- | src/x11.c | 2 | ||||
-rw-r--r-- | test/meson.build | 34 | ||||
-rw-r--r-- | test/test_cursor.c | 4 | ||||
-rw-r--r-- | test/test_gl_hints.c | 3 | ||||
-rw-r--r-- | test/test_stub_hints.c | 3 |
10 files changed, 40 insertions, 34 deletions
diff --git a/.clang-tidy b/.clang-tidy index 3e54543..7f81150 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -6,9 +6,11 @@ Checks: > -*-magic-numbers, -altera*, -bugprone-assignment-in-if-condition, + -bugprone-switch-missing-default-case, -clang-diagnostic-unused-function, -clang-diagnostic-unused-macros, -llvmlibc-*, + -misc-include-cleaner, -readability-identifier-length, CheckOptions: - key: hicpp-uppercase-literal-suffix.NewSuffixes diff --git a/examples/pugl_vulkan_cpp_demo.cpp b/examples/pugl_vulkan_cpp_demo.cpp index d0cc5a1..5e30b88 100644 --- a/examples/pugl_vulkan_cpp_demo.cpp +++ b/examples/pugl_vulkan_cpp_demo.cpp @@ -704,7 +704,7 @@ readFile(const char* const programPath, const std::string& filename) const std::unique_ptr<char, decltype(&free)> path{ resourcePath(programPath, filename.c_str()), &free}; - std::cerr << "Loading shader: " << path.get() << std::endl; + std::cerr << "Loading shader: " << path.get() << "\n"; const std::unique_ptr<FILE, int (*)(FILE*)> file{fopen(path.get(), "rb"), &fclose}; @@ -1201,7 +1201,7 @@ debugCallback(VkDebugReportFlagsEXT flags, void*) { std::cerr << sk::string(static_cast<VkDebugReportFlagBitsEXT>(flags)) << ": " - << layerPrefix << ": " << msg << std::endl; + << layerPrefix << ": " << msg << "\n"; return VK_FALSE; } @@ -1236,7 +1236,7 @@ void logInfo(const char* heading, const Value& value) { std::cout << std::setw(26) << std::left << (std::string(heading) + ":") - << value << std::endl; + << value << "\n"; } VkResult diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h index 2d7f4b4..ac5f51c 100644 --- a/include/pugl/pugl.h +++ b/include/pugl/pugl.h @@ -1573,7 +1573,8 @@ puglGetClipboard(PuglView* view, uint32_t typeIndex, size_t* len); for example if compiled on X11 without Xcursor support. @return #PUGL_BAD_PARAMETER if the given cursor is invalid, - #PUGL_FAILURE if the cursor is known but loading it system fails. + #PUGL_UNSUPPORTED if setting the cursor is not supported on this system, or + another error if the cursor is known but loading it fails. */ PUGL_API PuglStatus diff --git a/meson.build b/meson.build index e3b8450..78c6d7c 100644 --- a/meson.build +++ b/meson.build @@ -56,6 +56,7 @@ add_project_arguments( core_args = [] dl_dep = cc.find_library('dl', required: false) +with_timers = true if host_machine.system() == 'darwin' # MacOS @@ -173,15 +174,12 @@ else core_args += '-D_POSIX_C_SOURCE=200809L' xcursor_dep = cc.find_library('Xcursor', required: get_option('xcursor')) - if xcursor_dep.found() - core_args += ['-DUSE_XCURSOR=1'] - endif + core_args += ['-DUSE_XCURSOR=@0@'.format(xcursor_dep.found().to_int())] xrandr_dep = cc.find_library('Xrandr', required: get_option('xrandr')) - if xrandr_dep.found() - core_args += ['-DUSE_XRANDR=1'] - endif + core_args += ['-DUSE_XRANDR=@0@'.format(xrandr_dep.found().to_int())] + with_timers = false use_xsync = false xext_dep = cc.find_library('Xext', required: get_option('xsync')) if xext_dep.found() @@ -189,12 +187,13 @@ else #include <X11/extensions/sync.h> int main(void) { XSyncQueryExtension(0, 0, 0); return 0; }''' if cc.compiles(xsync_fragment, name: 'Xsync') - core_args += ['-DUSE_XSYNC=1'] + with_timers = true use_xsync = true elif get_option('xsync') == 'enabled' error('C header <X11/extensions/sync.h> not found') endif endif + core_args += ['-DUSE_XSYNC=@0@'.format(use_xsync.to_int())] x11_args = [] if cc.get_id() == 'clang' diff --git a/src/mac_cairo.m b/src/mac_cairo.m index 8e28985..e4d2f5f 100644 --- a/src/mac_cairo.m +++ b/src/mac_cairo.m @@ -93,10 +93,8 @@ puglMacCairoEnter(PuglView* view, const PuglExposeEvent* expose) const CGSize sizePx = {(CGFloat)view->lastConfigure.width, (CGFloat)view->lastConfigure.height}; - const CGSize sizePt = CGContextConvertSizeToUserSpace(context, sizePx); - // Convert coordinates to standard Cairo space - CGContextTranslateCTM(context, 0.0, -sizePt.height); + CGContextTranslateCTM(context, 0.0, sizePx.height * scale); CGContextScaleCTM(context, scale, -scale); drawView->surface = cairo_quartz_surface_create_for_cg_context( @@ -2194,7 +2194,7 @@ puglSetCursor(PuglView* const view, const PuglCursor cursor) #else (void)view; (void)cursor; - return PUGL_FAILURE; + return PUGL_UNSUPPORTED; #endif } diff --git a/test/meson.build b/test/meson.build index f8d2fd1..791cf04 100644 --- a/test/meson.build +++ b/test/meson.build @@ -39,10 +39,7 @@ if not meson.is_subproject() and get_option('lint') endif endif -basic_exclusive_tests = [ - 'local_copy_paste', - 'remote_copy_paste', -] +basic_exclusive_tests = [] basic_tests = [ 'cursor', @@ -53,7 +50,6 @@ basic_tests = [ 'strerror', 'stub', 'stub_hints', - 'timer', 'update', 'view', 'world', @@ -69,6 +65,11 @@ gl_tests = [ vulkan_tests = ['vulkan'] +if with_timers + basic_exclusive_tests += ['local_copy_paste', 'remote_copy_paste'] + basic_tests += ['timer'] +endif + includes = [ '.', '../include', @@ -152,7 +153,7 @@ if vulkan_dep.found() endforeach endif -unified_args = [] +unified_args = core_args unified_deps = [core_deps] if cairo_dep.found() unified_args += ['-DWITH_CAIRO'] @@ -174,9 +175,9 @@ if host_machine.system() == 'darwin' objcpp = meson.get_compiler('objcpp') - objcpp_args = [] + objcpp_unified_args = unified_args if objcpp.get_id() == 'clang' - objcpp_args += [ + objcpp_unified_args += [ '-Wno-c++98-compat', '-Wno-c++98-compat-pedantic', '-Wno-deprecated-declarations', @@ -184,7 +185,7 @@ if host_machine.system() == 'darwin' ] endif - unified_args += objcpp.get_supported_arguments(test_cpp_args + objcpp_args) + objcpp_unified_args = objcpp.get_supported_arguments(objcpp_unified_args) test( 'inline_objcpp', @@ -193,23 +194,22 @@ if host_machine.system() == 'darwin' 'test_inline_objcpp.mm', dependencies: unified_deps, include_directories: include_directories(includes), - objcpp_args: unified_args, + objcpp_args: objcpp_unified_args, ), suite: 'unit', ) elif is_variable('cpp') - unified_args = [] - + cpp_unified_args = unified_args if cpp.get_id() == 'clang' - unified_args += [ + cpp_unified_args += [ '-Wno-old-style-cast', '-Wno-switch-default', '-Wno-switch-enum', '-Wno-unused-macros', # Mac ] elif cpp.get_id() == 'gcc' - unified_args += [ + cpp_unified_args += [ '-Wno-conditionally-supported', '-Wno-old-style-cast', '-Wno-switch-default', @@ -217,17 +217,19 @@ elif is_variable('cpp') '-Wno-useless-cast', ] elif cpp.get_id() == 'msvc' - unified_args += [ + cpp_unified_args += [ '/wd4464', # relative include path contains '..' ] endif + cpp_unified_args = cpp.get_supported_arguments(cpp_unified_args) + test( 'inline_cpp', executable( 'test_inline_cpp', 'test_inline_cpp.cpp', - cpp_args: test_cpp_args + unified_args, + cpp_args: cpp_unified_args, dependencies: unified_deps, include_directories: include_directories(includes), ), diff --git a/test/test_cursor.c b/test/test_cursor.c index 11a52d7..9b0fa66 100644 --- a/test/test_cursor.c +++ b/test/test_cursor.c @@ -63,7 +63,9 @@ main(int argc, char** argv) // Change the cursor, updating each time assert(puglSetCursor(test.view, (PuglCursor)-1)); for (unsigned i = 0; i < (unsigned)PUGL_CURSOR_ALL_SCROLL; ++i) { - assert(!puglSetCursor(test.view, (PuglCursor)i)); + const PuglStatus st = puglSetCursor(test.view, (PuglCursor)i); + + assert(!st || st == PUGL_UNSUPPORTED); assert(!puglUpdate(test.world, 0.1)); } diff --git a/test/test_gl_hints.c b/test/test_gl_hints.c index 16b51c5..250136a 100644 --- a/test/test_gl_hints.c +++ b/test/test_gl_hints.c @@ -85,7 +85,8 @@ main(void) assert(puglGetViewHint(view, PUGL_SWAP_INTERVAL) != PUGL_DONT_CARE); assert(puglGetViewHint(view, PUGL_RESIZABLE) != PUGL_DONT_CARE); assert(puglGetViewHint(view, PUGL_IGNORE_KEY_REPEAT) != PUGL_DONT_CARE); - assert(puglGetViewHint(view, PUGL_REFRESH_RATE) != PUGL_DONT_CARE); + assert(puglGetViewHint(view, PUGL_REFRESH_RATE) == PUGL_DONT_CARE || + puglGetViewHint(view, PUGL_REFRESH_RATE) > 0); // Tear down puglFreeView(view); diff --git a/test/test_stub_hints.c b/test/test_stub_hints.c index 4c9d0c4..b7d54e3 100644 --- a/test/test_stub_hints.c +++ b/test/test_stub_hints.c @@ -77,7 +77,8 @@ main(void) assert(puglGetViewHint(view, PUGL_ALPHA_BITS) != PUGL_DONT_CARE); assert(puglGetViewHint(view, PUGL_RESIZABLE) != PUGL_DONT_CARE); assert(puglGetViewHint(view, PUGL_IGNORE_KEY_REPEAT) != PUGL_DONT_CARE); - assert(puglGetViewHint(view, PUGL_REFRESH_RATE) != PUGL_DONT_CARE); + assert(puglGetViewHint(view, PUGL_REFRESH_RATE) == PUGL_DONT_CARE || + puglGetViewHint(view, PUGL_REFRESH_RATE) > 0); // Tear down puglFreeView(view); |