summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-11-27 14:07:22 -0500
committerKristian Høgsberg <krh@bitplanet.net>2012-11-27 14:18:54 -0500
commitde318ab25fa8bcd84fa814fb7e0f94d176d2045d (patch)
treeb0d89da668c46ba01de77a6ad3ada0ee21537606 /clients
parent79bfde20bd782588a4747ebf15a0d17e5b1b3a7a (diff)
weston-simple-im: Stop using toytoolkit
Toytoolkit doesn't buy us anything in this case, we're not rendering or handling regular input events. Just talk directly to wl_display and look up the 'input_method' global directly.
Diffstat (limited to 'clients')
-rw-r--r--clients/Makefile.am4
-rw-r--r--clients/weston-simple-im.c41
2 files changed, 31 insertions, 14 deletions
diff --git a/clients/Makefile.am b/clients/Makefile.am
index 507f0ca..fd83a29 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -140,11 +140,9 @@ weston_keyboard_LDADD = $(toolkit_libs)
weston_simple_im_SOURCES = \
weston-simple-im.c \
- desktop-shell-client-protocol.h \
- desktop-shell-protocol.c \
input-method-protocol.c \
input-method-client-protocol.h
-weston_simple_im_LDADD = $(toolkit_libs)
+weston_simple_im_LDADD = $(CLIENT_LIBS)
weston_info_SOURCES = \
weston-info.c \
diff --git a/clients/weston-simple-im.c b/clients/weston-simple-im.c
index 0e80574..33b0cc0 100644
--- a/clients/weston-simple-im.c
+++ b/clients/weston-simple-im.c
@@ -47,7 +47,8 @@ struct simple_im {
struct input_method *input_method;
struct input_method_context *context;
struct xkb_context *xkb_context;
- struct display *display;
+ struct wl_display *display;
+ struct wl_registry *registry;
struct wl_keyboard *keyboard;
struct keyboard_input *keyboard_input;
enum compose_state compose_state;
@@ -334,19 +335,24 @@ static const struct input_method_listener input_method_listener = {
};
static void
-global_handler(struct display *display, uint32_t name,
- const char *interface, uint32_t version, void *data)
+registry_handle_global(void *data, struct wl_registry *registry,
+ uint32_t name, const char *interface, uint32_t version)
{
struct simple_im *keyboard = data;
if (!strcmp(interface, "input_method")) {
keyboard->input_method =
- display_bind(display, name,
- &input_method_interface, 1);
- input_method_add_listener(keyboard->input_method, &input_method_listener, keyboard);
+ wl_registry_bind(registry, name,
+ &input_method_interface, 1);
+ input_method_add_listener(keyboard->input_method,
+ &input_method_listener, keyboard);
}
}
+static const struct wl_registry_listener registry_listener = {
+ registry_handle_global
+};
+
static int
compare_compose_keys(const void *c1, const void *c2)
{
@@ -457,15 +463,25 @@ int
main(int argc, char *argv[])
{
struct simple_im simple_im;
+ int ret = 0;
memset(&simple_im, 0, sizeof(simple_im));
- simple_im.display = display_create(argc, argv);
+ simple_im.display = wl_display_connect(NULL);
if (simple_im.display == NULL) {
- fprintf(stderr, "failed to create display: %m\n");
+ fprintf(stderr, "failed to connect to server: %m\n");
return -1;
}
+ simple_im.registry = wl_display_get_registry(simple_im.display);
+ wl_registry_add_listener(simple_im.registry,
+ &registry_listener, &simple_im);
+ wl_display_roundtrip(simple_im.display);
+ if (simple_im.input_method == NULL) {
+ fprintf(stderr, "No input_method global\n");
+ exit(1);
+ }
+
simple_im.xkb_context = xkb_context_new(0);
if (simple_im.xkb_context == NULL) {
fprintf(stderr, "Failed to create XKB context\n");
@@ -477,10 +493,13 @@ main(int argc, char *argv[])
keyboard_input_set_user_data(simple_im.keyboard_input, &simple_im);
keyboard_input_set_key_handler(simple_im.keyboard_input, simple_im_key_handler);
- display_set_user_data(simple_im.display, &simple_im);
- display_set_global_handler(simple_im.display, global_handler);
+ while (ret != -1)
+ ret = wl_display_dispatch(simple_im.display);
- display_run(simple_im.display);
+ if (ret == -1) {
+ fprintf(stderr, "Dispatch error: %m\n");
+ exit(1);
+ }
return 0;
}