examples/pointer-constraints: style fixes

This commit is contained in:
emersion 2018-09-26 17:34:09 +02:00
parent afa2e399aa
commit e3736d4acc
1 changed files with 20 additions and 14 deletions

View File

@ -43,17 +43,19 @@ static void draw(void) {
eglSwapBuffers(egl.display, egl_surface); eglSwapBuffers(egl.display, egl_surface);
} }
static void pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial, static void pointer_handle_button(void *data, struct wl_pointer *pointer,
uint32_t time, uint32_t button, uint32_t state_w) { uint32_t serial, uint32_t time, uint32_t button, uint32_t state_w) {
struct wl_surface *surface = data; struct wl_surface *surface = data;
if (button == BTN_LEFT && state_w == WL_POINTER_BUTTON_STATE_PRESSED) { if (button == BTN_LEFT && state_w == WL_POINTER_BUTTON_STATE_PRESSED) {
region_type = (region_type + 1) % REGION_TYPE_MAX; region_type = (region_type + 1) % REGION_TYPE_MAX;
if (locked_pointer) { if (locked_pointer) {
zwp_locked_pointer_v1_set_region(locked_pointer, regions[region_type]); zwp_locked_pointer_v1_set_region(locked_pointer,
regions[region_type]);
} else if (confined_pointer) { } else if (confined_pointer) {
zwp_confined_pointer_v1_set_region(confined_pointer, regions[region_type]); zwp_confined_pointer_v1_set_region(confined_pointer,
regions[region_type]);
} }
wl_surface_commit(surface); wl_surface_commit(surface);
@ -149,9 +151,10 @@ static void handle_global(void *data, struct wl_registry *registry,
wm_base = wl_registry_bind(registry, name, &xdg_wm_base_interface, 1); wm_base = wl_registry_bind(registry, name, &xdg_wm_base_interface, 1);
} else if (strcmp(interface, wl_seat_interface.name) == 0) { } else if (strcmp(interface, wl_seat_interface.name) == 0) {
seat = wl_registry_bind(registry, name, &wl_seat_interface, version); seat = wl_registry_bind(registry, name, &wl_seat_interface, version);
} else if (strcmp(interface, zwp_pointer_constraints_v1_interface.name) == 0) { } else if (strcmp(interface,
zwp_pointer_constraints_v1_interface.name) == 0) {
pointer_constraints = wl_registry_bind(registry, name, pointer_constraints = wl_registry_bind(registry, name,
&zwp_pointer_constraints_v1_interface, version); &zwp_pointer_constraints_v1_interface, version);
} }
} }
@ -225,12 +228,15 @@ int main(int argc, char **argv) {
if (lock) { if (lock) {
locked_pointer = zwp_pointer_constraints_v1_lock_pointer( locked_pointer = zwp_pointer_constraints_v1_lock_pointer(
pointer_constraints, surface, pointer, regions[region_type], lifetime); pointer_constraints, surface, pointer,
regions[region_type], lifetime);
zwp_locked_pointer_v1_set_cursor_position_hint(locked_pointer, wl_fixed_from_int(128), wl_fixed_from_int(128)); zwp_locked_pointer_v1_set_cursor_position_hint(locked_pointer,
wl_fixed_from_int(128), wl_fixed_from_int(128));
} else { } else {
confined_pointer = zwp_pointer_constraints_v1_confine_pointer( confined_pointer = zwp_pointer_constraints_v1_confine_pointer(
pointer_constraints, surface, pointer, regions[region_type], lifetime); pointer_constraints, surface, pointer,
regions[region_type], lifetime);
} }
wl_surface_commit(surface); wl_surface_commit(surface);
@ -246,9 +252,9 @@ int main(int argc, char **argv) {
return EXIT_SUCCESS; return EXIT_SUCCESS;
invalid_args: { invalid_args:
fprintf(stderr, "pointer-constraints <lock | confine> <oneshot | persistent> " fprintf(stderr, "pointer-constraints <lock | confine> "
"<no-region | disjoint-rejoin | joint-region>\n"); "<oneshot | persistent> "
exit(EXIT_FAILURE); "<no-region | disjoint-rejoin | joint-region>\n");
} return EXIT_FAILURE;
} }