Initial commit: XRandR connects to the server via XCB.
I really need to start two cheatsheets for this: one for CMake, and one for XCB.
This commit is contained in:
commit
59a0c6acbf
|
@ -0,0 +1,10 @@
|
|||
*#
|
||||
.#*
|
||||
*~
|
||||
*.orig
|
||||
build/
|
||||
xrandr
|
||||
cmake_install.cmake
|
||||
CMakeCache.txt
|
||||
CMakeFiles/
|
||||
.ccls-cache/
|
|
@ -0,0 +1,15 @@
|
|||
project("XrandR")
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
|
||||
find_package(ECM REQUIRED NO_MODULE)
|
||||
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
||||
|
||||
find_package(XCB REQUIRED)
|
||||
link_libraries(${XCB_LIBRARIES})
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
|
||||
list(APPEND CMAKE_CXX_FLAGS "${CXXMAKE_C_FLAGS} -std=c++17 -I../src/include/ -g")
|
||||
|
||||
add_executable(xrandr src/xrandr.cpp)
|
||||
|
||||
target_link_libraries(xrandr ${X11_XCB_LIBRARIES})
|
|
@ -0,0 +1,29 @@
|
|||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2016, Ken "Elf" Mathieu Sternberg
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,197 @@
|
|||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.18
|
||||
|
||||
# Default target executed when no arguments are given to make.
|
||||
default_target: all
|
||||
|
||||
.PHONY : default_target
|
||||
|
||||
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
|
||||
.NOTPARALLEL:
|
||||
|
||||
|
||||
#=============================================================================
|
||||
# Special targets provided by cmake.
|
||||
|
||||
# Disable implicit rules so canonical targets will work.
|
||||
.SUFFIXES:
|
||||
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : %,v
|
||||
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : RCS/%
|
||||
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : RCS/%,v
|
||||
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : SCCS/s.%
|
||||
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : s.%
|
||||
|
||||
|
||||
.SUFFIXES: .hpux_make_needs_suffix_list
|
||||
|
||||
|
||||
# Command-line flag to silence nested $(MAKE).
|
||||
$(VERBOSE)MAKESILENT = -s
|
||||
|
||||
#Suppress display of executed commands.
|
||||
$(VERBOSE).SILENT:
|
||||
|
||||
# A target that is always out of date.
|
||||
cmake_force:
|
||||
|
||||
.PHONY : cmake_force
|
||||
|
||||
#=============================================================================
|
||||
# Set environment variables for the build.
|
||||
|
||||
# The shell in which to execute make rules.
|
||||
SHELL = /bin/sh
|
||||
|
||||
# The CMake executable.
|
||||
CMAKE_COMMAND = /usr/bin/cmake
|
||||
|
||||
# The command to remove a file.
|
||||
RM = /usr/bin/cmake -E rm -f
|
||||
|
||||
# Escaping for special characters.
|
||||
EQUALS = =
|
||||
|
||||
# The top-level source directory on which CMake was run.
|
||||
CMAKE_SOURCE_DIR = /home/elf/projects/xrandr-c
|
||||
|
||||
# The top-level build directory on which CMake was run.
|
||||
CMAKE_BINARY_DIR = /home/elf/projects/xrandr-c
|
||||
|
||||
#=============================================================================
|
||||
# Targets provided globally by CMake.
|
||||
|
||||
# Special rule for the target rebuild_cache
|
||||
rebuild_cache:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
|
||||
/usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
||||
.PHONY : rebuild_cache
|
||||
|
||||
# Special rule for the target rebuild_cache
|
||||
rebuild_cache/fast: rebuild_cache
|
||||
|
||||
.PHONY : rebuild_cache/fast
|
||||
|
||||
# Special rule for the target edit_cache
|
||||
edit_cache:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..."
|
||||
/usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
|
||||
.PHONY : edit_cache
|
||||
|
||||
# Special rule for the target edit_cache
|
||||
edit_cache/fast: edit_cache
|
||||
|
||||
.PHONY : edit_cache/fast
|
||||
|
||||
# The main all target
|
||||
all: cmake_check_build_system
|
||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/elf/projects/xrandr-c/CMakeFiles /home/elf/projects/xrandr-c//CMakeFiles/progress.marks
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
|
||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/elf/projects/xrandr-c/CMakeFiles 0
|
||||
.PHONY : all
|
||||
|
||||
# The main clean target
|
||||
clean:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean
|
||||
.PHONY : clean
|
||||
|
||||
# The main clean target
|
||||
clean/fast: clean
|
||||
|
||||
.PHONY : clean/fast
|
||||
|
||||
# Prepare targets for installation.
|
||||
preinstall: all
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
|
||||
.PHONY : preinstall
|
||||
|
||||
# Prepare targets for installation.
|
||||
preinstall/fast:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
|
||||
.PHONY : preinstall/fast
|
||||
|
||||
# clear depends
|
||||
depend:
|
||||
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
|
||||
.PHONY : depend
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named xrandr
|
||||
|
||||
# Build rule for target.
|
||||
xrandr: cmake_check_build_system
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 xrandr
|
||||
.PHONY : xrandr
|
||||
|
||||
# fast build rule for target.
|
||||
xrandr/fast:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/xrandr.dir/build.make CMakeFiles/xrandr.dir/build
|
||||
.PHONY : xrandr/fast
|
||||
|
||||
src/xrandr.o: src/xrandr.cpp.o
|
||||
|
||||
.PHONY : src/xrandr.o
|
||||
|
||||
# target to build an object file
|
||||
src/xrandr.cpp.o:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/xrandr.dir/build.make CMakeFiles/xrandr.dir/src/xrandr.cpp.o
|
||||
.PHONY : src/xrandr.cpp.o
|
||||
|
||||
src/xrandr.i: src/xrandr.cpp.i
|
||||
|
||||
.PHONY : src/xrandr.i
|
||||
|
||||
# target to preprocess a source file
|
||||
src/xrandr.cpp.i:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/xrandr.dir/build.make CMakeFiles/xrandr.dir/src/xrandr.cpp.i
|
||||
.PHONY : src/xrandr.cpp.i
|
||||
|
||||
src/xrandr.s: src/xrandr.cpp.s
|
||||
|
||||
.PHONY : src/xrandr.s
|
||||
|
||||
# target to generate assembly for a file
|
||||
src/xrandr.cpp.s:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/xrandr.dir/build.make CMakeFiles/xrandr.dir/src/xrandr.cpp.s
|
||||
.PHONY : src/xrandr.cpp.s
|
||||
|
||||
# Help Target
|
||||
help:
|
||||
@echo "The following are some of the valid targets for this Makefile:"
|
||||
@echo "... all (the default if no target is provided)"
|
||||
@echo "... clean"
|
||||
@echo "... depend"
|
||||
@echo "... edit_cache"
|
||||
@echo "... rebuild_cache"
|
||||
@echo "... xrandr"
|
||||
@echo "... src/xrandr.o"
|
||||
@echo "... src/xrandr.i"
|
||||
@echo "... src/xrandr.s"
|
||||
.PHONY : help
|
||||
|
||||
|
||||
|
||||
#=============================================================================
|
||||
# Special targets to cleanup operation of make.
|
||||
|
||||
# Special rule to run CMake to check the build system integrity.
|
||||
# No rule that depends on this can have commands that come from listfiles
|
||||
# because they might be regenerated.
|
||||
cmake_check_build_system:
|
||||
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
|
||||
.PHONY : cmake_check_build_system
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
**WHAT:**
|
||||
|
||||
This is an attempt to write a simple iteration of XRandR using XCB and
|
||||
C++.
|
||||
|
||||
**WHY:**
|
||||
|
||||
I'm not familiar enough with this ecosystem to be useful in it, and I
|
||||
need to start getting some familiarity with it before I start hacking
|
||||
a Rust project that needs XCB/XRandR capability.
|
||||
|
||||
**REQURIEMENTS:**
|
||||
|
||||
This code has been tested with gcc-7.3, and should work on any
|
||||
C++17-compliant compiler with the relevant standard library, and
|
||||
obviously X Windows.
|
||||
|
||||
**STATUS:**
|
||||
|
||||
In progress.
|
||||
|
||||
**DETAILS:**
|
||||
|
||||
**BUILDING:**
|
||||
|
||||
From the base directory of the project:
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <iostream>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
xcb_connection_t *sXRandR11XCBConnection = xcb_connect(nullptr, nullptr);
|
||||
std::cout << sXRandR11XCBConnection << std::endl;
|
||||
xcb_disconnect(sXRandR11XCBConnection);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue