Remove GUI specifics in save function.

This commit is contained in:
Brandon Wright 2018-05-13 11:02:52 -05:00
parent 31580a5300
commit a1fa47a978
13 changed files with 28 additions and 28 deletions

View File

@ -1576,7 +1576,7 @@ S9xQueryDrivers (void)
int error_base_p, event_base_p;
int major_version, minor_version;
Display *dpy = gdk_x11_display_get_xdisplay (gtk_widget_get_display (GTK_WIDGET (top_level->get_window())));
Window xid = gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (top_level->get_window())));
Window xid = GDK_COMPAT_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (top_level->get_window())));
if (!XRRQueryExtension (dpy, &event_base_p, &error_base_p))
{

View File

@ -17,7 +17,7 @@ class S9xDisplayDriver
virtual void push_buffer (uint16 *src) = 0;
virtual void reconfigure (int width, int height) = 0;
virtual void *get_parameters (void) = 0;
virtual void save (void) = 0;
virtual void save (const char *filename) = 0;
/* Namespaced sizing constants */
static const int image_width = 1024;

View File

@ -18,7 +18,7 @@ class S9xGTKDisplayDriver : public S9xDisplayDriver
void push_buffer (uint16 *src);
void reconfigure (int width, int height);
void *get_parameters (void) { return NULL; }
void save (void) { }
void save (const char *filename) { }
private:
void clear (void);

View File

@ -284,11 +284,11 @@ S9xOpenGLDisplayDriver::get_parameters(void)
}
void
S9xOpenGLDisplayDriver::save (void)
S9xOpenGLDisplayDriver::save (const char *filename)
{
if (using_glsl_shaders && glsl_shader)
{
glsl_shader->save();
glsl_shader->save(filename);
}
return;
@ -711,7 +711,7 @@ S9xOpenGLDisplayDriver::create_window (int width, int height)
gdk_window_set_user_data (gdk_window, (gpointer) drawing_area);
gdk_window_show (gdk_window);
xwindow = gdk_x11_window_get_xid (gdk_window);
xwindow = GDK_COMPAT_WINDOW_XID (gdk_window);
output_window_width = width;
output_window_height = height;

View File

@ -40,7 +40,7 @@ class S9xOpenGLDisplayDriver : public S9xDisplayDriver
void push_buffer (uint16 *src);
void reconfigure (int width, int height);
void *get_parameters (void);
void save (void);
void save (const char *filename);
static int query_availability (void);
private:

View File

@ -65,7 +65,7 @@ S9xXVDisplayDriver::create_window (int width, int height)
gdk_window_set_user_data (gdk_window, (gpointer) drawing_area);
gdk_window_show (gdk_window);
xwindow = gdk_x11_window_get_xid (gdk_window);
xwindow = GDK_COMPAT_WINDOW_XID (gdk_window);
output_window_width = width;
output_window_height = height;

View File

@ -25,7 +25,7 @@ class S9xXVDisplayDriver : public S9xDisplayDriver
void push_buffer (uint16 *src);
void reconfigure (int width, int height);
void *get_parameters (void) { return NULL; }
void save (void) { }
void save (const char *filename) { }
static int query_availability (void);
private:

View File

@ -131,11 +131,14 @@ const char *
S9xGetDirectory (enum s9x_getdirtype dirtype)
{
static char path[PATH_MAX + 1];
char *config_dir;
switch (dirtype)
{
case HOME_DIR:
strcpy (path, getenv ("HOME"));
config_dir = get_config_dir ();
strcpy (path, config_dir);
free (config_dir);
break;
case SNAPSHOT_DIR:

View File

@ -514,7 +514,12 @@ event_shader_parameters (GtkButton *widget, gpointer data)
}
else
{
driver->save();
char *config_dir = get_config_dir();
char *config_file = new char[strlen (config_dir) + 14];
sprintf(config_file, "%s/shader.glslp", config_dir);
delete[] config_dir;
driver->save (config_file);
realpath (config_file, gui_config->fragment_shader);
preferences->set_entry_text ("fragment_shader", preferences->config->fragment_shader);
}

View File

@ -1576,8 +1576,8 @@ static double XRRGetExactRefreshRate (Display *dpy, Window window)
double
Snes9xWindow::get_refresh_rate (void)
{
Window xid = gdk_x11_window_get_xid(gtk_widget_get_window (window));
Display *dpy = gdk_x11_display_get_xdisplay(gtk_widget_get_display (window));
Window xid = GDK_COMPAT_WINDOW_XID (gtk_widget_get_window (window));
Display *dpy = gdk_x11_display_get_xdisplay (gtk_widget_get_display (window));
double refresh_rate = XRRGetExactRefreshRate (dpy, xid);
if (refresh_rate < 10.0)
@ -1652,7 +1652,7 @@ Snes9xWindow::enter_fullscreen_mode (void)
gtk_window_present (GTK_WINDOW (window));
set_bypass_compositor (gdk_x11_display_get_xdisplay (gtk_widget_get_display (GTK_WIDGET (window))),
gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (window))),
GDK_COMPAT_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window))),
1);
config->fullscreen = 1;
@ -1707,7 +1707,7 @@ Snes9xWindow::leave_fullscreen_mode (void)
gtk_window_unfullscreen (GTK_WINDOW (window));
set_bypass_compositor (gdk_x11_display_get_xdisplay (gtk_widget_get_display (GTK_WIDGET (window))),
gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (window))),
GDK_COMPAT_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window))),
0);
resize (nfs_width, nfs_height);

View File

@ -80,7 +80,7 @@ bool gtk_shader_parameters_dialog (GtkWindow *parent)
}
else
{
GtkWidget *scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, p->min, p->max, p->step);
GtkWidget *scale = gtk_hscale_new_with_range (p->min, p->max, p->step);
gtk_widget_set_hexpand (scale, TRUE);
gtk_grid_attach (GTK_GRID (grid), scale, 1, i, 1, 1);
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_RIGHT);

View File

@ -960,17 +960,12 @@ void GLSLShader::clear_shader_vars (void)
#define outs(s, v) fprintf (file, "%s%d = \"%s\"\n", s, i, v)
#define outf(s, v) fprintf (file, "%s%d = \"%f\"\n", s, i, v)
#define outd(s, v) fprintf (file, "%s%d = \"%d\"\n", s, i, v)
void GLSLShader::save (void)
void GLSLShader::save (const char *filename)
{
char *config_dir = get_config_dir();
char *config_file = new char[strlen (config_dir) + 14];
sprintf(config_file, "%s/shader.glslp", config_dir);
delete[] config_dir;
FILE *file = fopen (config_file, "wb");
FILE *file = fopen (filename, "wb");
if (!file)
{
printf ("Couldn't save shader config to %s\n", config_file);
printf ("Couldn't save shader config to %s\n", filename);
}
fprintf (file, "shaders = \"%d\"\n", (unsigned int) pass.size() - 1);
@ -1039,9 +1034,6 @@ void GLSLShader::save (void)
}
fclose (file);
realpath (config_file, gui_config->fragment_shader);
delete[] config_file;
}
#undef outf
#undef outs

View File

@ -115,7 +115,7 @@ typedef struct
const char *defines,
GLuint type,
GLuint *out);
void save (void);
void save (const char *filename);
void destroy (void);
void register_uniforms (void);