[PATCH weston] cleanup text backend style

Murray Calavera murray.calavera at gmail.com
Tue Jun 9 13:29:28 PDT 2015


Signed-off-by: Murray Calavera <murray.calavera at gmail.com>
---
 src/text-backend.c | 157 +++++++++++++++++++++++++++++++++--------------------
 1 file changed, 98 insertions(+), 59 deletions(-)

diff --git a/src/text-backend.c b/src/text-backend.c
index 01cb70a..64a3c1b 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -125,8 +125,9 @@ deactivate_input_method(struct input_method *input_method)
 
 	if (input_method->context && input_method->input_method_binding) {
 		input_method_context_end_keyboard_grab(input_method->context);
-		wl_input_method_send_deactivate(input_method->input_method_binding,
-						input_method->context->resource);
+		wl_input_method_send_deactivate(
+			input_method->input_method_binding,
+			input_method->context->resource);
 	}
 
 	wl_list_remove(&input_method->link);
@@ -148,7 +149,8 @@ destroy_text_input(struct wl_resource *resource)
 	struct text_input *text_input = wl_resource_get_user_data(resource);
 	struct input_method *input_method, *next;
 
-	wl_list_for_each_safe(input_method, next, &text_input->input_methods, link)
+	wl_list_for_each_safe(input_method, next,
+			      &text_input->input_methods, link)
 		deactivate_input_method(input_method);
 
 	free(text_input);
@@ -164,13 +166,12 @@ text_input_set_surrounding_text(struct wl_client *client,
 	struct text_input *text_input = wl_resource_get_user_data(resource);
 	struct input_method *input_method, *next;
 
-	wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) {
+	wl_list_for_each_safe(input_method, next,
+			      &text_input->input_methods, link) {
 		if (!input_method->context)
 			continue;
-		wl_input_method_context_send_surrounding_text(input_method->context->resource,
-							      text,
-							      cursor,
-							      anchor);
+		wl_input_method_context_send_surrounding_text(
+			input_method->context->resource, text, cursor, anchor);
 	}
 }
 
@@ -209,12 +210,15 @@ text_input_activate(struct wl_client *client,
 	}
 
 	if (text_input->input_panel_visible) {
-		wl_signal_emit(&ec->show_input_panel_signal, text_input->surface);
-		wl_signal_emit(&ec->update_input_panel_signal, &text_input->cursor_rectangle);
+		wl_signal_emit(&ec->show_input_panel_signal,
+			       text_input->surface);
+		wl_signal_emit(&ec->update_input_panel_signal,
+			       &text_input->cursor_rectangle);
 		text_input->manager->current_panel = text_input;
 	}
 
-	wl_text_input_send_enter(text_input->resource, text_input->surface->resource);
+	wl_text_input_send_enter(text_input->resource,
+				 text_input->surface->resource);
 }
 
 static void
@@ -235,10 +239,12 @@ text_input_reset(struct wl_client *client,
 	struct text_input *text_input = wl_resource_get_user_data(resource);
 	struct input_method *input_method, *next;
 
-	wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) {
+	wl_list_for_each_safe(input_method, next,
+			      &text_input->input_methods, link) {
 		if (!input_method->context)
 			continue;
-		wl_input_method_context_send_reset(input_method->context->resource);
+		wl_input_method_context_send_reset(
+			input_method->context->resource);
 	}
 }
 
@@ -258,7 +264,8 @@ text_input_set_cursor_rectangle(struct wl_client *client,
 	text_input->cursor_rectangle.x2 = x + width;
 	text_input->cursor_rectangle.y2 = y + height;
 
-	wl_signal_emit(&ec->update_input_panel_signal, &text_input->cursor_rectangle);
+	wl_signal_emit(&ec->update_input_panel_signal,
+		       &text_input->cursor_rectangle);
 }
 
 static void
@@ -270,10 +277,12 @@ text_input_set_content_type(struct wl_client *client,
 	struct text_input *text_input = wl_resource_get_user_data(resource);
 	struct input_method *input_method, *next;
 
-	wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) {
+	wl_list_for_each_safe(input_method, next,
+			      &text_input->input_methods, link) {
 		if (!input_method->context)
 			continue;
-		wl_input_method_context_send_content_type(input_method->context->resource, hint, purpose);
+		wl_input_method_context_send_content_type(
+			input_method->context->resource, hint, purpose);
 	}
 }
 
@@ -286,10 +295,12 @@ text_input_invoke_action(struct wl_client *client,
 	struct text_input *text_input = wl_resource_get_user_data(resource);
 	struct input_method *input_method, *next;
 
-	wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) {
+	wl_list_for_each_safe(input_method, next,
+			      &text_input->input_methods, link) {
 		if (!input_method->context)
 			continue;
-		wl_input_method_context_send_invoke_action(input_method->context->resource, button, index);
+		wl_input_method_context_send_invoke_action(
+			input_method->context->resource, button, index);
 	}
 }
 
@@ -301,10 +312,12 @@ text_input_commit_state(struct wl_client *client,
 	struct text_input *text_input = wl_resource_get_user_data(resource);
 	struct input_method *input_method, *next;
 
-	wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) {
+	wl_list_for_each_safe(input_method, next,
+			      &text_input->input_methods, link) {
 		if (!input_method->context)
 			continue;
-		wl_input_method_context_send_commit_state(input_method->context->resource, serial);
+		wl_input_method_context_send_commit_state(
+			input_method->context->resource, serial);
 	}
 }
 
@@ -318,8 +331,10 @@ text_input_show_input_panel(struct wl_client *client,
 	text_input->input_panel_visible = true;
 
 	if (!wl_list_empty(&text_input->input_methods)) {
-		wl_signal_emit(&ec->show_input_panel_signal, text_input->surface);
-		wl_signal_emit(&ec->update_input_panel_signal, &text_input->cursor_rectangle);
+		wl_signal_emit(&ec->show_input_panel_signal,
+			       text_input->surface);
+		wl_signal_emit(&ec->update_input_panel_signal,
+			       &text_input->cursor_rectangle);
 	}
 }
 
@@ -347,11 +362,12 @@ text_input_set_preferred_language(struct wl_client *client,
 	struct text_input *text_input = wl_resource_get_user_data(resource);
 	struct input_method *input_method, *next;
 
-	wl_list_for_each_safe(input_method, next, &text_input->input_methods, link) {
+	wl_list_for_each_safe(input_method, next,
+			      &text_input->input_methods, link) {
 		if (!input_method->context)
 			continue;
-		wl_input_method_context_send_preferred_language(input_method->context->resource,
-								language);
+		wl_input_method_context_send_preferred_language(
+			input_method->context->resource, language);
 	}
 }
 
@@ -373,7 +389,8 @@ static void text_input_manager_create_text_input(struct wl_client *client,
 						 struct wl_resource *resource,
 						 uint32_t id)
 {
-	struct text_input_manager *text_input_manager = wl_resource_get_user_data(resource);
+	struct text_input_manager *text_input_manager =
+		wl_resource_get_user_data(resource);
 	struct text_input *text_input;
 
 	text_input = zalloc(sizeof *text_input);
@@ -392,7 +409,7 @@ static void text_input_manager_create_text_input(struct wl_client *client,
 	wl_list_init(&text_input->input_methods);
 };
 
-static const struct wl_text_input_manager_interface text_input_manager_implementation = {
+static const struct wl_text_input_manager_interface manager_implementation = {
 	text_input_manager_create_text_input
 };
 
@@ -411,7 +428,7 @@ bind_text_input_manager(struct wl_client *client,
 				   &wl_text_input_manager_interface, 1, id);
 	if (resource)
 		wl_resource_set_implementation(resource,
-					       &text_input_manager_implementation,
+					       &manager_implementation,
 					       text_input_manager, NULL);
 }
 
@@ -419,7 +436,9 @@ static void
 text_input_manager_notifier_destroy(struct wl_listener *listener, void *data)
 {
 	struct text_input_manager *text_input_manager =
-		container_of(listener, struct text_input_manager, destroy_listener);
+		container_of(listener,
+			     struct text_input_manager,
+			     destroy_listener);
 
 	wl_global_destroy(text_input_manager->text_input_manager_global);
 
@@ -442,8 +461,10 @@ text_input_manager_create(struct weston_compositor *ec)
 				 &wl_text_input_manager_interface, 1,
 				 text_input_manager, bind_text_input_manager);
 
-	text_input_manager->destroy_listener.notify = text_input_manager_notifier_destroy;
-	wl_signal_add(&ec->destroy_signal, &text_input_manager->destroy_listener);
+	text_input_manager->destroy_listener.notify =
+		text_input_manager_notifier_destroy;
+	wl_signal_add(&ec->destroy_signal,
+		      &text_input_manager->destroy_listener);
 }
 
 static void
@@ -520,8 +541,8 @@ input_method_context_delete_surrounding_text(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 
 	if (context->input)
-		wl_text_input_send_delete_surrounding_text(context->input->resource,
-							   index, length);
+		wl_text_input_send_delete_surrounding_text(
+			context->input->resource, index, length);
 }
 
 static void
@@ -588,16 +609,20 @@ input_method_context_grab_key(struct weston_keyboard_grab *grab,
 	if (!keyboard->input_method_resource)
 		return;
 
-	display = wl_client_get_display(wl_resource_get_client(keyboard->input_method_resource));
+	display = wl_client_get_display(
+		wl_resource_get_client(keyboard->input_method_resource));
 	serial = wl_display_next_serial(display);
 	wl_keyboard_send_key(keyboard->input_method_resource,
 			     serial, time, key, state_w);
 }
 
 static void
-input_method_context_grab_modifier(struct weston_keyboard_grab *grab, uint32_t serial,
-				   uint32_t mods_depressed, uint32_t mods_latched,
-				   uint32_t mods_locked, uint32_t group)
+input_method_context_grab_modifier(struct weston_keyboard_grab *grab,
+				   uint32_t serial,
+				   uint32_t mods_depressed,
+				   uint32_t mods_latched,
+				   uint32_t mods_locked,
+				   uint32_t group)
 {
 	struct weston_keyboard *keyboard = grab->keyboard;
 
@@ -626,7 +651,8 @@ input_method_context_grab_keyboard(struct wl_client *client,
 				   struct wl_resource *resource,
 				   uint32_t id)
 {
-	struct input_method_context *context = wl_resource_get_user_data(resource);
+	struct input_method_context *context =
+		wl_resource_get_user_data(resource);
 	struct wl_resource *cr;
 	struct weston_seat *seat = context->input_method->seat;
 	struct weston_keyboard *keyboard = seat->keyboard;
@@ -655,7 +681,8 @@ input_method_context_key(struct wl_client *client,
 			 uint32_t key,
 			 uint32_t state_w)
 {
-	struct input_method_context *context = wl_resource_get_user_data(resource);
+	struct input_method_context *context =
+		wl_resource_get_user_data(resource);
 	struct weston_seat *seat = context->input_method->seat;
 	struct weston_keyboard *keyboard = seat->keyboard;
 	struct weston_keyboard_grab *default_grab = &keyboard->default_grab;
@@ -672,7 +699,8 @@ input_method_context_modifiers(struct wl_client *client,
 			       uint32_t mods_locked,
 			       uint32_t group)
 {
-	struct input_method_context *context = wl_resource_get_user_data(resource);
+	struct input_method_context *context =
+		wl_resource_get_user_data(resource);
 
 	struct weston_seat *seat = context->input_method->seat;
 	struct weston_keyboard *keyboard = seat->keyboard;
@@ -690,7 +718,8 @@ input_method_context_language(struct wl_client *client,
 			      uint32_t serial,
 			      const char *language)
 {
-	struct input_method_context *context = wl_resource_get_user_data(resource);
+	struct input_method_context *context =
+		wl_resource_get_user_data(resource);
 
 	if (context->input)
 		wl_text_input_send_language(context->input->resource,
@@ -703,7 +732,8 @@ input_method_context_text_direction(struct wl_client *client,
 				    uint32_t serial,
 				    uint32_t direction)
 {
-	struct input_method_context *context = wl_resource_get_user_data(resource);
+	struct input_method_context *context =
+		wl_resource_get_user_data(resource);
 
 	if (context->input)
 		wl_text_input_send_text_direction(context->input->resource,
@@ -711,7 +741,7 @@ input_method_context_text_direction(struct wl_client *client,
 }
 
 
-static const struct wl_input_method_context_interface input_method_context_implementation = {
+static const struct wl_input_method_context_interface context_implementation = {
 	input_method_context_destroy,
 	input_method_context_commit_string,
 	input_method_context_preedit_string,
@@ -731,11 +761,11 @@ static const struct wl_input_method_context_interface input_method_context_imple
 static void
 destroy_input_method_context(struct wl_resource *resource)
 {
-	struct input_method_context *context = wl_resource_get_user_data(resource);
+	struct input_method_context *context =
+		wl_resource_get_user_data(resource);
 
-	if (context->keyboard) {
+	if (context->keyboard)
 		wl_resource_destroy(context->keyboard);
-	}
 
 	if (context->input_method && context->input_method->context == context)
 		context->input_method->context = NULL;
@@ -762,7 +792,7 @@ input_method_context_create(struct text_input *input,
 		wl_resource_create(wl_resource_get_client(binding),
 				   &wl_input_method_context_interface, 1, 0);
 	wl_resource_set_implementation(context->resource,
-				       &input_method_context_implementation,
+				       &context_implementation,
 				       context, destroy_input_method_context);
 
 	context->input = input;
@@ -819,14 +849,17 @@ bind_input_method(struct wl_client *client,
 		wl_resource_create(client, &wl_input_method_interface, 1, id);
 
 	if (input_method->input_method_binding != NULL) {
-		wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
+		wl_resource_post_error(resource,
+				       WL_DISPLAY_ERROR_INVALID_OBJECT,
 				       "interface object already bound");
 		return;
 	}
 
 	if (text_backend->input_method.client != client) {
-		wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
-				       "permission to bind input_method denied");
+		wl_resource_post_error(resource,
+				       WL_DISPLAY_ERROR_INVALID_OBJECT,
+				       "permission to bind "
+				       "input_method denied");
 		return;
 	}
 
@@ -857,7 +890,8 @@ handle_keyboard_focus(struct wl_listener *listener, void *data)
 {
 	struct weston_keyboard *keyboard = data;
 	struct input_method *input_method =
-		container_of(listener, struct input_method, keyboard_focus_listener);
+		container_of(listener, struct input_method,
+			     keyboard_focus_listener);
 	struct weston_surface *surface = keyboard->focus;
 
 	if (!input_method->input)
@@ -874,9 +908,12 @@ input_method_init_seat(struct weston_seat *seat)
 		return;
 
 	if (seat->keyboard) {
-		seat->input_method->keyboard_focus_listener.notify = handle_keyboard_focus;
-		wl_signal_add(&seat->keyboard->focus_signal, &seat->input_method->keyboard_focus_listener);
-		seat->keyboard->input_method_grab.interface = &input_method_context_grab;
+		seat->input_method->keyboard_focus_listener.notify =
+			handle_keyboard_focus;
+		wl_signal_add(&seat->keyboard->focus_signal,
+			      &seat->input_method->keyboard_focus_listener);
+		seat->keyboard->input_method_grab.interface =
+			&input_method_context_grab;
 	}
 
 	seat->input_method->focus_listener_initialized = 1;
@@ -923,13 +960,15 @@ launch_input_method(struct text_backend *text_backend)
 	if (text_backend->input_method.process.pid != 0)
 		return;
 
-	text_backend->input_method.client = weston_client_launch(text_backend->compositor,
-								 &text_backend->input_method.process,
-								 text_backend->input_method.path,
-								 handle_input_method_sigchld);
+	text_backend->input_method.client =
+		weston_client_launch(text_backend->compositor,
+				     &text_backend->input_method.process,
+				     text_backend->input_method.path,
+				     handle_input_method_sigchld);
 
 	if (!text_backend->input_method.client)
-		weston_log("not able to start %s\n", text_backend->input_method.path);
+		weston_log("not able to start %s\n",
+			   text_backend->input_method.path);
 }
 
 static void
-- 
2.4.2



More information about the wayland-devel mailing list