input: move mouse mode notifier to new core
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
		
							parent
							
								
									4798648e32
								
							
						
					
					
						commit
						4a33f45e2e
					
				@ -48,10 +48,6 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void kbd_put_ledstate(int ledstate);
 | 
					void kbd_put_ledstate(int ledstate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Does the current mouse generate absolute events */
 | 
					 | 
				
			||||||
void qemu_add_mouse_mode_change_notifier(Notifier *notify);
 | 
					 | 
				
			||||||
void qemu_remove_mouse_mode_change_notifier(Notifier *notify);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct MouseTransformInfo {
 | 
					struct MouseTransformInfo {
 | 
				
			||||||
    /* Touchscreen resolution */
 | 
					    /* Touchscreen resolution */
 | 
				
			||||||
    int x;
 | 
					    int x;
 | 
				
			||||||
 | 
				
			|||||||
@ -49,4 +49,8 @@ void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value);
 | 
				
			|||||||
void qemu_input_queue_abs(QemuConsole *src, InputAxis axis,
 | 
					void qemu_input_queue_abs(QemuConsole *src, InputAxis axis,
 | 
				
			||||||
                          int value, int size);
 | 
					                          int value, int size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void qemu_input_check_mode_change(void);
 | 
				
			||||||
 | 
					void qemu_add_mouse_mode_change_notifier(Notifier *notify);
 | 
				
			||||||
 | 
					void qemu_remove_mouse_mode_change_notifier(Notifier *notify);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* INPUT_H */
 | 
					#endif /* INPUT_H */
 | 
				
			||||||
 | 
				
			|||||||
@ -65,8 +65,6 @@ static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers =
 | 
				
			|||||||
    QTAILQ_HEAD_INITIALIZER(led_handlers);
 | 
					    QTAILQ_HEAD_INITIALIZER(led_handlers);
 | 
				
			||||||
static QTAILQ_HEAD(, QEMUPutMouseEntry) mouse_handlers =
 | 
					static QTAILQ_HEAD(, QEMUPutMouseEntry) mouse_handlers =
 | 
				
			||||||
    QTAILQ_HEAD_INITIALIZER(mouse_handlers);
 | 
					    QTAILQ_HEAD_INITIALIZER(mouse_handlers);
 | 
				
			||||||
static NotifierList mouse_mode_notifiers =
 | 
					 | 
				
			||||||
    NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const int key_defs[] = {
 | 
					static const int key_defs[] = {
 | 
				
			||||||
    [Q_KEY_CODE_SHIFT] = 0x2a,
 | 
					    [Q_KEY_CODE_SHIFT] = 0x2a,
 | 
				
			||||||
@ -364,20 +362,6 @@ void qemu_remove_kbd_event_handler(QEMUPutKbdEntry *entry)
 | 
				
			|||||||
    g_free(entry);
 | 
					    g_free(entry);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void check_mode_change(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    static int current_is_absolute;
 | 
					 | 
				
			||||||
    int is_absolute;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    is_absolute = qemu_input_is_absolute();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (is_absolute != current_is_absolute) {
 | 
					 | 
				
			||||||
        notifier_list_notify(&mouse_mode_notifiers, NULL);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    current_is_absolute = is_absolute;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void legacy_mouse_event(DeviceState *dev, QemuConsole *src,
 | 
					static void legacy_mouse_event(DeviceState *dev, QemuConsole *src,
 | 
				
			||||||
                               InputEvent *evt)
 | 
					                               InputEvent *evt)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -448,8 +432,6 @@ QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
 | 
				
			|||||||
    s->s = qemu_input_handler_register((DeviceState *)s,
 | 
					    s->s = qemu_input_handler_register((DeviceState *)s,
 | 
				
			||||||
                                       &s->h);
 | 
					                                       &s->h);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    check_mode_change();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return s;
 | 
					    return s;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -459,8 +441,6 @@ void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry)
 | 
				
			|||||||
    QTAILQ_INSERT_HEAD(&mouse_handlers, entry, node);
 | 
					    QTAILQ_INSERT_HEAD(&mouse_handlers, entry, node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qemu_input_handler_activate(entry->s);
 | 
					    qemu_input_handler_activate(entry->s);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    check_mode_change();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry)
 | 
					void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry)
 | 
				
			||||||
@ -471,8 +451,6 @@ void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    g_free(entry->qemu_put_mouse_event_name);
 | 
					    g_free(entry->qemu_put_mouse_event_name);
 | 
				
			||||||
    g_free(entry);
 | 
					    g_free(entry);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    check_mode_change();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func,
 | 
					QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func,
 | 
				
			||||||
@ -551,15 +529,5 @@ void do_mouse_set(Monitor *mon, const QDict *qdict)
 | 
				
			|||||||
        monitor_printf(mon, "Mouse at given index not found\n");
 | 
					        monitor_printf(mon, "Mouse at given index not found\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    check_mode_change();
 | 
					    qemu_input_check_mode_change();
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void qemu_add_mouse_mode_change_notifier(Notifier *notify)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    notifier_list_add(&mouse_mode_notifiers, notify);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void qemu_remove_mouse_mode_change_notifier(Notifier *notify)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    notifier_remove(notify);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										30
									
								
								ui/input.c
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								ui/input.c
									
									
									
									
									
								
							@ -13,6 +13,8 @@ struct QemuInputHandlerState {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
static QTAILQ_HEAD(, QemuInputHandlerState) handlers =
 | 
					static QTAILQ_HEAD(, QemuInputHandlerState) handlers =
 | 
				
			||||||
    QTAILQ_HEAD_INITIALIZER(handlers);
 | 
					    QTAILQ_HEAD_INITIALIZER(handlers);
 | 
				
			||||||
 | 
					static NotifierList mouse_mode_notifiers =
 | 
				
			||||||
 | 
					    NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
 | 
					QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
 | 
				
			||||||
                                                   QemuInputHandler *handler)
 | 
					                                                   QemuInputHandler *handler)
 | 
				
			||||||
@ -24,6 +26,8 @@ QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
 | 
				
			|||||||
    s->handler = handler;
 | 
					    s->handler = handler;
 | 
				
			||||||
    s->id = id++;
 | 
					    s->id = id++;
 | 
				
			||||||
    QTAILQ_INSERT_TAIL(&handlers, s, node);
 | 
					    QTAILQ_INSERT_TAIL(&handlers, s, node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    qemu_input_check_mode_change();
 | 
				
			||||||
    return s;
 | 
					    return s;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -31,12 +35,14 @@ void qemu_input_handler_activate(QemuInputHandlerState *s)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    QTAILQ_REMOVE(&handlers, s, node);
 | 
					    QTAILQ_REMOVE(&handlers, s, node);
 | 
				
			||||||
    QTAILQ_INSERT_HEAD(&handlers, s, node);
 | 
					    QTAILQ_INSERT_HEAD(&handlers, s, node);
 | 
				
			||||||
 | 
					    qemu_input_check_mode_change();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void qemu_input_handler_unregister(QemuInputHandlerState *s)
 | 
					void qemu_input_handler_unregister(QemuInputHandlerState *s)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    QTAILQ_REMOVE(&handlers, s, node);
 | 
					    QTAILQ_REMOVE(&handlers, s, node);
 | 
				
			||||||
    g_free(s);
 | 
					    g_free(s);
 | 
				
			||||||
 | 
					    qemu_input_check_mode_change();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static QemuInputHandlerState*
 | 
					static QemuInputHandlerState*
 | 
				
			||||||
@ -274,3 +280,27 @@ void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value, int size)
 | 
				
			|||||||
    qemu_input_event_send(src, evt);
 | 
					    qemu_input_event_send(src, evt);
 | 
				
			||||||
    qapi_free_InputEvent(evt);
 | 
					    qapi_free_InputEvent(evt);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void qemu_input_check_mode_change(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static int current_is_absolute;
 | 
				
			||||||
 | 
					    int is_absolute;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    is_absolute = qemu_input_is_absolute();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (is_absolute != current_is_absolute) {
 | 
				
			||||||
 | 
					        notifier_list_notify(&mouse_mode_notifiers, NULL);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    current_is_absolute = is_absolute;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void qemu_add_mouse_mode_change_notifier(Notifier *notify)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    notifier_list_add(&mouse_mode_notifiers, notify);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void qemu_remove_mouse_mode_change_notifier(Notifier *notify)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    notifier_remove(notify);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user