diff options
| author | 2019-07-18 01:31:43 -0400 | |
|---|---|---|
| committer | 2019-07-18 01:31:43 -0400 | |
| commit | a916009d4b29995ea8ad61ad47a51c2ee1fa80bc (patch) | |
| tree | f53f459caa6868bda7c3f6dae0d8f30f19325af3 | |
| parent | 68a36b3b67ec82cdd3f77e88e40d1043cbab5000 (diff) | |
New upstream version 2.3.0+dfsgupstream/2.3.0+dfsg
141 files changed, 2012 insertions, 461 deletions
@@ -20,3 +20,14 @@ src/gui/gui.pro.user* src/gui/.qmake.stash src/gui/.rnd src/setup/win32/barrier.suo +Makefile +*.cmake +**/CMakeFiles/ +CMakeCache.txt +/rpm +# Visual Studio 2015/2017 cache/options directory +.vs/ +# VS Code Directory +.vscode/ +# Transient in-project-directory dependencies +/deps/ diff --git a/Build.properties b/Build.properties index b8b83fd..7b352fe 100644 --- a/Build.properties +++ b/Build.properties @@ -1,7 +1,7 @@ # # Barrier build parameters # -BARRIER_VERSION_MAJOR = 1 -BARRIER_VERSION_MINOR = 9 +BARRIER_VERSION_MAJOR = 2 +BARRIER_VERSION_MINOR = 3 BARRIER_VERSION_PATCH = 0 BARRIER_VERSION_STAGE = snapshot diff --git a/CMakeLists.txt b/CMakeLists.txt index f6f6aa7..d5ec96f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -311,8 +311,10 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") ${OPENSSL_ROOT}/lib/ssleay32.lib ) elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - - if (IS_DIRECTORY /opt/local) + find_program(BREW_PROGRAM "brew") + find_program(PORT_PROGRAM "port") + + if (IS_DIRECTORY /opt/local AND PORT_PROGRAM) # macports set (OPENSSL_ROOT /opt/local) @@ -321,7 +323,7 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ${OPENSSL_ROOT}/lib/libcrypto.a z ) - elseif (IS_DIRECTORY /usr/local/opt/openssl) + elseif (IS_DIRECTORY /usr/local/opt/openssl AND BREW_PROGRAM) # brew set (OPENSSL_ROOT /usr/local/opt/openssl) @@ -388,12 +390,20 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set (BARRIER_BUNDLE_BINARY_DIR ${BARRIER_BUNDLE_APP_DIR}/Contents/MacOS) configure_files (${BARRIER_BUNDLE_SOURCE_DIR} ${BARRIER_BUNDLE_DIR}) + + if (CMAKE_BUILD_TYPE STREQUAL "Release") + add_custom_target(Barrier_dmg ALL + bash build_installer.sh + DEPENDS barrier barriers barrierc + WORKING_DIRECTORY ${BARRIER_BUNDLE_DIR}) + endif() endif() # # Windows installer # if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set (BARRIER_WIX_VERSION "${BARRIER_VERSION_MAJOR}.${BARRIER_VERSION_MINOR}.${BARRIER_VERSION_PATCH}") message (STATUS "Configuring the wix installer") configure_files (${CMAKE_CURRENT_SOURCE_DIR}/dist/wix ${CMAKE_BINARY_DIR}/installer-wix) message (STATUS "Configuring the inno installer") @@ -1,9 +1,16 @@ # Barrier -Eliminate the barrier between your machines. +Eliminate the barrier between your machines. +Find [releases here](https://github.com/debauchee/barrier/releases). + +### Contact info: + +- `#barrier` on freenode Master branch build status: [](https://travis-ci.org/debauchee/barrier) +Azure Pipelines build status: [](https://dev.azure.com/debauchee/Barrier/_build/latest?definitionId=1&branchName=master) + ### What is it? Barrier is KVM software forked from Symless's synergy 1.9 codebase. Synergy was a commercialized reimplementation of the original CosmoSynergy written by Chris Schoeneman. @@ -22,10 +29,28 @@ Communication. Everything we do is in the open. Our issue tracker will let you s ### Contact & support -Please be aware that the *only* way to draw our attention to a bug is to create a new PR in the issue tracker. Write a clear, concise, detailed report and you will get a clear, concise, detailed response. Priority is always give to issues that affect a wider range of users. +Please be aware that the *only* way to draw our attention to a bug is to create a new PR in the issue tracker. Write a clear, concise, detailed report and you will get a clear, concise, detailed response. Priority is always given to issues that affect a wider range of users. For short and simple questions or to just say hello find us on the Freenode IRC network in the #barrier channel. ### Contributions At this time we are looking for developers to help fix the issues found in the issue tracker. Submit pull requests once you've polished up your patch and we'll review and possibly merge it. + +### FAQ + +Q: Does drag and drop work on linux? + +A: No + +Q: What OSes are supported? + +A: + - Windows 7, 8, 8.1, and 10 + - MacOS/OS X + - Linux + - FreeBSD + +Q: Are 32-bit versions of Windows supported? + +A: No diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..cabe88f --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,94 @@ +trigger: + tags: + include: + - '*' + branches: + include: + - '*' + +jobs: +- job: WinBuild + displayName: Windows Build + pool: + vmImage: 'vs2017-win2016' + strategy: + matrix: + Debug: + CI_ENV_BUILD_TYPE: Debug + Release with Release Installer: + CI_ENV_BUILD_TYPE: Release + steps: + # Gather Dependencies + - task: PowerShell@2 + displayName: Download Bonjour SDK-like + inputs: + filePath: azure-pipelines/download_install_bonjour_sdk_like.ps1 + - task: UsePythonVersion@0 + displayName: Selecting Python Installer for QLI Installer + inputs: + versionSpec: '3.7' + - task: PowerShell@2 + displayName: Installing QT + condition: ne(variables['CacheRestored'], 'true') + inputs: + filePath: azure-pipelines/download_install_qt.ps1 + # Build time! + - powershell: Copy-Item azure-pipelines\build_env_tmpl.bat build_env.bat + displayName: Layering Azure Pipeline's build_env.bat + - script: | + call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\vsdevcmd" -arch=x64 && clean_build.bat + displayName: Clean Build + - task: ArchiveFiles@2 + displayName: Archive Completed Build Directory + inputs: + rootFolderOrFile: build\bin\$(CI_ENV_BUILD_TYPE)\ + includeRootFolder: true + archiveFile: $(Build.ArtifactStagingDirectory)\$(CI_ENV_BUILD_TYPE).zip + - task: PublishBuildArtifacts@1 + displayName: Publish Completed Build Directory Archive Build Artifact + inputs: + pathtoPublish: $(Build.ArtifactStagingDirectory)\$(CI_ENV_BUILD_TYPE).zip + artifactName: Windows $(CI_ENV_BUILD_TYPE) + - script: build_installer.bat + displayName: Build Installer + condition: eq(variables['CI_ENV_BUILD_TYPE'], 'Release') + - task: PublishBuildArtifacts@1 + displayName: Publish Release Installer + condition: eq(variables['CI_ENV_BUILD_TYPE'], 'Release') + inputs: + pathtoPublish: build\installer-inno\bin + artifactName: Windows Release Installer + +- job: LinuxBuild + displayName: Linux Build + pool: + vmImage: 'ubuntu-16.04' + steps: + - script: sudo apt-get update -y + - script: sudo apt-get install -y libxtst-dev qtdeclarative5-dev libavahi-compat-libdnssd-dev libcurl4-openssl-dev + displayName: Install Dependencies + - script: sh -x ./clean_build.sh + displayName: Clean Build + +- job: MacBuild + displayName: Mac Build + pool: + vmImage: 'macOS-10.14' + strategy: + matrix: + Release: + B_BUILD_TYPE: Release + BARRIER_VERSION_STAGE: Release + steps: + - script: brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/aac86fc018c48d7b6f23a2e7535276899774567a/Formula/qt.rb + displayName: Installed Pinned Qt + - script: brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/aac86fc018c48d7b6f23a2e7535276899774567a/Formula/openssl.rb + displayName: Installed Pinned OpenSSL + - script: sh -x ./clean_build.sh + displayName: Clean Build + - task: PublishBuildArtifacts@1 + displayName: Publish Release DMG + condition: eq(variables['B_BUILD_TYPE'], 'Release') + inputs: + pathtoPublish: build/bundle + artifactName: Mac Release Disk Image and App diff --git a/azure-pipelines/build_env_tmpl.bat b/azure-pipelines/build_env_tmpl.bat new file mode 100644 index 0000000..eefa014 --- /dev/null +++ b/azure-pipelines/build_env_tmpl.bat @@ -0,0 +1,6 @@ +set B_BUILD_TYPE=%CI_ENV_BUILD_TYPE% +set B_QT_ROOT=%cd%\deps\Qt +set B_QT_VER=Qt5.12.3\5.12.3 +set B_QT_MSVC=msvc2017_64 +set B_BONJOUR=%cd%\deps\BonjourSDKLike + diff --git a/azure-pipelines/download_install_bonjour_sdk_like.ps1 b/azure-pipelines/download_install_bonjour_sdk_like.ps1 new file mode 100644 index 0000000..97bfa83 --- /dev/null +++ b/azure-pipelines/download_install_bonjour_sdk_like.ps1 @@ -0,0 +1,12 @@ +$ErrorActionPreference = "Stop" + +New-Item -Force -ItemType Directory -Path ".\deps\" +$Wc = New-Object System.Net.WebClient +$Wc.DownloadFile('https://github.com/nelsonjchen/mDNSResponder/releases/download/v2019.05.08.1/x64_RelWithDebInfo.zip', 'deps\BonjourSDKLike.zip') ; +Write-Output 'Downloaded BonjourSDKLike Zip' +Write-Output 'Unzipping BonjourSDKLike Zip' +Remove-Item -Recurse -Force -ErrorAction Ignore .\deps\BonjourSDKLike +Expand-Archive .\deps\BonjourSDKLike.zip -DestinationPath .\deps\BonjourSDKLike +Write-Output 'Installed BonjourSDKLike Zip' +Remove-Item deps\BonjourSDKLike.zip +Write-Output 'Deleted BonjourSDKLike Zip' diff --git a/azure-pipelines/download_install_qt.ps1 b/azure-pipelines/download_install_qt.ps1 new file mode 100644 index 0000000..7edefbf --- /dev/null +++ b/azure-pipelines/download_install_qt.ps1 @@ -0,0 +1,26 @@ +$ErrorActionPreference = "Stop" + +$qli_install_version = '2019.05.26.1' +$qt_version = '5.12.3' + +New-Item -Force -ItemType Directory -Path ".\deps\" + +Write-Output 'Downloading QLI Installer' +$Wc = New-Object System.Net.WebClient +$Wc.DownloadFile("https://github.com/nelsonjchen/qli-installer/archive/v$qli_install_version.zip", '.\deps\qli-installer.zip') ; +Write-Output 'Downloaded QLI Installer' + +Write-Output 'Extracting QLI Installer' +Expand-Archive deps\qli-installer.zip deps\ +Move-Item .\deps\qli-installer-$qli_install_version\ .\deps\qli-installer +Write-Output 'Extracted QLI Installer' + +Write-Output 'Installing QLI Installer Dependencies' +pip install -r .\deps\qli-installer\requirements.txt +Write-Output 'Installed QLI Installer Dependencies' + +Write-Output 'Starting QT Installer' +$Env:QLI_OUT_DIR = ".\deps\Qt\Qt$qt_version" +$Env:QLI_BASE_URL = "http://mirrors.ocf.berkeley.edu/qt/online/qtsdkrepository/" +python .\deps\qli-installer\qli-installer.py $qt_version windows desktop win64_msvc2017_64 +Write-Output 'Installed QT Installer' diff --git a/build_installer.bat b/build_installer.bat index 424e585..9c204cc 100644 --- a/build_installer.bat +++ b/build_installer.bat @@ -1,25 +1,24 @@ @echo off
-set WIX_ROOT=C:\Program Files (x86)\WiX Toolset v3.11
+set INNO_ROOT=C:\Program Files (x86)\Inno Setup 5
set savedir=%cd%
cd /d %~dp0
if not exist build\bin\Release goto buildproject
-cd build\installer
-if ERRORLEVEL 1 goto buildproject
-
echo Building 64-bit Windows installer...
-"%WIX_ROOT%\bin\candle.exe" -nologo -arch x64 -dConfiguration=Release -dPlatform=x64 -ext WixUtilExtension -ext WixFirewallExtension Product.wxs -o Barrier.wixobj
-if ERRORLEVEL 1 goto failed
-"%WIX_ROOT%\bin\light.exe" -nologo -ext WixUtilExtension -ext WixFirewallExtension -ext WixUIExtension Barrier.wixobj -o bin\Barrier.msi
+
+cd build\installer-inno
+if ERRORLEVEL 1 goto buildproject
+"%INNO_ROOT%\ISCC.exe" /Qp barrier.iss
if ERRORLEVEL 1 goto failed
+
echo Build completed successfully
goto done
:buildproject
echo To build a 64-bit Windows installer:
-echo - set Q_BUILD_TYPE=Release in build_env.bat
+echo - set B_BUILD_TYPE=Release in build_env.bat
echo - also set other environmental overrides necessary for your build environment
echo - run clean_build.bat to build Barrier and verify that it succeeds
echo - re-run this script to create the installation package
@@ -29,7 +28,7 @@ goto done echo Build failed
:done
-set WIX_ROOT=
+set INNO_ROOT=
cd /d %savedir%
set savedir=
diff --git a/clean_build.bat b/clean_build.bat index b1f0410..e45f334 100644 --- a/clean_build.bat +++ b/clean_build.bat @@ -10,6 +10,18 @@ set B_BONJOUR=C:\Program Files\Bonjour SDK set savedir=%cd%
cd /d %~dp0
+REM cmake generator name for the target build system
+if "%VisualStudioVersion%"=="15.0" (
+ set cmake_gen=Visual Studio 15 2017
+) else if "%VisualStudioVersion%"=="16.0" (
+ set cmake_gen=Visual Studio 16 2019
+) else (
+ echo Visual Studio version was not detected.
+ echo Did you forget to run inside a VS developer prompt?
+ echo Using the default cmake generator.
+ set cmake_gen=Visual Studio 16 2019
+)
+
if exist build_env.bat call build_env.bat
REM needed by cmake to set bonjour include dir
@@ -25,7 +37,7 @@ rmdir /q /s build mkdir build
if ERRORLEVEL 1 goto failed
cd build
-cmake -G "Visual Studio 15 2017 Win64" -D CMAKE_BUILD_TYPE=%B_BUILD_TYPE% -D CMAKE_PREFIX_PATH="%B_QT_FULLPATH%" -D DNSSD_LIB="%B_BONJOUR%\Lib\x64\dnssd.lib" -D QT_VERSION=%B_QT_VER% ..
+cmake -G "%cmake_gen%" -A x64 -D CMAKE_BUILD_TYPE=%B_BUILD_TYPE% -D CMAKE_PREFIX_PATH="%B_QT_FULLPATH%" -D DNSSD_LIB="%B_BONJOUR%\Lib\x64\dnssd.lib" -D QT_VERSION=%B_QT_VER% ..
if ERRORLEVEL 1 goto failed
echo @msbuild barrier.sln /p:Platform="x64" /p:Configuration=%B_BUILD_TYPE% /m %B_BUILD_OPTIONS% > make.bat
call make.bat
@@ -69,3 +81,4 @@ set B_BONJOUR= set BONJOUR_SDK_HOME=
set B_QT_FULLPATH=
set savedir=
+set cmake_gen=
diff --git a/cmake/Version.cmake b/cmake/Version.cmake index 6b51e40..c003ad6 100644 --- a/cmake/Version.cmake +++ b/cmake/Version.cmake @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 3.4) set (BARRIER_VERSION_MAJOR 2) -set (BARRIER_VERSION_MINOR 2) +set (BARRIER_VERSION_MINOR 3) set (BARRIER_VERSION_PATCH 0) # diff --git a/dist/rpm/barrier.spec.in b/dist/rpm/barrier.spec.in index 0f70007..1c7c5fa 100644 --- a/dist/rpm/barrier.spec.in +++ b/dist/rpm/barrier.spec.in @@ -1,26 +1,105 @@ +%global barrier_revision @BARRIER_REVISION@ +Summary: Keyboard and mouse sharing solution Name: barrier Version: @BARRIER_VERSION@ -Summary: Keyboard and mouse sharing solution -Group: Applications/Productivity -URL: https://github.com/debauchee/barrier/ -Source: https://github.com/debauchee/barrier/ -Vendor: Debauchee -Packager: Debauchee <todo@mail.com> +Release: @BARRIER_BUILD_NUMBER@%{?dist} License: GPLv2 -Release: @BARRIER_BUILD_NUMBER@@BARRIER_SNAPSHOT_INFO@%{?dist} +Group: System Environment/Daemons +URL: https://github.com/debauchee/barrier +Source0: https://github.com/debauchee/barrier/archive/v%{version}.tar.gz + +BuildRequires: cmake3 +BuildRequires: avahi-compat-libdns_sd-devel +BuildRequires: libX11-devel +BuildRequires: libXtst-devel +BuildRequires: qt5-qtbase-devel +BuildRequires: libcurl-devel +BuildRequires: desktop-file-utils +BuildRequires: openssl-devel %description Barrier allows you to share one mouse and keyboard between multiple computers. Work seamlessly across Windows, macOS and Linux. +%prep +%setup -q -n %{name}-%{version} + + +%build +%{cmake3} -DSYNERGY_VERSION_STAGE:STRING=@BARRIER_VERSION_STAGE@ -DSYNERGY_REVISION:STRING=%{barrier_revision} . +make %{?_smp_mflags} + + +%install +install -D -p -m 0755 bin/barrier %{buildroot}%{_bindir}/barrier +install -D -p -m 0755 bin/barrierc %{buildroot}%{_bindir}/barrierc +install -D -p -m 0755 bin/barriers %{buildroot}%{_bindir}/barriers +install -D -p -m 0644 doc/barrierc.1 %{buildroot}%{_mandir}/man1/barrierc.1 +install -D -p -m 0644 doc/barriers.1 %{buildroot}%{_mandir}/man1/barriers.1 +install -D -p -m 0644 res/barrier.desktop %{buildroot}%{_datadir}/applications/barrier.desktop +install -D -p -m 0644 res/barrier.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/barrier.svg + +cd %{buildroot}%{_bindir} + +mkdir -p %{buildroot}%{_datadir}/metainfo +## Write AppStream +cat <<END> %{buildroot}%{_datadir}/metainfo/%{name}.appdata.xml +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright 2018 Ding-Yi Chen <dchen@redhat.com> --> +<component type="desktop-application"> + <id>%{name}</id> + <metadata_license>FSFAP</metadata_license> + <project_license>GPLv2</project_license> + <name>barrier</name> + <summary>Share mouse and keyboard between multiple computers over the network</summary> + + <description> + <p> + Barrier allows you to share one mouse and keyboard between multiple computers. + Work seamlessly across Windows, macOS and Linux. + </p> + </description> + + <launchable type="desktop-id">%{name}.desktop</launchable> + + <url type="homepage">https://github.com/debauchee/barrier</url> + + <provides> + <binary>barrier</binary> + <binary>barrierc</binary> + <binary>barriers</binary> + </provides> + + <releases> + <release version="%{version}" date="2019-03-21" /> + </releases> +</component> +END + +desktop-file-install --delete-original \ + --dir %{buildroot}%{_datadir}/applications \ + --set-icon=%{_datadir}/icons/hicolor/scalable/apps/barrier.svg \ + %{buildroot}%{_datadir}/applications/barrier.desktop + +desktop-file-validate %{buildroot}/%{_datadir}/applications/barrier.desktop + %files -%defattr(755,root,root,-) +# None of the documentation files are actually useful here, they all point to +# the online website, so include just one, the README +%doc LICENSE ChangeLog res/Readme.txt doc/barrier.conf.example* %{_bindir}/barrier %{_bindir}/barrierc %{_bindir}/barriers -%attr(644,-,-) %{_datarootdir}/applications/barrier.desktop -%attr(644,-,-) %{_datarootdir}/icons/hicolor/scalable/apps/barrier.svg +%{_datadir}/icons/hicolor/scalable/apps/barrier.svg +%{_datadir}/applications/barrier.desktop +%{_datadir}/metainfo/%{name}.appdata.xml +%{_mandir}/man1/barrierc.1* +%{_mandir}/man1/barriers.1* %changelog +* Thu Mar 21 2019 wendall911 <wendallc@83864.com> +- Actual working spec file for Fedora + * Sat Jan 27 2018 Debauchee <todo@mail.com> - Initial version of the package + diff --git a/osx_environment.sh b/osx_environment.sh index e30a0c0..09fa347 100644 --- a/osx_environment.sh +++ b/osx_environment.sh @@ -1,15 +1,26 @@ #!/bin/bash +# Checks if directory exists, otherwise asks to install package. +function check_dir_exists() { + local path=$1 + local package=$2 + + if [ ! -d "$path" ]; then + echo "Please install $package" + exit 1 + fi +} + if [ ! $BARRIER_BUILD_ENV ]; then + check_dir_exists '/Applications/Xcode.app' 'Xcode' - printf "Modifying environment for Barrier build..." + printf "Modifying environment for Barrier build...\n" if command -v port; then - printf "Detected Macports" + printf "Detected Macports\n" + + check_dir_exists '/opt/local/lib/cmake/Qt5' 'qt5-qtbase port' - 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" @@ -17,10 +28,13 @@ if [ ! $BARRIER_BUILD_ENV ]; then export PKG_CONFIG_PATH="/opt/local/libexec/qt5/lib/pkgconfig:$PKG_CONFIG_PATH" elif command -v brew; then - printf "Detected Homebrew" + printf "Detected Homebrew\n" QT_PATH=$(brew --prefix qt) OPENSSL_PATH=$(brew --prefix openssl) + check_dir_exists "$QT_PATH" 'qt' + check_dir_exists "$OPENSSL_PATH" '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" @@ -28,7 +42,7 @@ if [ ! $BARRIER_BUILD_ENV ]; then export PKG_CONFIG_PATH="$OPENSSL_PATH/lib/pkgconfig:$PKG_CONFIG_PATH" else - printf "Neither Homebrew nor Macports is installed. Can't get dependency paths" + printf "Neither Homebrew nor Macports is installed. Can't get dependency paths\n" exit 1 fi diff --git a/pre-build.bat b/pre-build.bat new file mode 100644 index 0000000..0c78903 --- /dev/null +++ b/pre-build.bat @@ -0,0 +1 @@ +%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" diff --git a/res/openssl/barrier.conf b/res/openssl/barrier.conf index 84325c6..a29abfd 100644 --- a/res/openssl/barrier.conf +++ b/res/openssl/barrier.conf @@ -31,7 +31,7 @@ commonName = supplied emailAddress = optional [req] -default_bits = 1024 # Size of keys +default_bits = 2048 # Size of keys default_keyfile = key.pem # name of generated keys default_md = md5 # message digest algorithm string_mask = nombstr # permitted characters diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..671ccd4 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,104 @@ +name: barrier-kvm # the Barrier Snappy for Linux / not tested on MAC yet +base: core18 +version: '2.2.0' # 03/2019 +summary: Eliminate the barrier between your machines. +description: | + Barrier is KVM software forked from Symless's synergy 1.9 codebase. + Synergy was a commercialized reimplementation of the original + CosmoSynergy written by Chris Schoeneman. +grade: stable # must be 'stable' to release into candidate/stable channels +confinement: strict # use 'strict' once you have the right plugs and slots + +apps: + barrier-kvm: + command: desktop-launch barrier #first run might take longer + plugs: + gnome-3-26-1604: + interface: content + target: gnome-platform + default-provider: gnome-3-26-1604:gnome-3-26-1604 + plugs: [gnome-3-26-1604] + plugs: [x11] +parts: [qt5conf] +parts: + desktop: + plugin: nil + source: https://github.com/ubuntu/snapcraft-desktop-helpers.git + desktop-qt5: + source: https://github.com/ubuntu/snapcraft-desktop-helpers.git + source-subdir: qt + plugin: make + make-parameters: ["FLAVOR=qt5"] + build-packages: + - build-essential + - qtbase5-dev + - dpkg-dev + stage-packages: + - libxkbcommon0 + - ttf-ubuntu-font-family + - dmz-cursor-theme + - light-themes + - adwaita-icon-theme + - gnome-themes-standard + - shared-mime-info + - libqt5gui5 + - libgdk-pixbuf2.0-0 + - libqt5svg5 # for loading icon themes which are svg + - try: [appmenu-qt5] # not available on core18 + - locales-all + - xdg-user-dirs + - fcitx-frontend-qt5 + qt5: + source: https://github.com/ubuntu/snapcraft-desktop-helpers.git + source-subdir: qt + plugin: make + make-parameters: ["FLAVOR=qt5"] + build-packages: + - qtbase5-dev + - dpkg-dev + stage-packages: + - libxkbcommon0 + - ttf-ubuntu-font-family + - dmz-cursor-theme + - light-themes + - adwaita-icon-theme + - gnome-themes-standard + - shared-mime-info + - libqt5gui5 + - libgdk-pixbuf2.0-0 + - libqt5svg5 # for loading icon themes which are svg + - try: [appmenu-qt5] # not available on core18 + - locales-all + barrier-kvm: + source: https://github.com/payomagic/barrier.git + plugin: cmake + build-packages: + - g++ + - gcc + - make + - xorg-dev + - libcurl4-openssl-dev + - libavahi-compat-libdnssd-dev + - libssl-dev + - libx11-dev + - libqt4-dev + - qtbase5-dev + - qt5-style-plugins + - qt5ct + stage-packages: + - libxinerama-dev + - libxinerama1 + - libxrandr-dev + - libxrandr2 + - libxrender-dev + - libxrender1 + - libxtst-dev + - qtdeclarative5-dev + - libavahi-compat-libdnssd-dev + - libqt5gui5 + - libavahi-common-dev + - libqt5x11extras5 + - libqt5svg5 + - libqt5svg5-dev + - qt5ct + after: [desktop-qt5] diff --git a/src/cmd/barrierc/barrierc.exe.manifest b/src/cmd/barrierc/barrierc.exe.manifest index 7309fde..2c6f365 100644 --- a/src/cmd/barrierc/barrierc.exe.manifest +++ b/src/cmd/barrierc/barrierc.exe.manifest @@ -1,2 +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>
\ No newline at end of file +<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><dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitor</dpiAwareness><dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware></windowsSettings></application></assembly>
\ No newline at end of file diff --git a/src/gui/gui.ts b/src/gui/gui.ts index 861a496..99bc7aa 100644 --- a/src/gui/gui.ts +++ b/src/gui/gui.ts @@ -456,7 +456,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_af-ZA.qm b/src/gui/res/lang/gui_af-ZA.qm Binary files differindex be651ee..9dad8df 100644 --- a/src/gui/res/lang/gui_af-ZA.qm +++ b/src/gui/res/lang/gui_af-ZA.qm diff --git a/src/gui/res/lang/gui_af-ZA.ts b/src/gui/res/lang/gui_af-ZA.ts index 446c9a4..7ff6304 100644 --- a/src/gui/res/lang/gui_af-ZA.ts +++ b/src/gui/res/lang/gui_af-ZA.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_ar.qm b/src/gui/res/lang/gui_ar.qm Binary files differindex dfc4afa..a375ebb 100644 --- a/src/gui/res/lang/gui_ar.qm +++ b/src/gui/res/lang/gui_ar.qm diff --git a/src/gui/res/lang/gui_ar.ts b/src/gui/res/lang/gui_ar.ts index c934dba..84ae1e6 100644 --- a/src/gui/res/lang/gui_ar.ts +++ b/src/gui/res/lang/gui_ar.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_bg-BG.qm b/src/gui/res/lang/gui_bg-BG.qm Binary files differindex a93d7af..013137d 100644 --- a/src/gui/res/lang/gui_bg-BG.qm +++ b/src/gui/res/lang/gui_bg-BG.qm diff --git a/src/gui/res/lang/gui_bg-BG.ts b/src/gui/res/lang/gui_bg-BG.ts index fc6988e..6a373d8 100644 --- a/src/gui/res/lang/gui_bg-BG.ts +++ b/src/gui/res/lang/gui_bg-BG.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Приложи</translation> </message> <message> diff --git a/src/gui/res/lang/gui_ca-AD.qm b/src/gui/res/lang/gui_ca-AD.qm Binary files differindex 45e8f7f..351c40d 100644 --- a/src/gui/res/lang/gui_ca-AD.qm +++ b/src/gui/res/lang/gui_ca-AD.qm diff --git a/src/gui/res/lang/gui_ca-AD.ts b/src/gui/res/lang/gui_ca-AD.ts index 3ccc7eb..34093d9 100644 --- a/src/gui/res/lang/gui_ca-AD.ts +++ b/src/gui/res/lang/gui_ca-AD.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Aplicar</translation> </message> <message> diff --git a/src/gui/res/lang/gui_cs-CZ.qm b/src/gui/res/lang/gui_cs-CZ.qm Binary files differindex 01a1b70..1ac02c8 100644 --- a/src/gui/res/lang/gui_cs-CZ.qm +++ b/src/gui/res/lang/gui_cs-CZ.qm diff --git a/src/gui/res/lang/gui_cs-CZ.ts b/src/gui/res/lang/gui_cs-CZ.ts index fd639fa..fd7b9c7 100644 --- a/src/gui/res/lang/gui_cs-CZ.ts +++ b/src/gui/res/lang/gui_cs-CZ.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">&Použít</translation> </message> <message> diff --git a/src/gui/res/lang/gui_cy.qm b/src/gui/res/lang/gui_cy.qm Binary files differindex a62d578..87bc58c 100644 --- a/src/gui/res/lang/gui_cy.qm +++ b/src/gui/res/lang/gui_cy.qm diff --git a/src/gui/res/lang/gui_cy.ts b/src/gui/res/lang/gui_cy.ts index 15b59ea..be9cd1d 100644 --- a/src/gui/res/lang/gui_cy.ts +++ b/src/gui/res/lang/gui_cy.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_da.qm b/src/gui/res/lang/gui_da.qm Binary files differindex 280988f..f78dbb7 100644 --- a/src/gui/res/lang/gui_da.qm +++ b/src/gui/res/lang/gui_da.qm diff --git a/src/gui/res/lang/gui_da.ts b/src/gui/res/lang/gui_da.ts index d910ccb..2b17c0b 100644 --- a/src/gui/res/lang/gui_da.ts +++ b/src/gui/res/lang/gui_da.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">&Anvend</translation> </message> <message> diff --git a/src/gui/res/lang/gui_de.qm b/src/gui/res/lang/gui_de.qm Binary files differindex 095a698..eb0bb40 100644 --- a/src/gui/res/lang/gui_de.qm +++ b/src/gui/res/lang/gui_de.qm diff --git a/src/gui/res/lang/gui_de.ts b/src/gui/res/lang/gui_de.ts index 4b826f5..67eb994 100644 --- a/src/gui/res/lang/gui_de.ts +++ b/src/gui/res/lang/gui_de.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">&Anwenden</translation> </message> <message> diff --git a/src/gui/res/lang/gui_es.qm b/src/gui/res/lang/gui_es.qm Binary files differindex f9057ee..d09974e 100644 --- a/src/gui/res/lang/gui_es.qm +++ b/src/gui/res/lang/gui_es.qm diff --git a/src/gui/res/lang/gui_es.ts b/src/gui/res/lang/gui_es.ts index 98ee4f9..4b3523a 100644 --- a/src/gui/res/lang/gui_es.ts +++ b/src/gui/res/lang/gui_es.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Aplicar</translation> </message> <message> @@ -1408,4 +1408,4 @@ Server response: <translation type="unfinished"></translation> </message> </context> -</TS>
\ No newline at end of file +</TS> diff --git a/src/gui/res/lang/gui_et-EE.qm b/src/gui/res/lang/gui_et-EE.qm Binary files differindex 2ff9398..7c2fc9b 100644 --- a/src/gui/res/lang/gui_et-EE.qm +++ b/src/gui/res/lang/gui_et-EE.qm diff --git a/src/gui/res/lang/gui_et-EE.ts b/src/gui/res/lang/gui_et-EE.ts index 1e1ea57..033b9d7 100644 --- a/src/gui/res/lang/gui_et-EE.ts +++ b/src/gui/res/lang/gui_et-EE.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Rakenda</translation> </message> <message> diff --git a/src/gui/res/lang/gui_fi.qm b/src/gui/res/lang/gui_fi.qm Binary files differindex 46f69c1..1e7178c 100644 --- a/src/gui/res/lang/gui_fi.qm +++ b/src/gui/res/lang/gui_fi.qm diff --git a/src/gui/res/lang/gui_fi.ts b/src/gui/res/lang/gui_fi.ts index 9fe0b60..e5aea17 100644 --- a/src/gui/res/lang/gui_fi.ts +++ b/src/gui/res/lang/gui_fi.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Käytä</translation> </message> <message> diff --git a/src/gui/res/lang/gui_fr.qm b/src/gui/res/lang/gui_fr.qm Binary files differindex 8251f4c..38116ce 100644 --- a/src/gui/res/lang/gui_fr.qm +++ b/src/gui/res/lang/gui_fr.qm diff --git a/src/gui/res/lang/gui_fr.ts b/src/gui/res/lang/gui_fr.ts index 8d96c5b..ed37997 100644 --- a/src/gui/res/lang/gui_fr.ts +++ b/src/gui/res/lang/gui_fr.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Appliquer</translation> </message> <message> diff --git a/src/gui/res/lang/gui_gl.qm b/src/gui/res/lang/gui_gl.qm Binary files differindex 11d78e1..16faa72 100644 --- a/src/gui/res/lang/gui_gl.qm +++ b/src/gui/res/lang/gui_gl.qm diff --git a/src/gui/res/lang/gui_gl.ts b/src/gui/res/lang/gui_gl.ts index 727878f..2f89802 100644 --- a/src/gui/res/lang/gui_gl.ts +++ b/src/gui/res/lang/gui_gl.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_grk.qm b/src/gui/res/lang/gui_grk.qm Binary files differindex 9793d0d..0d921a3 100644 --- a/src/gui/res/lang/gui_grk.qm +++ b/src/gui/res/lang/gui_grk.qm diff --git a/src/gui/res/lang/gui_grk.ts b/src/gui/res/lang/gui_grk.ts index 03b71e2..ffbede5 100644 --- a/src/gui/res/lang/gui_grk.ts +++ b/src/gui/res/lang/gui_grk.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_he.qm b/src/gui/res/lang/gui_he.qm Binary files differindex 2ceeae5..43fa7af 100644 --- a/src/gui/res/lang/gui_he.qm +++ b/src/gui/res/lang/gui_he.qm diff --git a/src/gui/res/lang/gui_he.ts b/src/gui/res/lang/gui_he.ts index 192d2a1..5a1ddcf 100644 --- a/src/gui/res/lang/gui_he.ts +++ b/src/gui/res/lang/gui_he.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">&שמור שינויים</translation> </message> <message> diff --git a/src/gui/res/lang/gui_hi.ts b/src/gui/res/lang/gui_hi.ts index a6ba550..57b409e 100644 --- a/src/gui/res/lang/gui_hi.ts +++ b/src/gui/res/lang/gui_hi.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_hr-HR.qm b/src/gui/res/lang/gui_hr-HR.qm Binary files differindex 6c3bd19..a7e5563 100644 --- a/src/gui/res/lang/gui_hr-HR.qm +++ b/src/gui/res/lang/gui_hr-HR.qm diff --git a/src/gui/res/lang/gui_hr-HR.ts b/src/gui/res/lang/gui_hr-HR.ts index 89e437a..4695e4e 100644 --- a/src/gui/res/lang/gui_hr-HR.ts +++ b/src/gui/res/lang/gui_hr-HR.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">&Primijeni</translation> </message> <message> diff --git a/src/gui/res/lang/gui_hu-HU.qm b/src/gui/res/lang/gui_hu-HU.qm Binary files differindex 88499fe..10361b7 100644 --- a/src/gui/res/lang/gui_hu-HU.qm +++ b/src/gui/res/lang/gui_hu-HU.qm diff --git a/src/gui/res/lang/gui_hu-HU.ts b/src/gui/res/lang/gui_hu-HU.ts index 524c013..7c26d46 100644 --- a/src/gui/res/lang/gui_hu-HU.ts +++ b/src/gui/res/lang/gui_hu-HU.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Alkalmaz</translation> </message> <message> diff --git a/src/gui/res/lang/gui_id.qm b/src/gui/res/lang/gui_id.qm Binary files differindex 2394cf7..74f4117 100644 --- a/src/gui/res/lang/gui_id.qm +++ b/src/gui/res/lang/gui_id.qm diff --git a/src/gui/res/lang/gui_id.ts b/src/gui/res/lang/gui_id.ts index fc2cd9e..ed52252 100644 --- a/src/gui/res/lang/gui_id.ts +++ b/src/gui/res/lang/gui_id.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_is-IS.qm b/src/gui/res/lang/gui_is-IS.qm Binary files differindex be651ee..0126ff8 100644 --- a/src/gui/res/lang/gui_is-IS.qm +++ b/src/gui/res/lang/gui_is-IS.qm diff --git a/src/gui/res/lang/gui_is-IS.ts b/src/gui/res/lang/gui_is-IS.ts index a4c0aa7..2764171 100644 --- a/src/gui/res/lang/gui_is-IS.ts +++ b/src/gui/res/lang/gui_is-IS.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_it.qm b/src/gui/res/lang/gui_it.qm Binary files differindex 6153507..bc8dc7e 100644 --- a/src/gui/res/lang/gui_it.qm +++ b/src/gui/res/lang/gui_it.qm diff --git a/src/gui/res/lang/gui_it.ts b/src/gui/res/lang/gui_it.ts index a802e28..c1096dd 100644 --- a/src/gui/res/lang/gui_it.ts +++ b/src/gui/res/lang/gui_it.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Applica</translation> </message> <message> diff --git a/src/gui/res/lang/gui_ja-JP.qm b/src/gui/res/lang/gui_ja-JP.qm Binary files differindex 6310eae..90ff995 100644 --- a/src/gui/res/lang/gui_ja-JP.qm +++ b/src/gui/res/lang/gui_ja-JP.qm diff --git a/src/gui/res/lang/gui_ja-JP.ts b/src/gui/res/lang/gui_ja-JP.ts index c4c0e9e..e7ff5bd 100644 --- a/src/gui/res/lang/gui_ja-JP.ts +++ b/src/gui/res/lang/gui_ja-JP.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">適用</translation> </message> <message> diff --git a/src/gui/res/lang/gui_ko.qm b/src/gui/res/lang/gui_ko.qm Binary files differindex d29f456..06612cb 100644 --- a/src/gui/res/lang/gui_ko.qm +++ b/src/gui/res/lang/gui_ko.qm diff --git a/src/gui/res/lang/gui_ko.ts b/src/gui/res/lang/gui_ko.ts index fee6276..8c477fc 100644 --- a/src/gui/res/lang/gui_ko.ts +++ b/src/gui/res/lang/gui_ko.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">적용(&A)</translation> </message> <message> diff --git a/src/gui/res/lang/gui_lt.qm b/src/gui/res/lang/gui_lt.qm Binary files differindex 10a7a05..1aa40d9 100644 --- a/src/gui/res/lang/gui_lt.qm +++ b/src/gui/res/lang/gui_lt.qm diff --git a/src/gui/res/lang/gui_lt.ts b/src/gui/res/lang/gui_lt.ts index 45713fb..66976b1 100644 --- a/src/gui/res/lang/gui_lt.ts +++ b/src/gui/res/lang/gui_lt.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_lv.qm b/src/gui/res/lang/gui_lv.qm Binary files differindex 908d8c4..655b16b 100644 --- a/src/gui/res/lang/gui_lv.qm +++ b/src/gui/res/lang/gui_lv.qm diff --git a/src/gui/res/lang/gui_lv.ts b/src/gui/res/lang/gui_lv.ts index e53cf7d..27b74f0 100644 --- a/src/gui/res/lang/gui_lv.ts +++ b/src/gui/res/lang/gui_lv.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_mr.qm b/src/gui/res/lang/gui_mr.qm Binary files differindex 6b0c47d..f6d5de8 100644 --- a/src/gui/res/lang/gui_mr.qm +++ b/src/gui/res/lang/gui_mr.qm diff --git a/src/gui/res/lang/gui_mr.ts b/src/gui/res/lang/gui_mr.ts index 028005d..b91bd19 100644 --- a/src/gui/res/lang/gui_mr.ts +++ b/src/gui/res/lang/gui_mr.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_nl-NL.qm b/src/gui/res/lang/gui_nl-NL.qm Binary files differindex b467c66..102cec8 100644 --- a/src/gui/res/lang/gui_nl-NL.qm +++ b/src/gui/res/lang/gui_nl-NL.qm diff --git a/src/gui/res/lang/gui_nl-NL.ts b/src/gui/res/lang/gui_nl-NL.ts index 2eabfbb..5c5b490 100644 --- a/src/gui/res/lang/gui_nl-NL.ts +++ b/src/gui/res/lang/gui_nl-NL.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Toep&assen</translation> </message> <message> diff --git a/src/gui/res/lang/gui_no.qm b/src/gui/res/lang/gui_no.qm Binary files differindex 6ebf434..903ae48 100644 --- a/src/gui/res/lang/gui_no.qm +++ b/src/gui/res/lang/gui_no.qm diff --git a/src/gui/res/lang/gui_no.ts b/src/gui/res/lang/gui_no.ts index 42d5b95..d27a620 100644 --- a/src/gui/res/lang/gui_no.ts +++ b/src/gui/res/lang/gui_no.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">&Bruk</translation> </message> <message> diff --git a/src/gui/res/lang/gui_pes-IR.ts b/src/gui/res/lang/gui_pes-IR.ts index d4a0f91..31d7a67 100644 --- a/src/gui/res/lang/gui_pes-IR.ts +++ b/src/gui/res/lang/gui_pes-IR.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_pl-PL.qm b/src/gui/res/lang/gui_pl-PL.qm Binary files differindex 4b024ad..83e7352 100644 --- a/src/gui/res/lang/gui_pl-PL.qm +++ b/src/gui/res/lang/gui_pl-PL.qm diff --git a/src/gui/res/lang/gui_pl-PL.ts b/src/gui/res/lang/gui_pl-PL.ts index 9fef7f3..6fb96a0 100644 --- a/src/gui/res/lang/gui_pl-PL.ts +++ b/src/gui/res/lang/gui_pl-PL.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">&Zastosuj</translation> </message> <message> diff --git a/src/gui/res/lang/gui_pt-BR.qm b/src/gui/res/lang/gui_pt-BR.qm Binary files differindex d335d9e..1deecfd 100644 --- a/src/gui/res/lang/gui_pt-BR.qm +++ b/src/gui/res/lang/gui_pt-BR.qm diff --git a/src/gui/res/lang/gui_pt-BR.ts b/src/gui/res/lang/gui_pt-BR.ts index 802551b..6245bca 100644 --- a/src/gui/res/lang/gui_pt-BR.ts +++ b/src/gui/res/lang/gui_pt-BR.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Aplicar</translation> </message> <message> diff --git a/src/gui/res/lang/gui_pt-PT.qm b/src/gui/res/lang/gui_pt-PT.qm Binary files differindex cda99e1..987d8ab 100644 --- a/src/gui/res/lang/gui_pt-PT.qm +++ b/src/gui/res/lang/gui_pt-PT.qm diff --git a/src/gui/res/lang/gui_pt-PT.ts b/src/gui/res/lang/gui_pt-PT.ts index 45a20a8..03fc40d 100644 --- a/src/gui/res/lang/gui_pt-PT.ts +++ b/src/gui/res/lang/gui_pt-PT.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">&Aplicar</translation> </message> <message> diff --git a/src/gui/res/lang/gui_ro.qm b/src/gui/res/lang/gui_ro.qm Binary files differindex 3e71663..6d1fdd2 100644 --- a/src/gui/res/lang/gui_ro.qm +++ b/src/gui/res/lang/gui_ro.qm diff --git a/src/gui/res/lang/gui_ro.ts b/src/gui/res/lang/gui_ro.ts index e79e83b..f82d128 100644 --- a/src/gui/res/lang/gui_ro.ts +++ b/src/gui/res/lang/gui_ro.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Aplică</translation> </message> <message> diff --git a/src/gui/res/lang/gui_ru.qm b/src/gui/res/lang/gui_ru.qm Binary files differindex 8ab5f1a..30ed0a7 100644 --- a/src/gui/res/lang/gui_ru.qm +++ b/src/gui/res/lang/gui_ru.qm diff --git a/src/gui/res/lang/gui_ru.ts b/src/gui/res/lang/gui_ru.ts index 08cc4cb..411272f 100644 --- a/src/gui/res/lang/gui_ru.ts +++ b/src/gui/res/lang/gui_ru.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">&Применить</translation> </message> <message> diff --git a/src/gui/res/lang/gui_si.qm b/src/gui/res/lang/gui_si.qm Binary files differindex 17ba794..f5c8824 100644 --- a/src/gui/res/lang/gui_si.qm +++ b/src/gui/res/lang/gui_si.qm diff --git a/src/gui/res/lang/gui_si.ts b/src/gui/res/lang/gui_si.ts index cb56677..33597e9 100644 --- a/src/gui/res/lang/gui_si.ts +++ b/src/gui/res/lang/gui_si.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_sk-SK.qm b/src/gui/res/lang/gui_sk-SK.qm Binary files differindex b2abe68..acdf4f6 100644 --- a/src/gui/res/lang/gui_sk-SK.qm +++ b/src/gui/res/lang/gui_sk-SK.qm diff --git a/src/gui/res/lang/gui_sk-SK.ts b/src/gui/res/lang/gui_sk-SK.ts index aac1379..3e63795 100644 --- a/src/gui/res/lang/gui_sk-SK.ts +++ b/src/gui/res/lang/gui_sk-SK.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_sl-SI.qm b/src/gui/res/lang/gui_sl-SI.qm Binary files differindex 4c5ae79..29919fa 100644 --- a/src/gui/res/lang/gui_sl-SI.qm +++ b/src/gui/res/lang/gui_sl-SI.qm diff --git a/src/gui/res/lang/gui_sl-SI.ts b/src/gui/res/lang/gui_sl-SI.ts index 2d4a49d..5aa6cde 100644 --- a/src/gui/res/lang/gui_sl-SI.ts +++ b/src/gui/res/lang/gui_sl-SI.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_sq-AL.qm b/src/gui/res/lang/gui_sq-AL.qm Binary files differindex 2de4bb7..c80f8ab 100644 --- a/src/gui/res/lang/gui_sq-AL.qm +++ b/src/gui/res/lang/gui_sq-AL.qm diff --git a/src/gui/res/lang/gui_sq-AL.ts b/src/gui/res/lang/gui_sq-AL.ts index 980b795..1fcd217 100644 --- a/src/gui/res/lang/gui_sq-AL.ts +++ b/src/gui/res/lang/gui_sq-AL.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">&Apliko</translation> </message> <message> diff --git a/src/gui/res/lang/gui_sr.ts b/src/gui/res/lang/gui_sr.ts index f245475..4ae87d8 100644 --- a/src/gui/res/lang/gui_sr.ts +++ b/src/gui/res/lang/gui_sr.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_sv.qm b/src/gui/res/lang/gui_sv.qm Binary files differindex c5fb93b..f014cfd 100644 --- a/src/gui/res/lang/gui_sv.qm +++ b/src/gui/res/lang/gui_sv.qm diff --git a/src/gui/res/lang/gui_sv.ts b/src/gui/res/lang/gui_sv.ts index 8494970..6a8420e 100644 --- a/src/gui/res/lang/gui_sv.ts +++ b/src/gui/res/lang/gui_sv.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Verkställ</translation> </message> <message> diff --git a/src/gui/res/lang/gui_th-TH.qm b/src/gui/res/lang/gui_th-TH.qm Binary files differindex 3762d16..77a70dc 100644 --- a/src/gui/res/lang/gui_th-TH.qm +++ b/src/gui/res/lang/gui_th-TH.qm diff --git a/src/gui/res/lang/gui_th-TH.ts b/src/gui/res/lang/gui_th-TH.ts index 878a4e3..07c74b8 100644 --- a/src/gui/res/lang/gui_th-TH.ts +++ b/src/gui/res/lang/gui_th-TH.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_tr-TR.qm b/src/gui/res/lang/gui_tr-TR.qm Binary files differindex 55ef0f8..14b3df6 100644 --- a/src/gui/res/lang/gui_tr-TR.qm +++ b/src/gui/res/lang/gui_tr-TR.qm diff --git a/src/gui/res/lang/gui_tr-TR.ts b/src/gui/res/lang/gui_tr-TR.ts index d35de14..01a681b 100644 --- a/src/gui/res/lang/gui_tr-TR.ts +++ b/src/gui/res/lang/gui_tr-TR.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Uygula</translation> </message> <message> diff --git a/src/gui/res/lang/gui_uk.qm b/src/gui/res/lang/gui_uk.qm Binary files differindex 275a454..3e9c9c5 100644 --- a/src/gui/res/lang/gui_uk.qm +++ b/src/gui/res/lang/gui_uk.qm diff --git a/src/gui/res/lang/gui_uk.ts b/src/gui/res/lang/gui_uk.ts index 68cac01..1f2dffe 100644 --- a/src/gui/res/lang/gui_uk.ts +++ b/src/gui/res/lang/gui_uk.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">Застосувати</translation> </message> <message> diff --git a/src/gui/res/lang/gui_ur.qm b/src/gui/res/lang/gui_ur.qm Binary files differindex c546613..0b364dd 100644 --- a/src/gui/res/lang/gui_ur.qm +++ b/src/gui/res/lang/gui_ur.qm diff --git a/src/gui/res/lang/gui_ur.ts b/src/gui/res/lang/gui_ur.ts index 2dbd1ea..9b36dcf 100644 --- a/src/gui/res/lang/gui_ur.ts +++ b/src/gui/res/lang/gui_ur.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_vi.qm b/src/gui/res/lang/gui_vi.qm Binary files differindex 12ce570..879b157 100644 --- a/src/gui/res/lang/gui_vi.qm +++ b/src/gui/res/lang/gui_vi.qm diff --git a/src/gui/res/lang/gui_vi.ts b/src/gui/res/lang/gui_vi.ts index e4031c5..a3c6025 100644 --- a/src/gui/res/lang/gui_vi.ts +++ b/src/gui/res/lang/gui_vi.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/gui/res/lang/gui_zh-CN.qm b/src/gui/res/lang/gui_zh-CN.qm Binary files differindex ab5415e..f11d0b5 100644 --- a/src/gui/res/lang/gui_zh-CN.qm +++ b/src/gui/res/lang/gui_zh-CN.qm diff --git a/src/gui/res/lang/gui_zh-CN.ts b/src/gui/res/lang/gui_zh-CN.ts index b5cdf6c..0c8522a 100644 --- a/src/gui/res/lang/gui_zh-CN.ts +++ b/src/gui/res/lang/gui_zh-CN.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">应用</translation> </message> <message> diff --git a/src/gui/res/lang/gui_zh-TW.qm b/src/gui/res/lang/gui_zh-TW.qm Binary files differindex 92e5e3a..5cc8653 100644 --- a/src/gui/res/lang/gui_zh-TW.qm +++ b/src/gui/res/lang/gui_zh-TW.qm diff --git a/src/gui/res/lang/gui_zh-TW.ts b/src/gui/res/lang/gui_zh-TW.ts index fc55f56..902a444 100644 --- a/src/gui/res/lang/gui_zh-TW.ts +++ b/src/gui/res/lang/gui_zh-TW.ts @@ -454,7 +454,7 @@ To automatically trust this fingerprint for future connections, click Yes. To re </message> <message> <location filename="res/MainWindowBase.ui" line="373"/> - <source>&Apply</source> + <source>&Reload</source> <translation type="finished">應用</translation> </message> <message> diff --git a/src/gui/src/BaseConfig.cpp b/src/gui/src/BaseConfig.cpp index 36fe430..241f590 100644 --- a/src/gui/src/BaseConfig.cpp +++ b/src/gui/src/BaseConfig.cpp @@ -33,7 +33,8 @@ const char* BaseConfig::m_FixNames[] = "halfDuplexCapsLock", "halfDuplexNumLock", "halfDuplexScrollLock", - "xtestIsXineramaUnaware" + "xtestIsXineramaUnaware", + "preserveFocus" }; const char* BaseConfig::m_SwitchCornerNames[] = diff --git a/src/gui/src/BaseConfig.h b/src/gui/src/BaseConfig.h index f1769bb..2a34969 100644 --- a/src/gui/src/BaseConfig.h +++ b/src/gui/src/BaseConfig.h @@ -29,7 +29,7 @@ class BaseConfig public: enum Modifier { DefaultMod = -1, Shift, Ctrl, Alt, Meta, Super, None, NumModifiers }; enum SwitchCorner { TopLeft, TopRight, BottomLeft, BottomRight, NumSwitchCorners }; - enum Fix { CapsLock, NumLock, ScrollLock, XTest, NumFixes }; + enum Fix { CapsLock, NumLock, ScrollLock, XTest, PreserveFocus, NumFixes }; protected: BaseConfig() {} diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 6829c22..bcbb15b 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -763,14 +763,14 @@ void MainWindow::setBarrierState(qBarrierState state) disconnect (m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartBarrier, SLOT(trigger())); connect (m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStopBarrier, SLOT(trigger())); m_pButtonToggleStart->setText(tr("&Stop")); - m_pButtonApply->setEnabled(true); + m_pButtonReload->setEnabled(true); } else if (state == barrierDisconnected) { disconnect (m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStopBarrier, SLOT(trigger())); connect (m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartBarrier, SLOT(trigger())); m_pButtonToggleStart->setText(tr("&Start")); - m_pButtonApply->setEnabled(false); + m_pButtonReload->setEnabled(false); } bool connected = false; @@ -1040,7 +1040,7 @@ void MainWindow::on_m_pButtonConfigureServer_clicked() showConfigureServer(); } -void MainWindow::on_m_pButtonApply_clicked() +void MainWindow::on_m_pButtonReload_clicked() { restartBarrier(); } diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index 5bb2895..c115b91 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -205,7 +205,7 @@ public slots: private slots: void on_m_pCheckBoxAutoConfig_toggled(bool checked); void on_m_pComboServerList_currentIndexChanged(QString ); - void on_m_pButtonApply_clicked(); + void on_m_pButtonReload_clicked(); void installBonjour(); }; diff --git a/src/gui/src/MainWindowBase.ui b/src/gui/src/MainWindowBase.ui index d1b0b37..117405c 100644 --- a/src/gui/src/MainWindowBase.ui +++ b/src/gui/src/MainWindowBase.ui @@ -278,12 +278,12 @@ </spacer> </item> <item> - <widget class="QPushButton" name="m_pButtonApply"> + <widget class="QPushButton" name="m_pButtonReload"> <property name="enabled"> <bool>false</bool> </property> <property name="text"> - <string>&Apply</string> + <string>&Reload</string> </property> </widget> </item> diff --git a/src/gui/src/ScreenSettingsDialog.cpp b/src/gui/src/ScreenSettingsDialog.cpp index 4f294e2..3023b6d 100644 --- a/src/gui/src/ScreenSettingsDialog.cpp +++ b/src/gui/src/ScreenSettingsDialog.cpp @@ -68,6 +68,7 @@ ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen) : m_pCheckBoxNumLock->setChecked(m_pScreen->fix(Screen::NumLock)); m_pCheckBoxScrollLock->setChecked(m_pScreen->fix(Screen::ScrollLock)); m_pCheckBoxXTest->setChecked(m_pScreen->fix(Screen::XTest)); + m_pCheckBoxPreserveFocus->setChecked(m_pScreen->fix(Screen::PreserveFocus)); } void ScreenSettingsDialog::accept() @@ -115,6 +116,7 @@ void ScreenSettingsDialog::accept() m_pScreen->setFix(Screen::NumLock, m_pCheckBoxNumLock->isChecked()); m_pScreen->setFix(Screen::ScrollLock, m_pCheckBoxScrollLock->isChecked()); m_pScreen->setFix(Screen::XTest, m_pCheckBoxXTest->isChecked()); + m_pScreen->setFix(Screen::PreserveFocus, m_pCheckBoxPreserveFocus->isChecked()); QDialog::accept(); } diff --git a/src/gui/src/ScreenSettingsDialogBase.ui b/src/gui/src/ScreenSettingsDialogBase.ui index 0d6d768..992919d 100644 --- a/src/gui/src/ScreenSettingsDialogBase.ui +++ b/src/gui/src/ScreenSettingsDialogBase.ui @@ -462,7 +462,17 @@ </property> </widget> </item> - <item row="4" column="0"> + <item row="4" column="0"> + <widget class="QCheckBox" name="m_pCheckBoxPreserveFocus"> + <property name="text"> + <string>Fix Preserve Focus</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="5" column="0"> <spacer> <property name="orientation"> <enum>Qt::Vertical</enum> diff --git a/src/gui/src/ServerConfig.cpp b/src/gui/src/ServerConfig.cpp index 6c19c0e..d7d1a77 100644 --- a/src/gui/src/ServerConfig.cpp +++ b/src/gui/src/ServerConfig.cpp @@ -117,6 +117,7 @@ void ServerConfig::saveSettings() settings().setValue("switchCornerSize", switchCornerSize()); settings().setValue("ignoreAutoConfigClient", ignoreAutoConfigClient()); settings().setValue("enableDragAndDrop", enableDragAndDrop()); + settings().setValue("clipboardSharing", clipboardSharing()); writeSettings(settings(), switchCorners(), "switchCorner"); @@ -161,6 +162,7 @@ void ServerConfig::loadSettings() setSwitchCornerSize(settings().value("switchCornerSize").toInt()); setIgnoreAutoConfigClient(settings().value("ignoreAutoConfigClient").toBool()); setEnableDragAndDrop(settings().value("enableDragAndDrop", true).toBool()); + setClipboardSharing(settings().value("clipboardSharing", true).toBool()); readSettings(settings(), switchCorners(), "switchCorner", false, NumSwitchCorners); diff --git a/src/gui/src/main.cpp b/src/gui/src/main.cpp index 76a7d1a..73251d5 100644 --- a/src/gui/src/main.cpp +++ b/src/gui/src/main.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define TRAY_RETRY_COUNT 10 +#define TRAY_RETRY_COUNT 5 #define TRAY_RETRY_WAIT 2000 #include "QBarrierApplication.h" @@ -74,8 +74,13 @@ int main(int argc, char* argv[]) QBarrierApplication app(argc, argv); #if defined(Q_OS_MAC) - if (app.applicationDirPath().startsWith("/Volumes/")) { + // macOS preferences track applications allowed assistive access by path + // Unfortunately, there's no user-friendly way to allow assistive access + // to applications that are not in default paths (/Applications), + // especially if an identically named application already exists in + // /Applications). Thus we require Barrier to reside in the /Applications + // folder QMessageBox::information( NULL, "Barrier", "Please drag Barrier to the Applications folder, and open it from there."); @@ -88,16 +93,20 @@ int main(int argc, char* argv[]) } #endif - if (!waitForTray()) - { - return -1; - } + int trayAvailable = waitForTray(); QApplication::setQuitOnLastWindowClosed(false); QSettings settings; AppConfig appConfig (&settings); + if (appConfig.getAutoHide() && !trayAvailable) + { + // force auto hide to false - otherwise there is no way to get the GUI back + fprintf(stdout, "System tray not available, force disabling auto hide!\n"); + appConfig.setAutoHide(false); + } + app.switchTranslator(appConfig.language()); MainWindow mainWindow(settings, appConfig); @@ -129,9 +138,8 @@ int waitForTray() if (++trayAttempts > TRAY_RETRY_COUNT) { - QMessageBox::critical(NULL, "Barrier", - QObject::tr("System tray is unavailable, don't close your window.")); - return true; + fprintf(stdout, "System tray is unavailable.\n"); + return false; } QThreadImpl::msleep(TRAY_RETRY_WAIT); diff --git a/src/lib/barrier/ArgParser.cpp b/src/lib/barrier/ArgParser.cpp index b20b33f..ec3991c 100644 --- a/src/lib/barrier/ArgParser.cpp +++ b/src/lib/barrier/ArgParser.cpp @@ -29,7 +29,7 @@ #ifdef WINAPI_MSWINDOWS #include <VersionHelpers.h> #endif - + ArgsBase* ArgParser::m_argsBase = NULL; ArgParser::ArgParser(App* app) : @@ -61,6 +61,10 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv) // save configuration file path args.m_configFile = argv[++i]; } + else if (isArg(i, argc, argv, NULL, "--screen-change-script", 1)) { + // save screen change script path + args.m_screenChangeScript = argv[++i]; + } else { LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_exename.c_str(), argv[i], args.m_exename.c_str())); return false; diff --git a/src/lib/barrier/ClientApp.cpp b/src/lib/barrier/ClientApp.cpp index 17de18e..15416f6 100644 --- a/src/lib/barrier/ClientApp.cpp +++ b/src/lib/barrier/ClientApp.cpp @@ -167,6 +167,7 @@ ClientApp::createScreen() false, args().m_noHooks, args().m_stopOnDeskSwitch, m_events), m_events); #elif WINAPI_XWINDOWS return new barrier::Screen(new XWindowsScreen( + new XWindowsImpl(), args().m_display, false, args().m_disableXInitThreads, args().m_yscroll, m_events), m_events); #elif WINAPI_CARBON diff --git a/src/lib/barrier/ServerApp.cpp b/src/lib/barrier/ServerApp.cpp index ff98cc1..fbb5092 100644 --- a/src/lib/barrier/ServerApp.cpp +++ b/src/lib/barrier/ServerApp.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman - * + * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. - * + * * This package is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -49,6 +49,8 @@ #if WINAPI_MSWINDOWS #include "platform/MSWindowsScreen.h" #elif WINAPI_XWINDOWS +#include <unistd.h> +#include <signal.h> #include "platform/XWindowsScreen.h" #elif WINAPI_CARBON #include "platform/OSXScreen.h" @@ -95,7 +97,7 @@ ServerApp::parseArgs(int argc, const char* const* argv) else { if (!args().m_barrierAddress.empty()) { try { - *m_barrierAddress = NetworkAddress(args().m_barrierAddress, + *m_barrierAddress = NetworkAddress(args().m_barrierAddress, kDefaultPort); m_barrierAddress->resolve(); } @@ -117,7 +119,10 @@ ServerApp::help() " [--display <display>] [--no-xinitthreads]" # define WINAPI_INFO \ " --display <display> connect to the X server at <display>\n" \ - " --no-xinitthreads do not call XInitThreads()\n" + " --no-xinitthreads do not call XInitThreads()\n" \ + " --screen-change-script <path>\n" \ + " full path to script to run on screen change\n" \ + " first argument is the new screen name\n" #else # define WINAPI_ARGS "" # define WINAPI_INFO "" @@ -240,7 +245,7 @@ ServerApp::loadConfig(const String& pathname) return false; } -void +void ServerApp::forceReconnect(const Event&, void*) { if (m_server != NULL) { @@ -248,7 +253,7 @@ ServerApp::forceReconnect(const Event&, void*) } } -void +void ServerApp::handleClientConnected(const Event&, void* vlistener) { ClientListener* listener = static_cast<ClientListener*>(vlistener); @@ -282,7 +287,7 @@ ServerApp::closeServer(Server* server) new TMethodEventJob<ServerApp>(this, &ServerApp::handleClientsDisconnected)); m_events->adoptHandler(m_events->forServer().disconnected(), server, new TMethodEventJob<ServerApp>(this, &ServerApp::handleClientsDisconnected)); - + m_events->loop(); m_events->removeHandler(Event::kTimer, timer); @@ -293,7 +298,7 @@ ServerApp::closeServer(Server* server) delete server; } -void +void ServerApp::stopRetryTimer() { if (m_timer != NULL) { @@ -317,7 +322,7 @@ void ServerApp::updateStatus(const String& msg) } } -void +void ServerApp::closeClientListener(ClientListener* listen) { if (listen != NULL) { @@ -326,7 +331,7 @@ ServerApp::closeClientListener(ClientListener* listen) } } -void +void ServerApp::stopServer() { if (m_serverState == kStarted) { @@ -350,7 +355,7 @@ ServerApp::closePrimaryClient(PrimaryClient* primaryClient) delete primaryClient; } -void +void ServerApp::closeServerScreen(barrier::Screen* screen) { if (screen != NULL) { @@ -517,7 +522,7 @@ static const char* const family_string(IArchNetwork::EAddressFamily family) return "Unknown"; } -bool +bool ServerApp::startServer() { // skip if already started or starting @@ -582,7 +587,7 @@ ServerApp::startServer() } } -barrier::Screen* +barrier::Screen* ServerApp::createScreen() { #if WINAPI_MSWINDOWS @@ -590,13 +595,14 @@ ServerApp::createScreen() true, args().m_noHooks, args().m_stopOnDeskSwitch, m_events), m_events); #elif WINAPI_XWINDOWS return new barrier::Screen(new XWindowsScreen( + new XWindowsImpl(), args().m_display, true, args().m_disableXInitThreads, 0, m_events), m_events); #elif WINAPI_CARBON return new barrier::Screen(new OSXScreen(m_events, true), m_events); #endif } -PrimaryClient* +PrimaryClient* ServerApp::openPrimaryClient(const String& name, barrier::Screen* screen) { LOG((CLOG_DEBUG1 "creating primary screen")); @@ -611,7 +617,7 @@ ServerApp::handleScreenError(const Event&, void*) m_events->addEvent(Event(Event::kQuit)); } -void +void ServerApp::handleSuspend(const Event&, void*) { if (!m_suspended) { @@ -621,7 +627,7 @@ ServerApp::handleSuspend(const Event&, void*) } } -void +void ServerApp::handleResume(const Event&, void*) { if (m_suspended) { @@ -639,16 +645,16 @@ ServerApp::openClientListener(const NetworkAddress& address) new TCPSocketFactory(m_events, getSocketMultiplexer()), m_events, args().m_enableCrypto); - + m_events->adoptHandler( m_events->forClientListener().connected(), listen, new TMethodEventJob<ServerApp>( this, &ServerApp::handleClientConnected, listen)); - + return listen; } -Server* +Server* ServerApp::openServer(Config& config, PrimaryClient* primaryClient) { Server* server = new Server(config, primaryClient, m_serverScreen, m_events, args()); @@ -678,6 +684,28 @@ ServerApp::handleNoClients(const Event&, void*) void ServerApp::handleScreenSwitched(const Event& e, void*) { + Server::SwitchToScreenInfo* info = (Server::SwitchToScreenInfo*)(e.getData()); + + #ifdef WINAPI_XWINDOWS + if (!args().m_screenChangeScript.empty()) { + LOG((CLOG_INFO "Running shell script for screen \"%s\"", info->m_screen)); + + signal(SIGCHLD, SIG_IGN); + + if (!access(args().m_screenChangeScript.c_str(), X_OK)) { + pid_t pid = fork(); + if (pid == 0) { + execl(args().m_screenChangeScript.c_str(),args().m_screenChangeScript.c_str(),info->m_screen,NULL); + exit(0); + } else if (pid < 0) { + LOG((CLOG_ERR "Script forking error")); + exit(1); + } + } else { + LOG((CLOG_ERR "Script not accessible \"%s\"", args().m_screenChangeScript.c_str())); + } + } + #endif } int @@ -713,7 +741,7 @@ ServerApp::mainLoop() // start server, etc appUtil().startNode(); - + // init ipc client after node start, since create a new screen wipes out // the event queue (the screen ctors call adoptBuffer). if (argsBase().m_enableIpc) { @@ -742,24 +770,24 @@ ServerApp::mainLoop() // later. the timer installed by startServer() will take care of // that. DAEMON_RUNNING(true); - + #if defined(MAC_OS_X_VERSION_10_7) - + Thread thread( new TMethodJob<ServerApp>( this, &ServerApp::runEventsLoop, NULL)); - + // wait until carbon loop is ready OSXScreen* screen = dynamic_cast<OSXScreen*>( m_serverScreen->getPlatformScreen()); screen->waitForCarbonLoop(); - + runCocoaApp(); #else m_events->loop(); #endif - + DAEMON_RUNNING(false); // close down @@ -787,7 +815,7 @@ void ServerApp::resetServer(const Event&, void*) startServer(); } -int +int ServerApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc startup) { // general initialization @@ -818,7 +846,7 @@ int daemonMainLoopStatic(int argc, const char** argv) { return ServerApp::instance().daemonMainLoop(argc, argv); } -int +int ServerApp::standardStartup(int argc, char** argv) { initApp(argc, argv); @@ -832,7 +860,7 @@ ServerApp::standardStartup(int argc, char** argv) } } -int +int ServerApp::foregroundStartup(int argc, char** argv) { initApp(argc, argv); @@ -841,7 +869,7 @@ ServerApp::foregroundStartup(int argc, char** argv) return mainLoop(); } -const char* +const char* ServerApp::daemonName() const { #if SYSAPI_WIN32 @@ -851,7 +879,7 @@ ServerApp::daemonName() const #endif } -const char* +const char* ServerApp::daemonInfo() const { #if SYSAPI_WIN32 diff --git a/src/lib/barrier/ServerArgs.cpp b/src/lib/barrier/ServerArgs.cpp index 49832f2..98b9d04 100644 --- a/src/lib/barrier/ServerArgs.cpp +++ b/src/lib/barrier/ServerArgs.cpp @@ -1,11 +1,11 @@ /* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2014-2016 Symless Ltd. - * + * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. - * + * * This package is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -19,7 +19,8 @@ ServerArgs::ServerArgs() : m_configFile(), - m_config(NULL) + m_config(NULL), + m_screenChangeScript() { } diff --git a/src/lib/barrier/ServerArgs.h b/src/lib/barrier/ServerArgs.h index 9c6e568..6d91233 100644 --- a/src/lib/barrier/ServerArgs.h +++ b/src/lib/barrier/ServerArgs.h @@ -29,4 +29,5 @@ public: public: String m_configFile; Config* m_config; + String m_screenChangeScript; }; diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp index 6670f5f..360db31 100644 --- a/src/lib/net/SecureSocket.cpp +++ b/src/lib/net/SecureSocket.cpp @@ -704,18 +704,30 @@ SecureSocket::verifyCertFingerprint() kFingerprintDirName, kFingerprintTrustedServersFilename); + // Provide debug hint as to what file is being used to verify fingerprint trust + LOG((CLOG_NOTE "trustedServersFilename: %s", trustedServersFilename.c_str() )); + // check if this fingerprint exist String fileLine; std::ifstream file; file.open(trustedServersFilename.c_str()); + if (!file.is_open()) { + LOG((CLOG_NOTE "Unable to open trustedServersFile: %s", trustedServersFilename.c_str() )); + } else { + LOG((CLOG_NOTE "Opened trustedServersFilename: %s", trustedServersFilename.c_str() )); + } + bool isValid = false; while (!file.eof() && file.is_open()) { getline(file,fileLine); if (!fileLine.empty()) { if (fileLine.compare(fingerprint) == 0) { + LOG((CLOG_NOTE "Fingerprint matches trusted fingerprint")); isValid = true; break; + } else { + LOG((CLOG_NOTE "Fingerprint does not match trusted fingerprint")); } } } diff --git a/src/lib/net/TCPSocket.cpp b/src/lib/net/TCPSocket.cpp index dce81ee..d454aa1 100644 --- a/src/lib/net/TCPSocket.cpp +++ b/src/lib/net/TCPSocket.cpp @@ -544,10 +544,11 @@ TCPSocket::serviceConnected(ISocketMultiplexerJob* job, return newJob(); } - EJobResult result = kRetry; + EJobResult writeResult = kRetry; + EJobResult readResult = kRetry; if (write) { try { - result = doWrite(); + writeResult = doWrite(); } catch (XArchNetworkShutdown&) { // remote read end of stream hungup. our output side @@ -558,13 +559,13 @@ TCPSocket::serviceConnected(ISocketMultiplexerJob* job, sendEvent(m_events->forISocket().disconnected()); m_connected = false; } - result = kNew; + writeResult = kNew; } catch (XArchNetworkDisconnected&) { // stream hungup onDisconnected(); sendEvent(m_events->forISocket().disconnected()); - result = kNew; + writeResult = kNew; } catch (XArchNetwork& e) { // other write error @@ -572,19 +573,19 @@ TCPSocket::serviceConnected(ISocketMultiplexerJob* job, onDisconnected(); sendEvent(m_events->forIStream().outputError()); sendEvent(m_events->forISocket().disconnected()); - result = kNew; + writeResult = kNew; } } if (read && m_readable) { try { - result = doRead(); + readResult = doRead(); } catch (XArchNetworkDisconnected&) { // stream hungup sendEvent(m_events->forISocket().disconnected()); onDisconnected(); - result = kNew; + readResult = kNew; } catch (XArchNetwork& e) { // ignore other read error @@ -592,5 +593,11 @@ TCPSocket::serviceConnected(ISocketMultiplexerJob* job, } } - return result == kBreak ? NULL : result == kNew ? newJob() : job; + if (writeResult == kBreak || readResult == kBreak) { + return NULL; + } else if (writeResult == kNew || readResult == kNew) { + return newJob(); + } else { + return job; + } } diff --git a/src/lib/platform/IXWindowsImpl.h b/src/lib/platform/IXWindowsImpl.h new file mode 100644 index 0000000..ddcaf2f --- /dev/null +++ b/src/lib/platform/IXWindowsImpl.h @@ -0,0 +1,234 @@ + +#pragma once + +#include "config.h" + +#if X_DISPLAY_MISSING +# error X11 is required to build barrier +#else +# include <X11/X.h> +# include <X11/Xutil.h> +# define XK_MISCELLANY +# define XK_XKB_KEYS +# include <X11/keysymdef.h> +# if HAVE_X11_EXTENSIONS_DPMS_H + extern "C" { +# include <X11/extensions/dpms.h> + } +# endif +# if HAVE_X11_EXTENSIONS_XTEST_H +# include <X11/extensions/XTest.h> +# else +# error The XTest extension is required to build barrier +# endif +# if HAVE_X11_EXTENSIONS_XINERAMA_H + // Xinerama.h may lack extern "C" for inclusion by C++ + extern "C" { +# include <X11/extensions/Xinerama.h> + } +# endif +# if HAVE_X11_EXTENSIONS_XRANDR_H +# include <X11/extensions/Xrandr.h> +# endif +# if HAVE_XKB_EXTENSION +# include <X11/XKBlib.h> +# endif +# ifdef HAVE_XI2 +# include <X11/extensions/XInput2.h> +# endif +#endif + +class IXWindowsImpl { +public: + + virtual Status XInitThreads() = 0; + virtual XIOErrorHandler XSetIOErrorHandler(XIOErrorHandler handler) = 0; + virtual Window do_DefaultRootWindow(Display* display) = 0; + virtual int XCloseDisplay(Display* display) = 0; + virtual int XTestGrabControl(Display* display, Bool impervious) = 0; + virtual void XDestroyIC(XIC ic) = 0; + virtual Status XCloseIM(XIM im) = 0; + virtual int XDestroyWindow(Display* display, Window w) = 0; + virtual int XGetKeyboardControl(Display* display, + XKeyboardState* value_return) = 0; + virtual int XMoveWindow(Display* display, Window w, int x, int y) = 0; + virtual int XMapRaised(Display* display, Window w) = 0; + virtual void XUnsetICFocus(XIC ic) = 0; + virtual int XUnmapWindow(Display* display, Window w) = 0; + virtual int XSetInputFocus(Display* display, Window focus, int revert_to, + Time time) = 0; + virtual Bool DPMSQueryExtension(Display* display, int* event_base, + int* error_base) = 0; + virtual Bool DPMSCapable(Display* display) = 0; + virtual Status DPMSInfo(Display* display, CARD16* power_level, + BOOL* state) = 0; + virtual Status DPMSForceLevel(Display* display, CARD16 level) =0; + virtual int XGetInputFocus(Display* display, Window* focus_return, + int* revert_to_return) = 0; + virtual void XSetICFocus(XIC ic) = 0; + virtual Bool XQueryPointer(Display* display, Window w, Window* root_return, + Window* child_return, int* root_x_return, + int* root_y_return, int* win_x_return, + int* win_y_return, unsigned int* mask_return) =0; + virtual void XLockDisplay(Display* display) = 0; + virtual Bool XCheckMaskEvent(Display* display, long event_mask, + XEvent* event_return) = 0; + virtual XModifierKeymap* XGetModifierMapping(Display* display) = 0; + virtual int XGrabKey(Display* display, int keycode, unsigned int modifiers, + Window grab_window, int owner_events, int pointer_made, + int keyboard_mode) = 0; + virtual int XFreeModifiermap(XModifierKeymap* modmap) = 0; + virtual int XUngrabKey(Display* display, int keycode, + unsigned int modifiers, Window grab_window) = 0; + virtual int XTestFakeButtonEvent(Display* display, unsigned int button, + int is_press, unsigned long delay) = 0; + virtual int XFlush(Display* display) = 0; + virtual int XWarpPointer(Display* display, Window src_w, Window dest_w, + int src_x, int src_y, + unsigned int src_width, unsigned int src_height, + int dest_x, int dest_y) = 0; + virtual int XTestFakeRelativeMotionEvent(Display* display, int x, int y, + unsigned long delay) = 0; + virtual KeyCode XKeysymToKeycode(Display* display, KeySym keysym) = 0; + virtual int XTestFakeKeyEvent(Display* display, unsigned int keycode, + int is_press, unsigned long delay) = 0; + virtual Display* XOpenDisplay(_Xconst char* display_name) = 0; + virtual Bool XQueryExtension(Display* display, const char* name, + int* major_opcode_return, + int* first_event_return, + int* first_error_return) = 0; + virtual Bool XkbLibraryVersion(int* libMajorRtrn, int* libMinorRtrn) = 0; + virtual Bool XkbQueryExtension(Display* display, int* opcodeReturn, + int* eventBaseReturn, int* errorBaseReturn, + int* majorRtrn, int* minorRtrn) = 0; + virtual Bool XkbSelectEvents(Display* display, unsigned int deviceID, + unsigned int affect, unsigned int values) = 0; + virtual Bool XkbSelectEventDetails(Display* display, unsigned int deviceID, + unsigned int eventType, + unsigned long affect, + unsigned long details) = 0; + virtual Bool XRRQueryExtension(Display* display, int* event_base_return, + int* error_base_return) = 0; + virtual void XRRSelectInput(Display *display, Window window, int mask) = 0; + virtual Bool XineramaQueryExtension(Display* display, int* event_base, + int* error_base) = 0; + virtual Bool XineramaIsActive(Display* display) = 0; + virtual void* XineramaQueryScreens(Display* display, + int* number) = 0; + virtual Window XCreateWindow(Display* display, Window parent, int x, int y, + unsigned int width, unsigned int height, + unsigned int border_width, int depth, + unsigned int klass, Visual* visual, + unsigned long valuemask, + XSetWindowAttributes* attributes) = 0; + virtual XIM XOpenIM(Display* display, _XrmHashBucketRec* rdb, + char* res_name, char* res_class) = 0; + virtual char* XGetIMValues(XIM im, const char* type, void* ptr) = 0; + virtual XIC XCreateIC(XIM im, const char* type1, unsigned long data1, + const char* type2, unsigned long data2) = 0; + virtual char* XGetICValues(XIC ic, const char* type, + unsigned long* mask) = 0; + virtual Status XGetWindowAttributes(Display* display, Window w, + XWindowAttributes* attrs) = 0; + virtual int XSelectInput(Display* display, Window w, long event_mask) = 0; + virtual Bool XCheckIfEvent(Display* display, XEvent* event, + Bool (*predicate)(Display *, XEvent *, XPointer), + XPointer arg) = 0; + virtual Bool XFilterEvent(XEvent* event, Window window) = 0; + virtual Bool XGetEventData(Display* display, + XGenericEventCookie* cookie) = 0; + virtual void XFreeEventData(Display* display, + XGenericEventCookie* cookie) = 0; + virtual int XDeleteProperty(Display* display, Window w, Atom property) = 0; + virtual int XResizeWindow(Display* display, Window w, unsigned int width, + unsigned int height) = 0; + virtual int XMaskEvent(Display* display, long event_mask, + XEvent* event_return) = 0; + virtual Status XQueryBestCursor(Display* display, Drawable d, + unsigned int width, unsigned int height, + unsigned int* width_return, + unsigned int* height_return) = 0; + virtual Pixmap XCreateBitmapFromData(Display* display, Drawable d, + const char* data, unsigned int width, + unsigned int height) = 0; + virtual Cursor XCreatePixmapCursor(Display* display, + Pixmap source, Pixmap mask, + XColor* foreground_color, + XColor* background_color, + unsigned int x, unsigned int y) = 0; + virtual int XFreePixmap(Display* display, Pixmap pixmap) = 0; + virtual Status XQueryTree(Display* display, Window w, Window* root_return, + Window* parent_return, Window** children_return, + unsigned int* nchildren_return) = 0; + virtual int XmbLookupString(XIC ic, XKeyPressedEvent* event, + char* buffer_return, int bytes_buffer, + KeySym* keysym_return, int* status_return) = 0; + virtual int XLookupString(XKeyEvent* event_struct, char* buffer_return, + int bytes_buffer, KeySym* keysym_return, + XComposeStatus* status_in_out) = 0; + + virtual Status XSendEvent(Display* display, Window w, Bool propagate, + long event_mask, XEvent* event_send) = 0; + virtual int XSync(Display* display, Bool discard) = 0; + virtual int XGetPointerMapping(Display* display, unsigned char* map_return, + int nmap) = 0; + virtual int XGrabKeyboard(Display* display, Window grab_window, + Bool owner_events, int pointer_mode, + int keyboard_mode, Time time) = 0; + virtual int XGrabPointer(Display* display, Window grab_window, + Bool owner_events, unsigned int event_mask, + int pointer_mode, int keyboard_mode, + Window confine_to, Cursor cursor, Time time) = 0; + virtual int XUngrabKeyboard(Display* display, Time time) = 0; + virtual int XPending(Display* display) = 0; + virtual int XPeekEvent(Display* display, XEvent* event_return) = 0; + virtual Status XkbRefreshKeyboardMapping(XkbMapNotifyEvent* event) = 0; + virtual int XRefreshKeyboardMapping(XMappingEvent* event_map) = 0; + virtual int XISelectEvents(Display* display, Window w, XIEventMask* masks, + int num_masks) = 0; + virtual Atom XInternAtom(Display* display, _Xconst char* atom_name, + Bool only_if_exists) = 0; + virtual int XGetScreenSaver(Display* display, int* timeout_return, + int* interval_return, int* prefer_blanking_return, + int* allow_exposures_return) = 0; + virtual int XSetScreenSaver(Display* display, int timeout, int interval, + int prefer_blanking, int allow_exposures) = 0; + virtual int XForceScreenSaver(Display* display, int mode) = 0; + virtual int XFree(void* data) = 0; + virtual Status DPMSEnable(Display* display) = 0; + virtual Status DPMSDisable(Display* display) = 0; + virtual int XSetSelectionOwner(Display* display, Atom selection, Window w, + Time time) = 0; + virtual Window XGetSelectionOwner(Display* display, Atom selection) = 0; + virtual Atom* XListProperties(Display* display, Window w, + int* num_prop_return) = 0; + virtual char* XGetAtomName(Display* display, Atom atom) = 0; + virtual void XkbFreeKeyboard(XkbDescPtr xkb, unsigned int which, + Bool freeDesc) = 0; + virtual XkbDescPtr XkbGetMap(Display* display, unsigned int which, + unsigned int deviceSpec) = 0; + virtual Status XkbGetState(Display* display, unsigned int deviceSet, + XkbStatePtr rtrnState) = 0; + virtual int XQueryKeymap(Display* display, char keys_return[32]) = 0; + virtual Status XkbGetUpdatedMap(Display* display, unsigned int which, + XkbDescPtr desc) = 0; + virtual Bool XkbLockGroup(Display* display, unsigned int deviceSpec, + unsigned int group) = 0; + virtual int XDisplayKeycodes(Display* display, int* min_keycodes_return, + int* max_keycodes_return) = 0; + virtual KeySym* XGetKeyboardMapping(Display* display, + unsigned int first_keycode, + int keycode_count, + int* keysyms_per_keycode_return) = 0; + virtual int do_XkbKeyNumGroups(XkbDescPtr m_xkb, KeyCode desc) = 0; + virtual XkbKeyTypePtr do_XkbKeyKeyType(XkbDescPtr m_xkb, KeyCode keycode, + int eGroup) = 0; + virtual KeySym do_XkbKeySymEntry(XkbDescPtr m_xkb, KeyCode keycode, + int level, int eGroup) = 0; + virtual Bool do_XkbKeyHasActions(XkbDescPtr m_xkb, KeyCode keycode) = 0; + virtual XkbAction* do_XkbKeyActionEntry(XkbDescPtr m_xkb, KeyCode keycode, + int level, int eGroup) = 0; + virtual unsigned char do_XkbKeyGroupInfo(XkbDescPtr m_xkb, + KeyCode keycode) = 0; + virtual int XNextEvent(Display* display, XEvent* event_return) = 0; +}; diff --git a/src/lib/platform/OSXKeyState.cpp b/src/lib/platform/OSXKeyState.cpp index 482d7c1..9d8f429 100644 --- a/src/lib/platform/OSXKeyState.cpp +++ b/src/lib/platform/OSXKeyState.cpp @@ -521,19 +521,19 @@ OSXKeyState::postHIDVirtualKey(const UInt8 virtualKeyCode, switch (virtualKeyCode) { case s_shiftVK: - modifiersDelta = NX_SHIFTMASK; + modifiersDelta = NX_SHIFTMASK | NX_DEVICELSHIFTKEYMASK; m_shiftPressed = postDown; break; case s_superVK: - modifiersDelta = NX_COMMANDMASK; + modifiersDelta = NX_COMMANDMASK | NX_DEVICELCMDKEYMASK; m_superPressed = postDown; break; case s_altVK: - modifiersDelta = NX_ALTERNATEMASK; + modifiersDelta = NX_ALTERNATEMASK | NX_DEVICELALTKEYMASK; m_altPressed = postDown; break; case s_controlVK: - modifiersDelta = NX_CONTROLMASK; + modifiersDelta = NX_CONTROLMASK | NX_DEVICELCTLKEYMASK; m_controlPressed = postDown; break; case s_capsLockVK: @@ -551,6 +551,7 @@ OSXKeyState::postHIDVirtualKey(const UInt8 virtualKeyCode, } kern_return_t kr; + event.key.keyCode = virtualKeyCode; kr = IOHIDPostEvent(getEventDriver(), NX_FLAGSCHANGED, loc, &event, kNXEventDataVersion, modifiers, true); assert(KERN_SUCCESS == kr); diff --git a/src/lib/platform/OSXScreen.mm b/src/lib/platform/OSXScreen.mm index 1e0268e..8c7e24c 100644 --- a/src/lib/platform/OSXScreen.mm +++ b/src/lib/platform/OSXScreen.mm @@ -1263,36 +1263,23 @@ OSXScreen::onKey(CGEventRef event) return true; } - // check for hot key. when we're on a secondary screen we disable - // all hotkeys so we can capture the OS defined hot keys as regular - // keystrokes but that means we don't get our own hot keys either. - // so we check for a key/modifier match in our hot key map. - if (!m_isOnScreen) { - HotKeyToIDMap::const_iterator i = - m_hotKeyToIDMap.find(HotKeyItem(virtualKey, - m_keyState->mapModifiersToCarbon(macMask) - & 0xff00u)); - if (i != m_hotKeyToIDMap.end()) { - UInt32 id = i->second; - - // determine event type - Event::Type type; - //UInt32 eventKind = GetEventKind(event); - if (eventKind == kCGEventKeyDown) { - type = m_events->forIPrimaryScreen().hotKeyDown(); - } - else if (eventKind == kCGEventKeyUp) { - type = m_events->forIPrimaryScreen().hotKeyUp(); - } - else { - return false; - } - - m_events->addEvent(Event(type, getEventTarget(), - HotKeyInfo::alloc(id))); - - return true; + HotKeyToIDMap::const_iterator i = m_hotKeyToIDMap.find(HotKeyItem(virtualKey, m_keyState->mapModifiersToCarbon(macMask) & 0xff00u)); + if (i != m_hotKeyToIDMap.end()) { + UInt32 id = i->second; + // determine event type + Event::Type type; + //UInt32 eventKind = GetEventKind(event); + if (eventKind == kCGEventKeyDown) { + type = m_events->forIPrimaryScreen().hotKeyDown(); } + else if (eventKind == kCGEventKeyUp) { + type = m_events->forIPrimaryScreen().hotKeyUp(); + } + else { + return false; + } + m_events->addEvent(Event(type, getEventTarget(), HotKeyInfo::alloc(id))); + return true; } // decode event type diff --git a/src/lib/platform/XWindowsClipboard.cpp b/src/lib/platform/XWindowsClipboard.cpp index 8e7d864..b2c17f9 100644 --- a/src/lib/platform/XWindowsClipboard.cpp +++ b/src/lib/platform/XWindowsClipboard.cpp @@ -38,7 +38,7 @@ // XWindowsClipboard // -XWindowsClipboard::XWindowsClipboard(Display* display, +XWindowsClipboard::XWindowsClipboard(IXWindowsImpl* impl, Display* display, Window window, ClipboardID id) : m_display(display), m_window(window), @@ -49,25 +49,30 @@ XWindowsClipboard::XWindowsClipboard(Display* display, m_timeOwned(0), m_timeLost(0) { + m_impl = impl; // get some atoms - m_atomTargets = XInternAtom(m_display, "TARGETS", False); - m_atomMultiple = XInternAtom(m_display, "MULTIPLE", False); - m_atomTimestamp = XInternAtom(m_display, "TIMESTAMP", False); - m_atomInteger = XInternAtom(m_display, "INTEGER", False); - m_atomAtom = XInternAtom(m_display, "ATOM", False); - m_atomAtomPair = XInternAtom(m_display, "ATOM_PAIR", False); - m_atomData = XInternAtom(m_display, "CLIP_TEMPORARY", False); - m_atomINCR = XInternAtom(m_display, "INCR", False); - m_atomMotifClipLock = XInternAtom(m_display, "_MOTIF_CLIP_LOCK", False); - m_atomMotifClipHeader = XInternAtom(m_display, "_MOTIF_CLIP_HEADER", False); - m_atomMotifClipAccess = XInternAtom(m_display, + m_atomTargets = m_impl->XInternAtom(m_display, "TARGETS", False); + m_atomMultiple = m_impl->XInternAtom(m_display, "MULTIPLE", False); + m_atomTimestamp = m_impl->XInternAtom(m_display, "TIMESTAMP", False); + m_atomInteger = m_impl->XInternAtom(m_display, "INTEGER", False); + m_atomAtom = m_impl->XInternAtom(m_display, "ATOM", False); + m_atomAtomPair = m_impl->XInternAtom(m_display, "ATOM_PAIR", False); + m_atomData = m_impl->XInternAtom(m_display, "CLIP_TEMPORARY", + False); + m_atomINCR = m_impl->XInternAtom(m_display, "INCR", False); + m_atomMotifClipLock = m_impl->XInternAtom(m_display, "_MOTIF_CLIP_LOCK", + False); + m_atomMotifClipHeader = m_impl->XInternAtom(m_display, "_MOTIF_CLIP_HEADER", + False); + m_atomMotifClipAccess = m_impl->XInternAtom(m_display, "_MOTIF_CLIP_LOCK_ACCESS_VALID", False); - m_atomGDKSelection = XInternAtom(m_display, "GDK_SELECTION", False); + m_atomGDKSelection = m_impl->XInternAtom(m_display, "GDK_SELECTION", + False); // set selection atom based on clipboard id switch (id) { case kClipboardClipboard: - m_selection = XInternAtom(m_display, "CLIPBOARD", False); + m_selection = m_impl->XInternAtom(m_display, "CLIPBOARD", False); break; case kClipboardSelection: @@ -273,8 +278,8 @@ XWindowsClipboard::empty() LOG((CLOG_DEBUG "empty clipboard %d", m_id)); // assert ownership of clipboard - XSetSelectionOwner(m_display, m_selection, m_window, m_time); - if (XGetSelectionOwner(m_display, m_selection) != m_window) { + m_impl->XSetSelectionOwner(m_display, m_selection, m_window, m_time); + if (m_impl->XGetSelectionOwner(m_display, m_selection) != m_window) { LOG((CLOG_DEBUG "failed to grab clipboard %d", m_id)); return false; } @@ -610,7 +615,7 @@ bool XWindowsClipboard::motifLockClipboard() const { // fail if anybody owns the lock (even us, so this is non-recursive) - Window lockOwner = XGetSelectionOwner(m_display, m_atomMotifClipLock); + Window lockOwner = m_impl->XGetSelectionOwner(m_display, m_atomMotifClipLock); if (lockOwner != None) { LOG((CLOG_DEBUG1 "motif lock owner 0x%08x", lockOwner)); return false; @@ -621,8 +626,8 @@ XWindowsClipboard::motifLockClipboard() const // A grabs successfully, B grabs successfully, A thinks it // still has the grab until it gets a SelectionClear. Time time = XWindowsUtil::getCurrentTime(m_display, m_window); - XSetSelectionOwner(m_display, m_atomMotifClipLock, m_window, time); - lockOwner = XGetSelectionOwner(m_display, m_atomMotifClipLock); + m_impl->XSetSelectionOwner(m_display, m_atomMotifClipLock, m_window, time); + lockOwner = m_impl->XGetSelectionOwner(m_display, m_atomMotifClipLock); if (lockOwner != m_window) { LOG((CLOG_DEBUG1 "motif lock owner 0x%08x", lockOwner)); return false; @@ -638,14 +643,14 @@ XWindowsClipboard::motifUnlockClipboard() const LOG((CLOG_DEBUG1 "unlocked motif clipboard")); // fail if we don't own the lock - Window lockOwner = XGetSelectionOwner(m_display, m_atomMotifClipLock); + Window lockOwner = m_impl->XGetSelectionOwner(m_display, m_atomMotifClipLock); if (lockOwner != m_window) { return; } // release lock Time time = XWindowsUtil::getCurrentTime(m_display, m_window); - XSetSelectionOwner(m_display, m_atomMotifClipLock, None, time); + m_impl->XSetSelectionOwner(m_display, m_atomMotifClipLock, None, time); } bool @@ -655,7 +660,7 @@ XWindowsClipboard::motifOwnsClipboard() const // FIXME -- this can't be right. even if the window is destroyed // Motif will still have a valid clipboard. how can we tell if // some other client owns CLIPBOARD? - Window owner = XGetSelectionOwner(m_display, m_selection); + Window owner = m_impl->XGetSelectionOwner(m_display, m_selection); if (owner == None) { return false; } @@ -712,7 +717,7 @@ XWindowsClipboard::motifFillCache() // get the Motif item property from the root window char name[18 + 20]; sprintf(name, "_MOTIF_CLIP_ITEM_%d", header.m_item); - Atom atomItem = XInternAtom(m_display, name, False); + Atom atomItem = m_impl->XInternAtom(m_display, name, False); data = ""; if (!XWindowsUtil::getWindowProperty(m_display, root, atomItem, &data, @@ -741,7 +746,7 @@ XWindowsClipboard::motifFillCache() for (SInt32 i = 0; i < numFormats; ++i) { // get Motif format property from the root window sprintf(name, "_MOTIF_CLIP_ITEM_%d", formats[i]); - Atom atomFormat = XInternAtom(m_display, name, False); + Atom atomFormat = m_impl->XInternAtom(m_display, name, False); String data; if (!XWindowsUtil::getWindowProperty(m_display, root, atomFormat, &data, @@ -824,7 +829,7 @@ XWindowsClipboard::motifGetSelection(const MotifClipFormat* format, // part that i don't know. char name[18 + 20]; sprintf(name, "_MOTIF_CLIP_ITEM_%d", format->m_data); - Atom target = XInternAtom(m_display, name, False); + Atom target = m_impl->XInternAtom(m_display, name, False); Window root = RootWindow(m_display, DefaultScreen(m_display)); return XWindowsUtil::getWindowProperty(m_display, root, target, data, @@ -919,11 +924,11 @@ XWindowsClipboard::insertReply(Reply* reply) // get and save the current event mask XWindowAttributes attr; - XGetWindowAttributes(m_display, reply->m_requestor, &attr); + m_impl->XGetWindowAttributes(m_display, reply->m_requestor, &attr); m_eventMasks[reply->m_requestor] = attr.your_event_mask; // add the events we want - XSelectInput(m_display, reply->m_requestor, attr.your_event_mask | + m_impl->XSelectInput(m_display, reply->m_requestor, attr.your_event_mask | StructureNotifyMask | PropertyChangeMask); } @@ -979,7 +984,7 @@ XWindowsClipboard::pushReplies(ReplyMap::iterator& mapIndex, if (replies.empty()) { XWindowsUtil::ErrorLock lock(m_display); Window requestor = mapIndex->first; - XSelectInput(m_display, requestor, m_eventMasks[requestor]); + m_impl->XSelectInput(m_display, requestor, m_eventMasks[requestor]); m_replies.erase(mapIndex++); m_eventMasks.erase(requestor); } @@ -1055,7 +1060,7 @@ XWindowsClipboard::sendReply(Reply* reply) reply->m_done = true; if (reply->m_property != None) { XWindowsUtil::ErrorLock lock(m_display); - XDeleteProperty(m_display, reply->m_requestor, reply->m_property); + m_impl->XDeleteProperty(m_display, reply->m_requestor, reply->m_property); } if (!reply->m_replied) { @@ -1091,12 +1096,13 @@ XWindowsClipboard::sendReply(Reply* reply) if (CLOG->getFilter() >= kDEBUG2) { XWindowsUtil::ErrorLock lock(m_display); int n; - Atom* props = XListProperties(m_display, reply->m_requestor, &n); + Atom* props = m_impl->XListProperties(m_display, reply->m_requestor, + &n); LOG((CLOG_DEBUG2 "properties of 0x%08x:", reply->m_requestor)); for (int i = 0; i < n; ++i) { Atom target; String data; - char* name = XGetAtomName(m_display, props[i]); + char* name = m_impl->XGetAtomName(m_display, props[i]); if (!XWindowsUtil::getWindowProperty(m_display, reply->m_requestor, props[i], &data, &target, NULL, False)) { @@ -1120,18 +1126,18 @@ XWindowsClipboard::sendReply(Reply* reply) break; } } - char* type = XGetAtomName(m_display, target); + char* type = m_impl->XGetAtomName(m_display, target); LOG((CLOG_DEBUG2 " %s (%s): %s", name, type, data.c_str())); if (type != NULL) { - XFree(type); + m_impl->XFree(type); } } if (name != NULL) { - XFree(name); + m_impl->XFree(name); } } if (props != NULL) { - XFree(props); + m_impl->XFree(props); } } @@ -1178,7 +1184,7 @@ XWindowsClipboard::sendNotify(Window requestor, event.xselection.property = property; event.xselection.time = time; XWindowsUtil::ErrorLock lock(m_display); - XSendEvent(m_display, requestor, False, 0, &event); + m_impl->XSendEvent(m_display, requestor, False, 0, &event); } bool diff --git a/src/lib/platform/XWindowsClipboard.h b/src/lib/platform/XWindowsClipboard.h index cf20e82..f00c3fc 100644 --- a/src/lib/platform/XWindowsClipboard.h +++ b/src/lib/platform/XWindowsClipboard.h @@ -23,6 +23,7 @@ #include "common/stdmap.h" #include "common/stdlist.h" #include "common/stdvector.h" +#include "XWindowsImpl.h" #if X_DISPLAY_MISSING # error X11 is required to build barrier @@ -39,7 +40,8 @@ public: Use \c window as the window that owns or interacts with the clipboard identified by \c id. */ - XWindowsClipboard(Display*, Window window, ClipboardID id); + XWindowsClipboard(IXWindowsImpl* impl, Display*, Window window, + ClipboardID id); virtual ~XWindowsClipboard(); //! Notify clipboard was lost @@ -284,6 +286,7 @@ private: private: typedef std::vector<IXWindowsClipboardConverter*> ConverterList; + IXWindowsImpl* m_impl; Display* m_display; Window m_window; diff --git a/src/lib/platform/XWindowsEventQueueBuffer.cpp b/src/lib/platform/XWindowsEventQueueBuffer.cpp index 234cd62..78f0e5a 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/XWindowsEventQueueBuffer.cpp @@ -52,17 +52,18 @@ class EventQueueTimer { }; // XWindowsEventQueueBuffer // -XWindowsEventQueueBuffer::XWindowsEventQueueBuffer( +XWindowsEventQueueBuffer::XWindowsEventQueueBuffer(IXWindowsImpl* impl, Display* display, Window window, IEventQueue* events) : m_events(events), m_display(display), m_window(window), m_waiting(false) { + m_impl = impl; assert(m_display != NULL); assert(m_window != None); - m_userEvent = XInternAtom(m_display, "BARRIER_USER_EVENT", False); + m_userEvent = m_impl->XInternAtom(m_display, "BARRIER_USER_EVENT", False); // set up for pipe hack int result = pipe(m_pipefd); assert(result == 0); @@ -206,7 +207,7 @@ XWindowsEventQueueBuffer::getEvent(Event& event, UInt32& dataID) flush(); // get next event - XNextEvent(m_display, &m_event); + m_impl->XNextEvent(m_display, &m_event); // process event if (m_event.xany.type == ClientMessage && @@ -262,7 +263,7 @@ bool XWindowsEventQueueBuffer::isEmpty() const { Lock lock(&m_mutex); - return (XPending(m_display) == 0 ); + return (m_impl->XPending(m_display) == 0 ); } EventQueueTimer* @@ -284,8 +285,8 @@ XWindowsEventQueueBuffer::flush() // flush the posted event list to the X server for (size_t i = 0; i < m_postedEvents.size(); ++i) { - XSendEvent(m_display, m_window, False, 0, &m_postedEvents[i]); + m_impl->XSendEvent(m_display, m_window, False, 0, &m_postedEvents[i]); } - XFlush(m_display); + m_impl->XFlush(m_display); m_postedEvents.clear(); } diff --git a/src/lib/platform/XWindowsEventQueueBuffer.h b/src/lib/platform/XWindowsEventQueueBuffer.h index 07f3b3a..e49b282 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.h +++ b/src/lib/platform/XWindowsEventQueueBuffer.h @@ -21,6 +21,7 @@ #include "mt/Mutex.h" #include "base/IEventQueueBuffer.h" #include "common/stdvector.h" +#include "XWindowsImpl.h" #if X_DISPLAY_MISSING # error X11 is required to build barrier @@ -33,7 +34,8 @@ class IEventQueue; //! Event queue buffer for X11 class XWindowsEventQueueBuffer : public IEventQueueBuffer { public: - XWindowsEventQueueBuffer(Display*, Window, IEventQueue* events); + XWindowsEventQueueBuffer(IXWindowsImpl* impl, Display*, Window, + IEventQueue* events); virtual ~XWindowsEventQueueBuffer(); // IEventQueueBuffer overrides @@ -51,6 +53,7 @@ private: private: typedef std::vector<XEvent> EventList; + IXWindowsImpl* m_impl; Mutex m_mutex; Display* m_display; diff --git a/src/lib/platform/XWindowsImpl.cpp b/src/lib/platform/XWindowsImpl.cpp new file mode 100644 index 0000000..d5508a4 --- /dev/null +++ b/src/lib/platform/XWindowsImpl.cpp @@ -0,0 +1,646 @@ + +#include "XWindowsImpl.h" + +Status XWindowsImpl::XInitThreads() +{ + return ::XInitThreads(); +} + +XIOErrorHandler XWindowsImpl::XSetIOErrorHandler(XIOErrorHandler handler) +{ + return ::XSetIOErrorHandler(handler); +} + +Window XWindowsImpl::do_DefaultRootWindow(Display* display) +{ + return DefaultRootWindow(display); +} + +int XWindowsImpl::XCloseDisplay(Display* display) +{ + return ::XCloseDisplay(display); +} + +int XWindowsImpl::XTestGrabControl(Display *display, int impervious) +{ + return ::XTestGrabControl(display, impervious); +} + +void XWindowsImpl::XDestroyIC(XIC ic) +{ + ::XDestroyIC(ic); +} + +Status XWindowsImpl::XCloseIM(XIM im) +{ + return ::XCloseIM(im); +} + +int XWindowsImpl::XDestroyWindow(Display* display, Window w) +{ + return ::XDestroyWindow(display, w); +} + +int XWindowsImpl::XGetKeyboardControl(Display* display, + XKeyboardState* value_return) +{ + return ::XGetKeyboardControl(display, value_return); +} + +int XWindowsImpl::XMoveWindow(Display* display, Window w, int x, int y) +{ + return ::XMoveWindow(display, w, x, y); +} + +int XWindowsImpl::XMapRaised(Display* display, Window w) +{ + return ::XMapRaised(display, w); +} + +void XWindowsImpl::XUnsetICFocus(XIC ic) +{ + ::XUnsetICFocus(ic); +} + +int XWindowsImpl::XUnmapWindow(Display* display, Window w) +{ + return ::XUnmapWindow(display, w); +} + +int XWindowsImpl::XSetInputFocus(Display* display, Window focus, + int revert_to, Time time) +{ + return ::XSetInputFocus(display, focus, revert_to, time); +} + +Bool XWindowsImpl::DPMSQueryExtension(Display* display, int* event_base, + int* error_base) +{ + return ::DPMSQueryExtension(display, event_base, error_base); +} + +Bool XWindowsImpl::DPMSCapable(Display* display) +{ + return ::DPMSCapable(display); +} + +Status XWindowsImpl::DPMSInfo(Display* display, CARD16* power_level, + BOOL* state) +{ + return ::DPMSInfo(display, power_level, state); +} + +Status XWindowsImpl::DPMSForceLevel(Display* display, CARD16 level) +{ + return ::DPMSForceLevel(display,level); +} + +int XWindowsImpl::XGetInputFocus(Display* display, Window* focus_return, + int* revert_to_return) +{ + return ::XGetInputFocus(display, focus_return, revert_to_return); +} + + +void XWindowsImpl::XSetICFocus(XIC ic) +{ + ::XSetICFocus(ic); +} + +Bool XWindowsImpl::XQueryPointer(Display* display, Window w, + Window* root_return, Window* child_return, + int* root_x_return, int* root_y_return, + int* win_x_return, int* win_y_return, + unsigned int* mask_return) +{ + return ::XQueryPointer(display, w, root_return, child_return, root_x_return, + root_y_return, win_x_return, win_y_return, + mask_return); +} + +void XWindowsImpl::XLockDisplay(Display* display) +{ + ::XLockDisplay(display); +} + +Bool XWindowsImpl::XCheckMaskEvent(Display* display, long event_mask, + XEvent* event_return) +{ + return ::XCheckMaskEvent(display,event_mask, event_return); +} + +XModifierKeymap* XWindowsImpl::XGetModifierMapping(Display* display) +{ + return ::XGetModifierMapping(display); +} + +int XWindowsImpl::XGrabKey(Display* display, int keycode, + unsigned int modifiers, Window grab_window, + int owner_events, int pointer_made, + int keyboard_mode) +{ + return ::XGrabKey(display, keycode, modifiers, grab_window, owner_events, + pointer_made, keyboard_mode); +} + +int XWindowsImpl::XFreeModifiermap(XModifierKeymap* modmap) +{ + return ::XFreeModifiermap(modmap); +} + +int XWindowsImpl::XUngrabKey(Display* display, int keycode, + unsigned int modifiers, Window grab_window) +{ + return ::XUngrabKey(display, keycode, modifiers, grab_window); +} + +int XWindowsImpl::XTestFakeButtonEvent(Display* display, unsigned int button, + int is_press, unsigned long delay) +{ + return ::XTestFakeButtonEvent(display, button, is_press, delay); +} + +int XWindowsImpl::XFlush(Display* display) +{ + return ::XFlush(display); +} + +int XWindowsImpl::XWarpPointer(Display* display, Window src_w, Window dest_w, + int src_x, int src_y, + unsigned int src_width, unsigned int src_height, + int dest_x, int dest_y) +{ + return ::XWarpPointer(display, src_w, dest_w, src_x, src_y, src_width, + src_height, dest_x, dest_y); +} + +int XWindowsImpl::XTestFakeRelativeMotionEvent(Display* display, int x, int y, + unsigned long delay) +{ + return ::XTestFakeRelativeMotionEvent(display, x, y, delay); +} + +KeyCode XWindowsImpl::XKeysymToKeycode(Display* display, KeySym keysym) +{ + return ::XKeysymToKeycode(display, keysym); +} + +int XWindowsImpl::XTestFakeKeyEvent(Display* display, unsigned int keycode, + int is_press, unsigned long delay) +{ + return ::XTestFakeKeyEvent(display, keycode, is_press, delay); +} + +Display* XWindowsImpl::XOpenDisplay(_Xconst char* display_name) +{ + return ::XOpenDisplay(display_name); +} + +Bool XWindowsImpl::XQueryExtension(Display* display, const char* name, + int* major_opcode_return, + int* first_event_return, + int* first_error_return) +{ + return ::XQueryExtension(display, name, major_opcode_return, + first_event_return, first_error_return); +} + +Bool XWindowsImpl::XkbLibraryVersion(int* libMajorRtrn, int* libMinorRtrn) +{ + return ::XkbLibraryVersion(libMajorRtrn, libMinorRtrn); +} + +Bool XWindowsImpl::XkbQueryExtension(Display* display, int* opcodeReturn, + int* eventBaseReturn, int* errorBaseReturn, + int* majorRtrn, int* minorRtrn) +{ + return ::XkbQueryExtension(display, opcodeReturn, eventBaseReturn, + errorBaseReturn, majorRtrn, minorRtrn); +} + + +Bool XWindowsImpl::XkbSelectEvents(Display* display, unsigned int deviceID, + unsigned int affect, unsigned int values) +{ + return ::XkbSelectEvents(display, deviceID, affect, values); +} + +Bool XWindowsImpl::XkbSelectEventDetails(Display* display, + unsigned int deviceID, + unsigned int eventType, + unsigned long affect, + unsigned long details) +{ + return ::XkbSelectEventDetails(display, deviceID, eventType, affect, + details); +} + +Bool XWindowsImpl::XRRQueryExtension(Display* display, int* event_base_return, + int* error_base_return) +{ +#if HAVE_X11_EXTENSIONS_XRANDR_H + return ::XRRQueryExtension(display, event_base_return, error_base_return); +#else + return false; +#endif +} + +void XWindowsImpl::XRRSelectInput(Display *display, Window window, int mask) +{ +#if HAVE_X11_EXTENSIONS_XRANDR_H + ::XRRSelectInput(display, window, mask); +#else + (void) display; (void) window; (void) mask; +#endif +} + +Bool XWindowsImpl::XineramaQueryExtension(Display* display, int* event_base, + int* error_base) +{ +#if HAVE_X11_EXTENSIONS_XINERAMA_H + return ::XineramaQueryExtension(display, event_base, error_base); +#else + return false; +#endif +} + +Bool XWindowsImpl::XineramaIsActive(Display* display) +{ +#if HAVE_X11_EXTENSIONS_XINERAMA_H + return ::XineramaIsActive(display); +#else + return false; +#endif +} + +void* XWindowsImpl::XineramaQueryScreens(Display* display, int* number) +{ +#if HAVE_X11_EXTENSIONS_XINERAMA_H + return ::XineramaQueryScreens(display, number); +#else + return nullptr; +#endif +} + +Window XWindowsImpl::XCreateWindow(Display* display, Window parent, + int x, int y, + unsigned int width, unsigned int height, + unsigned int border_width, int depth, + unsigned int klass, Visual* visual, + unsigned long valuemask, + XSetWindowAttributes* attributes) +{ + return ::XCreateWindow(display, parent, x, y, width, height, border_width, + depth, klass, visual, valuemask, attributes); +} + +XIM XWindowsImpl::XOpenIM(Display* display, _XrmHashBucketRec* rdb, + char* res_name, char* res_class) +{ + return ::XOpenIM(display, rdb, res_name, res_class); +} + +char* XWindowsImpl::XGetIMValues(XIM im, const char* type, void* ptr) +{ + return ::XGetIMValues(im, type, ptr, nullptr); +} + +XIC XWindowsImpl::XCreateIC(XIM im, const char* type1, unsigned long data, + const char* type2, unsigned long data2) +{ + return ::XCreateIC(im, type1, data, type2, data2, nullptr); +} + +char* XWindowsImpl::XGetICValues(XIC ic, const char* type, unsigned long* mask) +{ + return ::XGetICValues(ic, type, mask, nullptr); +} + +Status XWindowsImpl::XGetWindowAttributes(Display* display, Window w, + XWindowAttributes* attrs) +{ + return ::XGetWindowAttributes(display, w, attrs); +} + +int XWindowsImpl::XSelectInput(Display* display, Window w, long event_mask) +{ + return ::XSelectInput(display, w, event_mask); +} + +Bool XWindowsImpl::XCheckIfEvent(Display* display, XEvent* event, + Bool (*predicate)(Display *, XEvent *, + XPointer), + XPointer arg) +{ + return ::XCheckIfEvent(display, event, predicate, arg); +} + +Bool XWindowsImpl::XFilterEvent(XEvent* event, Window window) +{ + return ::XFilterEvent(event, window); +} + +Bool XWindowsImpl::XGetEventData(Display* display, + XGenericEventCookie* cookie) +{ + return ::XGetEventData(display, cookie); +} + +void XWindowsImpl::XFreeEventData(Display* display, + XGenericEventCookie* cookie) +{ + ::XFreeEventData(display, cookie); +} + +int XWindowsImpl::XDeleteProperty(Display* display, Window w, Atom property) +{ + return ::XDeleteProperty(display, w, property); +} + +int XWindowsImpl::XResizeWindow(Display* display, Window w, unsigned int width, + unsigned int height) +{ + return ::XResizeWindow(display, w, width, height); +} + +int XWindowsImpl::XMaskEvent(Display* display, long event_mask, + XEvent* event_return) +{ + return ::XMaskEvent(display, event_mask, event_return); +} + +Status XWindowsImpl::XQueryBestCursor(Display* display, Drawable d, + unsigned int width, unsigned int height, + unsigned int* width_return, + unsigned int* height_return) +{ + return ::XQueryBestCursor(display, d, width, height, width_return, + height_return); +} + +Pixmap XWindowsImpl::XCreateBitmapFromData(Display* display, Drawable d, + const char* data, unsigned int width, + unsigned int height) +{ + return ::XCreateBitmapFromData(display, d, data, width, height); +} + +Cursor XWindowsImpl::XCreatePixmapCursor(Display* display, + Pixmap source, Pixmap mask, + XColor* foreground_color, + XColor* background_color, + unsigned int x, unsigned int y) +{ + return ::XCreatePixmapCursor(display, source, mask, foreground_color, + background_color, x, y); +} + +int XWindowsImpl::XFreePixmap(Display* display, Pixmap pixmap) +{ + return ::XFreePixmap(display, pixmap); +} + +Status XWindowsImpl::XQueryTree(Display* display, Window w, Window* root_return, + Window* parent_return, Window** children_return, + unsigned int* nchildren_return) +{ + return ::XQueryTree(display, w, root_return, parent_return, children_return, + nchildren_return); +} + +int XWindowsImpl::XmbLookupString(XIC ic, XKeyPressedEvent* event, + char* buffer_return, int bytes_buffer, + KeySym* keysym_return, int* status_return) +{ + return ::XmbLookupString(ic, event, buffer_return, bytes_buffer, + keysym_return, status_return); +} + +int XWindowsImpl::XLookupString(XKeyEvent* event_struct, char* buffer_return, + int bytes_buffer, KeySym* keysym_return, + XComposeStatus* status_in_out) +{ + return ::XLookupString(event_struct, buffer_return, bytes_buffer, + keysym_return, status_in_out); +} + +Status XWindowsImpl::XSendEvent(Display* display, Window w, Bool propagate, + long event_mask, XEvent* event_send) +{ + return ::XSendEvent(display, w, propagate, event_mask, event_send); +} + +int XWindowsImpl::XSync(Display* display, Bool discard) +{ + return ::XSync(display, discard); +} + +int XWindowsImpl::XGetPointerMapping(Display* display, + unsigned char* map_return, int nmap) +{ + return ::XGetPointerMapping(display, map_return, nmap); +} + +int XWindowsImpl::XGrabKeyboard(Display* display, Window grab_window, + Bool owner_events, int pointer_mode, + int keyboard_mode, Time time) +{ + return ::XGrabKeyboard(display, grab_window, owner_events, pointer_mode, + keyboard_mode, time); +} + +int XWindowsImpl::XGrabPointer(Display* display, Window grab_window, + Bool owner_events, unsigned int event_mask, + int pointer_mode, int keyboard_mode, + Window confine_to, Cursor cursor, Time time) +{ + return ::XGrabPointer(display, grab_window, owner_events, event_mask, + pointer_mode, keyboard_mode, confine_to, cursor, + time); +} + +int XWindowsImpl::XUngrabKeyboard(Display* display, Time time) +{ + return ::XUngrabKeyboard(display, time); +} + +int XWindowsImpl::XPending(Display* display) +{ + return ::XPending(display); +} + +int XWindowsImpl::XPeekEvent(Display* display, XEvent* event_return) +{ + return ::XPeekEvent(display, event_return); +} + +Status XWindowsImpl::XkbRefreshKeyboardMapping(XkbMapNotifyEvent* event) +{ + return ::XkbRefreshKeyboardMapping(event); +} + +int XWindowsImpl::XRefreshKeyboardMapping(XMappingEvent* event_map) +{ + return ::XRefreshKeyboardMapping(event_map); +} + +int XWindowsImpl::XISelectEvents(Display* display, Window w, XIEventMask* masks, + int num_masks) +{ + return ::XISelectEvents(display, w, masks, num_masks); +} + +Atom XWindowsImpl::XInternAtom(Display* display, _Xconst char* atom_name, + Bool only_if_exists) +{ + return ::XInternAtom(display, atom_name, only_if_exists); +} + +int XWindowsImpl::XGetScreenSaver(Display* display, int* timeout_return, + int* interval_return, + int* prefer_blanking_return, + int* allow_exposures_return) +{ + return ::XGetScreenSaver(display, timeout_return, interval_return, + prefer_blanking_return, allow_exposures_return); +} + +int XWindowsImpl::XSetScreenSaver(Display* display, int timeout, int interval, + int prefer_blanking, int allow_exposures) +{ + return ::XSetScreenSaver(display, timeout, interval, prefer_blanking, + allow_exposures); +} + +int XWindowsImpl::XForceScreenSaver(Display* display, int mode) +{ + return ::XForceScreenSaver(display, mode); +} + +int XWindowsImpl::XFree(void* data) +{ + return ::XFree(data); +} + +Status XWindowsImpl::DPMSEnable(Display* display) +{ + return ::DPMSEnable(display); +} + +Status XWindowsImpl::DPMSDisable(Display* display) +{ + return ::DPMSDisable(display); +} + +int XWindowsImpl::XSetSelectionOwner(Display* display, Atom selection, Window w, + Time time) +{ + return ::XSetSelectionOwner(display, selection, w, time); +} + +Window XWindowsImpl::XGetSelectionOwner(Display* display, Atom selection) +{ + return ::XGetSelectionOwner(display, selection); +} + +Atom* XWindowsImpl::XListProperties(Display* display, Window w, + int* num_prop_return) +{ + return ::XListProperties(display, w, num_prop_return); +} + +char* XWindowsImpl::XGetAtomName(Display* display, Atom atom) +{ + return ::XGetAtomName(display, atom); +} + +void XWindowsImpl::XkbFreeKeyboard(XkbDescPtr xkb, unsigned int which, + Bool freeDesc) +{ + ::XkbFreeKeyboard(xkb, which, freeDesc); +} + +XkbDescPtr XWindowsImpl::XkbGetMap(Display* display, unsigned int which, + unsigned int deviceSpec) +{ + return ::XkbGetMap(display, which, deviceSpec); +} + +Status XWindowsImpl::XkbGetState(Display* display, unsigned int deviceSet, + XkbStatePtr rtrnState) +{ + return ::XkbGetState(display, deviceSet, rtrnState); +} + +int XWindowsImpl::XQueryKeymap(Display* display, char keys_return[32]) +{ + return ::XQueryKeymap(display, keys_return); +} + +Status XWindowsImpl::XkbGetUpdatedMap(Display* display, unsigned int which, + XkbDescPtr desc) +{ + return ::XkbGetUpdatedMap(display, which, desc); +} + +Bool XWindowsImpl::XkbLockGroup(Display* display, unsigned int deviceSpec, + unsigned int group) +{ + return ::XkbLockGroup(display, deviceSpec, group); +} + +int XWindowsImpl::XDisplayKeycodes(Display* display, int* min_keycodes_return, + int* max_keycodes_return) +{ + return ::XDisplayKeycodes(display, min_keycodes_return, + max_keycodes_return); +} + +KeySym* XWindowsImpl::XGetKeyboardMapping(Display* display, + unsigned int first_keycode, + int keycode_count, + int* keysyms_per_keycode_return) +{ + return ::XGetKeyboardMapping(display, first_keycode, keycode_count, + keysyms_per_keycode_return); +} + +int XWindowsImpl::do_XkbKeyNumGroups(XkbDescPtr m_xkb, KeyCode desc) + +{ + return XkbKeyNumGroups(m_xkb, desc); +} + +XkbKeyTypePtr XWindowsImpl::do_XkbKeyKeyType(XkbDescPtr m_xkb, KeyCode keycode, + int eGroup) +{ + return XkbKeyKeyType(m_xkb, keycode, eGroup); +} + +KeySym XWindowsImpl::do_XkbKeySymEntry(XkbDescPtr m_xkb, KeyCode keycode, + int level, int eGroup) +{ + return XkbKeySymEntry(m_xkb, keycode, level, eGroup); +} + +Bool XWindowsImpl::do_XkbKeyHasActions(XkbDescPtr m_xkb, KeyCode keycode) +{ + return XkbKeyHasActions(m_xkb, keycode); +} + +XkbAction* XWindowsImpl::do_XkbKeyActionEntry(XkbDescPtr m_xkb, KeyCode keycode, + int level, int eGroup) +{ + return XkbKeyActionEntry(m_xkb, keycode, level, eGroup); +} + +unsigned char XWindowsImpl::do_XkbKeyGroupInfo(XkbDescPtr m_xkb, + KeyCode keycode) +{ + return XkbKeyGroupInfo(m_xkb, keycode); +} + +int XWindowsImpl::XNextEvent(Display* display, XEvent* event_return) +{ + return ::XNextEvent(display, event_return); +} diff --git a/src/lib/platform/XWindowsImpl.h b/src/lib/platform/XWindowsImpl.h new file mode 100644 index 0000000..ae45aea --- /dev/null +++ b/src/lib/platform/XWindowsImpl.h @@ -0,0 +1,196 @@ + +#pragma once + +#include "IXWindowsImpl.h" + +class XWindowsImpl : public IXWindowsImpl { +public: + + virtual Status XInitThreads(); + virtual XIOErrorHandler XSetIOErrorHandler(XIOErrorHandler handler); + virtual Window do_DefaultRootWindow(Display* display); + virtual int XCloseDisplay(Display* display); + virtual int XTestGrabControl(Display* display, Bool impervious); + virtual void XDestroyIC(XIC ic); + virtual Status XCloseIM(XIM im); + virtual int XDestroyWindow(Display* display, Window w); + virtual int XGetKeyboardControl(Display* display, + XKeyboardState* value_return); + virtual int XMoveWindow(Display* display, Window w, int x, int y); + virtual int XMapRaised(Display* display, Window w); + virtual void XUnsetICFocus(XIC ic); + virtual int XUnmapWindow(Display* display, Window w); + virtual int XSetInputFocus(Display* display, Window focus, int revert_to, + Time time); + virtual Bool DPMSQueryExtension(Display* display, int* event_base, + int* error_base); + virtual Bool DPMSCapable(Display* display); + virtual Status DPMSInfo(Display* display, CARD16* power_level, BOOL* state); + virtual Status DPMSForceLevel(Display* display, CARD16 level); + virtual int XGetInputFocus(Display* display, Window* focus_return, + int* revert_to_return); + virtual void XSetICFocus(XIC ic); + virtual Bool XQueryPointer(Display* display, Window w, Window* root_return, + Window* child_return, int* root_x_return, + int* root_y_return, int* win_x_return, + int* win_y_return, unsigned int* mask_return); + virtual void XLockDisplay(Display* display); + virtual Bool XCheckMaskEvent(Display* display, long event_mask, + XEvent* event_return); + virtual XModifierKeymap* XGetModifierMapping(Display* display); + virtual int XGrabKey(Display* display, int keycode, unsigned int modifiers, + Window grab_window, int owner_events, int pointer_made, + int keyboard_mode); + virtual int XFreeModifiermap(XModifierKeymap* modmap); + virtual int XUngrabKey(Display* display, int keycode, + unsigned int modifiers, Window grab_window); + virtual int XTestFakeButtonEvent(Display* display, unsigned int button, + int is_press, unsigned long delay); + virtual int XFlush(Display* display); + virtual int XWarpPointer(Display* display, Window src_w, Window dest_w, + int src_x, int src_y, + unsigned int src_width, unsigned int src_height, + int dest_x, int dest_y); + virtual int XTestFakeRelativeMotionEvent(Display* display, int x, int y, + unsigned long delay); + virtual KeyCode XKeysymToKeycode(Display* display, KeySym keysym); + virtual int XTestFakeKeyEvent(Display* display, unsigned int keycode, + int is_press, unsigned long delay); + virtual Display* XOpenDisplay(_Xconst char* display_name); + virtual Bool XQueryExtension(Display* display, const char* name, + int* major_opcode_return, + int* first_event_return, + int* first_error_return); + virtual Bool XkbLibraryVersion(int* libMajorRtrn, int* libMinorRtrn); + virtual Bool XkbQueryExtension(Display* display, int* opcodeReturn, + int* eventBaseReturn, int* errorBaseReturn, + int* majorRtrn, int* minorRtrn); + virtual Bool XkbSelectEvents(Display* display, unsigned int deviceID, + unsigned int affect, unsigned int values); + virtual Bool XkbSelectEventDetails(Display* display, unsigned int deviceID, + unsigned int eventType, + unsigned long affect, + unsigned long details); + virtual Bool XRRQueryExtension(Display* display, int* event_base_return, + int* error_base_return); + virtual void XRRSelectInput(Display *display, Window window, int mask); + virtual Bool XineramaQueryExtension(Display* display, int* event_base, + int* error_base); + virtual Bool XineramaIsActive(Display* display); + virtual void* XineramaQueryScreens(Display* display, int* number); + virtual Window XCreateWindow(Display* display, Window parent, int x, int y, + unsigned int width, unsigned int height, + unsigned int border_width, int depth, + unsigned int klass, Visual* visual, + unsigned long valuemask, + XSetWindowAttributes* attributes); + virtual XIM XOpenIM(Display* display, _XrmHashBucketRec* rdb, + char* res_name, char* res_class); + virtual char* XGetIMValues(XIM im, const char* type, void* ptr); + virtual XIC XCreateIC(XIM im, const char* type1, unsigned long data1, + const char* type2, unsigned long data2); + virtual char* XGetICValues(XIC ic, const char* type, unsigned long* mask); + virtual Status XGetWindowAttributes(Display* display, Window w, + XWindowAttributes* attrs); + virtual int XSelectInput(Display* display, Window w, long event_mask); + virtual Bool XCheckIfEvent(Display* display, XEvent* event, + Bool (*predicate)(Display *, XEvent *, XPointer), + XPointer arg); + virtual Bool XFilterEvent(XEvent* event, Window window); + virtual Bool XGetEventData(Display* display, + XGenericEventCookie* cookie); + virtual void XFreeEventData(Display* display, + XGenericEventCookie* cookie); + virtual int XDeleteProperty(Display* display, Window w, Atom property); + virtual int XResizeWindow(Display* display, Window w, unsigned int width, + unsigned int height); + virtual int XMaskEvent(Display* display, long event_mask, + XEvent* event_return); + virtual Status XQueryBestCursor(Display* display, Drawable d, + unsigned int width, unsigned int height, + unsigned int* width_return, + unsigned int* height_return); + virtual Pixmap XCreateBitmapFromData(Display* display, Drawable d, + const char* data, unsigned int width, + unsigned int height); + virtual Cursor XCreatePixmapCursor(Display* display, + Pixmap source, Pixmap mask, + XColor* foreground_color, + XColor* background_color, + unsigned int x, unsigned int y); + virtual int XFreePixmap(Display* display, Pixmap pixmap); + virtual Status XQueryTree(Display* display, Window w, Window* root_return, + Window* parent_return, Window** children_return, + unsigned int* nchildren_return); + virtual int XmbLookupString(XIC ic, XKeyPressedEvent* event, + char* buffer_return, int bytes_buffer, + KeySym* keysym_return, int* status_return); + virtual int XLookupString(XKeyEvent* event_struct, char* buffer_return, + int bytes_buffer, KeySym* keysym_return, + XComposeStatus* status_in_out); + virtual Status XSendEvent(Display* display, Window w, Bool propagate, + long event_mask, XEvent* event_send); + virtual int XSync(Display* display, Bool discard); + virtual int XGetPointerMapping(Display* display, unsigned char* map_return, + int nmap); + virtual int XGrabKeyboard(Display* display, Window grab_window, + Bool owner_events, int pointer_mode, + int keyboard_mode, Time time); + virtual int XGrabPointer(Display* display, Window grab_window, + Bool owner_events, unsigned int event_mask, + int pointer_mode, int keyboard_mode, + Window confine_to, Cursor cursor, Time time); + virtual int XUngrabKeyboard(Display* display, Time time); + virtual int XPending(Display* display); + virtual int XPeekEvent(Display* display, XEvent* event_return); + virtual Status XkbRefreshKeyboardMapping(XkbMapNotifyEvent* event); + virtual int XRefreshKeyboardMapping(XMappingEvent* event_map); + virtual int XISelectEvents(Display* display, Window w, XIEventMask* masks, + int num_masks); + virtual Atom XInternAtom(Display* display, _Xconst char* atom_name, + Bool only_if_exists); + virtual int XGetScreenSaver(Display* display, int* timeout_return, + int* interval_return, + int* prefer_blanking_return, + int* allow_exposures_return); + virtual int XSetScreenSaver(Display* display, int timeout, int interval, + int prefer_blanking, int allow_exposures); + virtual int XForceScreenSaver(Display* display, int mode); + virtual int XFree(void* data); + virtual Status DPMSEnable(Display* display); + virtual Status DPMSDisable(Display* display); + virtual int XSetSelectionOwner(Display* display, Atom selection, Window w, + Time time); + virtual Window XGetSelectionOwner(Display* display, Atom selection); + virtual Atom* XListProperties(Display* display, Window w, + int* num_prop_return); + virtual char* XGetAtomName(Display* display, Atom atom); + virtual void XkbFreeKeyboard(XkbDescPtr xkb, unsigned int which, + Bool freeDesc); + virtual XkbDescPtr XkbGetMap(Display* display, unsigned int which, + unsigned int deviceSpec); + virtual Status XkbGetState(Display* display, unsigned int deviceSet, + XkbStatePtr rtrnState); + virtual int XQueryKeymap(Display* display, char keys_return[32]); + virtual Status XkbGetUpdatedMap(Display* display, unsigned int which, + XkbDescPtr desc); + virtual Bool XkbLockGroup(Display* display, unsigned int deviceSpec, + unsigned int group); + virtual int XDisplayKeycodes(Display* display, int* min_keycodes_return, + int* max_keycodes_return); + virtual KeySym* XGetKeyboardMapping(Display* display, + unsigned int first_keycode, + int keycode_count, + int* keysyms_per_keycode_return); + virtual int do_XkbKeyNumGroups(XkbDescPtr m_xkb, KeyCode desc); + virtual XkbKeyTypePtr do_XkbKeyKeyType(XkbDescPtr m_xkb, KeyCode keycode, + int eGroup); + virtual KeySym do_XkbKeySymEntry(XkbDescPtr m_xkb, KeyCode keycode, + int level, int eGroup); + virtual Bool do_XkbKeyHasActions(XkbDescPtr m_xkb, KeyCode keycode); + virtual XkbAction* do_XkbKeyActionEntry(XkbDescPtr m_xkb, KeyCode keycode, + int level, int eGroup); + virtual unsigned char do_XkbKeyGroupInfo(XkbDescPtr m_xkb, + KeyCode keycode); + virtual int XNextEvent(Display* display, XEvent* event_return); +}; diff --git a/src/lib/platform/XWindowsKeyState.cpp b/src/lib/platform/XWindowsKeyState.cpp index 1ca4629..37fd5e8 100644 --- a/src/lib/platform/XWindowsKeyState.cpp +++ b/src/lib/platform/XWindowsKeyState.cpp @@ -40,23 +40,26 @@ static const size_t ModifiersFromXDefaultSize = 32; -XWindowsKeyState::XWindowsKeyState( +XWindowsKeyState::XWindowsKeyState(IXWindowsImpl* impl, Display* display, bool useXKB, IEventQueue* events) : KeyState(events), m_display(display), m_modifierFromX(ModifiersFromXDefaultSize) { + m_impl = impl; + init(display, useXKB); } -XWindowsKeyState::XWindowsKeyState( +XWindowsKeyState::XWindowsKeyState(IXWindowsImpl* impl, Display* display, bool useXKB, IEventQueue* events, barrier::KeyMap& keyMap) : KeyState(events, keyMap), m_display(display), m_modifierFromX(ModifiersFromXDefaultSize) { + m_impl = impl; init(display, useXKB); } @@ -64,7 +67,7 @@ XWindowsKeyState::~XWindowsKeyState() { #if HAVE_XKB_EXTENSION if (m_xkb != NULL) { - XkbFreeKeyboard(m_xkb, 0, True); + m_impl->XkbFreeKeyboard(m_xkb, 0, True); } #endif } @@ -75,8 +78,9 @@ XWindowsKeyState::init(Display* display, bool useXKB) XGetKeyboardControl(m_display, &m_keyboardState); #if HAVE_XKB_EXTENSION if (useXKB) { - m_xkb = XkbGetMap(m_display, XkbKeyActionsMask | XkbKeyBehaviorsMask | - XkbAllClientInfoMask, XkbUseCoreKbd); + m_xkb = m_impl->XkbGetMap(m_display, + XkbKeyActionsMask | XkbKeyBehaviorsMask | + XkbAllClientInfoMask, XkbUseCoreKbd); } else { m_xkb = NULL; @@ -177,8 +181,9 @@ XWindowsKeyState::pollActiveModifiers() const Window root = DefaultRootWindow(m_display), window; int xRoot, yRoot, xWindow, yWindow; unsigned int state = 0; - if (XQueryPointer(m_display, root, &root, &window, - &xRoot, &yRoot, &xWindow, &yWindow, &state) == False) { + if (m_impl->XQueryPointer(m_display, root, &root, &window, + &xRoot, &yRoot, &xWindow, &yWindow, &state + ) == False) { state = 0; } return mapModifiersFromX(state); @@ -195,7 +200,7 @@ XWindowsKeyState::pollActiveGroup() const #if HAVE_XKB_EXTENSION if (m_xkb != NULL) { XkbStateRec state; - if (XkbGetState(m_display, XkbUseCoreKbd, &state) == Success) { + if (m_impl->XkbGetState(m_display, XkbUseCoreKbd, &state) == Success) { return state.group; } } @@ -207,7 +212,7 @@ void XWindowsKeyState::pollPressedKeys(KeyButtonSet& pressedKeys) const { char keys[32]; - XQueryKeymap(m_display, keys); + m_impl->XQueryKeymap(m_display, keys); for (UInt32 i = 0; i < 32; ++i) { for (UInt32 j = 0; j < 8; ++j) { if ((keys[i] & (1u << j)) != 0) { @@ -228,8 +233,9 @@ XWindowsKeyState::getKeyMap(barrier::KeyMap& keyMap) #if HAVE_XKB_EXTENSION if (m_xkb != NULL) { - if (XkbGetUpdatedMap(m_display, XkbKeyActionsMask | - XkbKeyBehaviorsMask | XkbAllClientInfoMask, m_xkb) == Success) { + unsigned mask = XkbKeyActionsMask | XkbKeyBehaviorsMask | + XkbAllClientInfoMask; + if (m_impl->XkbGetUpdatedMap(m_display, mask, m_xkb) == Success) { updateKeysymMapXKB(keyMap); return; } @@ -254,9 +260,9 @@ XWindowsKeyState::fakeKey(const Keystroke& keystroke) break; } } - XTestFakeKeyEvent(m_display, keystroke.m_data.m_button.m_button, - keystroke.m_data.m_button.m_press ? True : False, - CurrentTime); + m_impl->XTestFakeKeyEvent(m_display, keystroke.m_data.m_button.m_button, + keystroke.m_data.m_button.m_press, + CurrentTime); break; case Keystroke::kGroup: @@ -264,8 +270,9 @@ XWindowsKeyState::fakeKey(const Keystroke& keystroke) LOG((CLOG_DEBUG1 " group %d", keystroke.m_data.m_group.m_group)); #if HAVE_XKB_EXTENSION if (m_xkb != NULL) { - if (XkbLockGroup(m_display, XkbUseCoreKbd, - keystroke.m_data.m_group.m_group) == False) { + if (m_impl->XkbLockGroup(m_display, XkbUseCoreKbd, + keystroke.m_data.m_group.m_group + ) == False) { LOG((CLOG_DEBUG1 "XkbLockGroup request not sent")); } } @@ -279,9 +286,10 @@ XWindowsKeyState::fakeKey(const Keystroke& keystroke) LOG((CLOG_DEBUG1 " group %+d", keystroke.m_data.m_group.m_group)); #if HAVE_XKB_EXTENSION if (m_xkb != NULL) { - if (XkbLockGroup(m_display, XkbUseCoreKbd, - getEffectiveGroup(pollActiveGroup(), - keystroke.m_data.m_group.m_group)) == False) { + if (m_impl->XkbLockGroup(m_display, XkbUseCoreKbd, + getEffectiveGroup(pollActiveGroup(), + keystroke.m_data.m_group.m_group) + ) == False) { LOG((CLOG_DEBUG1 "XkbLockGroup request not sent")); } } @@ -320,14 +328,14 @@ XWindowsKeyState::updateKeysymMap(barrier::KeyMap& keyMap) // get the number of keycodes int minKeycode, maxKeycode; - XDisplayKeycodes(m_display, &minKeycode, &maxKeycode); + m_impl->XDisplayKeycodes(m_display, &minKeycode, &maxKeycode); int numKeycodes = maxKeycode - minKeycode + 1; // get the keyboard mapping for all keys int keysymsPerKeycode; - KeySym* allKeysyms = XGetKeyboardMapping(m_display, - minKeycode, numKeycodes, - &keysymsPerKeycode); + KeySym* allKeysyms = m_impl->XGetKeyboardMapping(m_display, + minKeycode, numKeycodes, + &keysymsPerKeycode); // it's more convenient to always have maxKeysyms KeySyms per key { @@ -343,7 +351,7 @@ XWindowsKeyState::updateKeysymMap(barrier::KeyMap& keyMap) } } } - XFree(allKeysyms); + m_impl->XFree(allKeysyms); allKeysyms = tmpKeysyms; } @@ -365,7 +373,7 @@ XWindowsKeyState::updateKeysymMap(barrier::KeyMap& keyMap) // going to ignore all KeySyms except the first modifier KeySym, // which means button 1 above won't map to Meta, just Alt. std::map<KeyCode, unsigned int> modifierButtons; - XModifierKeymap* modifiers = XGetModifierMapping(m_display); + XModifierKeymap* modifiers = m_impl->XGetModifierMapping(m_display); for (unsigned int i = 0; i < 8; ++i) { const KeyCode* buttons = modifiers->modifiermap + i * modifiers->max_keypermod; @@ -560,7 +568,7 @@ XWindowsKeyState::updateKeysymMapXKB(barrier::KeyMap& keyMap) // find the number of groups int maxNumGroups = 0; for (int i = m_xkb->min_key_code; i <= m_xkb->max_key_code; ++i) { - int numGroups = XkbKeyNumGroups(m_xkb, static_cast<KeyCode>(i)); + int numGroups = m_impl->do_XkbKeyNumGroups(m_xkb, static_cast<KeyCode>(i)); if (numGroups > maxNumGroups) { maxNumGroups = numGroups; } @@ -596,7 +604,7 @@ XWindowsKeyState::updateKeysymMapXKB(barrier::KeyMap& keyMap) item.m_client = 0; // skip keys with no groups (they generate no symbols) - if (XkbKeyNumGroups(m_xkb, keycode) == 0) { + if (m_impl->do_XkbKeyNumGroups(m_xkb, keycode) == 0) { continue; } @@ -612,7 +620,8 @@ XWindowsKeyState::updateKeysymMapXKB(barrier::KeyMap& keyMap) int eGroup = getEffectiveGroup(keycode, group); // get key info - XkbKeyTypePtr type = XkbKeyKeyType(m_xkb, keycode, eGroup); + XkbKeyTypePtr type = m_impl->do_XkbKeyKeyType(m_xkb, keycode, + eGroup); // set modifiers the item is sensitive to item.m_sensitive = type->mods.mask; @@ -641,16 +650,18 @@ XWindowsKeyState::updateKeysymMapXKB(barrier::KeyMap& keyMap) } // get the keysym for this item - KeySym keysym = XkbKeySymEntry(m_xkb, keycode, level, eGroup); + KeySym keysym = m_impl->do_XkbKeySymEntry(m_xkb, keycode, level, + eGroup); // check for group change actions, locking modifiers, and // modifier masks. item.m_lock = false; bool isModifier = false; UInt32 modifierMask = m_xkb->map->modmap[keycode]; - if (XkbKeyHasActions(m_xkb, keycode) == True) { + if (m_impl->do_XkbKeyHasActions(m_xkb, keycode) == True) { XkbAction* action = - XkbKeyActionEntry(m_xkb, keycode, level, eGroup); + m_impl->do_XkbKeyActionEntry(m_xkb, keycode, level, + eGroup); if (action->type == XkbSA_SetMods || action->type == XkbSA_LockMods) { isModifier = true; @@ -799,19 +810,19 @@ XWindowsKeyState::hasModifiersXKB() const // iterate over all keycodes for (int i = m_xkb->min_key_code; i <= m_xkb->max_key_code; ++i) { KeyCode keycode = static_cast<KeyCode>(i); - if (XkbKeyHasActions(m_xkb, keycode) == True) { + if (m_impl->do_XkbKeyHasActions(m_xkb, keycode) == True) { // iterate over all groups - int numGroups = XkbKeyNumGroups(m_xkb, keycode); + int numGroups = m_impl->do_XkbKeyNumGroups(m_xkb, keycode); for (int group = 0; group < numGroups; ++group) { // iterate over all shift levels for the button (including none) - XkbKeyTypePtr type = XkbKeyKeyType(m_xkb, keycode, group); + XkbKeyTypePtr type = m_impl->do_XkbKeyKeyType(m_xkb, keycode, group); for (int j = -1; j < type->map_count; ++j) { if (j != -1 && !type->map[j].active) { continue; } int level = ((j == -1) ? 0 : type->map[j].level); XkbAction* action = - XkbKeyActionEntry(m_xkb, keycode, level, group); + m_impl->do_XkbKeyActionEntry(m_xkb, keycode, level, group); if (action->type == XkbSA_SetMods || action->type == XkbSA_LockMods) { return true; @@ -830,9 +841,9 @@ XWindowsKeyState::getEffectiveGroup(KeyCode keycode, int group) const (void)keycode; #if HAVE_XKB_EXTENSION // get effective group for key - int numGroups = XkbKeyNumGroups(m_xkb, keycode); + int numGroups = m_impl->do_XkbKeyNumGroups(m_xkb, keycode); if (group >= numGroups) { - unsigned char groupInfo = XkbKeyGroupInfo(m_xkb, keycode); + unsigned char groupInfo = m_impl->do_XkbKeyGroupInfo(m_xkb, keycode); switch (XkbOutOfRangeGroupAction(groupInfo)) { case XkbClampIntoRange: group = numGroups - 1; diff --git a/src/lib/platform/XWindowsKeyState.h b/src/lib/platform/XWindowsKeyState.h index f3c0a1e..f42f7ac 100644 --- a/src/lib/platform/XWindowsKeyState.h +++ b/src/lib/platform/XWindowsKeyState.h @@ -21,6 +21,7 @@ #include "barrier/KeyState.h" #include "common/stdmap.h" #include "common/stdvector.h" +#include "XWindowsImpl.h" #if X_DISPLAY_MISSING # error X11 is required to build barrier @@ -50,9 +51,10 @@ public: kGroupPollAndSet = -2 }; - XWindowsKeyState(Display*, bool useXKB, IEventQueue* events); - XWindowsKeyState(Display*, bool useXKB, - IEventQueue* events, barrier::KeyMap& keyMap); + XWindowsKeyState(IXWindowsImpl* impl, Display*, bool useXKB, + IEventQueue* events); + XWindowsKeyState(IXWindowsImpl* impl, Display*, bool useXKB, + IEventQueue* events, barrier::KeyMap& keyMap); ~XWindowsKeyState(); //! @name modifiers @@ -145,6 +147,8 @@ private: typedef std::map<KeyCode, unsigned int> NonXKBModifierMap; typedef std::map<UInt32, XKBModifierInfo> XKBModifierMap; + IXWindowsImpl* m_impl; + Display* m_display; #if HAVE_XKB_EXTENSION XkbDescPtr m_xkb; diff --git a/src/lib/platform/XWindowsScreen.cpp b/src/lib/platform/XWindowsScreen.cpp index 2846412..5f6c623 100644 --- a/src/lib/platform/XWindowsScreen.cpp +++ b/src/lib/platform/XWindowsScreen.cpp @@ -37,40 +37,6 @@ #include <cstring> #include <cstdlib> #include <algorithm> -#if X_DISPLAY_MISSING -# error X11 is required to build barrier -#else -# include <X11/X.h> -# include <X11/Xutil.h> -# define XK_MISCELLANY -# define XK_XKB_KEYS -# include <X11/keysymdef.h> -# if HAVE_X11_EXTENSIONS_DPMS_H - extern "C" { -# include <X11/extensions/dpms.h> - } -# endif -# if HAVE_X11_EXTENSIONS_XTEST_H -# include <X11/extensions/XTest.h> -# else -# error The XTest extension is required to build barrier -# endif -# if HAVE_X11_EXTENSIONS_XINERAMA_H - // Xinerama.h may lack extern "C" for inclusion by C++ - extern "C" { -# include <X11/extensions/Xinerama.h> - } -# endif -# if HAVE_X11_EXTENSIONS_XRANDR_H -# include <X11/extensions/Xrandr.h> -# endif -# if HAVE_XKB_EXTENSION -# include <X11/XKBlib.h> -# endif -# ifdef HAVE_XI2 -# include <X11/extensions/XInput2.h> -# endif -#endif static int xi_opcode; @@ -92,6 +58,7 @@ static int xi_opcode; XWindowsScreen* XWindowsScreen::s_screen = NULL; XWindowsScreen::XWindowsScreen( + IXWindowsImpl* impl, const char* displayName, bool isPrimary, bool disableXInitThreads, @@ -125,6 +92,7 @@ XWindowsScreen::XWindowsScreen( m_events(events), PlatformScreen(events) { + m_impl = impl; assert(s_screen == NULL); if (mouseScrollDelta==0) m_mouseScrollDelta=120; @@ -132,32 +100,33 @@ XWindowsScreen::XWindowsScreen( if (!disableXInitThreads) { // initializes Xlib support for concurrent threads. - if (XInitThreads() == 0) + if (m_impl->XInitThreads() == 0) throw XArch("XInitThreads() returned zero"); } else { LOG((CLOG_DEBUG "skipping XInitThreads()")); } // set the X I/O error handler so we catch the display disconnecting - XSetIOErrorHandler(&XWindowsScreen::ioErrorHandler); + m_impl->XSetIOErrorHandler(&XWindowsScreen::ioErrorHandler); try { m_display = openDisplay(displayName); - m_root = DefaultRootWindow(m_display); + m_root = m_impl->do_DefaultRootWindow(m_display); saveShape(); m_window = openWindow(); - m_screensaver = new XWindowsScreenSaver(m_display, + m_screensaver = new XWindowsScreenSaver(m_impl, m_display, m_window, getEventTarget(), events); - m_keyState = new XWindowsKeyState(m_display, m_xkb, events, m_keyMap); + m_keyState = new XWindowsKeyState(m_impl, m_display, m_xkb, events, + m_keyMap); LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_xinerama ? "(xinerama)" : "")); LOG((CLOG_DEBUG "window is 0x%08x", m_window)); } catch (...) { if (m_display != NULL) { - XCloseDisplay(m_display); + m_impl->XCloseDisplay(m_display); } throw; - } + } // primary/secondary screen only initialization if (m_isPrimary) { @@ -177,12 +146,12 @@ XWindowsScreen::XWindowsScreen( } else { // become impervious to server grabs - XTestGrabControl(m_display, True); + m_impl->XTestGrabControl(m_display, True); } // initialize the clipboards for (ClipboardID id = 0; id < kClipboardEnd; ++id) { - m_clipboard[id] = new XWindowsClipboard(m_display, m_window, id); + m_clipboard[id] = new XWindowsClipboard(m_impl, m_display, m_window, id); } // install event handlers @@ -191,7 +160,7 @@ XWindowsScreen::XWindowsScreen( &XWindowsScreen::handleSystemEvent)); // install the platform event queue - m_events->adoptBuffer(new XWindowsEventQueueBuffer( + m_events->adoptBuffer(new XWindowsEventQueueBuffer(m_impl, m_display, m_window, m_events)); } @@ -205,24 +174,25 @@ XWindowsScreen::~XWindowsScreen() for (ClipboardID id = 0; id < kClipboardEnd; ++id) { delete m_clipboard[id]; } - delete m_keyState; + delete m_keyState; delete m_screensaver; m_keyState = NULL; m_screensaver = NULL; if (m_display != NULL) { // FIXME -- is it safe to clean up the IC and IM without a display? if (m_ic != NULL) { - XDestroyIC(m_ic); + m_impl->XDestroyIC(m_ic); } if (m_im != NULL) { - XCloseIM(m_im); + m_impl->XCloseIM(m_im); } - XDestroyWindow(m_display, m_window); - XCloseDisplay(m_display); + m_impl->XDestroyWindow(m_display, m_window); + m_impl->XCloseDisplay(m_display); } - XSetIOErrorHandler(NULL); + m_impl->XSetIOErrorHandler(NULL); s_screen = NULL; + delete m_impl; } void @@ -231,16 +201,16 @@ XWindowsScreen::enable() if (!m_isPrimary) { // get the keyboard control state XKeyboardState keyControl; - XGetKeyboardControl(m_display, &keyControl); + m_impl->XGetKeyboardControl(m_display, &keyControl); m_autoRepeat = (keyControl.global_auto_repeat == AutoRepeatModeOn); m_keyState->setAutoRepeat(keyControl); // move hider window under the cursor center - XMoveWindow(m_display, m_window, m_xCenter, m_yCenter); + m_impl->XMoveWindow(m_display, m_window, m_xCenter, m_yCenter); // raise and show the window // FIXME -- take focus? - XMapRaised(m_display, m_window); + m_impl->XMapRaised(m_display, m_window); // warp the mouse to the cursor center fakeMouseMove(m_xCenter, m_yCenter); @@ -252,12 +222,12 @@ XWindowsScreen::disable() { // release input context focus if (m_ic != NULL) { - XUnsetICFocus(m_ic); + m_impl->XUnsetICFocus(m_ic); } // unmap the hider/grab window. this also ungrabs the mouse and // keyboard if they're grabbed. - XUnmapWindow(m_display, m_window); + m_impl->XUnmapWindow(m_display, m_window); // restore auto-repeat state if (!m_isPrimary && m_autoRepeat) { @@ -272,14 +242,14 @@ XWindowsScreen::enter() // release input context focus if (m_ic != NULL) { - XUnsetICFocus(m_ic); + m_impl->XUnsetICFocus(m_ic); } // set the input focus to what it had been when we took it if (m_lastFocus != None) { // the window may not exist anymore so ignore errors XWindowsUtil::ErrorLock lock(m_display); - XSetInputFocus(m_display, m_lastFocus, m_lastFocusRevert, CurrentTime); + m_impl->XSetInputFocus(m_display, m_lastFocus, m_lastFocusRevert, CurrentTime); } #if HAVE_X11_EXTENSIONS_DPMS_H @@ -288,18 +258,18 @@ XWindowsScreen::enter() int dummy; CARD16 powerlevel; BOOL enabled; - if (DPMSQueryExtension(m_display, &dummy, &dummy) && - DPMSCapable(m_display) && - DPMSInfo(m_display, &powerlevel, &enabled)) + if (m_impl->DPMSQueryExtension(m_display, &dummy, &dummy) && + m_impl->DPMSCapable(m_display) && + m_impl->DPMSInfo(m_display, &powerlevel, &enabled)) { if (enabled && powerlevel != DPMSModeOn) - DPMSForceLevel(m_display, DPMSModeOn); + m_impl->DPMSForceLevel(m_display, DPMSModeOn); } #endif // unmap the hider/grab window. this also ungrabs the mouse and // keyboard if they're grabbed. - XUnmapWindow(m_display, m_window); + m_impl->XUnmapWindow(m_display, m_window); /* maybe call this if entering for the screensaver // set keyboard focus to root window. the screensaver should then @@ -310,7 +280,7 @@ XWindowsScreen::enter() if (!m_isPrimary) { // get the keyboard control state XKeyboardState keyControl; - XGetKeyboardControl(m_display, &keyControl); + m_impl->XGetKeyboardControl(m_display, &keyControl); m_autoRepeat = (keyControl.global_auto_repeat == AutoRepeatModeOn); m_keyState->setAutoRepeat(keyControl); @@ -338,24 +308,24 @@ XWindowsScreen::leave() } // move hider window under the cursor center - XMoveWindow(m_display, m_window, m_xCenter, m_yCenter); + m_impl->XMoveWindow(m_display, m_window, m_xCenter, m_yCenter); } // raise and show the window - XMapRaised(m_display, m_window); + m_impl->XMapRaised(m_display, m_window); // grab the mouse and keyboard, if primary and possible if (m_isPrimary && !grabMouseAndKeyboard()) { - XUnmapWindow(m_display, m_window); + m_impl->XUnmapWindow(m_display, m_window); return false; } // save current focus - XGetInputFocus(m_display, &m_lastFocus, &m_lastFocusRevert); + m_impl->XGetInputFocus(m_display, &m_lastFocus, &m_lastFocusRevert); // take focus if (m_isPrimary || !m_preserveFocus) { - XSetInputFocus(m_display, m_window, RevertToPointerRoot, CurrentTime); + m_impl->XSetInputFocus(m_display, m_window, RevertToPointerRoot, CurrentTime); } // now warp the mouse. we warp after showing the window so we're @@ -371,7 +341,7 @@ XWindowsScreen::leave() // set input context focus to our window if (m_ic != NULL) { XmbResetIC(m_ic); - XSetICFocus(m_ic); + m_impl->XSetICFocus(m_ic); m_filtered.clear(); } @@ -515,7 +485,7 @@ XWindowsScreen::getCursorPos(SInt32& x, SInt32& y) const Window root, window; int mx, my, xWindow, yWindow; unsigned int mask; - if (XQueryPointer(m_display, m_root, &root, &window, + if (m_impl->XQueryPointer(m_display, m_root, &root, &window, &mx, &my, &xWindow, &yWindow, &mask)) { x = mx; y = my; @@ -540,7 +510,7 @@ XWindowsScreen::warpCursor(SInt32 x, SInt32 y) // remove all input events before and including warp XEvent event; - while (XCheckMaskEvent(m_display, PointerMotionMask | + while (m_impl->XCheckMaskEvent(m_display, PointerMotionMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask | KeymapStateMask, @@ -609,7 +579,7 @@ XWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) KeyModifierSuper }; - XModifierKeymap* modKeymap = XGetModifierMapping(m_display); + XModifierKeymap* modKeymap = m_impl->XGetModifierMapping(m_display); for (size_t j = 0; j < sizeof(s_hotKeyModifiers) / sizeof(s_hotKeyModifiers[0]) && !err; ++j) { // skip modifier if not in mask @@ -672,7 +642,7 @@ XWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) for (int k = 0; k < modKeymap->max_keypermod && !err; ++k) { KeyCode code = modifiermap[k]; if (modifiermap[k] != 0) { - XGrabKey(m_display, code, modifiers2, m_root, + m_impl->XGrabKey(m_display, code, modifiers2, m_root, False, GrabModeAsync, GrabModeAsync); if (!err) { hotKeys.push_back(std::make_pair(code, modifiers2)); @@ -681,7 +651,7 @@ XWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) } } } - XFreeModifiermap(modKeymap); + m_impl->XFreeModifiermap(modKeymap); } // a non-modifier key must be insensitive to CapsLock, NumLock and @@ -719,7 +689,7 @@ XWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) } // add grab - XGrabKey(m_display, *j, tmpModifiers, m_root, + m_impl->XGrabKey(m_display, *j, tmpModifiers, m_root, False, GrabModeAsync, GrabModeAsync); if (!err) { hotKeys.push_back(std::make_pair(*j, tmpModifiers)); @@ -734,7 +704,7 @@ XWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) // if any failed then unregister any we did get for (HotKeyList::iterator j = hotKeys.begin(); j != hotKeys.end(); ++j) { - XUngrabKey(m_display, j->first, j->second, m_root); + m_impl->XUngrabKey(m_display, j->first, j->second, m_root); m_hotKeyToIDMap.erase(HotKeyItem(j->first, j->second)); } @@ -764,7 +734,7 @@ XWindowsScreen::unregisterHotKey(UInt32 id) HotKeyList& hotKeys = i->second; for (HotKeyList::iterator j = hotKeys.begin(); j != hotKeys.end(); ++j) { - XUngrabKey(m_display, j->first, j->second, m_root); + m_impl->XUngrabKey(m_display, j->first, j->second, m_root); m_hotKeyToIDMap.erase(HotKeyItem(j->first, j->second)); } } @@ -805,7 +775,7 @@ XWindowsScreen::isAnyMouseButtonDown(UInt32& buttonID) const Window root, window; int xRoot, yRoot, xWindow, yWindow; unsigned int state; - if (XQueryPointer(m_display, m_root, &root, &window, + if (m_impl->XQueryPointer(m_display, m_root, &root, &window, &xRoot, &yRoot, &xWindow, &yWindow, &state)) { return ((state & (Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask)) != 0); @@ -826,9 +796,9 @@ XWindowsScreen::fakeMouseButton(ButtonID button, bool press) { const unsigned int xButton = mapButtonToX(button); if (xButton > 0 && xButton < 11) { - XTestFakeButtonEvent(m_display, xButton, + m_impl->XTestFakeButtonEvent(m_display, xButton, press ? True : False, CurrentTime); - XFlush(m_display); + m_impl->XFlush(m_display); } } @@ -836,13 +806,13 @@ void XWindowsScreen::fakeMouseMove(SInt32 x, SInt32 y) { if (m_xinerama && m_xtestIsXineramaUnaware) { - XWarpPointer(m_display, None, m_root, 0, 0, 0, 0, x, y); + m_impl->XWarpPointer(m_display, None, m_root, 0, 0, 0, 0, x, y); } else { XTestFakeMotionEvent(m_display, DefaultScreen(m_display), x, y, CurrentTime); } - XFlush(m_display); + m_impl->XFlush(m_display); } void @@ -850,12 +820,12 @@ XWindowsScreen::fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const { // FIXME -- ignore xinerama for now if (false && m_xinerama && m_xtestIsXineramaUnaware) { -// XWarpPointer(m_display, None, m_root, 0, 0, 0, 0, x, y); +// m_impl->XWarpPointer(m_display, None, m_root, 0, 0, 0, 0, x, y); } else { - XTestFakeRelativeMotionEvent(m_display, dx, dy, CurrentTime); + m_impl->XTestFakeRelativeMotionEvent(m_display, dx, dy, CurrentTime); } - XFlush(m_display); + m_impl->XFlush(m_display); } void @@ -877,14 +847,14 @@ XWindowsScreen::fakeMouseWheel(SInt32, SInt32 yDelta) const // Patch by Tom Chadwick. KeyCode keycode = 0; if (yDelta >= 0) { - keycode = XKeysymToKeycode(m_display, XK_Page_Up); + keycode = m_impl->XKeysymToKeycode(m_display, XK_Page_Up); } else { - keycode = XKeysymToKeycode(m_display, XK_Page_Down); + keycode = m_impl->XKeysymToKeycode(m_display, XK_Page_Down); } if (keycode != 0) { - XTestFakeKeyEvent(m_display, keycode, True, CurrentTime); - XTestFakeKeyEvent(m_display, keycode, False, CurrentTime); + m_impl->XTestFakeKeyEvent(m_display, keycode, True, CurrentTime); + m_impl->XTestFakeKeyEvent(m_display, keycode, False, CurrentTime); } return; } @@ -893,11 +863,11 @@ XWindowsScreen::fakeMouseWheel(SInt32, SInt32 yDelta) const // send as many clicks as necessary for (; numEvents > 0; numEvents--) { - XTestFakeButtonEvent(m_display, xButton, True, CurrentTime); - XTestFakeButtonEvent(m_display, xButton, False, CurrentTime); + m_impl->XTestFakeButtonEvent(m_display, xButton, True, CurrentTime); + m_impl->XTestFakeButtonEvent(m_display, xButton, False, CurrentTime); } - XFlush(m_display); + m_impl->XFlush(m_display); } Display* @@ -913,7 +883,7 @@ XWindowsScreen::openDisplay(const char* displayName) // open the display LOG((CLOG_DEBUG "XOpenDisplay(\"%s\")", displayName)); - Display* display = XOpenDisplay(displayName); + Display* display = m_impl->XOpenDisplay(displayName); if (display == NULL) { throw XScreenUnavailable(60.0); } @@ -921,10 +891,10 @@ XWindowsScreen::openDisplay(const char* displayName) // verify the availability of the XTest extension if (!m_isPrimary) { int majorOpcode, firstEvent, firstError; - if (!XQueryExtension(display, XTestExtensionName, + if (!m_impl->XQueryExtension(display, XTestExtensionName, &majorOpcode, &firstEvent, &firstError)) { LOG((CLOG_ERR "XTEST extension not available")); - XCloseDisplay(display); + m_impl->XCloseDisplay(display); throw XScreenOpenFailure(); } } @@ -933,14 +903,14 @@ XWindowsScreen::openDisplay(const char* displayName) { m_xkb = false; int major = XkbMajorVersion, minor = XkbMinorVersion; - if (XkbLibraryVersion(&major, &minor)) { + if (m_impl->XkbLibraryVersion(&major, &minor)) { int opcode, firstError; - if (XkbQueryExtension(display, &opcode, &m_xkbEventBase, + if (m_impl->XkbQueryExtension(display, &opcode, &m_xkbEventBase, &firstError, &major, &minor)) { m_xkb = true; - XkbSelectEvents(display, XkbUseCoreKbd, + m_impl->XkbSelectEvents(display, XkbUseCoreKbd, XkbMapNotifyMask, XkbMapNotifyMask); - XkbSelectEventDetails(display, XkbUseCoreKbd, + m_impl->XkbSelectEventDetails(display, XkbUseCoreKbd, XkbStateNotifyMask, XkbGroupStateMask, XkbGroupStateMask); } @@ -951,10 +921,10 @@ XWindowsScreen::openDisplay(const char* displayName) #if HAVE_X11_EXTENSIONS_XRANDR_H // query for XRandR extension int dummyError; - m_xrandr = XRRQueryExtension(display, &m_xrandrEventBase, &dummyError); + m_xrandr = m_impl->XRRQueryExtension(display, &m_xrandrEventBase, &dummyError); if (m_xrandr) { // enable XRRScreenChangeNotifyEvent - XRRSelectInput(display, DefaultRootWindow(display), RRScreenChangeNotifyMask | RRCrtcChangeNotifyMask); + m_impl->XRRSelectInput(display, DefaultRootWindow(display), RRScreenChangeNotifyMask | RRCrtcChangeNotifyMask); } #endif @@ -991,11 +961,13 @@ XWindowsScreen::saveShape() m_xinerama = false; #if HAVE_X11_EXTENSIONS_XINERAMA_H int eventBase, errorBase; - if (XineramaQueryExtension(m_display, &eventBase, &errorBase) && - XineramaIsActive(m_display)) { + if (m_impl->XineramaQueryExtension(m_display, &eventBase, &errorBase) && + m_impl->XineramaIsActive(m_display)) { int numScreens; XineramaScreenInfo* screens; - screens = XineramaQueryScreens(m_display, &numScreens); + screens = reinterpret_cast<XineramaScreenInfo*>( + XineramaQueryScreens(m_display, &numScreens)); + if (screens != NULL) { if (numScreens > 1) { m_xinerama = true; @@ -1049,7 +1021,7 @@ XWindowsScreen::openWindow() const } // create and return the window - Window window = XCreateWindow(m_display, m_root, x, y, w, h, 0, 0, + Window window = m_impl->XCreateWindow(m_display, m_root, x, y, w, h, 0, 0, InputOnly, CopyFromParent, CWDontPropagate | CWEventMask | CWOverrideRedirect | CWCursor, @@ -1064,7 +1036,7 @@ void XWindowsScreen::openIM() { // open the input methods - XIM im = XOpenIM(m_display, NULL, NULL, NULL); + XIM im = m_impl->XOpenIM(m_display, NULL, NULL, NULL); if (im == NULL) { LOG((CLOG_INFO "no support for IM")); return; @@ -1073,10 +1045,10 @@ XWindowsScreen::openIM() // find the appropriate style. barrier supports XIMPreeditNothing // only at the moment. XIMStyles* styles; - if (XGetIMValues(im, XNQueryInputStyle, &styles, NULL) != NULL || + if (m_impl->XGetIMValues(im, XNQueryInputStyle, &styles) != nullptr || styles == NULL) { LOG((CLOG_WARN "cannot get IM styles")); - XCloseIM(im); + m_impl->XCloseIM(im); return; } XIMStyle style = 0; @@ -1091,24 +1063,24 @@ XWindowsScreen::openIM() XFree(styles); if (style == 0) { LOG((CLOG_INFO "no supported IM styles")); - XCloseIM(im); + m_impl->XCloseIM(im); return; } // create an input context for the style and tell it about our window - XIC ic = XCreateIC(im, XNInputStyle, style, XNClientWindow, m_window, NULL); + XIC ic = m_impl->XCreateIC(im, XNInputStyle, style, XNClientWindow, m_window); if (ic == NULL) { LOG((CLOG_WARN "cannot create IC")); - XCloseIM(im); + m_impl->XCloseIM(im); return; } // find out the events we must select for and do so unsigned long mask; - if (XGetICValues(ic, XNFilterEvents, &mask, NULL) != NULL) { + if (m_impl->XGetICValues(ic, XNFilterEvents, &mask) != NULL) { LOG((CLOG_WARN "cannot get IC filter events")); - XDestroyIC(ic); - XCloseIM(im); + m_impl->XDestroyIC(ic); + m_impl->XCloseIM(im); return; } @@ -1119,8 +1091,8 @@ XWindowsScreen::openIM() // select events on our window that IM requires XWindowAttributes attr; - XGetWindowAttributes(m_display, m_window, &attr); - XSelectInput(m_display, m_window, attr.your_event_mask | mask); + m_impl->XGetWindowAttributes(m_display, m_window, &attr); + m_impl->XSelectInput(m_display, m_window, attr.your_event_mask | mask); } void @@ -1174,7 +1146,7 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*) filter.m_time = xevent->xkey.time; filter.m_keycode = xevent->xkey.keycode; XEvent xevent2; - isRepeat = (XCheckIfEvent(m_display, &xevent2, + isRepeat = (m_impl->XCheckIfEvent(m_display, &xevent2, &XWindowsScreen::findKeyEvent, (XPointer)&filter) == True); } @@ -1219,7 +1191,7 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*) } // now filter the event - if (XFilterEvent(xevent, DefaultRootWindow(m_display))) { + if (m_impl->XFilterEvent(xevent, DefaultRootWindow(m_display))) { if (xevent->type == KeyPress) { // add filtered presses to the filtered list m_filtered.insert(m_lastKeycode); @@ -1246,7 +1218,7 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*) if (m_xi2detected) { // Process RawMotion XGenericEventCookie *cookie = (XGenericEventCookie*)&xevent->xcookie; - if (XGetEventData(m_display, cookie) && + if (m_impl->XGetEventData(m_display, cookie) && cookie->type == GenericEvent && cookie->extension == xi_opcode) { if (cookie->evtype == XI_RawMotion) { @@ -1259,7 +1231,7 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*) xmotion.window = m_window; /* xmotion's time, state and is_hint are not used */ unsigned int msk; - xmotion.same_screen = XQueryPointer( + xmotion.same_screen = m_impl->XQueryPointer( m_display, m_root, &xmotion.root, &xmotion.subwindow, &xmotion.x_root, &xmotion.y_root, @@ -1267,10 +1239,10 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*) &xmotion.y, &msk); onMouseMove(xmotion); - XFreeEventData(m_display, cookie); + m_impl->XFreeEventData(m_display, cookie); return; } - XFreeEventData(m_display, cookie); + m_impl->XFreeEventData(m_display, cookie); } } #endif @@ -1291,7 +1263,7 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*) case LeaveNotify: if (!m_isPrimary) { // mouse moved out of hider window somehow. hide the window. - XUnmapWindow(m_display, m_window); + m_impl->XUnmapWindow(m_display, m_window); } break; @@ -1315,7 +1287,7 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*) // retrieval methods. we'll just delete the property // with the data (satisfying the usual ICCCM protocol). if (xevent->xselection.property != None) { - XDeleteProperty(m_display, + m_impl->XDeleteProperty(m_display, xevent->xselection.requestor, xevent->xselection.property); } @@ -1417,8 +1389,8 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*) // off the server onto the client causes the pointer to warp to the // center of the server (so you can't move the pointer off the server) if (m_isPrimary) { - XMoveWindow(m_display, m_window, m_x, m_y); - XResizeWindow(m_display, m_window, m_w, m_h); + m_impl->XMoveWindow(m_display, m_window, m_x, m_y); + m_impl->XResizeWindow(m_display, m_window, m_w, m_h); } sendEvent(m_events->forIScreen().shapeChanged()); @@ -1594,7 +1566,7 @@ XWindowsScreen::onMouseMove(const XMotionEvent& xmotion) XEvent xevent; char cntr = 0; do { - XMaskEvent(m_display, PointerMotionMask, &xevent); + m_impl->XMaskEvent(m_display, PointerMotionMask, &xevent); if (cntr++ > 10) { LOG((CLOG_WARN "too many discarded events! %d", cntr)); break; @@ -1656,7 +1628,7 @@ XWindowsScreen::createBlankCursor() const // get the closet cursor size to 1x1 unsigned int w = 0, h = 0; - XQueryBestCursor(m_display, m_root, 1, 1, &w, &h); + m_impl->XQueryBestCursor(m_display, m_root, 1, 1, &w, &h); w = std::max(1u, w); h = std::max(1u, h); @@ -1668,7 +1640,7 @@ XWindowsScreen::createBlankCursor() const memset(data, 0, size); // make bitmap - Pixmap bitmap = XCreateBitmapFromData(m_display, m_root, data, w, h); + Pixmap bitmap = m_impl->XCreateBitmapFromData(m_display, m_root, data, w, h); // need an arbitrary color for the cursor XColor color; @@ -1677,12 +1649,12 @@ XWindowsScreen::createBlankCursor() const color.flags = DoRed | DoGreen | DoBlue; // make cursor from bitmap - Cursor cursor = XCreatePixmapCursor(m_display, bitmap, bitmap, + Cursor cursor = m_impl->XCreatePixmapCursor(m_display, bitmap, bitmap, &color, &color, 0, 0); // don't need bitmap or the data anymore delete[] data; - XFreePixmap(m_display, bitmap); + m_impl->XFreePixmap(m_display, bitmap); return cursor; } @@ -1794,7 +1766,7 @@ XWindowsScreen::doSelectEvents(Window w) const // it already. long mask = SubstructureNotifyMask; XWindowAttributes attr; - XGetWindowAttributes(m_display, w, &attr); + m_impl->XGetWindowAttributes(m_display, w, &attr); if ((attr.all_event_masks & PointerMotionMask) == PointerMotionMask) { mask |= PointerMotionMask; } @@ -1802,12 +1774,12 @@ XWindowsScreen::doSelectEvents(Window w) const // select events of interest. do this before querying the tree so // we'll get notifications of children created after the XQueryTree() // so we won't miss them. - XSelectInput(m_display, w, mask); + m_impl->XSelectInput(m_display, w, mask); // recurse on child windows Window rw, pw, *cw; unsigned int nc; - if (XQueryTree(m_display, w, &rw, &pw, &cw, &nc)) { + if (m_impl->XQueryTree(m_display, w, &rw, &pw, &cw, &nc)) { for (unsigned int i = 0; i < nc; ++i) { doSelectEvents(cw[i]); } @@ -1827,11 +1799,11 @@ XWindowsScreen::mapKeyFromX(XKeyEvent* event) const int n = sizeof(scratch) / sizeof(scratch[0]); char* buffer = scratch; int status; - n = XmbLookupString(m_ic, event, buffer, n, &keysym, &status); + n = m_impl->XmbLookupString(m_ic, event, buffer, n, &keysym, &status); if (status == XBufferOverflow) { // not enough space. grow buffer and try again. buffer = new char[n]; - n = XmbLookupString(m_ic, event, buffer, n, &keysym, &status); + n = m_impl->XmbLookupString(m_ic, event, buffer, n, &keysym, &status); delete[] buffer; } @@ -1852,7 +1824,7 @@ XWindowsScreen::mapKeyFromX(XKeyEvent* event) const else { // plain old lookup char dummy[1]; - XLookupString(event, dummy, 0, &keysym, NULL); + m_impl->XLookupString(event, dummy, 0, &keysym, NULL); } LOG((CLOG_DEBUG2 "mapped code=%d to keysym=0x%04x", event->keycode, keysym)); @@ -1935,14 +1907,14 @@ XWindowsScreen::warpCursorNoFlush(SInt32 x, SInt32 y) eventBefore.xmotion.is_hint = NotifyNormal; eventBefore.xmotion.same_screen = True; XEvent eventAfter = eventBefore; - XSendEvent(m_display, m_window, False, 0, &eventBefore); + m_impl->XSendEvent(m_display, m_window, False, 0, &eventBefore); // warp mouse - XWarpPointer(m_display, None, m_root, 0, 0, 0, 0, x, y); + m_impl->XWarpPointer(m_display, None, m_root, 0, 0, 0, 0, x, y); // send an event that we can recognize after the mouse warp - XSendEvent(m_display, m_window, False, 0, &eventAfter); - XSync(m_display, False); + m_impl->XSendEvent(m_display, m_window, False, 0, &eventAfter); + m_impl->XSync(m_display, False); LOG((CLOG_DEBUG2 "warped to %d,%d", x, y)); } @@ -1951,9 +1923,9 @@ void XWindowsScreen::updateButtons() { // query the button mapping - UInt32 numButtons = XGetPointerMapping(m_display, NULL, 0); + UInt32 numButtons = m_impl->XGetPointerMapping(m_display, NULL, 0); unsigned char* tmpButtons = new unsigned char[numButtons]; - XGetPointerMapping(m_display, tmpButtons, numButtons); + m_impl->XGetPointerMapping(m_display, tmpButtons, numButtons); // find the largest logical button id unsigned char maxButton = 0; @@ -1993,7 +1965,7 @@ XWindowsScreen::grabMouseAndKeyboard() do { // keyboard first do { - result = XGrabKeyboard(m_display, m_window, True, + result = m_impl->XGrabKeyboard(m_display, m_window, True, GrabModeAsync, GrabModeAsync, CurrentTime); assert(result != GrabNotViewable); if (result != GrabSuccess) { @@ -2008,13 +1980,13 @@ XWindowsScreen::grabMouseAndKeyboard() LOG((CLOG_DEBUG2 "grabbed keyboard")); // now the mouse --- use event_mask to get EnterNotify, LeaveNotify events - result = XGrabPointer(m_display, m_window, False, event_mask, + result = m_impl->XGrabPointer(m_display, m_window, False, event_mask, GrabModeAsync, GrabModeAsync, m_window, None, CurrentTime); assert(result != GrabNotViewable); if (result != GrabSuccess) { // back off to avoid grab deadlock - XUngrabKeyboard(m_display, CurrentTime); + m_impl->XUngrabKeyboard(m_display, CurrentTime); LOG((CLOG_DEBUG2 "ungrabbed keyboard, waiting to grab pointer")); ARCH->sleep(0.05); if (timer.getTime() >= s_timeout) { @@ -2031,9 +2003,9 @@ XWindowsScreen::grabMouseAndKeyboard() void XWindowsScreen::refreshKeyboard(XEvent* event) { - if (XPending(m_display) > 0) { + if (m_impl->XPending(m_display) > 0) { XEvent tmpEvent; - XPeekEvent(m_display, &tmpEvent); + m_impl->XPeekEvent(m_display, &tmpEvent); if (tmpEvent.type == MappingNotify) { // discard this event since another follows. // we tend to get a bunch of these in a row. @@ -2044,12 +2016,12 @@ XWindowsScreen::refreshKeyboard(XEvent* event) // keyboard mapping changed #if HAVE_XKB_EXTENSION if (m_xkb && event->type == m_xkbEventBase) { - XkbRefreshKeyboardMapping((XkbMapNotifyEvent*)event); + m_impl->XkbRefreshKeyboardMapping((XkbMapNotifyEvent*)event); } else #else { - XRefreshKeyboardMapping(&event->xmapping); + m_impl->XRefreshKeyboardMapping(&event->xmapping); } #endif m_keyState->updateKeyMap(); @@ -2079,7 +2051,7 @@ bool XWindowsScreen::detectXI2() { int event, error; - return XQueryExtension(m_display, + return m_impl->XQueryExtension(m_display, "XInputExtension", &xi_opcode, &event, &error); } @@ -2096,7 +2068,7 @@ XWindowsScreen::selectXIRawMotion() memset(mask.mask, 0, 2); XISetMask(mask.mask, XI_RawKeyRelease); XISetMask(mask.mask, XI_RawMotion); - XISelectEvents(m_display, DefaultRootWindow(m_display), &mask, 1); + m_impl->XISelectEvents(m_display, DefaultRootWindow(m_display), &mask, 1); free(mask.mask); } #endif diff --git a/src/lib/platform/XWindowsScreen.h b/src/lib/platform/XWindowsScreen.h index a2e3495..7134017 100644 --- a/src/lib/platform/XWindowsScreen.h +++ b/src/lib/platform/XWindowsScreen.h @@ -22,6 +22,7 @@ #include "barrier/KeyMap.h" #include "common/stdset.h" #include "common/stdvector.h" +#include "XWindowsImpl.h" #if X_DISPLAY_MISSING # error X11 is required to build barrier @@ -36,7 +37,7 @@ class XWindowsScreenSaver; //! Implementation of IPlatformScreen for X11 class XWindowsScreen : public PlatformScreen { public: - XWindowsScreen(const char* displayName, bool isPrimary, + XWindowsScreen(IXWindowsImpl* impl, const char* displayName, bool isPrimary, bool disableXInitThreads, int mouseScrollDelta, IEventQueue* events); virtual ~XWindowsScreen(); @@ -174,6 +175,8 @@ private: typedef std::vector<UInt32> HotKeyIDList; typedef std::map<HotKeyItem, UInt32> HotKeyToIDMap; + IXWindowsImpl* m_impl; + // true if screen is being used as a primary screen, false otherwise bool m_isPrimary; diff --git a/src/lib/platform/XWindowsScreenSaver.cpp b/src/lib/platform/XWindowsScreenSaver.cpp index bc457f9..5c4ef91 100644 --- a/src/lib/platform/XWindowsScreenSaver.cpp +++ b/src/lib/platform/XWindowsScreenSaver.cpp @@ -58,8 +58,9 @@ extern Status DPMSInfo(Display *, CARD16 *, BOOL *); // XWindowsScreenSaver // -XWindowsScreenSaver::XWindowsScreenSaver( - Display* display, Window window, void* eventTarget, IEventQueue* events) : +XWindowsScreenSaver::XWindowsScreenSaver(IXWindowsImpl* impl, Display* display, + Window window, void* eventTarget, + IEventQueue* events) : m_display(display), m_xscreensaverSink(window), m_eventTarget(eventTarget), @@ -72,22 +73,23 @@ XWindowsScreenSaver::XWindowsScreenSaver( m_disablePos(0), m_events(events) { + m_impl = impl; // get atoms - m_atomScreenSaver = XInternAtom(m_display, - "SCREENSAVER", False); - m_atomScreenSaverVersion = XInternAtom(m_display, - "_SCREENSAVER_VERSION", False); - m_atomScreenSaverActivate = XInternAtom(m_display, - "ACTIVATE", False); - m_atomScreenSaverDeactivate = XInternAtom(m_display, - "DEACTIVATE", False); + m_atomScreenSaver = m_impl->XInternAtom(m_display, "SCREENSAVER", False); + m_atomScreenSaverVersion = m_impl->XInternAtom(m_display, + "_SCREENSAVER_VERSION", + False); + m_atomScreenSaverActivate = m_impl->XInternAtom(m_display, "ACTIVATE", + False); + m_atomScreenSaverDeactivate = m_impl->XInternAtom(m_display, "DEACTIVATE", + False); // check for DPMS extension. this is an alternative screen saver // that powers down the display. #if HAVE_X11_EXTENSIONS_DPMS_H int eventBase, errorBase; - if (DPMSQueryExtension(m_display, &eventBase, &errorBase)) { - if (DPMSCapable(m_display)) { + if (m_impl->DPMSQueryExtension(m_display, &eventBase, &errorBase)) { + if (m_impl->DPMSCapable(m_display)) { // we have DPMS m_dpms = true; } @@ -98,11 +100,12 @@ XWindowsScreenSaver::XWindowsScreenSaver( bool error = false; { XWindowsUtil::ErrorLock lock(m_display, &error); - Window root = DefaultRootWindow(m_display); + Window root = m_impl->do_DefaultRootWindow(m_display); XWindowAttributes attr; - XGetWindowAttributes(m_display, root, &attr); + m_impl->XGetWindowAttributes(m_display, root, &attr); m_rootEventMask = attr.your_event_mask; - XSelectInput(m_display, root, m_rootEventMask | SubstructureNotifyMask); + m_impl->XSelectInput(m_display, root, + m_rootEventMask | SubstructureNotifyMask); } if (error) { LOG((CLOG_DEBUG "didn't set root event mask")); @@ -110,8 +113,8 @@ XWindowsScreenSaver::XWindowsScreenSaver( } // get the built-in settings - XGetScreenSaver(m_display, &m_timeout, &m_interval, - &m_preferBlanking, &m_allowExposures); + m_impl->XGetScreenSaver(m_display, &m_timeout, &m_interval, + &m_preferBlanking, &m_allowExposures); // get the DPMS settings m_dpmsEnabled = isDPMSEnabled(); @@ -137,11 +140,12 @@ XWindowsScreenSaver::~XWindowsScreenSaver() if (m_display != NULL) { enableDPMS(m_dpmsEnabled); - XSetScreenSaver(m_display, m_timeout, m_interval, - m_preferBlanking, m_allowExposures); + m_impl->XSetScreenSaver(m_display, m_timeout, m_interval, + m_preferBlanking, m_allowExposures); clearWatchForXScreenSaver(); XWindowsUtil::ErrorLock lock(m_display); - XSelectInput(m_display, DefaultRootWindow(m_display), m_rootEventMask); + m_impl->XSelectInput(m_display, DefaultRootWindow(m_display), + m_rootEventMask); } } @@ -221,8 +225,8 @@ XWindowsScreenSaver::enable() updateDisableTimer(); // for built-in X screen saver - XSetScreenSaver(m_display, m_timeout, m_interval, - m_preferBlanking, m_allowExposures); + m_impl->XSetScreenSaver(m_display, m_timeout, m_interval, m_preferBlanking, + m_allowExposures); // for DPMS enableDPMS(m_dpmsEnabled); @@ -236,10 +240,10 @@ XWindowsScreenSaver::disable() updateDisableTimer(); // use built-in X screen saver - XGetScreenSaver(m_display, &m_timeout, &m_interval, - &m_preferBlanking, &m_allowExposures); - XSetScreenSaver(m_display, 0, m_interval, - m_preferBlanking, m_allowExposures); + m_impl->XGetScreenSaver(m_display, &m_timeout, &m_interval, + &m_preferBlanking, &m_allowExposures); + m_impl->XSetScreenSaver(m_display, 0, m_interval, m_preferBlanking, + m_allowExposures); // for DPMS m_dpmsEnabled = isDPMSEnabled(); @@ -267,7 +271,7 @@ XWindowsScreenSaver::activate() // try built-in X screen saver if (m_timeout != 0) { - XForceScreenSaver(m_display, ScreenSaverActive); + m_impl->XForceScreenSaver(m_display, ScreenSaverActive); } // try DPMS @@ -297,7 +301,7 @@ XWindowsScreenSaver::deactivate() } // use built-in X screen saver - XForceScreenSaver(m_display, ScreenSaverReset); + m_impl->XForceScreenSaver(m_display, ScreenSaverReset); } bool @@ -326,14 +330,14 @@ XWindowsScreenSaver::findXScreenSaver() Window root = DefaultRootWindow(m_display); Window rw, pw, *cw; unsigned int nc; - if (XQueryTree(m_display, root, &rw, &pw, &cw, &nc)) { + if (m_impl->XQueryTree(m_display, root, &rw, &pw, &cw, &nc)) { for (unsigned int i = 0; i < nc; ++i) { if (isXScreenSaver(cw[i])) { setXScreenSaver(cw[i]); break; } } - XFree(cw); + m_impl->XFree(cw); } } @@ -357,7 +361,7 @@ XWindowsScreenSaver::setXScreenSaver(Window window) XWindowAttributes attr; { XWindowsUtil::ErrorLock lock(m_display, &error); - XGetWindowAttributes(m_display, m_xscreensaver, &attr); + m_impl->XGetWindowAttributes(m_display, m_xscreensaver, &attr); } setXScreenSaverActive(!error && attr.map_state != IsUnmapped); @@ -430,7 +434,7 @@ XWindowsScreenSaver::sendXScreenSaverCommand(Atom cmd, long arg1, long arg2) bool error = false; { XWindowsUtil::ErrorLock lock(m_display, &error); - XSendEvent(m_display, m_xscreensaver, False, 0, &event); + m_impl->XSendEvent(m_display, m_xscreensaver, False, 0, &event); } if (error) { findXScreenSaver(); @@ -447,11 +451,11 @@ XWindowsScreenSaver::watchForXScreenSaver() Window root = DefaultRootWindow(m_display); Window rw, pw, *cw; unsigned int nc; - if (XQueryTree(m_display, root, &rw, &pw, &cw, &nc)) { + if (m_impl->XQueryTree(m_display, root, &rw, &pw, &cw, &nc)) { for (unsigned int i = 0; i < nc; ++i) { addWatchXScreenSaver(cw[i]); } - XFree(cw); + m_impl->XFree(cw); } // now check for xscreensaver window in case it set the property @@ -469,7 +473,7 @@ XWindowsScreenSaver::clearWatchForXScreenSaver() XWindowsUtil::ErrorLock lock(m_display); for (WatchList::iterator index = m_watchWindows.begin(); index != m_watchWindows.end(); ++index) { - XSelectInput(m_display, index->first, index->second); + m_impl->XSelectInput(m_display, index->first, index->second); } m_watchWindows.clear(); } @@ -482,7 +486,7 @@ XWindowsScreenSaver::addWatchXScreenSaver(Window window) XWindowAttributes attr; { XWindowsUtil::ErrorLock lock(m_display, &error); - XGetWindowAttributes(m_display, window, &attr); + m_impl->XGetWindowAttributes(m_display, window, &attr); } // if successful and window uses override_redirect (like xscreensaver @@ -491,8 +495,8 @@ XWindowsScreenSaver::addWatchXScreenSaver(Window window) error = false; { XWindowsUtil::ErrorLock lock(m_display, &error); - XSelectInput(m_display, window, - attr.your_event_mask | PropertyChangeMask); + m_impl->XSelectInput(m_display, window, + attr.your_event_mask | PropertyChangeMask); } if (!error) { // if successful then add the window to our list @@ -535,7 +539,7 @@ XWindowsScreenSaver::handleDisableTimer(const Event&, void*) event.xmotion.same_screen = True; XWindowsUtil::ErrorLock lock(m_display); - XSendEvent(m_display, m_xscreensaver, False, 0, &event); + m_impl->XSendEvent(m_display, m_xscreensaver, False, 0, &event); m_disablePos = 20 - m_disablePos; } @@ -548,7 +552,8 @@ XWindowsScreenSaver::activateDPMS(bool activate) if (m_dpms) { // DPMSForceLevel will generate a BadMatch if DPMS is disabled XWindowsUtil::ErrorLock lock(m_display); - DPMSForceLevel(m_display, activate ? DPMSModeStandby : DPMSModeOn); + m_impl->DPMSForceLevel(m_display, + activate ? DPMSModeStandby : DPMSModeOn); } #endif } @@ -559,10 +564,10 @@ XWindowsScreenSaver::enableDPMS(bool enable) #if HAVE_X11_EXTENSIONS_DPMS_H if (m_dpms) { if (enable) { - DPMSEnable(m_display); + m_impl->DPMSEnable(m_display); } else { - DPMSDisable(m_display); + m_impl->DPMSDisable(m_display); } } #endif @@ -575,7 +580,7 @@ XWindowsScreenSaver::isDPMSEnabled() const if (m_dpms) { CARD16 level; BOOL state; - DPMSInfo(m_display, &level, &state); + m_impl->DPMSInfo(m_display, &level, &state); return (state != False); } else { @@ -593,7 +598,7 @@ XWindowsScreenSaver::isDPMSActivated() const if (m_dpms) { CARD16 level; BOOL state; - DPMSInfo(m_display, &level, &state); + m_impl->DPMSInfo(m_display, &level, &state); return (level != DPMSModeOn); } else { diff --git a/src/lib/platform/XWindowsScreenSaver.h b/src/lib/platform/XWindowsScreenSaver.h index db85f41..1761db2 100644 --- a/src/lib/platform/XWindowsScreenSaver.h +++ b/src/lib/platform/XWindowsScreenSaver.h @@ -21,6 +21,7 @@ #include "barrier/IScreenSaver.h" #include "base/IEventQueue.h" #include "common/stdmap.h" +#include "XWindowsImpl.h" #if X_DISPLAY_MISSING # error X11 is required to build barrier @@ -34,7 +35,8 @@ class EventQueueTimer; //! X11 screen saver implementation class XWindowsScreenSaver : public IScreenSaver { public: - XWindowsScreenSaver(Display*, Window, void* eventTarget, IEventQueue* events); + XWindowsScreenSaver(IXWindowsImpl* impl, Display*, Window, + void* eventTarget, IEventQueue* events); virtual ~XWindowsScreenSaver(); //! @name manipulators @@ -112,6 +114,8 @@ private: private: typedef std::map<Window, long> WatchList; + IXWindowsImpl* m_impl; + // the X display Display* m_display; diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 32153a6..12aedd0 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -2262,6 +2262,10 @@ Server::forceLeaveClient(BaseClientProxy* client) m_primaryClient->enter(m_x, m_y, m_seqNum, m_primaryClient->getToggleMask(), false); } + + Server::SwitchToScreenInfo* info = + Server::SwitchToScreenInfo::alloc(m_active->getName()); + m_events->addEvent(Event(m_events->forServer().screenSwitched(), this, info)); } // if this screen had the cursor when the screen saver activated |
