qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "René Korthaus" <qemu-dev@cordney.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Experimental Cocoa Video Driver
Date: Sun, 10 Apr 2005 14:05:42 +0200	[thread overview]
Message-ID: <282c26223c172bc5498fe3a2ceb6eb31@cordney.com> (raw)
In-Reply-To: <42590955.5070100@kberg.ch>



I meant a simple switch to set whether you want mouse grabbing or not,  
cause if you want to do this in qemu+sdl, you have to patch many files.  
I personally don't like this whole mouse grabbing thing.

Am 10.04.2005 um 13:09 schrieb Mike Kronenberg:
> some minor changes:
> - ing grab instead of bool :) (or did you mean the naming of the var?)
> - rightdrag works now
> - leftclick+command emulates rightclick (also for rightdrag)
> - disabled ungrab when windows-switching -> clicking qemu-window will  
> now activate window and grab
>
> Known Bug:
> - if you return to qemu by alt-tab and the mouse is outside the  
> qemu-window, clicks are passed to window under hidden cursor
>
> Workaround:
> - ungrab with ctrl+alt, click into qemu-window
>
> Mike
>
> PS.
> René Korthaus wrote:
>
>> What about a simple var for choosing mouse grabbing or not, like
>>
>> // grabbing enabled: 1, grabbing disabled: 0
>> int mouseGrabbing = 1;
>
> Tanks. I hope I got you right.
> Index: cocoa.m
> ===================================================================
> RCS file: /cvsroot/qemu/qemu/cocoa.m,v
> retrieving revision 1.4
> diff -u -r1.4 cocoa.m
> --- cocoa.m	7 Apr 2005 20:36:50 -0000	1.4
> +++ cocoa.m	10 Apr 2005 10:54:59 -0000
> @@ -27,7 +27,7 @@
>                x  center the window
>                -  save window position
>                -  handle keyboard event
> -              -  handle mouse event
> +              /  handle mouse event
>                -  non 32 bpp support
>                -  full screen
>                -  mouse focus
> @@ -47,6 +47,8 @@
>  char **gArgv;
>  DisplayState current_ds;
>
> +int grab = 0;
> +
>  /* main defined in qemu/vl.c */
>  int qemu_main(int argc, char **argv);
>
> @@ -173,55 +175,129 @@
>
>  static int keymap[] =
>  {
> -    30, //'a' 0x0
> -    31,  //'s'
> -    32,  //'d'
> -    33,  //'f'
> -    35,  //'h'
> -    34,  //'g'
> -    44,  //'z'
> -    45,  //'x'
> -    46,  //'c'
> -    47,  //'v'
> -    0,   // 0  0x0a
> -    48,  //'b'
> -    16,  //'q'
> -    17,  //'w'
> -    18,  //'e'
> -    19,  //'r'
> -    21,  //'y' 0x10
> -    20,  //'t'
> -    2,  //'1'
> -    3,  //'2'
> -    4,  //'3'
> -    5,  //'4'
> -    7,  //'6'
> -    6,  //'5'
> -    0,  //'='
> -    10,  //'9'
> -    8,  //'7' 0x1A
> -    0,  //'-'
> -    9,  //'8'
> -    11,  //'0'
> -    27,  //']'
> -    24,  //'o'
> -    22,  //'u' 0x20
> -    26,  //'['
> -    23,  //'i'
> -    25,  //'p'
> -    28,  //'\n'
> -    38,  //'l'
> -    36,  //'j'
> -    40,  //'"'
> -    37,  //'k'
> -    39,  //';'
> -    15,  //'\t' 0x30
> -    0,  //' '
> -    0,  //'`'
> -    14,  //'<backspace>'
> -    0,  //'' 0x34
> -    0,  //'<esc>'
> -    0,  //'<esc>'
> +    30,	//	0x00	#define QZ_a	0x1e
> +    31,	//	0x01	#define QZ_s	0x1f
> +    32,	//	0x02	#define QZ_d	0x20
> +    33,	//	0x03	#define QZ_f	0x21
> +    35,	//	0x04	#define QZ_h	0x23
> +    34,	//	0x05	#define QZ_g	0x22
> +    44,	//	0x06	#define QZ_z	0x2c
> +    45,	//	0x07	#define QZ_x	0x2d
> +    46,	//	0x08	#define QZ_c	0x2e
> +    47,	//	0x09	#define QZ_v	0x2f
> +    0,	//	0x0A	Undefined	
> +    48,	//	0x0B	#define QZ_b	0x30
> +    16,	//	0x0C	#define QZ_q	0x10
> +    17,	//	0x0D	#define QZ_w	0x11
> +    18,	//	0x0E	#define QZ_e	0x12
> +    19,	//	0x0F	#define QZ_r	0x13
> +    21,	//	0x10	#define QZ_y	0x15
> +    20,	//	0x11	#define QZ_t	0x14
> +    2,	//	0x12	#define QZ_1	0x2
> +    3,	//	0x13	#define QZ_2	0x3
> +    4,	//	0x14	#define QZ_3	0x4
> +    5,	//	0x15	#define QZ_4	0x5
> +    7,	//	0x16	#define QZ_6	0x7
> +    6,	//	0x17	#define QZ_5	0x6
> +    13,	//	0x18	#define QZ_EQUALS	0xd
> +    10,	//	0x19	#define QZ_9	0xa
> +    8,	//	0x1A	#define QZ_7	0x8
> +    12,	//	0x1B	#define QZ_MINUS	0xc
> +    9,	//	0x1C	#define QZ_8	0x9
> +    11,	//	0x1D	#define QZ_0	0xb
> +    27,	//	0x1E	#define QZ_RIGHTBRACKET	0x1b
> +    24,	//	0x1F	#define QZ_o	0x18
> +    22,	//	0x20	#define QZ_u	0x16
> +    26,	//	0x21	#define QZ_LEFTBRACKET	0x1a
> +    23,	//	0x22	#define QZ_i	0x17
> +    25,	//	0x23	#define QZ_p	0x19
> +    28,	//	0x24	#define QZ_RETURN	0x1c
> +    38,	//	0x25	#define QZ_l	0x26
> +    36,	//	0x26	#define QZ_j	0x24
> +    40,	//	0x27	#define QZ_QUOTE	0x28
> +    37,	//	0x28	#define QZ_k	0x25
> +    39,	//	0x29	#define QZ_SEMICOLON	0x27
> +    43,	//	0x2A	#define QZ_BACKSLASH	0x2b
> +    51,	//	0x2B	#define QZ_COMMA	0x33
> +    53,	//	0x2C	#define QZ_SLASH	0x35
> +    49,	//	0x2D	#define QZ_n	0x31
> +    50,	//	0x2E	#define QZ_m	0x32
> +    52,	//	0x2F	#define QZ_PERIOD	0x34
> +    15,	//	0x30	#define QZ_TAB	0xf
> +    57,	//	0x31	#define QZ_SPACE	0x39
> +    41,	//	0x32	#define QZ_BACKQUOTE	0x29
> +    14,	//	0x33	#define QZ_BACKSPACE	0xe
> +    0,	//	0x34	Undefined	
> +    1,	//	0x35	#define QZ_ESCAPE	0x1
> +    0,	//	0x36	#define QZ_RMETA	
> +    0,	//	0x37	#define QZ_LMETA	
> +    26,	//	0x38	#define QZ_LSHIFT	0x2a
> +    58,	//	0x39	#define QZ_CAPSLOCK	0x3a
> +    56,	//	0x3A	#define QZ_LALT	0x38
> +    29,	//	0x3B	#define QZ_LCTRL	0x1d
> +    54,	//	0x3C	#define QZ_RSHIFT	0x36
> +    168,	//	0x3D	#define QZ_RALT	0xb8
> +    157,	//	0x3E	#define QZ_RCTRL	0x9d
> +    0,	//	0x3F	Undefined	
> +    0,	//	0x40	Undefined	
> +    0,	//	0x41	Undefined	
> +    0,	//	0x42	Undefined	
> +    55,	//	0x43	#define QZ_KP_MULTIPLY	0x37
> +    78,	//	0x45	#define QZ_KP_PLUS	0x4e
> +    69,	//	0x47	#define QZ_NUMLOCK	0x45
> +    0,	//	0x48	Undefined	
> +    0,	//	0x49	Undefined	
> +    0,	//	0x4A	Undefined	
> +    21,	//	0x4B	#define QZ_KP_DIVIDE	0xb5
> +    152,	//	0x4C	#define QZ_KP_ENTER	0x9c
> +    74,	//	0x4E	#define QZ_KP_MINUS	0x4a
> +    0,	//	0x4F	Undefined	
> +    0,	//	0x50	Undefined	
> +    0,	//	0x51	#define QZ_KP_EQUALS	
> +    82,	//	0x52	#define QZ_KP0	0x52
> +    79,	//	0x53	#define QZ_KP1	0x4f
> +    80,	//	0x54	#define QZ_KP2	0x50
> +    81,	//	0x55	#define QZ_KP3	0x51
> +    76,	//	0x56	#define QZ_KP4	0x4b
> +    77,	//	0x57	#define QZ_KP5	0x4c
> +    78,	//	0x58	#define QZ_KP6	0x4d
> +    71,	//	0x59	#define QZ_KP7	0x47
> +    0,	//	0x5A	Undefined	
> +    72,	//	0x5B	#define QZ_KP8	0x48
> +    73,	//	0x5C	#define QZ_KP9	0x49
> +    0,	//	0x5D	Undefined	
> +    0,	//	0x5E	Undefined	
> +    0,	//	0x5F	Undefined	
> +    63,	//	0x60	#define QZ_F5	0x3f
> +    64,	//	0x61	#define QZ_F6	0x40
> +    65,	//	0x62	#define QZ_F7	0x41
> +    61,	//	0x63	#define QZ_F3	0x3d
> +    66,	//	0x64	#define QZ_F8	0x42
> +    67,	//	0x65	#define QZ_F9	0x43
> +    0,	//	0x66	Undefined	
> +    87,	//	0x67	#define QZ_F11	0x57
> +    0,	//	0x68	Undefined	
> +    23,	//	0x69	#define QZ_PRINT	0xb7
> +    0,	//	0x6A	Undefined	
> +    70,	//	0x6B	#define QZ_SCROLLOCK	0x46
> +    68,	//	0x6D	#define QZ_F10	0x44
> +    0,	//	0x6E	Undefined	
> +    88,	//	0x6F	#define QZ_F12	0x58
> +    0,	//	0x70	Undefined	
> +    110,	//	0x71	#define QZ_PAUSE	0x0
> +    210,	//	0x72	#define QZ_INSERT	0xd2
> +    199,	//	0x73	#define QZ_HOME	0xc7
> +    201,	//	0x74	#define QZ_PAGEUP	0xc9
> +    211,	//	0x75	#define QZ_DELETE	0xd3
> +    62,	//	0x76	#define QZ_F4	0x3e
> +    223,	//	0x77	#define QZ_END	0xcf
> +    60,	//	0x78	#define QZ_F2	0x3c
> +    209,	//	0x79	#define QZ_PAGEDOWN	0xd1
> +    59,	//	0x7A	#define QZ_F1	0x3b
> +    219,	//	0x7B	#define QZ_LEFT	0xcb
> +    221,	//	0x7C	#define QZ_RIGHT	0xcd
> +    208,	//	0x7D	#define QZ_DOWN	0xd0
> +    200,	//	0x7E	#define QZ_UP	0xc8	
>      /* Not completed to finish see  
> http://www.libsdl.org/cgi/cvsweb.cgi/SDL12/src/video/quartz/ 
> SDL_QuartzKeys.h?rev=1.6&content-type=text/x-cvsweb-markup */
>  };
>
> @@ -246,23 +322,33 @@
>      NSDate *distantPast;
>      NSEvent *event;
>      NSAutoreleasePool *pool;
> -    int grab = 1;
>
>      pool = [ [ NSAutoreleasePool alloc ] init ];
>      distantPast = [ NSDate distantPast ];
>
> +    /* release grab when switching windows or pressing ctrl+alt */
> +    if (
> +		//(![ NSApp isActive ]) ||
> +    		(([ [ NSApp currentEvent ] modifierFlags ] & NSControlKeyMask)  
> && ([ [ NSApp currentEvent ] modifierFlags ] & NSAlternateKeyMask))
> +    ) {
> +		grab = 0;
> +		[ window setTitle:@"Qemu" ];
> +   		[ NSCursor unhide ];
> +		CGAssociateMouseAndMouseCursorPosition ( TRUE );
> +    }
> +
>      if (is_active_console(vga_console))
>          vga_update_display();
>      do {
>          event = [ NSApp nextEventMatchingMask:NSAnyEventMask  
> untilDate:distantPast
>                          inMode: NSDefaultRunLoopMode dequeue:YES ];
>          if (event != nil) {
> +
>              switch ([event type]) {
>                  case NSKeyDown:
>                      if(grab)
>                      {
>                          int keycode = cocoa_keycode_to_qemu([event  
> keyCode]);
> -
>                          if (keycode & 0x80)
>                              kbd_put_keycode(0xe0);
>                          kbd_put_keycode(keycode & 0x7f);
> @@ -279,21 +365,91 @@
>                      }
>                      break;
>                  case NSScrollWheel:
> -
> +					if(grab)
> +					{
> +						int dz = [event deltaZ];
> +						kbd_mouse_event(0, 0, dz, 0);
> +					}
> +					break;
>                  case NSLeftMouseDown:
> +					if(grab)
> +					{
> +						int buttons = 0;
> +						if ([ [ NSApp currentEvent ] modifierFlags ] &  
> NSCommandKeyMask) { //leftclick+command simulates rightclick
> +							buttons |= MOUSE_EVENT_RBUTTON;
> +						} else {
> +							buttons |= MOUSE_EVENT_LBUTTON;
> +						}
> +						kbd_mouse_event(0, 0, 0, buttons);
> +					} else {
> +						grab = 1;
> +						[ window setTitle:@"Qemu - Press ctrl + alt to ungrab" ];
> +		       		    [ NSCursor hide ];
> +		    				CGAssociateMouseAndMouseCursorPosition ( FALSE );
> +					}
> +					break;
>                  case NSLeftMouseUp:
> -
> +					if(grab)
> +					{
> +						kbd_mouse_event(0, 0, 0, 0);
> +					}
> +					break;
>                  case NSOtherMouseDown:
>                  case NSRightMouseDown:
> -
> +					if(grab)
> +					{
> +						int buttons = 0;
> +						buttons |= MOUSE_EVENT_RBUTTON;
> +						kbd_mouse_event(0, 0, 0, buttons);
> +					}
> +					break;
>                  case NSOtherMouseUp:
>                  case NSRightMouseUp:
> +					if(grab)
> +					{
> +						kbd_mouse_event(0, 0, 0, 0);
> +					}
> +					break;
>
>                  case NSMouseMoved:
> +					if(grab)
> +					{
> +						int dx, dy, dz, buttons;
> +						dx = [event deltaX];
> +						dy = [event deltaY];
> +						dz = 0;
> +						buttons = 0;
> +						kbd_mouse_event(dx, dy, dz, buttons);
> +					}
> +					break;
>                  case NSOtherMouseDragged:
>                  case NSRightMouseDragged:
> +					if(grab)
> +					{
> +						int dx, dy, dz, buttons;
> +						dx = [event deltaX];
> +						dy = [event deltaY];
> +						dz = 0;
> +						buttons = 0;
> +						buttons |= MOUSE_EVENT_RBUTTON;
> +						kbd_mouse_event(dx, dy, dz, buttons);
> +					}
>                  case NSLeftMouseDragged:
> -
> +					if(grab)
> +					{
> +						int dx, dy, dz, buttons;
> +						dx = [event deltaX];
> +						dy = [event deltaY];
> +						dz = 0;
> +						buttons = 0;
> +						if ([ [ NSApp currentEvent ] modifierFlags ] &  
> NSCommandKeyMask) { //leftclick+command simulates rightclick
> +							buttons |= MOUSE_EVENT_RBUTTON;
> +						} else {
> +							buttons |= MOUSE_EVENT_LBUTTON;
> +						}
> +						kbd_mouse_event(dx, dy, dz, buttons);
> +					}
> +					break;
>                  default: [NSApp sendEvent:event];
>              }
>          }
> @@ -325,6 +481,7 @@
>
>      cocoa_resize(ds, 640, 400);
>
> +
>      atexit(cocoa_cleanup);
>  }
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel

  reply	other threads:[~2005-04-10 11:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-10  2:21 [Qemu-devel] [PATCH] Experimental Cocoa Video Driver Mike Kronenberg
2005-04-10  9:53 ` René Korthaus
2005-04-10 11:09   ` Mike Kronenberg
2005-04-10 12:05     ` René Korthaus [this message]
2005-04-10 13:07       ` Mike Kronenberg
2005-04-10 16:15         ` [Qemu-devel] Cocoa Video Driver & mouse grabbing (was: [PATCH] Experimental Cocoa Video Driver) René Korthaus
2005-04-10 16:50           ` [Qemu-devel] Cocoa Video Driver & mouse grabbing Mike Kronenberg
2005-04-10 17:20             ` Herbert Poetzl
2005-04-10 19:55               ` Jim C. Brown
2005-04-10 20:26                 ` John R. Hogerhuis
2005-04-10 20:39                   ` Thomas Steffen
2005-04-10 21:04                     ` Mike Kronenberg
2005-04-11  1:20                   ` Herbert Poetzl
2005-04-12  7:07               ` Antwort: Re: [Qemu-devel] Cocoa Video Driver & mouse grabbing [Hugo Boss: Virus checked] Michael Hoeller
2005-04-12  8:48                 ` Mike Kronenberg
2005-04-12 14:49                 ` [Qemu-devel] QEMU accelerator Question Michael Hoeller
2005-04-12 14:24                   ` Mark Williamson
2005-04-13  5:36                     ` Michael Hoeller
2005-04-12 10:13                       ` Mark Williamson
2005-04-10 18:18 ` [Qemu-devel] [PATCH] Experimental Cocoa Video Driver Mike Kronenberg
2005-04-11  2:11   ` Mike Kronenberg
  -- strict thread matches above, loose matches on Subject: below --
2005-04-06  2:23 Re: [Qemu-devel] Re: Windows 2000 SP4 (was Re: APM bug) Ben Taylor
2005-04-06  4:25 ` [Qemu-devel] [Patch] Experimental Cocoa Video Driver Mike Kronenberg
2005-04-06  4:29   ` Mike Kronenberg
2005-04-08 17:36   ` Pierre d'Herbemont
2005-02-27  0:04 Pierre d'Herbemont
2005-03-02  0:03 ` David Still
2005-03-02 19:48   ` Pierre d'Herbemont

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=282c26223c172bc5498fe3a2ceb6eb31@cordney.com \
    --to=qemu-dev@cordney.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).