wlr_cursor.c: fix formatting

This commit is contained in:
Tony Crisci 2017-08-29 10:31:39 -04:00
parent 3449777a8d
commit 1fb8bc9340
2 changed files with 34 additions and 24 deletions

View File

@ -8,15 +8,13 @@
#include <wlr/xcursor.h> #include <wlr/xcursor.h>
struct wlr_cursor_state; struct wlr_cursor_state;
//struct wlr_cursor_impl *;
struct wlr_cursor { struct wlr_cursor {
struct wlr_cursor_state *state; struct wlr_cursor_state *state;
//struct wlr_cursor_impl *impl; int x, y;
int x, y;
struct { struct {
struct wl_signal motion; struct wl_signal motion;
struct wl_signal motion_absolute; struct wl_signal motion_absolute;
struct wl_signal button; struct wl_signal button;
struct wl_signal axis; struct wl_signal axis;
@ -30,7 +28,7 @@ struct wlr_cursor {
struct wl_signal tablet_tool_proximity; struct wl_signal tablet_tool_proximity;
struct wl_signal tablet_tool_tip; struct wl_signal tablet_tool_tip;
struct wl_signal tablet_tool_button; struct wl_signal tablet_tool_button;
} events; } events;
}; };
struct wlr_cursor *wlr_cursor_init(); struct wlr_cursor *wlr_cursor_init();
@ -71,24 +69,25 @@ void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev,
* - WLR_INPUT_DEVICE_TABLET_TOOL * - WLR_INPUT_DEVICE_TABLET_TOOL
*/ */
void wlr_cursor_attach_input_device(struct wlr_cursor *cur, void wlr_cursor_attach_input_device(struct wlr_cursor *cur,
struct wlr_input_device *dev); struct wlr_input_device *dev);
void wlr_cursor_detach_input_device(struct wlr_cursor *cur, void wlr_cursor_detach_input_device(struct wlr_cursor *cur,
struct wlr_input_device *dev); struct wlr_input_device *dev);
/** /**
* Uses the given layout to establish the boundaries and movement semantics of * Uses the given layout to establish the boundaries and movement semantics of
* this cursor. Cursors without an output layout allow infinite movement in any * this cursor. Cursors without an output layout allow infinite movement in any
* direction and do not support absolute input events. * direction and do not support absolute input events.
*/ */
void wlr_cursor_attach_output_layout(struct wlr_cursor *cur, void wlr_cursor_attach_output_layout(struct wlr_cursor *cur,
struct wlr_output_layout *l); struct wlr_output_layout *l);
/** /**
* Attaches this cursor to the given output, which must be among the outputs in * Attaches this cursor to the given output, which must be among the outputs in
* the current output_layout for this cursor. This call is invalid for a cursor * the current output_layout for this cursor. This call is invalid for a cursor
* without an associated output layout. * without an associated output layout.
*/ */
void wlr_cursor_map_to_output(struct wlr_cursor *cur, struct wlr_output *output); void wlr_cursor_map_to_output(struct wlr_cursor *cur,
struct wlr_output *output);
/** /**
* Maps all input from a specific input device to a given output. The input * Maps all input from a specific input device to a given output. The input
@ -96,7 +95,7 @@ void wlr_cursor_map_to_output(struct wlr_cursor *cur, struct wlr_output *output)
* outputs in the attached output layout. * outputs in the attached output layout.
*/ */
void wlr_cursor_map_input_to_output(struct wlr_cursor *cur, void wlr_cursor_map_input_to_output(struct wlr_cursor *cur,
struct wlr_input_device *dev, struct wlr_output *output); struct wlr_input_device *dev, struct wlr_output *output);
/** /**
* Maps this cursor to an arbitrary region on the associated wlr_output_layout. * Maps this cursor to an arbitrary region on the associated wlr_output_layout.

View File

@ -110,7 +110,8 @@ static struct wlr_cursor_device *get_cursor_device(struct wlr_cursor *cur,
return ret; return ret;
} }
static void wlr_cursor_warp_unchecked(struct wlr_cursor *cur, double x, double y) { static void wlr_cursor_warp_unchecked(struct wlr_cursor *cur,
double x, double y) {
assert(cur->state->layout); assert(cur->state->layout);
int hotspot_x = 0; int hotspot_x = 0;
int hotspot_y = 0; int hotspot_y = 0;
@ -166,7 +167,7 @@ static struct wlr_geometry *get_mapping(struct wlr_cursor *cur,
if (cur->state->mapped_geometry) { if (cur->state->mapped_geometry) {
return cur->state->mapped_geometry; return cur->state->mapped_geometry;
} }
if(cur->state->mapped_output) { if (cur->state->mapped_output) {
return wlr_output_layout_get_geometry(cur->state->layout, return wlr_output_layout_get_geometry(cur->state->layout,
cur->state->mapped_output); cur->state->mapped_output);
} }
@ -186,7 +187,8 @@ bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev,
wlr_cursor_warp_unchecked(cur, x, y); wlr_cursor_warp_unchecked(cur, x, y);
result = true; result = true;
} }
} else if (wlr_output_layout_contains_point(cur->state->layout, NULL, x, y)) { } else if (wlr_output_layout_contains_point(cur->state->layout, NULL,
x, y)) {
wlr_cursor_warp_unchecked(cur, x, y); wlr_cursor_warp_unchecked(cur, x, y);
result = true; result = true;
} }
@ -243,19 +245,23 @@ void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev,
static void handle_pointer_motion(struct wl_listener *listener, void *data) { static void handle_pointer_motion(struct wl_listener *listener, void *data) {
struct wlr_event_pointer_motion *event = data; struct wlr_event_pointer_motion *event = data;
struct wlr_cursor_device *device = wl_container_of(listener, device, motion); struct wlr_cursor_device *device =
wl_container_of(listener, device, motion);
wl_signal_emit(&device->cursor->events.motion, event); wl_signal_emit(&device->cursor->events.motion, event);
} }
static void handle_pointer_motion_absolute(struct wl_listener *listener, void *data) { static void handle_pointer_motion_absolute(struct wl_listener *listener,
void *data) {
struct wlr_event_pointer_motion_absolute *event = data; struct wlr_event_pointer_motion_absolute *event = data;
struct wlr_cursor_device *device = wl_container_of(listener, device, motion_absolute); struct wlr_cursor_device *device =
wl_container_of(listener, device, motion_absolute);
wl_signal_emit(&device->cursor->events.motion_absolute, event); wl_signal_emit(&device->cursor->events.motion_absolute, event);
} }
static void handle_pointer_button(struct wl_listener *listener, void *data) { static void handle_pointer_button(struct wl_listener *listener, void *data) {
struct wlr_event_pointer_button *event = data; struct wlr_event_pointer_button *event = data;
struct wlr_cursor_device *device = wl_container_of(listener, device, button); struct wlr_cursor_device *device =
wl_container_of(listener, device, button);
wl_signal_emit(&device->cursor->events.button, event); wl_signal_emit(&device->cursor->events.button, event);
} }
@ -307,14 +313,16 @@ static void handle_tablet_tool_axis(struct wl_listener *listener, void *data) {
wl_signal_emit(&device->cursor->events.tablet_tool_axis, event); wl_signal_emit(&device->cursor->events.tablet_tool_axis, event);
} }
static void handle_tablet_tool_button(struct wl_listener *listener, void *data) { static void handle_tablet_tool_button(struct wl_listener *listener,
void *data) {
struct wlr_event_tablet_tool_button *event = data; struct wlr_event_tablet_tool_button *event = data;
struct wlr_cursor_device *device; struct wlr_cursor_device *device;
device = wl_container_of(listener, device, tablet_tool_button); device = wl_container_of(listener, device, tablet_tool_button);
wl_signal_emit(&device->cursor->events.tablet_tool_button, event); wl_signal_emit(&device->cursor->events.tablet_tool_button, event);
} }
static void handle_tablet_tool_proximity(struct wl_listener *listener, void *data) { static void handle_tablet_tool_proximity(struct wl_listener *listener,
void *data) {
struct wlr_event_tablet_tool_proximity *event = data; struct wlr_event_tablet_tool_proximity *event = data;
struct wlr_cursor_device *device; struct wlr_cursor_device *device;
device = wl_container_of(listener, device, tablet_tool_proximity); device = wl_container_of(listener, device, tablet_tool_proximity);
@ -364,7 +372,8 @@ void wlr_cursor_attach_input_device(struct wlr_cursor *cur,
wl_signal_add(&dev->pointer->events.motion, &device->motion); wl_signal_add(&dev->pointer->events.motion, &device->motion);
device->motion.notify = handle_pointer_motion; device->motion.notify = handle_pointer_motion;
wl_signal_add(&dev->pointer->events.motion_absolute, &device->motion_absolute); wl_signal_add(&dev->pointer->events.motion_absolute,
&device->motion_absolute);
device->motion_absolute.notify = handle_pointer_motion_absolute; device->motion_absolute.notify = handle_pointer_motion_absolute;
wl_signal_add(&dev->pointer->events.button, &device->button); wl_signal_add(&dev->pointer->events.button, &device->button);
@ -434,14 +443,16 @@ void wlr_cursor_map_input_to_output(struct wlr_cursor *cur,
struct wlr_input_device *dev, struct wlr_output *output) { struct wlr_input_device *dev, struct wlr_output *output) {
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(L_ERROR, "Cannot map device \"%s\" to output (not found in this cursor)", dev->name); wlr_log(L_ERROR, "Cannot map device \"%s\" to output"
"(not found in this cursor)", dev->name);
return; return;
} }
c_device->mapped_output = output; c_device->mapped_output = output;
} }
void wlr_cursor_map_to_region(struct wlr_cursor *cur, struct wlr_geometry *geo) { void wlr_cursor_map_to_region(struct wlr_cursor *cur,
struct wlr_geometry *geo) {
if (geo && wlr_geometry_empty(geo)) { if (geo && wlr_geometry_empty(geo)) {
wlr_log(L_ERROR, "cannot map cursor to an empty region"); wlr_log(L_ERROR, "cannot map cursor to an empty region");
return; return;