Commit 81b3e127 authored by Jeremy White's avatar Jeremy White

Add support for returning led status.

parent 9c92e392
......@@ -6,6 +6,7 @@ PKG_CHECK_MODULES(DAMAGE, xcb-damage)
PKG_CHECK_MODULES(XTEST, xcb-xtest)
PKG_CHECK_MODULES(SHM, xcb-shm)
PKG_CHECK_MODULES(UTIL, xcb-util)
PKG_CHECK_MODULES(XKB, xcb-xkb)
PKG_CHECK_MODULES(GTK2, gtk+-2.0)
PKG_CHECK_MODULES(SPICE, spice-server)
PKG_CHECK_MODULES(SPICE_PROTOCOL, spice-protocol)
......
......@@ -2,8 +2,8 @@
@CODE_COVERAGE_RULES@
bin_PROGRAMS = x11spice
ALL_XCB_CFLAGS=$(XCB_CFLAGS) $(DAMAGE_CFLAGS) $(XTEST_CFLAGS) $(SHM_CFLAGS) $(UTIL_CFLAGS)
ALL_XCB_LIBS=$(XCB_LIBS) $(DAMAGE_LIBS) $(XTEST_LIBS) $(SHM_LIBS) $(UTIL_LIBS)
ALL_XCB_CFLAGS=$(XCB_CFLAGS) $(DAMAGE_CFLAGS) $(XTEST_CFLAGS) $(SHM_CFLAGS) $(UTIL_CFLAGS) $(XKB_CFLAGS)
ALL_XCB_LIBS=$(XCB_LIBS) $(DAMAGE_LIBS) $(XTEST_LIBS) $(SHM_LIBS) $(UTIL_LIBS) $(XKB_LIBS)
AM_CFLAGS = -Wall $(ALL_XCB_CFLAGS) $(GTK2_CFLAGS) $(SPICE_CFLAGS) $(SPICE_PROTOCOL_CFLAGS) $(GLIB2_CFLAGS) $(PIXMAN_CFLAGS) $(CODE_COVERAGE_CFLAGS)
x11spice_LDADD = $(ALL_XCB_LIBS) $(GTK2_LIBS) $(SPICE_LIBS) $(GLIB2_LIBS) $(PIXMAN_LIBS) $(CODE_COVERAGE_LDFLAGS)
x11spice_SOURCES = \
......
......@@ -29,6 +29,7 @@
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <xcb/xkb.h>
#include <pixman.h>
#include <errno.h>
......@@ -168,6 +169,8 @@ int display_open(display_t *d, options_t *options)
int rc;
xcb_damage_query_version_cookie_t dcookie;
xcb_damage_query_version_reply_t *damage_version;
xcb_xkb_use_extension_cookie_t use_cookie;
xcb_xkb_use_extension_reply_t *use_reply;
xcb_void_cookie_t cookie;
xcb_generic_error_t *error;
......@@ -238,6 +241,17 @@ int display_open(display_t *d, options_t *options)
return X11SPICE_ERR_NOXFIXES;
}
use_cookie = xcb_xkb_use_extension(d->c, XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION);
use_reply = xcb_xkb_use_extension_reply(d->c, use_cookie, &error);
if (error)
{
fprintf(stderr, "Could not get use reply; type %d; code %d; major %d; minor %d\n",
error->response_type, error->error_code, error->major_code, error->minor_code);
return X11SPICE_ERR_NO_XKB;
}
free(use_reply);
rc = display_create_fullscreen(d);
g_message("Display %s opened", options->display ? options->display : "");
......
......@@ -92,7 +92,7 @@ static QXLDrawable *shm_image_to_drawable(spice_t *s, shm_image_t *shmi, int x,
static guint64 get_timeout(scanner_t *scanner)
{
// FIXME - make this a bit smarter...
return G_USEC_PER_SEC / 30;
}
......
......@@ -20,10 +20,12 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <xcb/xcb.h>
#include <xcb/xtest.h>
#include <xcb/xcb_aux.h>
#include <xcb/xkb.h>
#include "x11spice.h"
#include "session.h"
......@@ -228,3 +230,42 @@ int session_push_cursor_image(session_t *s,
return 0;
}
int session_get_one_led(session_t *session, const char *name)
{
int ret;
xcb_intern_atom_cookie_t atom_cookie;
xcb_intern_atom_reply_t *atom_reply;
xcb_xkb_get_named_indicator_cookie_t indicator_cookie;
xcb_xkb_get_named_indicator_reply_t *indicator_reply;
xcb_generic_error_t *error;
atom_cookie = xcb_intern_atom(session->display.c, 0, strlen(name), name);
atom_reply = xcb_intern_atom_reply(session->display.c, atom_cookie, &error);
if (error)
{
g_warning("Could not get atom; type %d; code %d; major %d; minor %d",
error->response_type, error->error_code, error->major_code, error->minor_code);
return 0;
}
indicator_cookie = xcb_xkb_get_named_indicator(session->display.c,
XCB_XKB_ID_USE_CORE_KBD,
XCB_XKB_LED_CLASS_DFLT_XI_CLASS,
XCB_XKB_ID_DFLT_XI_ID,
atom_reply->atom);
free(atom_reply);
indicator_reply = xcb_xkb_get_named_indicator_reply(session->display.c, indicator_cookie, &error);
if (error)
{
g_warning("Could not get indicator; type %d; code %d; major %d; minor %d",
error->response_type, error->error_code, error->major_code, error->minor_code);
return 0;
}
ret = indicator_reply->on;
free(indicator_reply);
return ret;
}
......@@ -63,6 +63,8 @@ void session_handle_mouse_position(session_t *session, int x, int y, uint32_t bu
void session_handle_mouse_buttons(session_t *session, uint32_t buttons_state);
void session_handle_mouse_wheel(session_t *session, int wheel_motion, uint32_t buttons_state);
int session_get_one_led(session_t *session, const char *name);
int session_push_cursor_image(session_t *s,
int x, int y, int w, int h, int xhot, int yhot,
int imglen, uint8_t *imgdata);
......
......@@ -306,13 +306,6 @@ static void update_area_complete(QXLInstance *qin, uint32_t surface_id,
g_debug("FIXME! UNIMPLEMENTED! %s", __func__);
}
static void set_client_capabilities(QXLInstance *qin,
uint8_t client_present,
uint8_t *caps)
{
g_debug("FIXME! UNIMPLEMENTED! %s", __func__);
}
static int client_monitors_config(QXLInstance *qin,
VDAgentMonitorsConfig *monitors_config)
{
......@@ -377,8 +370,17 @@ static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
{
g_debug("FIXME! UNIMPLEMENTED! %s", __func__);
return 0;
spice_t *s = SPICE_CONTAINEROF(sin, spice_t, keyboard_sin);
uint8_t ret = 0;
if (session_get_one_led(s->session, "Caps Lock"))
ret |= SPICE_KEYBOARD_MODIFIER_FLAGS_CAPS_LOCK;
if (session_get_one_led(s->session, "Scroll Lock"))
ret |= SPICE_KEYBOARD_MODIFIER_FLAGS_SCROLL_LOCK;
if (session_get_one_led(s->session, "Num Lock"))
ret |= SPICE_KEYBOARD_MODIFIER_FLAGS_NUM_LOCK;
return ret;
}
void tablet_set_logical_size(SpiceTabletInstance* tablet, int width, int height)
......@@ -498,7 +500,7 @@ void initialize_spice_instance(spice_t *s)
.async_complete = async_complete,
.update_area_complete = update_area_complete,
.client_monitors_config = client_monitors_config,
.set_client_capabilities = set_client_capabilities,
.set_client_capabilities = NULL, /* Allowed to be unset */
};
static const SpiceKbdInterface keyboard_sif = {
......
......@@ -37,5 +37,6 @@
#define X11SPICE_ERR_SHUTTING_DOWN 10
#define X11SPICE_ERR_NOXFIXES 11
#define X11SPICE_ERR_NOEVENTS 12
#define X11SPICE_ERR_NO_XKB 13
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment