mirror of
https://github.com/labwc/labwc.git
synced 2025-11-06 13:29:58 -05:00
Apply coding std to <mouse> code & add .clang-format
The files:
include/config/mousebind.h
src/config/mousebind.c
src/config/rc.xml
were formatted automatically via clang-format using the rules specified
in the .clang-format file. Specifically, the command;
clang-format -i -style=file include/config/mousebind.h \
src/config/mousebind.c src/config/rc.xml
This is unfortunately adding a break before the brace in enum
declarations
This commit is contained in:
parent
10a685a0e4
commit
1ac654f006
4 changed files with 117 additions and 102 deletions
|
|
@ -1,18 +1,17 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "config/mousebind.h"
|
||||
#include "config/rcxml.h"
|
||||
#include <wlr/util/log.h>
|
||||
#include <linux/input-event-codes.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/input-event-codes.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
static enum ssd_part_type
|
||||
context_from_str(const char* str)
|
||||
context_from_str(const char *str)
|
||||
{
|
||||
if(str == NULL) {
|
||||
if (str == NULL) {
|
||||
return LAB_SSD_NONE;
|
||||
}
|
||||
else if(strcasecmp(str, "Titlebar") == 0) {
|
||||
} else if (strcasecmp(str, "Titlebar") == 0) {
|
||||
return LAB_SSD_PART_TITLEBAR;
|
||||
} else {
|
||||
return LAB_SSD_NONE;
|
||||
|
|
@ -20,16 +19,15 @@ context_from_str(const char* str)
|
|||
}
|
||||
|
||||
static uint32_t
|
||||
mouse_button_from_str(const char* str)
|
||||
mouse_button_from_str(const char *str)
|
||||
{
|
||||
if(str == NULL) {
|
||||
if (str == NULL) {
|
||||
return UINT32_MAX;
|
||||
}
|
||||
else if(strcasecmp(str, "Left") == 0) {
|
||||
} else if (strcasecmp(str, "Left") == 0) {
|
||||
return BTN_LEFT;
|
||||
} else if(strcasecmp(str, "Right") == 0) {
|
||||
} else if (strcasecmp(str, "Right") == 0) {
|
||||
return BTN_RIGHT;
|
||||
} else if(strcasecmp(str, "Middle") == 0) {
|
||||
} else if (strcasecmp(str, "Middle") == 0) {
|
||||
return BTN_MIDDLE;
|
||||
} else {
|
||||
return UINT32_MAX;
|
||||
|
|
@ -37,42 +35,42 @@ mouse_button_from_str(const char* str)
|
|||
}
|
||||
|
||||
static enum action_mouse_did
|
||||
action_mouse_did_from_str(const char* str)
|
||||
action_mouse_did_from_str(const char *str)
|
||||
{
|
||||
if(str == NULL) {
|
||||
if (str == NULL) {
|
||||
return MOUSE_ACTION_NONE;
|
||||
}
|
||||
else if(strcasecmp(str, "doubleclick") == 0) {
|
||||
} else if (strcasecmp(str, "doubleclick") == 0) {
|
||||
return MOUSE_ACTION_DOUBLECLICK;
|
||||
} else {
|
||||
return MOUSE_ACTION_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
struct mousebind*
|
||||
mousebind_create(const char* context_str, const char* mouse_button_str,
|
||||
const char* action_mouse_did_str, const char* action,
|
||||
const char* command)
|
||||
struct mousebind *
|
||||
mousebind_create(const char *context_str, const char *mouse_button_str,
|
||||
const char *action_mouse_did_str, const char *action, const char *command)
|
||||
{
|
||||
struct mousebind* m = calloc(1, sizeof(struct mousebind));
|
||||
struct mousebind *m = calloc(1, sizeof(struct mousebind));
|
||||
|
||||
enum ssd_part_type context = context_from_str(context_str);
|
||||
uint32_t button = mouse_button_from_str(mouse_button_str);
|
||||
enum action_mouse_did action_mouse_did = action_mouse_did_from_str(action_mouse_did_str);
|
||||
enum action_mouse_did action_mouse_did =
|
||||
action_mouse_did_from_str(action_mouse_did_str);
|
||||
|
||||
if(context == LAB_SSD_NONE) {
|
||||
if (context == LAB_SSD_NONE) {
|
||||
wlr_log(WLR_ERROR, "unknown mouse context (%s)", context_str);
|
||||
goto CREATE_ERROR;
|
||||
}
|
||||
if(button == UINT32_MAX) {
|
||||
if (button == UINT32_MAX) {
|
||||
wlr_log(WLR_ERROR, "unknown button (%s)", mouse_button_str);
|
||||
goto CREATE_ERROR;
|
||||
}
|
||||
if(action_mouse_did == MOUSE_ACTION_NONE) {
|
||||
wlr_log(WLR_ERROR, "unknown mouse action (%s)", action_mouse_did_str);
|
||||
if (action_mouse_did == MOUSE_ACTION_NONE) {
|
||||
wlr_log(WLR_ERROR, "unknown mouse action (%s)",
|
||||
action_mouse_did_str);
|
||||
goto CREATE_ERROR;
|
||||
}
|
||||
if(action == NULL) {
|
||||
if (action == NULL) {
|
||||
wlr_log(WLR_ERROR, "action is NULL\n");
|
||||
goto CREATE_ERROR;
|
||||
}
|
||||
|
|
@ -81,7 +79,7 @@ mousebind_create(const char* context_str, const char* mouse_button_str,
|
|||
m->button = button;
|
||||
m->mouse_action = action_mouse_did;
|
||||
m->action = strdup(action); /* TODO: replace with strndup? */
|
||||
if(command && !strcasecmp(action, "Execute")) {
|
||||
if (command && !strcasecmp(action, "Execute")) {
|
||||
m->command = strdup(command);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue