ui patch queue
Hi,
Here comes the ui patch queue. Nothing outstanding here. Bugfixes and small improvements all user interfaces.
please pull,
Gerd
The following changes since commit a0def594286d9110a6035e02eef558cf3cf5d847:
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2017-01-30 10:23:20 +0000)
are available in the git repository at:
git://git.kraxel.org/qemu tags/pull-ui-20170131-1
for you to fetch changes up to 9f533e705dd140ea725747e8fd9bbab7f1e84a8b:
gtk: Hardcode LC_CTYPE as C.utf-8 (2017-01-31 14:02:28 +0100)
----------------------------------------------------------------
ui: bugfixes and small improvements all over the place.
----------------------------------------------------------------
Fabian Lesniak (3):
qapi: add support for mice with extra/side buttons
ps2: add support for mice with extra/side buttons
ui: add support for mice with extra/side buttons
Gerd Hoffmann (1):
vnc: fix overflow in vnc_update_stats
Kevin Wolf (1):
gtk: Hardcode LC_CTYPE as C.utf-8
Marc-André Lureau (1):
spice: wakeup QXL worker to pick up mouse changes
OGAWA Hirofumi (1):
ui/gtk: Fix mouse wheel on 3.4.0 or later
Pierre Ossman (1):
vnc: track LED state separately
Rami Rosen (1):
ui: fix format specfier in vnc to avoid break in build.
Ziyue Yang (1):
ui/gtk.c: add ctrl-alt-= support for zoom in acceleration
hw/input/ps2.c | 8 +++--- include/hw/input/ps2.h | 6 +++++ qapi-schema.json | 7 +++++- ui/gtk.c | 32 +++++++++++++++++++++++- ui/input-linux.c | 6 +++++ ui/spice-display.c | 2 ++ ui/vnc.c | 67 ++++++++++++++++---------------------------------- ui/vnc.h | 3 ++- 8 files changed, 79 insertions(+), 52 deletions(-)
[Qemu-devel] [PULL 09/10] vnc: fix overflow in vnc_update_stats
Commit "bea60dd ui/vnc: fix potential memory corruption issues" is incomplete. vnc_update_stats must calculate width and height the same way vnc_refresh_server_surface does it, to make sure we don't use width and height values larger than the qemu vnc server can handle.
Commit "e22492d ui/vnc: disable adaptive update calculations if not needed" masks the issue in the default configuration. It triggers only in case the "lossy" option is set to "on" (default is "off").
Message-id: [email protected]
--- ui/vnc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
ui/vnc.c +4 -2
@@ -2724,8 +2724,10 @@ static int vnc_refresh_lossy_rect(VncDisplay *vd, int x, int y)static int vnc_update_stats (VncDisplay *vd,struct timeval * tv) { -int width =pixman_image_get_width (vd->guest.fb); -int height =pixman_image_get_height (vd->guest.fb); +int width =MIN (pixman_image_get_width (vd->guest.fb), +pixman_image_get_width (vd->server)); +int height =MIN (pixman_image_get_height (vd->guest.fb), +pixman_image_get_height (vd->server));int x, y;struct timeval res;int has_dirty =0 ;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 01/10] qapi: add support for mice with extra/side buttons
In reply to Gerd HoffmannFrom: Fabian Lesniak <[email protected]>
Adds "side" and "extra" values to enum InputButton. The naming was borrowed from evdev since it is more descriptive than "button4" and "button5".
Message-id: [email protected]
--- qapi-schema.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
qapi-schema.json +6 -1
@@ -5390,10 +5390,15 @@ # # Button of a pointer input device (mouse, tablet). # +# @side: front side button of a 5-button mouse (since 2.9) +# +# @extra: rear side button of a 5-button mouse (since 2.9) +# # Since: 2.0 ## { 'enum' : 'InputButton', - 'data' : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down' ] } + 'data' : [ 'left', 'middle', 'right', 'wheel-up', 'wheel-down', 'side', + 'extra' ] } ## # @InputAxis:
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 02/10] ps2: add support for mice with extra/side buttons
In reply to Gerd HoffmannFrom: Fabian Lesniak <[email protected]>
This enables the ps2 controller to process mouse events for buttons 4 and 5. Additionally, distinct definitions for the ps2 mouse button state are introduced. The legacy definitions from console.h are not used anymore.
Message-id: [email protected]
--- hw/input/ps2.c | 8 +++++--- include/hw/input/ps2.h | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-)
hw/input/ps2.c +5 -3
@@ -881,9 +881,11 @@ static void ps2_mouse_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) {static const int bmap[INPUT_BUTTON__MAX ] = { - [INPUT_BUTTON_LEFT ] =MOUSE_EVENT_LBUTTON , - [INPUT_BUTTON_MIDDLE ] =MOUSE_EVENT_MBUTTON , - [INPUT_BUTTON_RIGHT ] =MOUSE_EVENT_RBUTTON , + [INPUT_BUTTON_LEFT ] =PS2_MOUSE_BUTTON_LEFT , + [INPUT_BUTTON_MIDDLE ] =PS2_MOUSE_BUTTON_MIDDLE , + [INPUT_BUTTON_RIGHT ] =PS2_MOUSE_BUTTON_RIGHT , + [INPUT_BUTTON_SIDE ] =PS2_MOUSE_BUTTON_SIDE , + [INPUT_BUTTON_EXTRA ] =PS2_MOUSE_BUTTON_EXTRA , };PS2MouseState *s = (PS2MouseState *)dev;InputMoveEvent *move;
include/hw/input/ps2.h +6 -0
@@ -25,6 +25,12 @@#ifndef HW_PS2_H #define HW_PS2_H +#define PS2_MOUSE_BUTTON_LEFT 0x01 +#define PS2_MOUSE_BUTTON_MIDDLE 0x02 +#define PS2_MOUSE_BUTTON_RIGHT 0x04 +#define PS2_MOUSE_BUTTON_SIDE 0x08 +#define PS2_MOUSE_BUTTON_EXTRA 0x10 +/* ps2.c */ void *ps2_kbd_init (void (*update_irq)(void *,int ),void *update_arg);void *ps2_mouse_init (void (*update_irq)(void *,int ),void *update_arg);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 03/10] ui: add support for mice with extra/side buttons
In reply to Gerd HoffmannFrom: Fabian Lesniak <[email protected]>
Adds input event generation for BTN_SIDE and BTN_EXTRA events to gtk and input-linux methods.
Message-id: [email protected]
--- ui/gtk.c | 4 ++++ ui/input-linux.c | 6 ++++++ 2 files changed, 10 insertions(+)
ui/gtk.c +4 -0
@@ -1007,6 +1007,10 @@ static gboolean gd_button_event(GtkWidget *widget, GdkEventButton *button, btn =INPUT_BUTTON_MIDDLE ; }else if (button->button ==3 ) { btn =INPUT_BUTTON_RIGHT ; + }else if (button->button ==8 ) { + btn =INPUT_BUTTON_SIDE ; + }else if (button->button ==9 ) { + btn =INPUT_BUTTON_EXTRA ; }else {return TRUE; }
ui/input-linux.c +6 -0
@@ -291,6 +291,12 @@ static void input_linux_handle_mouse(InputLinux *il, struct input_event *event)qemu_input_queue_btn (NULL ,INPUT_BUTTON_WHEEL_DOWN , event->value);break ; +case BTN_SIDE : +qemu_input_queue_btn (NULL ,INPUT_BUTTON_SIDE , event->value); +break ; +case BTN_EXTRA : +qemu_input_queue_btn (NULL ,INPUT_BUTTON_EXTRA , event->value); +break ; };break ;case EV_REL :
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 05/10] ui/gtk: Fix mouse wheel on 3.4.0 or later
In reply to Gerd HoffmannFrom: OGAWA Hirofumi <[email protected]>
On 3.4.0 or later, send GDK_SCROLL_SMOOTH event, instead of GDK_SCROLL_UP/DOWN.
This fixes it by converting any smooth scroll to up/down. (I.e. without smooth support)
--- ui/gtk.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
ui/gtk.c +13 -0
@@ -1031,6 +1031,19 @@ static gboolean gd_scroll_event(GtkWidget *widget, GdkEventScroll *scroll, btn =INPUT_BUTTON_WHEEL_UP ; }else if (scroll->direction ==GDK_SCROLL_DOWN ) { btn =INPUT_BUTTON_WHEEL_DOWN ; +#if GTK_CHECK_VERSION (3 ,4 ,0 ) + } else if (scroll->direction == GDK_SCROLL_SMOOTH) { +gdouble delta_x, delta_y; +if (!gdk_event_get_scroll_deltas ((GdkEvent *)scroll, + &delta_x, &delta_y)) { +return TRUE; + } +if (delta_y >0 ) { + btn =INPUT_BUTTON_WHEEL_DOWN ; + }else { + btn =INPUT_BUTTON_WHEEL_UP ; + } +#endif }else {return TRUE; }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 06/10] ui: fix format specfier in vnc to avoid break in build.
In reply to Gerd HoffmannFrom: Rami Rosen <[email protected]>
When building qemu after setting _VNC_DEBUG to 1 (see ui/vnc.h), we get the following error and the build breaks:
...ui/vnc.c: In function ‘vnc_client_io_error’:ui/vnc.c:1262:13: error: format ‘%d’ expects argument of type ‘int’, but
VNC_DEBUG("Closing down client sock: ret %d (%s)\n", ^
cc1: all warnings being treated as errors
make: *** [ui/vnc.o] Error 1
...
This patch solves this issue by fixing the print format specifier in vnc_client_io_error() to be %zd, which corresponds to the type of the "ret" variable.
Message-id: [email protected]
--- ui/vnc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ui/vnc.c +1 -1
@@ -1257,7 +1257,7 @@ ssize_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)if (ret ==0 ) {VNC_DEBUG ("Closing down client sock: EOF\n" ); }else if (ret !=QIO_CHANNEL_ERR_BLOCK ) { -VNC_DEBUG ("Closing down client sock: ret %d (%s)\n" , +VNC_DEBUG ("Closing down client sock: ret %zd (%s)\n" , ret, errp ?error_get_pretty (*errp) :"Unknown" ); }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 07/10] ui/gtk.c: add ctrl-alt-= support for zoom in acceleration
In reply to Gerd HoffmannFrom: Ziyue Yang <[email protected]>
Solving wishlist item at
https://bugs.launchpad.net/qemu/+bug/1656710
by accepting Ctrl-Alt-= as an additional zoom-in acceleration.
Using gtk_accel_group_connect to support multiple accelerations triggering a single menu item since that gtk_accel_map_add_entry seems to support only one acceleration. A wrapper function gd_accel_zoom_in is added to support gtk_accel_group_connect's callback activities.
Message-id: [email protected]
--- ui/gtk.c | 9 +++++++++ 1 file changed, 9 insertions(+)
ui/gtk.c +9 -0
@@ -105,6 +105,7 @@#define GDK_KEY_g GDK_g#define GDK_KEY_q GDK_q#define GDK_KEY_plus GDK_plus +#define GDK_KEY_equal GDK_equal#define GDK_KEY_minus GDK_minus#define GDK_KEY_Pause GDK_Pause#define GDK_KEY_Delete GDK_Delete
@@ -1342,6 +1343,12 @@ static void gd_menu_zoom_in(GtkMenuItem *item, void *opaque)gd_update_windowsize (vc); } +static void gd_accel_zoom_in (void *opaque) +{ +GtkDisplayState *s = opaque; +gtk_menu_item_activate (GTK_MENU_ITEM (s->zoom_in_item)); +} +static void gd_menu_zoom_out (GtkMenuItem *item,void *opaque) {GtkDisplayState *s = opaque;
@@ -2109,6 +2116,8 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s) "<QEMU>/View/Zoom In");gtk_accel_map_add_entry ("<QEMU>/View/Zoom In" , GDK_KEY_plus,HOTKEY_MODIFIERS ); +gtk_accel_group_connect (s->accel_group, GDK_KEY_equal,HOTKEY_MODIFIERS ,0 , +g_cclosure_new_swap (G_CALLBACK (gd_accel_zoom_in), s,NULL ));gtk_menu_shell_append (GTK_MENU_SHELL (view_menu), s->zoom_in_item); s->zoom_out_item =gtk_menu_item_new_with_mnemonic (_ ("Zoom _Out" ));
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 08/10] spice: wakeup QXL worker to pick up mouse changes
In reply to Gerd HoffmannFrom: Marc-André Lureau <[email protected]>
Without it, server-mode mouse is "slow" to update position: QXL will wait until new display commands come. This is very visible with virtio-gpu.
Message-id: [email protected]
--- ui/spice-display.c | 2 ++ 1 file changed, 2 insertions(+)
ui/spice-display.c +2 -0
@@ -769,6 +769,7 @@ static void display_mouse_set(DisplayChangeListener *dcl,g_free (ssd->ptr_move); ssd->ptr_move =qemu_spice_create_cursor_update (ssd,NULL , on);qemu_mutex_unlock (&ssd->lock); +qemu_spice_wakeup (ssd); } static void display_mouse_define(DisplayChangeListener *dcl,
@@ -787,6 +788,7 @@ static void display_mouse_define(DisplayChangeListener *dcl,g_free (ssd->ptr_define); ssd->ptr_define =qemu_spice_create_cursor_update (ssd, c,0 );qemu_mutex_unlock (&ssd->lock); +qemu_spice_wakeup (ssd); }static const DisplayChangeListenerOps display_listener_ops = {
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 10/10] gtk: Hardcode LC_CTYPE as C.utf-8
In reply to Gerd HoffmannFrom: Kevin Wolf <[email protected]>
Commit 2cb5d2a4 removed setlocale() for everything except LC_MESSAGES in order to avoid unwanted side effects such as using the wrong decimal separator in generated JSON objects. However, the problem that unsetting LC_CTYPE caused is that non-ASCII characters are considered non-printable now and therefore the GTK menus display question marks for accented letters, Chinese characters etc.
A first attempt to fix this [1] was rejected because even just setting LC_CTYPE to the user's locale (and thereby modifying the semantics of the ctype.h functions) could have unwanted effects that we're not aware of yet.
Recently, however, glibc introduced a new locale "C.utf-8" that just uses UTF-8 as its charset, but otherwise leaves the semantics alone. Just setting the right character set is enough for our use case, so we can just hardcode this one without having to be afraid of nasty side effects.
Older systems that don't have the new locale will continue displaying question marks, but this should fix the problem for most users.
[1] https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03591.html
('Re: gtk: use setlocale() for LC_MESSAGES only')
Message-id: [email protected]
--- ui/gtk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
ui/gtk.c +5 -1
@@ -2258,8 +2258,12 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover) s->free_scale = FALSE; -/* LC_MESSAGES only. See early_gtk_display_init() for details */ +/* Mostly LC_MESSAGES only. See early_gtk_display_init() for details. For +* LC_CTYPE, we need to make sure that non-ASCII characters are considered +* printable, but without changing any of the character classes to make +* sure that we don't accidentally break implicit assumptions. */ setlocale (LC_MESSAGES ,"" ); +setlocale (LC_CTYPE ,"C.utf-8" );bindtextdomain ("qemu" ,CONFIG_QEMU_LOCALEDIR );textdomain ("qemu" );
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 04/10] vnc: track LED state separately
In reply to Gerd HoffmannFrom: Pierre Ossman <[email protected]>
Piggy-backing on the modifier state array made it difficult to send out updates at the proper times.
Message-id: 5aa28297d665cee24ddab26bbf4633e4252f97b6.1483978442.git.ossman@cendio.se
--- ui/vnc.c | 59 ++++++++++++++++------------------------------------------- ui/vnc.h | 3 ++- 2 files changed, 18 insertions(+), 44 deletions(-)
ui/vnc.c +16 -43
@@ -1231,8 +1231,6 @@ void vnc_disconnect_finish(VncState *vs)vnc_update_server_surface (vs->vd); } -if (vs->vd->lock_key_sync) -qemu_remove_led_event_handler (vs->led);vnc_unlock_output (vs);qemu_mutex_destroy (&vs->output_mutex);
@@ -1665,69 +1663,39 @@ static void press_key(VncState *vs, int keysym)qemu_input_event_send_key_delay (vs->vd->key_delay_ms); } -static int current_led_state (VncState *vs) -{ -int ledstate =0 ; - -if (vs->modifiers_state[0x46 ]) { - ledstate |=QEMU_SCROLL_LOCK_LED ; - } -if (vs->modifiers_state[0x45 ]) { - ledstate |=QEMU_NUM_LOCK_LED ; - } -if (vs->modifiers_state[0x3a ]) { - ledstate |=QEMU_CAPS_LOCK_LED ; - } - -return ledstate; -} -static void vnc_led_state_change (VncState *vs) { -int ledstate =0 ; -if (!vnc_has_feature (vs,VNC_FEATURE_LED_STATE )) {return ; } - ledstate =current_led_state (vs);vnc_lock_output (vs);vnc_write_u8 (vs,VNC_MSG_SERVER_FRAMEBUFFER_UPDATE );vnc_write_u8 (vs,0 );vnc_write_u16 (vs,1 );vnc_framebuffer_update (vs,0 ,0 ,1 ,1 ,VNC_ENCODING_LED_STATE ); -vnc_write_u8 (vs, ledstate); +vnc_write_u8 (vs, vs->vd->ledstate);vnc_unlock_output (vs);vnc_flush (vs); }static void kbd_leds (void *opaque,int ledstate) { -VncState *vs = opaque; -int caps, num, scr; -bool has_changed = (ledstate !=current_led_state (vs)); +VncDisplay *vd = opaque; +VncState *client;trace_vnc_key_guest_leds ((ledstate &QEMU_CAPS_LOCK_LED ), (ledstate &QEMU_NUM_LOCK_LED ), (ledstate &QEMU_SCROLL_LOCK_LED )); - caps = ledstate &QEMU_CAPS_LOCK_LED ?1 :0 ; - num = ledstate &QEMU_NUM_LOCK_LED ?1 :0 ; - scr = ledstate &QEMU_SCROLL_LOCK_LED ?1 :0 ; - -if (vs->modifiers_state[0x3a ] != caps) { - vs->modifiers_state[0x3a ] = caps; - } -if (vs->modifiers_state[0x45 ] != num) { - vs->modifiers_state[0x45 ] = num; - } -if (vs->modifiers_state[0x46 ] != scr) { - vs->modifiers_state[0x46 ] = scr; +if (ledstate == vd->ledstate) { +return ; } -/* Sending the current led state message to the client */ -if (has_changed) { -vnc_led_state_change (vs); + vd->ledstate = ledstate; + + QTAILQ_FOREACH(client, &vd->clients, next) { +vnc_led_state_change (client); } }
@@ -3087,8 +3055,6 @@ void vnc_start_protocol(VncState *vs)vnc_write (vs,"RFB 003.008\n" ,12 );vnc_flush (vs);vnc_read_when (vs, protocol_version,12 ); -if (vs->vd->lock_key_sync) - vs->led =qemu_add_led_event_handler (kbd_leds, vs); vs->mouse_mode_notifier.notify = check_pointer_type_change;qemu_add_mouse_mode_change_notifier (&vs->mouse_mode_notifier);
@@ -3195,6 +3161,9 @@ static void vnc_display_close(VncDisplay *vd) }g_free (vd->tlsaclname); vd->tlsaclname =NULL ; +if (vd->lock_key_sync) { +qemu_remove_led_event_handler (vd->led); + } }int vnc_display_password (const char *id,const char *password)
@@ -3762,6 +3731,10 @@ void vnc_display_open(const char *id, Error **errp) }#endif vd->lock_key_sync = lock_key_sync; +if (lock_key_sync) { + vd->led =qemu_add_led_event_handler (kbd_leds, vd); + } + vd->ledstate =0 ; vd->key_delay_ms = key_delay_ms; device_id =qemu_opt_get (opts,"display" );
ui/vnc.h +2 -1
@@ -154,6 +154,8 @@ struct VncDisplayDisplayChangeListener dcl;kbd_layout_t *kbd_layout;int lock_key_sync; +QEMUPutLEDEntry *led; +int ledstate;int key_delay_ms;QemuMutex mutex;
@@ -304,7 +306,6 @@ struct VncStatesize_t read_handler_expect;/* input */ uint8_t modifiers_state[256 ]; -QEMUPutLEDEntry *led;bool abort;QemuMutex output_mutex;
Signature · 1 line
1.8.3.1
Quoted 7 lines · Gerd Hoffmann
Hi,
Here comes the ui patch queue. Nothing outstanding here. Bugfixes and small improvements all user interfaces.
please pull,
Gerd
You probably want a v2;
Quoted 4 lines
Kevin Wolf (1):
gtk: HardcodeLC_CTYPEas C.utf-8
Reviewers pointed out that this should be C.UTF-8.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org