2 * \brief DOpE client library
4 * \author Norman Feske <nf2@inf.tu-dresden.de>
8 * Copyright (C) 2002-2003 Norman Feske <nf2@os.inf.tu-dresden.de>
9 * Technische Universitaet Dresden, Operating Systems Research Group
11 * This file is part of the DOpE package, which is distributed under
12 * the terms of the GNU General Public Licence 2. Please see the
13 * COPYING file for details.
16 /*** GENERIC INCLUDES ***/
17 #include <l4/re/c/event.h>
18 #include <l4/input/libinput.h>
29 #define EVENT_RELEASE 2
30 #define EVENT_MOTION 3
31 #define EVENT_MOUSE_ENTER 4
32 #define EVENT_MOUSE_LEAVE 5
33 #define EVENT_KEY_REPEAT 6
34 #define EVENT_ABSMOTION 7
35 #define EVENT_ACTION 99
40 void (*callback)(dope_event *,void *);
44 /*** UTILITY: CONVERT CALLBACK FUNCTION TO BIND ARGUMENT STRING ***/
45 char *dopelib_callback_to_bindarg(void (*callback)(dope_event *,void *),
47 char *dst_buf, int dst_len)
49 struct cb_data *c = malloc(sizeof(struct cb_data));
50 c->callback = callback;
52 snprintf(dst_buf, dst_len, "0x%lx", (unsigned long)c);
57 /*** INTERFACE: BIND AN EVENT TO A DOpE WIDGET ***/
58 void dope_bind(const char *var, const char *event_type,
59 void (*callback)(dope_event *,void *), void *arg)
64 dopelib_mutex_lock(dopelib_cmdf_mutex);
66 dopelib_callback_to_bindarg(callback, arg, bindbuf, sizeof(bindbuf));
67 snprintf(cmdbuf, sizeof(cmdbuf), "%s.bind(\"%s\",%s)",
68 var, event_type, bindbuf);
71 dopelib_mutex_unlock(dopelib_cmdf_mutex);
75 /*** INTERFACE: BIND AN EVENT TO A DOpE WIDGET SPECIFIED AS FORMAT STRING ***/
76 void dope_bindf(const char *varfmt, const char *event_type,
77 void (*callback)(dope_event *,void *), void *arg,...)
84 vsnprintf(varstr, sizeof(varstr), varfmt, list);
87 dope_bind(varstr, event_type, callback, arg);
90 char *dope_get_bindarg(l4re_event_t *ev)
95 struct cb_data *cb = (struct cb_data*)(ev->stream_id);
102 void dope_process_event(l4re_event_t *ev);
104 /*** INTERFACE: PROCESS SINGLE DOpE EVENT ***/
105 void dope_process_event(l4re_event_t *ev)
110 struct cb_data *cb = (struct cb_data*)(ev->stream_id);
114 cb->callback(ev, cb->arg);
117 void dope_deinit_app(void) {}
120 /*** INTERFACE: DISCONNECT FROM DOpE ***
122 * FIXME: wait for the finishing of the current command and block net commands
124 void dope_deinit(void) {}