Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"permissions": {
"allow": [
"Bash(rg:*)",
"Bash(g++:*)",
"Bash(cmake:*)",
"Bash(sudo apt:*)",
"Bash(sudo apt install:*)"
],
"deny": []
}
}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

cmake_minimum_required (VERSION 3.4)
cmake_minimum_required (VERSION 3.5)
project (barrier C CXX)

option (BARRIER_BUILD_GUI "Build the GUI" ON)
Expand Down
265 changes: 265 additions & 0 deletions COMPILATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
# Barrier Linux Compilation Guide

## Exact Steps Performed (What We Actually Did)

This section documents the exact sequence of commands and fixes applied to successfully build Barrier on WSL2/Ubuntu.

### 1. Fixed CMake Version Requirements
Updated minimum CMake version from 3.4 to 3.5 in three files:

**File 1:** `CMakeLists.txt` (line 18)
```cmake
# Changed from:
cmake_minimum_required (VERSION 3.4)
# To:
cmake_minimum_required (VERSION 3.5)
```

**File 2:** `cmake/Version.cmake` (line 1)
```cmake
# Changed from:
cmake_minimum_required (VERSION 3.4)
# To:
cmake_minimum_required (VERSION 3.5)
```

**File 3:** `src/gui/CMakeLists.txt` (line 1)
```cmake
# Changed from:
cmake_minimum_required (VERSION 3.4)
# To:
cmake_minimum_required (VERSION 3.5)
```

### 2. Installed Dependencies
```bash
sudo apt install -y libcurl4-openssl-dev qtbase5-dev qttools5-dev-tools libssl-dev libx11-dev libxtst-dev libxinerama-dev libxss-dev libxi-dev libxrandr-dev libavahi-compat-libdnssd-dev
```

### 3. Fixed Missing Headers
**File 1:** `src/lib/base/String.h`
Added missing header after line 25:
```cpp
#include <stdarg.h>
#include <vector>
#include <cstdint> // ADDED THIS LINE
```

**File 2:** `src/lib/net/FingerprintData.h`
Added missing header after line 22:
```cpp
#include <string>
#include <vector>
#include <cstdint> // ADDED THIS LINE
```

### 4. Build
```bash
cd "/mnt/c/D Drive/CAPTAIN/CodeProjects/barrier"
./clean_build.sh
```

### 5. Verify Build Output
```bash
ls -la "/mnt/c/D Drive/CAPTAIN/CodeProjects/barrier/build/bin/"
```
**Files created:**
- `barriers` (12,709,936 bytes) - Server executable
- `barrierc` (10,165,752 bytes) - Client executable
- `integtests` (20,092,176 bytes) - Integration tests
- `unittests` (15,227,792 bytes) - Unit tests

### 6. Test Functionality
```bash
cd "/mnt/c/D Drive/CAPTAIN/CodeProjects/barrier/build/bin"
./barrierc <server-ip>
```
**Result:** βœ… Successfully connected to server

---

## General Compilation Guide

### Prerequisites

#### System Requirements
- Ubuntu/Debian-based Linux distribution
- CMake 4.0+ (installed via snap)
- GCC 13.3.0
- Git

#### Required Dependencies

Install the following packages:

```bash
sudo apt update
sudo apt install -y \
libcurl4-openssl-dev \
qtbase5-dev \
qttools5-dev-tools \
libssl-dev \
libx11-dev \
libxtst-dev \
libxinerama-dev \
libxss-dev \
libxi-dev \
libxrandr-dev \
libavahi-compat-libdnssd-dev
```

**Note on Package Names:**
- Use `qtbase5-dev` instead of the deprecated `qt5-default`
- Use `libavahi-compat-libdnssd-dev` instead of `avahi-compat-libdns_sd-dev`

### Source Code Fixes Required

The original Barrier source code requires several fixes to compile with modern toolchains:

#### 1. CMake Minimum Version Updates

**Files to modify:**
- `CMakeLists.txt` (line 18)
- `cmake/Version.cmake` (line 1)
- `src/gui/CMakeLists.txt` (line 1)

**Change:**
```cmake
# FROM:
cmake_minimum_required (VERSION 3.4)

# TO:
cmake_minimum_required (VERSION 3.5)
```

**Reason:** CMake 4.0+ no longer supports compatibility with CMake < 3.5

#### 2. Missing C++ Headers

**File:** `src/lib/base/String.h`

**Add after existing includes:**
```cpp
#include <stdarg.h>
#include <vector>
#include <cstdint> // ADD THIS LINE
```

**File:** `src/lib/net/FingerprintData.h`

**Add after existing includes:**
```cpp
#include <string>
#include <vector>
#include <cstdint> // ADD THIS LINE
```

**Reason:** Modern C++ compilers require explicit inclusion of `<cstdint>` for `std::uint8_t` types

### Compilation Process

#### 1. Clone and Navigate
```bash
git clone <barrier-repo-url>
cd barrier
```

#### 2. Initialize Submodules
```bash
git submodule update --init --recursive
```

#### 3. Apply Source Code Fixes
Apply all the fixes mentioned in the "Source Code Fixes Required" section above.

#### 4. Build
```bash
./clean_build.sh
```

**Alternative manual build:**
```bash
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
```

### Build Output

#### Successful Build Results
- **Location:** `build/bin/`
- **Core executables:**
- `barriers` (~12.7MB) - Server component
- `barrierc` (~10.2MB) - Client component
- `barrier` - GUI application (if Qt build completes)
- `integtests` - Integration tests
- `unittests` - Unit tests

#### Expected Warnings
- OpenSSL deprecation warnings (non-critical)
- CMake compatibility warnings (non-critical)
- Clock skew warnings in WSL (non-critical)

### Usage

#### Server Mode
```bash
cd build/bin
./barriers
```

#### Client Mode
```bash
cd build/bin
./barrierc <server-ip-address>
```

#### GUI Mode (if available)
```bash
cd build/bin
./barrier
```

### Troubleshooting

#### Common Issues

1. **Missing Qt5**: Install `qtbase5-dev` instead of `qt5-default`
2. **Missing Avahi**: Use `libavahi-compat-libdnssd-dev` package name
3. **uint8_t errors**: Add `#include <cstdint>` to header files
4. **CMake version errors**: Update minimum version requirements to 3.5
5. **CURL not found**: Install `libcurl4-openssl-dev`

#### Build Environment Notes
- **WSL Users**: No GUI display available by default
- **X11 Required**: For actual mouse/keyboard sharing functionality
- **Network**: Ensure firewall allows Barrier traffic (default port 24800)

### Platform-Specific Notes

#### Windows Build (Alternative)
If building on Windows instead of Linux:
- Requires Visual Studio 2019/2022
- Requires Qt 5.11.1 at `C:\Qt\5.11.1\msvc2017_64`
- Requires Bonjour SDK at `C:\Program Files\Bonjour SDK`
- Use `clean_build.bat` instead of `clean_build.sh`

#### Linux Desktop Environment
For full functionality, Barrier requires:
- X11 or Wayland display server
- Desktop environment (GNOME, KDE, etc.)
- Proper graphics drivers

### Version Information
- **Barrier Version:** 2.4.0
- **Build System:** CMake + Make
- **Compiler:** GCC 13.3.0
- **Target Platform:** Linux x86_64

### Summary of Changes Made
1. Updated CMake minimum version requirements (3 files)
2. Added missing `#include <cstdint>` headers (2 files)
3. Installed correct Linux development packages
4. Used appropriate package names for Ubuntu 24.04+

This guide should enable successful compilation of Barrier on modern Linux systems.
48 changes: 48 additions & 0 deletions GRAVE_MODIFIER_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Grave Modifier Setup for Barrier

## Overview
This implementation adds support for using the grave key (`) as a hotkey modifier in Barrier, similar to Control, Alt, and Shift.

## Required Setup

### 1. Code Changes
The following code changes have been implemented:

- **XWindowsUtil.cpp**: Added `case XK_grave: return kKeyModifierBitGrave;` to `getModifierBitForKeySym()`
- **XWindowsKeyState.cpp**: Added fallback mapping for grave modifier to Mod4 in `updateKeysymMapXKB()`
- **key_types.cpp**: Already included grave modifier in `kModifierNameMap`

### 2. X11 Modifier Mapping (REQUIRED)
The grave key must be mapped to an X11 modifier for hotkeys to work. Run this command:

```bash
xmodmap -e "add mod4 = grave"
```

### 3. Make it Permanent
To make the X11 mapping persistent across reboots, add this line to `~/.xsessionrc`:

```bash
echo 'xmodmap -e "add mod4 = grave"' >> ~/.xsessionrc
```

## Usage
Once setup is complete, you can use grave modifier hotkeys in your Barrier configuration:

```
keystroke(Grave+1) = switchToScreen(screen1,960,540)
keystroke(Grave+2) = switchToScreen(screen2,960,540)
```

## Verification
To verify the setup:

1. Check modifier mapping: `xmodmap -pm`
- Should show `grave (0x31)` in the mod4 line
2. Test hotkeys: Press and hold grave, then press a number key
3. Check Barrier logs for successful hotkey registration

## Troubleshooting
- If hotkeys don't work, verify grave is mapped to mod4: `xmodmap -pm`
- If mapping is lost after reboot, ensure `~/.xsessionrc` contains the xmodmap command
- Restart Barrier server after making X11 mapping changes
2 changes: 1 addition & 1 deletion cmake/Version.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.4)
cmake_minimum_required (VERSION 3.5)

set (BARRIER_VERSION_MAJOR 2)
set (BARRIER_VERSION_MINOR 4)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.4)
cmake_minimum_required (VERSION 3.5)

find_package (Qt5 REQUIRED COMPONENTS Core Widgets Network)
set (CMAKE_AUTOMOC ON)
Expand Down
17 changes: 16 additions & 1 deletion src/gui/src/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ Action::Action() :
m_SwitchDirection(switchLeft),
m_LockCursorMode(lockCursorToggle),
m_ActiveOnRelease(false),
m_HasScreens(false)
m_HasScreens(false),
m_hasCustomPosition(false),
m_customX(0),
m_customY(0)
{
}

Expand Down Expand Up @@ -87,6 +90,12 @@ QString Action::text() const
case switchToScreen:
text += "(";
text += switchScreenName();
if (hasCustomPosition()) {
text += ",";
text += QString::number(customX());
text += ",";
text += QString::number(customY());
}
text += ")";
break;

Expand Down Expand Up @@ -133,6 +142,9 @@ void Action::loadSettings(QSettings& settings)
setLockCursorMode(settings.value("lockCursorToScreen", lockCursorToggle).toInt());
setActiveOnRelease(settings.value("activeOnRelease", false).toBool());
setHaveScreens(settings.value("hasScreens", false).toBool());
setHasCustomPosition(settings.value("hasCustomPosition", false).toBool());
setCustomX(settings.value("customX", 0).toInt());
setCustomY(settings.value("customY", 0).toInt());
}

void Action::saveSettings(QSettings& settings) const
Expand All @@ -153,6 +165,9 @@ void Action::saveSettings(QSettings& settings) const
settings.setValue("lockCursorToScreen", lockCursorMode());
settings.setValue("activeOnRelease", activeOnRelease());
settings.setValue("hasScreens", haveScreens());
settings.setValue("hasCustomPosition", hasCustomPosition());
settings.setValue("customX", customX());
settings.setValue("customY", customY());
}

QTextStream& operator<<(QTextStream& outStream, const Action& action)
Expand Down
Loading