[PATCH weston 2/3] Rename 'state' for key/button to 'is_down'

Daniel Stone daniel at fooishbar.org
Tue May 1 12:30:39 PDT 2012


Since it's just a boolean indicating whether or not the key is down, and
state is such a hopelessly overloaded word.  And, er, XKB uses it quite
pervasively for modifier/group information.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 clients/clickdot.c       |    8 ++++----
 clients/desktop-shell.c  |   12 ++++++------
 clients/dnd.c            |    4 ++--
 clients/eventdemo.c      |   16 ++++++++--------
 clients/flower.c         |    8 ++++----
 clients/resizor.c        |    8 ++++----
 clients/simple-touch.c   |    4 ++--
 clients/tablet-shell.c   |    4 ++--
 clients/terminal.c       |   12 ++++++------
 clients/view.c           |    8 ++++----
 clients/window.c         |   26 +++++++++++++-------------
 clients/window.h         |    4 ++--
 src/compositor-drm.c     |    4 ++--
 src/compositor-wayland.c |    9 +++++----
 src/compositor-x11.c     |   12 ++++++------
 src/compositor.c         |   24 ++++++++++++------------
 src/compositor.h         |    8 ++++----
 src/screenshooter.c      |    2 +-
 src/shell.c              |   44 ++++++++++++++++++++++----------------------
 src/tablet-shell.c       |    8 ++++----
 src/util.c               |   12 ++++++------
 tests/test-client.c      |    6 +++---
 22 files changed, 122 insertions(+), 121 deletions(-)

diff --git a/clients/clickdot.c b/clients/clickdot.c
index 3b7210e..9eb1f20 100644
--- a/clients/clickdot.c
+++ b/clients/clickdot.c
@@ -93,11 +93,11 @@ keyboard_focus_handler(struct window *window,
 
 static void
 key_handler(struct window *window, struct input *input, uint32_t time,
-	    uint32_t key, uint32_t sym, uint32_t state, void *data)
+	    uint32_t key, uint32_t sym, uint32_t is_down, void *data)
 {
 	struct clickdot *clickdot = data;
 
-	if (state == 0)
+	if (is_down == 0)
 		return;
 
 	switch (sym) {
@@ -110,11 +110,11 @@ key_handler(struct window *window, struct input *input, uint32_t time,
 static void
 button_handler(struct widget *widget,
 	       struct input *input, uint32_t time,
-	       int button, int state, void *data)
+	       int button, int is_down, void *data)
 {
 	struct clickdot *clickdot = data;
 
-	if (state && button == BTN_LEFT)
+	if (is_down && button == BTN_LEFT)
 		input_get_position(input, &clickdot->x, &clickdot->y);
 
 	widget_schedule_redraw(widget);
diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index df4494e..f417761 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -256,24 +256,24 @@ panel_launcher_leave_handler(struct widget *widget,
 static void
 panel_launcher_button_handler(struct widget *widget,
 			      struct input *input, uint32_t time,
-			      int button, int state, void *data)
+			      int button, int is_down, void *data)
 {
 	struct panel_launcher *launcher;
 
 	launcher = widget_get_user_data(widget);
 	widget_schedule_redraw(widget);
-	if (state == 0)
+	if (is_down == 0)
 		panel_launcher_activate(launcher);
 }
 
 static void
 panel_button_handler(struct widget *widget,
 		     struct input *input, uint32_t time,
-		     int button, int state, void *data)
+		     int button, int is_down, void *data)
 {
 	struct panel *panel = data;
 
-	if (button == BTN_RIGHT && state)
+	if (button == BTN_RIGHT && is_down)
 		show_menu(panel, input, time);
 }
 
@@ -481,13 +481,13 @@ unlock_dialog_redraw_handler(struct widget *widget, void *data)
 static void
 unlock_dialog_button_handler(struct widget *widget,
 			     struct input *input, uint32_t time,
-			     int button, int state, void *data)
+			     int button, int is_down, void *data)
 {
 	struct unlock_dialog *dialog = data;
 	struct desktop *desktop = dialog->desktop;
 
 	if (button == BTN_LEFT) {
-		if (state == 0 && !dialog->closing) {
+		if (is_down == 0 && !dialog->closing) {
 			display_defer(desktop->display, &desktop->unlock_task);
 			dialog->closing = 1;
 		}
diff --git a/clients/dnd.c b/clients/dnd.c
index a7ac66f..3e262ff 100644
--- a/clients/dnd.c
+++ b/clients/dnd.c
@@ -361,7 +361,7 @@ create_drag_cursor(struct dnd_drag *dnd_drag,
 static void
 dnd_button_handler(struct widget *widget,
 		   struct input *input, uint32_t time,
-		   int button, int state, void *data)
+		   int button, int is_down, void *data)
 {
 	struct dnd *dnd = data;
 	int32_t x, y;
@@ -380,7 +380,7 @@ dnd_button_handler(struct widget *widget,
 	x -= allocation.x;
 	y -= allocation.y;
 
-	if (item && state == 1) {
+	if (item && is_down == 1) {
 		dnd_drag = malloc(sizeof *dnd_drag);
 		dnd_drag->dnd = dnd;
 		dnd_drag->input = input;
diff --git a/clients/eventdemo.c b/clients/eventdemo.c
index 0848fc8..6755b16 100644
--- a/clients/eventdemo.c
+++ b/clients/eventdemo.c
@@ -183,21 +183,21 @@ keyboard_focus_handler(struct window *window,
  * \param window window
  * \param key keycode
  * \param unicode associated character
- * \param state pressed or released
+ * \param is_down pressed or released
  * \param modifiers modifiers: ctrl, alt, meta etc.
  * \param data user data associated to the window
  */
 static void
 key_handler(struct window *window, struct input *input, uint32_t time,
-            uint32_t key, uint32_t unicode, uint32_t state, void *data)
+            uint32_t key, uint32_t unicode, uint32_t is_down, void *data)
 {
 	uint32_t modifiers = input_get_modifiers(input);
 
 	if(!log_key)
 		return;
 
-	printf("key key: %d, unicode: %d, state: %d, modifiers: %d\n",
-	       key, unicode, state, modifiers);
+	printf("key key: %d, unicode: %d, is_down: %d, modifiers: %d\n",
+	       key, unicode, is_down, modifiers);
 }
 
 /**
@@ -206,12 +206,12 @@ key_handler(struct window *window, struct input *input, uint32_t time,
  * \param input input device that caused the button event
  * \param time time the event happend
  * \param button button
- * \param state pressed or released
+ * \param is_down pressed or released
  * \param data user data associated to the window
  */
 static void
 button_handler(struct widget *widget, struct input *input, uint32_t time,
-	       int button, int state, void *data)
+	       int button, int is_down, void *data)
 {
 	int32_t x, y;
 
@@ -219,8 +219,8 @@ button_handler(struct widget *widget, struct input *input, uint32_t time,
 		return;
 
 	input_get_position(input, &x, &y);
-	printf("button time: %d, button: %d, state: %d, x: %d, y: %d\n",
-	       time, button, state, x, y);
+	printf("button time: %d, button: %d, is_down: %d, x: %d, y: %d\n",
+	       time, button, is_down, x, y);
 }
 
 /**
diff --git a/clients/flower.c b/clients/flower.c
index 2d13f9e..6409acf 100644
--- a/clients/flower.c
+++ b/clients/flower.c
@@ -142,22 +142,22 @@ motion_handler(struct widget *widget, struct input *input,
 static void
 button_handler(struct widget *widget,
 	       struct input *input, uint32_t time,
-	       int button, int state, void *data)
+	       int button, int is_down, void *data)
 {
 	struct flower *flower = data;
 
 	switch (button) {
 	case BTN_LEFT:
-		if (state)
+		if (is_down)
 			window_move(flower->window, input,
 				    display_get_serial(flower->display));
 		break;
 	case BTN_MIDDLE:
-		if (state)
+		if (is_down)
 			widget_schedule_redraw(widget);
 		break;
 	case BTN_RIGHT:
-		if (state)
+		if (is_down)
 			window_show_frame_menu(flower->window, input, time);
 		break;
 	}
diff --git a/clients/resizor.c b/clients/resizor.c
index 67d4899..228f966 100644
--- a/clients/resizor.c
+++ b/clients/resizor.c
@@ -134,11 +134,11 @@ keyboard_focus_handler(struct window *window,
 
 static void
 key_handler(struct window *window, struct input *input, uint32_t time,
-	    uint32_t key, uint32_t sym, uint32_t state, void *data)
+	    uint32_t key, uint32_t sym, uint32_t is_down, void *data)
 {
 	struct resizor *resizor = data;
 
-	if (state == 0)
+	if (is_down == 0)
 		return;
 
 	switch (sym) {
@@ -178,13 +178,13 @@ show_menu(struct resizor *resizor, struct input *input, uint32_t time)
 static void
 button_handler(struct widget *widget,
 	       struct input *input, uint32_t time,
-	       int button, int state, void *data)
+	       int button, int is_down, void *data)
 {
 	struct resizor *resizor = data;
 
 	switch (button) {
 	case BTN_RIGHT:
-		if (state)
+		if (is_down)
 			show_menu(resizor, input, time);
 		break;
 	}
diff --git a/clients/simple-touch.c b/clients/simple-touch.c
index b8d9156..6da8aa6 100644
--- a/clients/simple-touch.c
+++ b/clients/simple-touch.c
@@ -111,7 +111,7 @@ static void
 input_device_handle_button(void *data,
 			   struct wl_input_device *input_device,
 			   uint32_t serial, uint32_t time,
-			   uint32_t button, uint32_t state)
+			   uint32_t button, uint32_t is_down)
 {
 }
 
@@ -124,7 +124,7 @@ input_device_handle_axis(void *data, struct wl_input_device *input_device,
 static void
 input_device_handle_key(void *data, struct wl_input_device *input_device,
 			uint32_t serial, uint32_t time,
-			uint32_t key, uint32_t state)
+			uint32_t key, uint32_t is_down)
 {
 }
 
diff --git a/clients/tablet-shell.c b/clients/tablet-shell.c
index 4f4eec5..85368cf 100644
--- a/clients/tablet-shell.c
+++ b/clients/tablet-shell.c
@@ -217,11 +217,11 @@ lockscreen_draw(struct widget *widget, void *data)
 static void
 lockscreen_button_handler(struct widget *widget,
 			  struct input *input, uint32_t time,
-			  int button, int state, void *data)
+			  int button, int is_down, void *data)
 {
 	struct lockscreen *lockscreen = data;
 
-	if (state && lockscreen->window) {
+	if (is_down && lockscreen->window) {
 		window_destroy(lockscreen->window);
 		lockscreen->window = NULL;
 	}
diff --git a/clients/terminal.c b/clients/terminal.c
index 106e3d1..b8d3740 100644
--- a/clients/terminal.c
+++ b/clients/terminal.c
@@ -2070,7 +2070,7 @@ handle_bound_key(struct terminal *terminal,
 
 static void
 key_handler(struct window *window, struct input *input, uint32_t time,
-	    uint32_t key, uint32_t sym, uint32_t state, void *data)
+	    uint32_t key, uint32_t sym, uint32_t is_down, void *data)
 {
 	struct terminal *terminal = data;
 	char ch[MAX_RESPONSE];
@@ -2080,12 +2080,12 @@ key_handler(struct window *window, struct input *input, uint32_t time,
 	modifiers = input_get_modifiers(input);
 	if ((modifiers & XKB_COMMON_CONTROL_MASK) &&
 	    (modifiers & XKB_COMMON_SHIFT_MASK) &&
-	    state && handle_bound_key(terminal, input, sym, time))
+	    is_down && handle_bound_key(terminal, input, sym, time))
 		return;
 
 	switch (sym) {
 	case XK_F11:
-		if (!state)
+		if (!is_down)
 			break;
 		terminal->fullscreen ^= 1;
 		window_set_fullscreen(window, terminal->fullscreen);
@@ -2196,7 +2196,7 @@ key_handler(struct window *window, struct input *input, uint32_t time,
 		break;
 	}
 
-	if (state && len > 0)
+	if (is_down && len > 0)
 		terminal_write(terminal, ch, len);
 }
 
@@ -2213,13 +2213,13 @@ keyboard_focus_handler(struct window *window,
 static void
 button_handler(struct widget *widget,
 	       struct input *input, uint32_t time,
-	       int button, int state, void *data)
+	       int button, int is_down, void *data)
 {
 	struct terminal *terminal = data;
 
 	switch (button) {
 	case 272:
-		if (state) {
+		if (is_down) {
 			terminal->dragging = 1;
 			input_get_position(input,
 					   &terminal->selection_start_x,
diff --git a/clients/view.c b/clients/view.c
index 1264207..5897f28 100644
--- a/clients/view.c
+++ b/clients/view.c
@@ -138,11 +138,11 @@ view_page_down(struct view *view)
 
 static void
 button_handler(struct widget *widget, struct input *input, uint32_t time,
-               int button, int state, void *data)
+               int button, int is_down, void *data)
 {
         struct view *view = data;
 
-        if(!state)
+        if(!is_down)
                 return;
 
         switch(button) {
@@ -159,11 +159,11 @@ button_handler(struct widget *widget, struct input *input, uint32_t time,
 
 static void
 key_handler(struct window *window, struct input *input, uint32_t time,
-	    uint32_t key, uint32_t unicode, uint32_t state, void *data)
+	    uint32_t key, uint32_t unicode, uint32_t is_down, void *data)
 {
 	struct view *view = data;
 
-	if(!state)
+	if(!is_down)
 	        return;
 
 	switch (key) {
diff --git a/clients/window.c b/clients/window.c
index 2390485..2d6b364 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -1195,7 +1195,7 @@ frame_motion_handler(struct widget *widget,
 static void
 frame_button_handler(struct widget *widget,
 		     struct input *input, uint32_t time,
-		     int button, int state, void *data)
+		     int button, int is_down, void *data)
 
 {
 	struct frame *frame = data;
@@ -1205,7 +1205,7 @@ frame_button_handler(struct widget *widget,
 
 	location = frame_get_pointer_location(frame, input->sx, input->sy);
 
-	if (window->display->shell && button == BTN_LEFT && state == 1) {
+	if (window->display->shell && button == BTN_LEFT && is_down == 1) {
 		switch (location) {
 		case WINDOW_TITLEBAR:
 			if (!window->shell_surface)
@@ -1244,7 +1244,7 @@ frame_button_handler(struct widget *widget,
 						display->serial, location);
 			break;
 		}
-	} else if (button == BTN_RIGHT && state == 1) {
+	} else if (button == BTN_RIGHT && is_down == 1) {
 		window_show_frame_menu(window, input, time);
 	}
 }
@@ -1368,23 +1368,23 @@ input_ungrab(struct input *input)
 static void
 input_handle_button(void *data,
 		    struct wl_input_device *input_device, uint32_t serial,
-		    uint32_t time, uint32_t button, uint32_t state)
+		    uint32_t time, uint32_t button, uint32_t is_down)
 {
 	struct input *input = data;
 	struct widget *widget;
 
 	input->display->serial = serial;
-	if (input->focus_widget && input->grab == NULL && state)
+	if (input->focus_widget && input->grab == NULL && is_down)
 		input_grab(input, input->focus_widget, button);
 
 	widget = input->grab;
 	if (widget && widget->button_handler)
 		(*widget->button_handler)(widget,
 					  input, time,
-					  button, state,
+					  button, is_down,
 					  input->grab->user_data);
 
-	if (input->grab && input->grab_button == button && !state)
+	if (input->grab && input->grab_button == button && !is_down)
 		input_ungrab(input);
 }
 
@@ -1397,7 +1397,7 @@ input_handle_axis(void *data,
 
 static void
 input_handle_key(void *data, struct wl_input_device *input_device,
-		 uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
+		 uint32_t serial, uint32_t time, uint32_t key, uint32_t is_down)
 {
 	struct input *input = data;
 	struct window *window = input->keyboard_focus;
@@ -1416,18 +1416,18 @@ input_handle_key(void *data, struct wl_input_device *input_device,
 
 	sym = XkbKeySymEntry(d->xkb, code, level, 0);
 
-	if (state)
+	if (is_down)
 		input->modifiers |= d->xkb->map->modmap[code];
 	else
 		input->modifiers &= ~d->xkb->map->modmap[code];
 
 	if (key == KEY_F5 && input->modifiers == Mod4Mask) {
-		if (state)
+		if (is_down)
 			window_set_maximized(window,
 					     window->type != TYPE_MAXIMIZED);
 	} else if (window->key_handler) {
 		(*window->key_handler)(window, input, time, key,
-				       sym, state, window->user_data);
+				       sym, is_down, window->user_data);
 	}
 }
 
@@ -2334,12 +2334,12 @@ menu_leave_handler(struct widget *widget, struct input *input, void *data)
 static void
 menu_button_handler(struct widget *widget,
 		    struct input *input, uint32_t time,
-		    int button, int state, void *data)
+		    int button, int is_down, void *data)
 
 {
 	struct menu *menu = data;
 
-	if (state == 0 && time - menu->time > 500) {
+	if (is_down == 0 && time - menu->time > 500) {
 		/* Either relase after press-drag-release or
 		 * click-motion-click. */
 		menu->func(menu->window->parent, 
diff --git a/clients/window.h b/clients/window.h
index a2a7880..8126867 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -158,7 +158,7 @@ enum pointer_type {
 
 typedef void (*window_key_handler_t)(struct window *window, struct input *input,
 				     uint32_t time, uint32_t key, uint32_t unicode,
-				     uint32_t state, void *data);
+				     uint32_t is_down, void *data);
 
 typedef void (*window_keyboard_focus_handler_t)(struct window *window,
 						struct input *device, void *data);
@@ -190,7 +190,7 @@ typedef int (*widget_motion_handler_t)(struct widget *widget,
 				       int32_t x, int32_t y, void *data);
 typedef void (*widget_button_handler_t)(struct widget *widget,
 					struct input *input, uint32_t time,
-					int button, int state, void *data);
+					int button, int is_down, void *data);
 
 struct window *
 window_create(struct display *display);
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index e7433f7..9b39e42 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1680,11 +1680,11 @@ vt_func(struct weston_compositor *compositor, int event)
 
 static void
 switch_vt_binding(struct wl_input_device *device, uint32_t time,
-		  uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
+		  uint32_t key, uint32_t button, uint32_t axis, int32_t is_down, void *data)
 {
 	struct drm_compositor *ec = data;
 
-	if (state)
+	if (is_down)
 		tty_activate_vt(ec->tty, key - KEY_F1 + 1);
 }
 
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 3260c8e..6b804f3 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -520,12 +520,13 @@ input_handle_motion(void *data, struct wl_input_device *input_device,
 static void
 input_handle_button(void *data,
 		    struct wl_input_device *input_device,
-		    uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
+		    uint32_t serial, uint32_t time, uint32_t button,
+		    uint32_t is_down)
 {
 	struct wayland_input *input = data;
 	struct wayland_compositor *c = input->compositor;
 
-	notify_button(c->base.input_device, time, button, state);
+	notify_button(c->base.input_device, time, button, is_down);
 }
 
 static void
@@ -540,12 +541,12 @@ input_handle_axis(void *data, struct wl_input_device *input_device,
 
 static void
 input_handle_key(void *data, struct wl_input_device *input_device,
-		 uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
+		 uint32_t serial, uint32_t time, uint32_t key, uint32_t is_down)
 {
 	struct wayland_input *input = data;
 	struct wayland_compositor *c = input->compositor;
 
-	notify_key(c->base.input_device, time, key, state);
+	notify_key(c->base.input_device, time, key, is_down);
 }
 
 static void
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 304a4d5..01194a8 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -481,7 +481,7 @@ x11_compositor_find_output(struct x11_compositor *c, xcb_window_t window)
 
 static void
 x11_compositor_deliver_button_event(struct x11_compositor *c,
-				    xcb_generic_event_t *event, int state)
+				    xcb_generic_event_t *event, int is_down)
 {
 	xcb_button_press_event_t *button_event =
 		(xcb_button_press_event_t *) event;
@@ -498,25 +498,25 @@ x11_compositor_deliver_button_event(struct x11_compositor *c,
 		button = BTN_RIGHT;
 		break;
 	case 4:
-		if (state)
+		if (is_down)
 			notify_axis(c->base.input_device,
 				      weston_compositor_get_time(),
 				      WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, 1);
 		return;
 	case 5:
-		if (state)
+		if (is_down)
 			notify_axis(c->base.input_device,
 				      weston_compositor_get_time(),
 				      WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, -1);
 		return;
 	case 6:
-		if (state)
+		if (is_down)
 			notify_axis(c->base.input_device,
 				      weston_compositor_get_time(),
 				      WL_INPUT_DEVICE_AXIS_HORIZONTAL_SCROLL, 1);
 		return;
 	case 7:
-		if (state)
+		if (is_down)
 			notify_axis(c->base.input_device,
 				      weston_compositor_get_time(),
 				      WL_INPUT_DEVICE_AXIS_HORIZONTAL_SCROLL, -1);
@@ -524,7 +524,7 @@ x11_compositor_deliver_button_event(struct x11_compositor *c,
 	}
 
 	notify_button(c->base.input_device,
-		      weston_compositor_get_time(), button, state);
+		      weston_compositor_get_time(), button, is_down);
 }
 
 static int
diff --git a/src/compositor.c b/src/compositor.c
index 235b4a2..efde5b9 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1604,14 +1604,14 @@ weston_surface_activate(struct weston_surface *surface,
 
 WL_EXPORT void
 notify_button(struct wl_input_device *device,
-	      uint32_t time, int32_t button, int32_t state)
+	      uint32_t time, int32_t button, int32_t is_down)
 {
 	struct weston_input_device *wd = (struct weston_input_device *) device;
 	struct weston_compositor *compositor = wd->compositor;
 	struct weston_surface *focus = (struct weston_surface *) device->pointer_focus;
 	uint32_t serial = wl_display_next_serial(compositor->wl_display);
 
-	if (state) {
+	if (is_down) {
 		if (compositor->ping_handler && focus)
 			compositor->ping_handler(focus, serial);
 		weston_compositor_idle_inhibit(compositor);
@@ -1627,9 +1627,9 @@ notify_button(struct wl_input_device *device,
 		device->button_count--;
 	}
 
-	weston_compositor_run_binding(compositor, wd, time, 0, button, 0, state);
+	weston_compositor_run_binding(compositor, wd, time, 0, button, 0, is_down);
 
-	device->pointer_grab->interface->button(device->pointer_grab, time, button, state);
+	device->pointer_grab->interface->button(device->pointer_grab, time, button, is_down);
 
 	if (device->button_count == 1)
 		device->grab_serial =
@@ -1663,7 +1663,7 @@ notify_axis(struct wl_input_device *device,
 
 static void
 update_modifier_state(struct weston_input_device *device,
-		      uint32_t key, uint32_t state)
+		      uint32_t key, uint32_t is_down)
 {
 	uint32_t modifier;
 
@@ -1688,7 +1688,7 @@ update_modifier_state(struct weston_input_device *device,
 		break;
 	}
 
-	if (state)
+	if (is_down)
 		device->modifier_state |= modifier;
 	else
 		device->modifier_state &= ~modifier;
@@ -1696,7 +1696,7 @@ update_modifier_state(struct weston_input_device *device,
 
 WL_EXPORT void
 notify_key(struct wl_input_device *device,
-	   uint32_t time, uint32_t key, uint32_t state)
+	   uint32_t time, uint32_t key, uint32_t is_down)
 {
 	struct weston_input_device *wd = (struct weston_input_device *) device;
 	struct weston_compositor *compositor = wd->compositor;
@@ -1704,7 +1704,7 @@ notify_key(struct wl_input_device *device,
 	uint32_t serial = wl_display_next_serial(compositor->wl_display);
 	uint32_t *k, *end;
 
-	if (state) {
+	if (is_down) {
 		if (compositor->ping_handler && focus)
 			compositor->ping_handler(focus, serial);
 
@@ -1715,24 +1715,24 @@ notify_key(struct wl_input_device *device,
 		weston_compositor_idle_release(compositor);
 	}
 
-	update_modifier_state(wd, key, state);
+	update_modifier_state(wd, key, is_down);
 	end = device->keys.data + device->keys.size;
 	for (k = device->keys.data; k < end; k++) {
 		if (*k == key)
 			*k = *--end;
 	}
 	device->keys.size = (void *) end - device->keys.data;
-	if (state) {
+	if (is_down) {
 		k = wl_array_add(&device->keys, sizeof *k);
 		*k = key;
 	}
 
 	if (device->keyboard_grab == &device->default_keyboard_grab)
 		weston_compositor_run_binding(compositor, wd,
-					      time, key, 0, 0, state);
+					      time, key, 0, 0, is_down);
 
 	device->keyboard_grab->interface->key(device->keyboard_grab,
-					      time, key, state);
+					      time, key, is_down);
 }
 
 WL_EXPORT void
diff --git a/src/compositor.h b/src/compositor.h
index 3722d32..b4d648d 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -416,13 +416,13 @@ notify_motion(struct wl_input_device *device,
 	      uint32_t time, int x, int y);
 void
 notify_button(struct wl_input_device *device,
-	      uint32_t time, int32_t button, int32_t state);
+	      uint32_t time, int32_t button, int32_t is_down);
 void
 notify_axis(struct wl_input_device *device,
 	      uint32_t time, uint32_t axis, int32_t value);
 void
 notify_key(struct wl_input_device *device,
-	   uint32_t time, uint32_t key, uint32_t state);
+	   uint32_t time, uint32_t key, uint32_t is_down);
 
 void
 notify_pointer_focus(struct wl_input_device *device,
@@ -468,7 +468,7 @@ typedef void (*weston_binding_handler_t)(struct wl_input_device *device,
 					 uint32_t time, uint32_t key,
 					 uint32_t button,
 					 uint32_t axis,
-					 int32_t state, void *data);
+					 int32_t is_down, void *data);
 struct weston_binding *
 weston_compositor_add_binding(struct weston_compositor *compositor,
 			      uint32_t key, uint32_t button, uint32_t axis, uint32_t modifier,
@@ -483,7 +483,7 @@ void
 weston_compositor_run_binding(struct weston_compositor *compositor,
 			      struct weston_input_device *device,
 			      uint32_t time,
-			      uint32_t key, uint32_t button, uint32_t axis, int32_t state);
+			      uint32_t key, uint32_t button, uint32_t axis, int32_t is_down);
 int
 weston_environment_get_fd(const char *env);
 
diff --git a/src/screenshooter.c b/src/screenshooter.c
index 90dd497..c2b67e1 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -195,7 +195,7 @@ screenshooter_sigchld(struct weston_process *process, int status)
 static void
 screenshooter_binding(struct wl_input_device *device, uint32_t time,
 		 uint32_t key, uint32_t button, uint32_t axis,
-		 int32_t state, void *data)
+		 int32_t is_down, void *data)
 {
 	struct screenshooter *shooter = data;
 	const char *screenshooter_exe = LIBEXECDIR "/weston-screenshooter";
diff --git a/src/shell.c b/src/shell.c
index 6b8719c..c9898fc 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -326,13 +326,13 @@ move_grab_motion(struct wl_pointer_grab *grab,
 
 static void
 move_grab_button(struct wl_pointer_grab *grab,
-		 uint32_t time, uint32_t button, uint32_t state)
+		 uint32_t time, uint32_t button, uint32_t is_down)
 {
 	struct shell_grab *shell_grab = container_of(grab, struct shell_grab,
 						    grab);
 	struct wl_input_device *device = grab->input_device;
 
-	if (device->button_count == 0 && state == 0) {
+	if (device->button_count == 0 && is_down == 0) {
 		shell_grab_finish(shell_grab);
 		wl_input_device_end_pointer_grab(device);
 		free(grab);
@@ -566,12 +566,12 @@ resize_grab_motion(struct wl_pointer_grab *grab,
 
 static void
 resize_grab_button(struct wl_pointer_grab *grab,
-		   uint32_t time, uint32_t button, uint32_t state)
+		   uint32_t time, uint32_t button, uint32_t is_down)
 {
 	struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
 	struct wl_input_device *device = grab->input_device;
 
-	if (device->button_count == 0 && state == 0) {
+	if (device->button_count == 0 && is_down == 0) {
 		shell_grab_finish(&resize->base);
 		wl_input_device_end_pointer_grab(device);
 		free(grab);
@@ -1041,7 +1041,7 @@ popup_grab_motion(struct wl_pointer_grab *grab,
 
 static void
 popup_grab_button(struct wl_pointer_grab *grab,
-		  uint32_t time, uint32_t button, uint32_t state)
+		  uint32_t time, uint32_t button, uint32_t is_down)
 {
 	struct wl_resource *resource;
 	struct shell_surface *shsurf =
@@ -1054,8 +1054,8 @@ popup_grab_button(struct wl_pointer_grab *grab,
 		display = wl_client_get_display(resource->client);
 		serial = wl_display_get_serial(display);
 		wl_input_device_send_button(resource, serial,
-					    time, button, state);
-	} else if (state == 0 &&
+					    time, button, is_down);
+	} else if (is_down == 0 &&
 		   (shsurf->popup.initial_up ||
 		    time - shsurf->popup.device->grab_time > 500)) {
 		wl_shell_surface_send_popup_done(&shsurf->resource);
@@ -1063,7 +1063,7 @@ popup_grab_button(struct wl_pointer_grab *grab,
 		shsurf->popup.grab.input_device = NULL;
 	}
 
-	if (state == 0)
+	if (is_down == 0)
 		shsurf->popup.initial_up = 1;
 }
 
@@ -1476,7 +1476,7 @@ get_shell_surface_type(struct weston_surface *surface)
 
 static void
 move_binding(struct wl_input_device *device, uint32_t time,
-	     uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
+	     uint32_t key, uint32_t button, uint32_t axis, int32_t is_down, void *data)
 {
 	struct weston_surface *surface =
 		(struct weston_surface *) device->pointer_focus;
@@ -1499,7 +1499,7 @@ move_binding(struct wl_input_device *device, uint32_t time,
 
 static void
 resize_binding(struct wl_input_device *device, uint32_t time,
-	       uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
+	       uint32_t key, uint32_t button, uint32_t axis, int32_t is_down, void *data)
 {
 	struct weston_surface *surface =
 		(struct weston_surface *) device->pointer_focus;
@@ -1609,11 +1609,11 @@ zoom_binding(struct wl_input_device *device, uint32_t time,
 
 static void
 terminate_binding(struct wl_input_device *device, uint32_t time,
-		  uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
+		  uint32_t key, uint32_t button, uint32_t axis, int32_t is_down, void *data)
 {
 	struct weston_compositor *compositor = data;
 
-	if (state)
+	if (is_down)
 		wl_display_terminate(compositor->wl_display);
 }
 
@@ -1688,14 +1688,14 @@ rotate_grab_motion(struct wl_pointer_grab *grab,
 
 static void
 rotate_grab_button(struct wl_pointer_grab *grab,
-		 uint32_t time, uint32_t button, uint32_t state)
+		 uint32_t time, uint32_t button, uint32_t is_down)
 {
 	struct rotate_grab *rotate =
 		container_of(grab, struct rotate_grab, base.grab);
 	struct wl_input_device *device = grab->input_device;
 	struct shell_surface *shsurf = rotate->base.shsurf;
 
-	if (device->button_count == 0 && state == 0) {
+	if (device->button_count == 0 && is_down == 0) {
 		if (shsurf)
 			weston_matrix_multiply(&shsurf->rotation.rotation,
 					       &rotate->rotation);
@@ -1713,7 +1713,7 @@ static const struct wl_pointer_grab_interface rotate_grab_interface = {
 
 static void
 rotate_binding(struct wl_input_device *device, uint32_t time,
-	       uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
+	       uint32_t key, uint32_t button, uint32_t axis, int32_t is_down, void *data)
 {
 	struct weston_surface *base_surface =
 		(struct weston_surface *) device->pointer_focus;
@@ -1840,7 +1840,7 @@ is_black_surface (struct weston_surface *es, struct weston_surface **fs_surface)
 static void
 click_to_activate_binding(struct wl_input_device *device,
 			  uint32_t time, uint32_t key,
-			  uint32_t button, uint32_t axis, int32_t state, void *data)
+			  uint32_t button, uint32_t axis, int32_t is_down, void *data)
 {
 	struct weston_input_device *wd = (struct weston_input_device *) device;
 	struct desktop_shell *shell = data;
@@ -1854,7 +1854,7 @@ click_to_activate_binding(struct wl_input_device *device,
 	if (is_black_surface(focus, &upper))
 		focus = upper;
 
-	if (state && device->pointer_grab == &device->default_pointer_grab)
+	if (is_down && device->pointer_grab == &device->default_pointer_grab)
 		activate(shell, focus, wd);
 }
 
@@ -2380,7 +2380,7 @@ switcher_destroy(struct switcher *switcher, uint32_t time)
 
 static void
 switcher_key(struct wl_keyboard_grab *grab,
-	     uint32_t time, uint32_t key, uint32_t state)
+	     uint32_t time, uint32_t key, uint32_t is_down)
 {
 	struct switcher *switcher = container_of(grab, struct switcher, grab);
 	struct weston_input_device *device =
@@ -2388,7 +2388,7 @@ switcher_key(struct wl_keyboard_grab *grab,
 
 	if ((device->modifier_state & switcher->shell->binding_modifier) == 0) {
 		switcher_destroy(switcher, time);
-	} else if (key == KEY_TAB && state) {
+	} else if (key == KEY_TAB && is_down) {
 		switcher_next(switcher);
 	}
 };
@@ -2400,7 +2400,7 @@ static const struct wl_keyboard_grab_interface switcher_grab = {
 static void
 switcher_binding(struct wl_input_device *device, uint32_t time,
 		 uint32_t key, uint32_t button, uint32_t axis,
-		 int32_t state, void *data)
+		 int32_t is_down, void *data)
 {
 	struct desktop_shell *shell = data;
 	struct switcher *switcher;
@@ -2419,7 +2419,7 @@ switcher_binding(struct wl_input_device *device, uint32_t time,
 
 static void
 backlight_binding(struct wl_input_device *device, uint32_t time,
-		  uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
+		  uint32_t key, uint32_t button, uint32_t axis, int32_t is_down, void *data)
 {
 	struct weston_compositor *compositor = data;
 	struct weston_output *output;
@@ -2452,7 +2452,7 @@ backlight_binding(struct wl_input_device *device, uint32_t time,
 
 static void
 debug_repaint_binding(struct wl_input_device *device, uint32_t time,
-		      uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
+		      uint32_t key, uint32_t button, uint32_t axis, int32_t is_down, void *data)
 {
 	struct desktop_shell *shell = data;
 	struct weston_compositor *compositor = shell->compositor;
diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index 633c08f..ce3cd89 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -452,20 +452,20 @@ long_press_handler(void *data)
 
 static void
 menu_key_binding(struct wl_input_device *device, uint32_t time,
-		 uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
+		 uint32_t key, uint32_t button, uint32_t axis, int32_t is_down, void *data)
 {
 	struct tablet_shell *shell = data;
 
 	if (shell->state == STATE_LOCKED)
 		return;
 
-	if (state)
+	if (is_down)
 		toggle_switcher(shell);
 }
 
 static void
 home_key_binding(struct wl_input_device *device, uint32_t time,
-		 uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
+		 uint32_t key, uint32_t button, uint32_t axis, int32_t is_down, void *data)
 {
 	struct tablet_shell *shell = data;
 
@@ -474,7 +474,7 @@ home_key_binding(struct wl_input_device *device, uint32_t time,
 
 	shell->device = (struct weston_input_device *) device;
 
-	if (state) {
+	if (is_down) {
 		wl_event_source_timer_update(shell->long_press_source, 500);
 		shell->long_press_active = 1;
 	} else if (shell->long_press_active) {
diff --git a/src/util.c b/src/util.c
index 78f6980..711c04a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -249,7 +249,7 @@ struct binding_keyboard_grab {
 
 static void
 binding_key(struct wl_keyboard_grab *grab,
-	    uint32_t time, uint32_t key, uint32_t state)
+	    uint32_t time, uint32_t key, uint32_t is_down)
 {
 	struct binding_keyboard_grab *b =
 		container_of(grab, struct binding_keyboard_grab, grab);
@@ -259,14 +259,14 @@ binding_key(struct wl_keyboard_grab *grab,
 
 	resource = grab->input_device->keyboard_focus_resource;
 	if (key == b->key) {
-		if (!state) {
+		if (!is_down) {
 			wl_input_device_end_keyboard_grab(grab->input_device);
 			free(b);
 		}
 	} else if (resource) {
 		display = wl_client_get_display(resource->client);
 		serial = wl_display_next_serial(display);
-		wl_input_device_send_key(resource, serial, time, key, state);
+		wl_input_device_send_key(resource, serial, time, key, is_down);
 	}
 }
 
@@ -290,15 +290,15 @@ WL_EXPORT void
 weston_compositor_run_binding(struct weston_compositor *compositor,
 			      struct weston_input_device *device,
 			      uint32_t time, uint32_t key,
-			      uint32_t button, uint32_t axis, int32_t state)
+			      uint32_t button, uint32_t axis, int32_t is_down)
 {
 	struct weston_binding *b;
 
 	wl_list_for_each(b, &compositor->binding_list, link) {
 		if (b->key == key && b->button == button && b->axis == axis &&
-		    b->modifier == device->modifier_state && state) {
+		    b->modifier == device->modifier_state && is_down) {
 			b->handler(&device->input_device,
-				   time, key, button, axis, state, b->data);
+				   time, key, button, axis, is_down, b->data);
 
 			/* If this was a key binding and it didn't
 			 * install a keyboard grab, install one now to
diff --git a/tests/test-client.c b/tests/test-client.c
index 1db1615..30668ac 100644
--- a/tests/test-client.c
+++ b/tests/test-client.c
@@ -66,13 +66,13 @@ input_handle_motion(void *data, struct wl_input_device *input_device,
 static void
 input_handle_button(void *data,
 		    struct wl_input_device *input_device, uint32_t serial,
-		    uint32_t time, uint32_t button, uint32_t state)
+		    uint32_t time, uint32_t button, uint32_t is_down)
 {
 	struct input *input = data;
 	uint32_t bit;
 
 	bit = 1 << (button - 272);
-	if (state)
+	if (is_down)
 		input->button_mask |= bit;
 	else
 		input->button_mask &= ~bit;
@@ -87,7 +87,7 @@ input_handle_axis(void *data,
 
 static void
 input_handle_key(void *data, struct wl_input_device *input_device,
-		 uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
+		 uint32_t serial, uint32_t time, uint32_t key, uint32_t is_down)
 {
 }
 
-- 
1.7.10



More information about the wayland-devel mailing list