--- uae/src/xwin.c 2018/04/24 16:42:01 1.1.1.5 +++ uae/src/xwin.c 2018/04/24 16:44:42 1.1.1.6 @@ -26,10 +26,11 @@ #include "threaddep/penguin.h" #include "uae.h" #include "memory.h" +#include "xwin.h" #include "custom.h" +#include "drawing.h" #include "readcpu.h" #include "newcpu.h" -#include "xwin.h" #include "keyboard.h" #include "keybuf.h" #include "gui.h" @@ -64,7 +65,7 @@ #define DO_PUTIMAGE(IMG, SRCX, SRCY, DSTX, DSTY, WIDTH, HEIGHT) \ do { \ - if (currprefs.use_mitshm) \ + if (currprefs.x11_use_mitshm) \ XShmPutImage (display, mywin, mygc, (IMG), (SRCX), (SRCY), (DSTX), (DSTY), (WIDTH), (HEIGHT), 0); \ else \ XPutImage (display, mywin, mygc, (IMG), (SRCX), (SRCY), (DSTX), (DSTY), (WIDTH), (HEIGHT)); \ @@ -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,6 +164,7 @@ 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); @@ -170,14 +172,17 @@ static void framerate_down (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_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 +215,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); @@ -358,7 +363,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: @@ -437,7 +442,7 @@ void flush_screen (int ystart, int ystop return; #if SHM_SUPPORT_LINKS == 1 - if (currprefs.use_mitshm) + if (currprefs.x11_use_mitshm) XSync (display, 0); #endif } @@ -710,6 +715,7 @@ static void init_dispinfo (struct disp_i static void graphics_subinit (void) { + int i, j; XSetWindowAttributes wattr; unsigned long valuemask; @@ -767,7 +773,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 +797,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 +810,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,7 +826,7 @@ int graphics_init (void) int i,j; XPixmapFormatValues *xpfvs; - if (currprefs.use_mitshm && ! shmavail) { + if (currprefs.x11_use_mitshm && ! shmavail) { fprintf (stderr, "MIT-SHM extension not supported by X server.\n"); } if (currprefs.color_mode > 5) @@ -879,7 +894,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 +914,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; @@ -1088,6 +1094,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 +1106,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; @@ -1413,7 +1445,7 @@ void handle_events (void) } 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; } @@ -1496,7 +1528,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 +1541,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 +1561,27 @@ 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; + 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; } @@ -1771,7 +1823,7 @@ static void handle_mousegrab (void) static void handle_inhibit (void) { - toggle_inhibit_frame (0); + toggle_inhibit_frame (IHF_SCROLLLOCK); } static void framerate_up (void) @@ -1785,3 +1837,22 @@ static void framerate_down (void) if (currprefs.framerate > 1) changed_prefs.framerate = currprefs.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)); +}