wayland: Cleanup event source comments, headers, and error reporting Replace instances of fprintf(stderr, ...) with SDL_SetError(), replace C++ comments with C style, use a uniform format for multi-line comments, and remove unused headers as poll and select aren't used in this file (the SDL function which calls them is used instead).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index f74d0fa..fe70824 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -57,9 +57,7 @@
#define BTN_SIDE (0x113)
#define BTN_EXTRA (0x114)
#endif
-#include <sys/select.h>
#include <sys/mman.h>
-#include <poll.h>
#include <unistd.h>
#include <errno.h>
#include <xkbcommon/xkbcommon.h>
@@ -844,11 +842,11 @@ static const struct wl_pointer_listener pointer_listener = {
pointer_handle_motion,
pointer_handle_button,
pointer_handle_axis,
- pointer_handle_frame, // Version 5
- pointer_handle_axis_source, // Version 5
- pointer_handle_axis_stop, // Version 5
- pointer_handle_axis_discrete, // Version 5
- pointer_handle_axis_value120 // Version 8
+ pointer_handle_frame, /* Version 5 */
+ pointer_handle_axis_source, /* Version 5 */
+ pointer_handle_axis_stop, /* Version 5 */
+ pointer_handle_axis_discrete, /* Version 5 */
+ pointer_handle_axis_value120 /* Version 8 */
};
static void
@@ -953,7 +951,7 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
close(fd);
if (!input->xkb.keymap) {
- fprintf(stderr, "failed to compile keymap\n");
+ SDL_SetError("failed to compile keymap\n");
return;
}
@@ -969,7 +967,7 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
input->xkb.state = WAYLAND_xkb_state_new(input->xkb.keymap);
if (!input->xkb.state) {
- fprintf(stderr, "failed to create XKB state\n");
+ SDL_SetError("failed to create XKB state\n");
WAYLAND_xkb_keymap_unref(input->xkb.keymap);
input->xkb.keymap = NULL;
return;
@@ -997,7 +995,7 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
input->xkb.compose_state = WAYLAND_xkb_compose_state_new(input->xkb.compose_table,
XKB_COMPOSE_STATE_NO_FLAGS);
if (!input->xkb.compose_state) {
- fprintf(stderr, "could not create XKB compose state\n");
+ SDL_SetError("could not create XKB compose state\n");
WAYLAND_xkb_compose_table_unref(input->xkb.compose_table);
input->xkb.compose_table = NULL;
}
@@ -1075,7 +1073,7 @@ keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint
return SDL_FALSE;
}
- // TODO can this happen?
+ /* TODO: Can this happen? */
if (WAYLAND_xkb_state_key_get_syms(input->xkb.state, key + 8, &syms) != 1) {
return SDL_FALSE;
}
@@ -1132,10 +1130,11 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
has_text = keyboard_input_get_text(text, input, key, SDL_PRESSED, &handled_by_ime);
} else {
if (keyboard_repeat_key_is_set(&input->keyboard_repeat, key)) {
- // Send any due key repeat events before stopping the repeat and generating the key up event
- // Compute time based on the Wayland time, as it reports when the release event happened
- // Using SDL_GetTicks would be wrong, as it would report when the release event is processed,
- // which may be off if the application hasn't pumped events for a while
+ /* Send any due key repeat events before stopping the repeat and generating the key up event.
+ * Compute time based on the Wayland time, as it reports when the release event happened.
+ * Using SDL_GetTicks would be wrong, as it would report when the release event is processed,
+ * which may be off if the application hasn't pumped events for a while.
+ */
keyboard_repeat_handle(&input->keyboard_repeat, time - input->keyboard_repeat.wl_press_time);
keyboard_repeat_clear(&input->keyboard_repeat);
}
@@ -1276,7 +1275,7 @@ static const struct wl_keyboard_listener keyboard_listener = {
keyboard_handle_leave,
keyboard_handle_key,
keyboard_handle_modifiers,
- keyboard_handle_repeat_info, // Version 4
+ keyboard_handle_repeat_info, /* Version 4 */
};
static void
@@ -1329,7 +1328,7 @@ seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name)
static const struct wl_seat_listener seat_listener = {
seat_handle_capabilities,
- seat_handle_name, // Version 2
+ seat_handle_name, /* Version 2 */
};
static void
@@ -1371,9 +1370,9 @@ static const struct wl_data_source_listener data_source_listener = {
data_source_handle_target,
data_source_handle_send,
data_source_handle_cancelled,
- data_source_handle_dnd_drop_performed, // Version 3
- data_source_handle_dnd_finished, // Version 3
- data_source_handle_action, // Version 3
+ data_source_handle_dnd_drop_performed, /* Version 3 */
+ data_source_handle_dnd_finished, /* Version 3 */
+ data_source_handle_action, /* Version 3 */
};
static void
@@ -1488,8 +1487,8 @@ data_offer_handle_actions(void *data, struct wl_data_offer *wl_data_offer,
static const struct wl_data_offer_listener data_offer_listener = {
data_offer_handle_offer,
- data_offer_handle_source_actions, // Version 3
- data_offer_handle_actions, // Version 3
+ data_offer_handle_source_actions, /* Version 3 */
+ data_offer_handle_actions, /* Version 3 */
};
static void
@@ -1574,19 +1573,19 @@ data_device_handle_motion(void *data, struct wl_data_device *wl_data_device,
}
/* Decodes URI escape sequences in string buf of len bytes
- (excluding the terminating NULL byte) in-place. Since
- URI-encoded characters take three times the space of
- normal characters, this should not be an issue.
-
- Returns the number of decoded bytes that wound up in
- the buffer, excluding the terminating NULL byte.
-
- The buffer is guaranteed to be NULL-terminated but
- may contain embedded NULL bytes.
-
- On error, -1 is returned.
-
- FIXME: This was shamelessly copied from SDL_x11events.c
+ * (excluding the terminating NULL byte) in-place. Since
+ * URI-encoded characters take three times the space of
+ * normal characters, this should not be an issue.
+ *
+ * Returns the number of decoded bytes that wound up in
+ * the buffer, excluding the terminating NULL byte.
+ *
+ * The buffer is guaranteed to be NULL-terminated but
+ * may contain embedded NULL bytes.
+ *
+ * On error, -1 is returned.
+ *
+ * FIXME: This was shamelessly copied from SDL_x11events.c
*/
static int Wayland_URIDecode(char *buf, int len) {
int ri, wi, di;
@@ -1649,10 +1648,10 @@ static int Wayland_URIDecode(char *buf, int len) {
}
/* Convert URI to local filename
- return filename if possible, else NULL
-
- FIXME: This was shamelessly copied from SDL_x11events.c
-*/
+ * return filename if possible, else NULL
+ *
+ * FIXME: This was shamelessly copied from SDL_x11events.c
+ */
static char* Wayland_URIToLocal(char* uri) {
char *file = NULL;
SDL_bool local;
@@ -2582,7 +2581,8 @@ int Wayland_input_lock_pointer(struct SDL_WaylandInput *input)
return -1;
/* If we have a pointer confine active, we must destroy it here because
- * creating a locked pointer otherwise would be a protocol error. */
+ * creating a locked pointer otherwise would be a protocol error.
+ */
for (window = vd->windows; window; window = window->next)
pointer_confine_destroy(window);
@@ -2661,11 +2661,13 @@ int Wayland_input_confine_pointer(struct SDL_WaylandInput *input, SDL_Window *wi
return -1;
/* A confine may already be active, in which case we should destroy it and
- * create a new one. */
+ * create a new one.
+ */
pointer_confine_destroy(window);
/* We cannot create a confine if the pointer is already locked. Defer until
- * the pointer is unlocked. */
+ * the pointer is unlocked.
+ */
if (d->relative_mouse_mode)
return 0;