-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously, glog is a required to compile and link Wmderland. Now CMake can detect if glog is installed in your system and decide whether to link glog or not.
- Loading branch information
Showing
7 changed files
with
165 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,27 +4,41 @@ project(Wmderland) | |
# Request C++11 standard, using new CMake variables. | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -Wall") | ||
|
||
# There are two CMake scripts in ./cmake | ||
# 1. BuildType.cmake - determine build type on demand | ||
# 2. Findglog.cmake - used by `find_package(glog REQUIRED)` | ||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") | ||
|
||
# Load and run CMake code from a file or module. | ||
# Determine BuildType on demand. | ||
include(BuildType) | ||
|
||
# Add some extra flags to g++ | ||
# -flto: runs the standard link-time optimizer | ||
# -Wall: "warn all" turns on almost all warning | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -Wall") | ||
|
||
# Find the required libraries. | ||
find_package(X11 REQUIRED) | ||
find_package(glog REQUIRED) | ||
|
||
# Automatic macro construction. | ||
set(VERSION_MAJOR 0) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
set(VERSION_MINOR 9) | ||
|
||
# CMake will generate config.hpp from config.hpp.in | ||
# and store it under src/ | ||
configure_file( | ||
"${PROJECT_SOURCE_DIR}/src/config.hpp.in" | ||
"${PROJECT_SOURCE_DIR}/src/config.hpp" | ||
This comment has been minimized.
Sorry, something went wrong.
elfring
|
||
) | ||
|
||
|
||
# Grab all files end in .cpp | ||
FILE(GLOB cpp_sources src/*.cpp) | ||
add_executable(Wmderland ${cpp_sources}) | ||
target_link_libraries(Wmderland X11 glog) | ||
|
||
set(LIBRARIES "X11") | ||
if(GLOG_FOUND) | ||
set(LIBRARIES "${LIBRARIES} glog") | ||
endif() | ||
target_link_libraries(Wmderland X11 ${LIBRARIES}) | ||
|
||
# Install rule | ||
install (TARGETS Wmderland DESTINATION bin) | ||
install(TARGETS Wmderland DESTINATION bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,10 @@ | |
#define VARIABLE_PREFIX "$" | ||
#define DEFAULT_EXIT_KEY "Mod4+Shift+Escape" | ||
|
||
// The following macro will be generated by CMake which determines if Glog | ||
// is installed on the machine used to compile Wmderland. | ||
#define GLOG_FOUND TRUE | ||
This comment has been minimized.
Sorry, something went wrong.
elfring
|
||
|
||
enum class ConfigKeyword { | ||
SET, | ||
ASSIGN, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#ifndef WMDERLAND_CONFIG_HPP_ | ||
#define WMDERLAND_CONFIG_HPP_ | ||
|
||
#include "action.hpp" | ||
#include "util.hpp" | ||
#include <unordered_map> | ||
#include <vector> | ||
#include <string> | ||
|
||
#define WIN_MGR_NAME "Wmderland" | ||
#define VERSION "0.9.1 Beta" | ||
This comment has been minimized.
Sorry, something went wrong. |
||
#define CONFIG_FILE "~/.config/Wmderland/config" | ||
#define COOKIE_FILE "~/.local/share/Wmderland/cookie" | ||
|
||
#define WORKSPACE_UNSPECIFIED -1 | ||
#define WORKSPACE_COUNT 9 | ||
|
||
#define MIN_WINDOW_WIDTH 50 | ||
#define MIN_WINDOW_HEIGHT 50 | ||
#define DEFAULT_FLOATING_WINDOW_WIDTH 800 | ||
#define DEFAULT_FLOATING_WINDOW_HEIGHT 600 | ||
|
||
#define DEFAULT_GAP_WIDTH 15 | ||
#define DEFAULT_BORDER_WIDTH 3 | ||
#define DEFAULT_FOCUSED_COLOR 0xffffffff | ||
#define DEFAULT_UNFOCUSED_COLOR 0xff41485f | ||
|
||
#define VARIABLE_PREFIX "$" | ||
#define DEFAULT_EXIT_KEY "Mod4+Shift+Escape" | ||
|
||
// The following macro will be generated by CMake which determines if Glog | ||
// is installed on the machine used to compile Wmderland. | ||
#define GLOG_FOUND @GLOG_FOUND@ | ||
|
||
enum class ConfigKeyword { | ||
SET, | ||
ASSIGN, | ||
FLOATING, | ||
PROHIBIT, | ||
BINDSYM, | ||
EXEC, | ||
UNDEFINED | ||
}; | ||
|
||
class Config { | ||
public: | ||
Config(Display* dpy, Properties* prop, std::string filename); | ||
virtual ~Config(); | ||
|
||
int GetSpawnWorkspaceId(Window w) const; | ||
bool ShouldFloat(Window w) const; | ||
bool ShouldProhibit(Window w) const; | ||
const std::vector<Action>& GetKeybindActions(const std::string& modifier, const std::string& key) const; | ||
void SetKeybindActions(const std::string& modifier_and_key, const std::string& actions); | ||
|
||
unsigned short gap_width() const; | ||
unsigned short border_width() const; | ||
unsigned short min_window_width() const; | ||
unsigned short min_window_height() const; | ||
unsigned long focused_color() const; | ||
unsigned long unfocused_color() const; | ||
|
||
const std::unordered_map<std::string, short>& spawn_rules() const; | ||
const std::unordered_map<std::string, bool>& float_rules() const; | ||
const std::unordered_map<std::string, bool>& prohibit_rules() const; | ||
const std::unordered_map<std::string, std::vector<Action>>& keybind_rules() const; | ||
const std::vector<std::string>& autostart_rules() const; | ||
|
||
private: | ||
static ConfigKeyword StrToConfigKeyword(const std::string& s); | ||
static std::string ExtractWindowIdentifier(const std::string& s); | ||
std::vector<std::string> GeneratePossibleConfigKeys(Window w) const; | ||
const std::string& ReplaceSymbols(std::string& s); | ||
std::unordered_map<std::string, std::string> symtab_; | ||
|
||
// Global variables | ||
unsigned short gap_width_; | ||
unsigned short border_width_; | ||
unsigned short min_window_width_; | ||
unsigned short min_window_height_; | ||
unsigned long focused_color_; | ||
unsigned long unfocused_color_; | ||
|
||
// Rules | ||
std::unordered_map<std::string, short> spawn_rules_; // spawn certain apps in certain workspaces. | ||
std::unordered_map<std::string, bool> float_rules_; // start certain apps in floating mode. | ||
std::unordered_map<std::string, bool> prohibit_rules_; // apps that should be prohibit from starting. | ||
std::unordered_map<std::string, std::vector<Action>> keybind_rules_; // keybind actions. | ||
std::vector<std::string> autostart_rules_; // launch certain apps when wm starts. | ||
|
||
Display* dpy_; | ||
Properties* prop_; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I guess that you do need to define these two variables on your own when you can reuse others which would be automatically constructed by a command like “
project
”.