mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
cursor: avoid uninitialized wlr_box fields
This commit is contained in:
parent
138d21464d
commit
4462f5dcb3
1 changed files with 14 additions and 10 deletions
|
@ -236,19 +236,22 @@ static void cursor_warp_unchecked(struct wlr_cursor *cur,
|
||||||
* Absolute movement for touch and pen devices will be relative to this box and
|
* Absolute movement for touch and pen devices will be relative to this box and
|
||||||
* pointer movement will be constrained to this box.
|
* pointer movement will be constrained to this box.
|
||||||
*
|
*
|
||||||
* If none of these are set, empties the box and absolute movement should be
|
* If none of these are set, the box is empty and absolute movement should be
|
||||||
* relative to the extents of the layout.
|
* relative to the extents of the layout.
|
||||||
*/
|
*/
|
||||||
static void get_mapping(struct wlr_cursor *cur,
|
static void get_mapping(struct wlr_cursor *cur,
|
||||||
struct wlr_input_device *dev, struct wlr_box *box) {
|
struct wlr_input_device *dev, struct wlr_box *box) {
|
||||||
assert(cur->state->layout);
|
assert(cur->state->layout);
|
||||||
struct wlr_cursor_device *c_device = get_cursor_device(cur, dev);
|
|
||||||
|
|
||||||
|
memset(box, 0, sizeof(*box));
|
||||||
|
|
||||||
|
struct wlr_cursor_device *c_device = get_cursor_device(cur, dev);
|
||||||
if (c_device) {
|
if (c_device) {
|
||||||
if (!wlr_box_empty(&c_device->mapped_box)) {
|
if (!wlr_box_empty(&c_device->mapped_box)) {
|
||||||
*box = c_device->mapped_box;
|
*box = c_device->mapped_box;
|
||||||
return;
|
return;
|
||||||
} else if (c_device->mapped_output) {
|
}
|
||||||
|
if (c_device->mapped_output) {
|
||||||
wlr_output_layout_get_box(cur->state->layout,
|
wlr_output_layout_get_box(cur->state->layout,
|
||||||
c_device->mapped_output, box);
|
c_device->mapped_output, box);
|
||||||
return;
|
return;
|
||||||
|
@ -257,11 +260,12 @@ static void get_mapping(struct wlr_cursor *cur,
|
||||||
|
|
||||||
if (!wlr_box_empty(&cur->state->mapped_box)) {
|
if (!wlr_box_empty(&cur->state->mapped_box)) {
|
||||||
*box = cur->state->mapped_box;
|
*box = cur->state->mapped_box;
|
||||||
} else if (cur->state->mapped_output) {
|
return;
|
||||||
|
}
|
||||||
|
if (cur->state->mapped_output) {
|
||||||
wlr_output_layout_get_box(cur->state->layout,
|
wlr_output_layout_get_box(cur->state->layout,
|
||||||
cur->state->mapped_output, box);
|
cur->state->mapped_output, box);
|
||||||
} else {
|
return;
|
||||||
box->width = box->height = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,19 +872,21 @@ void wlr_cursor_map_input_to_output(struct wlr_cursor *cur,
|
||||||
|
|
||||||
void wlr_cursor_map_to_region(struct wlr_cursor *cur,
|
void wlr_cursor_map_to_region(struct wlr_cursor *cur,
|
||||||
const struct wlr_box *box) {
|
const struct wlr_box *box) {
|
||||||
|
memset(&cur->state->mapped_box, 0, sizeof(cur->state->mapped_box));
|
||||||
|
|
||||||
if (box) {
|
if (box) {
|
||||||
if (wlr_box_empty(box)) {
|
if (wlr_box_empty(box)) {
|
||||||
wlr_log(WLR_ERROR, "cannot map cursor to an empty region");
|
wlr_log(WLR_ERROR, "cannot map cursor to an empty region");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cur->state->mapped_box = *box;
|
cur->state->mapped_box = *box;
|
||||||
} else {
|
|
||||||
cur->state->mapped_box.width = cur->state->mapped_box.height = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_cursor_map_input_to_region(struct wlr_cursor *cur,
|
void wlr_cursor_map_input_to_region(struct wlr_cursor *cur,
|
||||||
struct wlr_input_device *dev, const struct wlr_box *box) {
|
struct wlr_input_device *dev, const struct wlr_box *box) {
|
||||||
|
memset(&cur->state->mapped_box, 0, sizeof(cur->state->mapped_box));
|
||||||
|
|
||||||
struct wlr_cursor_device *c_device = get_cursor_device(cur, dev);
|
struct wlr_cursor_device *c_device = get_cursor_device(cur, dev);
|
||||||
if (!c_device) {
|
if (!c_device) {
|
||||||
wlr_log(WLR_ERROR, "Cannot map device \"%s\" to geometry (not found in"
|
wlr_log(WLR_ERROR, "Cannot map device \"%s\" to geometry (not found in"
|
||||||
|
@ -896,7 +902,5 @@ void wlr_cursor_map_input_to_region(struct wlr_cursor *cur,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
c_device->mapped_box = *box;
|
c_device->mapped_box = *box;
|
||||||
} else {
|
|
||||||
c_device->mapped_box.width = c_device->mapped_box.height = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue