Skip to content

Commit

Permalink
Fix issue #19: add .clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
aesophor committed Nov 27, 2019
1 parent 10e35f6 commit 278b4f9
Show file tree
Hide file tree
Showing 26 changed files with 524 additions and 396 deletions.
151 changes: 151 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 95
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never
...

10 changes: 3 additions & 7 deletions src/action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ Action::Action(const string& s) {
}
}

Action::Action(Action::Type type)
: type_(type), argument_() {}

Action::Action(Action::Type type, const string& argument)
: type_(type), argument_(argument) {}
Action::Action(Action::Type type) : type_(type), argument_() {}

Action::Action(Action::Type type, const string& argument) : type_(type), argument_(argument) {}

Action::Type Action::type() const {
return type_;
Expand All @@ -39,7 +36,6 @@ const string& Action::argument() const {
return argument_;
}


Action::Type Action::StrToActionType(const string& s) {
if (s == "navigate_left") {
return Action::Type::NAVIGATE_LEFT;
Expand Down Expand Up @@ -78,4 +74,4 @@ Action::Type Action::StrToActionType(const string& s) {
}
}

} // namespace wmderland
} // namespace wmderland
6 changes: 3 additions & 3 deletions src/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Action {
RELOAD,
DEBUG_CRASH,
EXEC,
UNDEFINED
UNDEFINED,
};

explicit Action(const std::string& s);
Expand All @@ -43,6 +43,6 @@ class Action {
std::string argument_;
};

} // namespace wmderland
} // namespace wmderland

#endif // WMDERLAND_ACTION_H_
#endif // WMDERLAND_ACTION_H_
19 changes: 7 additions & 12 deletions src/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "client.h"

#include "config.h"
#include "workspace.h"
#include "util.h"
#include "workspace.h"

using std::string;
using std::unordered_map;
Expand Down Expand Up @@ -31,7 +31,6 @@ Client::~Client() {
Client::mapper_.erase(window_);
}


void Client::Map() const {
XMapWindow(dpy_, window_);
}
Expand All @@ -43,7 +42,7 @@ void Client::Unmap() {
return;
}

has_unmap_req_from_wm_ = true; // will be set to false in WindowManager::OnUnmapNotify
has_unmap_req_from_wm_ = true; // will be set to false in WindowManager::OnUnmapNotify
XUnmapWindow(dpy_, window_);
}

Expand Down Expand Up @@ -83,7 +82,6 @@ XWindowAttributes Client::GetXWindowAttributes() const {
return wm_utils::GetXWindowAttributes(window_);
}


Window Client::window() const {
return window_;
}
Expand All @@ -100,7 +98,6 @@ const XWindowAttributes& Client::attr_cache() const {
return attr_cache_;
}


bool Client::is_mapped() const {
return is_mapped_;
}
Expand All @@ -117,7 +114,6 @@ bool Client::has_unmap_req_from_wm() const {
return has_unmap_req_from_wm_;
}


void Client::set_workspace(Workspace* workspace) {
workspace_ = workspace;
}
Expand All @@ -142,17 +138,16 @@ void Client::set_attr_cache(const XWindowAttributes& attr) {
attr_cache_ = attr;
}


Client::Area::Area() : x(), y(), w(), h() {}

Client::Area::Area(int x, int y, int w, int h) : x(x), y(y), w(w), h(h) {}

bool Client::Area::operator== (const Client::Area& other) {
return (x == other.x) && (y == other.y) && (w== other.w) && (h== other.h);
bool Client::Area::operator==(const Client::Area& other) {
return (x == other.x) && (y == other.y) && (w == other.w) && (h == other.h);
}

bool Client::Area::operator!= (const Client::Area& other) {
return (x != other.x) || (y != other.y) || (w!= other.w) || (h!= other.h);
bool Client::Area::operator!=(const Client::Area& other) {
return (x != other.x) || (y != other.y) || (w != other.w) || (h != other.h);
}

} // namespace wmderland
} // namespace wmderland
14 changes: 7 additions & 7 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ extern "C" {
#include <X11/Xlib.h>
#include <X11/Xutil.h>
}
#include <unordered_map>
#include <string>
#include <unordered_map>

namespace wmderland {

class Workspace;

// A Client is any window that we have decided to manage. It is a wrapper class
// A Client is any window that we have decided to manage. It is a wrapper class
// of Window which provides some useful information and methods.
class Client {
public:
struct Area {
Area();
Area(int x, int y, int w, int h);
bool operator== (const Client::Area& other);
bool operator!= (const Client::Area& other);
bool operator==(const Client::Area& other);
bool operator!=(const Client::Area& other);

int x, y, w, h;
};
Expand All @@ -48,7 +48,7 @@ class Client {
Workspace* workspace() const;
const XSizeHints& size_hints() const;
const XWindowAttributes& attr_cache() const;

bool is_mapped() const;
bool is_floating() const;
bool is_fullscreen() const;
Expand All @@ -75,6 +75,6 @@ class Client {
bool has_unmap_req_from_wm_;
};

} // namespace wmderland
} // namespace wmderland

#endif // WMDERLAND_CLIENT_H_
#endif // WMDERLAND_CLIENT_H_
Loading

0 comments on commit 278b4f9

Please sign in to comment.