mirror of
https://github.com/debauchee/barrier.git
synced 2026-02-12 06:35:04 +08:00
Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53ebc47ace | ||
|
|
f203a7f49e | ||
|
|
e65ea3c545 | ||
| 3794767459 | |||
| b2aac6719f | |||
| 075d4f4758 | |||
| c63dd6f4f1 | |||
| 9e2fbe269d | |||
|
|
7a0bc3abb7 | ||
|
|
5916d40053 | ||
|
|
af8bbf2674 | ||
| a381347233 | |||
| 73c13ab023 | |||
|
|
443e656be2 | ||
|
|
87820d9387 | ||
|
|
c7c14f02dd | ||
| 5498836b6f | |||
|
|
cc69299ea3 | ||
|
|
ccfa11ca7b | ||
|
|
b28442ee1b | ||
|
|
4806441cb2 | ||
|
|
55c74e9075 | ||
|
|
4c0690dd96 | ||
|
|
af789958f0 | ||
|
|
5467b90982 | ||
|
|
f928c81afc | ||
|
|
39ccc4cbe6 | ||
| 2ddc81d927 | |||
| dc5dc25de7 | |||
|
|
53ee9c7803 | ||
| 1f3a91e74e | |||
|
|
99188fe24b | ||
| a956cad0da | |||
| e88bc97e63 | |||
|
|
f857354535 | ||
|
|
b570e57591 | ||
|
|
76c39aaf4e | ||
|
|
a645e9a296 | ||
| 773a0081e3 |
40
.travis.yml
40
.travis.yml
@@ -1,10 +1,34 @@
|
||||
language: cpp
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq libxtst-dev
|
||||
- sudo apt-get install -qq qtdeclarative5-dev
|
||||
- sudo apt-get install -qq libavahi-compat-libdnssd-dev
|
||||
script: sh -x ./clean_build.sh
|
||||
# skip install phase since we have a customized install package
|
||||
# creation tool for each supported platform
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
sudo: false
|
||||
dist: trusty
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libxtst-dev
|
||||
- qtdeclarative5-dev
|
||||
- libavahi-compat-libdnssd-dev
|
||||
script: sh -x ./clean_build.sh
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9
|
||||
script:
|
||||
- export COLUMNS=80
|
||||
- curl -LO https://raw.githubusercontent.com/GiovanniBussi/macports-ci/master/macports-ci
|
||||
- chmod +x ./macports-ci
|
||||
- ./macports-ci install
|
||||
- PATH="$PATH:/opt/local/bin"
|
||||
- sudo port -N install qt5-qtbase openssl
|
||||
- sh -x ./clean_build.sh
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9
|
||||
script:
|
||||
- brew update
|
||||
- brew install qt openssl
|
||||
- sh -x ./clean_build.sh
|
||||
|
||||
install: true
|
||||
|
||||
@@ -63,6 +63,7 @@ if (UNIX)
|
||||
include (CheckIncludeFileCXX)
|
||||
include (CheckSymbolExists)
|
||||
include (CheckCSourceCompiles)
|
||||
include (FindPkgConfig)
|
||||
|
||||
check_include_file_cxx (istream HAVE_ISTREAM)
|
||||
check_include_file_cxx (ostream HAVE_OSTREAM)
|
||||
@@ -131,7 +132,9 @@ if (UNIX)
|
||||
# curl is used on both Linux and Mac
|
||||
find_package (CURL)
|
||||
if (CURL_FOUND)
|
||||
list (APPEND libs curl)
|
||||
include_directories(${CURL_INCLUDE_DIRS})
|
||||
list (APPEND libs ${CURL_LIBRARIES})
|
||||
|
||||
else()
|
||||
message (FATAL_ERROR "Missing library: curl")
|
||||
endif()
|
||||
@@ -163,6 +166,12 @@ if (UNIX)
|
||||
link_directories("/usr/local/lib")
|
||||
endif()
|
||||
|
||||
if (${PKG_CONFIG_FOUND})
|
||||
pkg_check_modules (AVAHI_COMPAT REQUIRED avahi-compat-libdns_sd)
|
||||
include_directories (BEFORE SYSTEM ${AVAHI_COMPAT_INCLUDE_DIRS})
|
||||
set (CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${AVAHI_COMPAT_INCLUDE_DIRS}")
|
||||
endif ()
|
||||
|
||||
set (XKBlib "X11/Xlib.h;X11/XKBlib.h")
|
||||
set (CMAKE_EXTRA_INCLUDE_FILES "${XKBlib};X11/extensions/Xrandr.h")
|
||||
check_type_size ("XRRNotifyEvent" X11_EXTENSIONS_XRANDR_H)
|
||||
@@ -187,7 +196,7 @@ if (UNIX)
|
||||
message (FATAL_ERROR "Missing header: " ${XKBlib})
|
||||
endif()
|
||||
|
||||
if (NOT HAVE_DNSSD)
|
||||
if (BARRIER_BUILD_GUI AND NOT HAVE_DNSSD)
|
||||
message (FATAL_ERROR "Missing header: dns_sd.h")
|
||||
endif()
|
||||
|
||||
@@ -302,13 +311,28 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
${OPENSSL_ROOT}/lib/ssleay32.lib
|
||||
)
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set (OPENSSL_ROOT /usr/local/opt/openssl)
|
||||
|
||||
include_directories (BEFORE SYSTEM ${OPENSSL_ROOT}/include)
|
||||
set (OPENSSL_LIBS
|
||||
${OPENSSL_ROOT}/lib/libssl.a
|
||||
${OPENSSL_ROOT}/lib/libcrypto.a
|
||||
)
|
||||
if (IS_DIRECTORY /opt/local)
|
||||
# macports
|
||||
set (OPENSSL_ROOT /opt/local)
|
||||
|
||||
set (OPENSSL_LIBS
|
||||
${OPENSSL_ROOT}/lib/libssl.a
|
||||
${OPENSSL_ROOT}/lib/libcrypto.a
|
||||
z
|
||||
)
|
||||
elseif (IS_DIRECTORY /usr/local/opt/openssl)
|
||||
# brew
|
||||
set (OPENSSL_ROOT /usr/local/opt/openssl)
|
||||
|
||||
include_directories (BEFORE SYSTEM ${OPENSSL_ROOT}/include)
|
||||
|
||||
set (OPENSSL_LIBS
|
||||
${OPENSSL_ROOT}/lib/libssl.a
|
||||
${OPENSSL_ROOT}/lib/libcrypto.a
|
||||
)
|
||||
endif()
|
||||
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set (OPENSSL_LIBS ssl crypto)
|
||||
else()
|
||||
|
||||
@@ -10,7 +10,7 @@ Barrier is KVM software forked from Symless's synergy 1.9 codebase. Synergy was
|
||||
|
||||
### What's different?
|
||||
|
||||
Whereas synergy has moved beyond its goals from the 1.x era, barrier aims to maintain that simplicity. Barrier will let you use your keyboard and mouse from machine A to control machine B (or more). That's it.
|
||||
Whereas synergy has moved beyond its goals from the 1.x era, Barrier aims to maintain that simplicity. Barrier will let you use your keyboard and mouse from machine A to control machine B (or more). It's that simple.
|
||||
|
||||
### Project goals
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
REM defaults - override them by creating a build_env.bat file
|
||||
set B_BUILD_TYPE=Debug
|
||||
set B_QT_ROOT=C:\Qt
|
||||
set B_QT_VER=5.6.3
|
||||
set B_QT_MSVC=msvc2015_64
|
||||
set B_QT_VER=5.11.1
|
||||
set B_QT_MSVC=msvc2017_64
|
||||
set B_BONJOUR=C:\Program Files\Bonjour SDK
|
||||
|
||||
set savedir=%cd%
|
||||
|
||||
@@ -14,7 +14,7 @@ if [ "$(uname)" = "Darwin" ]; then
|
||||
# OSX needs a lot of extra help, poor thing
|
||||
# run the osx_environment.sh script to fix paths
|
||||
. ./osx_environment.sh
|
||||
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"
|
||||
B_CMAKE_FLAGS="-DCMAKE_OSX_SYSROOT=$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 $B_CMAKE_FLAGS"
|
||||
fi
|
||||
# allow local customizations to build environment
|
||||
[ -r ./build_env.sh ] && . ./build_env.sh
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required (VERSION 3.4)
|
||||
|
||||
set (BARRIER_VERSION_MAJOR 2)
|
||||
set (BARRIER_VERSION_MINOR 1)
|
||||
set (BARRIER_VERSION_MINOR 2)
|
||||
set (BARRIER_VERSION_PATCH 0)
|
||||
|
||||
#
|
||||
|
||||
5
debian/changelog
vendored
Normal file
5
debian/changelog
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
barrier (2.1-1) unstable; urgency=low
|
||||
|
||||
* Initial release (Closes: #123456)
|
||||
|
||||
-- Debauchee Open Source Group <debauchee.oss@gmail.com> Sat, 01 Apr 2018 00:00:00 +0000
|
||||
8
dist/inno/barrier.iss.in
vendored
8
dist/inno/barrier.iss.in
vendored
@@ -6,6 +6,7 @@
|
||||
#define MyAppServiceName "Barrier"
|
||||
#define MyAppServiceExe "barrierd.exe"
|
||||
#define MyAppServiceDesc "Manages the Barrier background processes."
|
||||
#define MyAppListenerDesc "Barrier Listener"
|
||||
|
||||
[Setup]
|
||||
AppId={{41036EA6-3F7A-4803-8AE0-469E5E91EFCC}
|
||||
@@ -40,6 +41,10 @@ Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||||
|
||||
[Run]
|
||||
; there's no "check if exists" or "insert if not exists" for netsh's firewall commands
|
||||
; to avoid duplicate entries remove the existing rule (fails if it doesn't exist) before adding
|
||||
Filename: {sys}\netsh.exe; Parameters: "advfirewall firewall delete rule name=""{#MyAppListenerDesc}"""; Flags: runhidden
|
||||
Filename: {sys}\netsh.exe; Parameters: "advfirewall firewall add rule name=""{#MyAppListenerDesc}"" protocol=TCP dir=in localport=24800 action=allow"; Flags: runhidden
|
||||
Filename: {sys}\sc.exe; Parameters: "create {#MyAppServiceName} start= auto binPath= ""{app}\{#MyAppServiceExe}"""; Flags: runhidden
|
||||
Filename: {sys}\sc.exe; Parameters: "description {#MyAppServiceName} ""{#MyAppServiceDesc}"""; Flags: runhidden
|
||||
Filename: {sys}\sc.exe; Parameters: "start {#MyAppServiceName}"; Flags: runhidden
|
||||
@@ -51,6 +56,7 @@ Type: files; Name: "{app}\barrierd.log"
|
||||
[UninstallRun]
|
||||
Filename: {sys}\sc.exe; Parameters: "stop {#MyAppServiceName}"; Flags: runhidden
|
||||
Filename: {sys}\sc.exe; Parameters: "delete {#MyAppServiceName}"; Flags: runhidden
|
||||
Filename: {sys}\netsh.exe; Parameters: "advfirewall firewall delete rule name=""{#MyAppListenerDesc}"""; Flags: runhidden
|
||||
|
||||
[CustomMessages]
|
||||
DependenciesDir="redist"
|
||||
@@ -68,7 +74,7 @@ begin
|
||||
// initialize windows version
|
||||
initwinversion();
|
||||
|
||||
vcredist2017('14'); // min allowed version is 14.0
|
||||
vcredist2017('14'); // min allowed version is 14.0
|
||||
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
@@ -1,16 +1,37 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! $BARRIER_BUILD_ENV ]; then
|
||||
|
||||
printf "Modifying environment for Barrier build..."
|
||||
|
||||
QT_PATH=$(brew --prefix qt)
|
||||
OPENSSL_PATH=$(brew --prefix openssl)
|
||||
if command -v port; then
|
||||
printf "Detected Macports"
|
||||
|
||||
if [ ! -d /opt/local/lib/cmake/Qt5 ]; then
|
||||
printf "Please install qt5-qtbase port"
|
||||
fi
|
||||
export BARRIER_BUILD_MACPORTS=1
|
||||
export CMAKE_PREFIX_PATH="/opt/local/lib/cmake/Qt5:$CMAKE_PREFIX_PATH"
|
||||
export LD_LIBRARY_PATH="/opt/local/lib:$LD_LIBRARY_PATH"
|
||||
export CPATH="/opt/local/include:$CPATH"
|
||||
export PKG_CONFIG_PATH="/opt/local/libexec/qt5/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
|
||||
elif command -v brew; then
|
||||
printf "Detected Homebrew"
|
||||
QT_PATH=$(brew --prefix qt)
|
||||
OPENSSL_PATH=$(brew --prefix openssl)
|
||||
|
||||
export BARRIER_BUILD_BREW=1
|
||||
export CMAKE_PREFIX_PATH="$QT_PATH:$CMAKE_PREFIX_PATH"
|
||||
export LD_LIBRARY_PATH="$OPENSSL_PATH/lib:$LD_LIBRARY_PATH"
|
||||
export CPATH="$OPENSSL_PATH/include:$CPATH"
|
||||
export PKG_CONFIG_PATH="$OPENSSL_PATH/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
|
||||
else
|
||||
printf "Neither Homebrew nor Macports is installed. Can't get dependency paths"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export CMAKE_PREFIX_PATH="$QT_PATH:$CMAKE_PREFIX_PATH"
|
||||
export LD_LIBRARY_PATH="$OPENSSL_PATH/lib:$LD_LIBRARY_PATH"
|
||||
export CPATH="$OPENSSL_PATH/include:$CPATH"
|
||||
export PKG_CONFIG_PATH="$OPENSSL_PATH/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
export BARRIER_BUILD_ENV=1
|
||||
|
||||
printf "done\n"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Version=2.1
|
||||
Name=Barrier
|
||||
Comment=Keyboard and mouse sharing solution
|
||||
Exec=barrier
|
||||
|
||||
@@ -29,6 +29,7 @@ if (WIN32)
|
||||
tb_idle.ico
|
||||
tb_run.ico
|
||||
tb_wait.ico
|
||||
barrierc.exe.manifest
|
||||
)
|
||||
elseif (APPLE)
|
||||
file(GLOB arch_headers "OSX*.h")
|
||||
|
||||
2
src/cmd/barrierc/barrierc.exe.manifest
Normal file
2
src/cmd/barrierc/barrierc.exe.manifest
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security><requestedPrivileges><requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel></requestedPrivileges></security></trustInfo><application xmlns="urn:schemas-microsoft-com:asm.v3"><windowsSettings><dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware></windowsSettings></application></assembly>
|
||||
@@ -29,6 +29,7 @@ if (WIN32)
|
||||
tb_idle.ico
|
||||
tb_run.ico
|
||||
tb_wait.ico
|
||||
barriers.exe.manifest
|
||||
)
|
||||
elseif (APPLE)
|
||||
file(GLOB arch_headers "OSX*.h")
|
||||
|
||||
2
src/cmd/barriers/barriers.exe.manifest
Normal file
2
src/cmd/barriers/barriers.exe.manifest
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security><requestedPrivileges><requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel></requestedPrivileges></security></trustInfo><application xmlns="urn:schemas-microsoft-com:asm.v3"><windowsSettings><dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware></windowsSettings></application></assembly>
|
||||
@@ -22,7 +22,7 @@ add_executable (barrier WIN32
|
||||
|
||||
include_directories (./src)
|
||||
|
||||
qt5_use_modules (barrier Core Widgets Network)
|
||||
target_link_libraries (barrier Qt5::Core Qt5::Widgets Qt5::Network)
|
||||
target_compile_definitions (barrier PRIVATE -DBARRIER_VERSION_STAGE="${BARRIER_VERSION_STAGE}")
|
||||
target_compile_definitions (barrier PRIVATE -DBARRIER_REVISION="${BARRIER_REVISION}")
|
||||
|
||||
@@ -36,8 +36,7 @@ if (WIN32)
|
||||
elseif (APPLE)
|
||||
find_library(APPSERVICES_LIB ApplicationServices)
|
||||
target_link_libraries(barrier ${APPSERVICES_LIB})
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR
|
||||
${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
else()
|
||||
target_link_libraries (barrier dns_sd)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
#include <QButtonGroup>
|
||||
|
||||
ActionDialog::ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey, Action& action) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* barrier -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless Ltd.
|
||||
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
||||
|
||||
@@ -23,6 +23,19 @@
|
||||
#include <QtGui>
|
||||
#include <QMessageBox>
|
||||
|
||||
static const QRegExp ValidScreenName("[a-z0-9\\._-]{,255}", Qt::CaseInsensitive);
|
||||
|
||||
static QString check_name_param(QString name)
|
||||
{
|
||||
// after internationalization happens the default name "Unnamed" might
|
||||
// be translated with spaces (or other chars). let's replace the spaces
|
||||
// with dashes and just give up if that doesn't pass the regexp
|
||||
name.replace(' ', '-');
|
||||
if (ValidScreenName.exactMatch(name))
|
||||
return name;
|
||||
return "";
|
||||
}
|
||||
|
||||
ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::ScreenSettingsDialogBase(),
|
||||
@@ -30,13 +43,11 @@ ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen) :
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
QRegExp validScreenName("[a-z0-9\\._-]{,255}", Qt::CaseInsensitive);
|
||||
|
||||
m_pLineEditName->setText(m_pScreen->name());
|
||||
m_pLineEditName->setValidator(new QRegExpValidator(validScreenName, m_pLineEditName));
|
||||
m_pLineEditName->setText(check_name_param(m_pScreen->name()));
|
||||
m_pLineEditName->setValidator(new QRegExpValidator(ValidScreenName, m_pLineEditName));
|
||||
m_pLineEditName->selectAll();
|
||||
|
||||
m_pLineEditAlias->setValidator(new QRegExpValidator(validScreenName, m_pLineEditName));
|
||||
m_pLineEditAlias->setValidator(new QRegExpValidator(ValidScreenName, m_pLineEditName));
|
||||
|
||||
for (int i = 0; i < m_pScreen->aliases().count(); i++)
|
||||
new QListWidgetItem(m_pScreen->aliases()[i], m_pListAliases);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
#include <QHeaderView>
|
||||
|
||||
ScreenSetupView::ScreenSetupView(QWidget* parent) :
|
||||
QTableView(parent)
|
||||
|
||||
@@ -167,7 +167,7 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_21">
|
||||
<property name="text">
|
||||
<string>&Interface:</string>
|
||||
<string>&Address:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pLineEditInterface</cstring>
|
||||
|
||||
@@ -121,7 +121,7 @@ void SslCertificate::generateCertificate()
|
||||
|
||||
// private key
|
||||
arguments.append("-newkey");
|
||||
arguments.append("rsa:1024");
|
||||
arguments.append("rsa:2048");
|
||||
|
||||
QDir sslDir(sslDirPath);
|
||||
if (!sslDir.exists()) {
|
||||
|
||||
@@ -41,7 +41,5 @@ add_library(arch STATIC ${sources})
|
||||
|
||||
if (UNIX)
|
||||
target_link_libraries(arch ${libs})
|
||||
if (NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
target_link_libraries(arch dl)
|
||||
endif()
|
||||
target_link_libraries(arch ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
|
||||
@@ -145,7 +145,7 @@ ServerApp::help()
|
||||
<< std::endl
|
||||
<< "If no configuration file pathname is provided then the first of the" << std::endl
|
||||
<< "following to load successfully sets the configuration:" << std::endl
|
||||
<< " " << PathUtilities::concat(DataDirectories::profile(), SYS_CONFIG_NAME) << std::endl
|
||||
<< " " << PathUtilities::concat(DataDirectories::profile(), USR_CONFIG_NAME) << std::endl
|
||||
<< " " << PathUtilities::concat(DataDirectories::systemconfig(), SYS_CONFIG_NAME) << std::endl;
|
||||
|
||||
LOG((CLOG_PRINT "%s", buffer.str().c_str()));
|
||||
|
||||
@@ -628,25 +628,25 @@ Unicode::fromUTF8(const UInt8*& data, UInt32& n)
|
||||
case 4:
|
||||
c = ((static_cast<UInt32>(data[0]) & 0x07) << 18) |
|
||||
((static_cast<UInt32>(data[1]) & 0x3f) << 12) |
|
||||
((static_cast<UInt32>(data[1]) & 0x3f) << 6) |
|
||||
((static_cast<UInt32>(data[1]) & 0x3f) );
|
||||
((static_cast<UInt32>(data[2]) & 0x3f) << 6) |
|
||||
((static_cast<UInt32>(data[3]) & 0x3f) );
|
||||
break;
|
||||
|
||||
case 5:
|
||||
c = ((static_cast<UInt32>(data[0]) & 0x03) << 24) |
|
||||
((static_cast<UInt32>(data[1]) & 0x3f) << 18) |
|
||||
((static_cast<UInt32>(data[1]) & 0x3f) << 12) |
|
||||
((static_cast<UInt32>(data[1]) & 0x3f) << 6) |
|
||||
((static_cast<UInt32>(data[1]) & 0x3f) );
|
||||
((static_cast<UInt32>(data[2]) & 0x3f) << 12) |
|
||||
((static_cast<UInt32>(data[3]) & 0x3f) << 6) |
|
||||
((static_cast<UInt32>(data[4]) & 0x3f) );
|
||||
break;
|
||||
|
||||
case 6:
|
||||
c = ((static_cast<UInt32>(data[0]) & 0x01) << 30) |
|
||||
((static_cast<UInt32>(data[1]) & 0x3f) << 24) |
|
||||
((static_cast<UInt32>(data[1]) & 0x3f) << 18) |
|
||||
((static_cast<UInt32>(data[1]) & 0x3f) << 12) |
|
||||
((static_cast<UInt32>(data[1]) & 0x3f) << 6) |
|
||||
((static_cast<UInt32>(data[1]) & 0x3f) );
|
||||
((static_cast<UInt32>(data[2]) & 0x3f) << 18) |
|
||||
((static_cast<UInt32>(data[3]) & 0x3f) << 12) |
|
||||
((static_cast<UInt32>(data[4]) & 0x3f) << 6) |
|
||||
((static_cast<UInt32>(data[5]) & 0x3f) );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -144,10 +144,10 @@ private:
|
||||
ButtonID mapMacButtonToBarrier(UInt16) const;
|
||||
|
||||
// map mac scroll wheel value to a barrier scroll wheel value
|
||||
SInt32 mapScrollWheelToBarrier(SInt32) const;
|
||||
SInt32 mapScrollWheelToBarrier(float) const;
|
||||
|
||||
// map barrier scroll wheel value to a mac scroll wheel value
|
||||
SInt32 mapScrollWheelFromBarrier(SInt32) const;
|
||||
SInt32 mapScrollWheelFromBarrier(float) const;
|
||||
|
||||
// get the current scroll wheel speed
|
||||
double getScrollSpeed() const;
|
||||
|
||||
@@ -1421,7 +1421,7 @@ OSXScreen::mapMacButtonToBarrier(UInt16 macButton) const
|
||||
}
|
||||
|
||||
SInt32
|
||||
OSXScreen::mapScrollWheelToBarrier(SInt32 x) const
|
||||
OSXScreen::mapScrollWheelToBarrier(float x) const
|
||||
{
|
||||
// return accelerated scrolling but not exponentially scaled as it is
|
||||
// on the mac.
|
||||
@@ -1430,7 +1430,7 @@ OSXScreen::mapScrollWheelToBarrier(SInt32 x) const
|
||||
}
|
||||
|
||||
SInt32
|
||||
OSXScreen::mapScrollWheelFromBarrier(SInt32 x) const
|
||||
OSXScreen::mapScrollWheelFromBarrier(float x) const
|
||||
{
|
||||
// use server's acceleration with a little boost since other platforms
|
||||
// take one wheel step as a larger step than the mac does.
|
||||
@@ -1948,9 +1948,9 @@ OSXScreen::handleCGInputEvent(CGEventTapProxy proxy,
|
||||
break;
|
||||
case kCGEventScrollWheel:
|
||||
screen->onMouseWheel(screen->mapScrollWheelToBarrier(
|
||||
CGEventGetIntegerValueField(event, kCGScrollWheelEventDeltaAxis2)),
|
||||
CGEventGetIntegerValueField(event, kCGScrollWheelEventFixedPtDeltaAxis2) / 65536.0f),
|
||||
screen->mapScrollWheelToBarrier(
|
||||
CGEventGetIntegerValueField(event, kCGScrollWheelEventDeltaAxis1)));
|
||||
CGEventGetIntegerValueField(event, kCGScrollWheelEventFixedPtDeltaAxis1) / 65536.0f));
|
||||
break;
|
||||
case kCGEventKeyDown:
|
||||
case kCGEventKeyUp:
|
||||
|
||||
@@ -99,6 +99,7 @@ XWindowsScreen::XWindowsScreen(
|
||||
IEventQueue* events) :
|
||||
m_isPrimary(isPrimary),
|
||||
m_mouseScrollDelta(mouseScrollDelta),
|
||||
m_accumulatedScroll(0),
|
||||
m_display(NULL),
|
||||
m_root(None),
|
||||
m_window(None),
|
||||
@@ -865,9 +866,11 @@ XWindowsScreen::fakeMouseWheel(SInt32, SInt32 yDelta) const
|
||||
return;
|
||||
}
|
||||
|
||||
// choose button depending on rotation direction
|
||||
const unsigned int xButton = mapButtonToX(static_cast<ButtonID>(
|
||||
(yDelta >= 0) ? -1 : -2));
|
||||
int numEvents = accumulateMouseScroll(yDelta);
|
||||
|
||||
// choose button depending on rotation direction
|
||||
const unsigned int xButton = mapButtonToX(static_cast<ButtonID>(
|
||||
(numEvents >= 0) ? -1 : -2));
|
||||
if (xButton == 0) {
|
||||
// If we get here, then the XServer does not support the scroll
|
||||
// wheel buttons, so send PageUp/PageDown keystrokes instead.
|
||||
@@ -886,20 +889,14 @@ XWindowsScreen::fakeMouseWheel(SInt32, SInt32 yDelta) const
|
||||
return;
|
||||
}
|
||||
|
||||
// now use absolute value of delta
|
||||
if (yDelta < 0) {
|
||||
yDelta = -yDelta;
|
||||
}
|
||||
|
||||
if (yDelta < m_mouseScrollDelta) {
|
||||
LOG((CLOG_WARN "Wheel scroll delta (%d) smaller than threshold (%d)", yDelta, m_mouseScrollDelta));
|
||||
}
|
||||
numEvents = std::abs(numEvents);
|
||||
|
||||
// send as many clicks as necessary
|
||||
for (; yDelta >= m_mouseScrollDelta; yDelta -= m_mouseScrollDelta) {
|
||||
for (; numEvents > 0; numEvents--) {
|
||||
XTestFakeButtonEvent(m_display, xButton, True, CurrentTime);
|
||||
XTestFakeButtonEvent(m_display, xButton, False, CurrentTime);
|
||||
}
|
||||
|
||||
XFlush(m_display);
|
||||
}
|
||||
|
||||
@@ -1643,6 +1640,15 @@ XWindowsScreen::onMouseMove(const XMotionEvent& xmotion)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
XWindowsScreen::accumulateMouseScroll(SInt32 yDelta) const
|
||||
{
|
||||
m_accumulatedScroll += yDelta;
|
||||
int numEvents = m_accumulatedScroll / m_mouseScrollDelta;
|
||||
m_accumulatedScroll -= numEvents * m_mouseScrollDelta;
|
||||
return numEvents;
|
||||
}
|
||||
|
||||
Cursor
|
||||
XWindowsScreen::createBlankCursor() const
|
||||
{
|
||||
|
||||
@@ -136,6 +136,10 @@ private:
|
||||
void onMouseRelease(const XButtonEvent&);
|
||||
void onMouseMove(const XMotionEvent&);
|
||||
|
||||
// Returns the number of scroll events needed after the current delta has
|
||||
// been taken into account
|
||||
int accumulateMouseScroll(SInt32 yDelta) const;
|
||||
|
||||
bool detectXI2();
|
||||
#ifdef HAVE_XI2
|
||||
void selectXIRawMotion();
|
||||
@@ -172,8 +176,15 @@ private:
|
||||
|
||||
// true if screen is being used as a primary screen, false otherwise
|
||||
bool m_isPrimary;
|
||||
|
||||
// The size of a smallest supported scroll event, in points
|
||||
int m_mouseScrollDelta;
|
||||
|
||||
// Accumulates scrolls of less than m_mouseScrollDelta across multiple
|
||||
// scroll events. We dispatch a scroll event whenever the accumulated scroll
|
||||
// becomes larger than m_mouseScrollDelta
|
||||
mutable int m_accumulatedScroll;
|
||||
|
||||
Display* m_display;
|
||||
Window m_root;
|
||||
Window m_window;
|
||||
|
||||
Reference in New Issue
Block a user