[PATCH 2/2] input: define two variable conventions for input types
Tiago Vignatti
vignatti at freedesktop.org
Mon Dec 12 08:55:44 PST 2011
From: Tiago Vignatti <tiago.vignatti at intel.com>
wl_input_device → winput_dev
wlsc_input_device → input_dev
i.e. respectively type definition and variable name.
Previously we had "device", "dev", "eid", "input_device", "wd", among others
to possibly describe the same type. My intention is that we respect this new
convention when developing from now on, so we benefit from a nicer
readability, easier ways to find code and overall better organization.
For now we're gonna end up with a few repetitive snips like
input_dev->winput_dev, but that will have a better meaning when we introduce
group class for input devices on the protocol.
Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
---
clients/window.c | 32 ++--
compositor/compositor-drm.c | 18 ++--
compositor/compositor-openwfd.c | 2 +-
compositor/compositor-wayland.c | 44 +++---
compositor/compositor-x11.c | 22 ++--
compositor/compositor.c | 300 ++++++++++++++++++++-------------------
compositor/compositor.h | 37 +++--
compositor/data-device.c | 115 ++++++++--------
compositor/evdev.c | 19 ++--
compositor/shell.c | 70 +++++-----
compositor/switcher.c | 9 +-
compositor/tablet-shell.c | 30 ++--
12 files changed, 357 insertions(+), 341 deletions(-)
diff --git a/clients/window.c b/clients/window.c
index e0693da..da2c44f 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -150,7 +150,7 @@ struct item {
struct input {
struct display *display;
- struct wl_input_device *input_device;
+ struct wl_input_device *winput_dev;
struct window *pointer_focus;
struct window *keyboard_focus;
uint32_t current_pointer_image;
@@ -1196,7 +1196,7 @@ input_set_pointer_image(struct input *input, uint32_t time, int pointer)
if (input->current_pointer_image == POINTER_DEFAULT)
return;
- wl_input_device_attach(input->input_device, time, NULL, 0, 0);
+ wl_input_device_attach(input->winput_dev, time, NULL, 0, 0);
input->current_pointer_image = POINTER_DEFAULT;
return;
default:
@@ -1213,7 +1213,7 @@ input_set_pointer_image(struct input *input, uint32_t time, int pointer)
return;
buffer = display_get_buffer_for_surface(display, surface);
- wl_input_device_attach(input->input_device, time, buffer,
+ wl_input_device_attach(input->winput_dev, time, buffer,
pointer_images[pointer].hotspot_x,
pointer_images[pointer].hotspot_y);
}
@@ -1233,7 +1233,7 @@ window_set_focus_item(struct window *window, struct item *focus)
}
static void
-window_handle_motion(void *data, struct wl_input_device *input_device,
+window_handle_motion(void *data, struct wl_input_device *winput_dev,
uint32_t time,
int32_t x, int32_t y, int32_t sx, int32_t sy)
{
@@ -1262,7 +1262,7 @@ window_handle_motion(void *data, struct wl_input_device *input_device,
static void
window_handle_button(void *data,
- struct wl_input_device *input_device,
+ struct wl_input_device *winput_dev,
uint32_t time, uint32_t button, uint32_t state)
{
struct input *input = data;
@@ -1282,7 +1282,7 @@ window_handle_button(void *data,
if (!window->shell_surface)
break;
wl_shell_surface_move(window->shell_surface,
- input_device, time);
+ winput_dev, time);
break;
case WINDOW_RESIZING_TOP:
case WINDOW_RESIZING_BOTTOM:
@@ -1295,7 +1295,7 @@ window_handle_button(void *data,
if (!window->shell_surface)
break;
wl_shell_surface_resize(window->shell_surface,
- input_device, time,
+ winput_dev, time,
location);
break;
case WINDOW_CLIENT_AREA:
@@ -1323,7 +1323,7 @@ window_handle_button(void *data,
}
static void
-window_handle_key(void *data, struct wl_input_device *input_device,
+window_handle_key(void *data, struct wl_input_device *winput_dev,
uint32_t time, uint32_t key, uint32_t state)
{
struct input *input = data;
@@ -1354,7 +1354,7 @@ window_handle_key(void *data, struct wl_input_device *input_device,
static void
window_handle_pointer_focus(void *data,
- struct wl_input_device *input_device,
+ struct wl_input_device *winput_dev,
uint32_t time, struct wl_surface *surface,
int32_t x, int32_t y, int32_t sx, int32_t sy)
{
@@ -1398,7 +1398,7 @@ window_handle_pointer_focus(void *data,
static void
window_handle_keyboard_focus(void *data,
- struct wl_input_device *input_device,
+ struct wl_input_device *winput_dev,
uint32_t time,
struct wl_surface *surface,
struct wl_array *keys)
@@ -1453,7 +1453,7 @@ input_get_position(struct input *input, int32_t *x, int32_t *y)
struct wl_input_device *
input_get_input_device(struct input *input)
{
- return input->input_device;
+ return input->winput_dev;
}
uint32_t
@@ -1703,7 +1703,7 @@ window_move(struct window *window, struct input *input, uint32_t time)
return;
wl_shell_surface_move(window->shell_surface,
- input->input_device, time);
+ input->winput_dev, time);
}
static void
@@ -2123,19 +2123,19 @@ display_add_input(struct display *d, uint32_t id)
memset(input, 0, sizeof *input);
input->display = d;
- input->input_device =
+ input->winput_dev =
wl_display_bind(d->display, id, &wl_input_device_interface);
input->pointer_focus = NULL;
input->keyboard_focus = NULL;
wl_list_insert(d->input_list.prev, &input->link);
- wl_input_device_add_listener(input->input_device,
+ wl_input_device_add_listener(input->winput_dev,
&input_device_listener, input);
- wl_input_device_set_user_data(input->input_device, input);
+ wl_input_device_set_user_data(input->winput_dev, input);
input->data_device =
wl_data_device_manager_get_data_device(d->data_device_manager,
- input->input_device);
+ input->winput_dev);
wl_data_device_add_listener(input->data_device,
&data_device_listener, input);
}
diff --git a/compositor/compositor-drm.c b/compositor/compositor-drm.c
index cd342e6..5b3b5b0 100644
--- a/compositor/compositor-drm.c
+++ b/compositor/compositor-drm.c
@@ -186,7 +186,7 @@ drm_output_prepare_scanout_surface(struct wlsc_output *output_base,
static int
drm_output_set_cursor(struct wlsc_output *output_base,
- struct wlsc_input_device *eid)
+ struct wlsc_input_device *input_dev)
{
struct drm_output *output = (struct drm_output *) output_base;
struct drm_compositor *c =
@@ -196,14 +196,14 @@ drm_output_set_cursor(struct wlsc_output *output_base,
pixman_region32_t cursor_region;
struct gbm_bo *bo;
- if (eid == NULL) {
+ if (input_dev == NULL) {
drmModeSetCursor(c->drm.fd, output->crtc_id, 0, 0, 0);
return 0;
}
pixman_region32_init_rect(&cursor_region,
- eid->sprite->x, eid->sprite->y,
- eid->sprite->width, eid->sprite->height);
+ input_dev->sprite->x, input_dev->sprite->y,
+ input_dev->sprite->width, input_dev->sprite->height);
pixman_region32_intersect_rect(&cursor_region, &cursor_region,
output->base.x, output->base.y,
@@ -213,15 +213,15 @@ drm_output_set_cursor(struct wlsc_output *output_base,
if (!pixman_region32_not_empty(&cursor_region))
goto out;
- if (eid->sprite->image == EGL_NO_IMAGE_KHR)
+ if (input_dev->sprite->image == EGL_NO_IMAGE_KHR)
goto out;
- if (eid->sprite->width > 64 || eid->sprite->height > 64)
+ if (input_dev->sprite->width > 64 || input_dev->sprite->height > 64)
goto out;
bo = gbm_bo_create_from_egl_image(c->gbm,
c->base.display,
- eid->sprite->image, 64, 64,
+ input_dev->sprite->image, 64, 64,
GBM_BO_USE_CURSOR_64X64);
handle = gbm_bo_get_handle(bo).s32;
@@ -241,8 +241,8 @@ drm_output_set_cursor(struct wlsc_output *output_base,
}
ret = drmModeMoveCursor(c->drm.fd, output->crtc_id,
- eid->sprite->x - output->base.x,
- eid->sprite->y - output->base.y);
+ input_dev->sprite->x - output->base.x,
+ input_dev->sprite->y - output->base.y);
if (ret) {
fprintf(stderr, "failed to move cursor: %s\n", strerror(-ret));
goto out;
diff --git a/compositor/compositor-openwfd.c b/compositor/compositor-openwfd.c
index 4cda851..9193ab3 100644
--- a/compositor/compositor-openwfd.c
+++ b/compositor/compositor-openwfd.c
@@ -186,7 +186,7 @@ wfd_output_prepare_scanout_surface(struct wlsc_output *output_base,
static int
wfd_output_set_cursor(struct wlsc_output *output_base,
- struct wlsc_input_device *input)
+ struct wlsc_input_device *input_dev)
{
return -1;
}
diff --git a/compositor/compositor-wayland.c b/compositor/compositor-wayland.c
index 237f56b..18aa074 100644
--- a/compositor/compositor-wayland.c
+++ b/compositor/compositor-wayland.c
@@ -76,23 +76,23 @@ struct wayland_output {
struct wayland_input {
struct wayland_compositor *compositor;
- struct wl_input_device *input_device;
+ struct wl_input_device *winput_dev;
struct wl_list link;
};
static int
wayland_input_create(struct wayland_compositor *c)
{
- struct wlsc_input_device *input;
+ struct wlsc_input_device *input_dev;
- input = malloc(sizeof *input);
- if (input == NULL)
+ input_dev = malloc(sizeof *input_dev);
+ if (input_dev == NULL)
return -1;
- memset(input, 0, sizeof *input);
- wlsc_input_device_init(input, &c->base);
+ memset(input_dev, 0, sizeof *input_dev);
+ wlsc_input_device_init(input_dev, &c->base);
- c->base.input_device = &input->input_device;
+ c->base.winput_dev = &input_dev->winput_dev;
return 0;
}
@@ -215,7 +215,7 @@ wayland_output_prepare_scanout_surface(struct wlsc_output *output_base,
static int
wayland_output_set_cursor(struct wlsc_output *output_base,
- struct wlsc_input_device *input)
+ struct wlsc_input_device *input_dev)
{
return -1;
}
@@ -353,25 +353,25 @@ static const struct wl_output_listener output_listener = {
/* parent input interface */
static void
-input_handle_motion(void *data, struct wl_input_device *input_device,
+input_handle_motion(void *data, struct wl_input_device *winput_dev,
uint32_t time,
int32_t x, int32_t y, int32_t sx, int32_t sy)
{
struct wayland_input *input = data;
struct wayland_compositor *c = input->compositor;
- notify_motion(c->base.input_device, time, sx, sy);
+ notify_motion(c->base.winput_dev, time, sx, sy);
}
static void
input_handle_button(void *data,
- struct wl_input_device *input_device,
+ struct wl_input_device *winput_dev,
uint32_t time, uint32_t button, uint32_t state)
{
struct wayland_input *input = data;
struct wayland_compositor *c = input->compositor;
- notify_button(c->base.input_device, time, button, state);
+ notify_button(c->base.winput_dev, time, button, state);
}
static void
@@ -381,12 +381,12 @@ input_handle_key(void *data, struct wl_input_device *input_device,
struct wayland_input *input = data;
struct wayland_compositor *c = input->compositor;
- notify_key(c->base.input_device, time, key, state);
+ notify_key(c->base.winput_dev, time, key, state);
}
static void
input_handle_pointer_focus(void *data,
- struct wl_input_device *input_device,
+ struct wl_input_device *winput_dev,
uint32_t time, struct wl_surface *surface,
int32_t x, int32_t y, int32_t sx, int32_t sy)
{
@@ -396,16 +396,16 @@ input_handle_pointer_focus(void *data,
if (surface) {
output = wl_surface_get_user_data(surface);
- notify_pointer_focus(c->base.input_device,
+ notify_pointer_focus(c->base.winput_dev,
time, &output->base, sx, sy);
} else {
- notify_pointer_focus(c->base.input_device, time, NULL, 0, 0);
+ notify_pointer_focus(c->base.winput_dev, time, NULL, 0, 0);
}
}
static void
input_handle_keyboard_focus(void *data,
- struct wl_input_device *input_device,
+ struct wl_input_device *winput_dev,
uint32_t time,
struct wl_surface *surface,
struct wl_array *keys)
@@ -416,10 +416,10 @@ input_handle_keyboard_focus(void *data,
if (surface) {
output = wl_surface_get_user_data(surface);
- notify_keyboard_focus(c->base.input_device,
+ notify_keyboard_focus(c->base.winput_dev,
time, &output->base, keys);
} else {
- notify_keyboard_focus(c->base.input_device, time, NULL, NULL);
+ notify_keyboard_focus(c->base.winput_dev, time, NULL, NULL);
}
}
@@ -443,13 +443,13 @@ display_add_input(struct wayland_compositor *c, uint32_t id)
memset(input, 0, sizeof *input);
input->compositor = c;
- input->input_device = wl_display_bind(c->parent.display,
+ input->winput_dev = wl_display_bind(c->parent.display,
id, &wl_input_device_interface);
wl_list_insert(c->input_list.prev, &input->link);
- wl_input_device_add_listener(input->input_device,
+ wl_input_device_add_listener(input->winput_dev,
&input_device_listener, input);
- wl_input_device_set_user_data(input->input_device, input);
+ wl_input_device_set_user_data(input->winput_dev, input);
}
static void
diff --git a/compositor/compositor-x11.c b/compositor/compositor-x11.c
index a781131..2283bcf 100644
--- a/compositor/compositor-x11.c
+++ b/compositor/compositor-x11.c
@@ -97,7 +97,7 @@ x11_input_create(struct x11_compositor *c)
memset(input, 0, sizeof *input);
wlsc_input_device_init(&input->base, &c->base);
- c->base.input_device = &input->base.input_device;
+ c->base.winput_dev = &input->base.winput_dev;
return 0;
}
@@ -219,7 +219,7 @@ x11_output_prepare_scanout_surface(struct wlsc_output *output_base,
static int
x11_output_set_cursor(struct wlsc_output *output_base,
- struct wlsc_input_device *input)
+ struct wlsc_input_device *input_dev)
{
return -1;
}
@@ -483,7 +483,7 @@ x11_compositor_deliver_button_event(struct x11_compositor *c,
return;
}
- notify_button(c->base.input_device,
+ notify_button(c->base.winput_dev,
wlsc_compositor_get_time(), button, state);
}
@@ -539,7 +539,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
/* Deliver the held key release now
* and fall through and handle the new
* event below. */
- notify_key(c->base.input_device,
+ notify_key(c->base.winput_dev,
wlsc_compositor_get_time(),
key_release->detail - 8, 0);
free(prev);
@@ -562,7 +562,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
}
output = x11_compositor_find_output(c, focus_in->event);
- notify_keyboard_focus(c->base.input_device,
+ notify_keyboard_focus(c->base.winput_dev,
wlsc_compositor_get_time(),
&output->base, &c->keys);
@@ -578,7 +578,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
switch (event->response_type & ~0x80) {
case XCB_KEY_PRESS:
key_press = (xcb_key_press_event_t *) event;
- notify_key(c->base.input_device,
+ notify_key(c->base.winput_dev,
wlsc_compositor_get_time(),
key_press->detail - 8, 1);
break;
@@ -594,7 +594,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
case XCB_MOTION_NOTIFY:
motion_notify = (xcb_motion_notify_event_t *) event;
output = x11_compositor_find_output(c, motion_notify->event);
- notify_motion(c->base.input_device,
+ notify_motion(c->base.winput_dev,
wlsc_compositor_get_time(),
output->base.x + motion_notify->event_x,
output->base.y + motion_notify->event_y);
@@ -612,7 +612,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
if (enter_notify->state >= Button1Mask)
break;
output = x11_compositor_find_output(c, enter_notify->event);
- notify_pointer_focus(c->base.input_device,
+ notify_pointer_focus(c->base.winput_dev,
wlsc_compositor_get_time(),
&output->base,
output->base.x + enter_notify->event_x,
@@ -624,7 +624,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
if (enter_notify->state >= Button1Mask)
break;
output = x11_compositor_find_output(c, enter_notify->event);
- notify_pointer_focus(c->base.input_device,
+ notify_pointer_focus(c->base.winput_dev,
wlsc_compositor_get_time(),
NULL,
output->base.x + enter_notify->event_x,
@@ -650,7 +650,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
focus_in = (xcb_focus_in_event_t *) event;
if (focus_in->mode == XCB_NOTIFY_MODE_WHILE_GRABBED)
break;
- notify_keyboard_focus(c->base.input_device,
+ notify_keyboard_focus(c->base.winput_dev,
wlsc_compositor_get_time(),
NULL, NULL);
break;
@@ -666,7 +666,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
switch (prev ? prev->response_type & ~0x80 : 0x80) {
case XCB_KEY_RELEASE:
key_release = (xcb_key_press_event_t *) prev;
- notify_key(c->base.input_device,
+ notify_key(c->base.winput_dev,
wlsc_compositor_get_time(),
key_release->detail - 8, 0);
free(prev);
diff --git a/compositor/compositor.c b/compositor/compositor.c
index c2575ac..31adbcb 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -319,7 +319,7 @@ wlsc_compositor_get_time(void)
WL_EXPORT void
wlsc_compositor_repick(struct wlsc_compositor *compositor)
{
- struct wlsc_input_device *device;
+ struct wlsc_input_device *input_dev;
struct wlsc_surface *surface;
int32_t sx, sy;
uint32_t time;
@@ -328,15 +328,15 @@ wlsc_compositor_repick(struct wlsc_compositor *compositor)
return;
time = wlsc_compositor_get_time();
- wl_list_for_each(device, &compositor->input_device_list, link) {
- if (device->input_device.grab)
+ wl_list_for_each(input_dev, &compositor->input_device_list, link) {
+ if (input_dev->winput_dev.grab)
continue;
- surface = pick_surface(&device->input_device, &sx, &sy);
- wl_input_device_set_pointer_focus(&device->input_device,
+ surface = pick_surface(&input_dev->winput_dev, &sx, &sy);
+ wl_input_device_set_pointer_focus(&input_dev->winput_dev,
&surface->surface,
time,
- device->input_device.x,
- device->input_device.y,
+ input_dev->winput_dev.x,
+ input_dev->winput_dev.y,
sx, sy);
}
}
@@ -794,17 +794,18 @@ fade_output(struct wlsc_output *output,
static void
wlsc_output_set_cursor(struct wlsc_output *output,
- struct wl_input_device *dev, int force_sw)
+ struct wl_input_device *winput_dev, int force_sw)
{
struct wlsc_compositor *ec = output->compositor;
- struct wlsc_input_device *device = (struct wlsc_input_device *) dev;
+ struct wlsc_input_device *input_dev =
+ (struct wlsc_input_device *) winput_dev;
pixman_region32_t cursor_region;
int use_hardware_cursor = 1, prior_was_hardware;
pixman_region32_init_rect(&cursor_region,
- device->sprite->x, device->sprite->y,
- device->sprite->width,
- device->sprite->height);
+ input_dev->sprite->x, input_dev->sprite->y,
+ input_dev->sprite->width,
+ input_dev->sprite->height);
pixman_region32_intersect(&cursor_region, &cursor_region, &output->region);
@@ -813,25 +814,25 @@ wlsc_output_set_cursor(struct wlsc_output *output,
goto out;
}
- prior_was_hardware = wl_list_empty(&device->sprite->link);
- if (force_sw || output->set_hardware_cursor(output, device) < 0) {
+ prior_was_hardware = wl_list_empty(&input_dev->sprite->link);
+ if (force_sw || output->set_hardware_cursor(output, input_dev) < 0) {
if (prior_was_hardware) {
- wlsc_surface_damage(device->sprite);
+ wlsc_surface_damage(input_dev->sprite);
output->set_hardware_cursor(output, NULL);
}
use_hardware_cursor = 0;
} else if (!prior_was_hardware) {
- wlsc_surface_damage_below(device->sprite);
+ wlsc_surface_damage_below(input_dev->sprite);
}
/* Remove always to be on top. */
- wl_list_remove(&device->sprite->link);
+ wl_list_remove(&input_dev->sprite->link);
if (!use_hardware_cursor && ec->focus) {
- wl_list_insert(&ec->surface_list, &device->sprite->link);
- device->sprite->output = output;
+ wl_list_insert(&ec->surface_list, &input_dev->sprite->link);
+ input_dev->sprite->output = output;
} else {
- wl_list_init(&device->sprite->link);
- device->sprite->output = NULL;
+ wl_list_init(&input_dev->sprite->link);
+ input_dev->sprite->output = NULL;
}
out:
@@ -871,7 +872,7 @@ wlsc_output_repaint(struct wlsc_output *output)
1, GL_FALSE, output->matrix.d);
glUniform1i(ec->texture_shader.tex_uniform, 0);
- wlsc_output_set_cursor(output, ec->input_device,
+ wlsc_output_set_cursor(output, ec->winput_dev,
ec->fade.spring.current >= 0.001);
pixman_region32_init(&new_damage);
@@ -1146,48 +1147,48 @@ const static struct wl_surface_interface surface_interface = {
};
static void
-wlsc_input_device_attach(struct wlsc_input_device *device,
+wlsc_input_device_attach(struct wlsc_input_device *input_dev,
int x, int y, int width, int height)
{
- wlsc_surface_damage_below(device->sprite);
+ wlsc_surface_damage_below(input_dev->sprite);
- device->hotspot_x = x;
- device->hotspot_y = y;
+ input_dev->hotspot_x = x;
+ input_dev->hotspot_y = y;
- device->sprite->x = device->input_device.x - device->hotspot_x;
- device->sprite->y = device->input_device.y - device->hotspot_y;
- device->sprite->width = width;
- device->sprite->height = height;
+ input_dev->sprite->x = input_dev->winput_dev.x - input_dev->hotspot_x;
+ input_dev->sprite->y = input_dev->winput_dev.y - input_dev->hotspot_y;
+ input_dev->sprite->width = width;
+ input_dev->sprite->height = height;
- wlsc_surface_damage(device->sprite);
+ wlsc_surface_damage(input_dev->sprite);
}
static void
-wlsc_input_device_attach_buffer(struct wlsc_input_device *device,
+wlsc_input_device_attach_buffer(struct wlsc_input_device *input_dev,
struct wl_buffer *buffer, int x, int y)
{
- wlsc_buffer_attach(buffer, &device->sprite->surface);
- wlsc_input_device_attach(device, x, y, buffer->width, buffer->height);
+ wlsc_buffer_attach(buffer, &input_dev->sprite->surface);
+ wlsc_input_device_attach(input_dev, x, y, buffer->width, buffer->height);
}
static void
-wlsc_input_device_attach_sprite(struct wlsc_input_device *device,
+wlsc_input_device_attach_sprite(struct wlsc_input_device *input_dev,
struct wlsc_sprite *sprite, int x, int y)
{
if (!sprite)
return;
- wlsc_sprite_attach(sprite, &device->sprite->surface);
- wlsc_input_device_attach(device, x, y, sprite->width, sprite->height);
+ wlsc_sprite_attach(sprite, &input_dev->sprite->surface);
+ wlsc_input_device_attach(input_dev, x, y, sprite->width, sprite->height);
}
WL_EXPORT void
-wlsc_input_device_set_pointer_image(struct wlsc_input_device *device,
+wlsc_input_device_set_pointer_image(struct wlsc_input_device *input_dev,
enum wlsc_pointer_type type)
{
- struct wlsc_compositor *compositor = device->compositor;
+ struct wlsc_compositor *compositor = input_dev->compositor;
- wlsc_input_device_attach_sprite(device,
+ wlsc_input_device_attach_sprite(input_dev,
compositor->pointer_sprites[type],
pointer_images[type].hotspot_x,
pointer_images[type].hotspot_y);
@@ -1230,16 +1231,18 @@ wlsc_surface_transform(struct wlsc_surface *surface,
}
WL_EXPORT struct wlsc_surface *
-pick_surface(struct wl_input_device *device, int32_t *sx, int32_t *sy)
+pick_surface(struct wl_input_device *winput_dev, int32_t *sx, int32_t *sy)
{
- struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
- struct wlsc_compositor *ec = wd->compositor;
+ struct wlsc_input_device *input_dev =
+ (struct wlsc_input_device *) winput_dev;
+ struct wlsc_compositor *ec = input_dev->compositor;
struct wlsc_surface *es;
wl_list_for_each(es, &ec->surface_list, link) {
if (es->surface.resource.client == NULL)
continue;
- wlsc_surface_transform(es, device->x, device->y, sx, sy);
+ wlsc_surface_transform(es, winput_dev->x, winput_dev->y, sx,
+ sy);
if (0 <= *sx && *sx < es->width &&
0 <= *sy && *sy < es->height)
return es;
@@ -1253,10 +1256,10 @@ static void
implicit_grab_motion(struct wl_grab *grab,
uint32_t time, int32_t x, int32_t y)
{
- struct wlsc_input_device *device =
+ struct wlsc_input_device *input_dev =
(struct wlsc_input_device *) grab->winput_dev;
struct wlsc_surface *es =
- (struct wlsc_surface *) device->input_device.pointer_focus;
+ (struct wlsc_surface *) input_dev->winput_dev.pointer_focus;
int32_t sx, sy;
struct wl_resource *resource;
@@ -1339,13 +1342,14 @@ idle_handler(void *data)
}
WL_EXPORT void
-notify_motion(struct wl_input_device *device, uint32_t time, int x, int y)
+notify_motion(struct wl_input_device *winput_dev, uint32_t time, int x, int y)
{
struct wlsc_surface *es;
struct wlsc_output *output;
const struct wl_grab_interface *interface;
- struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
- struct wlsc_compositor *ec = wd->compositor;
+ struct wlsc_input_device *input_dev =
+ (struct wlsc_input_device *) winput_dev;
+ struct wlsc_compositor *ec = input_dev->compositor;
int32_t sx, sy;
int x_valid = 0, y_valid = 0;
int min_x = INT_MAX, min_y = INT_MAX, max_x = INT_MIN, max_y = INT_MIN;
@@ -1384,39 +1388,39 @@ notify_motion(struct wl_input_device *device, uint32_t time, int x, int y)
y = max_y;
}
- device->x = x;
- device->y = y;
+ winput_dev->x = x;
+ winput_dev->y = y;
- if (device->grab) {
- interface = device->grab->interface;
- interface->motion(device->grab, time, x, y);
+ if (winput_dev->grab) {
+ interface = winput_dev->grab->interface;
+ interface->motion(winput_dev->grab, time, x, y);
} else {
- es = pick_surface(device, &sx, &sy);
- wl_input_device_set_pointer_focus(device,
+ es = pick_surface(winput_dev, &sx, &sy);
+ wl_input_device_set_pointer_focus(winput_dev,
&es->surface,
time, x, y, sx, sy);
- if (device->pointer_focus_resource)
- wl_resource_post_event(device->pointer_focus_resource,
+ if (winput_dev->pointer_focus_resource)
+ wl_resource_post_event(winput_dev->pointer_focus_resource,
WL_INPUT_DEVICE_MOTION,
time, x, y, sx, sy);
}
- wlsc_surface_damage_below(wd->sprite);
+ wlsc_surface_damage_below(input_dev->sprite);
- wd->sprite->x = device->x - wd->hotspot_x;
- wd->sprite->y = device->y - wd->hotspot_y;
+ input_dev->sprite->x = winput_dev->x - input_dev->hotspot_x;
+ input_dev->sprite->y = winput_dev->y - input_dev->hotspot_y;
- wlsc_surface_damage(wd->sprite);
+ wlsc_surface_damage(input_dev->sprite);
}
WL_EXPORT void
wlsc_surface_activate(struct wlsc_surface *surface,
- struct wlsc_input_device *device, uint32_t time)
+ struct wlsc_input_device *input_dev, uint32_t time)
{
wlsc_surface_raise(surface);
- wl_input_device_set_keyboard_focus(&device->input_device,
+ wl_input_device_set_keyboard_focus(&input_dev->winput_dev,
&surface->surface, time);
- wlsc_data_device_set_keyboard_focus(device);
+ wlsc_data_device_set_keyboard_focus(input_dev);
}
struct wlsc_binding {
@@ -1429,14 +1433,15 @@ struct wlsc_binding {
};
WL_EXPORT void
-notify_button(struct wl_input_device *device,
+notify_button(struct wl_input_device *winput_dev,
uint32_t time, int32_t button, int32_t state)
{
- struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
- struct wlsc_compositor *compositor = wd->compositor;
+ struct wlsc_input_device *input_dev =
+ (struct wlsc_input_device *) winput_dev;
+ struct wlsc_compositor *compositor = input_dev->compositor;
struct wlsc_binding *b;
struct wlsc_surface *surface =
- (struct wlsc_surface *) device->pointer_focus;
+ (struct wlsc_surface *) winput_dev->pointer_focus;
int32_t sx, sy;
if (state)
@@ -1444,38 +1449,38 @@ notify_button(struct wl_input_device *device,
else
wlsc_compositor_idle_release(compositor);
- if (state && surface && device->grab == NULL) {
+ if (state && surface && winput_dev->grab == NULL) {
compositor->shell->activate(compositor->shell,
- surface, wd, time);
- wl_input_device_start_grab(device,
- &device->implicit_grab,
+ surface, input_dev, time);
+ wl_input_device_start_grab(winput_dev,
+ &winput_dev->implicit_grab,
button, time);
}
wl_list_for_each(b, &compositor->binding_list, link) {
if (b->button == button &&
- b->modifier == wd->modifier_state && state) {
- b->handler(&wd->input_device,
+ b->modifier == input_dev->modifier_state && state) {
+ b->handler(&input_dev->winput_dev,
time, 0, button, state, b->data);
break;
}
}
- if (device->grab)
- device->grab->interface->button(device->grab, time,
+ if (winput_dev->grab)
+ winput_dev->grab->interface->button(winput_dev->grab, time,
button, state);
- if (!state && device->grab && device->grab_button == button) {
- wl_input_device_end_grab(device, time);
- surface = pick_surface(device, &sx, &sy);
- wl_input_device_set_pointer_focus(device, &surface->surface,
- time, device->x, device->y,
- sx, sy);
+ if (!state && winput_dev->grab && winput_dev->grab_button == button) {
+ wl_input_device_end_grab(winput_dev, time);
+ surface = pick_surface(winput_dev, &sx, &sy);
+ wl_input_device_set_pointer_focus(winput_dev, &surface->surface,
+ time, winput_dev->x,
+ winput_dev->y, sx, sy);
}
}
static void
-terminate_binding(struct wl_input_device *device, uint32_t time,
+terminate_binding(struct wl_input_device *winput_dev, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data)
{
struct wlsc_compositor *compositor = data;
@@ -1513,7 +1518,7 @@ wlsc_binding_destroy(struct wlsc_binding *binding)
}
static void
-update_modifier_state(struct wlsc_input_device *device,
+update_modifier_state(struct wlsc_input_device *input_dev,
uint32_t key, uint32_t state)
{
uint32_t modifier;
@@ -1540,17 +1545,17 @@ update_modifier_state(struct wlsc_input_device *device,
}
if (state)
- device->modifier_state |= modifier;
+ input_dev->modifier_state |= modifier;
else
- device->modifier_state &= ~modifier;
+ input_dev->modifier_state &= ~modifier;
}
WL_EXPORT void
-notify_key(struct wl_input_device *device,
+notify_key(struct wl_input_device *winput_dev,
uint32_t time, uint32_t key, uint32_t state)
{
- struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
- struct wlsc_compositor *compositor = wd->compositor;
+ struct wlsc_input_device *input_dev = (struct wlsc_input_device *) winput_dev;
+ struct wlsc_compositor *compositor = input_dev->compositor;
uint32_t *k, *end;
struct wlsc_binding *b;
@@ -1561,69 +1566,69 @@ notify_key(struct wl_input_device *device,
wl_list_for_each(b, &compositor->binding_list, link) {
if (b->key == key &&
- b->modifier == wd->modifier_state) {
- b->handler(&wd->input_device,
+ b->modifier == input_dev->modifier_state) {
+ b->handler(&input_dev->winput_dev,
time, key, 0, state, b->data);
break;
}
}
- update_modifier_state(wd, key, state);
- end = device->keys.data + device->keys.size;
- for (k = device->keys.data; k < end; k++) {
+ update_modifier_state(input_dev, key, state);
+ end = winput_dev->keys.data + winput_dev->keys.size;
+ for (k = winput_dev->keys.data; k < end; k++) {
if (*k == key)
*k = *--end;
}
- device->keys.size = (void *) end - device->keys.data;
+ winput_dev->keys.size = (void *) end - winput_dev->keys.data;
if (state) {
- k = wl_array_add(&device->keys, sizeof *k);
+ k = wl_array_add(&winput_dev->keys, sizeof *k);
*k = key;
}
- if (device->keyboard_focus_resource)
- wl_resource_post_event(device->keyboard_focus_resource,
+ if (winput_dev->keyboard_focus_resource)
+ wl_resource_post_event(winput_dev->keyboard_focus_resource,
WL_INPUT_DEVICE_KEY, time, key, state);
}
WL_EXPORT void
-notify_pointer_focus(struct wl_input_device *device,
+notify_pointer_focus(struct wl_input_device *winput_dev,
uint32_t time, struct wlsc_output *output,
int32_t x, int32_t y)
{
- struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
- struct wlsc_compositor *compositor = wd->compositor;
+ struct wlsc_input_device *input_dev = (struct wlsc_input_device *) winput_dev;
+ struct wlsc_compositor *compositor = input_dev->compositor;
struct wlsc_surface *es;
int32_t sx, sy;
if (output) {
- device->x = x;
- device->y = y;
- es = pick_surface(device, &sx, &sy);
- wl_input_device_set_pointer_focus(device,
+ winput_dev->x = x;
+ winput_dev->y = y;
+ es = pick_surface(winput_dev, &sx, &sy);
+ wl_input_device_set_pointer_focus(winput_dev,
&es->surface,
time, x, y, sx, sy);
compositor->focus = 1;
- wd->sprite->x = device->x - wd->hotspot_x;
- wd->sprite->y = device->y - wd->hotspot_y;
+ input_dev->sprite->x = winput_dev->x - input_dev->hotspot_x;
+ input_dev->sprite->y = winput_dev->y - input_dev->hotspot_y;
} else {
- wl_input_device_set_pointer_focus(device, NULL,
+ wl_input_device_set_pointer_focus(winput_dev, NULL,
time, 0, 0, 0, 0);
compositor->focus = 0;
}
- wlsc_surface_damage(wd->sprite);
+ wlsc_surface_damage(input_dev->sprite);
}
WL_EXPORT void
-notify_keyboard_focus(struct wl_input_device *device,
+notify_keyboard_focus(struct wl_input_device *winput_dev,
uint32_t time, struct wlsc_output *output,
struct wl_array *keys)
{
- struct wlsc_input_device *wd =
- (struct wlsc_input_device *) device;
- struct wlsc_compositor *compositor = wd->compositor;
+ struct wlsc_input_device *input_dev =
+ (struct wlsc_input_device *) winput_dev;
+ struct wlsc_compositor *compositor = input_dev->compositor;
struct wlsc_surface *es;
uint32_t *k, *end;
@@ -1634,24 +1639,24 @@ notify_keyboard_focus(struct wl_input_device *device,
es = NULL;
if (output) {
- wl_array_copy(&wd->input_device.keys, keys);
- wd->modifier_state = 0;
- end = device->keys.data + device->keys.size;
- for (k = device->keys.data; k < end; k++) {
+ wl_array_copy(&input_dev->winput_dev.keys, keys);
+ input_dev->modifier_state = 0;
+ end = winput_dev->keys.data + winput_dev->keys.size;
+ for (k = winput_dev->keys.data; k < end; k++) {
wlsc_compositor_idle_inhibit(compositor);
- update_modifier_state(wd, *k, 1);
+ update_modifier_state(input_dev, *k, 1);
}
if (es && es->surface.resource.client)
- wl_input_device_set_keyboard_focus(&wd->input_device,
+ wl_input_device_set_keyboard_focus(&input_dev->winput_dev,
&es->surface, time);
} else {
- end = device->keys.data + device->keys.size;
- for (k = device->keys.data; k < end; k++)
+ end = winput_dev->keys.data + winput_dev->keys.size;
+ for (k = winput_dev->keys.data; k < end; k++)
wlsc_compositor_idle_release(compositor);
- wd->modifier_state = 0;
- wl_input_device_set_keyboard_focus(&wd->input_device,
+ input_dev->modifier_state = 0;
+ wl_input_device_set_keyboard_focus(&input_dev->winput_dev,
NULL, time);
}
}
@@ -1663,23 +1668,23 @@ input_device_attach(struct wl_client *client,
uint32_t time,
struct wl_resource *buffer_resource, int32_t x, int32_t y)
{
- struct wlsc_input_device *device = resource->data;
+ struct wlsc_input_device *input_dev = resource->data;
struct wl_buffer *buffer;
- if (time < device->input_device.pointer_focus_time)
+ if (time < input_dev->winput_dev.pointer_focus_time)
return;
#if 0
- if (device->input_device.pointer_focus == NULL)
+ if (device->winput_dev.pointer_focus == NULL)
return;
- if (device->input_device.pointer_focus->resource.client != client)
+ if (device->winput_dev.pointer_focus->resource.client != client)
return;
#endif
if (buffer_resource) {
buffer = buffer_resource->data;
- wlsc_input_device_attach_buffer(device, buffer, x, y);
+ wlsc_input_device_attach_buffer(input_dev, buffer, x, y);
} else {
- wlsc_input_device_set_pointer_image(device,
+ wlsc_input_device_set_pointer_image(input_dev,
WLSC_POINTER_LEFT_PTR);
return;
}
@@ -1699,41 +1704,40 @@ static void
bind_input_device(struct wl_client *client,
void *data, uint32_t version, uint32_t id)
{
- struct wl_input_device *device = data;
+ struct wl_input_device *winput_dev = data;
struct wl_resource *resource;
resource = wl_client_add_object(client, &wl_input_device_interface,
&input_device_interface, id, data);
- wl_list_insert(&device->resource_list, &resource->link);
+ wl_list_insert(&winput_dev->resource_list, &resource->link);
resource->destroy = unbind_input_device;
}
WL_EXPORT void
-wlsc_input_device_init(struct wlsc_input_device *device,
+wlsc_input_device_init(struct wlsc_input_device *input_dev,
struct wlsc_compositor *ec)
{
- wl_input_device_init(&device->input_device);
- wl_list_init(&device->drag_resource_list);
+ wl_input_device_init(&input_dev->winput_dev);
+ wl_list_init(&input_dev->drag_resource_list);
wl_display_add_global(ec->wl_display, &wl_input_device_interface,
- device, bind_input_device);
+ input_dev, bind_input_device);
- device->sprite = wlsc_surface_create(ec,
- device->input_device.x,
- device->input_device.y, 32, 32);
- wl_list_insert(&ec->surface_list, &device->sprite->link);
+ input_dev->sprite = wlsc_surface_create(ec, input_dev->winput_dev.x,
+ input_dev->winput_dev.y, 32, 32);
+ wl_list_insert(&ec->surface_list, &input_dev->sprite->link);
- device->compositor = ec;
- device->hotspot_x = 16;
- device->hotspot_y = 16;
- device->modifier_state = 0;
+ input_dev->compositor = ec;
+ input_dev->hotspot_x = 16;
+ input_dev->hotspot_y = 16;
+ input_dev->modifier_state = 0;
- device->input_device.implicit_grab.interface = &implicit_grab_interface;
+ input_dev->winput_dev.implicit_grab.interface = &implicit_grab_interface;
- wl_list_insert(ec->input_device_list.prev, &device->link);
+ wl_list_insert(ec->input_device_list.prev, &input_dev->link);
- wlsc_input_device_set_pointer_image(device, WLSC_POINTER_LEFT_PTR);
- device->selection_data_source = NULL;
+ wlsc_input_device_set_pointer_image(input_dev, WLSC_POINTER_LEFT_PTR);
+ input_dev->selection_data_source = NULL;
}
static void
diff --git a/compositor/compositor.h b/compositor/compositor.h
index 7f1dd74..6899242 100644
--- a/compositor/compositor.h
+++ b/compositor/compositor.h
@@ -92,7 +92,7 @@ struct wlsc_output {
int (*prepare_scanout_surface)(struct wlsc_output *output,
struct wlsc_surface *es);
int (*set_hardware_cursor)(struct wlsc_output *output,
- struct wlsc_input_device *input);
+ struct wlsc_input_device *input_dev);
void (*destroy)(struct wlsc_output *output);
};
@@ -110,8 +110,15 @@ enum wlsc_pointer_type {
WLSC_POINTER_IBEAM,
};
+/*
+ * In principle, we use the following convention for input variables:
+ * wl_input_device → winput_dev
+ * wlsc_input_device → input_dev
+ *
+ * i.e. respectively type definition and variable name.
+ */
struct wlsc_input_device {
- struct wl_input_device input_device;
+ struct wl_input_device winput_dev;
struct wlsc_compositor *compositor;
struct wlsc_surface *sprite;
int32_t hotspot_x, hotspot_y;
@@ -171,7 +178,7 @@ struct wlsc_spring {
struct wlsc_shell {
void (*activate)(struct wlsc_shell *shell,
struct wlsc_surface *es,
- struct wlsc_input_device *device, uint32_t time);
+ struct wlsc_input_device *input_dev, uint32_t time);
void (*lock)(struct wlsc_shell *shell);
void (*unlock)(struct wlsc_shell *shell);
void (*map)(struct wlsc_shell *shell, struct wlsc_surface *surface,
@@ -203,7 +210,7 @@ struct wlsc_compositor {
struct wlsc_shell *shell;
/* There can be more than one, but not right now... */
- struct wl_input_device *input_device;
+ struct wl_input_device *winput_dev;
struct wl_list output_list;
struct wl_list input_device_list;
@@ -289,26 +296,26 @@ wlsc_spring_done(struct wlsc_spring *spring);
void
wlsc_surface_activate(struct wlsc_surface *surface,
- struct wlsc_input_device *device, uint32_t time);
+ struct wlsc_input_device *input_dev, uint32_t time);
void
-notify_motion(struct wl_input_device *device,
+notify_motion(struct wl_input_device *winput_dev,
uint32_t time, int x, int y);
void
-notify_button(struct wl_input_device *device,
+notify_button(struct wl_input_device *winput_dev,
uint32_t time, int32_t button, int32_t state);
void
-notify_key(struct wl_input_device *device,
+notify_key(struct wl_input_device *winput_dev,
uint32_t time, uint32_t key, uint32_t state);
void
-notify_pointer_focus(struct wl_input_device *device,
+notify_pointer_focus(struct wl_input_device *winput_dev,
uint32_t time,
struct wlsc_output *output,
int32_t x, int32_t y);
void
-notify_keyboard_focus(struct wl_input_device *device,
+notify_keyboard_focus(struct wl_input_device *winput_dev,
uint32_t time, struct wlsc_output *output,
struct wl_array *keys);
@@ -332,7 +339,7 @@ void
wlsc_compositor_activity(struct wlsc_compositor *compositor);
struct wlsc_binding;
-typedef void (*wlsc_binding_handler_t)(struct wl_input_device *device,
+typedef void (*wlsc_binding_handler_t)(struct wl_input_device *winput_dev,
uint32_t time, uint32_t key,
uint32_t button,
uint32_t state, void *data);
@@ -366,10 +373,10 @@ wlsc_surface_damage_rectangle(struct wlsc_surface *surface,
int32_t width, int32_t height);
void
-wlsc_input_device_set_pointer_image(struct wlsc_input_device *device,
+wlsc_input_device_set_pointer_image(struct wlsc_input_device *input_dev,
enum wlsc_pointer_type type);
struct wlsc_surface *
-pick_surface(struct wl_input_device *device, int32_t *sx, int32_t *sy);
+pick_surface(struct wl_input_device *winput_dev, int32_t *sx, int32_t *sy);
uint32_t
wlsc_compositor_get_time(void);
@@ -387,7 +394,7 @@ void
wlsc_output_destroy(struct wlsc_output *output);
void
-wlsc_input_device_init(struct wlsc_input_device *device,
+wlsc_input_device_init(struct wlsc_input_device *input_dev,
struct wlsc_compositor *ec);
void
@@ -437,7 +444,7 @@ wlsc_client_launch(struct wlsc_compositor *compositor,
int
wlsc_data_device_manager_init(struct wlsc_compositor *compositor);
void
-wlsc_data_device_set_keyboard_focus(struct wlsc_input_device *device);
+wlsc_data_device_set_keyboard_focus(struct wlsc_input_device *input_dev);
void
wlsc_watch_process(struct wlsc_process *process);
diff --git a/compositor/data-device.c b/compositor/data-device.c
index c39465f..87a9b7d 100644
--- a/compositor/data-device.c
+++ b/compositor/data-device.c
@@ -159,47 +159,47 @@ static void
destroy_drag_focus(struct wl_listener *listener,
struct wl_resource *resource, uint32_t time)
{
- struct wlsc_input_device *device =
+ struct wlsc_input_device *input_dev =
container_of(listener, struct wlsc_input_device,
drag_focus_listener);
- device->drag_focus_resource = NULL;
+ input_dev->drag_focus_resource = NULL;
}
static void
-drag_set_focus(struct wlsc_input_device *device,
+drag_set_focus(struct wlsc_input_device *input_dev,
struct wl_surface *surface, uint32_t time,
int32_t x, int32_t y)
{
struct wl_resource *resource, *offer;
- if (device->drag_focus == surface)
+ if (input_dev->drag_focus == surface)
return;
- if (device->drag_focus_resource) {
- wl_resource_post_event(device->drag_focus_resource,
+ if (input_dev->drag_focus_resource) {
+ wl_resource_post_event(input_dev->drag_focus_resource,
WL_DATA_DEVICE_LEAVE);
- wl_list_remove(&device->drag_focus_listener.link);
- device->drag_focus_resource = NULL;
- device->drag_focus = NULL;
+ wl_list_remove(&input_dev->drag_focus_listener.link);
+ input_dev->drag_focus_resource = NULL;
+ input_dev->drag_focus = NULL;
}
if (surface)
- resource = find_resource(&device->drag_resource_list,
+ resource = find_resource(&input_dev->drag_resource_list,
surface->resource.client);
if (surface && resource) {
- offer = wlsc_data_source_send_offer(device->drag_data_source,
+ offer = wlsc_data_source_send_offer(input_dev->drag_data_source,
resource);
wl_resource_post_event(resource,
WL_DATA_DEVICE_ENTER,
time, surface, x, y, offer);
- device->drag_focus = surface;
- device->drag_focus_listener.func = destroy_drag_focus;
+ input_dev->drag_focus = surface;
+ input_dev->drag_focus_listener.func = destroy_drag_focus;
wl_list_insert(resource->destroy_listener_list.prev,
- &device->drag_focus_listener.link);
- device->drag_focus_resource = resource;
+ &input_dev->drag_focus_listener.link);
+ input_dev->drag_focus_resource = resource;
}
}
@@ -207,15 +207,15 @@ static void
drag_grab_motion(struct wl_grab *grab,
uint32_t time, int32_t x, int32_t y)
{
- struct wlsc_input_device *device =
+ struct wlsc_input_device *input_dev =
container_of(grab, struct wlsc_input_device, grab);
struct wlsc_surface *es;
- es = pick_surface(&device->input_device, &x, &y);
- drag_set_focus(device, &es->surface, time, x, y);
+ es = pick_surface(&input_dev->winput_dev, &x, &y);
+ drag_set_focus(input_dev, &es->surface, time, x, y);
- if (es && device->drag_focus_resource)
- wl_resource_post_event(device->drag_focus_resource,
+ if (es && input_dev->drag_focus_resource)
+ wl_resource_post_event(input_dev->drag_focus_resource,
WL_DATA_DEVICE_MOTION, time, x, y);
}
@@ -228,16 +228,16 @@ drag_grab_button(struct wl_grab *grab,
static void
drag_grab_end(struct wl_grab *grab, uint32_t time)
{
- struct wlsc_input_device *device =
+ struct wlsc_input_device *input_dev =
container_of(grab, struct wlsc_input_device, grab);
- if (device->drag_focus_resource)
- wl_resource_post_event(device->drag_focus_resource,
+ if (input_dev->drag_focus_resource)
+ wl_resource_post_event(input_dev->drag_focus_resource,
WL_DATA_DEVICE_DROP);
- drag_set_focus(device, NULL, time, 0, 0);
- wlsc_data_source_unref(device->drag_data_source);
- device->drag_data_source = NULL;
+ drag_set_focus(input_dev, NULL, time, 0, 0);
+ wlsc_data_source_unref(input_dev->drag_data_source);
+ input_dev->drag_data_source = NULL;
}
static const struct wl_grab_interface drag_grab_interface = {
@@ -251,7 +251,7 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *source_resource,
struct wl_resource *surface_resource, uint32_t time)
{
- struct wlsc_input_device *device = resource->data;
+ struct wlsc_input_device *input_dev = resource->data;
struct wlsc_surface *surface = surface_resource->data;
struct wlsc_surface *target;
int32_t sx, sy;
@@ -261,18 +261,19 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
/* FIXME: Check that the data source type array isn't empty. */
- if (wl_input_device_update_grab(&device->input_device, &device->grab,
+ if (wl_input_device_update_grab(&input_dev->winput_dev,
+ &input_dev->grab,
&surface->surface, time) < 0)
return;
- device->grab.interface = &drag_grab_interface;
- device->drag_data_source = source_resource->data;
- device->drag_data_source->refcount++;
+ input_dev->grab.interface = &drag_grab_interface;
+ input_dev->drag_data_source = source_resource->data;
+ input_dev->drag_data_source->refcount++;
- target = pick_surface(&device->input_device, &sx, &sy);
- wl_input_device_set_pointer_focus(&device->input_device,
+ target = pick_surface(&input_dev->winput_dev, &sx, &sy);
+ wl_input_device_set_pointer_focus(&input_dev->winput_dev,
NULL, time, 0, 0, 0, 0);
- drag_set_focus(device, &target->surface, time, sx, sy);
+ drag_set_focus(input_dev, &target->surface, time, sx, sy);
}
static void
@@ -286,16 +287,16 @@ static void
destroy_selection_data_source(struct wl_listener *listener,
struct wl_resource *resource, uint32_t time)
{
- struct wlsc_input_device *device =
+ struct wlsc_input_device *input_dev =
container_of(listener, struct wlsc_input_device,
selection_data_source_listener);
struct wl_resource *data_device, *focus;
- device->selection_data_source = NULL;
+ input_dev->selection_data_source = NULL;
- focus = device->input_device.keyboard_focus_resource;
+ focus = input_dev->winput_dev.keyboard_focus_resource;
if (focus) {
- data_device = find_resource(&device->drag_resource_list,
+ data_device = find_resource(&input_dev->drag_resource_list,
focus->client);
wl_resource_post_event(data_device,
WL_DATA_DEVICE_SELECTION, NULL);
@@ -307,39 +308,39 @@ data_device_set_selection(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *source_resource, uint32_t time)
{
- struct wlsc_input_device *device = resource->data;
+ struct wlsc_input_device *input_dev = resource->data;
struct wl_resource *data_device, *focus, *offer;
if (!source_resource)
return;
- if (device->selection_data_source) {
+ if (input_dev->selection_data_source) {
/* FIXME: All non-active clients will probably hold a
* reference to the selection data source, and thus it
* won't get destroyed until every client has been
* activated and seen the new selection event. */
- wl_list_remove(&device->selection_data_source_listener.link);
- wlsc_data_source_unref(device->selection_data_source);
- device->selection_data_source = NULL;
+ wl_list_remove(&input_dev->selection_data_source_listener.link);
+ wlsc_data_source_unref(input_dev->selection_data_source);
+ input_dev->selection_data_source = NULL;
}
- device->selection_data_source = source_resource->data;
- device->selection_data_source->refcount++;
+ input_dev->selection_data_source = source_resource->data;
+ input_dev->selection_data_source->refcount++;
- focus = device->input_device.keyboard_focus_resource;
+ focus = input_dev->winput_dev.keyboard_focus_resource;
if (focus) {
- data_device = find_resource(&device->drag_resource_list,
+ data_device = find_resource(&input_dev->drag_resource_list,
focus->client);
- offer = wlsc_data_source_send_offer(device->selection_data_source,
+ offer = wlsc_data_source_send_offer(input_dev->selection_data_source,
data_device);
wl_resource_post_event(data_device,
WL_DATA_DEVICE_SELECTION, offer);
}
- device->selection_data_source_listener.func =
+ input_dev->selection_data_source_listener.func =
destroy_selection_data_source;
wl_list_insert(source_resource->destroy_listener_list.prev,
- &device->selection_data_source_listener.link);
+ &input_dev->selection_data_source_listener.link);
}
static const struct wl_data_device_interface data_device_interface = {
@@ -400,14 +401,14 @@ get_data_device(struct wl_client *client,
struct wl_resource *manager_resource,
uint32_t id, struct wl_resource *input_device)
{
- struct wlsc_input_device *device = input_device->data;
+ struct wlsc_input_device *input_dev = input_device->data;
struct wl_resource *resource;
resource =
wl_client_add_object(client, &wl_data_device_interface,
- &data_device_interface, id, device);
+ &data_device_interface, id, input_dev);
- wl_list_insert(&device->drag_resource_list, &resource->link);
+ wl_list_insert(&input_dev->drag_resource_list, &resource->link);
resource->destroy = unbind_data_device;
}
@@ -425,21 +426,21 @@ bind_manager(struct wl_client *client,
}
WL_EXPORT void
-wlsc_data_device_set_keyboard_focus(struct wlsc_input_device *device)
+wlsc_data_device_set_keyboard_focus(struct wlsc_input_device *input_dev)
{
struct wl_resource *data_device, *focus, *offer;
struct wlsc_data_source *source;
- focus = device->input_device.keyboard_focus_resource;
+ focus = input_dev->winput_dev.keyboard_focus_resource;
if (!focus)
return;
- data_device = find_resource(&device->drag_resource_list,
+ data_device = find_resource(&input_dev->drag_resource_list,
focus->client);
if (!data_device)
return;
- source = device->selection_data_source;
+ source = input_dev->selection_data_source;
if (source) {
offer = wlsc_data_source_send_offer(source, data_device);
wl_resource_post_event(data_device,
diff --git a/compositor/evdev.c b/compositor/evdev.c
index 1755a95..ce134ea 100644
--- a/compositor/evdev.c
+++ b/compositor/evdev.c
@@ -96,12 +96,12 @@ evdev_process_key(struct evdev_input_device *device,
case BTN_FORWARD:
case BTN_BACK:
case BTN_TASK:
- notify_button(&device->master->base.input_device,
+ notify_button(&device->master->base.winput_dev,
time, e->code, e->value);
break;
default:
- notify_key(&device->master->base.input_device,
+ notify_key(&device->master->base.winput_dev,
time, e->code, e->value);
break;
}
@@ -204,14 +204,15 @@ is_motion_event(struct input_event *e)
}
static void
-evdev_flush_motion(struct wl_input_device *device, uint32_t time,
+evdev_flush_motion(struct wl_input_device *winput_dev, uint32_t time,
struct evdev_motion_accumulator *accum)
{
if (accum->type == EVDEV_RELATIVE_MOTION)
- notify_motion(device, time,
- device->x + accum->dx, device->y + accum->dy);
+ notify_motion(winput_dev, time,
+ winput_dev->x + accum->dx,
+ winput_dev->y + accum->dy);
if (accum->type == EVDEV_ABSOLUTE_MOTION)
- notify_motion(device, time, accum->x, accum->y);
+ notify_motion(winput_dev, time, accum->x, accum->y);
memset(accum, 0, sizeof *accum);
}
@@ -247,7 +248,7 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
* forwarded to the compositor, so we accumulate motion
* events and send as a bunch */
if (!is_motion_event(e))
- evdev_flush_motion(&device->master->base.input_device,
+ evdev_flush_motion(&device->master->base.winput_dev,
time, &accumulator);
switch (e->type) {
case EV_REL:
@@ -267,7 +268,7 @@ evdev_input_device_data(int fd, uint32_t mask, void *data)
}
}
- evdev_flush_motion(&device->master->base.input_device, time, &accumulator);
+ evdev_flush_motion(&device->master->base.winput_dev, time, &accumulator);
return 1;
}
@@ -510,5 +511,5 @@ evdev_input_add_devices(struct wlsc_compositor *c,
}
udev_enumerate_unref(e);
- c->input_device = &input->base.input_device;
+ c->winput_dev = &input->base.winput_dev;
}
diff --git a/compositor/shell.c b/compositor/shell.c
index bb09166..65a494c 100644
--- a/compositor/shell.c
+++ b/compositor/shell.c
@@ -118,7 +118,7 @@ static const struct wl_grab_interface move_grab_interface = {
static int
wlsc_surface_move(struct wlsc_surface *es,
- struct wlsc_input_device *wd, uint32_t time)
+ struct wlsc_input_device *input_dev, uint32_t time)
{
struct wlsc_move_grab *move;
@@ -127,16 +127,16 @@ wlsc_surface_move(struct wlsc_surface *es,
return -1;
move->grab.interface = &move_grab_interface;
- move->dx = es->x - wd->input_device.grab_x;
- move->dy = es->y - wd->input_device.grab_y;
+ move->dx = es->x - input_dev->winput_dev.grab_x;
+ move->dy = es->y - input_dev->winput_dev.grab_y;
move->surface = es;
- if (wl_input_device_update_grab(&wd->input_device,
+ if (wl_input_device_update_grab(&input_dev->winput_dev,
&move->grab, &es->surface, time) < 0)
return 0;
- wlsc_input_device_set_pointer_image(wd, WLSC_POINTER_DRAGGING);
- wl_input_device_set_pointer_focus(&wd->input_device,
+ wlsc_input_device_set_pointer_image(input_dev, WLSC_POINTER_DRAGGING);
+ wl_input_device_set_pointer_focus(&input_dev->winput_dev,
NULL, time, 0, 0, 0, 0);
return 0;
@@ -146,10 +146,10 @@ static void
shell_surface_move(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *input_resource, uint32_t time)
{
- struct wlsc_input_device *wd = input_resource->data;
+ struct wlsc_input_device *input_dev = input_resource->data;
struct shell_surface *shsurf = resource->data;
- if (wlsc_surface_move(shsurf->surface, wd, time) < 0)
+ if (wlsc_surface_move(shsurf->surface, input_dev, time) < 0)
wl_resource_post_no_memory(resource);
}
@@ -165,21 +165,21 @@ resize_grab_motion(struct wl_grab *grab,
uint32_t time, int32_t x, int32_t y)
{
struct wlsc_resize_grab *resize = (struct wlsc_resize_grab *) grab;
- struct wl_input_device *device = grab->winput_dev;
+ struct wl_input_device *winput_dev = grab->winput_dev;
int32_t width, height;
if (resize->edges & WL_SHELL_SURFACE_RESIZE_LEFT) {
- width = device->grab_x - x + resize->width;
+ width = winput_dev->grab_x - x + resize->width;
} else if (resize->edges & WL_SHELL_SURFACE_RESIZE_RIGHT) {
- width = x - device->grab_x + resize->width;
+ width = x - winput_dev->grab_x + resize->width;
} else {
width = resize->width;
}
if (resize->edges & WL_SHELL_SURFACE_RESIZE_TOP) {
- height = device->grab_y - y + resize->height;
+ height = winput_dev->grab_y - y + resize->height;
} else if (resize->edges & WL_SHELL_SURFACE_RESIZE_BOTTOM) {
- height = y - device->grab_y + resize->height;
+ height = y - winput_dev->grab_y + resize->height;
} else {
height = resize->height;
}
@@ -209,7 +209,7 @@ static const struct wl_grab_interface resize_grab_interface = {
static int
wlsc_surface_resize(struct shell_surface *shsurf,
- struct wlsc_input_device *wd,
+ struct wlsc_input_device *input_dev,
uint32_t time, uint32_t edges)
{
struct wlsc_resize_grab *resize;
@@ -224,8 +224,8 @@ wlsc_surface_resize(struct shell_surface *shsurf,
resize->grab.interface = &resize_grab_interface;
resize->edges = edges;
- resize->dx = es->x - wd->input_device.grab_x;
- resize->dy = es->y - wd->input_device.grab_y;
+ resize->dx = es->x - input_dev->winput_dev.grab_x;
+ resize->dy = es->y - input_dev->winput_dev.grab_y;
resize->width = es->width;
resize->height = es->height;
resize->shsurf = shsurf;
@@ -261,12 +261,12 @@ wlsc_surface_resize(struct shell_surface *shsurf,
break;
}
- if (wl_input_device_update_grab(&wd->input_device,
+ if (wl_input_device_update_grab(&input_dev->winput_dev,
&resize->grab, &es->surface, time) < 0)
return 0;
- wlsc_input_device_set_pointer_image(wd, pointer);
- wl_input_device_set_pointer_focus(&wd->input_device,
+ wlsc_input_device_set_pointer_image(input_dev, pointer);
+ wl_input_device_set_pointer_focus(&input_dev->winput_dev,
NULL, time, 0, 0, 0, 0);
return 0;
@@ -277,12 +277,12 @@ shell_surface_resize(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *input_resource, uint32_t time,
uint32_t edges)
{
- struct wlsc_input_device *wd = input_resource->data;
+ struct wlsc_input_device *input_dev = input_resource->data;
struct shell_surface *shsurf = resource->data;
/* FIXME: Reject if fullscreen */
- if (wlsc_surface_resize(shsurf, wd, time, edges) < 0)
+ if (wlsc_surface_resize(shsurf, input_dev, time, edges) < 0)
wl_resource_post_no_memory(resource);
}
@@ -606,11 +606,11 @@ get_shell_surface_type(struct wlsc_surface *surface)
}
static void
-move_binding(struct wl_input_device *device, uint32_t time,
+move_binding(struct wl_input_device *winput_dev, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data)
{
struct wlsc_surface *surface =
- (struct wlsc_surface *) device->pointer_focus;
+ (struct wlsc_surface *) winput_dev->pointer_focus;
if (surface == NULL)
return;
@@ -624,15 +624,16 @@ move_binding(struct wl_input_device *device, uint32_t time,
break;
}
- wlsc_surface_move(surface, (struct wlsc_input_device *) device, time);
+ wlsc_surface_move(surface, (struct wlsc_input_device *) winput_dev,
+ time);
}
static void
-resize_binding(struct wl_input_device *device, uint32_t time,
+resize_binding(struct wl_input_device *winput_dev, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data)
{
struct wlsc_surface *surface =
- (struct wlsc_surface *) device->pointer_focus;
+ (struct wlsc_surface *) winput_dev->pointer_focus;
uint32_t edges = 0;
int32_t x, y;
struct shell_surface *shsurf;
@@ -653,8 +654,8 @@ resize_binding(struct wl_input_device *device, uint32_t time,
break;
}
- x = device->grab_x - surface->x;
- y = device->grab_y - surface->y;
+ x = winput_dev->grab_x - surface->x;
+ y = winput_dev->grab_y - surface->y;
if (x < surface->width / 3)
edges |= WL_SHELL_SURFACE_RESIZE_LEFT;
@@ -670,18 +671,18 @@ resize_binding(struct wl_input_device *device, uint32_t time,
else
edges |= WL_SHELL_SURFACE_RESIZE_BOTTOM;
- wlsc_surface_resize(shsurf, (struct wlsc_input_device *) device,
+ wlsc_surface_resize(shsurf, (struct wlsc_input_device *) winput_dev,
time, edges);
}
static void
activate(struct wlsc_shell *base, struct wlsc_surface *es,
- struct wlsc_input_device *device, uint32_t time)
+ struct wlsc_input_device *input_dev, uint32_t time)
{
struct wl_shell *shell = container_of(base, struct wl_shell, shell);
struct wlsc_compositor *compositor = shell->compositor;
- wlsc_surface_activate(es, device, time);
+ wlsc_surface_activate(es, input_dev, time);
if (compositor->wxs)
wlsc_xserver_surface_activate(es);
@@ -715,7 +716,7 @@ lock(struct wlsc_shell *base)
struct wl_list *surface_list = &shell->compositor->surface_list;
struct wlsc_surface *cur;
struct wlsc_surface *tmp;
- struct wlsc_input_device *device;
+ struct wlsc_input_device *input_dev;
uint32_t time;
if (shell->locked)
@@ -751,8 +752,9 @@ lock(struct wlsc_shell *base)
/* reset keyboard foci */
time = wlsc_compositor_get_time();
- wl_list_for_each(device, &shell->compositor->input_device_list, link) {
- wl_input_device_set_keyboard_focus(&device->input_device,
+ wl_list_for_each(input_dev, &shell->compositor->input_device_list,
+ link) {
+ wl_input_device_set_keyboard_focus(&input_dev->winput_dev,
NULL, time);
}
diff --git a/compositor/switcher.c b/compositor/switcher.c
index 266b5d3..eea2675 100644
--- a/compositor/switcher.c
+++ b/compositor/switcher.c
@@ -84,7 +84,7 @@ wlsc_switcher_destroy(struct wlsc_switcher *switcher)
}
static void
-switcher_next_binding(struct wl_input_device *device, uint32_t time,
+switcher_next_binding(struct wl_input_device *winput_dev, uint32_t time,
uint32_t key, uint32_t button,
uint32_t state, void *data)
{
@@ -101,15 +101,16 @@ switcher_next_binding(struct wl_input_device *device, uint32_t time,
}
static void
-switcher_terminate_binding(struct wl_input_device *device,
+switcher_terminate_binding(struct wl_input_device *winput_dev,
uint32_t time, uint32_t key, uint32_t button,
uint32_t state, void *data)
{
struct wlsc_compositor *compositor = data;
- struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
+ struct wlsc_input_device *input_dev =
+ (struct wlsc_input_device *) winput_dev;
if (compositor->switcher && !state) {
- wlsc_surface_activate(compositor->switcher->current, wd, time);
+ wlsc_surface_activate(compositor->switcher->current, input_dev, time);
wlsc_switcher_destroy(compositor->switcher);
compositor->switcher = NULL;
compositor->overlay = NULL;
diff --git a/compositor/tablet-shell.c b/compositor/tablet-shell.c
index 6901acd..2128ac9 100644
--- a/compositor/tablet-shell.c
+++ b/compositor/tablet-shell.c
@@ -50,7 +50,7 @@ struct tablet_shell {
struct wlsc_compositor *compositor;
struct wlsc_process process;
- struct wlsc_input_device *device;
+ struct wlsc_input_device *input_dev;
struct wl_client *client;
struct wlsc_surface *surface;
@@ -224,11 +224,11 @@ minimize_zoom_done(struct wlsc_zoom *zoom, void *data)
{
struct tablet_shell *shell = data;
struct wlsc_compositor *compositor = shell->compositor;
- struct wlsc_input_device *device =
- (struct wlsc_input_device *) compositor->input_device;
+ struct wlsc_input_device *input_dev =
+ (struct wlsc_input_device *) compositor->winput_dev;
wlsc_surface_activate(shell->home_surface,
- device, wlsc_compositor_get_time());
+ input_dev, wlsc_compositor_get_time());
}
static void
@@ -236,8 +236,8 @@ tablet_shell_switch_to(struct tablet_shell *shell,
struct wlsc_surface *surface)
{
struct wlsc_compositor *compositor = shell->compositor;
- struct wlsc_input_device *device =
- (struct wlsc_input_device *) compositor->input_device;
+ struct wlsc_input_device *input_dev =
+ (struct wlsc_input_device *) compositor->winput_dev;
struct wlsc_surface *current;
if (shell->state == STATE_SWITCHER) {
@@ -255,7 +255,7 @@ tablet_shell_switch_to(struct tablet_shell *shell,
}
} else {
fprintf(stderr, "switch to %p\n", surface);
- wlsc_surface_activate(surface, device,
+ wlsc_surface_activate(surface, input_dev,
wlsc_compositor_get_time());
tablet_shell_set_state(shell, STATE_TASK);
wlsc_zoom_run(surface, 0.3, 1.0, NULL, NULL);
@@ -390,9 +390,9 @@ toggle_switcher(struct tablet_shell *shell)
static void
tablet_shell_activate(struct wlsc_shell *base, struct wlsc_surface *es,
- struct wlsc_input_device *device, uint32_t time)
+ struct wlsc_input_device *input_dev, uint32_t time)
{
- wlsc_surface_activate(es, device, time);
+ wlsc_surface_activate(es, input_dev, time);
}
static void
@@ -425,14 +425,14 @@ tablet_shell_unlock(struct wlsc_shell *base)
static void
go_home(struct tablet_shell *shell)
{
- struct wlsc_input_device *device =
- (struct wlsc_input_device *) shell->compositor->input_device;
+ struct wlsc_input_device *input_dev =
+ (struct wlsc_input_device *) shell->compositor->winput_dev;
if (shell->state == STATE_SWITCHER)
wl_resource_post_event(&shell->resource,
TABLET_SHELL_HIDE_SWITCHER);
- wlsc_surface_activate(shell->home_surface, device,
+ wlsc_surface_activate(shell->home_surface, input_dev,
wlsc_compositor_get_time());
tablet_shell_set_state(shell, STATE_HOME);
@@ -450,7 +450,7 @@ long_press_handler(void *data)
}
static void
-menu_key_binding(struct wl_input_device *device, uint32_t time,
+menu_key_binding(struct wl_input_device *winput_dev, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data)
{
struct tablet_shell *shell = data;
@@ -463,7 +463,7 @@ menu_key_binding(struct wl_input_device *device, uint32_t time,
}
static void
-home_key_binding(struct wl_input_device *device, uint32_t time,
+home_key_binding(struct wl_input_device *winput_dev, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data)
{
struct tablet_shell *shell = data;
@@ -471,7 +471,7 @@ home_key_binding(struct wl_input_device *device, uint32_t time,
if (shell->state == STATE_LOCKED)
return;
- shell->device = (struct wlsc_input_device *) device;
+ shell->input_dev = (struct wlsc_input_device *) winput_dev;
if (state) {
wl_event_source_timer_update(shell->long_press_source, 500);
--
1.7.5.4
More information about the wayland-devel
mailing list