Skip to content

Commit

Permalink
Merge pull request #125 from msharov/master
Browse files Browse the repository at this point in the history
Remove use of float and math.h
  • Loading branch information
JLErvin committed Mar 25, 2021
2 parents 6e5ea0c + 3d7fffa commit 05c2465
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 95 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
*.o
berry
berryc
.o
config.status
Config.mk
config.h
18 changes: 9 additions & 9 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ struct command {
};
static const struct command command_table[] = {
{ "window_move", IPCWindowMoveRelative, false, 2, fn_int },
{ "window_move_absolute", IPCWindowMoveAbsolute, false, 2, fn_int },
{ "window_move_absolute", IPCWindowMoveAbsolute, false, 2, fn_int },
{ "window_resize", IPCWindowResizeRelative, false, 2, fn_int },
{ "window_resize_absolute", IPCWindowResizeAbsolute, false, 2, fn_int },
{ "window_raise", IPCWindowRaise, false, 0, NULL },
{ "window_monocle", IPCWindowMonocle, false, 0, NULL },
{ "window_close", IPCWindowClose, false, 0, NULL },
{ "window_center", IPCWindowCenter, false, 0, NULL },
{ "focus_color", IPCFocusColor, true, 1, fn_hex },
{ "unfocus_color", IPCUnfocusColor, true, 1, fn_hex },
{ "unfocus_color", IPCUnfocusColor, true, 1, fn_hex },
{ "inner_focus_color", IPCInnerFocusColor, true, 1, fn_hex },
{ "inner_unfocus_color", IPCInnerUnfocusColor, true, 1, fn_hex },
{ "text_focus_color", IPCTitleFocusColor, true, 1, fn_hex },
{ "text_unfocus_color", IPCTitleUnfocusColor, true, 1, fn_hex },
{ "inner_unfocus_color", IPCInnerUnfocusColor, true, 1, fn_hex },
{ "text_focus_color", IPCTitleFocusColor, true, 1, fn_hex },
{ "text_unfocus_color", IPCTitleUnfocusColor, true, 1, fn_hex },
{ "border_width", IPCBorderWidth, true, 1, fn_int },
{ "inner_border_width", IPCInnerBorderWidth, true, 1, fn_int },
{ "title_height", IPCTitleHeight, true, 1, fn_int },
Expand Down Expand Up @@ -126,7 +126,7 @@ fn_str(long *data, bool b, int i, char **argv)
/* This function works by setting a new atom globally on the root
* window called BERRY_FONT_PROPERTY which tells berry what font
* to use for window decoration.
* We set the font here in the client and then send a message to
* We set the font here in the client and then send a message to
* berry, notifying the main program to read this value
*/
static void
Expand All @@ -137,7 +137,7 @@ fn_font(long *data, bool b, int i, char** argv)
UNUSED(data);
char** font_list;
XTextProperty font_prop;

font_list = malloc(sizeof(char*));
font_list[0] = argv[0];
Xutf8TextListToTextProperty(display, font_list, 1,
Expand Down Expand Up @@ -208,7 +208,7 @@ send_command(const struct command *c, int argc, char **argv)
ev.xclient.message_type = XInternAtom(display, BERRY_CLIENT_EVENT, False);
ev.xclient.format = 32;

/* We use the following protocol:
/* We use the following protocol:
* If the given command is related to berry's confid then assign it a value of
* IPCConfig at d[0]. Then, assign the specific config element at d[1], shifting
* all values up by one.
Expand Down Expand Up @@ -245,7 +245,7 @@ main(int argc, char **argv)
c_argc = argc - 2;
c_argv = argv + 2;

if (c_argc == -1)
if (c_argc == -1)
return 1;
else if (strcmp(argv[1], "-h") == 0)
usage();
Expand Down
2 changes: 1 addition & 1 deletion config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#define MOVE_STEP 40
#define RESIZE_STEP 40
#define PLACE_RES 10
#define PLACE_RES 10

#define TOP_GAP 30
#define BOT_GAP 0
Expand Down
18 changes: 0 additions & 18 deletions utils.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#include "types.h"
#include "utils.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>

int
asprintf(char **buf, const char *fmt, ...)
Expand Down Expand Up @@ -37,18 +34,3 @@ vasprintf(char **buf, const char *fmt, va_list args)
size = vsprintf(*buf, fmt, args);
return size;
}

int
euclidean_distance(struct client *a, struct client *b)
{
int x_diff, y_diff;
x_diff = a->geom.x - b->geom.x;
y_diff = a->geom.y - b->geom.y;
return pow(x_diff, 2) + pow(y_diff, 2);
}

int
round_k(int n)
{
return ceil(n / 10) * 10;
}
5 changes: 1 addition & 4 deletions utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
#define _BERRY_UTILS_H_

#include "types.h"
#include <X11/Xlib.h>
#include <stdarg.h>

#define MAX(a, b) ((a > b) ? (a) : (b))
#define MIN(a, b) ((a < b) ? (a) : (b))
#define UNUSED(x) (void)(x)
#define LOGN(msg) do { if (debug) fprintf(stderr, __WINDOW_MANAGER_NAME__": " msg "\n"); } while (0)
#define LOGN(msg) do { if (debug) fprintf(stderr, __WINDOW_MANAGER_NAME__": " msg "\n"); } while (0)
#define LOGP(msg, ...) do { if (debug) fprintf(stderr, __WINDOW_MANAGER_NAME__": " msg "\n", __VA_ARGS__); } while (0)

int asprintf(char **buf, const char *fmt, ...);
int vasprintf(char **buf, const char *fmt, va_list args);
int euclidean_distance(struct client *a, struct client *b);
int round_k(int n);

#endif
Loading

0 comments on commit 05c2465

Please sign in to comment.