baum driver update v2
v2 cover baum driver update v2
This is a series of updates for the baum driver, to improve its integration of input/output and fix focus tracking with sdl2 and gtk backends.
The difference with the previously-posted series is that it should fix the win32 build. Loads of thanks for having set up the build bot :)
Samuel Thibault (3):
Add dots keypresses support to the baum braille device Defer BrlAPI tty acquisition to when guest starts using device Move getting XWindow ID from baum driver to graphical backend
backends/baum.c | 302 +++++++++++++++++++++++++++------------------------ include/ui/console.h | 3 + ui/console.c | 18 +++ ui/gtk.c | 27 ++++- ui/sdl.c | 25 +++++ ui/sdl2.c | 7 ++ 6 files changed, 241 insertions(+), 141 deletions(-)
Signature · 1 line
2.9.3
PATCH v2 1/3 Add dots keypresses support to the baum braille device
--- backends/baum.c | 234 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 130 insertions(+), 104 deletions(-)
backends/baum.c +130 -104
@@ -1,7 +1,7 @@/* * QEMU Baum Braille Device * -* Copyright (c) 2008, 2016 Samuel Thibault +* Copyright (c) 2008, 2010-2011, 2016 Samuel Thibault * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal
@@ -102,8 +102,11 @@ typedef struct { } BaumDriverState;/* Let's assume NABCC by default */ -static const uint8_t nabcc_translation[256 ] = { - [0 ] =' ' , +enum way { +DOTS2ASCII , +ASCII2DOTS +}; +static const uint8_t nabcc_translation[2 ][256 ] = { #ifndef BRLAPI_DOTS #define BRLAPI_DOTS(d1,d2,d3,d4,d5,d6,d7,d8) \ ((d1?BRLAPI_DOT1:0)|\
@@ -115,105 +118,109 @@ static const uint8_t nabcc_translation[256] = { (d7?BRLAPI_DOT7:0)|\ (d8?BRLAPI_DOT8:0))#endif - [BRLAPI_DOTS(1,0,0,0,0,0,0,0)] = 'a', - [BRLAPI_DOTS(1,1,0,0,0,0,0,0)] = 'b', - [BRLAPI_DOTS(1,0,0,1,0,0,0,0)] = 'c', - [BRLAPI_DOTS(1,0,0,1,1,0,0,0)] = 'd', - [BRLAPI_DOTS(1,0,0,0,1,0,0,0)] = 'e', - [BRLAPI_DOTS(1,1,0,1,0,0,0,0)] = 'f', - [BRLAPI_DOTS(1,1,0,1,1,0,0,0)] = 'g', - [BRLAPI_DOTS(1,1,0,0,1,0,0,0)] = 'h', - [BRLAPI_DOTS(0,1,0,1,0,0,0,0)] = 'i', - [BRLAPI_DOTS(0,1,0,1,1,0,0,0)] = 'j', - [BRLAPI_DOTS(1,0,1,0,0,0,0,0)] = 'k', - [BRLAPI_DOTS(1,1,1,0,0,0,0,0)] = 'l', - [BRLAPI_DOTS(1,0,1,1,0,0,0,0)] = 'm', - [BRLAPI_DOTS(1,0,1,1,1,0,0,0)] = 'n', - [BRLAPI_DOTS(1,0,1,0,1,0,0,0)] = 'o', - [BRLAPI_DOTS(1,1,1,1,0,0,0,0)] = 'p', - [BRLAPI_DOTS(1,1,1,1,1,0,0,0)] = 'q', - [BRLAPI_DOTS(1,1,1,0,1,0,0,0)] = 'r', - [BRLAPI_DOTS(0,1,1,1,0,0,0,0)] = 's', - [BRLAPI_DOTS(0,1,1,1,1,0,0,0)] = 't', - [BRLAPI_DOTS(1,0,1,0,0,1,0,0)] = 'u', - [BRLAPI_DOTS(1,1,1,0,0,1,0,0)] = 'v', - [BRLAPI_DOTS(0,1,0,1,1,1,0,0)] = 'w', - [BRLAPI_DOTS(1,0,1,1,0,1,0,0)] = 'x', - [BRLAPI_DOTS(1,0,1,1,1,1,0,0)] = 'y', - [BRLAPI_DOTS(1,0,1,0,1,1,0,0)] = 'z', - - [BRLAPI_DOTS(1,0,0,0,0,0,1,0)] = 'A', - [BRLAPI_DOTS(1,1,0,0,0,0,1,0)] = 'B', - [BRLAPI_DOTS(1,0,0,1,0,0,1,0)] = 'C', - [BRLAPI_DOTS(1,0,0,1,1,0,1,0)] = 'D', - [BRLAPI_DOTS(1,0,0,0,1,0,1,0)] = 'E', - [BRLAPI_DOTS(1,1,0,1,0,0,1,0)] = 'F', - [BRLAPI_DOTS(1,1,0,1,1,0,1,0)] = 'G', - [BRLAPI_DOTS(1,1,0,0,1,0,1,0)] = 'H', - [BRLAPI_DOTS(0,1,0,1,0,0,1,0)] = 'I', - [BRLAPI_DOTS(0,1,0,1,1,0,1,0)] = 'J', - [BRLAPI_DOTS(1,0,1,0,0,0,1,0)] = 'K', - [BRLAPI_DOTS(1,1,1,0,0,0,1,0)] = 'L', - [BRLAPI_DOTS(1,0,1,1,0,0,1,0)] = 'M', - [BRLAPI_DOTS(1,0,1,1,1,0,1,0)] = 'N', - [BRLAPI_DOTS(1,0,1,0,1,0,1,0)] = 'O', - [BRLAPI_DOTS(1,1,1,1,0,0,1,0)] = 'P', - [BRLAPI_DOTS(1,1,1,1,1,0,1,0)] = 'Q', - [BRLAPI_DOTS(1,1,1,0,1,0,1,0)] = 'R', - [BRLAPI_DOTS(0,1,1,1,0,0,1,0)] = 'S', - [BRLAPI_DOTS(0,1,1,1,1,0,1,0)] = 'T', - [BRLAPI_DOTS(1,0,1,0,0,1,1,0)] = 'U', - [BRLAPI_DOTS(1,1,1,0,0,1,1,0)] = 'V', - [BRLAPI_DOTS(0,1,0,1,1,1,1,0)] = 'W', - [BRLAPI_DOTS(1,0,1,1,0,1,1,0)] = 'X', - [BRLAPI_DOTS(1,0,1,1,1,1,1,0)] = 'Y', - [BRLAPI_DOTS(1,0,1,0,1,1,1,0)] = 'Z', - - [BRLAPI_DOTS(0,0,1,0,1,1,0,0)] = '0', - [BRLAPI_DOTS(0,1,0,0,0,0,0,0)] = '1', - [BRLAPI_DOTS(0,1,1,0,0,0,0,0)] = '2', - [BRLAPI_DOTS(0,1,0,0,1,0,0,0)] = '3', - [BRLAPI_DOTS(0,1,0,0,1,1,0,0)] = '4', - [BRLAPI_DOTS(0,1,0,0,0,1,0,0)] = '5', - [BRLAPI_DOTS(0,1,1,0,1,0,0,0)] = '6', - [BRLAPI_DOTS(0,1,1,0,1,1,0,0)] = '7', - [BRLAPI_DOTS(0,1,1,0,0,1,0,0)] = '8', - [BRLAPI_DOTS(0,0,1,0,1,0,0,0)] = '9', - - [BRLAPI_DOTS(0,0,0,1,0,1,0,0)] = '.', - [BRLAPI_DOTS(0,0,1,1,0,1,0,0)] = '+', - [BRLAPI_DOTS(0,0,1,0,0,1,0,0)] = '-', - [BRLAPI_DOTS(1,0,0,0,0,1,0,0)] = '*', - [BRLAPI_DOTS(0,0,1,1,0,0,0,0)] = '/', - [BRLAPI_DOTS(1,1,1,0,1,1,0,0)] = '(', - [BRLAPI_DOTS(0,1,1,1,1,1,0,0)] = ')', - - [BRLAPI_DOTS(1,1,1,1,0,1,0,0)] = '&', - [BRLAPI_DOTS(0,0,1,1,1,1,0,0)] = '#', - - [BRLAPI_DOTS(0,0,0,0,0,1,0,0)] = ',', - [BRLAPI_DOTS(0,0,0,0,1,1,0,0)] = ';', - [BRLAPI_DOTS(1,0,0,0,1,1,0,0)] = ':', - [BRLAPI_DOTS(0,1,1,1,0,1,0,0)] = '!', - [BRLAPI_DOTS(1,0,0,1,1,1,0,0)] = '?', - [BRLAPI_DOTS(0,0,0,0,1,0,0,0)] = '"', - [BRLAPI_DOTS(0,0,1,0,0,0,0,0)] ='\'', - [BRLAPI_DOTS(0,0,0,1,0,0,0,0)] = '`', - [BRLAPI_DOTS(0,0,0,1,1,0,1,0)] = '^', - [BRLAPI_DOTS(0,0,0,1,1,0,0,0)] = '~', - [BRLAPI_DOTS(0,1,0,1,0,1,1,0)] = '[', - [BRLAPI_DOTS(1,1,0,1,1,1,1,0)] = ']', - [BRLAPI_DOTS(0,1,0,1,0,1,0,0)] = '{', - [BRLAPI_DOTS(1,1,0,1,1,1,0,0)] = '}', - [BRLAPI_DOTS(1,1,1,1,1,1,0,0)] = '=', - [BRLAPI_DOTS(1,1,0,0,0,1,0,0)] = '<', - [BRLAPI_DOTS(0,0,1,1,1,0,0,0)] = '>', - [BRLAPI_DOTS(1,1,0,1,0,1,0,0)] = '$', - [BRLAPI_DOTS(1,0,0,1,0,1,0,0)] = '%', - [BRLAPI_DOTS(0,0,0,1,0,0,1,0)] = '@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_DOTS(0, 0, 0, 1, 1, 1, 0, 0), '_'), };/* The serial port can receive more of our data */
@@ -346,8 +353,10 @@ static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len) cursor = i +1 ; c &= ~(BRLAPI_DOT7 |BRLAPI_DOT8 ); } -if (!(c = nabcc_translation[c])) + c = nabcc_translation[DOTS2ASCII ][c]; +if (!c) { c ='?' ; + } text[i] = c; }timer_del (baum->cellCount_timer);
@@ -476,6 +485,13 @@ static void baum_send_key(BaumDriverState *baum, uint8_t type, uint8_t value) {baum_write_packet (baum, packet,sizeof (packet)); } +static void baum_send_key2 (BaumDriverState *baum,uint8_t type,uint8_t value, +uint8_t value2) { +uint8_t packet[] = { type, value, value2 }; +DPRINTF ("writing key %x %x\n" , type, value); +baum_write_packet (baum, packet,sizeof (packet)); +} +/* We got some data on the BrlAPI socket */ static void baum_chr_read (void *opaque) {
@@ -540,7 +556,17 @@ static void baum_chr_read(void *opaque) }break ;case BRLAPI_KEY_TYPE_SYM : -break ; + { +brlapi_keyCode_t keysym = code &BRLAPI_KEY_CODE_MASK ; +if (keysym <0x100 ) { +uint8_t dots = nabcc_translation[ASCII2DOTS ][keysym]; +if (dots) { +baum_send_key2 (baum, BAUM_RSP_EntryKeys,0 , dots); +baum_send_key2 (baum, BAUM_RSP_EntryKeys,0 ,0 ); + } + } +break ; + } } }if (ret ==-1 && (brlapi_errno !=BRLAPI_ERROR_LIBCERR || errno !=EINTR )) {
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 1/3] Add dots keypresses support to the baum braille device
Quoted 1 line · Samuel Thibault
Signed-off-by Samuel Thibault <[email protected]>
Hmm, this one throws strange errors at me:
kraxel@nilsson ~/projects/qemu (queue/ui)# git am -3 ~/Downloads/patches/input/\[PATCH_1_3 \]_Add_dots_keypresses_support_to_the_baum_braille_device.mbox
Applying: Add dots keypresses support to the baum braille device Using index info to reconstruct a base tree...
M backends/baum.c
error: patch failed: backends/baum.c:1
error: backends/baum.c: patch does not apply
Did you hand edit your patch?
It does not apply to blobs recorded in its index. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Hmm? How can that happen?
/me looks puzzled.
Cannot fall back to three-way merge.
Patch failed at 0001 Add dots keypresses support to the baum braille device
cheers,
Gerd
Re: [Qemu-devel] [PATCH 1/3] Add dots keypresses support to the baum braille device
Quoted 5 lines · Gerd Hoffmann, on Wed 26 Oct 2016 14:37:14 +0200, wrote:
Quoted 1 line · Samuel Thibault
Signed-off-by Samuel Thibault <[email protected]>Hmm, this one throws strange errors at me:
Quoted 9 lines
kraxel@nilsson ~/projects/qemu (queue/ui)# git am -3 ~/Downloads/patches/input/\[PATCH_1_3 \]_Add_dots_keypresses_support_to_the_baum_braille_device.mbox
Applying: Add dots keypresses support to the baum braille device Using index info to reconstruct a base tree...
Mbackends/baum.c
error: patch failed:backends/baum.c:1
error:backends/baum.c: patch does not apply
Did you hand edit your patch?
Uh, no. That's odd, I just used git format-patch and git send-email. I have attached it by hand here.
Samuel
commit ce73b6b9a5ce3a0f7465b9877273eea70708953f
Author: Samuel Thibault <[email protected]> Date: Mon Aug 22 17:31:58 2011 +0200
Add dots keypresses support to the baum braille device
backends/baum.c +130 -104
@@ -1,7 +1,7 @@/* * QEMU Baum Braille Device * -* Copyright (c) 2008 Samuel Thibault +* Copyright (c) 2008, 2010-2011, 2016 Samuel Thibault * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal
@@ -102,8 +102,11 @@ typedef struct { } BaumDriverState;/* Let's assume NABCC by default */ -static const uint8_t nabcc_translation[256 ] = { - [0 ] =' ' , +enum way { +DOTS2ASCII , +ASCII2DOTS +}; +static const uint8_t nabcc_translation[2 ][256 ] = { #ifndef BRLAPI_DOTS #define BRLAPI_DOTS(d1,d2,d3,d4,d5,d6,d7,d8) \ ((d1?BRLAPI_DOT1:0)|\
@@ -115,105 +118,109 @@ static const uint8_t nabcc_translation[256] = { (d7?BRLAPI_DOT7:0)|\ (d8?BRLAPI_DOT8:0))#endif - [BRLAPI_DOTS(1,0,0,0,0,0,0,0)] = 'a', - [BRLAPI_DOTS(1,1,0,0,0,0,0,0)] = 'b', - [BRLAPI_DOTS(1,0,0,1,0,0,0,0)] = 'c', - [BRLAPI_DOTS(1,0,0,1,1,0,0,0)] = 'd', - [BRLAPI_DOTS(1,0,0,0,1,0,0,0)] = 'e', - [BRLAPI_DOTS(1,1,0,1,0,0,0,0)] = 'f', - [BRLAPI_DOTS(1,1,0,1,1,0,0,0)] = 'g', - [BRLAPI_DOTS(1,1,0,0,1,0,0,0)] = 'h', - [BRLAPI_DOTS(0,1,0,1,0,0,0,0)] = 'i', - [BRLAPI_DOTS(0,1,0,1,1,0,0,0)] = 'j', - [BRLAPI_DOTS(1,0,1,0,0,0,0,0)] = 'k', - [BRLAPI_DOTS(1,1,1,0,0,0,0,0)] = 'l', - [BRLAPI_DOTS(1,0,1,1,0,0,0,0)] = 'm', - [BRLAPI_DOTS(1,0,1,1,1,0,0,0)] = 'n', - [BRLAPI_DOTS(1,0,1,0,1,0,0,0)] = 'o', - [BRLAPI_DOTS(1,1,1,1,0,0,0,0)] = 'p', - [BRLAPI_DOTS(1,1,1,1,1,0,0,0)] = 'q', - [BRLAPI_DOTS(1,1,1,0,1,0,0,0)] = 'r', - [BRLAPI_DOTS(0,1,1,1,0,0,0,0)] = 's', - [BRLAPI_DOTS(0,1,1,1,1,0,0,0)] = 't', - [BRLAPI_DOTS(1,0,1,0,0,1,0,0)] = 'u', - [BRLAPI_DOTS(1,1,1,0,0,1,0,0)] = 'v', - [BRLAPI_DOTS(0,1,0,1,1,1,0,0)] = 'w', - [BRLAPI_DOTS(1,0,1,1,0,1,0,0)] = 'x', - [BRLAPI_DOTS(1,0,1,1,1,1,0,0)] = 'y', - [BRLAPI_DOTS(1,0,1,0,1,1,0,0)] = 'z', - - [BRLAPI_DOTS(1,0,0,0,0,0,1,0)] = 'A', - [BRLAPI_DOTS(1,1,0,0,0,0,1,0)] = 'B', - [BRLAPI_DOTS(1,0,0,1,0,0,1,0)] = 'C', - [BRLAPI_DOTS(1,0,0,1,1,0,1,0)] = 'D', - [BRLAPI_DOTS(1,0,0,0,1,0,1,0)] = 'E', - [BRLAPI_DOTS(1,1,0,1,0,0,1,0)] = 'F', - [BRLAPI_DOTS(1,1,0,1,1,0,1,0)] = 'G', - [BRLAPI_DOTS(1,1,0,0,1,0,1,0)] = 'H', - [BRLAPI_DOTS(0,1,0,1,0,0,1,0)] = 'I', - [BRLAPI_DOTS(0,1,0,1,1,0,1,0)] = 'J', - [BRLAPI_DOTS(1,0,1,0,0,0,1,0)] = 'K', - [BRLAPI_DOTS(1,1,1,0,0,0,1,0)] = 'L', - [BRLAPI_DOTS(1,0,1,1,0,0,1,0)] = 'M', - [BRLAPI_DOTS(1,0,1,1,1,0,1,0)] = 'N', - [BRLAPI_DOTS(1,0,1,0,1,0,1,0)] = 'O', - [BRLAPI_DOTS(1,1,1,1,0,0,1,0)] = 'P', - [BRLAPI_DOTS(1,1,1,1,1,0,1,0)] = 'Q', - [BRLAPI_DOTS(1,1,1,0,1,0,1,0)] = 'R', - [BRLAPI_DOTS(0,1,1,1,0,0,1,0)] = 'S', - [BRLAPI_DOTS(0,1,1,1,1,0,1,0)] = 'T', - [BRLAPI_DOTS(1,0,1,0,0,1,1,0)] = 'U', - [BRLAPI_DOTS(1,1,1,0,0,1,1,0)] = 'V', - [BRLAPI_DOTS(0,1,0,1,1,1,1,0)] = 'W', - [BRLAPI_DOTS(1,0,1,1,0,1,1,0)] = 'X', - [BRLAPI_DOTS(1,0,1,1,1,1,1,0)] = 'Y', - [BRLAPI_DOTS(1,0,1,0,1,1,1,0)] = 'Z', - - [BRLAPI_DOTS(0,0,1,0,1,1,0,0)] = '0', - [BRLAPI_DOTS(0,1,0,0,0,0,0,0)] = '1', - [BRLAPI_DOTS(0,1,1,0,0,0,0,0)] = '2', - [BRLAPI_DOTS(0,1,0,0,1,0,0,0)] = '3', - [BRLAPI_DOTS(0,1,0,0,1,1,0,0)] = '4', - [BRLAPI_DOTS(0,1,0,0,0,1,0,0)] = '5', - [BRLAPI_DOTS(0,1,1,0,1,0,0,0)] = '6', - [BRLAPI_DOTS(0,1,1,0,1,1,0,0)] = '7', - [BRLAPI_DOTS(0,1,1,0,0,1,0,0)] = '8', - [BRLAPI_DOTS(0,0,1,0,1,0,0,0)] = '9', - - [BRLAPI_DOTS(0,0,0,1,0,1,0,0)] = '.', - [BRLAPI_DOTS(0,0,1,1,0,1,0,0)] = '+', - [BRLAPI_DOTS(0,0,1,0,0,1,0,0)] = '-', - [BRLAPI_DOTS(1,0,0,0,0,1,0,0)] = '*', - [BRLAPI_DOTS(0,0,1,1,0,0,0,0)] = '/', - [BRLAPI_DOTS(1,1,1,0,1,1,0,0)] = '(', - [BRLAPI_DOTS(0,1,1,1,1,1,0,0)] = ')', - - [BRLAPI_DOTS(1,1,1,1,0,1,0,0)] = '&', - [BRLAPI_DOTS(0,0,1,1,1,1,0,0)] = '#', - - [BRLAPI_DOTS(0,0,0,0,0,1,0,0)] = ',', - [BRLAPI_DOTS(0,0,0,0,1,1,0,0)] = ';', - [BRLAPI_DOTS(1,0,0,0,1,1,0,0)] = ':', - [BRLAPI_DOTS(0,1,1,1,0,1,0,0)] = '!', - [BRLAPI_DOTS(1,0,0,1,1,1,0,0)] = '?', - [BRLAPI_DOTS(0,0,0,0,1,0,0,0)] = '"', - [BRLAPI_DOTS(0,0,1,0,0,0,0,0)] ='\'', - [BRLAPI_DOTS(0,0,0,1,0,0,0,0)] = '`', - [BRLAPI_DOTS(0,0,0,1,1,0,1,0)] = '^', - [BRLAPI_DOTS(0,0,0,1,1,0,0,0)] = '~', - [BRLAPI_DOTS(0,1,0,1,0,1,1,0)] = '[', - [BRLAPI_DOTS(1,1,0,1,1,1,1,0)] = ']', - [BRLAPI_DOTS(0,1,0,1,0,1,0,0)] = '{', - [BRLAPI_DOTS(1,1,0,1,1,1,0,0)] = '}', - [BRL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,0 ,0 ,1 ,0 ,1 ,0 ,0 ),'%' ), +DO (BRLAPI_DOTS (0 ,0 ,0 ,1 ,0 ,0 ,1 ,0 ),'@' ), +DO (BRLAPI_DOTS (1 ,1 ,0 ,0 ,1 ,1 ,0 ,0 ),'|' ), +DO (BRLAPI_DOTS (1 ,1 ,0 ,0 ,1 ,1 ,1 ,0 ),'\\' ), + DO(BRLAPI_DOTS(0, 0, 0, 1, 1, 1, 0, 0), '_'), };/* The serial port can receive more of our data */
@@ -346,8 +353,10 @@ static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len) cursor = i +1 ; c &= ~(BRLAPI_DOT7 |BRLAPI_DOT8 ); } -if (!(c = nabcc_translation[c])) + c = nabcc_translation[DOTS2ASCII ][c]; +if (!c) { c ='?' ; + } text[i] = c; }timer_del (baum->cellCount_timer);
@@ -476,6 +485,13 @@ static void baum_send_key(BaumDriverState *baum, uint8_t type, uint8_t value) {baum_write_packet (baum, packet,sizeof (packet)); } +static void baum_send_key2 (BaumDriverState *baum,uint8_t type,uint8_t value, +uint8_t value2) { +uint8_t packet[] = { type, value, value2 }; +DPRINTF ("writing key %x %x\n" , type, value); +baum_write_packet (baum, packet,sizeof (packet)); +} +/* We got some data on the BrlAPI socket */ static void baum_chr_read (void *opaque) {
@@ -540,7 +556,17 @@ static void baum_chr_read(void *opaque) }break ;case BRLAPI_KEY_TYPE_SYM : -break ; + { +brlapi_keyCode_t keysym = code &BRLAPI_KEY_CODE_MASK ; +if (keysym <0x100 ) { +uint8_t dots = nabcc_translation[ASCII2DOTS ][keysym]; +if (dots) { +baum_send_key2 (baum, BAUM_RSP_EntryKeys,0 , dots); +baum_send_key2 (baum, BAUM_RSP_EntryKeys,0 ,0 ); + } + } +break ; + } } }if (ret ==-1 && (brlapi_errno !=BRLAPI_ERROR_LIBCERR || errno !=EINTR )) {
Re: [Qemu-devel] [PATCH 1/3] Add dots keypresses support to the baum braille device
Quoted 16 lines · Samuel Thibault
Quoted 5 lines · Gerd Hoffmann, on Wed 26 Oct 2016 14:37:14 +0200, wrote:
Quoted 1 line · Samuel Thibault
Signed-off-by Samuel Thibault <[email protected]>Hmm, this one throws strange errors at me:
Quoted 9 lines
kraxel@nilsson ~/projects/qemu (queue/ui)# git am -3 ~/Downloads/patches/input/\[PATCH_1_3 \]_Add_dots_keypresses_support_to_the_baum_braille_device.mbox
Applying: Add dots keypresses support to the baum braille device Using index info to reconstruct a base tree...
Mbackends/baum.c
error: patch failed:backends/baum.c:1
error:backends/baum.c: patch does not apply
Did you hand edit your patch?
Quoted 4 lines
Uh, no. That's odd, I just used git format-patch and git send-email. I have attached it by hand here.
Samuel
That worked.
thanks,
Gerd
PATCH v2 2/3 Defer BrlAPI tty acquisition to when guest starts using device
In reply to Samuel ThibaultWe do not want to catch the BrlAPI input/ouput immediately, but only when the guest has started discussing withour virtual device.
This notably fixes input before the guest driver has started.
--- backends/baum.c | 81 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 32 deletions(-)
backends/baum.c +49 -32
@@ -92,6 +92,7 @@ typedef struct {brlapi_handle_t *brlapi;int brlapi_fd;unsigned int x, y; +bool deferred_init;uint8_t in_buf[BUF_SIZE ];uint8_t in_buf_used;
@@ -223,6 +224,49 @@ static const uint8_t nabcc_translation[2][256] = { DO(BRLAPI_DOTS(0, 0, 0, 1, 1, 1, 0, 0), '_'), }; +/* The guest OS has started discussing with us, finish initializing BrlAPI */ +static int baum_deferred_init(BaumDriverState *baum) +{ +#if defined(CONFIG_SDL) +#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0) + SDL_SysWMinfo info; +#endif +#endif + int tty; + + if (baum->deferred_init) { + return 1; + } + + if (brlapi__getDisplaySize(baum->brlapi, &baum->x, &baum->y) == -1) { + brlapi_perror("baum: brlapi__getDisplaySize"); + return 0; + } + +#if defined(CONFIG_SDL) +#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0) + memset(&info, 0, sizeof(info)); + SDL_VERSION(&info.version); + if (SDL_GetWMInfo(&info)) { + tty = info.info.x11.wmwindow; + } else { +#endif +#endif + tty = BRLAPI_TTY_DEFAULT; +#if defined(CONFIG_SDL) +#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0) + } +#endif +#endif + + if (brlapi__enterTtyMode(baum->brlapi, tty, NULL) == -1) { + brlapi_perror("baum: brlapi__enterTtyMode"); + return 0; + } + baum->deferred_init = 1; + return 1; +} + /* The serial port can receive more of our data */ static void baum_accept_input(struct CharDriverState *chr) {
@@ -449,6 +493,8 @@ static int baum_write(CharDriverState *chr, const uint8_t *buf, int len)return 0 ;if (!baum->brlapi)return len; +if (!baum_deferred_init (baum)) +return len;while (len) {/* Complete our buffer as much as possible */
@@ -500,6 +546,8 @@ static void baum_chr_read(void *opaque)int ret;if (!baum->brlapi)return ; +if (!baum_deferred_init (baum)) +return ;while ((ret =brlapi__readKey (baum->brlapi,0 , &code)) ==1 ) {DPRINTF ("got key %" BRLAPI_PRIxKEYCODE"\n" , code);/* Emulate */
@@ -598,12 +646,6 @@ static CharDriverState *chr_baum_init(const char *id,BaumDriverState *baum;CharDriverState *chr;brlapi_handle_t *handle; -#if defined(CONFIG_SDL ) -#if SDL_COMPILEDVERSION <SDL_VERSIONNUM (2 ,0 ,0 ) -SDL_SysWMinfo info; -#endif -#endif -int tty; chr =qemu_chr_alloc (common, errp);if (!chr) {
@@ -626,39 +668,14 @@ static CharDriverState *chr_baum_init(const char *id, brlapi_strerror(brlapi_error_location())); goto fail_handle; } + baum->deferred_init =0 ; baum->cellCount_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , baum_cellCount_timer_cb, baum); -if (brlapi__getDisplaySize (handle, &baum->x, &baum->y) ==-1 ) { -error_setg (errp,"brlapi__getDisplaySize: %s" , -brlapi_strerror (brlapi_error_location ())); - goto fail; - } - -#if defined(CONFIG_SDL ) -#if SDL_COMPILEDVERSION <SDL_VERSIONNUM (2 ,0 ,0 ) -memset (&info,0 ,sizeof (info)); -SDL_VERSION (&info.version); -if (SDL_GetWMInfo (&info)) - tty = info.info.x11.wmwindow; - else -#endif -#endif - tty =BRLAPI_TTY_DEFAULT ; - -if (brlapi__enterTtyMode (handle, tty,NULL ) ==-1 ) { -error_setg (errp,"brlapi__enterTtyMode: %s" , -brlapi_strerror (brlapi_error_location ())); - goto fail; - } -qemu_set_fd_handler (baum->brlapi_fd, baum_chr_read,NULL , baum);return chr; -fail: -timer_free (baum->cellCount_timer); -brlapi__closeConnection (handle); fail_handle:g_free (handle);g_free (chr);
Signature · 1 line
2.9.3
PATCH v2 3/3 Move getting XWindow ID from baum driver to graphical backend
In reply to Samuel ThibaultThis adds two console functions, qemu_console_set_window_id and qemu_graphic_console_get_window_id, to let graphical backend record the window id in the QemuConsole structure, and let the baum driver read it.
We can then move the SDL code from the baum driver to the sdl ui code, and add SDL2 and Gtk versions of the code.
--- backends/baum.c | 25 +++---------------------- include/ui/console.h | 3 +++ ui/console.c | 18 ++++++++++++++++++ ui/gtk.c | 25 +++++++++++++++++++++++-- ui/sdl.c | 25 +++++++++++++++++++++++++ ui/sdl2.c | 7 +++++++ 6 files changed, 79 insertions(+), 24 deletions(-)
backends/baum.c +3 -22
@@ -27,12 +27,10 @@#include "sysemu/char.h" #include "qemu/timer.h" #include "hw/usb.h" +#include "ui/console.h" #include <brlapi.h> #include <brlapi_constants.h> #include <brlapi_keycodes.h> -#ifdef CONFIG_SDL -#include <SDL_syswm.h> -#endif #if 0 #define DPRINTF (fmt, ...) \
@@ -227,11 +225,6 @@ static const uint8_t nabcc_translation[2][256] = {/* The guest OS has started discussing with us, finish initializing BrlAPI */ static int baum_deferred_init (BaumDriverState *baum) { -#if defined(CONFIG_SDL ) -#if SDL_COMPILEDVERSION <SDL_VERSIONNUM (2 ,0 ,0 ) -SDL_SysWMinfo info; -#endif -#endif int tty;if (baum->deferred_init) {
@@ -243,21 +236,9 @@ static int baum_deferred_init(BaumDriverState *baum)return 0 ; } -#if defined(CONFIG_SDL) -#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0) - memset(&info, 0, sizeof(info)); - SDL_VERSION(&info.version); - if (SDL_GetWMInfo(&info)) { - tty = info.info.x11.wmwindow; - } else { -#endif -#endif + tty =qemu_graphic_console_get_window_id (); +if (tty ==-1 ) tty =BRLAPI_TTY_DEFAULT ; -#if defined(CONFIG_SDL) -#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0) - } -#endif -#endifif (brlapi__enterTtyMode (baum->brlapi, tty,NULL ) ==-1 ) {brlapi_perror ("baum: brlapi__enterTtyMode" );
include/ui/console.h +3 -0
@@ -394,6 +394,9 @@ uint32_t qemu_console_get_head(QemuConsole *con);QemuUIInfo *qemu_console_get_ui_info (QemuConsole *con);int qemu_console_get_width (QemuConsole *con,int fallback);int qemu_console_get_height (QemuConsole *con,int fallback); +/* Return the low-level window id for the first graphical console */ +int qemu_graphic_console_get_window_id (void ); +void qemu_console_set_window_id (int index,int window_id);void console_select (unsigned int index);void qemu_console_resize (QemuConsole *con,int width,int height);
ui/console.c +18 -0
@@ -124,6 +124,7 @@ struct QemuConsole {int dcls;DisplayChangeListener *gl;bool gl_block; +int window_id;/* Graphic console state. */ Object *device;
@@ -273,6 +274,23 @@ void graphic_hw_gl_block(QemuConsole *con, bool block) } } +int qemu_graphic_console_get_window_id (void ) +{ +int i; +for (i =0 ; i < nb_consoles; i++) { +if (consoles[i]->console_type ==GRAPHIC_CONSOLE ) { +return consoles[i]->window_id; + } + } +return -1 ; +} + +void qemu_console_set_window_id (int index,int window_id) +{ +assert (index < nb_consoles); + consoles[index]->window_id = window_id; +} +void graphic_hw_invalidate (QemuConsole *con) {if (!con) {
ui/gtk.c +23 -2
@@ -2155,6 +2155,13 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)GtkDisplayState *s =g_malloc0 (sizeof (*s));char *filename;GdkDisplay *window_display; +GdkWindow *gdk_window; +#ifdef GDK_WINDOWING_X11 +Window window_id; +#elif defined(GDK_WINDOWING_WIN32 ) +HWND window_id; +#endif +int i;if (!gtkinit) {fprintf (stderr,"gtk initialization failed\n" );
@@ -2217,8 +2224,6 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover) {VirtualConsole *cur =gd_vc_find_current (s);if (cur) { -int i; -for (i =0 ; i < s->nb_vcs; i++) {VirtualConsole *vc = &s->vc[i];if (vc && vc->type ==GD_VC_VTE && vc != cur) {
@@ -2238,6 +2243,22 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover) }gd_set_keycode_type (s); + + gdk_window =gtk_widget_get_window (s->window); +#ifdef GDK_WINDOWING_X11 + window_id =GDK_WINDOW_XID (gdk_window); +#elif defined(GDK_WINDOWING_WIN32 ) + window_id =gdk_win32_window_get_impl_hwnd (gdk_window); +#endif +for (i =0 ; ; i++) { +/* All consoles share the same window */ +QemuConsole *con =qemu_console_lookup_by_index (i); +if (con) { +qemu_console_set_window_id (i, (int ) window_id); + }else { +break ; + } + } }void early_gtk_display_init (int opengl)
ui/sdl.c +25 -0
@@ -947,6 +947,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)int flags;uint8_t data =0 ;const SDL_VideoInfo *vi; +SDL_SysWMinfo info;char *filename;#if defined(__APPLE__)
@@ -1023,5 +1024,29 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame) sdl_cursor_hidden =SDL_CreateCursor (&data, &data,8 ,1 ,0 ,0 ); sdl_cursor_normal =SDL_GetCursor (); +memset (&info,0 ,sizeof (info)); +SDL_VERSION (&info.version); +if (SDL_GetWMInfo (&info)) { +int i; +for (i =0 ; ; i++) { +/* All consoles share the same window */ +QemuConsole *con =qemu_console_lookup_by_index (i); +if (con) { +#if defined(SDL_VIDEO_DRIVER_X11 ) +qemu_console_set_window_id (i, info.info.x11.wmwindow); +#elif defined(SDL_VIDEO_DRIVER_NANOX ) || \ + defined(SDL_VIDEO_DRIVER_WINDIB ) || defined(SDL_VIDEO_DRIVER_DDRAW ) || \ + defined(SDL_VIDEO_DRIVER_GAPI ) || \ + defined(SDL_VIDEO_DRIVER_RISCOS ) +qemu_console_set_window_id (i, (int ) info.window); +#else +qemu_console_set_window_id (i, info.data); +#endif + }else { +break ; + } + } + } +atexit (sdl_cleanup); }
ui/sdl2.c +7 -0
@@ -761,6 +761,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)uint8_t data =0 ;char *filename;int i; +SDL_SysWMinfo info;if (no_frame) { gui_noframe =1 ;
@@ -786,6 +787,8 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)exit (1 ); }SDL_SetHint (SDL_HINT_GRAB_KEYBOARD ,"1" ); +memset (&info,0 ,sizeof (info)); +SDL_VERSION (&info.version);for (i =0 ;; i++) {QemuConsole *con =qemu_console_lookup_by_index (i);
@@ -813,6 +816,10 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)#endif sdl2_console[i].dcl.con = con;register_displaychangelistener (&sdl2_console[i].dcl); + +if (SDL_GetWindowWMInfo (sdl2_console[i].real_window, &info)) { +qemu_console_set_window_id (i, info.info.x11.window); + } }/* Load a 32x32x4 image. White pixels are transparent. */
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 3/3] Move getting XWindow ID from baum driver to graphical backend
Quoted 6 lines · Samuel Thibault
This adds two console functions,
qemu_console_set_window_idandqemu_graphic_console_get_window_id, to let graphical backend record the window id in the QemuConsole structure, and let the baum driver read it.We can then move the SDL code from the baum driver to the sdl ui code, and add SDL2 and Gtk versions of the code.
Patches 1+2 look good to me, but I don't feel like rushing this one before the freeze. Also splitting this up would be nice.
ui/console.c void graphic_hw_gl_block(QemuConsole *con, bool block) · line 286
Quoted 10 lines
ui/console.c +10
-0+int qemu_graphic_console_get_window_id (void ) +{ +int i; +for (i =0 ; i < nb_consoles; i++) { +if (consoles[i]->console_type ==GRAPHIC_CONSOLE ) { +return consoles[i]->window_id; + } + } +return -1 ; +}
No loop needed here. qemu sorts consoles so the graphic ones come first.
ui/gtk.c void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover) · line 2254
Quoted 8 lines
ui/gtk.c +8
-0+ gdk_window =gtk_widget_get_window (s->window); +#ifdef GDK_WINDOWING_X11 + window_id =GDK_WINDOW_XID (gdk_window); +#elif defined(GDK_WINDOWING_WIN32 ) + window_id =gdk_win32_window_get_impl_hwnd (gdk_window); +#endif +for (i =0 ; ; i++) { +/* All consoles share the same window */
No. That is the default setup, but try "View / Detach tab". Window ID changing at runtime ...
cheers,
Gerd
Re: [Qemu-devel] [PATCH 3/3] Move getting XWindow ID from baum driver to graphical backend
Hello,
Quoted 10 lines · Gerd Hoffmann, on Wed 26 Oct 2016 12:17:44 +0200, wrote:
Quoted 6 lines · Samuel Thibault
This adds two console functions,
qemu_console_set_window_idandqemu_graphic_console_get_window_id, to let graphical backend record the window id in the QemuConsole structure, and let the baum driver read it.We can then move the SDL code from the baum driver to the sdl ui code, and add SDL2 and Gtk versions of the code.
Patches 1+2 look good to me, but I don't feel like rushing this one before the freeze.
Ok, it'd be nice to have 1+2 in in the next release already indeed, they are needed fixes. 3 can be applied later, for the time being people can use sdl1.2.
Quoted 1 line
Also splitting this up would be nice.
You mean separating the move of the sdl1.2 code from the addition of sdl2+gtk code? (and perhaps separate sdl2 and gtk?)
Quoted 5 lines
Quoted 5 lines
ui/console.c +5
-0+int qemu_graphic_console_get_window_id (void ) +{ +int i; +for (i =0 ; i < nb_consoles; i++) { +if (consoles[i]->console_type ==GRAPHIC_CONSOLE ) {
Quoted 8 lines
ui/console.c void graphic_hw_gl_block(QemuConsole *con, bool block) · line 286
Quoted 5 lines
ui/console.c +5
-0+return consoles[i]->window_id; + } + } +return -1 ; +}No loop needed here. qemu sorts consoles so the graphic ones come first.
Ok, but are we sure nobody will change that assumption someday? Or do we assume that if somebody changes it he will notice the assumption in qemu_graphic_console_get_window_id?
Quoted 11 lines
ui/gtk.c void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover) · line 2254
Quoted 8 lines
ui/gtk.c +8
-0+ gdk_window =gtk_widget_get_window (s->window); +#ifdef GDK_WINDOWING_X11 + window_id =GDK_WINDOW_XID (gdk_window); +#elif defined(GDK_WINDOWING_WIN32 ) + window_id =gdk_win32_window_get_impl_hwnd (gdk_window); +#endif +for (i =0 ; ; i++) { +/* All consoles share the same window */ No. That is the default setup, but try "View / Detach tab". Window ID changing at runtime ...
Ah. That'll have to be reworked then indeed.
Samuel
Re: [Qemu-devel] [PATCH 3/3] Move getting XWindow ID from baum driver to graphical backend
Quoted 4 lines
Quoted 1 line
Also splitting this up would be nice.
You mean separating the move of the sdl1.2 code from the addition of sdl2+gtk code? (and perhaps separate sdl2 and gtk?)
One patch adding new console.[ch] interfaces, then one patch per UI, finally switch over baum to the new interfaces.
Maybe put sdl-ui + baum into one patch as this moves existing code sdl code from baum.c to sdl*.c for the most part.
Quoted 6 lines
Quoted 2 lines
No loop needed here. qemu sorts consoles so the graphic ones come first.
Ok, but are we sure nobody will change that assumption someday? Or do we assume that if somebody changes it he will notice the assumption in
qemu_graphic_console_get_window_id?
If that assumption ever changes the code here (and in quite a few more places) must be adapted to it.
cheers,
Gerd
Re: [Qemu-devel] [PATCH 3/3] Move getting XWindow ID from baum driver to graphical backend
In reply to Gerd HoffmannQuoted 4 lines · Gerd Hoffmann, on Wed 26 Oct 2016 12:17:44 +0200, wrote:
Quoted 1 line
+ /* All consoles share the same window */
No. That is the default setup, but try "View / Detach tab". Window ID changing at runtime ...
So we would need to make baum register for notification of Window ID change.
It could be a mere
typedef void QemuConsoleWindowIDListener(void); qemu_console_window_id_add_listener(QemuConsoleWindowIDListener listener); qemu_console_window_id_remove_listener(QemuConsoleWindowIDListener listener);
that adds/removes the listener to a list to be called when qemu_console_set_window_id is called.
Or we could generalize a bit:
typedef void QemuConsoleConfigListener(void); qemu_console_config_add_listener(QemuConsoleConfigListener listener); qemu_console_config_remove_listener(QemuConsoleConfigListener listener);
Or even more generalized:
struct QemuConsoleListener {
void (*window_id)(void);
};
typedef struct QemuConsoleListener QemuConsoleListener; qemu_console_add_listener(QemuConsoleListener *listener); qemu_console_remove_listener(QemuConsoleListener *listener);
What would be preferrable?
Samuel
Re: [Qemu-devel] [PATCH 3/3] Move getting XWindow ID from baum driver to graphical backend
Hi,
Quoted 1 line
typedef void QemuConsoleConfigListener(void);
I think we should also pass the console which has changed:
QemuConsoleConfigListener(QemuConsole *con);
Quoted 2 lines
qemu_console_config_add_listener(QemuConsoleConfigListener listener);qemu_console_config_remove_listener(QemuConsoleConfigListener listener);
Otherwise this approach looks good to me.
cheers,
Gerd