commit 40d9b54a485da445885c48530a8407a2bfefea0d
parent 08ad563acfb4351df25d03df725455e47d17d691
Author: Michael Forney <mforney@mforney.org>
Date: Tue, 21 Jan 2014 19:11:55 -0800
Style
Diffstat:
21 files changed, 74 insertions(+), 68 deletions(-)
diff --git a/libswc/bindings.c b/libswc/bindings.c
@@ -36,11 +36,22 @@ struct binding
void * data;
};
+static bool handle_key(struct swc_keyboard * keyboard, uint32_t time,
+ uint32_t key, uint32_t state);
+
+static struct swc_keyboard_handler binding_handler = {
+ .key = &handle_key,
+};
+
static struct
{
struct wl_array keys;
} bindings;
+const struct swc_bindings swc_bindings = {
+ .keyboard_handler = &binding_handler
+};
+
static bool handle_keysym(xkb_keysym_t keysym,
uint32_t modifiers, uint32_t time)
{
@@ -60,8 +71,8 @@ static bool handle_keysym(xkb_keysym_t keysym,
return false;
}
-static bool handle_key(struct swc_keyboard * keyboard, uint32_t time,
- uint32_t key, uint32_t state)
+bool handle_key(struct swc_keyboard * keyboard, uint32_t time,
+ uint32_t key, uint32_t state)
{
if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
{
@@ -86,14 +97,6 @@ static bool handle_key(struct swc_keyboard * keyboard, uint32_t time,
return false;
}
-static struct swc_keyboard_handler binding_handler = {
- .key = &handle_key,
-};
-
-const struct swc_bindings_global bindings_global = {
- .keyboard_handler = &binding_handler
-};
-
bool swc_bindings_initialize()
{
wl_array_init(&bindings.keys);
diff --git a/libswc/bindings.h b/libswc/bindings.h
@@ -26,7 +26,7 @@
#include <stdbool.h>
-struct swc_bindings_global
+struct swc_bindings
{
struct swc_keyboard_handler * keyboard_handler;
};
diff --git a/libswc/compositor.c b/libswc/compositor.c
@@ -88,6 +88,11 @@ static void handle_focus(struct swc_pointer * pointer);
static bool handle_motion(struct swc_pointer * pointer, uint32_t time);
static void perform_update(void * data);
+static const struct swc_pointer_handler pointer_handler = {
+ .focus = &handle_focus,
+ .motion = &handle_motion
+};
+
static struct
{
struct wl_list views;
@@ -107,10 +112,7 @@ static struct
} compositor;
const struct swc_compositor swc_compositor = {
- .pointer_handler = {
- .focus = &handle_focus,
- .motion = &handle_motion
- }
+ .pointer_handler = &pointer_handler
};
static void buffer_destroy(void * data)
diff --git a/libswc/compositor.h b/libswc/compositor.h
@@ -24,11 +24,13 @@
#ifndef SWC_COMPOSITOR_H
#define SWC_COMPOSITOR_H
-#include "pointer.h"
+#include <stdbool.h>
+
+struct swc_surface;
struct swc_compositor
{
- struct swc_pointer_handler pointer_handler;
+ const struct swc_pointer_handler * pointer_handler;
};
bool swc_compositor_initialize();
diff --git a/libswc/data_device.c b/libswc/data_device.c
@@ -85,7 +85,7 @@ bool swc_data_device_initialize(struct swc_data_device * data_device)
return true;
}
-void swc_data_device_finish(struct swc_data_device * data_device)
+void swc_data_device_finalize(struct swc_data_device * data_device)
{
struct wl_resource * resource, * tmp;
diff --git a/libswc/data_device.h b/libswc/data_device.h
@@ -45,7 +45,7 @@ struct swc_data_device
};
bool swc_data_device_initialize(struct swc_data_device * data_device);
-void swc_data_device_finish(struct swc_data_device * data_device);
+void swc_data_device_finalize(struct swc_data_device * data_device);
void swc_data_device_bind(struct swc_data_device * data_device,
struct wl_client * client, uint32_t id);
diff --git a/libswc/drm.c b/libswc/drm.c
@@ -43,7 +43,7 @@
#include <wayland-server.h>
#include "protocol/wayland-drm-server-protocol.h"
-struct swc_drm drm_global;
+struct swc_drm swc_drm;
static struct
{
diff --git a/libswc/input_focus.c b/libswc/input_focus.c
@@ -80,7 +80,7 @@ bool swc_input_focus_initialize(struct swc_input_focus * input_focus,
return true;
}
-void swc_input_focus_finish(struct swc_input_focus * input_focus)
+void swc_input_focus_finalize(struct swc_input_focus * input_focus)
{
/* XXX: Destroy resources? */
}
diff --git a/libswc/input_focus.h b/libswc/input_focus.h
@@ -62,7 +62,7 @@ struct swc_input_focus
bool swc_input_focus_initialize(struct swc_input_focus * input_focus,
struct swc_input_focus_handler * input_handler);
-void swc_input_focus_finish(struct swc_input_focus * input_focus);
+void swc_input_focus_finalize(struct swc_input_focus * input_focus);
void swc_input_focus_add_resource(struct swc_input_focus * input_focus,
struct wl_resource * resource);
diff --git a/libswc/internal.h b/libswc/internal.h
@@ -35,8 +35,8 @@ struct swc
struct udev * udev;
struct swc_launch * const launch;
- const struct swc_seat_global * const seat;
- const struct swc_bindings_global * const bindings;
+ const struct swc_seat * const seat;
+ const struct swc_bindings * const bindings;
struct wl_list screens;
const struct swc_compositor * const compositor;
struct swc_shm * const shm;
diff --git a/libswc/keyboard.c b/libswc/keyboard.c
@@ -128,16 +128,16 @@ bool swc_keyboard_initialize(struct swc_keyboard * keyboard)
return true;
error1:
- swc_xkb_finish(&keyboard->xkb);
+ swc_xkb_finalize(&keyboard->xkb);
error0:
return false;
}
-void swc_keyboard_finish(struct swc_keyboard * keyboard)
+void swc_keyboard_finalize(struct swc_keyboard * keyboard)
{
wl_array_release(&keyboard->client_handler.keys);
- swc_input_focus_finish(&keyboard->focus);
- swc_xkb_finish(&keyboard->xkb);
+ swc_input_focus_finalize(&keyboard->focus);
+ swc_xkb_finalize(&keyboard->xkb);
}
/**
diff --git a/libswc/keyboard.h b/libswc/keyboard.h
@@ -66,7 +66,7 @@ struct swc_keyboard
};
bool swc_keyboard_initialize(struct swc_keyboard * keyboard);
-void swc_keyboard_finish(struct swc_keyboard * keyboard);
+void swc_keyboard_finalize(struct swc_keyboard * keyboard);
void swc_keyboard_set_focus(struct swc_keyboard * keyboard,
struct swc_surface * surface);
struct wl_resource * swc_keyboard_bind(struct swc_keyboard * keyboard,
diff --git a/libswc/output.c b/libswc/output.c
@@ -48,8 +48,8 @@ static void bind_output(struct wl_client * client, void * data,
if (swc_mode_equal(&screen->planes.framebuffer.mode, mode))
flags |= WL_OUTPUT_MODE_CURRENT;
- wl_output_send_mode(resource, flags, mode->width, mode->height,
- mode->refresh);
+ wl_output_send_mode(resource, flags,
+ mode->width, mode->height, mode->refresh);
}
if (version >= 2)
diff --git a/libswc/pointer.c b/libswc/pointer.c
@@ -180,9 +180,9 @@ bool swc_pointer_initialize(struct swc_pointer * pointer)
return true;
}
-void swc_pointer_finish(struct swc_pointer * pointer)
+void swc_pointer_finalize(struct swc_pointer * pointer)
{
- swc_input_focus_finish(&pointer->focus);
+ swc_input_focus_finalize(&pointer->focus);
pixman_region32_fini(&pointer->region);
}
diff --git a/libswc/pointer.h b/libswc/pointer.h
@@ -47,7 +47,7 @@ struct swc_pointer
};
bool swc_pointer_initialize(struct swc_pointer * pointer);
-void swc_pointer_finish(struct swc_pointer * pointer);
+void swc_pointer_finalize(struct swc_pointer * pointer);
void swc_pointer_set_focus(struct swc_pointer * pointer,
struct swc_surface * surface);
void swc_pointer_set_region(struct swc_pointer * pointer,
diff --git a/libswc/seat.c b/libswc/seat.c
@@ -50,7 +50,7 @@ static struct
struct wl_list devices;
} seat;
-const struct swc_seat_global seat_global = {
+const struct swc_seat swc_seat = {
.pointer = &seat.pointer,
.keyboard = &seat.keyboard,
.data_device = &seat.data_device
@@ -298,9 +298,9 @@ bool swc_seat_initialize(const char * seat_name)
return true;
error4:
- swc_keyboard_finish(&seat.keyboard);
+ swc_keyboard_finalize(&seat.keyboard);
error3:
- swc_data_device_finish(&seat.data_device);
+ swc_data_device_finalize(&seat.data_device);
error2:
wl_global_destroy(seat.global);
error1:
@@ -313,8 +313,8 @@ void swc_seat_finalize()
{
struct swc_evdev_device * device, * tmp;
- swc_pointer_finish(&seat.pointer);
- swc_keyboard_finish(&seat.keyboard);
+ swc_pointer_finalize(&seat.pointer);
+ swc_keyboard_finalize(&seat.keyboard);
wl_list_for_each_safe(device, tmp, &seat.devices, link)
swc_evdev_device_destroy(device);
diff --git a/libswc/seat.h b/libswc/seat.h
@@ -26,7 +26,7 @@
#include <stdbool.h>
-struct swc_seat_global
+struct swc_seat
{
struct swc_pointer * pointer;
struct swc_keyboard * keyboard;
diff --git a/libswc/shm.c b/libswc/shm.c
@@ -28,7 +28,7 @@
#include <wld/wld.h>
#include <wld/pixman.h>
-struct swc_shm shm_global;
+struct swc_shm swc_shm;
bool swc_shm_initialize()
{
diff --git a/libswc/swc.c b/libswc/swc.c
@@ -43,19 +43,19 @@
#include <libudev.h>
extern struct swc_launch swc_launch;
-extern const struct swc_seat_global seat_global;
-extern const struct swc_bindings_global bindings_global;
+extern const struct swc_seat swc_seat;
+extern const struct swc_bindings swc_bindings;
extern const struct swc_compositor swc_compositor;
-extern struct swc_drm drm_global;
-extern struct swc_shm shm_global;
+extern struct swc_drm swc_drm;
+extern struct swc_shm swc_shm;
struct swc swc = {
.launch = &swc_launch,
- .seat = &seat_global,
- .bindings = &bindings_global,
+ .seat = &swc_seat,
+ .bindings = &swc_bindings,
.compositor = &swc_compositor,
- .drm = &drm_global,
- .shm = &shm_global
+ .drm = &swc_drm,
+ .shm = &swc_shm
};
static void setup_compositor()
@@ -66,7 +66,7 @@ static void setup_compositor()
wl_list_insert(&swc.seat->keyboard->handlers,
&swc.bindings->keyboard_handler->link);
- swc.seat->pointer->handler = &swc.compositor->pointer_handler;
+ swc.seat->pointer->handler = swc.compositor->pointer_handler;
wl_signal_add(&swc.seat->pointer->focus.event_signal,
swc_window_enter_listener);
diff --git a/libswc/xkb.c b/libswc/xkb.c
@@ -21,7 +21,7 @@ bool swc_xkb_initialize(struct swc_xkb * xkb)
if (!xkb->context)
{
printf("could not create XKB context\n");
- goto error_base;
+ goto error0;
}
xkb->keymap.map = xkb_keymap_new_from_names(xkb->context, &rule_names, 0);
@@ -29,7 +29,7 @@ bool swc_xkb_initialize(struct swc_xkb * xkb)
if (!xkb->keymap.map)
{
printf("could not create XKB keymap\n");
- goto error_context;
+ goto error1;
}
xkb->state = xkb_state_new(xkb->keymap.map);
@@ -37,28 +37,28 @@ bool swc_xkb_initialize(struct swc_xkb * xkb)
if (!xkb->state)
{
printf("could not create XKB state\n");
- goto error_keymap;
+ goto error2;
}
if (!swc_xkb_update_keymap(xkb))
{
printf("could not update XKB keymap\n");
- goto error_state;
+ goto error3;
}
return true;
- error_state:
+ error3:
xkb_state_unref(xkb->state);
- error_keymap:
+ error2:
xkb_keymap_unref(xkb->keymap.map);
- error_context:
+ error1:
xkb_context_unref(xkb->context);
- error_base:
+ error0:
return false;
}
-void swc_xkb_finish(struct swc_xkb * xkb)
+void swc_xkb_finalize(struct swc_xkb * xkb)
{
munmap(xkb->keymap.area, xkb->keymap.size);
close(xkb->keymap.fd);
@@ -97,7 +97,7 @@ bool swc_xkb_update_keymap(struct swc_xkb * xkb)
if (!keymap_string)
{
printf("could not get XKB keymap as a string\n");
- goto error_base;
+ goto error0;
}
sprintf(keymap_path, "%s/%s", keymap_directory, keymap_file_template);
@@ -108,7 +108,7 @@ bool swc_xkb_update_keymap(struct swc_xkb * xkb)
if (xkb->keymap.fd == -1)
{
printf("could not create XKB keymap file\n");
- goto error_string;
+ goto error1;
}
unlink(keymap_path);
@@ -116,7 +116,7 @@ bool swc_xkb_update_keymap(struct swc_xkb * xkb)
if (posix_fallocate(xkb->keymap.fd, 0, xkb->keymap.size) != 0)
{
printf("could not resize XKB keymap file\n");
- goto error_fd;
+ goto error2;
}
xkb->keymap.area = mmap(NULL, xkb->keymap.size, PROT_READ | PROT_WRITE,
@@ -125,7 +125,7 @@ bool swc_xkb_update_keymap(struct swc_xkb * xkb)
if (xkb->keymap.area == MAP_FAILED)
{
printf("could not mmap XKB keymap string\n");
- goto error_fd;
+ goto error2;
}
strcpy(xkb->keymap.area, keymap_string);
@@ -135,11 +135,11 @@ bool swc_xkb_update_keymap(struct swc_xkb * xkb)
return true;
- error_fd:
+ error2:
close(xkb->keymap.fd);
- error_string:
+ error1:
free(keymap_string);
- error_base:
+ error0:
return false;
}
diff --git a/libswc/xkb.h b/libswc/xkb.h
@@ -27,8 +27,7 @@ struct swc_xkb
};
bool swc_xkb_initialize(struct swc_xkb * xkb);
-
-void swc_xkb_finish(struct swc_xkb * xkb);
+void swc_xkb_finalize(struct swc_xkb * xkb);
bool swc_xkb_update_keymap(struct swc_xkb * xkb);