Commit 74ca2f8f authored by Markus Ongyerth's avatar Markus Ongyerth
Browse files

Another round of feedback from acrisci

parent 43b20bfe
#ifndef UTIL_ARRAY_H
#define UTIL_ARRAY_H
#include <stdint.h>
#include <stdlib.h>
size_t push_zeroes_to_end(uint32_t arr[], size_t n);
#endif
......@@ -3,6 +3,7 @@
#endif
#include "tablet-unstable-v2-protocol.h"
#include "util/array.h"
#include <assert.h>
#include <stdlib.h>
#include <types/wlr_tablet_v2.h>
......@@ -231,25 +232,8 @@ struct wlr_tablet_tool_client_v2 *tablet_tool_client_from_resource(struct wl_res
/* Actual protocol foo */
// https://www.geeksforgeeks.org/move-zeroes-end-array/
static size_t push_zeroes_to_end(uint32_t arr[], size_t n) {
size_t count = 0;
for (size_t i = 0; i < n; i++) {
if (arr[i] != 0) {
arr[count++] = arr[i];
}
}
size_t ret = count;
while (count < n) {
arr[count++] = 0;
}
return ret;
}
// Button 0 is KEY_RESERVED in input-event-codes on linux (and freebsd)
static ssize_t tablet_tool_button_update(struct wlr_tablet_v2_tablet_tool *tool,
uint32_t button, enum zwp_tablet_pad_v2_button_state state) {
bool found = false;
......@@ -261,11 +245,16 @@ static ssize_t tablet_tool_button_update(struct wlr_tablet_v2_tablet_tool *tool,
}
}
if (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED && !found &&
tool->num_buttons < WLR_TABLET_V2_TOOL_BUTTONS_CAP) {
i = tool->num_buttons++;
tool->pressed_buttons[i] = button;
tool->pressed_serials[i] = -1;
if (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED && !found) {
if (tool->num_buttons < WLR_TABLET_V2_TOOL_BUTTONS_CAP) {
i = tool->num_buttons++;
tool->pressed_buttons[i] = button;
tool->pressed_serials[i] = -1;
} else {
i = -1;
wlr_log(WLR_ERROR, "You pressed more than %d tablet tool buttons. This is currently not supporte by wlroots. Please report this with a description of your tablet, since this is either a bug, or fancy hardware",
WLR_TABLET_V2_TOOL_BUTTONS_CAP);
}
} else {
i = -1;
}
......
#include "util/array.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
......@@ -58,25 +59,6 @@ static bool keyboard_modifier_update(struct wlr_keyboard *keyboard) {
return true;
}
// https://www.geeksforgeeks.org/move-zeroes-end-array/
static size_t push_zeroes_to_end(uint32_t arr[], size_t n) {
size_t count = 0;
for (size_t i = 0; i < n; i++) {
if (arr[i] != 0) {
arr[count++] = arr[i];
}
}
size_t ret = count;
while (count < n) {
arr[count++] = 0;
}
return ret;
}
static void keyboard_key_update(struct wlr_keyboard *keyboard,
struct wlr_event_keyboard_key *event) {
bool found = false;
......
#include <stdlib.h>
#include <stdint.h>
// https://www.geeksforgeeks.org/move-zeroes-end-array/
size_t push_zeroes_to_end(uint32_t arr[], size_t n) {
size_t count = 0;
for (size_t i = 0; i < n; i++) {
if (arr[i] != 0) {
arr[count++] = arr[i];
}
}
size_t ret = count;
while (count < n) {
arr[count++] = 0;
}
return ret;
}
lib_wlr_util = static_library(
'wlr_util',
files(
'array.c',
'log.c',
'os-compatibility.c',
'region.c',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment