--- uae/src/xwin.c 2018/04/24 16:42:01 1.1.1.5 +++ uae/src/xwin.c 2018/04/24 17:05:29 1.1.1.16 @@ -23,13 +23,13 @@ #include "config.h" #include "options.h" -#include "threaddep/penguin.h" +#include "threaddep/thread.h" #include "uae.h" #include "memory.h" +#include "xwin.h" #include "custom.h" -#include "readcpu.h" +#include "drawing.h" #include "newcpu.h" -#include "xwin.h" #include "keyboard.h" #include "keybuf.h" #include "gui.h" @@ -64,7 +64,7 @@ #define DO_PUTIMAGE(IMG, SRCX, SRCY, DSTX, DSTY, WIDTH, HEIGHT) \ do { \ - if (currprefs.use_mitshm) \ + if (currprefs.x11_use_mitshm && shmavail) \ XShmPutImage (display, mywin, mygc, (IMG), (SRCX), (SRCY), (DSTX), (DSTY), (WIDTH), (HEIGHT), 0); \ else \ XPutImage (display, mywin, mygc, (IMG), (SRCX), (SRCY), (DSTX), (DSTY), (WIDTH), (HEIGHT)); \ @@ -114,6 +114,7 @@ struct disp_info { static Display *display; static int screen; static Window rootwin, mywin; +static Atom delete_win; static GC mygc; static XColor black, white; @@ -149,7 +150,7 @@ static int x11_init_ok; static int dgaavail = 0, vidmodeavail = 0, shmavail = 0; static int dgamode; - /* Keyboard and mouse */ +/* Keyboard and mouse */ static int keystate[256]; @@ -163,21 +164,26 @@ struct uae_hotkeys { int mask; }; +static void handle_modeswitch (void); static void handle_mousegrab (void); static void handle_inhibit (void); static void framerate_up (void); static void framerate_down (void); - +static void handle_interpol (void); static struct uae_hotkeys hotkeys[] = { - {{ XK_F12, XK_q, 0 }, uae_quit, -1 }, - {{ XK_F12, XK_m, 0 }, togglemouse, -1 }, - {{ XK_F12, XK_g, 0 }, handle_mousegrab, -1 }, - {{ XK_F12, XK_i, 0 }, handle_inhibit, -1 }, - {{ XK_F12, XK_KP_Add, 0 }, framerate_up, -1 }, - {{ XK_F12, XK_KP_Subtract, 0 }, framerate_down, -1 }, - {{ XK_Scroll_Lock, 0 }, handle_inhibit, -1 }, - {{ 0 }, NULL, -1 } /* List must be terminated */ +#ifdef USE_DGA_EXTENSION + {{ XK_F12, XK_s, 0 }, handle_modeswitch, -1, 0 }, +#endif + {{ XK_F12, XK_q, 0 }, uae_quit, -1, 0 }, + {{ XK_F12, XK_m, 0 }, togglemouse, -1, 0 }, + {{ XK_F12, XK_g, 0 }, handle_mousegrab, -1, 0 }, + {{ XK_F12, XK_i, 0 }, handle_inhibit, -1, 0 }, + {{ XK_F12, XK_p, 0 }, handle_interpol, -1, 0 }, + {{ XK_F12, XK_KP_Add, 0 }, framerate_up, -1, 0 }, + {{ XK_F12, XK_KP_Subtract, 0 }, framerate_down, -1, 0 }, + {{ XK_Scroll_Lock, 0 }, handle_inhibit, -1, 0 }, + {{ 0 }, NULL, -1, 0 } /* List must be terminated */ }; static int inwindow; @@ -210,7 +216,7 @@ static void get_image (int w, int h, str char *p; #if SHM_SUPPORT_LINKS == 1 - if (currprefs.use_mitshm && shmavail) { + if (currprefs.x11_use_mitshm && shmavail) { XShmSegmentInfo *shminfo = &dispi->shminfo; new_img = XShmCreateImage (display, vis, bitdepth, ZPixmap, 0, shminfo, w, h); @@ -231,7 +237,7 @@ static void get_image (int w, int h, str XDestroyImage (new_img); shminfo->shmid = -1; shmavail = 0; - fprintf (stderr, "MIT-SHM extension failed, trying fallback.\n"); + write_log ("MIT-SHM extension failed, trying fallback.\n"); } else { /* now deleting means making it temporary */ shmctl (shminfo->shmid, IPC_RMID, 0); @@ -251,7 +257,7 @@ static void get_image (int w, int h, str new_img = XCreateImage (display, vis, bitdepth, ZPixmap, 0, p, w, h, 32, 0); if (new_img->bytes_per_line != w * ((bit_unit + 7) / 8)) - fprintf (stderr, "Possible bug here... graphics may look strange.\n"); + write_log ("Possible bug here... graphics may look strange.\n"); dispi->image_mem = p; dispi->ximg = new_img; @@ -275,8 +281,12 @@ static int fb_width; static void switch_to_best_mode (void) { - int i, best; + Screen *scr = ScreenOfDisplay (display, screen); + int w = WidthOfScreen (scr); + int h = HeightOfScreen (scr); + int d = DefaultDepthOfScreen (scr); #ifdef USE_VIDMODE_EXTENSION + int i, best; if (vidmodeavail) { best = 0; for (i = 1; i < vidmodecount; i++) { @@ -297,15 +307,11 @@ static void switch_to_best_mode (void) XWarpPointer (display, None, rootwin, 0, 0, 0, 0, 0, 0); XF86DGADirectVideo (display, screen, XF86DGADirectGraphics | XF86DGADirectMouse | XF86DGADirectKeyb); XF86DGASetViewPort (display, screen, 0, 0); - memset (fb_addr, 0, fb_mem * 1024); + memset (fb_addr, 0, (w * h) * (d / 8)); } static void enter_dga_mode (void) { - Screen *scr = ScreenOfDisplay (display, screen); - int w = WidthOfScreen (scr); - int h = HeightOfScreen (scr); - XRaiseWindow (display, mywin); /* We want all the key presses */ @@ -327,13 +333,13 @@ static void enter_dga_mode (void) static void leave_dga_mode (void) { + XF86DGADirectVideo (display, screen, 0); + XUngrabPointer (display, CurrentTime); + XUngrabKeyboard (display, CurrentTime); #ifdef USE_VIDMODE_EXTENSION if (vidmodeavail) XF86VidModeSwitchToMode (display, screen, allmodes[0]); #endif - XF86DGADirectVideo (display, screen, 0); - XUngrabPointer (display, CurrentTime); - XUngrabKeyboard (display, CurrentTime); } #endif @@ -358,7 +364,7 @@ void flush_line (int y) xs = 0; xe = gfxvidinfo.width - 1; - if (currprefs.use_low_bandwidth) { + if (currprefs.x11_use_low_bandwidth) { char *src, *dst; switch (gfxvidinfo.pixbytes) { case 4: @@ -416,7 +422,7 @@ void flush_line (int y) len = currprefs.gfx_width; DitherLine (target, (uae_u16 *)linebuf, 0, y, gfxvidinfo.width, bit_unit); } else { - fprintf (stderr, "Bug!\n"); + write_log ("Bug!\n"); abort(); } @@ -437,12 +443,12 @@ void flush_screen (int ystart, int ystop return; #if SHM_SUPPORT_LINKS == 1 - if (currprefs.use_mitshm) + if (currprefs.x11_use_mitshm && shmavail) XSync (display, 0); #endif } -static __inline__ int bitsInMask (unsigned long mask) +STATIC_INLINE int bitsInMask (unsigned long mask) { /* count bits in mask */ int n = 0; @@ -453,7 +459,7 @@ static __inline__ int bitsInMask (unsign return n; } -static __inline__ int maskShift (unsigned long mask) +STATIC_INLINE int maskShift (unsigned long mask) { /* determine how far mask is shifted */ int n = 0; @@ -512,7 +518,7 @@ static int init_colors (void) } else { if (bitdepth != 8 && bitdepth != 12 && bitdepth != 15 && bitdepth != 16 && bitdepth != 24) { - fprintf (stderr, "Unsupported bit depth (%d)\n", bitdepth); + write_log ("Unsupported bit depth (%d)\n", bitdepth); return 0; } @@ -523,10 +529,10 @@ static int init_colors (void) XParseColor (display, cmap, "#000000", &black); if (! XAllocColor (display, cmap, &black)) - fprintf (stderr, "Whoops??\n"); + write_log ("Whoops??\n"); XParseColor (display, cmap, "#ffffff", &white); if (! XAllocColor (display, cmap, &white)) - fprintf (stderr, "Whoops??\n"); + write_log ("Whoops??\n"); break; case GrayScale: @@ -535,7 +541,7 @@ static int init_colors (void) break; default: - fprintf (stderr, "Unsupported visual class (%d)\n", visualInfo.VI_CLASS); + write_log ("Unsupported visual class (%d)\n", visualInfo.VI_CLASS); return 0; } } @@ -580,35 +586,35 @@ static int dga_available (void) int EventBase, ErrorBase; if (! XF86DGAQueryVersion (display, &MajorVersion, &MinorVersion)) { - fprintf (stderr, "Unable to query video extension version\n"); + write_log ("Unable to query video extension version\n"); return 0; } if (! XF86DGAQueryExtension (display, &EventBase, &ErrorBase)) { - fprintf (stderr, "Unable to query video extension information\n"); + write_log ("Unable to query video extension information\n"); return 0; } /* Fail if the extension version in the server is too old */ if (MajorVersion < DGA_MINMAJOR || (MajorVersion == DGA_MINMAJOR && MinorVersion < DGA_MINMINOR)) { - fprintf (stderr, + write_log ( "Xserver is running an old XFree86-DGA version" " (%d.%d)\n", MajorVersion, MinorVersion); - fprintf (stderr, "Minimum required version is %d.%d\n", + write_log ("Minimum required version is %d.%d\n", DGA_MINMAJOR, DGA_MINMINOR); return 0; } if (geteuid () != 0) { - fprintf (stderr, "UAE is not running as root, DGA extension disabled.\n"); + write_log ("UAE is not running as root, DGA extension disabled.\n"); return 0; } if (! XF86DGAGetVideo (display, screen, &fb_addr, &fb_width, &fb_bank, &fb_mem) || fb_bank < fb_mem) { - fprintf (stderr, "Problems with DGA - disabling DGA extension.\n"); + write_log ("Problems with DGA - disabling DGA extension.\n"); return 0; } - fprintf (stderr, "DGA extension: addr:%X, width %d, bank size %d mem size %d\n", + write_log ("DGA extension: addr:%X, width %d, bank size %d mem size %d\n", fb_addr, fb_width, fb_bank, fb_mem); return 1; @@ -626,24 +632,24 @@ static int vid_mode_available (void) if (! dgaavail) return 0; if (! XF86VidModeQueryVersion (display, &MajorVersion, &MinorVersion)) { - fprintf (stderr, "Unable to query video extension version\n"); + write_log ("Unable to query video extension version\n"); return 0; } if (! XF86VidModeQueryExtension (display, &EventBase, &ErrorBase)) { - fprintf (stderr, "Unable to query video extension information\n"); + write_log ("Unable to query video extension information\n"); return 0; } if (MajorVersion < VidMode_MINMAJOR || (MajorVersion == VidMode_MINMAJOR && MinorVersion < VidMode_MINMINOR)) { /* Fail if the extension version in the server is too old */ - fprintf (stderr, "Xserver is running an old XFree86-VidMode version (%d.%d)\n", + write_log ("Xserver is running an old XFree86-VidMode version (%d.%d)\n", MajorVersion, MinorVersion); - fprintf (stderr, "Minimum required version is %d.%d\n", + write_log ("Minimum required version is %d.%d\n", VidMode_MINMAJOR, VidMode_MINMINOR); return 0; } if (! get_vidmodes ()) { - fprintf (stderr, "Error getting video mode information\n"); + write_log ("Error getting video mode information\n"); return 0; } return 1; @@ -667,7 +673,7 @@ int graphics_setup (void) display = XOpenDisplay (display_name); if (display == 0) { - fprintf (stderr, "Can't connect to X server %s\n", XDisplayName (display_name)); + write_log ("Can't connect to X server %s\n", XDisplayName (display_name)); return 0; } @@ -710,7 +716,10 @@ static void init_dispinfo (struct disp_i static void graphics_subinit (void) { + int i, j; XSetWindowAttributes wattr; + XClassHint classhint; + XWMHints *hints; unsigned long valuemask; dgamode = screen_is_picasso ? currprefs.gfx_pfullscreen : currprefs.gfx_afullscreen; @@ -733,11 +742,29 @@ static void graphics_subinit (void) wattr.event_mask = EVENTMASK; XSync (display, 0); + delete_win = XInternAtom(display, "WM_DELETE_WINDOW", False); mywin = XCreateWindow (display, rootwin, 0, 0, current_width, current_height, 0, bitdepth, InputOutput, vis, valuemask, &wattr); + XSetWMProtocols (display, mywin, &delete_win, 1); XSync (display, 0); XStoreName (display, mywin, "UAE"); + XSetIconName (display, mywin, "UAE Screen"); + + /* set class hint */ + classhint.res_name = "UAE"; + classhint.res_class = "UAEScreen"; + XSetClassHint(display, mywin, &classhint); + + hints = XAllocWMHints(); + /* Set window group leader to self to become an application + * that can be hidden by e.g. WindowMaker. + * Would be more useful if we could find out what the + * (optional) GTK+ window ID is :-/ */ + hints->window_group = mywin; + hints->flags = WindowGroupHint; + XSetWMHints(display, mywin, hints); + XMapRaised (display, mywin); XSync (display, 0); mygc = XCreateGC (display, mywin, 0, 0); @@ -767,7 +794,7 @@ static void graphics_subinit (void) gfxvidinfo.linemem = 0; gfxvidinfo.bufmem = ami_dinfo.image_mem; gfxvidinfo.rowbytes = ami_dinfo.ximg->bytes_per_line; - if (currprefs.use_low_bandwidth) { + if (currprefs.x11_use_low_bandwidth) { gfxvidinfo.maxblocklines = 0; gfxvidinfo.rowbytes = ami_dinfo.ximg->bytes_per_line; gfxvidinfo.linemem = (char *)malloc (gfxvidinfo.rowbytes); @@ -791,7 +818,7 @@ static void graphics_subinit (void) #endif if (! dgamode) { - if (! currprefs.no_xhair) + if (! currprefs.x11_hide_cursor) XDefineCursor (display, mywin, xhairCursor); else XDefineCursor (display, mywin, blankCursor); @@ -804,6 +831,15 @@ static void graphics_subinit (void) picasso_invalid_stop = -1; memset (picasso_invalid_lines, 0, sizeof picasso_invalid_lines); } + + lastmx = lastmy = 0; + newmousecounters = 0; + inwindow = 0; + for (i = 0; hotkeys[i].syms[0] != 0; i++) { + hotkeys[i].mask = 0; + for (j = 0; hotkeys[i].syms[j] != 0; j++) + hotkeys[i].mask |= (1 << j); + } } int graphics_init (void) @@ -811,11 +847,11 @@ int graphics_init (void) int i,j; XPixmapFormatValues *xpfvs; - if (currprefs.use_mitshm && ! shmavail) { - fprintf (stderr, "MIT-SHM extension not supported by X server.\n"); + if (currprefs.x11_use_mitshm && ! shmavail) { + write_log ("MIT-SHM extension not supported by X server.\n"); } if (currprefs.color_mode > 5) - fprintf (stderr, "Bad color mode selected. Using default.\n"), currprefs.color_mode = 0; + write_log ("Bad color mode selected. Using default.\n"), currprefs.color_mode = 0; x11_init_ok = 0; need_dither = 0; @@ -841,7 +877,7 @@ int graphics_init (void) } else if (XMatchVisualInfo (display, screen, 1, StaticGray, &visualInfo)) { /* Mono server. Yuk */ } else { - fprintf (stderr, "Can't obtain appropriate X visual.\n"); + write_log ("Can't obtain appropriate X visual.\n"); return 0; } vis = visualInfo.visual; @@ -857,11 +893,11 @@ int graphics_init (void) bit_unit = xpfvs[j].bits_per_pixel; XFree (xpfvs); if (j == i) { - fprintf (stderr, "Your X server is feeling ill.\n"); + write_log ("Your X server is feeling ill.\n"); return 0; } - fprintf (stderr, "Using %d bit visual, %d bits per pixel\n", bitdepth, bit_unit); + write_log ("Using %d bit visual, %d bits per pixel\n", bitdepth, bit_unit); fixup_prefs_dimensions (&currprefs); @@ -879,7 +915,7 @@ int graphics_init (void) if (bitdepth < 8 || (bitdepth == 8 && currprefs.color_mode == 3)) { gfxvidinfo.pixbytes = 2; - currprefs.use_low_bandwidth = 0; + currprefs.x11_use_low_bandwidth = 0; need_dither = 1; } else { gfxvidinfo.pixbytes = bit_unit >> 3; @@ -899,15 +935,6 @@ int graphics_init (void) buttonstate[0] = buttonstate[1] = buttonstate[2] = 0; for (i = 0; i < 256; i++) keystate[i] = 0; - - lastmx = lastmy = 0; - newmousecounters = 0; - inwindow = 0; - for (i = 0; hotkeys[i].syms[0] != 0; i++) { - hotkeys[i].mask = 0; - for (j = 0; hotkeys[i].syms[j] != 0; j++) - hotkeys[i].mask |= (1 << j); - } grabbed = 0; return x11_init_ok = 1; @@ -961,7 +988,9 @@ void graphics_leave (void) XFreeColormap (display, cmap); XFreeColormap (display, cmap2); +#if 0 XCloseDisplay (display); +#endif dumpcustom (); } @@ -1070,7 +1099,11 @@ static int kc_decode (KeySym ks) case XK_Left: return AK_LF; case XK_Right: return AK_RT; +#if 0 case XK_F11: return AK_BACKSLASH; +#else + case XK_F11: frametime = 0; timeframes = 0; bogusframe = 1; break; +#endif #ifdef XK_Page_Up /* These are missing occasionally */ case XK_Page_Up: return AK_RAMI; /* PgUp mapped to right amiga */ case XK_Page_Down: return AK_LAMI; /* PgDn mapped to left amiga */ @@ -1088,6 +1121,7 @@ static int decode_fr (KeySym ks) case XK_Y: case XK_y: return AK_Y; case XK_W: case XK_w: return AK_Z; case XK_Z: case XK_z: return AK_W; +#if 0 case XK_bracketleft: return AK_LBRACKET; case XK_bracketright: return AK_RBRACKET; case XK_comma: return AK_M; @@ -1099,6 +1133,31 @@ static int decode_fr (KeySym ks) case XK_slash: return AK_PERIOD; case XK_minus: return AK_EQUAL; case XK_backslash: return AK_BACKSLASH; +#else + /* not sure for this one: my X 3.3 server doesn't handle this key always + * correctly... But anyway, on new french keyboards, no more bracket key + * at this place. + */ + case XK_dead_circumflex: + case XK_dead_diaeresis: return AK_LBRACKET; + case XK_dollar: + case XK_sterling: return AK_RBRACKET; + case XK_comma: case XK_question: return AK_M; + case XK_less: case XK_greater: return AK_LTGT; + case XK_semicolon: case XK_period: return AK_COMMA; + case XK_parenright: case XK_degree: return AK_MINUS; + case XK_equal: case XK_plus: return AK_SLASH; + case XK_numbersign: return AK_NUMBERSIGN; + case XK_colon: case XK_slash: return AK_PERIOD; + case XK_minus: case XK_6: return AK_6; + case XK_ugrave: case XK_percent: return AK_QUOTE; + /* found a spare key - I hope it deserves this place. */ + case XK_asterisk: case XK_mu: return AK_BACKSLASH; + case XK_exclam: case XK_section: return AK_EQUAL; + case XK_twosuperior: case XK_asciitilde: return AK_BACKQUOTE; + case XK_Multi_key: return AK_RAMI; + case XK_Mode_switch: return AK_RALT; +#endif } return -1; @@ -1157,6 +1216,35 @@ static int decode_de (KeySym ks) return -1; } +static int decode_dk (KeySym ks) +{ + switch(ks) { + /* DK specific */ + case XK_A: case XK_a: return AK_A; + case XK_M: case XK_m: return AK_M; + case XK_Q: case XK_q: return AK_Q; + case XK_W: case XK_w: return AK_W; + case XK_Y: case XK_y: return AK_Y; + case XK_Z: case XK_z: return AK_Z; + case XK_AE: case XK_ae: return AK_SEMICOLON; + case XK_Ooblique: case XK_oslash: return AK_QUOTE; + case XK_Aring: case XK_aring: return AK_LBRACKET; + case XK_apostrophe: case XK_asterisk: return AK_NUMBERSIGN; + case XK_dead_diaeresis: case XK_dead_circumflex: return AK_RBRACKET; + case XK_dead_acute: case XK_dead_grave: return AK_BACKSLASH; + case XK_onehalf: case XK_section: return AK_BACKQUOTE; + case XK_comma: return AK_COMMA; + case XK_period: return AK_PERIOD; + case XK_less: case XK_greater: return AK_LTGT; + case XK_numbersign: return AK_NUMBERSIGN; + case XK_plus: return AK_MINUS; + case XK_asciicircum: return AK_BACKQUOTE; + case XK_minus: return AK_SLASH; + } + + return -1; +} + static int decode_se (KeySym ks) { switch(ks) { @@ -1291,6 +1379,10 @@ static int keycode2amiga (XKeyEvent *eve as = decode_de (ks); break; + case KBD_LANG_DK: + as = decode_dk (ks); + break; + case KBD_LANG_SE: as = decode_se (ks); break; @@ -1379,7 +1471,7 @@ void handle_events (void) lastmy += ((XMotionEvent *)&event)->y_root; } else if (grabbed) { int realmove = 0; - int tx, ty; + int tx, ty,ttx,tty; tx = ((XMotionEvent *)&event)->x; ty = ((XMotionEvent *)&event)->y; @@ -1396,40 +1488,32 @@ void handle_events (void) { #undef ABS XEvent event; - tx = current_width / 2; - ty = current_height / 2; + ttx = current_width / 2; + tty = current_height / 2; event.type = MotionNotify; event.xmotion.display = display; event.xmotion.window = mywin; - event.xmotion.x = tx; - event.xmotion.y = ty; + event.xmotion.x = ttx; + event.xmotion.y = tty; XSendEvent (display, mywin, False, PointerMotionMask, &event); - XWarpPointer (display, None, mywin, 0, 0, 0, 0, tx, ty); + XWarpPointer (display, None, mywin, 0, 0, 0, 0, ttx, tty); } + } else { + tx=event.xmotion.x; + ty=event.xmotion.y; } oldx = tx; oldy = ty; } else if (inwindow) { lastmx = ((XMotionEvent *)&event)->x; lastmy = ((XMotionEvent *)&event)->y; - if (! cursorOn && !currprefs.no_xhair) { + if (! cursorOn && !currprefs.x11_hide_cursor) { XDefineCursor(display, mywin, xhairCursor); cursorOn = 1; } gettimeofday(&lastMotionTime, NULL); } - - if (ievent_alive) { - if (lastmx < 0) - lastmx = 0; - if (lastmx > current_width) - lastmx = current_width; - if (lastmy < 0) - lastmy = 0; - if (lastmy > current_height) - lastmy = current_height; - } break; case EnterNotify: newmousecounters = 1; @@ -1453,6 +1537,11 @@ void handle_events (void) case Expose: refresh_necessary = 1; break; + case ClientMessage: + if (event.xclient.data.l[0]==delete_win) { + uae_quit (); + } + break; } } @@ -1496,7 +1585,7 @@ void handle_events (void) DO_PUTIMAGE (ami_dinfo.ximg, 0, 0, 0, 0, currprefs.gfx_width, currprefs.gfx_height); refresh_necessary = 0; } - if (cursorOn && !currprefs.no_xhair) { + if (cursorOn && !currprefs.x11_hide_cursor) { struct timeval now; int diff; gettimeofday(&now, NULL); @@ -1509,7 +1598,7 @@ void handle_events (void) } } /* "Affengriff" */ - if (keystate[AK_CTRL] && keystate[AK_LAMI] && keystate[AK_RAMI]) + if ((keystate[AK_CTRL] || keystate[AK_RCTRL]) && keystate[AK_LAMI] && keystate[AK_RAMI]) uae_reset (); } @@ -1529,7 +1618,30 @@ int check_prefs_changed_gfx (void) && changed_prefs.gfx_afullscreen == currprefs.gfx_afullscreen && changed_prefs.gfx_pfullscreen == currprefs.gfx_pfullscreen) return 0; - + + graphics_subshutdown (); + currprefs.gfx_width = changed_prefs.gfx_width; + currprefs.gfx_height = changed_prefs.gfx_height; + currprefs.gfx_lores = changed_prefs.gfx_lores; + currprefs.gfx_linedbl = changed_prefs.gfx_linedbl; + currprefs.gfx_correct_aspect = changed_prefs.gfx_correct_aspect; + currprefs.gfx_xcenter = changed_prefs.gfx_xcenter; + currprefs.gfx_ycenter = changed_prefs.gfx_ycenter; + currprefs.gfx_afullscreen = changed_prefs.gfx_afullscreen; + currprefs.gfx_pfullscreen = changed_prefs.gfx_pfullscreen; + + gui_update_gfx (); + + graphics_subinit (); + + if (! inwindow) + XWarpPointer (display, None, mywin, 0, 0, 0, 0, + current_width / 2, current_height / 2); + + notice_screen_contents_lost (); + init_row_map (); + if (screen_is_picasso) + picasso_enablescreen (1); return 0; } @@ -1540,7 +1652,7 @@ int debuggable (void) int needmousehack (void) { - if (dgamode) + if (dgamode || grabbed) return 0; else return 1; @@ -1771,17 +1883,57 @@ static void handle_mousegrab (void) static void handle_inhibit (void) { - toggle_inhibit_frame (0); + toggle_inhibit_frame (IHF_SCROLLLOCK); +} + +#include "gensound.h" +#include "sounddep/sound.h" +#include "events.h" +#include "audio.h" + +static void handle_interpol (void) +{ + if (currprefs.sound_interpol == 0) { + currprefs.sound_interpol = 1; + printf ("Interpol on: rh\n"); + } + else if (currprefs.sound_interpol == 1) { + currprefs.sound_interpol = 2; + printf ("Interpol on: crux\n"); + } + else { + currprefs.sound_interpol = 0; + printf ("Interpol off\n"); + } } static void framerate_up (void) { - if (currprefs.framerate < 20) - changed_prefs.framerate = currprefs.framerate + 1; + if (currprefs.gfx_framerate < 20) + changed_prefs.gfx_framerate = currprefs.gfx_framerate + 1; } static void framerate_down (void) { - if (currprefs.framerate > 1) - changed_prefs.framerate = currprefs.framerate - 1; + if (currprefs.gfx_framerate > 1) + changed_prefs.gfx_framerate = currprefs.gfx_framerate - 1; +} + +static void handle_modeswitch (void) +{ + changed_prefs.gfx_afullscreen = changed_prefs.gfx_pfullscreen = !dgamode; +} + +void target_save_options (FILE *f, struct uae_prefs *p) +{ + fprintf (f, "x11.low_bandwidth=%s\n", p->x11_use_low_bandwidth ? "true" : "false"); + fprintf (f, "x11.use_mitshm=%s\n", p->x11_use_mitshm ? "true" : "false"); + fprintf (f, "x11.hide_cursor=%s\n", p->x11_hide_cursor ? "true" : "false"); +} + +int target_parse_option (struct uae_prefs *p, char *option, char *value) +{ + return (cfgfile_yesno (option, value, "low_bandwidth", &p->x11_use_low_bandwidth) + || cfgfile_yesno (option, value, "use_mitshm", &p->x11_use_mitshm) + || cfgfile_yesno (option, value, "hide_cursor", &p->x11_hide_cursor)); }