4 * Copyright 1998 Ulrich Weigand
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #ifdef HAVE_LIBXXF86DGA2
25 #include <X11/extensions/xf86dga.h>
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
33 #include "wine/winuser16.h"
37 #include "wine/server.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(cursor);
42 /**********************************************************************/
44 #define NB_BUTTONS 5 /* Windows can handle 3 buttons and the wheel too */
46 static const UINT button_down_flags[NB_BUTTONS] =
49 MOUSEEVENTF_MIDDLEDOWN,
50 MOUSEEVENTF_RIGHTDOWN,
55 static const UINT button_up_flags[NB_BUTTONS] =
66 /***********************************************************************
69 * get the coordinates of a mouse event
71 static inline void get_coords( HWND hwnd, Window window, int x, int y, POINT *pt )
73 struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
77 pt->x = x + data->whole_rect.left;
78 pt->y = y + data->whole_rect.top;
82 /***********************************************************************
85 * Update the button state with what X provides us
87 static void update_button_state( unsigned int state )
89 key_state_table[VK_LBUTTON] = (state & Button1Mask ? 0x80 : 0);
90 key_state_table[VK_MBUTTON] = (state & Button2Mask ? 0x80 : 0);
91 key_state_table[VK_RBUTTON] = (state & Button3Mask ? 0x80 : 0);
95 /***********************************************************************
98 * Update the key state with what X provides us
100 static void update_key_state( unsigned int state )
102 key_state_table[VK_SHIFT] = (state & ShiftMask ? 0x80 : 0);
103 key_state_table[VK_CONTROL] = (state & ControlMask ? 0x80 : 0);
107 /***********************************************************************
110 static WORD get_key_state(void)
114 if (GetSystemMetrics( SM_SWAPBUTTON ))
116 if (key_state_table[VK_RBUTTON] & 0x80) ret |= MK_LBUTTON;
117 if (key_state_table[VK_LBUTTON] & 0x80) ret |= MK_RBUTTON;
121 if (key_state_table[VK_LBUTTON] & 0x80) ret |= MK_LBUTTON;
122 if (key_state_table[VK_RBUTTON] & 0x80) ret |= MK_RBUTTON;
124 if (key_state_table[VK_MBUTTON] & 0x80) ret |= MK_MBUTTON;
125 if (key_state_table[VK_SHIFT] & 0x80) ret |= MK_SHIFT;
126 if (key_state_table[VK_CONTROL] & 0x80) ret |= MK_CONTROL;
127 if (key_state_table[VK_XBUTTON1] & 0x80) ret |= MK_XBUTTON1;
128 if (key_state_table[VK_XBUTTON2] & 0x80) ret |= MK_XBUTTON2;
133 /***********************************************************************
134 * queue_raw_mouse_message
136 static void queue_raw_mouse_message( UINT message, HWND hwnd, DWORD x, DWORD y,
137 DWORD data, DWORD time, DWORD extra_info, UINT injected_flags )
143 hook.mouseData = MAKELONG( 0, data );
144 hook.flags = injected_flags;
146 hook.dwExtraInfo = extra_info;
148 if (HOOK_CallHooks( WH_MOUSE_LL, HC_ACTION, message, (LPARAM)&hook, TRUE )) return;
150 SERVER_START_REQ( send_message )
152 req->id = (injected_flags & LLMHF_INJECTED) ? 0 : GetCurrentThreadId();
153 req->type = MSG_HARDWARE;
157 req->wparam = MAKEWPARAM( get_key_state(), data );
162 req->info = extra_info;
164 req->callback = NULL;
165 wine_server_call( req );
172 /***********************************************************************
173 * X11DRV_send_mouse_input
175 void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, DWORD x, DWORD y,
176 DWORD data, DWORD time, DWORD extra_info, UINT injected_flags )
180 if (flags & MOUSEEVENTF_ABSOLUTE)
182 if (injected_flags & LLMHF_INJECTED)
184 pt.x = (x * screen_width) >> 16;
185 pt.y = (y * screen_height) >> 16;
196 else if (flags & MOUSEEVENTF_MOVE)
198 int accel[3], xMult = 1, yMult = 1;
200 /* dx and dy can be negative numbers for relative movements */
201 SystemParametersInfoW(SPI_GETMOUSE, 0, accel, 0);
203 if (x > accel[0] && accel[2] != 0)
206 if ((x > accel[1]) && (accel[2] == 2)) xMult = 4;
208 if (y > accel[0] && accel[2] != 0)
211 if ((y > accel[1]) && (accel[2] == 2)) yMult = 4;
215 pt.x = cursor_pos.x + (long)x * xMult;
216 pt.y = cursor_pos.y + (long)y * yMult;
218 /* Clip to the current screen size */
219 if (pt.x < 0) pt.x = 0;
220 else if (pt.x >= screen_width) pt.x = screen_width - 1;
221 if (pt.y < 0) pt.y = 0;
222 else if (pt.y >= screen_height) pt.y = screen_height - 1;
233 if (flags & MOUSEEVENTF_MOVE)
235 queue_raw_mouse_message( WM_MOUSEMOVE, hwnd, pt.x, pt.y, data, time,
236 extra_info, injected_flags );
237 if (injected_flags & LLMHF_INJECTED) /* we have to actually move the cursor */
239 TRACE( "warping to (%ld,%ld)\n", pt.x, pt.y );
241 XWarpPointer( thread_display(), root_window, root_window, 0, 0, 0, 0, pt.x, pt.y );
245 if (flags & MOUSEEVENTF_LEFTDOWN)
247 key_state_table[VK_LBUTTON] |= 0xc0;
248 queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON) ? WM_RBUTTONDOWN : WM_LBUTTONDOWN,
249 hwnd, pt.x, pt.y, data, time, extra_info, injected_flags );
251 if (flags & MOUSEEVENTF_LEFTUP)
253 key_state_table[VK_LBUTTON] &= ~0x80;
254 queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON) ? WM_RBUTTONUP : WM_LBUTTONUP,
255 hwnd, pt.x, pt.y, data, time, extra_info, injected_flags );
257 if (flags & MOUSEEVENTF_RIGHTDOWN)
259 key_state_table[VK_RBUTTON] |= 0xc0;
260 queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON) ? WM_LBUTTONDOWN : WM_RBUTTONDOWN,
261 hwnd, pt.x, pt.y, data, time, extra_info, injected_flags );
263 if (flags & MOUSEEVENTF_RIGHTUP)
265 key_state_table[VK_RBUTTON] &= ~0x80;
266 queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON) ? WM_LBUTTONUP : WM_RBUTTONUP,
267 hwnd, pt.x, pt.y, data, time, extra_info, injected_flags );
269 if (flags & MOUSEEVENTF_MIDDLEDOWN)
271 key_state_table[VK_MBUTTON] |= 0xc0;
272 queue_raw_mouse_message( WM_MBUTTONDOWN, hwnd, pt.x, pt.y, data, time,
273 extra_info, injected_flags );
275 if (flags & MOUSEEVENTF_MIDDLEUP)
277 key_state_table[VK_MBUTTON] &= ~0x80;
278 queue_raw_mouse_message( WM_MBUTTONUP, hwnd, pt.x, pt.y, data, time,
279 extra_info, injected_flags );
281 if (flags & MOUSEEVENTF_WHEEL)
283 queue_raw_mouse_message( WM_MOUSEWHEEL, hwnd, pt.x, pt.y, data, time,
284 extra_info, injected_flags );
289 /***********************************************************************
292 * Update the cursor of a window on a mouse event.
294 static void update_cursor( HWND hwnd, Window win )
296 struct x11drv_thread_data *data = x11drv_thread_data();
298 if (data->cursor_window != win)
300 data->cursor_window = win;
302 if (data->cursor) XDefineCursor( data->display, win, data->cursor );
308 /***********************************************************************
311 * Create an X cursor from a Windows one.
313 static Cursor create_cursor( Display *display, CURSORICONINFO *ptr )
315 Pixmap pixmapBits, pixmapMask, pixmapMaskInv, pixmapAll;
317 Cursor cursor = None;
319 if (!ptr) /* Create an empty cursor */
321 static const char data[] = { 0 };
323 bg.red = bg.green = bg.blue = 0x0000;
324 pixmapBits = XCreateBitmapFromData( display, root_window, data, 1, 1 );
327 cursor = XCreatePixmapCursor( display, pixmapBits, pixmapBits,
329 XFreePixmap( display, pixmapBits );
332 else /* Create the X cursor from the bits */
337 TRACE("Bitmap %dx%d planes=%d bpp=%d bytesperline=%d\n",
338 ptr->nWidth, ptr->nHeight, ptr->bPlanes, ptr->bBitsPerPixel,
340 /* Create a pixmap and transfer all the bits to it */
342 /* NOTE: Following hack works, but only because XFree depth
343 * 1 images really use 1 bit/pixel (and so the same layout
344 * as the Windows cursor data). Perhaps use a more generic
347 /* This pixmap will be written with two bitmaps. The first is
348 * the mask and the second is the image.
350 if (!(pixmapAll = XCreatePixmap( display, root_window,
351 ptr->nWidth, ptr->nHeight * 2, 1 )))
353 if (!(image = XCreateImage( display, visual,
354 1, ZPixmap, 0, (char *)(ptr + 1), ptr->nWidth,
355 ptr->nHeight * 2, 16, ptr->nWidthBytes/ptr->bBitsPerPixel)))
357 XFreePixmap( display, pixmapAll );
360 gc = XCreateGC( display, pixmapAll, 0, NULL );
361 XSetGraphicsExposures( display, gc, False );
362 image->byte_order = MSBFirst;
363 image->bitmap_bit_order = MSBFirst;
364 image->bitmap_unit = 16;
365 _XInitImageFuncPtrs(image);
366 if (ptr->bPlanes * ptr->bBitsPerPixel == 1)
368 /* A plain old white on black cursor. */
369 fg.red = fg.green = fg.blue = 0xffff;
370 bg.red = bg.green = bg.blue = 0x0000;
371 XPutImage( display, pixmapAll, gc, image,
372 0, 0, 0, 0, ptr->nWidth, ptr->nHeight * 2 );
376 int rbits, gbits, bbits, red, green, blue;
377 int rfg, gfg, bfg, rbg, gbg, bbg;
378 int rscale, gscale, bscale;
379 int x, y, xmax, ymax, bitIndex, byteIndex, xorIndex;
380 unsigned char *theMask, *theImage, theChar;
381 int threshold, fgBits, bgBits, bitShifted;
382 BYTE pXorBits[128]; /* Up to 32x32 icons */
384 switch (ptr->bBitsPerPixel)
399 FIXME("Currently no support for cursors with %d bits per pixel\n",
401 XFreePixmap( display, pixmapAll );
402 XFreeGC( display, gc );
404 XDestroyImage( image );
407 /* The location of the mask. */
408 theMask = (char *)(ptr + 1);
409 /* The mask should still be 1 bit per pixel. The color image
410 * should immediately follow the mask.
412 theImage = &theMask[ptr->nWidth/8 * ptr->nHeight];
413 rfg = gfg = bfg = rbg = gbg = bbg = 0;
419 xmax = (ptr->nWidth > 32) ? 32 : ptr->nWidth;
420 if (ptr->nWidth > 32) {
421 ERR("Got a %dx%d cursor. Cannot handle larger than 32x32.\n",
422 ptr->nWidth, ptr->nHeight);
424 ymax = (ptr->nHeight > 32) ? 32 : ptr->nHeight;
426 memset(pXorBits, 0, 128);
427 for (y=0; y<ymax; y++)
429 for (x=0; x<xmax; x++)
431 red = green = blue = 0;
432 switch (ptr->bBitsPerPixel)
435 theChar = theImage[byteIndex++];
437 theChar = theImage[byteIndex++];
439 theChar = theImage[byteIndex++];
443 theChar = theImage[byteIndex++];
444 blue = theChar & 0x1F;
445 green = (theChar & 0xE0) >> 5;
446 theChar = theImage[byteIndex++];
447 green |= (theChar & 0x07) << 3;
448 red = (theChar & 0xF8) >> 3;
452 if (red+green+blue > threshold)
458 pXorBits[xorIndex] |= bitShifted;
472 bitShifted = bitShifted << 1;
475 rscale = 1 << (16 - rbits);
476 gscale = 1 << (16 - gbits);
477 bscale = 1 << (16 - bbits);
480 fg.red = rfg * rscale / fgBits;
481 fg.green = gfg * gscale / fgBits;
482 fg.blue = bfg * bscale / fgBits;
484 else fg.red = fg.green = fg.blue = 0;
485 bgBits = xmax * ymax - fgBits;
488 bg.red = rbg * rscale / bgBits;
489 bg.green = gbg * gscale / bgBits;
490 bg.blue = bbg * bscale / bgBits;
492 else bg.red = bg.green = bg.blue = 0;
493 pixmapBits = XCreateBitmapFromData( display, root_window, pXorBits, xmax, ymax );
496 XFreePixmap( display, pixmapAll );
497 XFreeGC( display, gc );
499 XDestroyImage( image );
504 XPutImage( display, pixmapAll, gc, image,
505 0, 0, 0, 0, ptr->nWidth, ptr->nHeight );
506 XSetFunction( display, gc, GXcopy );
508 XCopyArea( display, pixmapBits, pixmapAll, gc,
509 0, 0, xmax, ymax, 0, ptr->nHeight );
510 XFreePixmap( display, pixmapBits );
513 XDestroyImage( image );
515 /* Now create the 2 pixmaps for bits and mask */
517 pixmapBits = XCreatePixmap( display, root_window, ptr->nWidth, ptr->nHeight, 1 );
518 pixmapMask = XCreatePixmap( display, root_window, ptr->nWidth, ptr->nHeight, 1 );
519 pixmapMaskInv = XCreatePixmap( display, root_window, ptr->nWidth, ptr->nHeight, 1 );
521 /* Make sure everything went OK so far */
523 if (pixmapBits && pixmapMask && pixmapMaskInv)
527 /* We have to do some magic here, as cursors are not fully
528 * compatible between Windows and X11. Under X11, there
529 * are only 3 possible color cursor: black, white and
530 * masked. So we map the 4th Windows color (invert the
531 * bits on the screen) to black and an additional white bit on
532 * an other place (+1,+1). This require some boolean arithmetic:
535 * And Xor Result | Bits Mask Result
536 * 0 0 black | 0 1 background
537 * 0 1 white | 1 1 foreground
538 * 1 0 no change | X 0 no change
539 * 1 1 inverted | 0 1 background
542 * Bits = not 'And' and 'Xor' or 'And2' and 'Xor2'
543 * Mask = not 'And' or 'Xor' or 'And2' and 'Xor2'
545 * FIXME: apparently some servers do support 'inverted' color.
546 * I don't know if it's correct per the X spec, but maybe
547 * we ought to take advantage of it. -- AJ
549 XSetFunction( display, gc, GXcopy );
550 XCopyArea( display, pixmapAll, pixmapBits, gc,
551 0, 0, ptr->nWidth, ptr->nHeight, 0, 0 );
552 XCopyArea( display, pixmapAll, pixmapMask, gc,
553 0, 0, ptr->nWidth, ptr->nHeight, 0, 0 );
554 XCopyArea( display, pixmapAll, pixmapMaskInv, gc,
555 0, 0, ptr->nWidth, ptr->nHeight, 0, 0 );
556 XSetFunction( display, gc, GXand );
557 XCopyArea( display, pixmapAll, pixmapMaskInv, gc,
558 0, ptr->nHeight, ptr->nWidth, ptr->nHeight, 0, 0 );
559 XSetFunction( display, gc, GXandReverse );
560 XCopyArea( display, pixmapAll, pixmapBits, gc,
561 0, ptr->nHeight, ptr->nWidth, ptr->nHeight, 0, 0 );
562 XSetFunction( display, gc, GXorReverse );
563 XCopyArea( display, pixmapAll, pixmapMask, gc,
564 0, ptr->nHeight, ptr->nWidth, ptr->nHeight, 0, 0 );
565 /* Additional white */
566 XSetFunction( display, gc, GXor );
567 XCopyArea( display, pixmapMaskInv, pixmapMask, gc,
568 0, 0, ptr->nWidth, ptr->nHeight, 1, 1 );
569 XCopyArea( display, pixmapMaskInv, pixmapBits, gc,
570 0, 0, ptr->nWidth, ptr->nHeight, 1, 1 );
571 XSetFunction( display, gc, GXcopy );
573 /* Make sure hotspot is valid */
574 hotspot.x = ptr->ptHotSpot.x;
575 hotspot.y = ptr->ptHotSpot.y;
576 if (hotspot.x < 0 || hotspot.x >= ptr->nWidth ||
577 hotspot.y < 0 || hotspot.y >= ptr->nHeight)
579 hotspot.x = ptr->nWidth / 2;
580 hotspot.y = ptr->nHeight / 2;
582 cursor = XCreatePixmapCursor( display, pixmapBits, pixmapMask,
583 &fg, &bg, hotspot.x, hotspot.y );
586 /* Now free everything */
588 if (pixmapAll) XFreePixmap( display, pixmapAll );
589 if (pixmapBits) XFreePixmap( display, pixmapBits );
590 if (pixmapMask) XFreePixmap( display, pixmapMask );
591 if (pixmapMaskInv) XFreePixmap( display, pixmapMaskInv );
592 XFreeGC( display, gc );
598 /***********************************************************************
599 * SetCursor (X11DRV.@)
601 void X11DRV_SetCursor( CURSORICONINFO *lpCursor )
605 if (root_window != DefaultRootWindow(gdi_display))
607 /* If in desktop mode, set the cursor on the desktop window */
610 cursor = create_cursor( gdi_display, lpCursor );
613 XDefineCursor( gdi_display, root_window, cursor );
614 /* Make the change take effect immediately */
616 XFreeCursor( gdi_display, cursor );
620 else /* set the same cursor for all top-level windows of the current thread */
622 struct x11drv_thread_data *data = x11drv_thread_data();
625 cursor = create_cursor( data->display, lpCursor );
628 if (data->cursor) XFreeCursor( data->display, data->cursor );
629 data->cursor = cursor;
630 if (data->cursor_window)
632 XDefineCursor( data->display, data->cursor_window, cursor );
633 /* Make the change take effect immediately */
634 XFlush( data->display );
641 /***********************************************************************
642 * SetCursorPos (X11DRV.@)
644 BOOL X11DRV_SetCursorPos( INT x, INT y )
646 Display *display = thread_display();
648 TRACE( "warping to (%d,%d)\n", x, y );
651 XWarpPointer( display, root_window, root_window, 0, 0, 0, 0, x, y );
658 /***********************************************************************
659 * GetCursorPos (X11DRV.@)
661 BOOL X11DRV_GetCursorPos(LPPOINT pos)
663 Display *display = thread_display();
665 int rootX, rootY, winX, winY;
669 if (XQueryPointer( display, root_window, &root, &child,
670 &rootX, &rootY, &winX, &winY, &xstate ))
672 update_key_state( xstate );
673 update_button_state( xstate );
674 TRACE("pointer at (%d,%d)\n", winX, winY );
683 /***********************************************************************
686 void X11DRV_ButtonPress( HWND hwnd, XEvent *xev )
688 XButtonEvent *event = &xev->xbutton;
689 int buttonNum = event->button - 1;
693 if (buttonNum >= NB_BUTTONS) return;
696 update_cursor( hwnd, event->window );
697 get_coords( hwnd, event->window, event->x, event->y, &pt );
705 wData = -WHEEL_DELTA;
708 update_key_state( event->state );
709 X11DRV_send_mouse_input( hwnd, button_down_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE,
710 pt.x, pt.y, wData, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
714 /***********************************************************************
715 * X11DRV_ButtonRelease
717 void X11DRV_ButtonRelease( HWND hwnd, XEvent *xev )
719 XButtonEvent *event = &xev->xbutton;
720 int buttonNum = event->button - 1;
723 if (buttonNum >= NB_BUTTONS || !button_up_flags[buttonNum]) return;
726 update_cursor( hwnd, event->window );
727 get_coords( hwnd, event->window, event->x, event->y, &pt );
728 update_key_state( event->state );
729 X11DRV_send_mouse_input( hwnd, button_up_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE,
730 pt.x, pt.y, 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
734 /***********************************************************************
735 * X11DRV_MotionNotify
737 void X11DRV_MotionNotify( HWND hwnd, XEvent *xev )
739 XMotionEvent *event = &xev->xmotion;
742 TRACE("hwnd %p, event->is_hint %d\n", hwnd, event->is_hint);
746 update_cursor( hwnd, event->window );
747 get_coords( hwnd, event->window, event->x, event->y, &pt );
748 update_key_state( event->state );
749 X11DRV_send_mouse_input( hwnd, MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
750 pt.x, pt.y, 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
754 /***********************************************************************
757 void X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
759 XCrossingEvent *event = &xev->xcrossing;
762 TRACE("hwnd %p, event->detail %d\n", hwnd, event->detail);
765 if (event->detail == NotifyVirtual || event->detail == NotifyNonlinearVirtual) return;
767 /* simulate a mouse motion event */
768 update_cursor( hwnd, event->window );
769 get_coords( hwnd, event->window, event->x, event->y, &pt );
770 update_key_state( event->state );
771 X11DRV_send_mouse_input( hwnd, MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
772 pt.x, pt.y, 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
776 #ifdef HAVE_LIBXXF86DGA2
780 /**********************************************************************
781 * X11DRV_DGAMotionEvent
783 void X11DRV_DGAMotionEvent( HWND hwnd, XEvent *xev )
785 XDGAMotionEvent *event = (XDGAMotionEvent *)xev;
786 update_key_state( event->state );
787 X11DRV_send_mouse_input( DGAhwnd, MOUSEEVENTF_MOVE, event->dx, event->dy,
788 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
791 /**********************************************************************
792 * X11DRV_DGAButtonPressEvent
794 void X11DRV_DGAButtonPressEvent( HWND hwnd, XEvent *xev )
796 XDGAButtonEvent *event = (XDGAButtonEvent *)xev;
797 int buttonNum = event->button - 1;
799 if (buttonNum >= NB_BUTTONS) return;
800 update_key_state( event->state );
801 X11DRV_send_mouse_input( DGAhwnd, button_down_flags[buttonNum], 0, 0,
802 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
805 /**********************************************************************
806 * X11DRV_DGAButtonReleaseEvent
808 void X11DRV_DGAButtonReleaseEvent( HWND hwnd, XEvent *xev )
810 XDGAButtonEvent *event = (XDGAButtonEvent *)xev;
811 int buttonNum = event->button - 1;
813 if (buttonNum >= NB_BUTTONS) return;
814 update_key_state( event->state );
815 X11DRV_send_mouse_input( DGAhwnd, button_up_flags[buttonNum], 0, 0,
816 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
819 #endif /* HAVE_LIBXXF86DGA2 */