Fix SDL build on linux:

- removed inclusion of SDL headers in all headers.
- replaced those by forward declarations and in one case by a wrapper
class (for a typedef struct).
- added -Wno-strict-prototypes to 7z build (gmake target)
This commit is contained in:
couriersud 2016-04-09 22:19:17 +02:00
parent 887858c6ca
commit 5f6e20d6a6
8 changed files with 72 additions and 45 deletions

View File

@ -327,6 +327,7 @@ project "7z"
configuration { "gmake" }
buildoptions_c {
"-Wno-undef",
"-Wno-strict-prototypes",
}
configuration { "mingw*" }

View File

@ -14,8 +14,8 @@
#include "osdhelper.h"
#ifdef OSD_SDL
// standard SDL headers
#include "sdlinc.h"
// forward declaration
class SDL_Window;
#endif
//============================================================

View File

@ -13,6 +13,7 @@
#ifndef __SDL_GL_CONTEXT__
#define __SDL_GL_CONTEXT__
#include "sdlinc.h"
#include "modules/opengl/osd_opengl.h"
class sdl_gl_context : public osd_gl_context

View File

@ -3,8 +3,6 @@
#ifndef _osdsdl_h_
#define _osdsdl_h_
#include "sdlinc.h"
#include "watchdog.h"
#include "clifront.h"
#include "modules/lib/osdobj_common.h"

View File

@ -116,6 +116,11 @@ void sdl_osd_interface::video_exit()
// sdlvideo_monitor_refresh
//============================================================
inline osd_rect SDL_Rect_to_osd_rect(const SDL_Rect &r)
{
return osd_rect(r.x, r.y, r.w, r.h);
}
void sdl_monitor_info::refresh()
{
SDL_DisplayMode dmode;

View File

@ -18,11 +18,6 @@
// TYPE DEFINITIONS
//============================================================
inline osd_rect SDL_Rect_to_osd_rect(const SDL_Rect &r)
{
return osd_rect(r.x, r.y, r.w, r.h);
}
class sdl_monitor_info : public osd_monitor_info
{
public:

View File

@ -89,6 +89,14 @@ sdl_window_info *sdl_window_list;
static sdl_window_info **last_window_ptr;
class SDL_DM_Wrapper
{
public:
SDL_DisplayMode mode;
};
// event handling
static SDL_threadID main_threadid;
static SDL_threadID window_threadid;
@ -488,7 +496,7 @@ OSDWORK_CALLBACK( sdl_window_info::sdlwindow_toggle_full_screen_wt )
if (window->fullscreen() && (video_config.switchres || is_osx))
{
SDL_SetWindowFullscreen(window->sdl_window(), 0); // Try to set mode
SDL_SetWindowDisplayMode(window->sdl_window(), &window->m_original_mode); // Try to set mode
SDL_SetWindowDisplayMode(window->sdl_window(), &window->m_original_mode->mode); // Try to set mode
SDL_SetWindowFullscreen(window->sdl_window(), SDL_WINDOW_FULLSCREEN); // Try to set mode
}
SDL_DestroyWindow(window->sdl_window());
@ -673,7 +681,7 @@ OSDWORK_CALLBACK( sdl_window_info::sdlwindow_video_window_destroy_wt )
if (window->fullscreen() && video_config.switchres)
{
SDL_SetWindowFullscreen(window->sdl_window(), 0); // Try to set mode
SDL_SetWindowDisplayMode(window->sdl_window(), &window->m_original_mode); // Try to set mode
SDL_SetWindowDisplayMode(window->sdl_window(), &window->m_original_mode->mode); // Try to set mode
SDL_SetWindowFullscreen(window->sdl_window(), SDL_WINDOW_FULLSCREEN); // Try to set mode
}
SDL_DestroyWindow(window->sdl_window());
@ -967,7 +975,7 @@ OSDWORK_CALLBACK( sdl_window_info::complete_create_wt )
SDL_DisplayMode mode;
//SDL_GetCurrentDisplayMode(window().monitor()->handle, &mode);
SDL_GetWindowDisplayMode(window->sdl_window(), &mode);
window->m_original_mode = mode;
window->m_original_mode->mode = mode;
mode.w = temp.width();
mode.h = temp.height();
if (window->m_win_config.refresh)
@ -1319,6 +1327,16 @@ osd_dim sdl_window_info::get_min_bounds(int constrain)
return osd_dim(minwidth, minheight);
}
//============================================================
// get_size
//============================================================
osd_dim sdl_window_info::get_size()
{
int w=0; int h=0;
SDL_GetWindowSize(m_sdl_window, &w, &h);
return osd_dim(w,h);
}
//============================================================
@ -1361,3 +1379,37 @@ osd_dim sdl_window_info::get_max_bounds(int constrain)
return maximum.dim();
}
//============================================================
// construction and destruction
//============================================================
sdl_window_info::sdl_window_info(running_machine &a_machine, int index, osd_monitor_info *a_monitor,
const osd_window_config *config)
: osd_window(), m_next(NULL),
// Following three are used by input code to defer resizes
m_resize_width(0),
m_resize_height(0),
m_last_resize(0),
m_minimum_dim(0,0),
m_windowed_dim(0,0),
m_rendered_event(0), m_target(0),
m_sdl_window(NULL),
m_machine(a_machine), m_monitor(a_monitor), m_fullscreen(0)
{
m_win_config = *config;
m_index = index;
//FIXME: these should be per_window in config-> or even better a bit set
m_fullscreen = !video_config.windowed;
m_prescale = video_config.prescale;
m_windowed_dim = osd_dim(config->width, config->height);
m_original_mode = global_alloc(SDL_DM_Wrapper);
}
sdl_window_info::~sdl_window_info()
{
global_free(m_renderer);
global_free(m_original_mode);
}

View File

@ -11,7 +11,6 @@
#ifndef __SDLWINDOW__
#define __SDLWINDOW__
#include "sdlinc.h"
#include "osdsdl.h"
#include "video.h"
@ -24,6 +23,10 @@
// TYPE DEFINITIONS
//============================================================
// forward of SDL_DisplayMode not possible (typedef struct) - define wrapper
class SDL_DM_Wrapper;
typedef uintptr_t HashT;
#define OSDWORK_CALLBACK(name) void *name(void *param, ATTR_UNUSED int threadid)
@ -32,32 +35,9 @@ class sdl_window_info : public osd_window
{
public:
sdl_window_info(running_machine &a_machine, int index, osd_monitor_info *a_monitor,
const osd_window_config *config)
: osd_window(), m_next(NULL),
// Following three are used by input code to defer resizes
m_resize_width(0),
m_resize_height(0),
m_last_resize(0),
m_minimum_dim(0,0),
m_windowed_dim(0,0),
m_rendered_event(0), m_target(0),
m_sdl_window(NULL),
m_machine(a_machine), m_monitor(a_monitor), m_fullscreen(0)
{
m_win_config = *config;
m_index = index;
const osd_window_config *config);
//FIXME: these should be per_window in config-> or even better a bit set
m_fullscreen = !video_config.windowed;
m_prescale = video_config.prescale;
m_windowed_dim = osd_dim(config->width, config->height);
}
~sdl_window_info()
{
global_free(m_renderer);
}
~sdl_window_info();
int window_init();
@ -69,12 +49,7 @@ public:
void notify_changed();
osd_dim get_size() override
{
int w=0; int h=0;
SDL_GetWindowSize(m_sdl_window, &w, &h);
return osd_dim(w,h);
}
osd_dim get_size() override;
int xy_to_render_target(int x, int y, int *xt, int *yt);
@ -112,7 +87,7 @@ private:
// Needs to be here as well so we can identify window
SDL_Window *m_sdl_window;
// Original display_mode
SDL_DisplayMode m_original_mode;
SDL_DM_Wrapper *m_original_mode;
int m_extra_flags;