Revision 7e581fb3 input.c
b/input.c | ||
---|---|---|
28 | 28 |
#include "console.h" |
29 | 29 |
#include "qjson.h" |
30 | 30 |
|
31 |
|
|
32 | 31 |
static QEMUPutKBDEvent *qemu_put_kbd_event; |
33 | 32 |
static void *qemu_put_kbd_event_opaque; |
34 | 33 |
static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers = QTAILQ_HEAD_INITIALIZER(led_handlers); |
35 | 34 |
static QTAILQ_HEAD(, QEMUPutMouseEntry) mouse_handlers = |
36 | 35 |
QTAILQ_HEAD_INITIALIZER(mouse_handlers); |
36 |
static NotifierList mouse_mode_notifiers = |
|
37 |
NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers); |
|
37 | 38 |
|
38 | 39 |
void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque) |
39 | 40 |
{ |
... | ... | |
41 | 42 |
qemu_put_kbd_event = func; |
42 | 43 |
} |
43 | 44 |
|
45 |
static void check_mode_change(void) |
|
46 |
{ |
|
47 |
static int current_is_absolute, current_has_absolute; |
|
48 |
int is_absolute; |
|
49 |
int has_absolute; |
|
50 |
|
|
51 |
is_absolute = kbd_mouse_is_absolute(); |
|
52 |
has_absolute = kbd_mouse_has_absolute(); |
|
53 |
|
|
54 |
if (is_absolute != current_is_absolute || |
|
55 |
has_absolute != current_has_absolute) { |
|
56 |
notifier_list_notify(&mouse_mode_notifiers); |
|
57 |
} |
|
58 |
|
|
59 |
current_is_absolute = is_absolute; |
|
60 |
current_has_absolute = has_absolute; |
|
61 |
} |
|
62 |
|
|
44 | 63 |
QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, |
45 | 64 |
void *opaque, int absolute, |
46 | 65 |
const char *name) |
... | ... | |
58 | 77 |
|
59 | 78 |
QTAILQ_INSERT_TAIL(&mouse_handlers, s, node); |
60 | 79 |
|
80 |
check_mode_change(); |
|
81 |
|
|
61 | 82 |
return s; |
62 | 83 |
} |
63 | 84 |
|
... | ... | |
75 | 96 |
|
76 | 97 |
qemu_free(entry->qemu_put_mouse_event_name); |
77 | 98 |
qemu_free(entry); |
99 |
|
|
100 |
check_mode_change(); |
|
78 | 101 |
} |
79 | 102 |
|
80 | 103 |
QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, |
... | ... | |
256 | 279 |
if (!found) { |
257 | 280 |
monitor_printf(mon, "Mouse at given index not found\n"); |
258 | 281 |
} |
282 |
|
|
283 |
check_mode_change(); |
|
284 |
} |
|
285 |
|
|
286 |
void qemu_add_mouse_mode_change_notifier(Notifier *notify) |
|
287 |
{ |
|
288 |
notifier_list_add(&mouse_mode_notifiers, notify); |
|
289 |
} |
|
290 |
|
|
291 |
void qemu_remove_mouse_mode_change_notifier(Notifier *notify) |
|
292 |
{ |
|
293 |
notifier_list_remove(&mouse_mode_notifiers, notify); |
|
259 | 294 |
} |
Also available in: Unified diff