Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dorota Czaplejewicz
wlroots
Commits
74ca2f8f
Commit
74ca2f8f
authored
Jul 07, 2018
by
Markus Ongyerth
Browse files
Another round of feedback from acrisci
parent
43b20bfe
Changes
5
Hide whitespace changes
Inline
Side-by-side
include/util/array.h
0 → 100644
View file @
74ca2f8f
#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
types/tablet_v2/wlr_tablet_v2_tool.c
View file @
74ca2f8f
...
...
@@ -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
;
}
...
...
types/wlr_keyboard.c
View file @
74ca2f8f
#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
;
...
...
util/array.c
0 → 100644
View file @
74ca2f8f
#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
;
}
util/meson.build
View file @
74ca2f8f
lib_wlr_util = static_library(
'wlr_util',
files(
'array.c',
'log.c',
'os-compatibility.c',
'region.c',
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment