From 676fa39f9ade5d89c5f5e70015025267afc4b84f Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 1 Nov 2021 05:53:20 +0200 Subject: [PATCH 1/2] lib/platform: Switch remaining ObjC source files to ObjC++ --- src/lib/platform/{OSXDragSimulator.m => OSXDragSimulator.mm} | 0 src/lib/platform/{OSXDragView.m => OSXDragView.mm} | 0 .../{OSXMediaKeySimulator.m => OSXMediaKeySimulator.mm} | 4 ++-- .../platform/{OSXMediaKeySupport.m => OSXMediaKeySupport.mm} | 4 ++-- .../{OSXPasteboardPeeker.m => OSXPasteboardPeeker.mm} | 0 .../platform/{OSXScreenSaverUtil.m => OSXScreenSaverUtil.mm} | 0 6 files changed, 4 insertions(+), 4 deletions(-) rename src/lib/platform/{OSXDragSimulator.m => OSXDragSimulator.mm} (100%) rename src/lib/platform/{OSXDragView.m => OSXDragView.mm} (100%) rename src/lib/platform/{OSXMediaKeySimulator.m => OSXMediaKeySimulator.mm} (96%) rename src/lib/platform/{OSXMediaKeySupport.m => OSXMediaKeySupport.mm} (97%) rename src/lib/platform/{OSXPasteboardPeeker.m => OSXPasteboardPeeker.mm} (100%) rename src/lib/platform/{OSXScreenSaverUtil.m => OSXScreenSaverUtil.mm} (100%) diff --git a/src/lib/platform/OSXDragSimulator.m b/src/lib/platform/OSXDragSimulator.mm similarity index 100% rename from src/lib/platform/OSXDragSimulator.m rename to src/lib/platform/OSXDragSimulator.mm diff --git a/src/lib/platform/OSXDragView.m b/src/lib/platform/OSXDragView.mm similarity index 100% rename from src/lib/platform/OSXDragView.m rename to src/lib/platform/OSXDragView.mm diff --git a/src/lib/platform/OSXMediaKeySimulator.m b/src/lib/platform/OSXMediaKeySimulator.mm similarity index 96% rename from src/lib/platform/OSXMediaKeySimulator.m rename to src/lib/platform/OSXMediaKeySimulator.mm index 5aacd107..efc4251b 100644 --- a/src/lib/platform/OSXMediaKeySimulator.m +++ b/src/lib/platform/OSXMediaKeySimulator.mm @@ -85,8 +85,8 @@ fakeNativeMediaKey(KeyID id) data2:-1]; CGEventRef upEvent = [upRef CGEvent]; - CGEventPost(0, downEvent); - CGEventPost(0, upEvent); + CGEventPost(kCGHIDEventTap, downEvent); + CGEventPost(kCGHIDEventTap, upEvent); return true; } diff --git a/src/lib/platform/OSXMediaKeySupport.m b/src/lib/platform/OSXMediaKeySupport.mm similarity index 97% rename from src/lib/platform/OSXMediaKeySupport.m rename to src/lib/platform/OSXMediaKeySupport.mm index 9c9dbc31..a4d57679 100644 --- a/src/lib/platform/OSXMediaKeySupport.m +++ b/src/lib/platform/OSXMediaKeySupport.mm @@ -147,8 +147,8 @@ fakeNativeMediaKey(KeyID id) data2:-1]; CGEventRef upEvent = [upRef CGEvent]; - CGEventPost(0, downEvent); - CGEventPost(0, upEvent); + CGEventPost(kCGHIDEventTap, downEvent); + CGEventPost(kCGHIDEventTap, upEvent); return true; } diff --git a/src/lib/platform/OSXPasteboardPeeker.m b/src/lib/platform/OSXPasteboardPeeker.mm similarity index 100% rename from src/lib/platform/OSXPasteboardPeeker.m rename to src/lib/platform/OSXPasteboardPeeker.mm diff --git a/src/lib/platform/OSXScreenSaverUtil.m b/src/lib/platform/OSXScreenSaverUtil.mm similarity index 100% rename from src/lib/platform/OSXScreenSaverUtil.m rename to src/lib/platform/OSXScreenSaverUtil.mm From 20f66fe1332057c2338179a700527142e778b874 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 1 Nov 2021 05:53:21 +0200 Subject: [PATCH 2/2] lib/common: Clean up declarations of {S,U}Int{8,16,32} types --- src/lib/barrier/Chunk.h | 2 +- src/lib/barrier/key_types.cpp | 1 + src/lib/common/basic_types.h | 63 ++++------------------------------- src/lib/common/common.h | 13 -------- src/lib/io/StreamBuffer.cpp | 2 ++ 5 files changed, 11 insertions(+), 70 deletions(-) diff --git a/src/lib/barrier/Chunk.h b/src/lib/barrier/Chunk.h index 07f0360d..26a343df 100644 --- a/src/lib/barrier/Chunk.h +++ b/src/lib/barrier/Chunk.h @@ -17,7 +17,7 @@ #pragma once -#include "common/basic_types.h" +#include class Chunk { public: diff --git a/src/lib/barrier/key_types.cpp b/src/lib/barrier/key_types.cpp index 43fd69b1..33ee3ebc 100644 --- a/src/lib/barrier/key_types.cpp +++ b/src/lib/barrier/key_types.cpp @@ -17,6 +17,7 @@ */ #include "barrier/key_types.h" +#include const KeyNameMapEntry kKeyNameMap[] = { { "AltGr", kKeyAltGr }, diff --git a/src/lib/common/basic_types.h b/src/lib/common/basic_types.h index 86300ca9..1882e57e 100644 --- a/src/lib/common/basic_types.h +++ b/src/lib/common/basic_types.h @@ -18,49 +18,7 @@ #pragma once -#include "common/common.h" - -// -// pick types of particular sizes -// - -#if !defined(TYPE_OF_SIZE_1) -# if SIZEOF_CHAR == 1 -# define TYPE_OF_SIZE_1 char -# endif -#endif - -#if !defined(TYPE_OF_SIZE_2) -# if SIZEOF_INT == 2 -# define TYPE_OF_SIZE_2 int -# else -# define TYPE_OF_SIZE_2 short -# endif -#endif - -#if !defined(TYPE_OF_SIZE_4) - // Carbon defines SInt32 and UInt32 in terms of long -# if SIZEOF_INT == 4 && !defined(__APPLE__) -# define TYPE_OF_SIZE_4 int -# else -# define TYPE_OF_SIZE_4 long -# endif -#endif - - // -// verify existence of required types -// - -#if !defined(TYPE_OF_SIZE_1) -# error No 1 byte integer type -#endif -#if !defined(TYPE_OF_SIZE_2) -# error No 2 byte integer type -#endif -#if !defined(TYPE_OF_SIZE_4) -# error No 4 byte integer type -#endif - +#include // // make typedefs @@ -75,18 +33,11 @@ #if defined(__APPLE__) #include #else -typedef signed TYPE_OF_SIZE_1 SInt8; -typedef signed TYPE_OF_SIZE_2 SInt16; -typedef signed TYPE_OF_SIZE_4 SInt32; -typedef unsigned TYPE_OF_SIZE_1 UInt8; -typedef unsigned TYPE_OF_SIZE_2 UInt16; -typedef unsigned TYPE_OF_SIZE_4 UInt32; +using SInt8 = std::int8_t; +using SInt16 = std::int16_t; +using SInt32 = std::int32_t; +using UInt8 = std::uint8_t; +using UInt16 = std::uint16_t; +using UInt32 = std::uint32_t; #endif #endif -// -// clean up -// - -#undef TYPE_OF_SIZE_1 -#undef TYPE_OF_SIZE_2 -#undef TYPE_OF_SIZE_4 diff --git a/src/lib/common/common.h b/src/lib/common/common.h index 2feea235..39462568 100644 --- a/src/lib/common/common.h +++ b/src/lib/common/common.h @@ -22,19 +22,6 @@ # include "config.h" #endif -// VC++ has built-in sized types -#if defined(_MSC_VER) -# include -# define TYPE_OF_SIZE_1 __int8 -# define TYPE_OF_SIZE_2 __int16 -# define TYPE_OF_SIZE_4 __int32 -#else -# define SIZE_OF_CHAR 1 -# define SIZE_OF_SHORT 2 -# define SIZE_OF_INT 4 -# define SIZE_OF_LONG 4 -#endif - // define NULL #include diff --git a/src/lib/io/StreamBuffer.cpp b/src/lib/io/StreamBuffer.cpp index 34bb47cc..8abbbb82 100644 --- a/src/lib/io/StreamBuffer.cpp +++ b/src/lib/io/StreamBuffer.cpp @@ -22,6 +22,8 @@ // StreamBuffer // +#include + const UInt32 StreamBuffer::kChunkSize = 4096; StreamBuffer::StreamBuffer() :