From 6cf4f14dec0daf159a6cde91fd355ac1d37823e0 Mon Sep 17 00:00:00 2001
From: walker0643 <>
Date: Tue, 13 Feb 2018 15:14:26 -0500
Subject: [PATCH 1/5] fix some compiler warnings
---
src/gui/src/MainWindow.cpp | 4 ++++
src/gui/src/ScreenSetupView.h | 14 +++++++-------
src/lib/platform/OSXDragSimulator.m | 2 +-
src/lib/platform/OSXMediaKeySimulator.m | 4 ++--
src/lib/platform/OSXMediaKeySupport.m | 4 ++--
src/lib/platform/OSXPasteboardPeeker.m | 2 +-
6 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp
index ae1fad40..83dbd548 100644
--- a/src/gui/src/MainWindow.cpp
+++ b/src/gui/src/MainWindow.cpp
@@ -945,6 +945,10 @@ void MainWindow::changeEvent(QEvent* event)
windowStateChanged();
break;
}
+ default:
+ {
+ break;
+ }
}
}
// all that do not return are allowing the event to propagate
diff --git a/src/gui/src/ScreenSetupView.h b/src/gui/src/ScreenSetupView.h
index a263a8d5..a6605117 100644
--- a/src/gui/src/ScreenSetupView.h
+++ b/src/gui/src/ScreenSetupView.h
@@ -43,14 +43,14 @@ class ScreenSetupView : public QTableView
ScreenSetupModel* model() const;
protected:
- void mouseDoubleClickEvent(QMouseEvent*);
+ void mouseDoubleClickEvent(QMouseEvent*) override;
void setTableSize();
- void resizeEvent(QResizeEvent*);
- void dragEnterEvent(QDragEnterEvent* event);
- void dragMoveEvent(QDragMoveEvent* event);
- void startDrag(Qt::DropActions supportedActions);
- QStyleOptionViewItem viewOptions() const;
- void scrollTo(const QModelIndex&, ScrollHint) {}
+ void resizeEvent(QResizeEvent*) override;
+ void dragEnterEvent(QDragEnterEvent* event) override;
+ void dragMoveEvent(QDragMoveEvent* event) override;
+ void startDrag(Qt::DropActions supportedActions) override;
+ QStyleOptionViewItem viewOptions() const override;
+ void scrollTo(const QModelIndex&, ScrollHint) override {}
};
#endif
diff --git a/src/lib/platform/OSXDragSimulator.m b/src/lib/platform/OSXDragSimulator.m
index affed383..5112ad91 100644
--- a/src/lib/platform/OSXDragSimulator.m
+++ b/src/lib/platform/OSXDragSimulator.m
@@ -35,7 +35,7 @@ runCocoaApp()
NSWindow* window = [[NSWindow alloc]
initWithContentRect: NSMakeRect(0, 0, 3, 3)
- styleMask: NSBorderlessWindowMask
+ styleMask: NSWindowStyleMaskBorderless
backing: NSBackingStoreBuffered
defer: NO];
[window setTitle: @""];
diff --git a/src/lib/platform/OSXMediaKeySimulator.m b/src/lib/platform/OSXMediaKeySimulator.m
index 5aacd107..08d43ef8 100644
--- a/src/lib/platform/OSXMediaKeySimulator.m
+++ b/src/lib/platform/OSXMediaKeySimulator.m
@@ -71,14 +71,14 @@ bool
fakeNativeMediaKey(KeyID id)
{
- NSEvent* downRef = [NSEvent otherEventWithType:NSSystemDefined
+ NSEvent* downRef = [NSEvent otherEventWithType:NSEventTypeSystemDefined
location: NSMakePoint(0, 0) modifierFlags:0xa00
timestamp:0 windowNumber:0 context:0 subtype:8
data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xa) << 8)
data2:-1];
CGEventRef downEvent = [downRef CGEvent];
- NSEvent* upRef = [NSEvent otherEventWithType:NSSystemDefined
+ NSEvent* upRef = [NSEvent otherEventWithType:NSEventTypeSystemDefined
location: NSMakePoint(0, 0) modifierFlags:0xa00
timestamp:0 windowNumber:0 context:0 subtype:8
data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xb) << 8)
diff --git a/src/lib/platform/OSXMediaKeySupport.m b/src/lib/platform/OSXMediaKeySupport.m
index 9c9dbc31..e73a0914 100644
--- a/src/lib/platform/OSXMediaKeySupport.m
+++ b/src/lib/platform/OSXMediaKeySupport.m
@@ -133,14 +133,14 @@ bool
fakeNativeMediaKey(KeyID id)
{
- NSEvent* downRef = [NSEvent otherEventWithType:NSSystemDefined
+ NSEvent* downRef = [NSEvent otherEventWithType:NSEventTypeSystemDefined
location: NSMakePoint(0, 0) modifierFlags:0xa00
timestamp:0 windowNumber:0 context:0 subtype:8
data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xa) << 8)
data2:-1];
CGEventRef downEvent = [downRef CGEvent];
- NSEvent* upRef = [NSEvent otherEventWithType:NSSystemDefined
+ NSEvent* upRef = [NSEvent otherEventWithType:NSEventTypeSystemDefined
location: NSMakePoint(0, 0) modifierFlags:0xa00
timestamp:0 windowNumber:0 context:0 subtype:8
data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xb) << 8)
diff --git a/src/lib/platform/OSXPasteboardPeeker.m b/src/lib/platform/OSXPasteboardPeeker.m
index ab39e262..cf61046e 100644
--- a/src/lib/platform/OSXPasteboardPeeker.m
+++ b/src/lib/platform/OSXPasteboardPeeker.m
@@ -21,7 +21,7 @@
CFStringRef
getDraggedFileURL()
{
- NSString* pbName = NSDragPboard;
+ NSString* pbName = NSPasteboardNameDrag;
NSPasteboard* pboard = [NSPasteboard pasteboardWithName:pbName];
NSMutableString* string;
From 8073db2247292bf4db68ef36a16014ae0ea2d0a1 Mon Sep 17 00:00:00 2001
From: walker0643 <>
Date: Tue, 13 Feb 2018 17:43:39 -0500
Subject: [PATCH 2/5] silence a couple more compiler warnings on osx
---
src/lib/platform/OSXDragView.m | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/lib/platform/OSXDragView.m b/src/lib/platform/OSXDragView.m
index 6ebc5973..9f774993 100644
--- a/src/lib/platform/OSXDragView.m
+++ b/src/lib/platform/OSXDragView.m
@@ -25,6 +25,17 @@
@dynamic animatesToDestination;
@dynamic numberOfValidItemsForDrop;
+/* springLoadingHighlight is a property that will not be auto-synthesized by
+ clang. explicitly synthesizing it here as well as defining an empty handler
+ for resetSpringLoading() satisfies the compiler */
+@synthesize springLoadingHighlight = _springLoadingHighlight;
+
+/* unused */
+- (void)
+resetSpringLoading
+{
+}
+
- (id)
initWithFrame:(NSRect)frame
{
From 71a20eedec4a86b778cc1167039cc18ef6760f5b Mon Sep 17 00:00:00 2001
From: walker0643 <>
Date: Tue, 13 Feb 2018 22:11:56 -0500
Subject: [PATCH 3/5] automate building mac installer
---
build_mac_installer.sh | 61 +++++++++++++++++++
.../bundle/Barrier.app/Contents/Info.plist.in | 2 +-
2 files changed, 62 insertions(+), 1 deletion(-)
create mode 100755 build_mac_installer.sh
diff --git a/build_mac_installer.sh b/build_mac_installer.sh
new file mode 100755
index 00000000..8a815047
--- /dev/null
+++ b/build_mac_installer.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+# change this to rename the installer package
+B_DMG="Barrier-v1.9.dmg"
+
+# sanity check so we don't distribute packages full of debug symbols
+echo Make sure you have built the Release version!!
+echo Press Enter to continue or Ctrl+C to abort
+read
+
+cd $(dirname $0)
+
+# remove any old copies so there's no confusion about whever this
+# process completes successfully or not
+rm -rf build/bundle/{bundle.dmg,$B_DMG}
+
+B_BINARY_PATH=$(pwd)/build/bin
+cd build/bundle/Barrier.app/Contents 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo Please make sure that the build completed successfully
+ echo before trying to create the installer.
+ exit 1
+fi
+
+# MacOS folder holds the executables, non-system libraries,
+# and the startup script
+rm -rf MacOS
+mkdir MacOS || exit 1
+cd MacOS || exit 1
+
+# copy all executables
+cp ${B_BINARY_PATH}/* . || exit 1
+
+# only one executable (barrier) needs non-system libraries.
+# get a list of them and make local copies
+B_LIBS=$(otool -XL barrier | awk '{ print $1 }' | grep -Ev '^(/usr/lib|/System)')
+[ $? -ne 0 ] && exit 1
+for B_SRC in $B_LIBS; do
+ cp $B_SRC . || exit 1
+ B_DST=@executable_path/$(basename $B_SRC)
+ # adjust the executable's metadata to point to the local copy
+ # rather than the system-wide copy which would only exist on
+ # a development machine
+ install_name_tool -change $B_SRC $B_DST barrier || exit 1
+done
+
+# create a startup script that will change to the binary directory
+# before starting barrier
+printf "%s\n" "#!/bin/sh" "cd \$(dirname \$0)" "exec ./barrier" > barrier.sh
+chmod +x barrier.sh
+
+# create the DMG to be distributed in build/bundle
+cd ../../..
+hdiutil create -size 32m -fs HFS+ -volname "Barrier" bundle.dmg || exit 1
+hdiutil attach bundle.dmg -mountpoint mnt || exit 1
+cp -r Barrier.app mnt/ || exit 1
+hdiutil detach mnt || exit 1
+hdiutil convert bundle.dmg -format UDZO -o $B_DMG || exit 1
+rm bundle.dmg
+
+echo "Installer created successfully"
diff --git a/dist/macos/bundle/Barrier.app/Contents/Info.plist.in b/dist/macos/bundle/Barrier.app/Contents/Info.plist.in
index 277963ae..b973f5e9 100644
--- a/dist/macos/bundle/Barrier.app/Contents/Info.plist.in
+++ b/dist/macos/bundle/Barrier.app/Contents/Info.plist.in
@@ -6,7 +6,7 @@
CFBundleDisplayName
Barrier
CFBundleExecutable
- barrier
+ barrier.sh
CFBundleIconFile
Barrier.icns
CFBundleIdentifier
From a8d0dfdacceb6ece787273a3db04b6acce2b9b4c Mon Sep 17 00:00:00 2001
From: walker0643 <>
Date: Wed, 14 Feb 2018 14:41:59 -0500
Subject: [PATCH 4/5] recursive re-referencing of binaries, and add cocoa qt
platform plugin
---
build_mac_installer.sh | 42 +++++++++++++++++++++++++++++-------------
mac_reref_dylibs.sh | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 13 deletions(-)
create mode 100755 mac_reref_dylibs.sh
diff --git a/build_mac_installer.sh b/build_mac_installer.sh
index 8a815047..b2d98ad9 100755
--- a/build_mac_installer.sh
+++ b/build_mac_installer.sh
@@ -10,6 +10,12 @@ read
cd $(dirname $0)
+B_REREF_SCRIPT=$(pwd)/mac_reref_dylibs.sh
+if [ ! -x $B_REREF_SCRIPT ]; then
+ echo Missing script: $B_REREF_SCRIPT
+ exit 1
+fi
+
# remove any old copies so there's no confusion about whever this
# process completes successfully or not
rm -rf build/bundle/{bundle.dmg,$B_DMG}
@@ -31,18 +37,28 @@ cd MacOS || exit 1
# copy all executables
cp ${B_BINARY_PATH}/* . || exit 1
-# only one executable (barrier) needs non-system libraries.
-# get a list of them and make local copies
-B_LIBS=$(otool -XL barrier | awk '{ print $1 }' | grep -Ev '^(/usr/lib|/System)')
-[ $? -ne 0 ] && exit 1
-for B_SRC in $B_LIBS; do
- cp $B_SRC . || exit 1
- B_DST=@executable_path/$(basename $B_SRC)
- # adjust the executable's metadata to point to the local copy
- # rather than the system-wide copy which would only exist on
- # a development machine
- install_name_tool -change $B_SRC $B_DST barrier || exit 1
-done
+# copy the qt platform plugin
+# TODO: this is hacky and will probably break if there is more than one qt
+# version installed. need a better way to find this library
+B_COCOA=$(find /usr/local/Cellar/qt -type f -name libqcocoa.dylib | head -1)
+if [ $? -ne 0 ] || [ "x$B_COCOA" = "x" ]; then
+ echo "Could not find cocoa platform plugin"
+ exit 1
+fi
+mkdir platforms
+cp $B_COCOA platforms/ || exit 1
+
+# make sure we can r/w all these binaries
+chmod -R u+rw * || exit 1
+
+# only one executable (barrier) needs non-system libraries although it's
+# libraries can call each other. use a recursive script to handle the
+# re-referencing
+$B_REREF_SCRIPT barrier || exit 1
+# the cocoa platform plugin also needs to know where to find the qt libraries.
+# because it exists in a subdirectory we append ../ to the relative path of the
+# libraries in its metadata
+$B_REREF_SCRIPT platforms/libqcocoa.dylib ../ || exit 1
# create a startup script that will change to the binary directory
# before starting barrier
@@ -51,7 +67,7 @@ chmod +x barrier.sh
# create the DMG to be distributed in build/bundle
cd ../../..
-hdiutil create -size 32m -fs HFS+ -volname "Barrier" bundle.dmg || exit 1
+hdiutil create -size 64m -fs HFS+ -volname "Barrier" bundle.dmg || exit 1
hdiutil attach bundle.dmg -mountpoint mnt || exit 1
cp -r Barrier.app mnt/ || exit 1
hdiutil detach mnt || exit 1
diff --git a/mac_reref_dylibs.sh b/mac_reref_dylibs.sh
new file mode 100755
index 00000000..15191bd2
--- /dev/null
+++ b/mac_reref_dylibs.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# $1 = binary (program or dylib)
+B_TARGET=$1
+if [ "x$B_TARGET" = "x" ]; then
+ echo Which binary needs to be re-referenced?
+ exit 1
+fi
+
+cd $(dirname $B_TARGET) || exit 1
+
+# where to find non-system libraries relative to target's directory.
+# the vast majority of the time this should be empty
+B_REL_PATH=$2
+
+# we're in target's directory now. trim off the path
+B_TARGET=$(basename $B_TARGET)
+
+# get a list of non-system libraries and make local copies
+B_LIBS=$(otool -XL $B_TARGET | awk '{ print $1 }' | grep -Ev '^(/usr/lib|/System)')
+[ $? -ne 0 ] && exit 1
+for B_LIB in $B_LIBS; do
+ B_LIB_NAME=$(basename $B_LIB)
+
+ # ignore self-references
+ [ "$B_TARGET" = "$B_LIB_NAME" ] && continue
+
+ B_DST=${B_REL_PATH}${B_LIB_NAME}
+ if [ ! -e $B_DST ]; then
+ cp $B_LIB $B_DST || exit 1
+ chmod u+rw $B_DST || exit 1
+ # recursively call this script on libraries purposefully not passing
+ # $B_REL_PATH so that it is only used explicitly
+ $0 $B_DST
+ fi
+
+ # adjust the target's metadata to point to the local copy
+ # rather than the system-wide copy which would only exist on
+ # a development machine
+ install_name_tool -change $B_LIB @loader_path/$B_DST $B_TARGET || exit 1
+done
From f5b5258f4af875bfb5dd0003182df5051e241db8 Mon Sep 17 00:00:00 2001
From: walker0643 <>
Date: Thu, 15 Feb 2018 01:17:18 -0500
Subject: [PATCH 5/5] revert some of the "deprecated" fixes so that older OSX
versions are still supported. my thanks to Cpuroast for additional macos
testing.
---
build_mac_installer.sh | 12 +++++++-----
clean_build.sh | 3 ++-
src/lib/platform/OSXDragSimulator.m | 2 +-
src/lib/platform/OSXMediaKeySimulator.m | 4 ++--
src/lib/platform/OSXMediaKeySupport.m | 4 ++--
src/lib/platform/OSXPasteboardPeeker.m | 2 +-
6 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/build_mac_installer.sh b/build_mac_installer.sh
index b2d98ad9..021562dd 100755
--- a/build_mac_installer.sh
+++ b/build_mac_installer.sh
@@ -3,13 +3,15 @@
# change this to rename the installer package
B_DMG="Barrier-v1.9.dmg"
-# sanity check so we don't distribute packages full of debug symbols
-echo Make sure you have built the Release version!!
-echo Press Enter to continue or Ctrl+C to abort
-read
-
cd $(dirname $0)
+# sanity check so we don't distribute packages full of debug symbols
+B_BUILD_TYPE=$(grep -E ^CMAKE_BUILD_TYPE build/CMakeCache.txt | cut -d= -f2)
+if [ "$B_BUILD_TYPE" != "Release" ]; then
+ echo Will only build installers for Release builds
+ exit 1
+fi
+
B_REREF_SCRIPT=$(pwd)/mac_reref_dylibs.sh
if [ ! -x $B_REREF_SCRIPT ]; then
echo Missing script: $B_REREF_SCRIPT
diff --git a/clean_build.sh b/clean_build.sh
index f5a99807..290d570e 100755
--- a/clean_build.sh
+++ b/clean_build.sh
@@ -13,9 +13,10 @@ if [ "$(uname)" = "Darwin" ]; then
# OSX needs a lot of extra help, poor thing
# run the osx_environment.sh script to fix paths
[ -r ../osx_environment.sh ] && source ../osx_environment.sh
- B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk $B_CMAKE_FLAGS"
+ B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 $B_CMAKE_FLAGS"
fi
B_CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=$B_BUILD_TYPE $B_CMAKE_FLAGS"
+echo Starting Barrier $B_BUILD_TYPE build...
$B_CMAKE $B_CMAKE_FLAGS .. || exit 1
make || exit 1
echo "Build completed successfully"
diff --git a/src/lib/platform/OSXDragSimulator.m b/src/lib/platform/OSXDragSimulator.m
index 5112ad91..affed383 100644
--- a/src/lib/platform/OSXDragSimulator.m
+++ b/src/lib/platform/OSXDragSimulator.m
@@ -35,7 +35,7 @@ runCocoaApp()
NSWindow* window = [[NSWindow alloc]
initWithContentRect: NSMakeRect(0, 0, 3, 3)
- styleMask: NSWindowStyleMaskBorderless
+ styleMask: NSBorderlessWindowMask
backing: NSBackingStoreBuffered
defer: NO];
[window setTitle: @""];
diff --git a/src/lib/platform/OSXMediaKeySimulator.m b/src/lib/platform/OSXMediaKeySimulator.m
index 08d43ef8..5aacd107 100644
--- a/src/lib/platform/OSXMediaKeySimulator.m
+++ b/src/lib/platform/OSXMediaKeySimulator.m
@@ -71,14 +71,14 @@ bool
fakeNativeMediaKey(KeyID id)
{
- NSEvent* downRef = [NSEvent otherEventWithType:NSEventTypeSystemDefined
+ NSEvent* downRef = [NSEvent otherEventWithType:NSSystemDefined
location: NSMakePoint(0, 0) modifierFlags:0xa00
timestamp:0 windowNumber:0 context:0 subtype:8
data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xa) << 8)
data2:-1];
CGEventRef downEvent = [downRef CGEvent];
- NSEvent* upRef = [NSEvent otherEventWithType:NSEventTypeSystemDefined
+ NSEvent* upRef = [NSEvent otherEventWithType:NSSystemDefined
location: NSMakePoint(0, 0) modifierFlags:0xa00
timestamp:0 windowNumber:0 context:0 subtype:8
data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xb) << 8)
diff --git a/src/lib/platform/OSXMediaKeySupport.m b/src/lib/platform/OSXMediaKeySupport.m
index e73a0914..9c9dbc31 100644
--- a/src/lib/platform/OSXMediaKeySupport.m
+++ b/src/lib/platform/OSXMediaKeySupport.m
@@ -133,14 +133,14 @@ bool
fakeNativeMediaKey(KeyID id)
{
- NSEvent* downRef = [NSEvent otherEventWithType:NSEventTypeSystemDefined
+ NSEvent* downRef = [NSEvent otherEventWithType:NSSystemDefined
location: NSMakePoint(0, 0) modifierFlags:0xa00
timestamp:0 windowNumber:0 context:0 subtype:8
data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xa) << 8)
data2:-1];
CGEventRef downEvent = [downRef CGEvent];
- NSEvent* upRef = [NSEvent otherEventWithType:NSEventTypeSystemDefined
+ NSEvent* upRef = [NSEvent otherEventWithType:NSSystemDefined
location: NSMakePoint(0, 0) modifierFlags:0xa00
timestamp:0 windowNumber:0 context:0 subtype:8
data1:(convertKeyIDToNXKeyType(id) << 16) | ((0xb) << 8)
diff --git a/src/lib/platform/OSXPasteboardPeeker.m b/src/lib/platform/OSXPasteboardPeeker.m
index cf61046e..ab39e262 100644
--- a/src/lib/platform/OSXPasteboardPeeker.m
+++ b/src/lib/platform/OSXPasteboardPeeker.m
@@ -21,7 +21,7 @@
CFStringRef
getDraggedFileURL()
{
- NSString* pbName = NSPasteboardNameDrag;
+ NSString* pbName = NSDragPboard;
NSPasteboard* pboard = [NSPasteboard pasteboardWithName:pbName];
NSMutableString* string;