--- uae/src/xwin.c 2018/04/24 16:47:20 1.1.1.7 +++ uae/src/xwin.c 2018/04/24 17:03:42 1.1.1.15 @@ -23,13 +23,12 @@ #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 "drawing.h" -#include "readcpu.h" #include "newcpu.h" #include "keyboard.h" #include "keybuf.h" @@ -65,7 +64,7 @@ #define DO_PUTIMAGE(IMG, SRCX, SRCY, DSTX, DSTY, WIDTH, HEIGHT) \ do { \ - if (currprefs.x11_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)); \ @@ -282,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++) { @@ -304,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 */ @@ -334,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 @@ -444,12 +443,12 @@ void flush_screen (int ystart, int ystop return; #if SHM_SUPPORT_LINKS == 1 - if (currprefs.x11_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; @@ -460,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; @@ -989,7 +988,9 @@ void graphics_leave (void) XFreeColormap (display, cmap); XFreeColormap (display, cmap2); +#if 0 XCloseDisplay (display); +#endif dumpcustom (); } @@ -1098,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 */ @@ -1211,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) { @@ -1345,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; @@ -1433,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; @@ -1450,17 +1488,20 @@ 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; @@ -1473,17 +1514,6 @@ void handle_events (void) } 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; @@ -1599,6 +1629,9 @@ int check_prefs_changed_gfx (void) 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) @@ -1619,7 +1652,7 @@ int debuggable (void) int needmousehack (void) { - if (dgamode) + if (dgamode || grabbed) return 0; else return 1; @@ -1860,19 +1893,18 @@ static void handle_inhibit (void) static void handle_interpol (void) { - if (sample_handler == sample16si_handler) { - sample_handler = sample16s_handler; - printf ("Interpol off\n"); + 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 if (sample_handler == sample16s_handler) { - sample_handler = sample16si_handler; - printf ("Interpol on\n"); - } - else if (sample_handler == sample16i_handler) - sample_handler = sample16_handler; - else if (sample_handler == sample16_handler) - sample_handler = sample16i_handler; - + else { + currprefs.sound_interpol = 0; + printf ("Interpol off\n"); + } } static void framerate_up (void)