Skip to content

Commit

Permalink
Formatted stuff, Thanks WebFreak001
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Printzell <[email protected]>
  • Loading branch information
Vild committed Jan 4, 2016
1 parent f5c3fc8 commit a16f222
Show file tree
Hide file tree
Showing 16 changed files with 455 additions and 212 deletions.
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 160

[*.md]
trim_trailing_whitespace = false

[*.d]
// It's more like K&R than otbs, but K&R does not exist in dfmt
dfmt_brace_style = otbs
dfmt_soft_max_line_length = 120
dfmt_align_switch_statements = true
dfmt_outdent_attributes = true
dfmt_split_operator_at_line_end = false
dfmt_space_after_cast = false
dfmt_space_after_keywords = false
dfmt_selective_import_space = true
dfmt_compact_labeled_statements = true
67 changes: 67 additions & 0 deletions dscanner.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
; Configurue which static analysis checks are enabled
[analysis.config.StaticAnalysisConfig]
; Check variable, class, struct, interface, union, and function names against t
; he Phobos style guide
style_check="false"
; Check for array literals that cause unnecessary allocation
enum_array_literal_check="true"
; Check for poor exception handling practices
exception_check="true"
; Check for use of the deprecated 'delete' keyword
delete_check="true"
; Check for use of the deprecated floating point operators
float_operator_check="true"
; Check number literals for readability
number_style_check="true"
; Checks that opEquals, opCmp, toHash, and toString are either const, immutable
; , or inout.
object_const_check="true"
; Checks for .. expressions where the left side is larger than the right.
backwards_range_check="true"
; Checks for if statements whose 'then' block is the same as the 'else' block
if_else_same_check="true"
; Checks for some problems with constructors
constructor_check="true"
; Checks for unused variables and function parameters
unused_variable_check="true"
; Checks for unused labels
unused_label_check="true"
; Checks for duplicate attributes
duplicate_attribute="true"
; Checks that opEquals and toHash are both defined or neither are defined
opequals_tohash_check="true"
; Checks for subtraction from .length properties
length_subtraction_check="true"
; Checks for methods or properties whose names conflict with built-in propertie
; s
builtin_property_names_check="true"
; Checks for confusing code in inline asm statements
asm_style_check="true"
; Checks for confusing logical operator precedence
logical_precedence_check="true"
; Checks for undocumented public declarations
undocumented_declaration_check="true"
; Checks for poor placement of function attributes
function_attribute_check="true"
; Checks for use of the comma operator
comma_expression_check="true"
; Checks for local imports that are too broad
local_import_check="true"
; Checks for variables that could be declared immutable
could_be_immutable_check="true"
; Checks for redundant expressions in if statements
redundant_if_check="true"
; Checks for redundant parenthesis
redundant_parens_check="true"
; Checks for mismatched argument and parameter names
mismatched_args_check="true"
; Checks for labels with the same name as variables
label_var_same_name_check="true"
; Checks for lines longer than 120 characters
long_line_check="true"
; Checks for assignment to auto-ref function parameters
auto_ref_assignment_check="true"
; Checks for incorrect infinite range definitions
incorrect_infinite_range_check="true"
; Checks for asserts that are always true
useless_assert_check="true"
10 changes: 5 additions & 5 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "dwin",
"description": "A minimal D application.",
"copyright": "Copyright © 2015, wildn00b",
"authors": ["wildn00b"],
"authors": [
"wildn00b"
],
"dependencies": {
"xcb-d": {
"path": "../xcb-d"
}
"xcb-d": "~>1.11.1"
}
}
}
Binary file removed getRoots
Binary file not shown.
31 changes: 0 additions & 31 deletions getRoots.c

This file was deleted.

4 changes: 3 additions & 1 deletion source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ int main(string[] args) {
}

auto dwin = new DWin();
scope (exit)
dwin.destroy;

dwin.Run();
dwin.destroy;

return 0;
}
2 changes: 1 addition & 1 deletion source/dwin/backend/hotkeymanager.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module dwin.backend.hotkeymanager;

final class HotKeyManager {

}
107 changes: 95 additions & 12 deletions source/dwin/backend/xcb/atom.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ struct Atom {
this(XCB xcb, string name, bool createOnMissing = true) {
atom = XCB_ATOM_NONE;
this.xcb = xcb;
xcb_intern_atom_cookie_t c = xcb_intern_atom_unchecked(xcb.Connection, !createOnMissing, cast(ushort)name.length, name.toStringz);
//dfmt off
xcb_intern_atom_cookie_t c = xcb_intern_atom_unchecked(
xcb.Connection,
!createOnMissing,
cast(ushort)name.length,
name.toStringz
);
//dfmt on
if (auto reply = xcb_intern_atom_reply(xcb.Connection, c, null)) {
atom = reply.atom;
free(reply);
Expand All @@ -24,9 +31,19 @@ struct Atom {

Atom[] GetAtom(Window window) {
Atom[] ret;
xcb_get_property_cookie_t c = xcb_get_property_unchecked(xcb.Connection, 0, window.Window, atom, XCB_ATOM_ATOM, 0, 0);
//dfmt off
xcb_get_property_cookie_t c = xcb_get_property_unchecked(
xcb.Connection,
0,
window.Window,
atom,
XCB_ATOM_ATOM,
0,
0
);
//dfmt on
if (auto reply = xcb_get_property_reply(xcb.Connection, c, null)) {
xcb_atom_t[] tmp = (cast(xcb_atom_t *)xcb_get_property_value(reply))[0 .. xcb_get_property_value_length(reply)];
xcb_atom_t[] tmp = (cast(xcb_atom_t*)xcb_get_property_value(reply))[0 .. xcb_get_property_value_length(reply)];
foreach (atom; tmp)
ret ~= Atom(atom);
free(reply);
Expand All @@ -36,9 +53,19 @@ struct Atom {

Window[] GetWindow(Window window) {
Window[] ret;
xcb_get_property_cookie_t c = xcb_get_property_unchecked(xcb.Connection, 0, window.Window, atom, XCB_ATOM_WINDOW, 0, 0);
//dfmt off
xcb_get_property_cookie_t c = xcb_get_property_unchecked(
xcb.Connection,
0,
window.Window,
atom,
XCB_ATOM_WINDOW,
0,
0
);
//dfmt on
if (auto reply = xcb_get_property_reply(xcb.Connection, c, null)) {
xcb_window_t[] tmp = (cast(xcb_window_t *)xcb_get_property_value(reply))[0 .. xcb_get_property_value_length(reply)];
xcb_window_t[] tmp = (cast(xcb_window_t*)xcb_get_property_value(reply))[0 .. xcb_get_property_value_length(reply)];
foreach (win; tmp)
ret ~= new Window(xcb, win);
free(reply);
Expand All @@ -48,36 +75,92 @@ struct Atom {

string GetString(Window window) {
string ret = null;
xcb_get_property_cookie_t c = xcb_get_property_unchecked(xcb.Connection, 0, window.Window, atom, XCB_ATOM_STRING, 0, 0);
//dfmt off
xcb_get_property_cookie_t c = xcb_get_property_unchecked(
xcb.Connection,
0,
window.Window,
atom,
XCB_ATOM_STRING,
0,
0
);
//dfmt on
if (auto reply = xcb_get_property_reply(xcb.Connection, c, null)) {
char[] tmp = (cast(char *)xcb_get_property_value(reply))[0 .. xcb_get_property_value_length(reply)];
char[] tmp = (cast(char*)xcb_get_property_value(reply))[0 .. xcb_get_property_value_length(reply)];
ret = tmp.to!string;
free(reply);
}
return ret;
}

void Change(Window window, Atom[] value) {
xcb_change_property(xcb.Connection, XCB_PROP_MODE_REPLACE, window.Window, atom, XCB_ATOM_ATOM, 32, cast(uint)value.length, cast(ubyte *)value.ptr);
//dfmt off
xcb_change_property(
xcb.Connection,
XCB_PROP_MODE_REPLACE,
window.Window,
atom,
XCB_ATOM_ATOM,
32,
cast(uint)value.length,
cast(ubyte*)value.ptr
);
//dfmt on
}

void Change(Window window, Atom value) {
xcb_change_property(xcb.Connection, XCB_PROP_MODE_REPLACE, window.Window, atom, XCB_ATOM_ATOM, 32, 1, cast(ubyte *)&value);
//dfmt off
xcb_change_property(
xcb.Connection,
XCB_PROP_MODE_REPLACE,
window.Window,
atom,
XCB_ATOM_ATOM,
32,
1,
cast(ubyte*)&value
);
//dfmt on
}

void Change(Window window, Window value) {
xcb_change_property(xcb.Connection, XCB_PROP_MODE_REPLACE, window.Window, atom, XCB_ATOM_WINDOW, 32, 1, cast(ubyte *)&value);
//dfmt off
xcb_change_property(
xcb.Connection,
XCB_PROP_MODE_REPLACE,
window.Window,
atom,
XCB_ATOM_WINDOW,
32,
1,
cast(ubyte*)&value
);
//dfmt on
}

void Change(Window window, string value) {
xcb_change_property(xcb.Connection, XCB_PROP_MODE_REPLACE, window.Window, atom, XCB_ATOM_STRING, 8, cast(uint)value.length, value.toStringz);
//dfmt off
xcb_change_property(
xcb.Connection,
XCB_PROP_MODE_REPLACE,
window.Window,
atom,
XCB_ATOM_STRING,
8,
cast(uint)value.length,
value.toStringz
);
//dfmt on
}

void Delete(Window window) {
xcb_delete_property(xcb.Connection, window.Window, atom);
}

@property bool IsValid() { return atom != XCB_ATOM_NONE; }
@property bool IsValid() {
return atom != XCB_ATOM_NONE;
}

alias atom this;
xcb_atom_t atom;
Expand Down
8 changes: 7 additions & 1 deletion source/dwin/backend/xcb/cursor.d
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ final class Cursor {
public:
this(XCB xcb, CursorIcons icon) {
import std.string : toStringz;

this.xcb = xcb;
font = xcb_generate_id(xcb.Connection);
xcb_open_font(xcb.Connection, font, 6, "cursor".toStringz);

cursor = xcb_generate_id(xcb.Connection);
//dfmt off
xcb_create_glyph_cursor(xcb.Connection,
cursor,
font,
Expand All @@ -22,6 +24,7 @@ public:
0, 0, 0,
ushort.max, ushort.max, ushort.max
);
//dfmt on
}

~this() {
Expand All @@ -33,7 +36,10 @@ public:
xcb.Root.ChangeAttributes(XCB_CW_CURSOR, &cursor);
}

@property xcb_cursor_t Cursor() { return cursor; }
@property xcb_cursor_t Cursor() {
return cursor;
}

private:
XCB xcb;
xcb_font_t font;
Expand Down
Loading

0 comments on commit a16f222

Please sign in to comment.