summaryrefslogtreecommitdiffstats
path: root/meta/packages/qemu/files/qemu-x-no-sdl.patch
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2007-06-13 11:55:58 +0000
committerRichard Purdie <richard@openedhand.com>2007-06-13 11:55:58 +0000
commitc6a97a06968d062b742d458f86cb8fbf6ab63e99 (patch)
tree3b684d87ce2dcf944ddb0acf1a6c609c9b22036a /meta/packages/qemu/files/qemu-x-no-sdl.patch
parent4b747705b4adc0085f131e2b6bd8f01fe306e59b (diff)
downloadpoky-c6a97a06968d062b742d458f86cb8fbf6ab63e99.tar.gz
qemu: Update to a recent version
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1923 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages/qemu/files/qemu-x-no-sdl.patch')
-rw-r--r--meta/packages/qemu/files/qemu-x-no-sdl.patch630
1 files changed, 0 insertions, 630 deletions
diff --git a/meta/packages/qemu/files/qemu-x-no-sdl.patch b/meta/packages/qemu/files/qemu-x-no-sdl.patch
deleted file mode 100644
index eb00d9806b..0000000000
--- a/meta/packages/qemu/files/qemu-x-no-sdl.patch
+++ /dev/null
@@ -1,630 +0,0 @@
1diff -urN qemu-0.8.2/configure qemu-0.8.2-x/configure
2--- qemu-0.8.2/configure 2006-07-22 18:23:34.000000000 +0100
3+++ qemu-0.8.2-x/configure 2006-08-24 14:24:33.000000000 +0100
4@@ -492,6 +492,21 @@
5 fi # cross compilation
6 fi # -z $sdl
7
8+##########################################
9+# X Probe
10+
11+x11=no
12+if test -z "$sdl" || test "$sdl" = "no"; then
13+ x11=yes
14+fi
15+
16+if test "$x11" = "yes"; then
17+ x11=no
18+ if `pkg-config --exists x11 xext`; then
19+ x11=yes
20+ fi
21+fi
22+
23 # Check if tools are available to build documentation.
24 if [ -x "`which texi2html`" ] && [ -x "`which pod2man`" ]; then
25 build_docs="yes"
26@@ -540,6 +555,7 @@
27 if test "$sdl" != "no" ; then
28 echo "SDL static link $sdl_static"
29 fi
30+echo "X11 support $x11"
31 echo "mingw32 support $mingw32"
32 echo "Adlib support $adlib"
33 echo "CoreAudio support $coreaudio"
34@@ -748,14 +764,14 @@
35 fi
36
37 if test "$target_user_only" = "no" -a "$check_gfx" = "yes" \
38- -a "$sdl" = "no" -a "$cocoa" = "no" ; then
39+ -a "$sdl" = "no" -a "$x11" = "no" -a "$cocoa" = "no" ; then
40 echo "ERROR: QEMU requires SDL or Cocoa for graphical output"
41 echo "To build QEMU without graphical output configure with --disable-gfx-check"
42 echo "Note that this will disable all output from the virtual graphics card."
43 exit 1;
44 fi
45
46-#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
47+echo "Creating $config_mak, $config_h and $target_dir/Makefile"
48
49 mkdir -p $target_dir
50 mkdir -p $target_dir/fpu
51@@ -882,6 +898,14 @@
52 fi
53 fi
54
55+# x11
56+if test "$x11" = "yes"; then
57+ echo "#define CONFIG_X11 1" >> $config_h
58+ echo "CONFIG_X11=yes" >> $config_mak
59+ echo "X11_LIBS=`pkg-config --libs x11 xext`" >> $config_mak
60+ echo "X11_CFLAGS=`pkg-config --cflags x11 xext`" >> $config_mak
61+fi
62+
63 if test "$cocoa" = "yes" ; then
64 echo "#define CONFIG_COCOA 1" >> $config_h
65 echo "CONFIG_COCOA=yes" >> $config_mak
66diff -urN qemu-0.8.2/Makefile.target qemu-0.8.2-x/Makefile.target
67--- qemu-0.8.2/Makefile.target 2006-07-22 18:23:34.000000000 +0100
68+++ qemu-0.8.2-x/Makefile.target 2006-08-23 14:47:17.000000000 +0100
69@@ -376,6 +376,9 @@
70 ifdef CONFIG_SDL
71 VL_OBJS+=sdl.o
72 endif
73+ifdef CONFIG_X11
74+VL_OBJS+=x.o
75+endif
76 VL_OBJS+=vnc.o
77 ifdef CONFIG_COCOA
78 VL_OBJS+=cocoa.o
79@@ -426,7 +429,7 @@
80 endif
81
82 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
83- $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
84+ $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(X11_LIBS) $(COCOA_LIBS) $(VL_LIBS)
85
86 cocoa.o: cocoa.m
87 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
88@@ -434,6 +437,10 @@
89 sdl.o: sdl.c keymaps.c sdl_keysym.h
90 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
91
92+x.o: x.c keymaps.c
93+ $(CC) $(CFLAGS) $(DEFINES) $(X11_CFLAGS) -c -o $@ $<
94+
95+
96 vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h
97 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
98
99diff -urN qemu-0.8.2/vl.c qemu-0.8.2-x/vl.c
100--- qemu-0.8.2/vl.c 2006-07-22 18:23:34.000000000 +0100
101+++ qemu-0.8.2-x/vl.c 2006-09-29 18:58:26.000000000 +0100
102@@ -5217,6 +5217,9 @@
103 #ifdef USE_CODE_COPY
104 "-no-code-copy disable code copy acceleration\n"
105 #endif
106+#if defined(CONFIG_X11)
107+ "-parent xid Use pre-existing window as qemu output window\n"
108+#endif
109 #ifdef TARGET_I386
110 "-std-vga simulate a standard VGA card with VESA Bochs Extensions\n"
111 " (default is CL-GD5446 PCI VGA)\n"
112@@ -5302,6 +5305,8 @@
113 QEMU_OPTION_smp,
114 QEMU_OPTION_vnc,
115 QEMU_OPTION_no_acpi,
116+
117+ QEMU_OPTION_parent_xid,
118 };
119
120 typedef struct QEMUOption {
121@@ -5361,6 +5366,9 @@
122 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
123 { "g", 1, QEMU_OPTION_g },
124 #endif
125+#if defined(CONFIG_X11)
126+ { "parent", HAS_ARG, QEMU_OPTION_parent_xid },
127+#endif
128 { "localtime", 0, QEMU_OPTION_localtime },
129 { "std-vga", 0, QEMU_OPTION_std_vga },
130 { "monitor", 1, QEMU_OPTION_monitor },
131@@ -5608,6 +5616,10 @@
132 char usb_devices[MAX_USB_CMDLINE][128];
133 int usb_devices_index;
134
135+#if defined(CONFIG_X11)
136+ unsigned long parent_xid = 0;
137+#endif
138+
139 LIST_INIT (&vm_change_state_head);
140 #ifndef _WIN32
141 {
142@@ -6021,6 +6033,11 @@
143 case QEMU_OPTION_no_acpi:
144 acpi_enabled = 0;
145 break;
146+#if defined(CONFIG_X11)
147+ case QEMU_OPTION_parent_xid:
148+ parent_xid = strtol(optarg, NULL, 0);
149+ break;
150+#endif
151 }
152 }
153 }
154@@ -6142,6 +6159,8 @@
155 sdl_display_init(ds, full_screen);
156 #elif defined(CONFIG_COCOA)
157 cocoa_display_init(ds, full_screen);
158+#elif defined(CONFIG_X11)
159+ x_display_init(ds, full_screen, parent_xid);
160 #else
161 dumb_display_init(ds);
162 #endif
163diff -urN qemu-0.8.2/vl.h qemu-0.8.2-x/vl.h
164--- qemu-0.8.2/vl.h 2006-07-22 18:23:34.000000000 +0100
165+++ qemu-0.8.2-x/vl.h 2006-09-29 18:35:32.000000000 +0100
166@@ -767,6 +767,9 @@
167 /* vnc.c */
168 void vnc_display_init(DisplayState *ds, int display);
169
170+/* x.c */
171+void x_display_init(DisplayState *ds, int display, unsigned long parent_xid);
172+
173 /* ide.c */
174 #define MAX_DISKS 4
175
176diff -urN qemu-0.8.2/x.c qemu-0.8.2-x/x.c
177--- qemu-0.8.2/x.c 1970-01-01 01:00:00.000000000 +0100
178+++ qemu-0.8.2-x/x.c 2006-09-29 18:35:02.000000000 +0100
179@@ -0,0 +1,451 @@
180+#include "vl.h"
181+
182+#include <X11/Xlib.h>
183+#include <X11/Xutil.h>
184+#include <X11/Xatom.h>
185+#include <X11/keysym.h>
186+#include <X11/extensions/XShm.h>
187+
188+#include <sys/ipc.h>
189+#include <sys/shm.h>
190+
191+typedef struct XHostScreen
192+{
193+ Display *xdpy;
194+ int xscreen;
195+ Visual *xvisual;
196+ Window xwin, xwinroot;
197+ GC xgc;
198+ int xdepth;
199+ XImage *ximg;
200+ int xwin_width, xwin_height;
201+ Bool use_fullscreen;
202+ Bool have_shm;
203+ unsigned char *fb_data;
204+ unsigned long cmap[256];
205+ XShmSegmentInfo shminfo;
206+}
207+XHostScreen;
208+
209+static XHostScreen *xscreen;
210+static int trapped_error_code = 0;
211+static int (*old_error_handler) (Display *d, XErrorEvent *e);
212+
213+static void
214+x_update(DisplayState *ds, int x, int y, int w, int h);
215+
216+static int
217+error_handler(Display *display,
218+ XErrorEvent *error)
219+{
220+ trapped_error_code = error->error_code;
221+ return 0;
222+}
223+
224+static void
225+x_errors_trap(void)
226+{
227+ trapped_error_code = 0;
228+ old_error_handler = XSetErrorHandler(error_handler);
229+}
230+
231+static int
232+x_errors_untrap(void)
233+{
234+ XSetErrorHandler(old_error_handler);
235+ return trapped_error_code;
236+}
237+
238+static void
239+x_update(DisplayState *ds, int x, int y, int w, int h)
240+{
241+ if (xscreen->have_shm)
242+ {
243+ XShmPutImage(xscreen->xdpy, xscreen->xwin, xscreen->xgc, xscreen->ximg,
244+ x, y, x, y, w, h, False);
245+ }
246+ else
247+ {
248+ XPutImage(xscreen->xdpy, xscreen->xwin, xscreen->xgc, xscreen->ximg,
249+ x, y, x, y, w, h);
250+ }
251+
252+ XSync(xscreen->xdpy, False);
253+}
254+
255+static void
256+x_resize(DisplayState *ds, int w, int h)
257+{
258+ Bool shm_success = False;
259+ int bitmap_pad;
260+ XSizeHints *size_hints;
261+
262+ if (xscreen->ximg != NULL)
263+ {
264+ if (xscreen->have_shm)
265+ {
266+ XShmDetach(xscreen->xdpy, &xscreen->shminfo);
267+ XDestroyImage (xscreen->ximg);
268+ shmdt(xscreen->shminfo.shmaddr);
269+ shmctl(xscreen->shminfo.shmid, IPC_RMID, 0);
270+ }
271+ else
272+ {
273+ if (xscreen->ximg->data)
274+ {
275+ free(xscreen->ximg->data);
276+ xscreen->ximg->data = NULL;
277+ }
278+
279+ XDestroyImage(xscreen->ximg);
280+ }
281+ }
282+
283+ if (xscreen->have_shm)
284+ {
285+ xscreen->ximg = XShmCreateImage(xscreen->xdpy,
286+ xscreen->xvisual,
287+ xscreen->xdepth,
288+ ZPixmap,
289+ NULL,
290+ &xscreen->shminfo,
291+ w, h );
292+
293+ xscreen->shminfo.shmid
294+ = shmget(IPC_PRIVATE,
295+ xscreen->ximg->bytes_per_line * h,
296+ IPC_CREAT|0777);
297+ xscreen->shminfo.shmaddr = xscreen->ximg->data
298+ = shmat(xscreen->shminfo.shmid, 0, 0);
299+
300+ if (xscreen->ximg->data == (char *)-1)
301+ {
302+ xscreen->have_shm = False;
303+ XDestroyImage(xscreen->ximg);
304+ shmctl(xscreen->shminfo.shmid, IPC_RMID, 0);
305+ }
306+ else
307+ {
308+ xscreen->shminfo.readOnly = False;
309+ XShmAttach(xscreen->xdpy, &xscreen->shminfo);
310+ shm_success = True;
311+ }
312+ }
313+
314+ if (!shm_success)
315+ {
316+ bitmap_pad = ( xscreen->xdepth > 16 ) ?
317+ 32 : (( xscreen->xdepth > 8 )? 16 : 8 );
318+
319+ xscreen->ximg = XCreateImage( xscreen->xdpy,
320+ xscreen->xvisual,
321+ xscreen->xdepth,
322+ ZPixmap, 0, 0,
323+ w,
324+ h,
325+ bitmap_pad,
326+ 0);
327+
328+ xscreen->ximg->data
329+ = malloc( xscreen->ximg->bytes_per_line * h );
330+ }
331+
332+ XResizeWindow(xscreen->xdpy, xscreen->xwin, w, h);
333+
334+ /* Ask the WM to keep our size static */
335+ size_hints = XAllocSizeHints();
336+ size_hints->max_width = size_hints->min_width = w;
337+ size_hints->max_height = size_hints->min_height = h;
338+ size_hints->flags = PMinSize|PMaxSize;
339+ XSetWMNormalHints(xscreen->xdpy, xscreen->xwin, size_hints);
340+ XFree(size_hints);
341+
342+ XMapWindow(xscreen->xdpy, xscreen->xwin);
343+
344+ XSync(xscreen->xdpy, False);
345+
346+ xscreen->xwin_width = w;
347+ xscreen->xwin_height = h;
348+
349+ if (1) // (ds->depth == xscreen->xdepth)
350+ {
351+ ds->data = xscreen->ximg->data;
352+ }
353+ else
354+ {
355+ xscreen->fb_data = malloc(w*h*(ds->depth>>3));
356+ ds->data = xscreen->fb_data;
357+ }
358+
359+ ds->linesize = xscreen->ximg->bytes_per_line;
360+ ds->depth = (xscreen->xdepth >= 24) ? 32 : xscreen->xdepth;
361+ ds->bgr = 0;
362+
363+#if 0
364+ if (ds->depth == 32 && screen->format->Rshift == 0) {
365+ ds->bgr = 1;
366+ } else {
367+ ds->bgr = 0;
368+ }
369+#endif
370+
371+ ds->width = w;
372+ ds->height = h;
373+
374+}
375+
376+static void
377+x_refresh(DisplayState *ds)
378+{
379+ vga_hw_update();
380+}
381+
382+static int
383+x_listen_poll(void *opaque)
384+{
385+ return XPending(xscreen->xdpy);
386+}
387+
388+static void
389+x_grab(void)
390+{
391+ static Bool grab = False;
392+
393+ if (!grab)
394+ {
395+ if (XGrabPointer (xscreen->xdpy, xscreen->xwin,
396+ True,
397+ NoEventMask,
398+ GrabModeAsync,
399+ GrabModeAsync,
400+ xscreen->xwin, None, CurrentTime) == 0
401+ && XGrabKeyboard (xscreen->xdpy, xscreen->xwin, True,
402+ GrabModeAsync,
403+ GrabModeAsync,
404+ CurrentTime) == 0)
405+ {
406+ grab = True;
407+ XStoreName(xscreen->xdpy, xscreen->xwin,
408+ "QEmu (ctrl+shift releases mouse and keyboard )");
409+ }
410+ }
411+ else
412+ {
413+ XUngrabPointer (xscreen->xdpy, CurrentTime);
414+ XUngrabKeyboard (xscreen->xdpy, CurrentTime);
415+ grab = False;
416+ XStoreName(xscreen->xdpy, xscreen->xwin,
417+ "QEmu (ctrl+shift grabs mouse and keyboard )");
418+ }
419+}
420+
421+static void
422+x_listen_read(void *opaque)
423+{
424+ XEvent xev;
425+ DisplayState *ds = opaque;
426+ Bool grabbed = False;
427+ static int last_x = 0, last_y = 0, button_state = 0, state;
428+
429+ if (XPending(xscreen->xdpy))
430+ {
431+ XNextEvent(xscreen->xdpy, &xev);
432+
433+ switch (xev.type)
434+ {
435+ case EnterNotify:
436+ case LeaveNotify:
437+ break;
438+ case FocusIn:
439+ if (!kbd_mouse_is_absolute())
440+ x_grab();
441+ break;
442+ case FocusOut:
443+ break;
444+ case Expose:
445+ while (XCheckTypedWindowEvent(xscreen->xdpy, xev.xexpose.window,
446+ Expose, &xev));
447+ x_update(ds, 0, 0,
448+ xscreen->xwin_width,
449+ xscreen->xwin_height);
450+ break;
451+ case KeyRelease:
452+ if ((XKeycodeToKeysym(xscreen->xdpy,
453+ xev.xkey.keycode,0) == XK_Shift_L
454+ || XKeycodeToKeysym(xscreen->xdpy,
455+ xev.xkey.keycode,0) == XK_Shift_R)
456+ && (xev.xkey.state & ControlMask))
457+ {
458+ x_grab();
459+ break;
460+ }
461+ case KeyPress:
462+ {
463+ int keycode = xev.xkey.keycode-8; /* X adds 8 to keycode */
464+
465+ /* FIXME: LUT needed here me thinks */
466+
467+ if (keycode & 0x80) /* Extended */
468+ kbd_put_keycode(0xe0);
469+
470+ if (xev.type == KeyPress)
471+ kbd_put_keycode(keycode & 0x7f);
472+ else
473+ kbd_put_keycode(keycode | 0x80);
474+ }
475+ break;
476+ case ButtonPress:
477+ case ButtonRelease:
478+ case MotionNotify:
479+ {
480+ int ev_state, ev_x, ev_y, dx, dy;
481+
482+ state = 0;
483+
484+ if (xev.type == MotionNotify)
485+ {
486+ ev_state = xev.xmotion.state;
487+ ev_x = xev.xmotion.x;
488+ ev_y = xev.xmotion.y;
489+
490+ if (ev_state & Button1Mask)
491+ state |= MOUSE_EVENT_LBUTTON;
492+ if (ev_state & Button2Mask)
493+ state |= MOUSE_EVENT_RBUTTON;
494+ if (ev_state & Button3Mask)
495+ state |= MOUSE_EVENT_MBUTTON;
496+
497+ /* Touchscreen dont send motion notifys */
498+ if (kbd_mouse_is_absolute() && state == 0)
499+ break;
500+ }
501+ else
502+ {
503+ ev_state = xev.xbutton.state;
504+ ev_x = xev.xbutton.x;
505+ ev_y = xev.xbutton.y;
506+
507+ if (xev.type == ButtonPress)
508+ {
509+ if (xev.xbutton.button == Button1)
510+ state |= MOUSE_EVENT_LBUTTON;
511+ if (xev.xbutton.state == Button1)
512+ state |= MOUSE_EVENT_RBUTTON;
513+ if (xev.xbutton.state & Button3)
514+ state |= MOUSE_EVENT_MBUTTON;
515+ }
516+ }
517+
518+ if (kbd_mouse_is_absolute())
519+ {
520+ dx = ev_x * 0x7FFF / xscreen->xwin_width;
521+ dy = ev_y * 0x7FFF / xscreen->xwin_height;
522+ }
523+ else
524+ {
525+ dx = ev_x - last_x;
526+ dy = ev_y - last_y;
527+ }
528+
529+ kbd_mouse_event(dx, dy, 0, state);
530+
531+ last_x = ev_x;
532+ last_y = ev_y;
533+ }
534+ break;
535+ default:
536+ break;
537+
538+ }
539+ }
540+ return;
541+}
542+
543+void
544+x_display_init(DisplayState *ds, int full_screen, unsigned long parent_xid)
545+{
546+ Cursor empty_cursor;
547+ Pixmap cursor_pxm;
548+ XColor col;
549+ XSetWindowAttributes attr;
550+
551+ xscreen = malloc(sizeof(XHostScreen));
552+ memset(xscreen, 0, sizeof(XHostScreen));
553+
554+ if ((xscreen->xdpy = XOpenDisplay(getenv("DISPLAY"))) == NULL)
555+ {
556+ fprintf(stderr, "\nqemu cannot open host display. Is DISPLAY set?\n");
557+ exit(-1);
558+ }
559+
560+ xscreen->xscreen = DefaultScreen(xscreen->xdpy);
561+ xscreen->xwinroot = RootWindow(xscreen->xdpy, xscreen->xscreen);
562+ xscreen->xgc = XCreateGC(xscreen->xdpy, xscreen->xwinroot, 0, NULL);
563+ xscreen->xdepth = DefaultDepth(xscreen->xdpy, xscreen->xscreen);
564+ xscreen->xvisual = DefaultVisual(xscreen->xdpy, xscreen->xscreen);
565+
566+ attr.event_mask = ButtonPressMask|ButtonReleaseMask|PointerMotionMask
567+ |KeyPressMask|KeyReleaseMask|ExposureMask
568+ |FocusChangeMask|EnterWindowMask|LeaveWindowMask;
569+
570+ xscreen->xwin = XCreateWindow(xscreen->xdpy,
571+ xscreen->xwinroot,
572+ 0,0,640,480,
573+ 0,
574+ CopyFromParent,
575+ CopyFromParent,
576+ CopyFromParent,
577+ CWEventMask,
578+ &attr);
579+
580+ xscreen->have_shm = True;
581+
582+ if (!XShmQueryExtension(xscreen->xdpy) || getenv("QEMU_X_NO_SHM"))
583+ {
584+ xscreen->have_shm = False;
585+ }
586+ else
587+ {
588+ XShmSegmentInfo shminfo;
589+
590+ shminfo.shmid=shmget(IPC_PRIVATE, 1, IPC_CREAT|0777);
591+ shminfo.shmaddr=shmat(shminfo.shmid,0,0);
592+ shminfo.readOnly=True;
593+
594+ x_errors_trap();
595+
596+ XShmAttach(xscreen->xdpy, &shminfo);
597+ XSync(xscreen->xdpy, False);
598+
599+ if (x_errors_untrap())
600+ {
601+ fprintf(stderr, "QEmu unable to use SHM XImages\n");
602+ xscreen->have_shm = False;
603+ }
604+
605+ shmdt(shminfo.shmaddr);
606+ shmctl(shminfo.shmid, IPC_RMID, 0);
607+ }
608+
609+ if (!kbd_mouse_is_absolute())
610+ {
611+ /* Only hide cursor if were not a touchscreen */
612+ cursor_pxm = XCreatePixmap (xscreen->xdpy, xscreen->xwinroot, 1, 1, 1);
613+ memset (&col, 0, sizeof (col));
614+ empty_cursor = XCreatePixmapCursor (xscreen->xdpy,
615+ cursor_pxm, cursor_pxm,
616+ &col, &col, 1, 1);
617+ XDefineCursor (xscreen->xdpy, xscreen->xwin, empty_cursor);
618+ XFreePixmap (xscreen->xdpy, cursor_pxm);
619+ }
620+
621+ ds->dpy_update = x_update;
622+ ds->dpy_resize = x_resize;
623+ ds->dpy_refresh = x_refresh;
624+
625+ if ((qemu_set_fd_handler2 (ConnectionNumber(xscreen->xdpy),
626+ x_listen_poll, x_listen_read, NULL, ds)) == -1)
627+ exit(-1);
628+
629+ x_resize(ds, 640, 480);
630+}