diff --git a/desmume/src/frontend/posix/cli/main.cpp b/desmume/src/frontend/posix/cli/main.cpp index acfc5a3e1..194245fe9 100644 --- a/desmume/src/frontend/posix/cli/main.cpp +++ b/desmume/src/frontend/posix/cli/main.cpp @@ -18,6 +18,7 @@ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include #include #include #include @@ -627,6 +628,12 @@ int main(int argc, char ** argv) { execute = true; + /* X11 multi-threading support */ + if(!XInitThreads()) + { + fprintf(stderr, "Warning: X11 not thread-safe\n"); + } + if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) { fprintf(stderr, "Error trying to initialize SDL: %s\n", diff --git a/desmume/src/frontend/posix/cli/meson.build b/desmume/src/frontend/posix/cli/meson.build index f33813d3f..d3eb234f1 100644 --- a/desmume/src/frontend/posix/cli/meson.build +++ b/desmume/src/frontend/posix/cli/meson.build @@ -1,3 +1,7 @@ +dep_x11 = dependency('x11') + +cli_dependencies = dependencies + [dep_x11] + cli_src = [ 'main.cpp', '../shared/sndsdl.cpp', @@ -13,7 +17,7 @@ includes = include_directories( executable('desmume-cli', cli_src, - dependencies: dependencies, + dependencies: cli_dependencies, include_directories: includes, link_with: libdesmume, install: true, diff --git a/desmume/src/frontend/posix/gtk/main.cpp b/desmume/src/frontend/posix/gtk/main.cpp index 3e31274d0..2ad7c43f7 100644 --- a/desmume/src/frontend/posix/gtk/main.cpp +++ b/desmume/src/frontend/posix/gtk/main.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include "types.h" @@ -4590,6 +4591,12 @@ int main (int argc, char *argv[]) my_config.parse(argc, argv); init_configured_features( &my_config); + /* X11 multi-threading support */ + if(!XInitThreads()) + { + fprintf(stderr, "Warning: X11 not thread-safe\n"); + } + // TODO: pass G_APPLICATION_HANDLES_COMMAND_LINE instead. GtkApplication *app = gtk_application_new("org.desmume.DeSmuME", G_APPLICATION_HANDLES_OPEN); g_signal_connect (app, "activate", G_CALLBACK(common_gtk_main), &my_config); diff --git a/desmume/src/frontend/posix/gtk/meson.build b/desmume/src/frontend/posix/gtk/meson.build index caceaae39..20a31da12 100644 --- a/desmume/src/frontend/posix/gtk/meson.build +++ b/desmume/src/frontend/posix/gtk/meson.build @@ -1,6 +1,7 @@ dep_gtk3 = dependency('gtk+-3.0', version: '>=3.24') +dep_x11 = dependency('x11') -gtk_dependencies = dependencies + [dep_gtk3] +gtk_dependencies = dependencies + [dep_gtk3, dep_x11] desmume_src = [ 'avout_pipe_base.cpp',