qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/4] sdl2: add support for text consoles
@ 2014-06-02 14:37 Gerd Hoffmann
  2014-06-02 14:37 ` [Qemu-devel] [PULL 1/4] console: add kbd_put_qcode_console Gerd Hoffmann
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2014-06-02 14:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

This patch series adds support for text consoles (i.e. qemu -monitor vc)
to sdl2.  It also makes the Ctrl-Alt-<nr> hotkeys work.  Behavior is a
bit different than sdl1 though:  Each console gets its own window, and
Ctrl-Alt-<nr> hotkeys will show/hide the windows.

please pull,
  Gerd

The following changes since commit 9bb931802e6ab5ab6947e3cb9cea934fc0724274:

  Revert "bsd-user: replace fprintf(stderr, ...) with error_report()" (2014-06-02 13:26:59 +0100)

are available in the git repository at:

  git://git.kraxel.org/qemu tags/pull-sdl-3

for you to fetch changes up to f2335791fd0ceb2f9e3cc99b57bfd9c63d98baf0:

  sdl2: textinput + terminal (2014-06-02 16:28:58 +0200)

----------------------------------------------------------------
sdl2: add support for text consoles

----------------------------------------------------------------
Gerd Hoffmann (4):
      console: add kbd_put_qcode_console
      console: add kbd_put_string_console
      sdl2: make Ctrl-Alt-<nr> hotkeys show and hide windows
      sdl2: textinput + terminal

 include/ui/console.h |  2 ++
 ui/console.c         | 33 +++++++++++++++++++++++++
 ui/sdl2.c            | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 101 insertions(+), 2 deletions(-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 1/4] console: add kbd_put_qcode_console
  2014-06-02 14:37 [Qemu-devel] [PULL 0/4] sdl2: add support for text consoles Gerd Hoffmann
@ 2014-06-02 14:37 ` Gerd Hoffmann
  2014-06-02 14:37 ` [Qemu-devel] [PULL 2/4] console: add kbd_put_string_console Gerd Hoffmann
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2014-06-02 14:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h |  1 +
 ui/console.c         | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/include/ui/console.h b/include/ui/console.h
index b513e20..4ad16c9 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -82,6 +82,7 @@ void do_mouse_set(Monitor *mon, const QDict *qdict);
 #define QEMU_KEY_CTRL_PAGEDOWN   0xe407
 
 void kbd_put_keysym_console(QemuConsole *s, int keysym);
+bool kbd_put_qcode_console(QemuConsole *s, int qcode);
 void kbd_put_keysym(int keysym);
 
 /* consoles */
diff --git a/ui/console.c b/ui/console.c
index 75ec3af..b99312c 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1109,6 +1109,30 @@ void kbd_put_keysym_console(QemuConsole *s, int keysym)
     }
 }
 
+static const int qcode_to_keysym[Q_KEY_CODE_MAX] = {
+    [Q_KEY_CODE_UP]     = QEMU_KEY_UP,
+    [Q_KEY_CODE_DOWN]   = QEMU_KEY_DOWN,
+    [Q_KEY_CODE_RIGHT]  = QEMU_KEY_RIGHT,
+    [Q_KEY_CODE_LEFT]   = QEMU_KEY_LEFT,
+    [Q_KEY_CODE_HOME]   = QEMU_KEY_HOME,
+    [Q_KEY_CODE_END]    = QEMU_KEY_END,
+    [Q_KEY_CODE_PGUP]   = QEMU_KEY_PAGEUP,
+    [Q_KEY_CODE_PGDN]   = QEMU_KEY_PAGEDOWN,
+    [Q_KEY_CODE_DELETE] = QEMU_KEY_DELETE,
+};
+
+bool kbd_put_qcode_console(QemuConsole *s, int qcode)
+{
+    int keysym;
+
+    keysym = qcode_to_keysym[qcode];
+    if (keysym == 0) {
+        return false;
+    }
+    kbd_put_keysym_console(s, keysym);
+    return true;
+}
+
 void kbd_put_keysym(int keysym)
 {
     kbd_put_keysym_console(active_console, keysym);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 2/4] console: add kbd_put_string_console
  2014-06-02 14:37 [Qemu-devel] [PULL 0/4] sdl2: add support for text consoles Gerd Hoffmann
  2014-06-02 14:37 ` [Qemu-devel] [PULL 1/4] console: add kbd_put_qcode_console Gerd Hoffmann
@ 2014-06-02 14:37 ` Gerd Hoffmann
  2014-06-02 14:37 ` [Qemu-devel] [PULL 3/4] sdl2: make Ctrl-Alt-<nr> hotkeys show and hide windows Gerd Hoffmann
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2014-06-02 14:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h | 1 +
 ui/console.c         | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/include/ui/console.h b/include/ui/console.h
index 4ad16c9..edbaa9b 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -83,6 +83,7 @@ void do_mouse_set(Monitor *mon, const QDict *qdict);
 
 void kbd_put_keysym_console(QemuConsole *s, int keysym);
 bool kbd_put_qcode_console(QemuConsole *s, int qcode);
+void kbd_put_string_console(QemuConsole *s, const char *str, int len);
 void kbd_put_keysym(int keysym);
 
 /* consoles */
diff --git a/ui/console.c b/ui/console.c
index b99312c..2ce55a6 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1133,6 +1133,15 @@ bool kbd_put_qcode_console(QemuConsole *s, int qcode)
     return true;
 }
 
+void kbd_put_string_console(QemuConsole *s, const char *str, int len)
+{
+    int i;
+
+    for (i = 0; i < len && str[i]; i++) {
+        kbd_put_keysym_console(s, str[i]);
+    }
+}
+
 void kbd_put_keysym(int keysym)
 {
     kbd_put_keysym_console(active_console, keysym);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 3/4] sdl2: make Ctrl-Alt-<nr> hotkeys show and hide windows
  2014-06-02 14:37 [Qemu-devel] [PULL 0/4] sdl2: add support for text consoles Gerd Hoffmann
  2014-06-02 14:37 ` [Qemu-devel] [PULL 1/4] console: add kbd_put_qcode_console Gerd Hoffmann
  2014-06-02 14:37 ` [Qemu-devel] [PULL 2/4] console: add kbd_put_string_console Gerd Hoffmann
@ 2014-06-02 14:37 ` Gerd Hoffmann
  2014-06-02 14:37 ` [Qemu-devel] [PULL 4/4] sdl2: textinput + terminal Gerd Hoffmann
  2014-06-02 16:06 ` [Qemu-devel] [PULL 0/4] sdl2: add support for text consoles Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2014-06-02 14:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/sdl2.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/ui/sdl2.c b/ui/sdl2.c
index 0e884f9..749fa89 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -49,6 +49,7 @@ static struct sdl2_state {
     int idx;
     int last_vm_running; /* per console for caption reasons */
     int x, y;
+    int hidden;
 } *sdl2_console;
 
 static SDL_Surface *guest_sprite_surface;
@@ -136,6 +137,9 @@ static void do_sdl_resize(struct sdl2_state *scon, int width, int height,
         } else {
             flags |= SDL_WINDOW_RESIZABLE;
         }
+        if (scon->hidden) {
+            flags |= SDL_WINDOW_HIDDEN;
+        }
 
         scon->real_window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED,
                                              SDL_WINDOWPOS_UNDEFINED,
@@ -458,7 +462,7 @@ static void toggle_full_screen(struct sdl2_state *scon)
 
 static void handle_keydown(SDL_Event *ev)
 {
-    int mod_state;
+    int mod_state, win;
     struct sdl2_state *scon = get_scon_from_window(ev->key.windowID);
 
     if (alt_grab) {
@@ -473,6 +477,27 @@ static void handle_keydown(SDL_Event *ev)
 
     if (gui_key_modifier_pressed) {
         switch (ev->key.keysym.scancode) {
+        case SDL_SCANCODE_2:
+        case SDL_SCANCODE_3:
+        case SDL_SCANCODE_4:
+        case SDL_SCANCODE_5:
+        case SDL_SCANCODE_6:
+        case SDL_SCANCODE_7:
+        case SDL_SCANCODE_8:
+        case SDL_SCANCODE_9:
+            win = ev->key.keysym.scancode - SDL_SCANCODE_1;
+            if (win < sdl2_num_outputs) {
+                sdl2_console[win].hidden = !sdl2_console[win].hidden;
+                if (sdl2_console[win].real_window) {
+                    if (sdl2_console[win].hidden) {
+                        SDL_HideWindow(sdl2_console[win].real_window);
+                    } else {
+                        SDL_ShowWindow(sdl2_console[win].real_window);
+                    }
+                }
+                gui_keysym = 1;
+            }
+            break;
         case SDL_SCANCODE_F:
             toggle_full_screen(scon);
             gui_keysym = 1;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 4/4] sdl2: textinput + terminal
  2014-06-02 14:37 [Qemu-devel] [PULL 0/4] sdl2: add support for text consoles Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2014-06-02 14:37 ` [Qemu-devel] [PULL 3/4] sdl2: make Ctrl-Alt-<nr> hotkeys show and hide windows Gerd Hoffmann
@ 2014-06-02 14:37 ` Gerd Hoffmann
  2014-06-02 16:06 ` [Qemu-devel] [PULL 0/4] sdl2: add support for text consoles Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2014-06-02 14:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/sdl2.c | 41 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/ui/sdl2.c b/ui/sdl2.c
index 749fa89..fcac87b 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -214,6 +214,23 @@ static void sdl_process_key(struct sdl2_state *scon,
     int qcode = sdl2_scancode_to_qcode[ev->keysym.scancode];
     QemuConsole *con = scon ? scon->dcl.con : NULL;
 
+    if (!qemu_console_is_graphic(con)) {
+        if (ev->type == SDL_KEYDOWN) {
+            switch (ev->keysym.scancode) {
+            case SDL_SCANCODE_RETURN:
+                kbd_put_keysym_console(con, '\n');
+                break;
+            case SDL_SCANCODE_BACKSPACE:
+                kbd_put_keysym_console(con, QEMU_KEY_BACKSPACE);
+                break;
+            default:
+                kbd_put_qcode_console(con, qcode);
+                break;
+            }
+        }
+        return;
+    }
+
     switch (ev->keysym.scancode) {
 #if 0
     case SDL_SCANCODE_NUMLOCKCLEAR:
@@ -309,6 +326,11 @@ static void sdl_show_cursor(void)
 
 static void sdl_grab_start(struct sdl2_state *scon)
 {
+    QemuConsole *con = scon ? scon->dcl.con : NULL;
+
+    if (!con || !qemu_console_is_graphic(con)) {
+        return;
+    }
     /*
      * If the application is not active, do not try to enter grab state. This
      * prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from blocking all the
@@ -569,6 +591,17 @@ static void handle_keyup(SDL_Event *ev)
     }
 }
 
+static void handle_textinput(SDL_Event *ev)
+{
+    struct sdl2_state *scon = get_scon_from_window(ev->key.windowID);
+    QemuConsole *con = scon ? scon->dcl.con : NULL;
+
+    if (qemu_console_is_graphic(con)) {
+        return;
+    }
+    kbd_put_string_console(con, ev->text.text, strlen(ev->text.text));
+}
+
 static void handle_mousemotion(SDL_Event *ev)
 {
     int max_x, max_y;
@@ -705,6 +738,9 @@ static void sdl_refresh(DisplayChangeListener *dcl)
         case SDL_KEYUP:
             handle_keyup(ev);
             break;
+        case SDL_TEXTINPUT:
+            handle_textinput(ev);
+            break;
         case SDL_QUIT:
             if (!no_quit) {
                 no_shutdown = 0;
@@ -833,7 +869,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
 
     for (i = 0;; i++) {
         QemuConsole *con = qemu_console_lookup_by_index(i);
-        if (!con || !qemu_console_is_graphic(con)) {
+        if (!con) {
             break;
         }
     }
@@ -841,6 +877,9 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     sdl2_console = g_new0(struct sdl2_state, sdl2_num_outputs);
     for (i = 0; i < sdl2_num_outputs; i++) {
         QemuConsole *con = qemu_console_lookup_by_index(i);
+        if (!qemu_console_is_graphic(con)) {
+            sdl2_console[i].hidden = true;
+        }
         sdl2_console[i].dcl.ops = &dcl_ops;
         sdl2_console[i].dcl.con = con;
         register_displaychangelistener(&sdl2_console[i].dcl);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PULL 0/4] sdl2: add support for text consoles
  2014-06-02 14:37 [Qemu-devel] [PULL 0/4] sdl2: add support for text consoles Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2014-06-02 14:37 ` [Qemu-devel] [PULL 4/4] sdl2: textinput + terminal Gerd Hoffmann
@ 2014-06-02 16:06 ` Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2014-06-02 16:06 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 2 June 2014 15:37, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
> This patch series adds support for text consoles (i.e. qemu -monitor vc)
> to sdl2.  It also makes the Ctrl-Alt-<nr> hotkeys work.  Behavior is a
> bit different than sdl1 though:  Each console gets its own window, and
> Ctrl-Alt-<nr> hotkeys will show/hide the windows.
>
> please pull,
>   Gerd
>
> The following changes since commit 9bb931802e6ab5ab6947e3cb9cea934fc0724274:
>
>   Revert "bsd-user: replace fprintf(stderr, ...) with error_report()" (2014-06-02 13:26:59 +0100)
>
> are available in the git repository at:
>
>   git://git.kraxel.org/qemu tags/pull-sdl-3
>
> for you to fetch changes up to f2335791fd0ceb2f9e3cc99b57bfd9c63d98baf0:
>
>   sdl2: textinput + terminal (2014-06-02 16:28:58 +0200)
>
> ----------------------------------------------------------------
> sdl2: add support for text consoles
>

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-02 16:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-02 14:37 [Qemu-devel] [PULL 0/4] sdl2: add support for text consoles Gerd Hoffmann
2014-06-02 14:37 ` [Qemu-devel] [PULL 1/4] console: add kbd_put_qcode_console Gerd Hoffmann
2014-06-02 14:37 ` [Qemu-devel] [PULL 2/4] console: add kbd_put_string_console Gerd Hoffmann
2014-06-02 14:37 ` [Qemu-devel] [PULL 3/4] sdl2: make Ctrl-Alt-<nr> hotkeys show and hide windows Gerd Hoffmann
2014-06-02 14:37 ` [Qemu-devel] [PULL 4/4] sdl2: textinput + terminal Gerd Hoffmann
2014-06-02 16:06 ` [Qemu-devel] [PULL 0/4] sdl2: add support for text consoles Peter Maydell

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).