Previous 15994 Revisions Next

r2153 Saturday 29th March, 2008 at 23:39:36 UTC by R. Belmont
[SDLMESS] Ported -maximize switch from baseline.
[src/osd/sdl]osdsdl.h sdlmain.c video.c window.c window.h

src/osd/sdl/video.c
r2152r2153
814814
815815static void get_resolution(const char *name, sdl_window_config *config, int report_error)
816816{
817   const char *defdata = options_get_string(mame_options(), SDLOPTION_RESOLUTION(""));
817818   const char *data = options_get_string(mame_options(), name);
818819
819820   config->width = config->height = config->depth = config->refresh = 0;
820821   if (strcmp(data, SDLOPTVAL_AUTO) == 0)
821822   {
822      return;
823      if (strcmp(defdata, SDLOPTVAL_AUTO) == 0)
824      {
825         return;
826      }
827
828      data = defdata;
823829   }
824   else if (sscanf(data, "%dx%dx%d@%d", &config->width, &config->height, &config->depth, &config->refresh) < 2 && report_error)
830   
831   if (sscanf(data, "%dx%dx%d@%d", &config->width, &config->height, &config->depth, &config->refresh) < 2 && report_error)
825832      mame_printf_error("Illegal resolution value for %s = %s\n", name, data);
826833}
827834
src/osd/sdl/window.c
r2152r2153
4747//  PARAMETERS
4848//============================================================
4949
50// these are arbitrary values since AFAIK there's no way to make X/SDL tell you
51#define WINDOW_DECORATION_WIDTH   (8)   // should be more than plenty
52#define WINDOW_DECORATION_HEIGHT (48)   // title bar + bottom drag region
53
5054#if 1
5155#define ASSERT_USE(x)   assert_always(SDL_ThreadID() == x, "Wrong Thread")
5256//#define ASSERT_USE(x)
r2152r2153
128132
129133
130134static void get_min_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain);
135static void get_max_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain);
131136
132137static void *complete_create_wt(void *param, int threadid);
133138static void set_starting_view(running_machine *machine, int index, sdl_window_info *window, const char *view);
r2152r2153
805810   window->refresh = config->refresh;
806811   window->monitor = monitor;
807812   window->fullscreen = !video_config.windowed;
813
814   // set the initial maximized state
815   window->startmaximized = options_get_bool(mame_options(), SDLOPTION_MAXIMIZE);
816
808817   if (!window->fullscreen)
809818   {
810819      window->windowed_width = config->width;
r2152r2153
11661175
11671176static OSDWORK_CALLBACK( complete_create_wt )
11681177{
1169   
11701178   worker_param *wp = (worker_param *) param;
11711179   sdl_window_info *window = wp->window;
11721180   int tempwidth, tempheight;
1173   //sdl_info *sdl;
11741181   static int result[2] = {0,1};
11751182
11761183   ASSERT_WINDOW_THREAD();
11771184   free(wp);
11781185
1179   //sdl = window->dxdata;
1180
11811186   if (window->fullscreen)
11821187   {
11831188
r2152r2153
12011206   {
12021207      window->extra_flags = SDL_RESIZABLE;
12031208
1204      /* Create the window directly with the correct aspect
1205         instead of letting sdlwindow_blit_surface_size() resize it
1206         this stops the window from "flashing" from the wrong aspect
1207         size to the right one at startup. */
1208      tempwidth = (window->maxwidth != 0) ? window->maxwidth : 640;
1209      tempheight = (window->maxheight != 0) ? window->maxheight : 480;
1209      if (window->startmaximized)
1210      {
1211         tempwidth = tempheight = 0;
1212         get_max_bounds(window, &tempwidth, &tempheight, video_config.keepaspect );
1213      }
1214      else
1215      {
1216         /* Create the window directly with the correct aspect
1217            instead of letting sdlwindow_blit_surface_size() resize it
1218            this stops the window from "flashing" from the wrong aspect
1219            size to the right one at startup. */
1220         tempwidth = (window->maxwidth != 0) ? window->maxwidth : 640;
1221         tempheight = (window->maxheight != 0) ? window->maxheight : 480;
12101222
1211      get_min_bounds(window, &tempwidth, &tempheight, video_config.keepaspect );
1223         get_min_bounds(window, &tempwidth, &tempheight, video_config.keepaspect );
1224      }
12121225   }
12131226
12141227#ifndef NO_OPENGL
r2152r2153
15191532   *window_width = minwidth;
15201533   *window_height = minheight;
15211534}
1535
1536//============================================================
1537//  get_max_bounds
1538//  (window thread)
1539//============================================================
1540
1541static void get_max_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain)
1542{
1543   INT32 maxwidth, maxheight;
1544
1545   assert(GetCurrentThreadId() == window_threadid);
1546
1547   // compute the maximum client area
1548   maxwidth = window->monitor->center_width;
1549   maxheight = window->monitor->center_height;
1550
1551   // clamp to the window's max
1552   if (window->maxwidth != 0)
1553   {
1554      int temp = window->maxwidth + WINDOW_DECORATION_WIDTH;
1555      if (temp < maxwidth)
1556         maxwidth = temp;
1557   }
1558   if (window->maxheight != 0)
1559   {
1560      int temp = window->maxheight + WINDOW_DECORATION_HEIGHT;
1561      if (temp < maxheight)
1562         maxheight = temp;
1563   }
1564
1565   // constrain to fit
1566   if (constrain)
1567      constrain_to_aspect_ratio(window, &maxwidth, &maxheight, WMSZ_BOTTOMRIGHT);
1568   else
1569   {
1570      maxwidth -= WINDOW_DECORATION_WIDTH;
1571      maxheight -= WINDOW_DECORATION_HEIGHT;
1572      *window_width = maxwidth;
1573      *window_height = maxheight;   
1574   }
1575}
1576
src/osd/sdl/window.h
r2152r2153
110110   int               refresh;
111111   int               windowed_width;
112112   int               windowed_height;
113   int               startmaximized;
113114
114115   // rendering info
115116   osd_lock *         render_lock;
src/osd/sdl/sdlmain.c
r2152r2153
100100   { SDLOPTION_VIDEO,                   SDLOPTVAL_SOFT,  0,                 "video output method: soft or opengl" },
101101   { SDLOPTION_NUMSCREENS,                   "1",        0,                 "number of screens to create; SDLMAME only supports 1 at this time" },
102102   { SDLOPTION_WINDOW ";w",                  "0",        OPTION_BOOLEAN,    "enable window mode; otherwise, full screen mode is assumed" },
103   { SDLOPTION_MAXIMIZE ";max",              "1",        OPTION_BOOLEAN,    "default to maximized windows; otherwise, windows will be minimized" },
103104   { SDLOPTION_KEEPASPECT ";ka",             "1",        OPTION_BOOLEAN,    "constrain to the proper aspect ratio" },
104105   { SDLOPTION_UNEVENSTRETCH ";ues",         "1",        OPTION_BOOLEAN,    "allow non-integer stretch factors" },
105106   { SDLOPTION_EFFECT,                  SDLOPTVAL_NONE,  0,                 "name of a PNG file to use for visual effects, or 'none'" },
src/osd/sdl/osdsdl.h
r2152r2153
108108#define SDLOPTION_NUMSCREENS         "numscreens"
109109#define SDLOPTION_UNEVENSTRETCH         "unevenstretch"
110110#define SDLOPTION_USEALLHEADS         "useallheads"
111#define SDLOPTION_MAXIMIZE         "maximize"
111112#define SDLOPTION_EFFECT            "effect"
112113#define SDLOPTION_VIDEO               "video"
113114#define SDLOPTION_SWITCHRES            "switchres"

Previous 15994 Revisions Next


© 1998-2018 The MESS Team