qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL v4 31/38] input: move mouse mode notifier to new core
Date: Wed,  5 Mar 2014 12:53:33 +0100	[thread overview]
Message-ID: <1394020420-17576-32-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1394020420-17576-1-git-send-email-kraxel@redhat.com>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h |  4 ----
 include/ui/input.h   |  4 ++++
 ui/input-legacy.c    | 34 +---------------------------------
 ui/input.c           | 30 ++++++++++++++++++++++++++++++
 4 files changed, 35 insertions(+), 37 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 71a0da3..9a282cb 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -48,10 +48,6 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry);
 
 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 {
     /* Touchscreen resolution */
     int x;
diff --git a/include/ui/input.h b/include/ui/input.h
index 28afc45..4976f3d 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -49,4 +49,8 @@ void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value);
 void qemu_input_queue_abs(QemuConsole *src, InputAxis axis,
                           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 */
diff --git a/ui/input-legacy.c b/ui/input-legacy.c
index 26ff06f..7f8e72b 100644
--- a/ui/input-legacy.c
+++ b/ui/input-legacy.c
@@ -65,8 +65,6 @@ static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers =
     QTAILQ_HEAD_INITIALIZER(led_handlers);
 static QTAILQ_HEAD(, QEMUPutMouseEntry) mouse_handlers =
     QTAILQ_HEAD_INITIALIZER(mouse_handlers);
-static NotifierList mouse_mode_notifiers =
-    NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers);
 
 static const int key_defs[] = {
     [Q_KEY_CODE_SHIFT] = 0x2a,
@@ -364,20 +362,6 @@ void qemu_remove_kbd_event_handler(QEMUPutKbdEntry *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,
                                InputEvent *evt)
 {
@@ -448,8 +432,6 @@ QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
     s->s = qemu_input_handler_register((DeviceState *)s,
                                        &s->h);
 
-    check_mode_change();
-
     return s;
 }
 
@@ -459,8 +441,6 @@ void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry)
     QTAILQ_INSERT_HEAD(&mouse_handlers, entry, node);
 
     qemu_input_handler_activate(entry->s);
-
-    check_mode_change();
 }
 
 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);
-
-    check_mode_change();
 }
 
 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");
     }
 
-    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);
+    qemu_input_check_mode_change();
 }
diff --git a/ui/input.c b/ui/input.c
index 60302b1..b8fc681 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -13,6 +13,8 @@ struct QemuInputHandlerState {
 };
 static QTAILQ_HEAD(, QemuInputHandlerState) handlers =
     QTAILQ_HEAD_INITIALIZER(handlers);
+static NotifierList mouse_mode_notifiers =
+    NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers);
 
 QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
                                                    QemuInputHandler *handler)
@@ -24,6 +26,8 @@ QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
     s->handler = handler;
     s->id = id++;
     QTAILQ_INSERT_TAIL(&handlers, s, node);
+
+    qemu_input_check_mode_change();
     return s;
 }
 
@@ -31,12 +35,14 @@ void qemu_input_handler_activate(QemuInputHandlerState *s)
 {
     QTAILQ_REMOVE(&handlers, s, node);
     QTAILQ_INSERT_HEAD(&handlers, s, node);
+    qemu_input_check_mode_change();
 }
 
 void qemu_input_handler_unregister(QemuInputHandlerState *s)
 {
     QTAILQ_REMOVE(&handlers, s, node);
     g_free(s);
+    qemu_input_check_mode_change();
 }
 
 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);
     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);
+}
-- 
1.8.3.1

  parent reply	other threads:[~2014-03-05 11:55 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-05 11:53 [Qemu-devel] [PULL v4 00/38] rework input handling, sdl2 support Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 01/38] console: export QemuConsole index, width, height Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 02/38] input: rename file to legacy Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 03/38] input: qapi: define event types Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 04/38] input: qapi: add unmapped key Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 05/38] input: qapi: add pause key Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 06/38] input: add core bits of the new input layer Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 07/38] input: keyboard: add helper functions to core Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 08/38] input: keyboard: switch legacy handlers to new core Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 09/38] input: keyboard: switch qmp_send_key() " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 10/38] input: keyboard: switch gtk ui " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 11/38] input: keyboard: switch sdl " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 12/38] input: keyboard: switch vnc " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 13/38] input: keyboard: switch spice " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 14/38] input: keyboard: switch curses " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 15/38] input: mouse: add helpers functions to core Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 16/38] input: mouse: add graphic_rotate support Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 17/38] input: mouse: add qemu_input_is_absolute() Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 18/38] input: mouse: switch legacy handlers to new core Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 19/38] input: mouse: switch gtk ui " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 20/38] input: mouse: switch sdl " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 21/38] input: mouse: switch vnc " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 22/38] input: mouse: switch spice " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 23/38] input: mouse: switch monitor " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 24/38] input: keyboard: switch cocoa ui " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 25/38] input: mouse: " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 26/38] input: trace events Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 27/38] input-legacy: remove kbd_put_keycode Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 28/38] input-legacy: remove kbd_mouse_has_absolute Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 29/38] input-legacy: remove kbd_mouse_is_absolute Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 30/38] input-legacy: remove kbd_mouse_event Gerd Hoffmann
2014-03-05 11:53 ` Gerd Hoffmann [this message]
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 32/38] input: add input_mouse_mode tracepoint Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 33/38] input: move qmp_query_mice to new core Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 34/38] input: move do_mouse_set " Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 35/38] input: remove index_from_keycode (no users) Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 36/38] console: add head to index to qemu consoles Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 37/38] console: add QemuUIInfo Gerd Hoffmann
2014-03-05 11:53 ` [Qemu-devel] [PULL v4 38/38] ui/sdl2 : initial port to SDL 2.0 (v2.0) Gerd Hoffmann
2014-03-07 19:23 ` [Qemu-devel] [PULL v4 00/38] rework input handling, sdl2 support Peter Maydell
2014-03-07 19:45   ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394020420-17576-32-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).