All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/2] ui: gtk vc fix, adaptive sdl refresh.
@ 2016-02-02 13:10 Gerd Hoffmann
  2016-02-02 13:10 ` [Qemu-devel] [PULL 1/2] gtk: use qemu_chr_alloc() to allocate CharDriverState Gerd Hoffmann
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2016-02-02 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Two ui patches, for gtk and sdl.

please pull,
  Gerd

The following changes since commit 10ae9d76388e3f4a31f6a1475b5e2d1f28404a10:

  Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.6-20160201' into staging (2016-02-02 09:13:10 +0000)

are available in the git repository at:


  git://git.kraxel.org/qemu tags/pull-ui-20160202-1

for you to fetch changes up to 56bdd4b69aa10bec274b1e812685bcf44dcb0c72:

  sdl: shorten the GUI refresh interval when mouse or keyboard is active (2016-02-02 14:05:07 +0100)

----------------------------------------------------------------
ui: gtk vc fix, adaptive sdl refresh.

----------------------------------------------------------------
Daniel P. Berrange (1):
      gtk: use qemu_chr_alloc() to allocate CharDriverState

Jindřich Makovička (1):
      sdl: shorten the GUI refresh interval when mouse or keyboard is active

 include/ui/sdl2.h |  1 +
 ui/gtk.c          |  9 +++++++--
 ui/sdl.c          | 22 ++++++++++++++++++++++
 ui/sdl2.c         | 23 +++++++++++++++++++++++
 4 files changed, 53 insertions(+), 2 deletions(-)

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

* [Qemu-devel] [PULL 1/2] gtk: use qemu_chr_alloc() to allocate CharDriverState
  2016-02-02 13:10 [Qemu-devel] [PULL 0/2] ui: gtk vc fix, adaptive sdl refresh Gerd Hoffmann
@ 2016-02-02 13:10 ` Gerd Hoffmann
  2016-02-02 13:10 ` [Qemu-devel] [PULL 2/2] sdl: shorten the GUI refresh interval when mouse or keyboard is active Gerd Hoffmann
  2016-02-02 15:54 ` [Qemu-devel] [PULL 0/2] ui: gtk vc fix, adaptive sdl refresh Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2016-02-02 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

From: "Daniel P. Berrange" <berrange@redhat.com>

The gd_vc_handler() callback is using g_malloc0() to
allocate the CharDriverState struct. As a result the
logfd field is getting initialized to 0, instead of
-1 when no logfile is requested.

The result is that when running

 $ qemu-system-i386 -nodefaults -chardev vc,id=mon0 -mon chardev=mon0

qemu duplicates all monitor output to stdout as well
as the GTK window.

Not using qemu_chr_alloc() was already a bug, but harmless
until this commit

  commit d0d7708ba29cbcc343364a46bff981e0ff88366f
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Mon Jan 11 12:44:41 2016 +0000

    qemu-char: add logfile facility to all chardev backends

which exposed the problem as a behaviour regression

Reported-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Tested-by: Hervé Poussineau <hpoussin@reactos.org>
Message-id: 1453377386-10190-1-git-send-email-berrange@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index ce7018e..c8dbd5c 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1598,11 +1598,16 @@ static void gd_vc_chr_set_echo(CharDriverState *chr, bool echo)
 static int nb_vcs;
 static CharDriverState *vcs[MAX_VCS];
 
-static CharDriverState *gd_vc_handler(ChardevVC *unused, Error **errp)
+static CharDriverState *gd_vc_handler(ChardevVC *vc, Error **errp)
 {
+    ChardevCommon *common = qapi_ChardevVC_base(vc);
     CharDriverState *chr;
 
-    chr = g_malloc0(sizeof(*chr));
+    chr = qemu_chr_alloc(common, errp);
+    if (!chr) {
+        return NULL;
+    }
+
     chr->chr_write = gd_vc_chr_write;
     chr->chr_set_echo = gd_vc_chr_set_echo;
 
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 2/2] sdl: shorten the GUI refresh interval when mouse or keyboard is active
  2016-02-02 13:10 [Qemu-devel] [PULL 0/2] ui: gtk vc fix, adaptive sdl refresh Gerd Hoffmann
  2016-02-02 13:10 ` [Qemu-devel] [PULL 1/2] gtk: use qemu_chr_alloc() to allocate CharDriverState Gerd Hoffmann
@ 2016-02-02 13:10 ` Gerd Hoffmann
  2016-02-02 15:54 ` [Qemu-devel] [PULL 0/2] ui: gtk vc fix, adaptive sdl refresh Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2016-02-02 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jindřich Makovička, Gerd Hoffmann

From: Jindřich Makovička <makovick@gmail.com>

Signed-off-by: Jindřich Makovička <makovick@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/sdl2.h |  1 +
 ui/sdl.c          | 22 ++++++++++++++++++++++
 ui/sdl2.c         | 23 +++++++++++++++++++++++
 3 files changed, 46 insertions(+)

diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h
index b7ac38f..3f0b57b 100644
--- a/include/ui/sdl2.h
+++ b/include/ui/sdl2.h
@@ -19,6 +19,7 @@ struct sdl2_console {
     int hidden;
     int opengl;
     int updates;
+    int idle_counter;
     SDL_GLContext winctx;
 #ifdef CONFIG_OPENGL
     ConsoleGLState *gls;
diff --git a/ui/sdl.c b/ui/sdl.c
index c837436..f215fe1 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -60,6 +60,11 @@ static SDL_Cursor *guest_sprite = NULL;
 static SDL_PixelFormat host_format;
 static int scaling_active = 0;
 static Notifier mouse_mode_notifier;
+static int idle_counter;
+
+#define SDL_REFRESH_INTERVAL_BUSY 10
+#define SDL_MAX_IDLE_COUNT (2 * GUI_REFRESH_INTERVAL_DEFAULT \
+                            / SDL_REFRESH_INTERVAL_BUSY + 1)
 
 #if 0
 #define DEBUG_SDL
@@ -802,6 +807,7 @@ static void handle_activation(SDL_Event *ev)
 static void sdl_refresh(DisplayChangeListener *dcl)
 {
     SDL_Event ev1, *ev = &ev1;
+    int idle = 1;
 
     if (last_vm_running != runstate_is_running()) {
         last_vm_running = runstate_is_running();
@@ -817,9 +823,11 @@ static void sdl_refresh(DisplayChangeListener *dcl)
             sdl_update(dcl, 0, 0, real_screen->w, real_screen->h);
             break;
         case SDL_KEYDOWN:
+            idle = 0;
             handle_keydown(ev);
             break;
         case SDL_KEYUP:
+            idle = 0;
             handle_keyup(ev);
             break;
         case SDL_QUIT:
@@ -829,10 +837,12 @@ static void sdl_refresh(DisplayChangeListener *dcl)
             }
             break;
         case SDL_MOUSEMOTION:
+            idle = 0;
             handle_mousemotion(ev);
             break;
         case SDL_MOUSEBUTTONDOWN:
         case SDL_MOUSEBUTTONUP:
+            idle = 0;
             handle_mousebutton(ev);
             break;
         case SDL_ACTIVEEVENT:
@@ -847,6 +857,18 @@ static void sdl_refresh(DisplayChangeListener *dcl)
             break;
         }
     }
+
+    if (idle) {
+        if (idle_counter < SDL_MAX_IDLE_COUNT) {
+            idle_counter++;
+            if (idle_counter >= SDL_MAX_IDLE_COUNT) {
+                dcl->update_interval = GUI_REFRESH_INTERVAL_DEFAULT;
+            }
+        }
+    } else {
+        idle_counter = 0;
+        dcl->update_interval = SDL_REFRESH_INTERVAL_BUSY;
+    }
 }
 
 static void sdl_mouse_warp(DisplayChangeListener *dcl,
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 46270f4..c0a76d7 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -49,6 +49,10 @@ static int guest_x, guest_y;
 static SDL_Cursor *guest_sprite;
 static Notifier mouse_mode_notifier;
 
+#define SDL2_REFRESH_INTERVAL_BUSY 10
+#define SDL2_MAX_IDLE_COUNT (2 * GUI_REFRESH_INTERVAL_DEFAULT \
+                             / SDL2_REFRESH_INTERVAL_BUSY + 1)
+
 static void sdl_update_caption(struct sdl2_console *scon);
 
 static struct sdl2_console *get_scon_from_window(uint32_t window_id)
@@ -578,6 +582,7 @@ static void handle_windowevent(SDL_Event *ev)
 void sdl2_poll_events(struct sdl2_console *scon)
 {
     SDL_Event ev1, *ev = &ev1;
+    int idle = 1;
 
     if (scon->last_vm_running != runstate_is_running()) {
         scon->last_vm_running = runstate_is_running();
@@ -587,12 +592,15 @@ void sdl2_poll_events(struct sdl2_console *scon)
     while (SDL_PollEvent(ev)) {
         switch (ev->type) {
         case SDL_KEYDOWN:
+            idle = 0;
             handle_keydown(ev);
             break;
         case SDL_KEYUP:
+            idle = 0;
             handle_keyup(ev);
             break;
         case SDL_TEXTINPUT:
+            idle = 0;
             handle_textinput(ev);
             break;
         case SDL_QUIT:
@@ -602,13 +610,16 @@ void sdl2_poll_events(struct sdl2_console *scon)
             }
             break;
         case SDL_MOUSEMOTION:
+            idle = 0;
             handle_mousemotion(ev);
             break;
         case SDL_MOUSEBUTTONDOWN:
         case SDL_MOUSEBUTTONUP:
+            idle = 0;
             handle_mousebutton(ev);
             break;
         case SDL_MOUSEWHEEL:
+            idle = 0;
             handle_mousewheel(ev);
             break;
         case SDL_WINDOWEVENT:
@@ -618,6 +629,18 @@ void sdl2_poll_events(struct sdl2_console *scon)
             break;
         }
     }
+
+    if (idle) {
+        if (scon->idle_counter < SDL2_MAX_IDLE_COUNT) {
+            scon->idle_counter++;
+            if (scon->idle_counter >= SDL2_MAX_IDLE_COUNT) {
+                scon->dcl.update_interval = GUI_REFRESH_INTERVAL_DEFAULT;
+            }
+        }
+    } else {
+        scon->idle_counter = 0;
+        scon->dcl.update_interval = SDL2_REFRESH_INTERVAL_BUSY;
+    }
 }
 
 static void sdl_mouse_warp(DisplayChangeListener *dcl,
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PULL 0/2] ui: gtk vc fix, adaptive sdl refresh.
  2016-02-02 13:10 [Qemu-devel] [PULL 0/2] ui: gtk vc fix, adaptive sdl refresh Gerd Hoffmann
  2016-02-02 13:10 ` [Qemu-devel] [PULL 1/2] gtk: use qemu_chr_alloc() to allocate CharDriverState Gerd Hoffmann
  2016-02-02 13:10 ` [Qemu-devel] [PULL 2/2] sdl: shorten the GUI refresh interval when mouse or keyboard is active Gerd Hoffmann
@ 2016-02-02 15:54 ` Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2016-02-02 15:54 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 2 February 2016 at 13:10, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
> Two ui patches, for gtk and sdl.
>
> please pull,
>   Gerd
>
> The following changes since commit 10ae9d76388e3f4a31f6a1475b5e2d1f28404a10:
>
>   Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.6-20160201' into staging (2016-02-02 09:13:10 +0000)
>
> are available in the git repository at:
>
>
>   git://git.kraxel.org/qemu tags/pull-ui-20160202-1
>
> for you to fetch changes up to 56bdd4b69aa10bec274b1e812685bcf44dcb0c72:
>
>   sdl: shorten the GUI refresh interval when mouse or keyboard is active (2016-02-02 14:05:07 +0100)
>
> ----------------------------------------------------------------
> ui: gtk vc fix, adaptive sdl refresh.
>
> ----------------------------------------------------------------

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2016-02-02 15:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-02 13:10 [Qemu-devel] [PULL 0/2] ui: gtk vc fix, adaptive sdl refresh Gerd Hoffmann
2016-02-02 13:10 ` [Qemu-devel] [PULL 1/2] gtk: use qemu_chr_alloc() to allocate CharDriverState Gerd Hoffmann
2016-02-02 13:10 ` [Qemu-devel] [PULL 2/2] sdl: shorten the GUI refresh interval when mouse or keyboard is active Gerd Hoffmann
2016-02-02 15:54 ` [Qemu-devel] [PULL 0/2] ui: gtk vc fix, adaptive sdl refresh Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.