Beispiel #1
0
void
wlb_keyboard_set_focus(struct wlb_keyboard *keyboard,
		       struct wlb_surface *focus)
{
	struct wl_resource *resource;
	uint32_t serial;

	if (keyboard->focus == focus)
		return;

	serial = wl_display_next_serial(keyboard->seat->compositor->display);
	
	if (keyboard->focus) {
		wl_resource_for_each(resource, &keyboard->resource_list)
			wl_keyboard_send_leave(resource, serial,
					       keyboard->focus->resource);

		wl_list_remove(&keyboard->surface_destroy_listener.link);
	}

	keyboard->focus = focus;
	
	if (keyboard->focus) {
		wl_resource_add_destroy_listener(focus->resource,
						 &keyboard->surface_destroy_listener);

		wl_resource_for_each(resource, &keyboard->resource_list)
			wl_keyboard_send_enter(resource, serial,
					       keyboard->focus->resource,
					       &keyboard->keys);
	}
}
Beispiel #2
0
WL_EXPORT void
wlb_keyboard_key(struct wlb_keyboard *keyboard, uint32_t time,
		 uint32_t key, enum wl_keyboard_key_state state)
{
	struct wl_resource *resource;
	uint32_t serial, *k, *end;

	keyboard_ensure_focus(keyboard);

	end = keyboard->keys.data + keyboard->keys.size;
	for (k = keyboard->keys.data; k < end; k++) {
		if (*k == key) {
			/* Ignore server-generated repeats. */
			if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
				return;
			*k = *--end;
		}
	}
	keyboard->keys.size = (void *) end - keyboard->keys.data;
	if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
		k = wl_array_add(&keyboard->keys, sizeof *k);
		*k = key;
	}

	if (!keyboard->focus || wl_list_empty(&keyboard->resource_list))
		return;
	
	serial = wl_display_next_serial(keyboard->seat->compositor->display);
	wl_resource_for_each(resource, &keyboard->resource_list)
		wl_keyboard_send_key(resource, serial, time, key, state);
}
Beispiel #3
0
static bool set_name(struct config_node * node, const char * value)
{
    struct tag * tag = wl_container_of(node, tag, config.name);
    struct wl_resource * resource;
    char * name;

    if (!(name = strdup(value)))
        return false;

    free(tag->name);
    tag->name = name;

    wl_resource_for_each(resource, &tag->resources)
        velox_tag_send_name(resource, tag->name);

    return true;
}
Beispiel #4
0
WL_EXPORT void
wlb_keyboard_modifiers(struct wlb_keyboard *keyboard, uint32_t mods_depressed,
		       uint32_t mods_latched, uint32_t mods_locked,
		       uint32_t group)
{
	struct wl_resource *resource;
	uint32_t serial;

	keyboard_ensure_focus(keyboard);

	if (!keyboard->focus || wl_list_empty(&keyboard->resource_list))
		return;
	
	serial = wl_display_next_serial(keyboard->seat->compositor->display);
	wl_resource_for_each(resource, &keyboard->resource_list)
		wl_keyboard_send_modifiers(resource, serial, mods_depressed,
					   mods_latched, mods_locked, group);
}
Beispiel #5
0
void tag_add(struct tag * tag, struct screen * screen)
{
    struct wl_resource * resource;

    assert(tag->screen == NULL);

    /* Add the tag to the end of the tag list to minimize churn of the screen's
     * active tag, and to prefer recently released tags. */
    wl_list_insert(screen ? screen->tags.prev : &velox.unused_tags, &tag->link);

    if (screen)
    {
        screen->mask |= tag->mask;
        tag->screen = screen;
    }

    wl_resource_for_each(resource, &tag->resources)
        tag_send_screen(tag, wl_resource_get_client(resource), resource, NULL);
}