sway/input: Use "!ptr" for comparison to NULL

Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
This commit is contained in:
Elyes HAOUAS 2021-04-13 10:31:47 +02:00
parent c01f7df5e2
commit 99634bf396
6 changed files with 22 additions and 22 deletions

View file

@ -98,7 +98,7 @@ struct sway_node *node_at_coords(
// find the output the cursor is on
struct wlr_output *wlr_output = wlr_output_layout_output_at(
root->output_layout, lx, ly);
if (wlr_output == NULL) {
if (!wlr_output) {
return NULL;
}
struct sway_output *output = wlr_output->data;
@ -888,7 +888,7 @@ static void handle_request_pointer_set_cursor(struct wl_listener *listener,
}
// TODO: check cursor mode
if (focused_client == NULL ||
if (!focused_client ||
event->seat_client->client != focused_client) {
sway_log(SWAY_DEBUG, "denying request to set cursor from unfocused client");
return;
@ -1345,7 +1345,7 @@ void sway_cursor_constrain(struct sway_cursor *cursor,
wl_list_remove(&cursor->constraint_commit.link);
if (cursor->active_constraint) {
if (constraint == NULL) {
if (!constraint) {
warp_to_constraint_cursor_hint(cursor);
}
wlr_pointer_constraint_v1_send_deactivated(
@ -1354,7 +1354,7 @@ void sway_cursor_constrain(struct sway_cursor *cursor,
cursor->active_constraint = constraint;
if (constraint == NULL) {
if (!constraint) {
wl_list_init(&cursor->constraint_commit.link);
return;
}

View file

@ -133,7 +133,7 @@ static void apply_input_type_config(struct sway_input_device *input_device) {
break;
}
}
if (type_config == NULL) {
if (!type_config) {
return;
}

View file

@ -265,12 +265,12 @@ static void handle_seat_node_destroy(struct wl_listener *listener, void *data) {
// Find new focus_inactive (ie. sibling, or workspace if no siblings left)
struct sway_node *next_focus = NULL;
while (next_focus == NULL && parent != NULL) {
while (!next_focus && parent) {
struct sway_container *con =
seat_get_focus_inactive_view(seat, parent);
next_focus = con ? &con->node : NULL;
if (next_focus == NULL && parent->type == N_WORKSPACE) {
if (!next_focus && parent->type == N_WORKSPACE) {
next_focus = parent;
break;
}
@ -332,7 +332,7 @@ static struct sway_seat_node *seat_node_from_node(
}
seat_node = calloc(1, sizeof(struct sway_seat_node));
if (seat_node == NULL) {
if (!seat_node) {
sway_log(SWAY_ERROR, "could not allocate seat node");
return NULL;
}
@ -375,7 +375,7 @@ void drag_icon_update_position(struct sway_drag_icon *icon) {
case WLR_DRAG_GRAB_KEYBOARD_TOUCH:;
struct wlr_touch_point *point =
wlr_seat_touch_get_point(seat->wlr_seat, wlr_icon->drag->touch_id);
if (point == NULL) {
if (!point) {
return;
}
icon->x = seat->touch_x;
@ -469,7 +469,7 @@ static void handle_start_drag(struct wl_listener *listener, void *data) {
struct wlr_drag *wlr_drag = data;
struct sway_drag *drag = calloc(1, sizeof(struct sway_drag));
if (drag == NULL) {
if (!drag) {
sway_log(SWAY_ERROR, "Allocation failed");
return;
}
@ -483,7 +483,7 @@ static void handle_start_drag(struct wl_listener *listener, void *data) {
struct wlr_drag_icon *wlr_drag_icon = wlr_drag->icon;
if (wlr_drag_icon != NULL) {
struct sway_drag_icon *icon = calloc(1, sizeof(struct sway_drag_icon));
if (icon == NULL) {
if (!icon) {
sway_log(SWAY_ERROR, "Allocation failed");
return;
}
@ -723,7 +723,7 @@ static void seat_apply_input_config(struct sway_seat *seat,
* built-in output.
*/
mapped_to_output = sway_device->input_device->wlr_device->output_name;
if (mapped_to_output == NULL && is_touch_or_tablet_tool(sway_device) &&
if (!mapped_to_output && is_touch_or_tablet_tool(sway_device) &&
sway_libinput_device_is_builtin(sway_device->input_device)) {
mapped_to_output = get_builtin_output_name();
if (mapped_to_output) {
@ -731,7 +731,7 @@ static void seat_apply_input_config(struct sway_seat *seat,
mapped_to_output, sway_device->input_device->identifier);
}
}
if (mapped_to_output == NULL) {
if (!mapped_to_output) {
return;
}
/* fallthrough */
@ -1123,7 +1123,7 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
struct sway_workspace *last_workspace = seat_get_focused_workspace(seat);
if (node == NULL) {
if (!node) {
// Close any popups on the old focus
if (node_is_view(last_focus)) {
view_close_popups(last_focus->sway_container->view);

View file

@ -21,7 +21,7 @@ static void handle_pointer_axis(struct sway_seat *seat,
struct input_config *ic =
input_device ? input_device_get_config(input_device) : NULL;
float scroll_factor =
(ic == NULL || ic->scroll_factor == FLT_MIN) ? 1.0f : ic->scroll_factor;
(!ic || ic->scroll_factor == FLT_MIN) ? 1.0f : ic->scroll_factor;
wlr_seat_pointer_notify_axis(seat->wlr_seat, event->time_msec,
event->orientation, scroll_factor * event->delta,

View file

@ -114,7 +114,7 @@ static void handle_tablet_tool_set_cursor(struct wl_listener *listener, void *da
}
// TODO: check cursor mode
if (focused_client == NULL ||
if (!focused_client ||
event->seat_client->client != focused_client) {
sway_log(SWAY_DEBUG, "denying request to set cursor from unfocused client");
return;

View file

@ -142,7 +142,7 @@ static void relay_send_im_state(struct sway_input_method_relay *relay,
static void handle_text_input_enable(struct wl_listener *listener, void *data) {
struct sway_text_input *text_input = wl_container_of(listener, text_input,
text_input_enable);
if (text_input->relay->input_method == NULL) {
if (!text_input->relay->input_method) {
sway_log(SWAY_INFO, "Enabling text input when input method is gone");
return;
}
@ -159,7 +159,7 @@ static void handle_text_input_commit(struct wl_listener *listener,
return;
}
sway_log(SWAY_DEBUG, "Text input committed update");
if (text_input->relay->input_method == NULL) {
if (!text_input->relay->input_method) {
sway_log(SWAY_INFO, "Text input committed, but input method is gone");
return;
}
@ -168,7 +168,7 @@ static void handle_text_input_commit(struct wl_listener *listener,
static void relay_disable_text_input(struct sway_input_method_relay *relay,
struct sway_text_input *text_input) {
if (relay->input_method == NULL) {
if (!relay->input_method) {
sway_log(SWAY_DEBUG, "Disabling text input, but input method is gone");
return;
}
@ -180,7 +180,7 @@ static void handle_text_input_disable(struct wl_listener *listener,
void *data) {
struct sway_text_input *text_input = wl_container_of(listener, text_input,
text_input_disable);
if (text_input->input->focused_surface == NULL) {
if (!text_input->input->focused_surface) {
sway_log(SWAY_DEBUG, "Disabling text input, but no longer focused");
return;
}
@ -316,12 +316,12 @@ void sway_input_method_relay_set_focus(struct sway_input_method_relay *relay,
struct sway_text_input *text_input;
wl_list_for_each(text_input, &relay->text_inputs, link) {
if (text_input->pending_focused_surface) {
assert(text_input->input->focused_surface == NULL);
assert(!text_input->input->focused_surface);
if (surface != text_input->pending_focused_surface) {
text_input_set_pending_focused_surface(text_input, NULL);
}
} else if (text_input->input->focused_surface) {
assert(text_input->pending_focused_surface == NULL);
assert(!text_input->pending_focused_surface);
if (surface != text_input->input->focused_surface) {
relay_disable_text_input(relay, text_input);
wlr_text_input_v3_send_leave(text_input->input);