--- uae/src/xwin.c 2018/04/24 17:14:11 1.1.1.19 +++ uae/src/xwin.c 2018/04/24 17:21:44 1.1.1.22 @@ -22,7 +22,6 @@ #include #include -#include "config.h" #include "options.h" #include "threaddep/thread.h" #include "uae.h" @@ -132,7 +131,6 @@ static int dga_colormap_installed; static int need_dither; -static int screen_is_picasso; static char picasso_invalid_lines[1201]; static int picasso_has_invalid_lines; static int picasso_invalid_start, picasso_invalid_stop; @@ -245,9 +243,30 @@ static void get_image (int w, int h, str static XF86VidModeModeInfo **allmodes; static int vidmodecount; +static int sortfn (const void *a, const void *b) +{ + XF86VidModeInfo **ppa = a, *ppb = b; + XF86VidModeInfo *pa = *ppa, *pb = *ppb; + if (pa->hdisplay != pb->hdisplay) + return pa->hdisplay - pb->hdisplay; + return pa->vdisplay - pb->vdisplay; +} + static int get_vidmodes (void) { - return XF86VidModeGetAllModeLines (display, screen, &vidmodecount, &allmodes); + int i; + + if (!XF86VidModeGetAllModeLines (display, screen, &vidmodecount, &allmodes)) + return 0; + + qsort (allmodes, vidmodecount, sizeof *allmode, sortfn); + + gfx_fullscreen_modes = sizeof (struct uae_rect) * vidmodecount; + n_fullscreen_modes = vidmodecount; + for (i = 0; i < vidmodecount; i++) { + gfx_fullscreen_modes[i].w = allmodes[i].hdisplay; + gfx_fullscreen_modes[i].h = allmodes[i].vdisplay; + } } #endif @@ -397,7 +416,7 @@ void flush_line (int y) memcpy (dst, src, len * gfxvidinfo.pixbytes); } else if (need_dither) { uae_u8 *target = (uae_u8 *)ami_dinfo.image_mem + ami_dinfo.ximg->bytes_per_line * y; - len = currprefs.gfx_width; + len = gfxvidinfo.width; DitherLine (target, (uae_u16 *)linebuf, 0, y, gfxvidinfo.width, bit_unit); } else { write_log ("Bug!\n"); @@ -708,7 +727,7 @@ static void reset_cursor (void) } } -static void graphics_subinit (void) +int graphics_subinit (void) { int i, j; XSetWindowAttributes wattr; @@ -716,8 +735,27 @@ static void graphics_subinit (void) XWMHints *hints; unsigned long valuemask; - dgamode = screen_is_picasso ? currprefs.gfx_pfullscreen : currprefs.gfx_afullscreen; - dgamode = dgamode && dgaavail; + if (screen_is_picasso) { + // Set height, width for Picasso gfx + current_width = picasso_vidinfo.width; + current_height = picasso_vidinfo.height; + dgamode = currprefs.gfx_pfullscreen && dgaavail; + curr_gfx = 0; + } else { + // Set height, width for Amiga gfx + dgamode = currprefs.gfx_afullscreen && dgaavail; + if (dgamode) + curr_gfx = &currprefs.gfx_f; + else + curr_gfx = &currprefs.gfx_w; + + current_width = curr_gfx->width; + current_height = curr_gfx->height; + } + if (!screen_is_picasso) { + gfxvidinfo.width = current_width; + gfxvidinfo.height = current_height; + } wattr.background_pixel = /*black.pixel*/0; wattr.backing_store = Always; @@ -748,7 +786,7 @@ static void graphics_subinit (void) /* set class hint */ classhint.res_name = "UAE"; classhint.res_class = "UAEScreen"; - XSetClassHint(display, mywin, &classhint); + XSetClassHint (display, mywin, &classhint); hints = XAllocWMHints(); /* Set window group leader to self to become an application @@ -757,7 +795,8 @@ static void graphics_subinit (void) * (optional) GTK+ window ID is :-/ */ hints->window_group = mywin; hints->flags = WindowGroupHint; - XSetWMHints(display, mywin, hints); + XSetWMHints (display, mywin, hints); + XFree (hints); XMapRaised (display, mywin); XSync (display, 0); @@ -781,7 +820,7 @@ static void graphics_subinit (void) if (need_dither) { gfxvidinfo.maxblocklines = 0; - gfxvidinfo.rowbytes = gfxvidinfo.pixbytes * currprefs.gfx_width; + gfxvidinfo.rowbytes = gfxvidinfo.pixbytes * current_width; gfxvidinfo.linemem = (char *)malloc (gfxvidinfo.rowbytes); } else if (! dgamode) { gfxvidinfo.emergmem = 0; @@ -823,6 +862,10 @@ static void graphics_subinit (void) inwindow = 0; inputdevice_release_all_keys (); reset_hotkeys (); + + XWarpPointer (display, None, mywin, 0, 0, 0, 0, + current_width / 2, current_height / 2); + return 1; } static int get_best_visual (XVisualInfo *vi) @@ -902,12 +945,8 @@ int graphics_init (void) write_log ("Using %d bit visual, %d bits per pixel\n", bitdepth, bit_unit); - fixup_prefs_dimensions (&currprefs); - - gfxvidinfo.width = currprefs.gfx_width; - gfxvidinfo.height = currprefs.gfx_height; - current_width = currprefs.gfx_width; - current_height = currprefs.gfx_height; + fixup_prefs_dimensions (&currprefs.gfx_w, gfx_windowed_modes, n_windowed_modes); + fixup_prefs_dimensions (&currprefs.gfx_f, gfx_fullscreen_modes, n_fullscreen_modes); cmap = XCreateColormap (display, rootwin, vis, AllocNone); cmap2 = XCreateColormap (display, rootwin, vis, AllocNone); @@ -920,8 +959,10 @@ int graphics_init (void) gfxvidinfo.pixbytes = 2; currprefs.x11_use_low_bandwidth = 0; need_dither = 1; + picasso_vidinfo.pixbytes = 1 /* ??? */; } else { gfxvidinfo.pixbytes = bit_unit >> 3; + picasso_vidinfo.pixbytes = bit_unit >> 3; } if (! init_colors ()) @@ -953,7 +994,7 @@ static void destroy_dinfo (struct disp_i dinfo->ximg = NULL; } -static void graphics_subshutdown (void) +void graphics_subshutdown (int final) { XSync (display, 0); #ifdef USE_DGA_EXTENSION @@ -980,7 +1021,7 @@ void graphics_leave (void) if (! x11_init_ok) return; - graphics_subshutdown (); + graphics_subshutdown (1); if (autorepeatoff) XAutoRepeatOn (display); @@ -1175,7 +1216,7 @@ void handle_events (void) if (! dgamode) { if (! screen_is_picasso && refresh_necessary) { - DO_PUTIMAGE (ami_dinfo.ximg, 0, 0, 0, 0, currprefs.gfx_width, currprefs.gfx_height); + DO_PUTIMAGE (ami_dinfo.ximg, 0, 0, 0, 0, current_width, current_height); refresh_necessary = 0; } if (cursorOn && !currprefs.x11_hide_cursor) { @@ -1192,49 +1233,6 @@ void handle_events (void) } } -int check_prefs_changed_gfx (void) -{ - if (changed_prefs.gfx_width != currprefs.gfx_width - || changed_prefs.gfx_height != currprefs.gfx_height) - fixup_prefs_dimensions (&changed_prefs); - - if (changed_prefs.gfx_width == currprefs.gfx_width - && changed_prefs.gfx_height == currprefs.gfx_height - && changed_prefs.gfx_lores == currprefs.gfx_lores - && changed_prefs.gfx_linedbl == currprefs.gfx_linedbl - && changed_prefs.gfx_correct_aspect == currprefs.gfx_correct_aspect - && changed_prefs.gfx_xcenter == currprefs.gfx_xcenter - && changed_prefs.gfx_ycenter == currprefs.gfx_ycenter - && 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; -} - int debuggable (void) { return 1; @@ -1446,56 +1444,6 @@ int DX_FillResolutions (uae_u16 *ppixel_ return count; } -static void set_window_for_picasso (void) -{ - if (current_width == picasso_vidinfo.width && current_height == picasso_vidinfo.height) - return; - - graphics_subshutdown (); - current_width = picasso_vidinfo.width; - current_height = picasso_vidinfo.height; -#if 0 && defined USE_DGA_EXTENSION && defined USE_VIDMODE_EXTENSION - if (dgamode && vidmodeavail) - switch_to_best_mode (); -#endif - graphics_subinit (); -} - -void gfx_set_picasso_modeinfo (int w, int h, int depth, int rgbfmt) -{ - picasso_vidinfo.width = w; - picasso_vidinfo.height = h; - picasso_vidinfo.depth = depth; - picasso_vidinfo.pixbytes = bit_unit >> 3; - - if (screen_is_picasso) - set_window_for_picasso (); -} - -void gfx_set_picasso_baseaddr (uaecptr a) -{ -} - -void gfx_set_picasso_state (int on) -{ - if (on == screen_is_picasso) - return; - graphics_subshutdown (); - screen_is_picasso = on; - if (on) { - current_width = picasso_vidinfo.width; - current_height = picasso_vidinfo.height; - graphics_subinit (); - } else { - current_width = gfxvidinfo.width; - current_height = gfxvidinfo.height; - graphics_subinit (); - reset_drawing (); - } - if (on) - DX_SetPalette_real (0, 256); -} - uae_u8 *gfx_lock_picasso (void) { #ifdef USE_DGA_EXTENSION @@ -1593,12 +1541,12 @@ static void close_mouse (void) return; } -static int acquire_mouse (int num, int flags) +static int acquire_mouse (unsigned int num, int flags) { return 1; } -static void unacquire_mouse (int num) +static void unacquire_mouse (unsigned int num) { return; } @@ -1608,17 +1556,17 @@ static int get_mouse_num (void) return 1; } -static char *get_mouse_name (int mouse) +static const char *get_mouse_name (unsigned int mouse) { return 0; } -static int get_mouse_widget_num (int mouse) +static int get_mouse_widget_num (unsigned int mouse) { return MAX_AXES + MAX_BUTTONS; } -static int get_mouse_widget_first (int mouse, int type) +static int get_mouse_widget_first (unsigned int mouse, int type) { switch (type) { case IDEV_WIDGET_BUTTON: @@ -1629,7 +1577,7 @@ static int get_mouse_widget_first (int m return -1; } -static int get_mouse_widget_type (int mouse, int num, char *name, uae_u32 *code) +static int get_mouse_widget_type (unsigned int mouse, unsigned int num, char *name, uae_u32 *code) { if (num >= MAX_AXES && num < MAX_AXES + MAX_BUTTONS) { if (name) @@ -1663,22 +1611,22 @@ static int get_kb_num (void) return 1; } -static char *get_kb_name (int kb) +static const char *get_kb_name (unsigned int kb) { - return 0; + return "Default keyboard"; } -static int get_kb_widget_num (int kb) +static int get_kb_widget_num (unsigned int kb) { return 255; // fix me } -static int get_kb_widget_first (int kb, int type) +static int get_kb_widget_first (unsigned int kb, int type) { return 0; } -static int get_kb_widget_type (int kb, int num, char *name, uae_u32 *code) +static int get_kb_widget_type (unsigned int kb, unsigned int num, char *name, uae_u32 *code) { // fix me *code = num; @@ -1695,7 +1643,7 @@ static void read_kb (void) } static int init_kb (void) { - set_default_hotkeys ( get_x11_default_hotkeys()); + set_default_hotkeys (get_x11_default_hotkeys()); return 1; } @@ -1703,12 +1651,12 @@ static void close_kb (void) { } -static int acquire_kb (int num, int flags) +static int acquire_kb (unsigned int num, int flags) { return 1; } -static void unacquire_kb (int num) +static void unacquire_kb (unsigned int num) { } @@ -1746,14 +1694,14 @@ void setcapslockstate (int state) /* * Handle gfx cfgfile options */ -void target_save_options (FILE *f, struct uae_prefs *p) +void target_save_options (FILE *f, const 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) +int target_parse_option (struct uae_prefs *p, const char *option, const char *value) { return (cfgfile_yesno (option, value, "low_bandwidth", &p->x11_use_low_bandwidth) || cfgfile_yesno (option, value, "use_mitshm", &p->x11_use_mitshm)